Hi Jules,
I have some issues with the DynamicObject class in JavaScript.
I'm trying to bridge my own Param system to Javascript using DynamicObjects. What i would like to do is forward calls on invoked DynamicObjects to my params object. See code at the end of the post.
This works fine when setting properties, so that when a user types in Params.scale = 10; It will call setProperty and i'll forward it to param->setValue, and call the base method as well.
This does not work when reading properties. So i can't do this var scale = Params.scale; In the JavaScript engine getProperty won't be called because it uses getProperties, which just directly access the NameValueSet.
if (var* prop = o->getProperties().getVarPointer (functionName)) return *prop;
So my question is, why isn't getProperty being called instead of getProperties().getVarPointer()?
If you would call getProperty it would allow us to have much more flexibility.
class JSParams : public DynamicObject { private: ra::ParamContainer::Ptr params; public: JSParams(ra::ParamContainer::Ptr params_) : params(params_) { } static Indentifier getClassName() { static const Identifier i("Params"); return i; } bool hasProperty (const Identifier& propertyName) const { return params->getParam(propertyName.toString()) != nullptr; } var getProperty (const Identifier& propertyName) const { //this never get's called! ra::ParamBase::Ptr param = params->getParam(propertyName.toString()); return param->getValue(); } void setProperty (const Identifier& propertyName, const var& newValue) { //this get's called ra::ParamBase::Ptr param = params->getParam(propertyName.toString()); param->setValue(newValue); DynamicObject::setProperty(propertyName, newValue); } };