summaryrefslogtreecommitdiffstats
path: root/src/script/bridge/qscriptactivationobject.cpp
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-14 12:05:25 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-14 12:05:25 (GMT)
commite0a86dc604b87921652b844a5f85889bb6291ed9 (patch)
treeedc084c4e047dfc1724d76adc8bb65ae9ca0be19 /src/script/bridge/qscriptactivationobject.cpp
parent61c303e8bab04312c17ad2ee03e9ba3f29a0184b (diff)
downloadQt-e0a86dc604b87921652b844a5f85889bb6291ed9.zip
Qt-e0a86dc604b87921652b844a5f85889bb6291ed9.tar.gz
Qt-e0a86dc604b87921652b844a5f85889bb6291ed9.tar.bz2
make it possible for any script object to serve as activation object
This was possible in the old back-end. In JSC, activation objects have to be instances of JSC::JSVariableObject. So the way we solve it is by having our QScriptActivationObject be able to act as a proxy to any other JSObject.
Diffstat (limited to 'src/script/bridge/qscriptactivationobject.cpp')
-rw-r--r--src/script/bridge/qscriptactivationobject.cpp58
1 files changed, 56 insertions, 2 deletions
diff --git a/src/script/bridge/qscriptactivationobject.cpp b/src/script/bridge/qscriptactivationobject.cpp
index ae466e8..5faf7fe 100644
--- a/src/script/bridge/qscriptactivationobject.cpp
+++ b/src/script/bridge/qscriptactivationobject.cpp
@@ -63,8 +63,9 @@ namespace QScript
const JSC::ClassInfo QScriptActivationObject::info = { "QScriptActivationObject", 0, 0, 0 };
-QScriptActivationObject::QScriptActivationObject(JSC::ExecState *callFrame)
- : JSC::JSVariableObject(callFrame->globalData().activationStructure, new QScriptActivationObjectData(callFrame->registers()))
+QScriptActivationObject::QScriptActivationObject(JSC::ExecState *callFrame, JSC::JSObject *delegate)
+ : JSC::JSVariableObject(callFrame->globalData().activationStructure,
+ new QScriptActivationObjectData(callFrame->registers(), delegate))
{
}
@@ -73,8 +74,36 @@ QScriptActivationObject::~QScriptActivationObject()
delete d;
}
+bool QScriptActivationObject::getOwnPropertySlot(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertySlot& slot)
+{
+ if (d_ptr()->delegate != 0)
+ return d_ptr()->delegate->getOwnPropertySlot(exec, propertyName, slot);
+ return JSC::JSVariableObject::getOwnPropertySlot(exec, propertyName, slot);
+}
+
+bool QScriptActivationObject::getPropertyAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, unsigned& attributes) const
+{
+ if (d_ptr()->delegate != 0)
+ return d_ptr()->delegate->getPropertyAttributes(exec, propertyName, attributes);
+ return JSC::JSVariableObject::getPropertyAttributes(exec, propertyName, attributes);
+}
+
+void QScriptActivationObject::getPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames, unsigned listedAttributes)
+{
+ if (d_ptr()->delegate != 0) {
+ d_ptr()->delegate->getPropertyNames(exec, propertyNames, listedAttributes);
+ return;
+ }
+ return JSC::JSVariableObject::getPropertyNames(exec, propertyNames, listedAttributes);
+}
+
void QScriptActivationObject::putWithAttributes(JSC::ExecState *exec, const JSC::Identifier &propertyName, JSC::JSValue value, unsigned attributes)
{
+ if (d_ptr()->delegate != 0) {
+ d_ptr()->delegate->putWithAttributes(exec, propertyName, value, attributes);
+ return;
+ }
+
if (symbolTablePutWithAttributes(propertyName, value, attributes))
return;
@@ -82,6 +111,31 @@ void QScriptActivationObject::putWithAttributes(JSC::ExecState *exec, const JSC:
JSObject::putWithAttributes(exec, propertyName, value, attributes, true, slot);
}
+void QScriptActivationObject::put(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue value, JSC::PutPropertySlot& slot)
+{
+ if (d_ptr()->delegate != 0) {
+ d_ptr()->delegate->put(exec, propertyName, value, slot);
+ return;
+ }
+ JSC::JSVariableObject::put(exec, propertyName, value, slot);
+}
+
+void QScriptActivationObject::put(JSC::ExecState* exec, unsigned propertyName, JSC::JSValue value)
+{
+ if (d_ptr()->delegate != 0) {
+ d_ptr()->delegate->put(exec, propertyName, value);
+ return;
+ }
+ JSC::JSVariableObject::put(exec, propertyName, value);
+}
+
+bool QScriptActivationObject::deleteProperty(JSC::ExecState* exec, const JSC::Identifier& propertyName, bool checkDontDelete)
+{
+ if (d_ptr()->delegate != 0)
+ return d_ptr()->delegate->deleteProperty(exec, propertyName, checkDontDelete);
+ return JSC::JSVariableObject::deleteProperty(exec, propertyName, checkDontDelete);
+}
+
} // namespace QScript
QT_END_NAMESPACE