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)
;
}