|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtScript module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL-ONLY$ |
|
10 ** GNU Lesser General Public License Usage |
|
11 ** This file may be used under the terms of the GNU Lesser |
|
12 ** General Public License version 2.1 as published by the Free Software |
|
13 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
14 ** packaging of this file. Please review the following information to |
|
15 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
16 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
17 ** |
|
18 ** If you have questions regarding the use of this file, please contact |
|
19 ** Nokia at qt-info@nokia.com. |
|
20 ** $QT_END_LICENSE$ |
|
21 ** |
|
22 ****************************************************************************/ |
|
23 |
|
24 #include "config.h" |
|
25 #include "qscriptglobalobject_p.h" |
|
26 |
|
27 #include "../api/qscriptengine.h" |
|
28 #include "../api/qscriptengine_p.h" |
|
29 |
|
30 namespace JSC |
|
31 { |
|
32 QT_USE_NAMESPACE |
|
33 |
|
34 ASSERT_CLASS_FITS_IN_CELL(QScript::GlobalObject); |
|
35 ASSERT_CLASS_FITS_IN_CELL(QScript::OriginalGlobalObjectProxy); |
|
36 |
|
37 } // namespace JSC |
|
38 |
|
39 QT_BEGIN_NAMESPACE |
|
40 |
|
41 namespace QScript |
|
42 { |
|
43 |
|
44 GlobalObject::GlobalObject() |
|
45 : JSC::JSGlobalObject(), customGlobalObject(0) |
|
46 { |
|
47 } |
|
48 |
|
49 GlobalObject::~GlobalObject() |
|
50 { |
|
51 } |
|
52 |
|
53 void GlobalObject::markChildren(JSC::MarkStack& markStack) |
|
54 { |
|
55 JSC::JSGlobalObject::markChildren(markStack); |
|
56 if (customGlobalObject) |
|
57 markStack.append(customGlobalObject); |
|
58 } |
|
59 |
|
60 bool GlobalObject::getOwnPropertySlot(JSC::ExecState* exec, |
|
61 const JSC::Identifier& propertyName, |
|
62 JSC::PropertySlot& slot) |
|
63 { |
|
64 QScriptEnginePrivate *engine = scriptEngineFromExec(exec); |
|
65 if (propertyName == exec->propertyNames().arguments && engine->currentFrame->argumentCount() > 0) { |
|
66 JSC::JSValue args = engine->scriptValueToJSCValue(engine->contextForFrame(engine->currentFrame)->argumentsObject()); |
|
67 slot.setValue(args); |
|
68 return true; |
|
69 } |
|
70 if (customGlobalObject) |
|
71 return customGlobalObject->getOwnPropertySlot(exec, propertyName, slot); |
|
72 return JSC::JSGlobalObject::getOwnPropertySlot(exec, propertyName, slot); |
|
73 } |
|
74 |
|
75 void GlobalObject::put(JSC::ExecState* exec, const JSC::Identifier& propertyName, |
|
76 JSC::JSValue value, JSC::PutPropertySlot& slot) |
|
77 { |
|
78 if (customGlobalObject) |
|
79 customGlobalObject->put(exec, propertyName, value, slot); |
|
80 else |
|
81 JSC::JSGlobalObject::put(exec, propertyName, value, slot); |
|
82 } |
|
83 |
|
84 void GlobalObject::putWithAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, |
|
85 JSC::JSValue value, unsigned attributes) |
|
86 { |
|
87 if (customGlobalObject) |
|
88 customGlobalObject->putWithAttributes(exec, propertyName, value, attributes); |
|
89 else |
|
90 JSC::JSGlobalObject::putWithAttributes(exec, propertyName, value, attributes); |
|
91 } |
|
92 |
|
93 bool GlobalObject::deleteProperty(JSC::ExecState* exec, |
|
94 const JSC::Identifier& propertyName, bool checkDontDelete) |
|
95 { |
|
96 if (customGlobalObject) |
|
97 return customGlobalObject->deleteProperty(exec, propertyName, checkDontDelete); |
|
98 return JSC::JSGlobalObject::deleteProperty(exec, propertyName, checkDontDelete); |
|
99 } |
|
100 |
|
101 bool GlobalObject::getPropertyAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, |
|
102 unsigned& attributes) const |
|
103 { |
|
104 if (customGlobalObject) |
|
105 return customGlobalObject->getPropertyAttributes(exec, propertyName, attributes); |
|
106 return JSC::JSGlobalObject::getPropertyAttributes(exec, propertyName, attributes); |
|
107 } |
|
108 |
|
109 void GlobalObject::getOwnPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames, |
|
110 bool includeNonEnumerable) |
|
111 { |
|
112 if (customGlobalObject) |
|
113 customGlobalObject->getOwnPropertyNames(exec, propertyNames, includeNonEnumerable); |
|
114 else |
|
115 JSC::JSGlobalObject::getOwnPropertyNames(exec, propertyNames, includeNonEnumerable); |
|
116 } |
|
117 |
|
118 void GlobalObject::defineGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes) |
|
119 { |
|
120 if (customGlobalObject) |
|
121 customGlobalObject->defineGetter(exec, propertyName, getterFunction, attributes); |
|
122 else |
|
123 JSC::JSGlobalObject::defineGetter(exec, propertyName, getterFunction, attributes); |
|
124 } |
|
125 |
|
126 void GlobalObject::defineSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes) |
|
127 { |
|
128 if (customGlobalObject) |
|
129 customGlobalObject->defineSetter(exec, propertyName, setterFunction, attributes); |
|
130 else |
|
131 JSC::JSGlobalObject::defineSetter(exec, propertyName, setterFunction, attributes); |
|
132 } |
|
133 |
|
134 JSC::JSValue GlobalObject::lookupGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName) |
|
135 { |
|
136 if (customGlobalObject) |
|
137 return customGlobalObject->lookupGetter(exec, propertyName); |
|
138 return JSC::JSGlobalObject::lookupGetter(exec, propertyName); |
|
139 } |
|
140 |
|
141 JSC::JSValue GlobalObject::lookupSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName) |
|
142 { |
|
143 if (customGlobalObject) |
|
144 return customGlobalObject->lookupSetter(exec, propertyName); |
|
145 return JSC::JSGlobalObject::lookupSetter(exec, propertyName); |
|
146 } |
|
147 |
|
148 } // namespace QScript |
|
149 |
|
150 QT_END_NAMESPACE |