source: trunk/src/script/bridge/qscriptglobalobject.cpp@ 573

Last change on this file since 573 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

  • Property svn:eol-style set to native
File size: 5.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
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 [email protected].
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
30namespace JSC
31{
32QT_USE_NAMESPACE
33
34ASSERT_CLASS_FITS_IN_CELL(QScript::GlobalObject);
35ASSERT_CLASS_FITS_IN_CELL(QScript::OriginalGlobalObjectProxy);
36
37} // namespace JSC
38
39QT_BEGIN_NAMESPACE
40
41namespace QScript
42{
43
44GlobalObject::GlobalObject()
45 : JSC::JSGlobalObject(), customGlobalObject(0)
46{
47}
48
49GlobalObject::~GlobalObject()
50{
51}
52
53void GlobalObject::markChildren(JSC::MarkStack& markStack)
54{
55 JSC::JSGlobalObject::markChildren(markStack);
56 if (customGlobalObject)
57 markStack.append(customGlobalObject);
58}
59
60bool 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
75void 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
84void 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
93bool 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
101bool 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
109void 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
118void 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
126void 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
134JSC::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
141JSC::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
150QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.