|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 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$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "config.h" |
|
43 #include "qscriptglobalobject_p.h" |
|
44 |
|
45 #include "../api/qscriptengine.h" |
|
46 #include "../api/qscriptengine_p.h" |
|
47 |
|
48 namespace JSC |
|
49 { |
|
50 QT_USE_NAMESPACE |
|
51 |
|
52 ASSERT_CLASS_FITS_IN_CELL(QScript::GlobalObject); |
|
53 ASSERT_CLASS_FITS_IN_CELL(QScript::OriginalGlobalObjectProxy); |
|
54 |
|
55 } // namespace JSC |
|
56 |
|
57 QT_BEGIN_NAMESPACE |
|
58 |
|
59 namespace QScript |
|
60 { |
|
61 |
|
62 GlobalObject::GlobalObject() |
|
63 : JSC::JSGlobalObject(), customGlobalObject(0) |
|
64 { |
|
65 } |
|
66 |
|
67 GlobalObject::~GlobalObject() |
|
68 { |
|
69 } |
|
70 |
|
71 void GlobalObject::markChildren(JSC::MarkStack& markStack) |
|
72 { |
|
73 JSC::JSGlobalObject::markChildren(markStack); |
|
74 if (customGlobalObject) |
|
75 markStack.append(customGlobalObject); |
|
76 } |
|
77 |
|
78 bool GlobalObject::getOwnPropertySlot(JSC::ExecState* exec, |
|
79 const JSC::Identifier& propertyName, |
|
80 JSC::PropertySlot& slot) |
|
81 { |
|
82 QScriptEnginePrivate *engine = scriptEngineFromExec(exec); |
|
83 if (propertyName == exec->propertyNames().arguments && engine->currentFrame->argumentCount() > 0) { |
|
84 JSC::JSValue args = engine->scriptValueToJSCValue(engine->contextForFrame(engine->currentFrame)->argumentsObject()); |
|
85 slot.setValue(args); |
|
86 return true; |
|
87 } |
|
88 if (customGlobalObject) |
|
89 return customGlobalObject->getOwnPropertySlot(exec, propertyName, slot); |
|
90 return JSC::JSGlobalObject::getOwnPropertySlot(exec, propertyName, slot); |
|
91 } |
|
92 |
|
93 void GlobalObject::put(JSC::ExecState* exec, const JSC::Identifier& propertyName, |
|
94 JSC::JSValue value, JSC::PutPropertySlot& slot) |
|
95 { |
|
96 if (customGlobalObject) |
|
97 customGlobalObject->put(exec, propertyName, value, slot); |
|
98 else |
|
99 JSC::JSGlobalObject::put(exec, propertyName, value, slot); |
|
100 } |
|
101 |
|
102 void GlobalObject::putWithAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, |
|
103 JSC::JSValue value, unsigned attributes) |
|
104 { |
|
105 if (customGlobalObject) |
|
106 customGlobalObject->putWithAttributes(exec, propertyName, value, attributes); |
|
107 else |
|
108 JSC::JSGlobalObject::putWithAttributes(exec, propertyName, value, attributes); |
|
109 } |
|
110 |
|
111 bool GlobalObject::deleteProperty(JSC::ExecState* exec, |
|
112 const JSC::Identifier& propertyName, bool checkDontDelete) |
|
113 { |
|
114 if (customGlobalObject) |
|
115 return customGlobalObject->deleteProperty(exec, propertyName, checkDontDelete); |
|
116 return JSC::JSGlobalObject::deleteProperty(exec, propertyName, checkDontDelete); |
|
117 } |
|
118 |
|
119 bool GlobalObject::getPropertyAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, |
|
120 unsigned& attributes) const |
|
121 { |
|
122 if (customGlobalObject) |
|
123 return customGlobalObject->getPropertyAttributes(exec, propertyName, attributes); |
|
124 return JSC::JSGlobalObject::getPropertyAttributes(exec, propertyName, attributes); |
|
125 } |
|
126 |
|
127 void GlobalObject::getOwnPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames, |
|
128 bool includeNonEnumerable) |
|
129 { |
|
130 if (customGlobalObject) |
|
131 customGlobalObject->getOwnPropertyNames(exec, propertyNames, includeNonEnumerable); |
|
132 else |
|
133 JSC::JSGlobalObject::getOwnPropertyNames(exec, propertyNames, includeNonEnumerable); |
|
134 } |
|
135 |
|
136 void GlobalObject::defineGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes) |
|
137 { |
|
138 if (customGlobalObject) |
|
139 customGlobalObject->defineGetter(exec, propertyName, getterFunction, attributes); |
|
140 else |
|
141 JSC::JSGlobalObject::defineGetter(exec, propertyName, getterFunction, attributes); |
|
142 } |
|
143 |
|
144 void GlobalObject::defineSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes) |
|
145 { |
|
146 if (customGlobalObject) |
|
147 customGlobalObject->defineSetter(exec, propertyName, setterFunction, attributes); |
|
148 else |
|
149 JSC::JSGlobalObject::defineSetter(exec, propertyName, setterFunction, attributes); |
|
150 } |
|
151 |
|
152 JSC::JSValue GlobalObject::lookupGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName) |
|
153 { |
|
154 if (customGlobalObject) |
|
155 return customGlobalObject->lookupGetter(exec, propertyName); |
|
156 return JSC::JSGlobalObject::lookupGetter(exec, propertyName); |
|
157 } |
|
158 |
|
159 JSC::JSValue GlobalObject::lookupSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName) |
|
160 { |
|
161 if (customGlobalObject) |
|
162 return customGlobalObject->lookupSetter(exec, propertyName); |
|
163 return JSC::JSGlobalObject::lookupSetter(exec, propertyName); |
|
164 } |
|
165 |
|
166 } // namespace QScript |
|
167 |
|
168 QT_END_NAMESPACE |