kripken/emscripten-site

Embind documentation for smart pointers is out of date.

Grayson opened this issue · 1 comments

I have been recently attempting to support communication between the JS and C++ layer of code and was following through the embind documentation. I ran into a problem when implementing smart pointers (shared_ptr). The documentation is, if not incorrect, then so minimal as to be misleading. I was able to find a solution for using smart pointers from the test suite, but I think some attention to the documentation would help alleviate problems for future developers.

Ideally, I think the documentation for smart pointers should convey the following information:

  • A corrected example that calls smart_ptr_constructor with the appropriate parameters. I found that I needed or provide a name parameter as the first argument in my use case. This was not indicated by the documentation.
  • An example of creating a smart pointer in Javascript.
  • An example of passing a smart pointer from Javascript to C++.

I think that correcting any errors and providing examples in these areas would greatly lower the barrier to making use of smart pointers.

For further consideration, I also think a discussion on the parameters taken in smart_ptr_constructor and for what they are used, an example with a class that takes parameters in its constructor, an example of a class with multiple constructors, and some more discussion on unique pointers and smart_ptr_traits would be appreciated and make this portion of the documentation feel more complete.

This repo is just for the site itself, the docs are in the main emscripten repo. Best to file this there, and add the label "embind".