Re: How does using malloc, then memory growth work?

2023-08-07 Thread Brion Vibber
On Mon, Aug 7, 2023 at 7:52 AM 'Michael Hagar' via emscripten-discuss < emscripten-discuss@googlegroups.com> wrote: > It's mentioned in the docs here: > https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html?highlight=memory_growth#access-memory-from-javascrip

Re: embinding a templated class

2023-08-07 Thread Brion Vibber
Sample code working for me with emcc 3.1.44: #include using namespace emscripten; template class Foo { public: Foo() { m_value = 0; } void add (T value) { m_value += value; } T m_value; }; EMSCRIPTEN_BINDINGS(main) { class_>("Foo_int") .constructor<>() .function("add", &Foo::add) .property("

Re: How does using malloc, then memory growth work?

2023-08-07 Thread 'Sam Clegg' via emscripten-discuss
On Mon, Aug 7, 2023 at 7:52 AM 'Michael Hagar' via emscripten-discuss < emscripten-discuss@googlegroups.com> wrote: > It's mentioned in the docs here: > https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html?highlight=memory_growth#access-memory-from-javascrip

How does using malloc, then memory growth work?

2023-08-07 Thread 'Michael Hagar' via emscripten-discuss
It's mentioned in the docs here: https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html?highlight=memory_growth#access-memory-from-javascript That if using the ALLOW_MEMORY_GROWTH option, the JS side needs to refresh the views on the memory buffer. If I us

Re: Are the GROWABLE_HEAP_X methods only needed for pthreads + ALLOW_MEMORY_GROWTH?

2023-08-07 Thread 'Michael Hagar' via emscripten-discuss
Thanks! I haven't tested using the non-GROWABLE methods for heap access, but that's good to know they shouldn't be needed. On Friday, July 7, 2023 at 7:41:51 PM UTC-5 s...@google.com wrote: > Yes, those methods are only used/needed/present when growable memory is > combined with threads. > > Wh

embinding a templated class

2023-08-07 Thread Ronny Nissengold
Hi all! here is a compiling example of a cpp templated class: The question is is it possible to embind, for example for Foo the member function Foo::add? When trying the naiive approach it failed. Thanks! Ronny template class Foo { public: Foo() { m_value = 0; } void add (T value) { m_value +=

Re: A ctor which receives const char*

2023-08-07 Thread Ronny Nissengold
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 > #include > #include > > class Foo > { > public: > Foo(const char* a, con

Re: A ctor which receives const char*

2023-08-07 Thread 'Mike Lischke' via emscripten-discuss
> Here is the full compiling cpp code: > > #include > #include > #include > > 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

Re: embind- pass class to class

2023-08-07 Thread 'Mike Lischke' via emscripten-discuss
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

Re: A ctor which receives const char*

2023-08-07 Thread Ronny Nissengold
Here is the full compiling cpp code: #include #include #include 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