author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 02 Feb 2010 00:43:10 +0200 | |
changeset 3 | 41300fa6a67c |
parent 0 | 1918ee327afb |
child 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 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 |
** |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
9 |
** $QT_BEGIN_LICENSE:LGPL-ONLY$ |
0 | 10 |
** GNU Lesser General Public License Usage |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
11 |
** This file may be used under the terms of the GNU Lesser |
0 | 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 "qscriptobject_p.h" |
|
26 |
#include "private/qobject_p.h" |
|
27 |
||
28 |
namespace JSC |
|
29 |
{ |
|
30 |
//QT_USE_NAMESPACE |
|
31 |
ASSERT_CLASS_FITS_IN_CELL(QT_PREPEND_NAMESPACE(QScriptObject)); |
|
32 |
ASSERT_CLASS_FITS_IN_CELL(QT_PREPEND_NAMESPACE(QScriptObjectPrototype)); |
|
33 |
} |
|
34 |
||
35 |
QT_BEGIN_NAMESPACE |
|
36 |
||
37 |
// masquerading as JSC::JSObject |
|
38 |
const JSC::ClassInfo QScriptObject::info = { "Object", 0, 0, 0 }; |
|
39 |
||
40 |
QScriptObject::Data::~Data() |
|
41 |
{ |
|
42 |
delete delegate; |
|
43 |
} |
|
44 |
||
45 |
QScriptObject::QScriptObject(WTF::PassRefPtr<JSC::Structure> sid) |
|
46 |
: JSC::JSObject(sid), d(0) |
|
47 |
{ |
|
48 |
} |
|
49 |
||
50 |
QScriptObject::~QScriptObject() |
|
51 |
{ |
|
52 |
delete d; |
|
53 |
} |
|
54 |
||
55 |
bool 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 |
||
64 |
void QScriptObject::put(JSC::ExecState* exec, const JSC::Identifier& propertyName, |
|
65 |
JSC::JSValue value, JSC::PutPropertySlot& slot) |
|
66 |
{ |
|
67 |
if (!d || !d->delegate) { |
|
68 |
JSC::JSObject::put(exec, propertyName, value, slot); |
|
69 |
return; |
|
70 |
} |
|
71 |
d->delegate->put(this, exec, propertyName, value, slot); |
|
72 |
} |
|
73 |
||
74 |
bool QScriptObject::deleteProperty(JSC::ExecState* exec, |
|
75 |
const JSC::Identifier& propertyName, |
|
76 |
bool checkDontDelete) |
|
77 |
{ |
|
78 |
if (!d || !d->delegate) |
|
79 |
return JSC::JSObject::deleteProperty(exec, propertyName, checkDontDelete); |
|
80 |
return d->delegate->deleteProperty(this, exec, propertyName, checkDontDelete); |
|
81 |
} |
|
82 |
||
83 |
bool QScriptObject::getPropertyAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, |
|
84 |
unsigned& attributes) const |
|
85 |
{ |
|
86 |
if (!d || !d->delegate) |
|
87 |
return JSC::JSObject::getPropertyAttributes(exec, propertyName, attributes); |
|
88 |
return d->delegate->getPropertyAttributes(this, exec, propertyName, attributes); |
|
89 |
} |
|
90 |
||
91 |
void QScriptObject::getOwnPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames, |
|
92 |
bool includeNonEnumerable) |
|
93 |
{ |
|
94 |
if (!d || !d->delegate) { |
|
95 |
JSC::JSObject::getOwnPropertyNames(exec, propertyNames, includeNonEnumerable); |
|
96 |
return; |
|
97 |
} |
|
98 |
d->delegate->getOwnPropertyNames(this, exec, propertyNames, includeNonEnumerable); |
|
99 |
} |
|
100 |
||
101 |
bool QScriptObject::compareToObject(JSC::ExecState* exec, JSC::JSObject *other) |
|
102 |
{ |
|
103 |
if (!d || !d->delegate) { |
|
104 |
return JSC::JSObject::compareToObject(exec, other); |
|
105 |
} |
|
106 |
return d->delegate->compareToObject(this, exec, other); |
|
107 |
} |
|
108 |
||
109 |
void QScriptObject::markChildren(JSC::MarkStack& markStack) |
|
110 |
{ |
|
111 |
if (!d) |
|
112 |
d = new Data(); |
|
113 |
if (d->isMarking) |
|
114 |
return; |
|
115 |
QBoolBlocker markBlocker(d->isMarking, true); |
|
116 |
if (d && d->data) |
|
117 |
markStack.append(d->data); |
|
118 |
if (!d || !d->delegate) { |
|
119 |
JSC::JSObject::markChildren(markStack); |
|
120 |
return; |
|
121 |
} |
|
122 |
d->delegate->markChildren(this, markStack); |
|
123 |
} |
|
124 |
||
125 |
JSC::CallType QScriptObject::getCallData(JSC::CallData &data) |
|
126 |
{ |
|
127 |
if (!d || !d->delegate) |
|
128 |
return JSC::JSObject::getCallData(data); |
|
129 |
return d->delegate->getCallData(this, data); |
|
130 |
} |
|
131 |
||
132 |
JSC::ConstructType QScriptObject::getConstructData(JSC::ConstructData &data) |
|
133 |
{ |
|
134 |
if (!d || !d->delegate) |
|
135 |
return JSC::JSObject::getConstructData(data); |
|
136 |
return d->delegate->getConstructData(this, data); |
|
137 |
} |
|
138 |
||
139 |
bool QScriptObject::hasInstance(JSC::ExecState* exec, JSC::JSValue value, JSC::JSValue proto) |
|
140 |
{ |
|
141 |
if (!d || !d->delegate) |
|
142 |
return JSC::JSObject::hasInstance(exec, value, proto); |
|
143 |
return d->delegate->hasInstance(this, exec, value, proto); |
|
144 |
} |
|
145 |
||
146 |
QScriptObjectPrototype::QScriptObjectPrototype(JSC::ExecState*, WTF::PassRefPtr<JSC::Structure> structure, |
|
147 |
JSC::Structure* /*prototypeFunctionStructure*/) |
|
148 |
: QScriptObject(structure) |
|
149 |
{ |
|
150 |
} |
|
151 |
||
152 |
QScriptObjectDelegate::QScriptObjectDelegate() |
|
153 |
{ |
|
154 |
} |
|
155 |
||
156 |
QScriptObjectDelegate::~QScriptObjectDelegate() |
|
157 |
{ |
|
158 |
} |
|
159 |
||
160 |
bool QScriptObjectDelegate::getOwnPropertySlot(QScriptObject* object, JSC::ExecState* exec, |
|
161 |
const JSC::Identifier& propertyName, |
|
162 |
JSC::PropertySlot& slot) |
|
163 |
{ |
|
164 |
return object->JSC::JSObject::getOwnPropertySlot(exec, propertyName, slot); |
|
165 |
} |
|
166 |
||
167 |
void QScriptObjectDelegate::put(QScriptObject* object, JSC::ExecState* exec, |
|
168 |
const JSC::Identifier& propertyName, |
|
169 |
JSC::JSValue value, JSC::PutPropertySlot& slot) |
|
170 |
{ |
|
171 |
object->JSC::JSObject::put(exec, propertyName, value, slot); |
|
172 |
} |
|
173 |
||
174 |
bool QScriptObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState* exec, |
|
175 |
const JSC::Identifier& propertyName, |
|
176 |
bool checkDontDelete) |
|
177 |
{ |
|
178 |
return object->JSC::JSObject::deleteProperty(exec, propertyName, checkDontDelete); |
|
179 |
} |
|
180 |
||
181 |
bool QScriptObjectDelegate::getPropertyAttributes(const QScriptObject* object, |
|
182 |
JSC::ExecState* exec, |
|
183 |
const JSC::Identifier& propertyName, |
|
184 |
unsigned& attributes) const |
|
185 |
{ |
|
186 |
return object->JSC::JSObject::getPropertyAttributes(exec, propertyName, attributes); |
|
187 |
} |
|
188 |
||
189 |
void QScriptObjectDelegate::getOwnPropertyNames(QScriptObject* object, JSC::ExecState* exec, |
|
190 |
JSC::PropertyNameArray& propertyNames, |
|
191 |
bool includeNonEnumerable) |
|
192 |
{ |
|
193 |
object->JSC::JSObject::getOwnPropertyNames(exec, propertyNames, includeNonEnumerable); |
|
194 |
} |
|
195 |
||
196 |
void QScriptObjectDelegate::markChildren(QScriptObject* object, JSC::MarkStack& markStack) |
|
197 |
{ |
|
198 |
// ### should this call the virtual function instead?? |
|
199 |
object->JSC::JSObject::markChildren(markStack); |
|
200 |
} |
|
201 |
||
202 |
JSC::CallType QScriptObjectDelegate::getCallData(QScriptObject* object, JSC::CallData& data) |
|
203 |
{ |
|
204 |
return object->JSC::JSObject::getCallData(data); |
|
205 |
} |
|
206 |
||
207 |
JSC::ConstructType QScriptObjectDelegate::getConstructData(QScriptObject* object, JSC::ConstructData& data) |
|
208 |
{ |
|
209 |
return object->JSC::JSObject::getConstructData(data); |
|
210 |
} |
|
211 |
||
212 |
bool QScriptObjectDelegate::hasInstance(QScriptObject* object, JSC::ExecState* exec, |
|
213 |
JSC::JSValue value, JSC::JSValue proto) |
|
214 |
{ |
|
215 |
return object->JSC::JSObject::hasInstance(exec, value, proto); |
|
216 |
} |
|
217 |
||
218 |
bool QScriptObjectDelegate::compareToObject(QScriptObject* object, JSC::ExecState* exec, JSC::JSObject* o) |
|
219 |
{ |
|
220 |
return object->JSC::JSObject::compareToObject(exec, o); |
|
221 |
} |
|
222 |
||
223 |
QT_END_NAMESPACE |