Thanks a lot Mike! Looks like I will inherit a CTOR and use it with std::string
ב-יום שני, 7 באוגוסט 2023 בשעה 12:25:13 UTC+3, mike.l...@googlemail.com כתב/ה: > Here is the full compiling cpp code: > > #include <string> > #include <emscripten/bind.h> > #include <emscripten/val.h> > > class Foo > { > public: > Foo(const char* a, const char* b, const char* c) > { > m_a = std::string(a); > m_b = std::string(b); > m_c = std::string(c); > } > > private: > std::string m_a; > std::string m_b; > std::string m_c; > }; > > > EMSCRIPTEN_BINDINGS(FooTest) > { > emscripten::class_<Foo>("Foo"). > constructor<const char*, const char*, const char*>(); > } > > ב-יום שני, 7 באוגוסט 2023 בשעה 08:03:35 UTC+3, Shlomi Fish כתב/ה: > > > Is this supposed to be called from JS? If so, how can you provide char > pointers for the constructor, given that you only have JS strings? > > Instead use std::string for the constructor. If you cannot change that > write a helper class which takes strings and passes the data() pointer > along to the inherited c-tor. Alternatively, you can write a constructor > factory method, known as external constructor ( > https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html#external-constructors > ). > > Mike > -- > www.soft-gems.net > > -- 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 emscripten-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/e57024d7-9277-4aca-b8fa-e76f2f6975e8n%40googlegroups.com.