summaryrefslogtreecommitdiffstats
path: root/src/script/bridge/qscriptqobject.cpp
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-07-15 08:40:24 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-07-15 08:40:24 (GMT)
commit2fe8eb61d878c74674415ec32d1d0b420a7c656f (patch)
tree34cdbb0212cd7eb291cada8b9b91c9092a34f9a9 /src/script/bridge/qscriptqobject.cpp
parentb0e9dc67c7bc2ef7292e7aac20fae846ea89cccf (diff)
downloadQt-2fe8eb61d878c74674415ec32d1d0b420a7c656f.zip
Qt-2fe8eb61d878c74674415ec32d1d0b420a7c656f.tar.gz
Qt-2fe8eb61d878c74674415ec32d1d0b420a7c656f.tar.bz2
implement QObject wrapper caching (PreferExistingWrapperObject)
Diffstat (limited to 'src/script/bridge/qscriptqobject.cpp')
-rw-r--r--src/script/bridge/qscriptqobject.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp
index 0f54ec9..e668df3 100644
--- a/src/script/bridge/qscriptqobject.cpp
+++ b/src/script/bridge/qscriptqobject.cpp
@@ -1926,6 +1926,17 @@ void QObjectData::mark()
{
if (connectionManager)
connectionManager->mark();
+ {
+ QList<QScript::QObjectWrapperInfo>::iterator it;
+ for (it = wrappers.begin(); it != wrappers.end(); ) {
+ const QScript::QObjectWrapperInfo &info = *it;
+ if (info.object->marked()) {
+ ++it;
+ } else {
+ it = wrappers.erase(it);
+ }
+ }
+ }
}
bool QObjectData::addSignalHandler(QObject *sender,
@@ -1951,6 +1962,24 @@ bool QObjectData::removeSignalHandler(QObject *sender,
sender, signalIndex, receiver, slot);
}
+QScriptObject *QObjectData::findWrapper(QScriptEngine::ValueOwnership ownership,
+ const QScriptEngine::QObjectWrapOptions &options) const
+{
+ for (int i = 0; i < wrappers.size(); ++i) {
+ const QObjectWrapperInfo &info = wrappers.at(i);
+ if ((info.ownership == ownership) && (info.options == options))
+ return info.object;
+ }
+ return 0;
+}
+
+void QObjectData::registerWrapper(QScriptObject *wrapper,
+ QScriptEngine::ValueOwnership ownership,
+ const QScriptEngine::QObjectWrapOptions &options)
+{
+ wrappers.append(QObjectWrapperInfo(wrapper, ownership, options));
+}
+
} // namespace QScript
namespace JSC