[556] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[556] | 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 | **
|
---|
| 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 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 | 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,
|
---|
[846] | 84 | const JSC::Identifier& propertyName)
|
---|
[556] | 85 | {
|
---|
| 86 | if (!d || !d->delegate)
|
---|
[846] | 87 | return JSC::JSObject::deleteProperty(exec, propertyName);
|
---|
| 88 | return d->delegate->deleteProperty(this, exec, propertyName);
|
---|
[556] | 89 | }
|
---|
| 90 |
|
---|
| 91 | void QScriptObject::getOwnPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames,
|
---|
[846] | 92 | JSC::EnumerationMode mode)
|
---|
[556] | 93 | {
|
---|
| 94 | if (!d || !d->delegate) {
|
---|
[846] | 95 | JSC::JSObject::getOwnPropertyNames(exec, propertyNames, mode);
|
---|
[556] | 96 | return;
|
---|
| 97 | }
|
---|
[846] | 98 | d->delegate->getOwnPropertyNames(this, exec, propertyNames, mode);
|
---|
[556] | 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 | bool QScriptObjectDelegate::getOwnPropertyDescriptor(QScriptObject* object, JSC::ExecState* exec,
|
---|
| 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,
|
---|
[846] | 183 | const JSC::Identifier& propertyName)
|
---|
[556] | 184 | {
|
---|
[846] | 185 | return object->JSC::JSObject::deleteProperty(exec, propertyName);
|
---|
[556] | 186 | }
|
---|
| 187 |
|
---|
| 188 | void QScriptObjectDelegate::getOwnPropertyNames(QScriptObject* object, JSC::ExecState* exec,
|
---|
| 189 | JSC::PropertyNameArray& propertyNames,
|
---|
[846] | 190 | JSC::EnumerationMode mode)
|
---|
[556] | 191 | {
|
---|
[846] | 192 | object->JSC::JSObject::getOwnPropertyNames(exec, propertyNames, mode);
|
---|
[556] | 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 |
|
---|
| 222 | QT_END_NAMESPACE
|
---|