source: trunk/src/script/bridge/qscriptobject.cpp@ 636

Last change on this file since 636 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: 8.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 "qscriptobject_p.h"
26#include "private/qobject_p.h"
27
28namespace JSC
29{
30//QT_USE_NAMESPACE
31ASSERT_CLASS_FITS_IN_CELL(QT_PREPEND_NAMESPACE(QScriptObject));
32ASSERT_CLASS_FITS_IN_CELL(QT_PREPEND_NAMESPACE(QScriptObjectPrototype));
33}
34
35QT_BEGIN_NAMESPACE
36
37// masquerading as JSC::JSObject
38const JSC::ClassInfo QScriptObject::info = { "Object", 0, 0, 0 };
39
40QScriptObject::Data::~Data()
41{
42 delete delegate;
43}
44
45QScriptObject::QScriptObject(WTF::PassRefPtr<JSC::Structure> sid)
46 : JSC::JSObject(sid), d(0)
47{
48}
49
50QScriptObject::~QScriptObject()
51{
52 delete d;
53}
54
55bool QScriptObject::getOwnPropertySlot(JSC::ExecState* exec,
56 const JSC::Identifier& propertyName,
57 JSC::PropertySlot& slot)
58{
59 if (!d || !d->delegate)
60 return JSC::JSObject::getOwnPropertySlot(exec, propertyName, slot);
61 return d->delegate->getOwnPropertySlot(this, exec, propertyName, slot);
62}
63
64bool QScriptObject::getOwnPropertyDescriptor(JSC::ExecState* exec,
65 const JSC::Identifier& propertyName,
66 JSC::PropertyDescriptor& descriptor)
67{
68 if (!d || !d->delegate)
69 return JSC::JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
70 return d->delegate->getOwnPropertyDescriptor(this, exec, propertyName, descriptor);
71}
72
73void QScriptObject::put(JSC::ExecState* exec, const JSC::Identifier& propertyName,
74 JSC::JSValue value, JSC::PutPropertySlot& slot)
75{
76 if (!d || !d->delegate) {
77 JSC::JSObject::put(exec, propertyName, value, slot);
78 return;
79 }
80 d->delegate->put(this, exec, propertyName, value, slot);
81}
82
83bool QScriptObject::deleteProperty(JSC::ExecState* exec,
84 const JSC::Identifier& propertyName,
85 bool checkDontDelete)
86{
87 if (!d || !d->delegate)
88 return JSC::JSObject::deleteProperty(exec, propertyName, checkDontDelete);
89 return d->delegate->deleteProperty(this, exec, propertyName, checkDontDelete);
90}
91
92bool QScriptObject::getPropertyAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName,
93 unsigned& attributes) const
94{
95 if (!d || !d->delegate)
96 return JSC::JSObject::getPropertyAttributes(exec, propertyName, attributes);
97 return d->delegate->getPropertyAttributes(this, exec, propertyName, attributes);
98}
99
100void QScriptObject::getOwnPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames,
101 bool includeNonEnumerable)
102{
103 if (!d || !d->delegate) {
104 JSC::JSObject::getOwnPropertyNames(exec, propertyNames, includeNonEnumerable);
105 return;
106 }
107 d->delegate->getOwnPropertyNames(this, exec, propertyNames, includeNonEnumerable);
108}
109
110bool QScriptObject::compareToObject(JSC::ExecState* exec, JSC::JSObject *other)
111{
112 if (!d || !d->delegate) {
113 return JSC::JSObject::compareToObject(exec, other);
114 }
115 return d->delegate->compareToObject(this, exec, other);
116}
117
118void QScriptObject::markChildren(JSC::MarkStack& markStack)
119{
120 if (!d)
121 d = new Data();
122 if (d->isMarking)
123 return;
124 QBoolBlocker markBlocker(d->isMarking, true);
125 if (d && d->data)
126 markStack.append(d->data);
127 if (!d || !d->delegate) {
128 JSC::JSObject::markChildren(markStack);
129 return;
130 }
131 d->delegate->markChildren(this, markStack);
132}
133
134JSC::CallType QScriptObject::getCallData(JSC::CallData &data)
135{
136 if (!d || !d->delegate)
137 return JSC::JSObject::getCallData(data);
138 return d->delegate->getCallData(this, data);
139}
140
141JSC::ConstructType QScriptObject::getConstructData(JSC::ConstructData &data)
142{
143 if (!d || !d->delegate)
144 return JSC::JSObject::getConstructData(data);
145 return d->delegate->getConstructData(this, data);
146}
147
148bool QScriptObject::hasInstance(JSC::ExecState* exec, JSC::JSValue value, JSC::JSValue proto)
149{
150 if (!d || !d->delegate)
151 return JSC::JSObject::hasInstance(exec, value, proto);
152 return d->delegate->hasInstance(this, exec, value, proto);
153}
154
155QScriptObjectPrototype::QScriptObjectPrototype(JSC::ExecState*, WTF::PassRefPtr<JSC::Structure> structure,
156 JSC::Structure* /*prototypeFunctionStructure*/)
157 : QScriptObject(structure)
158{
159}
160
161QScriptObjectDelegate::QScriptObjectDelegate()
162{
163}
164
165QScriptObjectDelegate::~QScriptObjectDelegate()
166{
167}
168
169bool QScriptObjectDelegate::getOwnPropertySlot(QScriptObject* object, JSC::ExecState* exec,
170 const JSC::Identifier& propertyName,
171 JSC::PropertySlot& slot)
172{
173 return object->JSC::JSObject::getOwnPropertySlot(exec, propertyName, slot);
174}
175
176bool QScriptObjectDelegate::getOwnPropertyDescriptor(QScriptObject* object, JSC::ExecState* exec,
177 const JSC::Identifier& propertyName,
178 JSC::PropertyDescriptor& descriptor)
179{
180 return object->JSC::JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
181}
182
183
184void QScriptObjectDelegate::put(QScriptObject* object, JSC::ExecState* exec,
185 const JSC::Identifier& propertyName,
186 JSC::JSValue value, JSC::PutPropertySlot& slot)
187{
188 object->JSC::JSObject::put(exec, propertyName, value, slot);
189}
190
191bool QScriptObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState* exec,
192 const JSC::Identifier& propertyName,
193 bool checkDontDelete)
194{
195 return object->JSC::JSObject::deleteProperty(exec, propertyName, checkDontDelete);
196}
197
198bool QScriptObjectDelegate::getPropertyAttributes(const QScriptObject* object,
199 JSC::ExecState* exec,
200 const JSC::Identifier& propertyName,
201 unsigned& attributes) const
202{
203 return object->JSC::JSObject::getPropertyAttributes(exec, propertyName, attributes);
204}
205
206void QScriptObjectDelegate::getOwnPropertyNames(QScriptObject* object, JSC::ExecState* exec,
207 JSC::PropertyNameArray& propertyNames,
208 bool includeNonEnumerable)
209{
210 object->JSC::JSObject::getOwnPropertyNames(exec, propertyNames, includeNonEnumerable);
211}
212
213void QScriptObjectDelegate::markChildren(QScriptObject* object, JSC::MarkStack& markStack)
214{
215 // ### should this call the virtual function instead??
216 object->JSC::JSObject::markChildren(markStack);
217}
218
219JSC::CallType QScriptObjectDelegate::getCallData(QScriptObject* object, JSC::CallData& data)
220{
221 return object->JSC::JSObject::getCallData(data);
222}
223
224JSC::ConstructType QScriptObjectDelegate::getConstructData(QScriptObject* object, JSC::ConstructData& data)
225{
226 return object->JSC::JSObject::getConstructData(data);
227}
228
229bool QScriptObjectDelegate::hasInstance(QScriptObject* object, JSC::ExecState* exec,
230 JSC::JSValue value, JSC::JSValue proto)
231{
232 return object->JSC::JSObject::hasInstance(exec, value, proto);
233}
234
235bool QScriptObjectDelegate::compareToObject(QScriptObject* object, JSC::ExecState* exec, JSC::JSObject* o)
236{
237 return object->JSC::JSObject::compareToObject(exec, o);
238}
239
240QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.