summaryrefslogtreecommitdiffstats
path: root/src/script/api
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-07-27 12:10:30 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-07-27 12:10:30 (GMT)
commitc068efe3b63508e9a805674ac787e23a953ca5cb (patch)
tree26fca9084a7c31a198d36054cb349a391d824b9a /src/script/api
parentba2432acf72a0649f0f841759a61ec246c5a9b1f (diff)
downloadQt-c068efe3b63508e9a805674ac787e23a953ca5cb.zip
Qt-c068efe3b63508e9a805674ac787e23a953ca5cb.tar.gz
Qt-c068efe3b63508e9a805674ac787e23a953ca5cb.tar.bz2
introduce scriptEngineFromExec() helper function
No need to expose the fact that we go via the Global Object to get an engine pointer.
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/qscriptengine.cpp27
-rw-r--r--src/script/api/qscriptengine_p.h27
2 files changed, 27 insertions, 27 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 524a250..7ffb178 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -307,6 +307,29 @@ public:
namespace QScript
{
+
+class GlobalObject : public JSC::JSGlobalObject
+{
+public:
+ GlobalObject(QScriptEnginePrivate*);
+ virtual ~GlobalObject();
+ virtual JSC::UString className() const { return "global"; }
+ virtual void mark();
+ virtual bool getOwnPropertySlot(JSC::ExecState*,
+ const JSC::Identifier& propertyName,
+ JSC::PropertySlot&);
+ virtual void put(JSC::ExecState* exec, const JSC::Identifier& propertyName,
+ JSC::JSValue, JSC::PutPropertySlot&);
+ virtual bool deleteProperty(JSC::ExecState*,
+ const JSC::Identifier& propertyName);
+ virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier&,
+ unsigned&) const;
+ virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);
+
+public:
+ QScriptEnginePrivate *engine;
+};
+
static int toDigit(char c)
{
if ((c >= '0') && (c <= '9'))
@@ -387,6 +410,10 @@ QString qtStringFromJSCUString(const JSC::UString &str)
return QString(reinterpret_cast<const QChar*>(str.data()), str.size());
}
+QScriptEnginePrivate *scriptEngineFromExec(JSC::ExecState *exec)
+{
+ return static_cast<QScript::GlobalObject*>(exec->lexicalGlobalObject())->engine;
+}
bool isFunction(JSC::JSValue value)
{
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index e6db40e..b7109b0 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -196,33 +196,6 @@ public:
#endif
};
-namespace QScript
-{
-
-class GlobalObject : public JSC::JSGlobalObject
-{
-public:
- GlobalObject(QScriptEnginePrivate*);
- virtual ~GlobalObject();
- virtual JSC::UString className() const { return "global"; }
- virtual void mark();
- virtual bool getOwnPropertySlot(JSC::ExecState*,
- const JSC::Identifier& propertyName,
- JSC::PropertySlot&);
- virtual void put(JSC::ExecState* exec, const JSC::Identifier& propertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
- virtual bool deleteProperty(JSC::ExecState*,
- const JSC::Identifier& propertyName);
- virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier&,
- unsigned&) const;
- virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);
-
-public:
- QScriptEnginePrivate *engine;
-};
-
-} // namespace QScript
-
QT_END_NAMESPACE
#endif // QT_NO_SCRIPT