Changes between Version 1 and Version 2 of QtScript


Ignore:
Timestamp:
Jul 27, 2010 10:42:59 AM (14 years ago)
Author:
kent.hansen@nokia.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • QtScript

    v1 v2  
    2929    * '''Static (QMetaObject) properties'''. Returns an accessor (get/set functions) for the property, not the actual value.
    3030    * '''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.
    3333    * '''Named child objects'''. Returns a wrapper object for the child.
    3434 * Writing:
     
    9292One limitation of the QtScript signal & slot mechanism is that it doesn't provide a way to force a queued connection.
    9393
     94C++ API related to QtScript connections: QScriptEngine::signalHandlerException(), qScriptConnect() and qScriptDisconnect().
     95
     96=== Built-in QObject Prototype Object ===
     97
     98QtScript provides a QObject prototype object which provides the functions findChild(), findChildren(), and toString() (since these functions are not slots).
     99
    94100=== Handling QObject Deletion ===
    95101
    96102It's possible that a wrapped QObject is deleted "behind our back", i.e. outside the QtScript environment.
    97103To 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
     107See 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
     111Meta-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.
    98112
    99113=== Implementation Concerns & Ideas ===
     
    112126
    113127Second, 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.