The WebIDL binder can already support that. The input parameter would be a JS object wrapping the C++ object.
On Thu, Sep 24, 2015 at 1:28 AM, Alexey Solovey <[email protected]> wrote: > I think about support like this (not pointer): > void setObject(Bike a); > > > четверг, 24 сентября 2015 г., 2:20:07 UTC+8 пользователь Alon Zakai > написал: >> >> This should definitely work. And with something like the WebIDL binder, >> C++ objects can look very much like JS objects, including method calls too. >> Basically Typed Objects will let us enhance the WebIDL wrapper objects so >> they have fast property accesses. >> >> A concern though is alignment, we would need to make sure that it matches >> the object layouts in emscripten output. >> >> Regarding pointers, they would be just integers. What kind of special >> support did you have in mind for them? >> >> On Wed, Sep 23, 2015 at 8:29 AM, Alexey Solovey <[email protected]> wrote: >> >>> Sorry for wrong link. >>> http://wiki.ecmascript.org/doku.php?id=harmony:typed_objects >>> >>> среда, 23 сентября 2015 г., 23:22:52 UTC+8 пользователь Alexey Solovey >>> написал: >>> >>>> What you think about typed objects support/using with Emscripten? >>>> http://wiki.ecmascript.org/doku.php?id=harmony:proxies >>>> >>>> I tried polyfill with Emscripten allocated memory. But I want native >>>> browser support, for knowing what will with pointers. >>>> >>>> Sample JS: >>>> >>>> const Bike = new TypedObjects.StructType({ >>>> top: TypedObjects.int32, >>>> bottom: TypedObjects.int32 >>>> }); >>>> >>>> var adr = Module._malloc(8); >>>> var a = new Bike(Module.buffer, adr); >>>> a.top = 100; >>>> a.bottom = 10; >>>> >>>> var setObject = Module.cwrap('setObject', 'number', ['number']); >>>> setObject(adr); >>>> >>>> Sample C: >>>> >>>> #include <stdio.h> >>>> >>>> typedef struct{ >>>> int top; >>>> int bottom; >>>> } Bike; >>>> >>>> //Use pointer >>>> Bike * getObject(int top, int bottom){ >>>> Bike a; >>>> a.top = top; >>>> a.bottom = bottom; >>>> Bike * b = &a; >>>> return b; >>>> } >>>> >>>> //Use pointer >>>> void setObject(Bike * a){ >>>> printf("%d\n", a->top); >>>> printf("%d\n", a->bottom); >>>> } >>>> >>> -- >>> 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. >>> >> >> -- > 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. > -- 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.
