> 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/emscripten-discuss/9AE2E2FB-6CFA-47A4-8166-2E615D5ED66E%40googlemail.com.