Hi everyone,

I have trolled the internet for the last 3 days and is unable to find 
anything that would help, therefore the question here:

In JS, I would like to pass an array of objects like so:

Module.myFunction([{x: 10, y: 10}, {x: 5, y: 5}]);

where the array of objects is of dynamic size.

I am able to use EMBIND, specifically EMSCRTIPTEN_BINDINGS but only to bind 
an object or an array of fixed size using value_object or value_aray.

struct PT {
    float x;
    float y;
};

PT EMSCRIPTEN_KEEPALIVE myFunction(std::vector<PT> &points, int count) {
    PT p = PT();

    p.x = points[0].x++;
    p.y = points[0].y++;
}

EMSCRIPTEN_BINDINGS(test) {
    value_object<PT>("PT")
        .field("x", &SEG::x)
        .field("y", &SEG::y)
        ;

    function("myFunction", &myFunction);

    register_vector<SEG>("vector<SEG>");
}

Since the object array size is dynamic, my question is, is the HEAP and 
copying over the data to the heap, the only way to pass these dynamic array 
of objects?

Thanks in advance for your help!

-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to