wowserhq / stormjs

StormLib for Javascript, powered by Emscripten
MIT License
14 stars 6 forks source link

Refactor: Clean up pointer utilities #22

Closed fallenoak closed 6 years ago

fallenoak commented 6 years ago

Prep work for implementation of #6. Permits passing in nullptr from the JS side when calling bound functions.

StormLib has several functions with optional arguments. These arguments can either be, for example, uint32_t* or nullptr. If you want to get the value placed in an optional argument, you'd pass in a valid pointer. If you don't care, you'd pass in a nullptr (and skip a stack allocation).

Embind doesn't really deal with pointers at all, which is why we have the EmPtr classes. With this refactor, in the example above, you'd pass in either an instance of StormLib.Uint32Ptr or the constant StormLib.NULLPTR.

Closes #21