This is how i did it using EM_ASM_( ) this_.objects is a JS array of
objects I can refer to by numeric index from C

https://github.com/d3x0r/jsox-wasm/blob/master/simple_js.c#L273-L279

On Tue, May 19, 2020 at 1:07 PM gerald-dotcom <[email protected]> wrote:

> I was able to do following,
>
>     emscripten::val ExampleObject = emscripten::val::object();
>     ExampleObjectset("key", value);
>
> It is working, but is this correct way to create native Objects in
> emscripten?
>
> On Tuesday, May 19, 2020 at 2:06:21 PM UTC-5, gerald-dotcom wrote:
>>
>> I haven't seen a single example of embind::val that pass Object Key Value
>> Pair as an Argument to JavaScript Functions.
>>
>> Therefore, I decided to try by structuring JSON-style string with C++ and
>> passing it as an argument to that specific function,
>>
>> '{' + std::string("brandId") + ':' + std::to_string(brandId) + '}'
>> However, the Javascript run time not recognize it as an valid Object
>> instead it being parsed as a String literal.
>>
>> While I'm new to C++, I got slight memory about Struct data type and I
>> decided to give it try, but even though I can pass Struct as an Argument,
>> at run time, it trigger following error,
>>
>> parameter 1 has unknown type
>> Z9getCarBrandiNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEiE10brandStruct
>>
> --
> 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/ef9f8051-a026-4dae-8572-b26794cbc4e7%40googlegroups.com
> <https://groups.google.com/d/msgid/emscripten-discuss/ef9f8051-a026-4dae-8572-b26794cbc4e7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAA2GJqW4eO0YM_8m-npwjSXvOUzqrk3eVWHHAzxaN0nxtQOyPQ%40mail.gmail.com.

Reply via email to