Qt 4.8
qscriptobject.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtScript module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL-ONLY$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser
11 ** General Public License version 2.1 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.LGPL included in the
13 ** packaging of this file. Please review the following information to
14 ** ensure the GNU Lesser General Public License version 2.1 requirements
15 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** If you have questions regarding the use of this file, please contact
18 ** us via http://www.qt-project.org/.
19 **
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
33 }
34 
36 
37 // masquerading as JSC::JSObject
38 const JSC::ClassInfo QScriptObject::info = { "Object", 0, 0, 0 };
39 
41 {
42  delete delegate;
43 }
44 
45 QScriptObject::QScriptObject(WTF::PassRefPtr<JSC::Structure> sid)
46  : JSC::JSObject(sid), d(0)
47 {
48 }
49 
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 bool 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 
73 void 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 
83 bool QScriptObject::deleteProperty(JSC::ExecState* exec,
84  const JSC::Identifier& propertyName)
85 {
86  if (!d || !d->delegate)
87  return JSC::JSObject::deleteProperty(exec, propertyName);
88  return d->delegate->deleteProperty(this, exec, propertyName);
89 }
90 
91 void QScriptObject::getOwnPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames,
92  JSC::EnumerationMode mode)
93 {
94  if (!d || !d->delegate) {
95  JSC::JSObject::getOwnPropertyNames(exec, propertyNames, mode);
96  return;
97  }
98  d->delegate->getOwnPropertyNames(this, exec, propertyNames, mode);
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 
153 {
154 }
155 
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 
168  const JSC::Identifier& propertyName,
169  JSC::PropertyDescriptor& descriptor)
170 {
171  return object->JSC::JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
172 }
173 
174 
175 void QScriptObjectDelegate::put(QScriptObject* object, JSC::ExecState* exec,
176  const JSC::Identifier& propertyName,
177  JSC::JSValue value, JSC::PutPropertySlot& slot)
178 {
179  object->JSC::JSObject::put(exec, propertyName, value, slot);
180 }
181 
182 bool QScriptObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState* exec,
183  const JSC::Identifier& propertyName)
184 {
185  return object->JSC::JSObject::deleteProperty(exec, propertyName);
186 }
187 
189  JSC::PropertyNameArray& propertyNames,
190  JSC::EnumerationMode mode)
191 {
192  object->JSC::JSObject::getOwnPropertyNames(exec, propertyNames, mode);
193 }
194 
195 void QScriptObjectDelegate::markChildren(QScriptObject* object, JSC::MarkStack& markStack)
196 {
197  // ### should this call the virtual function instead??
198  object->JSC::JSObject::markChildren(markStack);
199 }
200 
201 JSC::CallType QScriptObjectDelegate::getCallData(QScriptObject* object, JSC::CallData& data)
202 {
203  return object->JSC::JSObject::getCallData(data);
204 }
205 
206 JSC::ConstructType QScriptObjectDelegate::getConstructData(QScriptObject* object, JSC::ConstructData& data)
207 {
208  return object->JSC::JSObject::getConstructData(data);
209 }
210 
211 bool QScriptObjectDelegate::hasInstance(QScriptObject* object, JSC::ExecState* exec,
212  JSC::JSValue value, JSC::JSValue proto)
213 {
214  return object->JSC::JSObject::hasInstance(exec, value, proto);
215 }
216 
217 bool QScriptObjectDelegate::compareToObject(QScriptObject* object, JSC::ExecState* exec, JSC::JSObject* o)
218 {
219  return object->JSC::JSObject::compareToObject(exec, o);
220 }
221 
double d
Definition: qnumeric_p.h:62
virtual JSC::ConstructType getConstructData(QScriptObject *, JSC::ConstructData &)
virtual bool deleteProperty(QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName)
virtual void getOwnPropertyNames(QScriptObject *, JSC::ExecState *, JSC::PropertyNameArray &, JSC::EnumerationMode mode=JSC::ExcludeDontEnumProperties)
virtual bool getOwnPropertySlot(JSC::ExecState *, const JSC::Identifier &propertyName, JSC::PropertySlot &)
virtual bool hasInstance(QScriptObject *, JSC::ExecState *, JSC::JSValue value, JSC::JSValue proto)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
ASSERT_CLASS_FITS_IN_CELL(::QScript::QScriptActivationObject)
virtual void markChildren(QScriptObject *, JSC::MarkStack &markStack)
virtual bool compareToObject(QScriptObject *, JSC::ExecState *, JSC::JSObject *)
virtual bool getOwnPropertyDescriptor(QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName, JSC::PropertyDescriptor &)
static const JSC::ClassInfo info
virtual void put(QScriptObject *, JSC::ExecState *exec, const JSC::Identifier &propertyName, JSC::JSValue, JSC::PutPropertySlot &)
virtual bool deleteProperty(JSC::ExecState *, const JSC::Identifier &propertyName)
virtual bool getOwnPropertyDescriptor(JSC::ExecState *, const JSC::Identifier &, JSC::PropertyDescriptor &)
virtual bool hasInstance(JSC::ExecState *, JSC::JSValue value, JSC::JSValue proto)
virtual void getOwnPropertyNames(JSC::ExecState *, JSC::PropertyNameArray &, JSC::EnumerationMode mode=JSC::ExcludeDontEnumProperties)
virtual bool compareToObject(JSC::ExecState *, JSC::JSObject *)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
JSC::JSValue data() const
virtual void put(JSC::ExecState *exec, const JSC::Identifier &propertyName, JSC::JSValue, JSC::PutPropertySlot &)
virtual ~QScriptObjectDelegate()
#define QT_PREPEND_NAMESPACE(name)
This macro qualifies identifier with the full namespace.
Definition: qglobal.h:87
virtual JSC::CallType getCallData(JSC::CallData &)
virtual ~QScriptObject()
QScriptObjectPrototype(JSC::ExecState *, WTF::PassRefPtr< JSC::Structure >, JSC::Structure *prototypeFunctionStructure)
virtual bool getOwnPropertySlot(QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName, JSC::PropertySlot &)
QScriptObjectDelegate * delegate
QScriptObject(WTF::PassRefPtr< JSC::Structure > sid)
virtual JSC::ConstructType getConstructData(JSC::ConstructData &)
virtual void markChildren(JSC::MarkStack &markStack)
virtual JSC::CallType getCallData(QScriptObject *, JSC::CallData &)