Hi,
In that code:
class Foo : public DynamicObject { public: Foo( ) { setMethod("hello", Foo::hello); } static var hello(const var::NativeFunctionArgs& args) { if (dynamic_cast<Foo*>(args.thisObject.getObject( ))) { DBG("Good"); } else { DBG("Bad"); } return var::undefined(); } }; int main (int argc, char* argv[]) { ScopedPointer<JavascriptEngine> mJS(new JavascriptEngine( )); mJS->registerNativeObject("Foo", new Foo( )); mJS->execute("var o = new Foo( ); o.hello( ); Foo.hello( )"); return 0; }
MacBook-de-nicolas:debug nicolas$ ./Foo JUCE v3.0.2 Bad Good
Executing "Foo.hello( )", args.thisObject can be dynamic_cast to Foo whereas with "o.hello( )" it can not.
I can not figure which kind of object is passed to the function in the second case (a DynamicObject?).