DynamicObject woes


#1

How was the override of hasProperty/setProperty/getProperty supposed to be used?

I thought I’d be able to override them to provide properties from another source, but it doesn’t appear to be as simple as that. If I call object.some_property from the javascript neither hasProperty nor getProperty are actually called…


#2

Getting the properties doesn’t really work that well. Jules previously answered on this issue that the JavaScriptEngine tends to read the properties directly from a NamedValueSet, not by calling the getProperty method of the DynamicObject. Which makes the DynamicObject properties not so useful if the properties have some dynamically changing data source. (Like audio transport position or GUI window size etc…)

I suppose the solution currently is to just add annoying get and set methods for script object properties. Hello C++, in JavaScript world.


#3

Ah - that’s what I was thinking must be happening from a quick skim of the source code. Is there some speed advantage to this or could it just be adjusted so the hasProperty stuff works in a way that’s useful to me ? :slight_smile:


#4

Jules mentioned he was using the NamedValueSet directly and not calling getProperty or hasProperty for speed reasons. Would be very nice if this would change, i would like to be able to override those methods for use in the JavasScriptEngine.


#5

Jules - any views on this one?


#6

I vaguely remember looking into this very briefly, but not seeing any easy way to do it. Happy to review any suggestions that people want to give, but it’s critically important that any changes wouldn’t affect the performance of a property lookup in a var, as that would have a huge impact on code that doesn’t use JS but which works with ValueTrees.


#7

How about having accesses to data in the DynamicObject class use functions that can be overloaded, rather than the java script engine diving into the private data via a reference to the NamedValueSet? It might impact the performance of the javascript but wouldn’t break anything else?


#8

Sure, if there’s a place to do this that only impacts JS performance, then that’s totally fine. Can’t remember offhand how it all works though…