1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtScript module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL-ONLY$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
43 #include "qscriptobject_p.h"
44 #include "private/qobject_p.h"
49 ASSERT_CLASS_FITS_IN_CELL(QT_PREPEND_NAMESPACE(QScriptObject
));
50 ASSERT_CLASS_FITS_IN_CELL(QT_PREPEND_NAMESPACE(QScriptObjectPrototype
));
55 // masquerading as JSC::JSObject
56 const JSC::ClassInfo
QScriptObject::info
= { "Object", 0, 0, 0 };
58 QScriptObject::Data::~Data()
63 QScriptObject::QScriptObject(WTF::PassRefPtr
<JSC::Structure
> sid
)
64 : JSC::JSObject(sid
), d(0)
68 QScriptObject::~QScriptObject()
73 bool QScriptObject::getOwnPropertySlot(JSC::ExecState
* exec
,
74 const JSC::Identifier
& propertyName
,
75 JSC::PropertySlot
& slot
)
77 if (!d
|| !d
->delegate
)
78 return JSC::JSObject::getOwnPropertySlot(exec
, propertyName
, slot
);
79 return d
->delegate
->getOwnPropertySlot(this, exec
, propertyName
, slot
);
82 void QScriptObject::put(JSC::ExecState
* exec
, const JSC::Identifier
& propertyName
,
83 JSC::JSValue value
, JSC::PutPropertySlot
& slot
)
85 if (!d
|| !d
->delegate
) {
86 JSC::JSObject::put(exec
, propertyName
, value
, slot
);
89 d
->delegate
->put(this, exec
, propertyName
, value
, slot
);
92 bool QScriptObject::deleteProperty(JSC::ExecState
* exec
,
93 const JSC::Identifier
& propertyName
,
96 if (!d
|| !d
->delegate
)
97 return JSC::JSObject::deleteProperty(exec
, propertyName
, checkDontDelete
);
98 return d
->delegate
->deleteProperty(this, exec
, propertyName
, checkDontDelete
);
101 bool QScriptObject::getPropertyAttributes(JSC::ExecState
* exec
, const JSC::Identifier
& propertyName
,
102 unsigned& attributes
) const
104 if (!d
|| !d
->delegate
)
105 return JSC::JSObject::getPropertyAttributes(exec
, propertyName
, attributes
);
106 return d
->delegate
->getPropertyAttributes(this, exec
, propertyName
, attributes
);
109 void QScriptObject::getOwnPropertyNames(JSC::ExecState
* exec
, JSC::PropertyNameArray
& propertyNames
,
110 bool includeNonEnumerable
)
112 if (!d
|| !d
->delegate
) {
113 JSC::JSObject::getOwnPropertyNames(exec
, propertyNames
, includeNonEnumerable
);
116 d
->delegate
->getOwnPropertyNames(this, exec
, propertyNames
, includeNonEnumerable
);
119 bool QScriptObject::compareToObject(JSC::ExecState
* exec
, JSC::JSObject
*other
)
121 if (!d
|| !d
->delegate
) {
122 return JSC::JSObject::compareToObject(exec
, other
);
124 return d
->delegate
->compareToObject(this, exec
, other
);
127 void QScriptObject::markChildren(JSC::MarkStack
& markStack
)
133 QBoolBlocker
markBlocker(d
->isMarking
, true);
135 markStack
.append(d
->data
);
136 if (!d
|| !d
->delegate
) {
137 JSC::JSObject::markChildren(markStack
);
140 d
->delegate
->markChildren(this, markStack
);
143 JSC::CallType
QScriptObject::getCallData(JSC::CallData
&data
)
145 if (!d
|| !d
->delegate
)
146 return JSC::JSObject::getCallData(data
);
147 return d
->delegate
->getCallData(this, data
);
150 JSC::ConstructType
QScriptObject::getConstructData(JSC::ConstructData
&data
)
152 if (!d
|| !d
->delegate
)
153 return JSC::JSObject::getConstructData(data
);
154 return d
->delegate
->getConstructData(this, data
);
157 bool QScriptObject::hasInstance(JSC::ExecState
* exec
, JSC::JSValue value
, JSC::JSValue proto
)
159 if (!d
|| !d
->delegate
)
160 return JSC::JSObject::hasInstance(exec
, value
, proto
);
161 return d
->delegate
->hasInstance(this, exec
, value
, proto
);
164 QScriptObjectPrototype::QScriptObjectPrototype(JSC::ExecState
*, WTF::PassRefPtr
<JSC::Structure
> structure
,
165 JSC::Structure
* /*prototypeFunctionStructure*/)
166 : QScriptObject(structure
)
170 QScriptObjectDelegate::QScriptObjectDelegate()
174 QScriptObjectDelegate::~QScriptObjectDelegate()
178 bool QScriptObjectDelegate::getOwnPropertySlot(QScriptObject
* object
, JSC::ExecState
* exec
,
179 const JSC::Identifier
& propertyName
,
180 JSC::PropertySlot
& slot
)
182 return object
->JSC::JSObject::getOwnPropertySlot(exec
, propertyName
, slot
);
185 void QScriptObjectDelegate::put(QScriptObject
* object
, JSC::ExecState
* exec
,
186 const JSC::Identifier
& propertyName
,
187 JSC::JSValue value
, JSC::PutPropertySlot
& slot
)
189 object
->JSC::JSObject::put(exec
, propertyName
, value
, slot
);
192 bool QScriptObjectDelegate::deleteProperty(QScriptObject
* object
, JSC::ExecState
* exec
,
193 const JSC::Identifier
& propertyName
,
194 bool checkDontDelete
)
196 return object
->JSC::JSObject::deleteProperty(exec
, propertyName
, checkDontDelete
);
199 bool QScriptObjectDelegate::getPropertyAttributes(const QScriptObject
* object
,
200 JSC::ExecState
* exec
,
201 const JSC::Identifier
& propertyName
,
202 unsigned& attributes
) const
204 return object
->JSC::JSObject::getPropertyAttributes(exec
, propertyName
, attributes
);
207 void QScriptObjectDelegate::getOwnPropertyNames(QScriptObject
* object
, JSC::ExecState
* exec
,
208 JSC::PropertyNameArray
& propertyNames
,
209 bool includeNonEnumerable
)
211 object
->JSC::JSObject::getOwnPropertyNames(exec
, propertyNames
, includeNonEnumerable
);
214 void QScriptObjectDelegate::markChildren(QScriptObject
* object
, JSC::MarkStack
& markStack
)
216 // ### should this call the virtual function instead??
217 object
->JSC::JSObject::markChildren(markStack
);
220 JSC::CallType
QScriptObjectDelegate::getCallData(QScriptObject
* object
, JSC::CallData
& data
)
222 return object
->JSC::JSObject::getCallData(data
);
225 JSC::ConstructType
QScriptObjectDelegate::getConstructData(QScriptObject
* object
, JSC::ConstructData
& data
)
227 return object
->JSC::JSObject::getConstructData(data
);
230 bool QScriptObjectDelegate::hasInstance(QScriptObject
* object
, JSC::ExecState
* exec
,
231 JSC::JSValue value
, JSC::JSValue proto
)
233 return object
->JSC::JSObject::hasInstance(exec
, value
, proto
);
236 bool QScriptObjectDelegate::compareToObject(QScriptObject
* object
, JSC::ExecState
* exec
, JSC::JSObject
* o
)
238 return object
->JSC::JSObject::compareToObject(exec
, o
);