Re: embind- pass class to class

15 views
Skip to first unread message

Mike Lischke

unread,
Aug 7, 2023, 5:18:59 AM8/7/23
to emscripte...@googlegroups.com
Hi Ronny,

Is it possible using the current EMBIND to pass one CPP class to another?
For example:
Here I tried constructing class Bar in the same binding declaration as Foo, and construct a Bar using Foo.
Is it possible at all, and if yes how?
Thanks
Ronny


EMSCRIPTEN_BINDINGS(Test) {
emscripten::class_<Foo>("Foo").
constructor<const char*, const char*, const char*>().
emscripten::class_<Bar>("Bar").
constructor<Foo>();
}

Sure is it possible, if you pass in the class as raw or smart pointer:

EMSCRIPTEN_BINDINGS(Test) {
emscripten::class_<Foo>("Foo").
constructor<const char*, const char*, const char*>();

emscripten::class_<Bar>("Bar").
constructor<Foo *>();
}

Watch out to terminate a class declaration properly. If I'm not wrong then you cannot bind a new class to the result of a constructor call of a previous class.


Reply all
Reply to author
Forward
0 new messages