mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-30 02:50:05 +00:00
DynamicObject: Make virtual functions non-virtual
This commit is contained in:
parent
46c2a95905
commit
ef31cbb620
2 changed files with 41 additions and 7 deletions
|
|
@ -2,6 +2,40 @@
|
|||
|
||||
# Version 8.0.1
|
||||
|
||||
## Change
|
||||
|
||||
All member functions of DynamicObject other than clone() and writeAsJSON() have
|
||||
been made non-virtual.
|
||||
|
||||
**Possible Issues**
|
||||
|
||||
Classes that override these functions will fail to compile.
|
||||
|
||||
**Workaround**
|
||||
|
||||
Instead of overriding hasMethod() and invokeMethod(), call setMethod() to
|
||||
add new member functions.
|
||||
|
||||
Instead of overriding getProperty() to return a custom property, add that
|
||||
property using setProperty().
|
||||
|
||||
**Rationale**
|
||||
|
||||
Allowing the implementations of these functions to be changed may cause derived
|
||||
types to accidentally break the invariants of the DynamicObject type.
|
||||
Specifically, the results of hasMethod() and hasProperty() must be consistent
|
||||
with the result of getProperties(). Additiionally, calling getProperty() should
|
||||
return the same var as fetching the property through getProperties(), and
|
||||
calling invokeMethod() should behave the same way as retrieving and invoking a
|
||||
NativeFunction via getProperties().
|
||||
|
||||
More concretely, the new QuickJS-based Javascript engine requires that all
|
||||
methods/properties are declared explicitly, which cannot be mapped to the more
|
||||
open-ended invokeMethod() API taking an arbitrary method name. Making
|
||||
invokeMethod() non-virtual forces users to add methods with setMethod() instead
|
||||
of overriding invokeMethod(), which is more compatible with QuickJS.
|
||||
|
||||
|
||||
## Change
|
||||
|
||||
The LowLevelGraphicsPostscriptRenderer has been removed.
|
||||
|
|
|
|||
|
|
@ -62,18 +62,18 @@ public:
|
|||
/** Returns true if the object has a property with this name.
|
||||
Note that if the property is actually a method, this will return false.
|
||||
*/
|
||||
virtual bool hasProperty (const Identifier& propertyName) const;
|
||||
bool hasProperty (const Identifier& propertyName) const;
|
||||
|
||||
/** Returns a named property.
|
||||
This returns var() if no such property exists.
|
||||
*/
|
||||
virtual const var& getProperty (const Identifier& propertyName) const;
|
||||
const var& getProperty (const Identifier& propertyName) const;
|
||||
|
||||
/** Sets a named property. */
|
||||
virtual void setProperty (const Identifier& propertyName, const var& newValue);
|
||||
void setProperty (const Identifier& propertyName, const var& newValue);
|
||||
|
||||
/** Removes a named property. */
|
||||
virtual void removeProperty (const Identifier& propertyName);
|
||||
void removeProperty (const Identifier& propertyName);
|
||||
|
||||
//==============================================================================
|
||||
/** Checks whether this object has the specified method.
|
||||
|
|
@ -82,7 +82,7 @@ public:
|
|||
with this name that's actually a method, but this can be overridden for
|
||||
building objects with dynamic invocation.
|
||||
*/
|
||||
virtual bool hasMethod (const Identifier& methodName) const;
|
||||
bool hasMethod (const Identifier& methodName) const;
|
||||
|
||||
/** Invokes a named method on this object.
|
||||
|
||||
|
|
@ -92,8 +92,8 @@ public:
|
|||
This method is virtual to allow more dynamic invocation to used for objects
|
||||
where the methods may not already be set as properties.
|
||||
*/
|
||||
virtual var invokeMethod (Identifier methodName,
|
||||
const var::NativeFunctionArgs& args);
|
||||
var invokeMethod (Identifier methodName,
|
||||
const var::NativeFunctionArgs& args);
|
||||
|
||||
/** Adds a method to the class.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue