Hi Aaron!

>From JavaScript's perspective, what would you like getTest to return?  A
single float value?  A JavaScript array?  A proxy for the memory in the
Emscripten heap with some kind of accessor methods?

The meaning of a pointer is ambiguous enough that embind doesn't even try
to assume a particular interpretation.


On Sat, Sep 13, 2014 at 10:52 PM, Aaron <wanmm...@gmail.com> wrote:

> Dear All
>
>       I am new to emscripten, and I have read the docs and test it, it is
> amazing for me.
>       But I have a question, I copy the demo and add a new function to
> return float*, then bind it and compile it.
>      All the things here are ok.
>
>      But when I invoke the getTest() in js, I got the UnboundTypeError:
> Cannot call MyClass.getM due to unbound types: Pf
>      How can I fix it?
>
>      The codes:
>
> class MyClass {public:
>     MyClass(int x, std::string y)
>         : x(x)
>         , y(y)
>     {
>      test[0] = 0;
>      test[1] = 0;
>      }
>
>     void incrementX() {
>         ++x;
>     }
>
>     int getX() const { return x; }
>     void setX(int x_) { x = x_; }
>     float* getTest() {return test;}
>     static std::string getStringFromInstance(const MyClass& instance) {
>         return instance.y;
>     }
> private:
>     int x;
>     std::string y;
>     float test[2];
>  };
> EMSCRIPTEN_BINDINGS(my_class_example) {
>     class_<MyClass>("MyClass")
>         .constructor<int, std::string>()
>         .function("incrementX", &MyClass::incrementX)
>         .function("getTest", &MyClass::getTest, allow_raw_pointers())
>         .property("x", &MyClass::getX, &MyClass::setX)
>         .class_function("getStringFromInstance", 
> &MyClass::getStringFromInstance)
>         ;}
>
>  --
> 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 emscripten-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Chad Austin
Technical Director, IMVU
http://engineering.imvu.com <http://www.imvu.com/members/Chad/>
http://chadaustin.me

-- 
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 emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to