It depends what you mean. A pointer in emscripten (in general) is just an integer. So it's fine to pass pointers into and out of compiled code, including WebIDL glue. The WebIDL glue does add functionality on top, by converting a return value of a wrapped class into a JS object wrapper. It also handles an input parameter that is a JS object wrapper, converting it into the integer for the compiled method underneath (it's also fine to just pass that integer as a parameter).
On Tue, Oct 25, 2016 at 10:32 PM, Philipp Gloor <[email protected]> wrote: > OK thanks. And did I understand correctly that pointers only work for > non-primitive data types? > > On 26 October 2016 at 00:11, Alon Zakai <[email protected]> wrote: > >> Yes, WebIDL focuses on simple types that map directly to JS (numbers, >> pointers, etc). embind has more functionality for sophisticated mappings of >> C++ classes, like std::vector. >> >> On Tue, Oct 25, 2016 at 2:39 PM, Philipp Gloor <[email protected]> >> wrote: >> >>> I have a C++ function that should return a vector of doubles but on the >>> WebIDL >>> doc page >>> <https://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/WebIDL-Binder.html> >>> I >>> found nothing that could help me. >>> >>> The header file: >>> >>> #ifndef __JSAPI_H__ >>> #define __JSAPI_H__ >>> >>> #include <string> >>> #include "annotation.h" >>> >>> class JSAPI >>> { >>> Annotation* annotations; >>> public: >>> char* getAnnotContent(int annotID); >>> std::vector<double> getAnnotRect(int annotID); >>> >>> }; >>> >>> #endif >>> >>> And the implementation >>> >>> #include "jsapi.h" >>> >>> >>> char* JSAPI::getAnnotContent(int annotID) >>> { >>> return annotations[annotID].content; >>> } >>> >>> std::vector<double> JSAPI::getAnnotRect(int annotID) >>> { >>> return annotations[annotID].rect; >>> } >>> >>> And I'm looking for the proper definition of >>> >>> interface JSAPI >>> { >>> void JSAPI(); >>> DOMString getAnnotContent(long annotID); >>> std::vector<double> getAnnotRect(long annotID); >>> }; >>> >>> Is something like this even possible? Or do I need to switch to embind >>> for this? >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "emscripten-discuss" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "emscripten-discuss" group. >> To unsubscribe from this topic, visit https://groups.google.com/d/to >> pic/emscripten-discuss/18GjJeGOq08/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
