Changes between Version 1 and Version 2 of QtScript
- Timestamp:
- Jul 27, 2010, 10:42:59 AM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
QtScript
v1 v2 29 29 * '''Static (QMetaObject) properties'''. Returns an accessor (get/set functions) for the property, not the actual value. 30 30 * '''Dynamic (QObject::dynamicPropertyNames()) properties'''. Returns the property's value, converted from QVariant. 31 * '''Meta-methods (signals, slots) by name'''. Returns a method wrapper object. 32 * '''Meta-methods (signals, slots) by signature'''. Returns a method wrapper object.31 * '''Meta-methods (signals, slots) by name'''. Returns a method wrapper object. Private slots are not exposed (but protected are). 32 * '''Meta-methods (signals, slots) by signature'''. Ditto. 33 33 * '''Named child objects'''. Returns a wrapper object for the child. 34 34 * Writing: … … 92 92 One limitation of the QtScript signal & slot mechanism is that it doesn't provide a way to force a queued connection. 93 93 94 C++ API related to QtScript connections: QScriptEngine::signalHandlerException(), qScriptConnect() and qScriptDisconnect(). 95 96 === Built-in QObject Prototype Object === 97 98 QtScript provides a QObject prototype object which provides the functions findChild(), findChildren(), and toString() (since these functions are not slots). 99 94 100 === Handling QObject Deletion === 95 101 96 102 It's possible that a wrapped QObject is deleted "behind our back", i.e. outside the QtScript environment. 97 103 To detect this, QtScript stores the QObject* in a QPointer. Trying to perform an operation (e.g. property access) on a wrapper object whose underlying C++ object has been deleted will cause an error to be thrown. 104 105 === QScriptable === 106 107 See http://doc.trolltech.com/qscriptable.html. Basically, if a QObject subclasses QScriptable, a field will be set in the QObject that makes it possible for the C++ property accessor or slot to inspect how it was called from JS (the this-object, the original arguments, etc.). This is typically used to implement a QObject-based prototype object. 108 109 === Transferable Meta-Methods === 110 111 Meta-method wrappers are transferable; for example, "myQObject.deleteLater.apply(myQWidget)", where myQObject is a QObject and myQWidget is a QWidget, will call myQWidget's deleteLater() slot. 98 112 99 113 === Implementation Concerns & Ideas === … … 112 126 113 127 Second, in order to obtain the meta-types for the return type and arguments, some costly operations are performed: 1) The parameter types are extracted using QMetaMethod::parameterTypes(). 2) The type names are resolved to meta-type ids using QMetaType::type(). At least for built-in types (it's not safe for custom types because they can be unregistered), this information could be computed once and cached. 128 129 '''Supporting QScriptable''': The string-based (slow) QObject::qt_metacast() is used to determine if the object implements the QScriptable interface. This is done per method call / property access. This information should also be cached in the meta-method/property wrapper if possible.