Debian Codegraph @

src/script/bridge/qscriptobject.cpp

raw symbols SCIP
1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtScript module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39
40 #include "config.h"
41 #include "qscriptobject_p.h"
42 #include "private/qobject_p.h"
43
44 namespace JSC
45 {
46 //QT_USE_NAMESPACE
47 ASSERT_CLASS_FITS_IN_CELL(QT_PREPEND_NAMESPACE(QScriptObject));
48 ASSERT_CLASS_FITS_IN_CELL(QT_PREPEND_NAMESPACE(QScriptObjectPrototype));
49 }
50
51 QT_BEGIN_NAMESPACE
52
53 // masquerading as JSC::JSObject
54 const JSC::ClassInfo QScriptObject::info = { "Object", 0, 0, 0 };
55
56 QScriptObject::Data::~Data()
57 {
58 delete delegate;
59 }
60
61 QScriptObject::QScriptObject(WTF::PassRefPtr<JSC::Structure> sid)
62 : JSC::JSObject(sid), d(0)
63 {
64 }
65
66 QScriptObject::~QScriptObject()
67 {
68 delete d;
69 }
70
71 bool QScriptObject::getOwnPropertySlot(JSC::ExecState* exec,
72 const JSC::Identifier& propertyName,
73 JSC::PropertySlot& slot)
74 {
75 if (!d || !d->delegate)
76 return JSC::JSObject::getOwnPropertySlot(exec, propertyName, slot);
77 return d->delegate->getOwnPropertySlot(this, exec, propertyName, slot);
78 }
79
80 bool QScriptObject::getOwnPropertyDescriptor(JSC::ExecState* exec,
81 const JSC::Identifier& propertyName,
82 JSC::PropertyDescriptor& descriptor)
83 {
84 if (!d || !d->delegate)
85 return JSC::JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
86 return d->delegate->getOwnPropertyDescriptor(this, exec, propertyName, descriptor);
87 }
88
89 void QScriptObject::put(JSC::ExecState* exec, const JSC::Identifier& propertyName,
90 JSC::JSValue value, JSC::PutPropertySlot& slot)
91 {
92 if (!d || !d->delegate) {
93 JSC::JSObject::put(exec, propertyName, value, slot);
94 return;
95 }
96 d->delegate->put(this, exec, propertyName, value, slot);
97 }
98
99 bool QScriptObject::deleteProperty(JSC::ExecState* exec,
100 const JSC::Identifier& propertyName)
101 {
102 if (!d || !d->delegate)
103 return JSC::JSObject::deleteProperty(exec, propertyName);
104 return d->delegate->deleteProperty(this, exec, propertyName);
105 }
106
107 void QScriptObject::getOwnPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames,
108 JSC::EnumerationMode mode)
109 {
110 if (!d || !d->delegate) {
111 JSC::JSObject::getOwnPropertyNames(exec, propertyNames, mode);
112 return;
113 }
114 d->delegate->getOwnPropertyNames(this, exec, propertyNames, mode);
115 }
116
117 bool QScriptObject::compareToObject(JSC::ExecState* exec, JSC::JSObject *other)
118 {
119 if (!d || !d->delegate) {
120 return JSC::JSObject::compareToObject(exec, other);
121 }
122 return d->delegate->compareToObject(this, exec, other);
123 }
124
125 void QScriptObject::markChildren(JSC::MarkStack& markStack)
126 {
127 if (!d)
128 d = new Data();
129 if (d->isMarking)
130 return;
131 QBoolBlocker markBlocker(d->isMarking, true);
132 if (d && d->data)
133 markStack.append(d->data);
134 if (!d || !d->delegate) {
135 JSC::JSObject::markChildren(markStack);
136 return;
137 }
138 d->delegate->markChildren(this, markStack);
139 }
140
141 JSC::CallType QScriptObject::getCallData(JSC::CallData &data)
142 {
143 if (!d || !d->delegate)
144 return JSC::JSObject::getCallData(data);
145 return d->delegate->getCallData(this, data);
146 }
147
148 JSC::ConstructType QScriptObject::getConstructData(JSC::ConstructData &data)
149 {
150 if (!d || !d->delegate)
151 return JSC::JSObject::getConstructData(data);
152 return d->delegate->getConstructData(this, data);
153 }
154
155 bool QScriptObject::hasInstance(JSC::ExecState* exec, JSC::JSValue value, JSC::JSValue proto)
156 {
157 if (!d || !d->delegate)
158 return JSC::JSObject::hasInstance(exec, value, proto);
159 return d->delegate->hasInstance(this, exec, value, proto);
160 }
161
162 QScriptObjectPrototype::QScriptObjectPrototype(JSC::ExecState*, WTF::PassRefPtr<JSC::Structure> structure,
163 JSC::Structure* /*prototypeFunctionStructure*/)
164 : QScriptObject(structure)
165 {
166 }
167
168 QScriptObjectDelegate::QScriptObjectDelegate()
169 {
170 }
171
172 QScriptObjectDelegate::~QScriptObjectDelegate()
173 {
174 }
175
176 bool QScriptObjectDelegate::getOwnPropertySlot(QScriptObject* object, JSC::ExecState* exec,
177 const JSC::Identifier& propertyName,
178 JSC::PropertySlot& slot)
179 {
180 return object->JSC::JSObject::getOwnPropertySlot(exec, propertyName, slot);
181 }
182
183 bool QScriptObjectDelegate::getOwnPropertyDescriptor(QScriptObject* object, JSC::ExecState* exec,
184 const JSC::Identifier& propertyName,
185 JSC::PropertyDescriptor& descriptor)
186 {
187 return object->JSC::JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
188 }
189
190
191 void QScriptObjectDelegate::put(QScriptObject* object, JSC::ExecState* exec,
192 const JSC::Identifier& propertyName,
193 JSC::JSValue value, JSC::PutPropertySlot& slot)
194 {
195 object->JSC::JSObject::put(exec, propertyName, value, slot);
196 }
197
198 bool QScriptObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState* exec,
199 const JSC::Identifier& propertyName)
200 {
201 return object->JSC::JSObject::deleteProperty(exec, propertyName);
202 }
203
204 void QScriptObjectDelegate::getOwnPropertyNames(QScriptObject* object, JSC::ExecState* exec,
205 JSC::PropertyNameArray& propertyNames,
206 JSC::EnumerationMode mode)
207 {
208 object->JSC::JSObject::getOwnPropertyNames(exec, propertyNames, mode);
209 }
210
211 void QScriptObjectDelegate::markChildren(QScriptObject* object, JSC::MarkStack& markStack)
212 {
213 // ### should this call the virtual function instead??
214 object->JSC::JSObject::markChildren(markStack);
215 }
216
217 JSC::CallType QScriptObjectDelegate::getCallData(QScriptObject* object, JSC::CallData& data)
218 {
219 return object->JSC::JSObject::getCallData(data);
220 }
221
222 JSC::ConstructType QScriptObjectDelegate::getConstructData(QScriptObject* object, JSC::ConstructData& data)
223 {
224 return object->JSC::JSObject::getConstructData(data);
225 }
226
227 bool QScriptObjectDelegate::hasInstance(QScriptObject* object, JSC::ExecState* exec,
228 JSC::JSValue value, JSC::JSValue proto)
229 {
230 return object->JSC::JSObject::hasInstance(exec, value, proto);
231 }
232
233 bool QScriptObjectDelegate::compareToObject(QScriptObject* object, JSC::ExecState* exec, JSC::JSObject* o)
234 {
235 return object->JSC::JSObject::compareToObject(exec, o);
236 }
237
238 QT_END_NAMESPACE