| 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 | **
|
|---|
| 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,
|
|---|
| 84 | const JSC::Identifier& propertyName,
|
|---|
| 85 | bool checkDontDelete)
|
|---|
| 86 | {
|
|---|
| 87 | if (!d || !d->delegate)
|
|---|
| 88 | return JSC::JSObject::deleteProperty(exec, propertyName, checkDontDelete);
|
|---|
| 89 | return d->delegate->deleteProperty(this, exec, propertyName, checkDontDelete);
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | bool QScriptObject::getPropertyAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName,
|
|---|
| 93 | unsigned& attributes) const
|
|---|
| 94 | {
|
|---|
| 95 | if (!d || !d->delegate)
|
|---|
| 96 | return JSC::JSObject::getPropertyAttributes(exec, propertyName, attributes);
|
|---|
| 97 | return d->delegate->getPropertyAttributes(this, exec, propertyName, attributes);
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | void QScriptObject::getOwnPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames,
|
|---|
| 101 | bool includeNonEnumerable)
|
|---|
| 102 | {
|
|---|
| 103 | if (!d || !d->delegate) {
|
|---|
| 104 | JSC::JSObject::getOwnPropertyNames(exec, propertyNames, includeNonEnumerable);
|
|---|
| 105 | return;
|
|---|
| 106 | }
|
|---|
| 107 | d->delegate->getOwnPropertyNames(this, exec, propertyNames, includeNonEnumerable);
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | bool QScriptObject::compareToObject(JSC::ExecState* exec, JSC::JSObject *other)
|
|---|
| 111 | {
|
|---|
| 112 | if (!d || !d->delegate) {
|
|---|
| 113 | return JSC::JSObject::compareToObject(exec, other);
|
|---|
| 114 | }
|
|---|
| 115 | return d->delegate->compareToObject(this, exec, other);
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | void QScriptObject::markChildren(JSC::MarkStack& markStack)
|
|---|
| 119 | {
|
|---|
| 120 | if (!d)
|
|---|
| 121 | d = new Data();
|
|---|
| 122 | if (d->isMarking)
|
|---|
| 123 | return;
|
|---|
| 124 | QBoolBlocker markBlocker(d->isMarking, true);
|
|---|
| 125 | if (d && d->data)
|
|---|
| 126 | markStack.append(d->data);
|
|---|
| 127 | if (!d || !d->delegate) {
|
|---|
| 128 | JSC::JSObject::markChildren(markStack);
|
|---|
| 129 | return;
|
|---|
| 130 | }
|
|---|
| 131 | d->delegate->markChildren(this, markStack);
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | JSC::CallType QScriptObject::getCallData(JSC::CallData &data)
|
|---|
| 135 | {
|
|---|
| 136 | if (!d || !d->delegate)
|
|---|
| 137 | return JSC::JSObject::getCallData(data);
|
|---|
| 138 | return d->delegate->getCallData(this, data);
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | JSC::ConstructType QScriptObject::getConstructData(JSC::ConstructData &data)
|
|---|
| 142 | {
|
|---|
| 143 | if (!d || !d->delegate)
|
|---|
| 144 | return JSC::JSObject::getConstructData(data);
|
|---|
| 145 | return d->delegate->getConstructData(this, data);
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | bool QScriptObject::hasInstance(JSC::ExecState* exec, JSC::JSValue value, JSC::JSValue proto)
|
|---|
| 149 | {
|
|---|
| 150 | if (!d || !d->delegate)
|
|---|
| 151 | return JSC::JSObject::hasInstance(exec, value, proto);
|
|---|
| 152 | return d->delegate->hasInstance(this, exec, value, proto);
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | QScriptObjectPrototype::QScriptObjectPrototype(JSC::ExecState*, WTF::PassRefPtr<JSC::Structure> structure,
|
|---|
| 156 | JSC::Structure* /*prototypeFunctionStructure*/)
|
|---|
| 157 | : QScriptObject(structure)
|
|---|
| 158 | {
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | QScriptObjectDelegate::QScriptObjectDelegate()
|
|---|
| 162 | {
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | QScriptObjectDelegate::~QScriptObjectDelegate()
|
|---|
| 166 | {
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | bool QScriptObjectDelegate::getOwnPropertySlot(QScriptObject* object, JSC::ExecState* exec,
|
|---|
| 170 | const JSC::Identifier& propertyName,
|
|---|
| 171 | JSC::PropertySlot& slot)
|
|---|
| 172 | {
|
|---|
| 173 | return object->JSC::JSObject::getOwnPropertySlot(exec, propertyName, slot);
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 | bool QScriptObjectDelegate::getOwnPropertyDescriptor(QScriptObject* object, JSC::ExecState* exec,
|
|---|
| 177 | const JSC::Identifier& propertyName,
|
|---|
| 178 | JSC::PropertyDescriptor& descriptor)
|
|---|
| 179 | {
|
|---|
| 180 | return object->JSC::JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 | void QScriptObjectDelegate::put(QScriptObject* object, JSC::ExecState* exec,
|
|---|
| 185 | const JSC::Identifier& propertyName,
|
|---|
| 186 | JSC::JSValue value, JSC::PutPropertySlot& slot)
|
|---|
| 187 | {
|
|---|
| 188 | object->JSC::JSObject::put(exec, propertyName, value, slot);
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | bool QScriptObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState* exec,
|
|---|
| 192 | const JSC::Identifier& propertyName,
|
|---|
| 193 | bool checkDontDelete)
|
|---|
| 194 | {
|
|---|
| 195 | return object->JSC::JSObject::deleteProperty(exec, propertyName, checkDontDelete);
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | bool QScriptObjectDelegate::getPropertyAttributes(const QScriptObject* object,
|
|---|
| 199 | JSC::ExecState* exec,
|
|---|
| 200 | const JSC::Identifier& propertyName,
|
|---|
| 201 | unsigned& attributes) const
|
|---|
| 202 | {
|
|---|
| 203 | return object->JSC::JSObject::getPropertyAttributes(exec, propertyName, attributes);
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | void QScriptObjectDelegate::getOwnPropertyNames(QScriptObject* object, JSC::ExecState* exec,
|
|---|
| 207 | JSC::PropertyNameArray& propertyNames,
|
|---|
| 208 | bool includeNonEnumerable)
|
|---|
| 209 | {
|
|---|
| 210 | object->JSC::JSObject::getOwnPropertyNames(exec, propertyNames, includeNonEnumerable);
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | void QScriptObjectDelegate::markChildren(QScriptObject* object, JSC::MarkStack& markStack)
|
|---|
| 214 | {
|
|---|
| 215 | // ### should this call the virtual function instead??
|
|---|
| 216 | object->JSC::JSObject::markChildren(markStack);
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 | JSC::CallType QScriptObjectDelegate::getCallData(QScriptObject* object, JSC::CallData& data)
|
|---|
| 220 | {
|
|---|
| 221 | return object->JSC::JSObject::getCallData(data);
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | JSC::ConstructType QScriptObjectDelegate::getConstructData(QScriptObject* object, JSC::ConstructData& data)
|
|---|
| 225 | {
|
|---|
| 226 | return object->JSC::JSObject::getConstructData(data);
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | bool QScriptObjectDelegate::hasInstance(QScriptObject* object, JSC::ExecState* exec,
|
|---|
| 230 | JSC::JSValue value, JSC::JSValue proto)
|
|---|
| 231 | {
|
|---|
| 232 | return object->JSC::JSObject::hasInstance(exec, value, proto);
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 | bool QScriptObjectDelegate::compareToObject(QScriptObject* object, JSC::ExecState* exec, JSC::JSObject* o)
|
|---|
| 236 | {
|
|---|
| 237 | return object->JSC::JSObject::compareToObject(exec, o);
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | QT_END_NAMESPACE
|
|---|