I think if you have a binding defined, you can create the object in C++ and
then pass it to JS through the call method on an emscripten::val carrying a
function callback.

This should run your object through the bindings and create the JS proxy
object as expected, whereas if you call a JS library function directly
you'll just get the raw pointer value.

-- brion
On Jul 30, 2015 4:26 AM, "Jason Kempster" <[email protected]> wrote:

> Hi
>
> I'm using EMSCRIPTEN_BINDINGS to bind a C++ class. Im my JavaScript code
> all works well and I can do new Module.MyClass()
>
> What I would like to do is initialise the class in my C++ code, pass the
> pointer to JavaScript and then call methods on that instance.
>
> I have a hacky version working like this:
>
> jsTest: function(self) {
>
>         var instance = new Module.Assets();
>         instance.$$.ptr = self;
>         instance.loadingDone();
>     }
>
> This will call loadingDone on my instance created in my C++ code with the
> instance pointer passed to the JavaScript function as self
>
> Does anyone know how I can do this properly?
>
> Thanks
>
> --
> 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.

Reply via email to