- The documentation sucks a bit at the moment – I found that the best way to experiment was to use the xpcshell REPL. I’m sure this will be fixed in time for Firefox 4.0.
- The js-ctypes type hierarchy makes complete sense. I haven’t used any other equivalents (python ctypes, .NET P/Invoke), but I hope they’re similar.
- Declaring Win32 types and functions is simple enough – just look them up on MSDN. Declaring constants can be harder, since not all constant values are provided on MSDN. To get some of them, I had to resort to grepping the Microsoft SDK include directory, and in a couple of cases writing and compiling small C programs to print the value.
- Comparing pointers is annoying. That was probably what I spent the most time figuring out. I ultimately cast my
intptr_tand worked with its value, which is a
0x80000000 | 0x40000000 = –0x40000000and not
0xC0000000. This impacts how bit flags work. Ways to avoid this include adding up the flags instead (as long as you know all the flags you’re adding are mutually exclusive) or simply using the composite flag.