summaryrefslogtreecommitdiffstats
path: root/src/script
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-18 12:26:14 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-18 12:26:14 (GMT)
commit91cb5464a35d2f461644677973ffdcc91985e7fd (patch)
tree91707880b76513c7a43a4de22b97ea5f2c98d226 /src/script
parenta2af6621a00cf0be03077132a271b2620a725bee (diff)
downloadQt-91cb5464a35d2f461644677973ffdcc91985e7fd.zip
Qt-91cb5464a35d2f461644677973ffdcc91985e7fd.tar.gz
Qt-91cb5464a35d2f461644677973ffdcc91985e7fd.tar.bz2
implement getter/setter proxying for Global Object and activation object
Diffstat (limited to 'src/script')
-rw-r--r--src/script/bridge/qscriptactivationobject.cpp30
-rw-r--r--src/script/bridge/qscriptactivationobject_p.h5
-rw-r--r--src/script/bridge/qscriptglobalobject.cpp30
-rw-r--r--src/script/bridge/qscriptglobalobject_p.h12
4 files changed, 77 insertions, 0 deletions
diff --git a/src/script/bridge/qscriptactivationobject.cpp b/src/script/bridge/qscriptactivationobject.cpp
index 5faf7fe..a8a2181 100644
--- a/src/script/bridge/qscriptactivationobject.cpp
+++ b/src/script/bridge/qscriptactivationobject.cpp
@@ -136,6 +136,36 @@ bool QScriptActivationObject::deleteProperty(JSC::ExecState* exec, const JSC::Id
return JSC::JSVariableObject::deleteProperty(exec, propertyName, checkDontDelete);
}
+void QScriptActivationObject::defineGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction)
+{
+ if (d_ptr()->delegate != 0)
+ d_ptr()->delegate->defineGetter(exec, propertyName, getterFunction);
+ else
+ JSC::JSVariableObject::defineGetter(exec, propertyName, getterFunction);
+}
+
+void QScriptActivationObject::defineSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction)
+{
+ if (d_ptr()->delegate != 0)
+ d_ptr()->delegate->defineSetter(exec, propertyName, setterFunction);
+ else
+ JSC::JSVariableObject::defineSetter(exec, propertyName, setterFunction);
+}
+
+JSC::JSValue QScriptActivationObject::lookupGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName)
+{
+ if (d_ptr()->delegate != 0)
+ return d_ptr()->delegate->lookupGetter(exec, propertyName);
+ return JSC::JSVariableObject::lookupGetter(exec, propertyName);
+}
+
+JSC::JSValue QScriptActivationObject::lookupSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName)
+{
+ if (d_ptr()->delegate != 0)
+ return d_ptr()->delegate->lookupSetter(exec, propertyName);
+ return JSC::JSVariableObject::lookupSetter(exec, propertyName);
+}
+
} // namespace QScript
QT_END_NAMESPACE
diff --git a/src/script/bridge/qscriptactivationobject_p.h b/src/script/bridge/qscriptactivationobject_p.h
index fd7b0be..cb28341 100644
--- a/src/script/bridge/qscriptactivationobject_p.h
+++ b/src/script/bridge/qscriptactivationobject_p.h
@@ -78,6 +78,11 @@ public:
virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier& propertyName, bool checkDontDelete = true);
+ virtual void defineGetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction);
+ virtual void defineSetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction);
+ virtual JSC::JSValue lookupGetter(JSC::ExecState*, const JSC::Identifier& propertyName);
+ virtual JSC::JSValue lookupSetter(JSC::ExecState*, const JSC::Identifier& propertyName);
+
virtual const JSC::ClassInfo* classInfo() const { return &info; }
static const JSC::ClassInfo info;
diff --git a/src/script/bridge/qscriptglobalobject.cpp b/src/script/bridge/qscriptglobalobject.cpp
index 5f374ed..eb8673e 100644
--- a/src/script/bridge/qscriptglobalobject.cpp
+++ b/src/script/bridge/qscriptglobalobject.cpp
@@ -123,6 +123,36 @@ void GlobalObject::getPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray
JSC::JSGlobalObject::getPropertyNames(exec, propertyNames, listedAttributes);
}
+void GlobalObject::defineGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction)
+{
+ if (customGlobalObject)
+ customGlobalObject->defineGetter(exec, propertyName, getterFunction);
+ else
+ JSC::JSGlobalObject::defineGetter(exec, propertyName, getterFunction);
+}
+
+void GlobalObject::defineSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction)
+{
+ if (customGlobalObject)
+ customGlobalObject->defineSetter(exec, propertyName, setterFunction);
+ else
+ JSC::JSGlobalObject::defineSetter(exec, propertyName, setterFunction);
+}
+
+JSC::JSValue GlobalObject::lookupGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName)
+{
+ if (customGlobalObject)
+ return customGlobalObject->lookupGetter(exec, propertyName);
+ return JSC::JSGlobalObject::lookupGetter(exec, propertyName);
+}
+
+JSC::JSValue GlobalObject::lookupSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName)
+{
+ if (customGlobalObject)
+ return customGlobalObject->lookupSetter(exec, propertyName);
+ return JSC::JSGlobalObject::lookupSetter(exec, propertyName);
+}
+
} // namespace QScript
QT_END_NAMESPACE
diff --git a/src/script/bridge/qscriptglobalobject_p.h b/src/script/bridge/qscriptglobalobject_p.h
index 5365a21..673f7f6 100644
--- a/src/script/bridge/qscriptglobalobject_p.h
+++ b/src/script/bridge/qscriptglobalobject_p.h
@@ -81,6 +81,10 @@ public:
unsigned&) const;
virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&,
unsigned listedAttributes = JSC::Structure::Prototype);
+ virtual void defineGetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction);
+ virtual void defineSetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction);
+ virtual JSC::JSValue lookupGetter(JSC::ExecState*, const JSC::Identifier& propertyName);
+ virtual JSC::JSValue lookupSetter(JSC::ExecState*, const JSC::Identifier& propertyName);
public:
JSC::JSObject *customGlobalObject;
@@ -120,6 +124,14 @@ public:
virtual void getPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames,
unsigned listedAttributes = JSC::Structure::Prototype)
{ originalGlobalObject->JSC::JSGlobalObject::getPropertyNames(exec, propertyNames, listedAttributes); }
+ virtual void defineGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction)
+ { originalGlobalObject->JSC::JSGlobalObject::defineGetter(exec, propertyName, getterFunction); }
+ virtual void defineSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction)
+ { originalGlobalObject->JSC::JSGlobalObject::defineSetter(exec, propertyName, setterFunction); }
+ virtual JSC::JSValue lookupGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName)
+ { return originalGlobalObject->JSC::JSGlobalObject::lookupGetter(exec, propertyName); }
+ virtual JSC::JSValue lookupSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName)
+ { return originalGlobalObject->JSC::JSGlobalObject::lookupSetter(exec, propertyName); }
private:
JSC::JSGlobalObject *originalGlobalObject;
};