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 "qscriptactivationobject_p.h" |
42 | |
43 | #include "JSVariableObject.h" |
44 | |
45 | namespace JSC |
46 | { |
47 | ASSERT_CLASS_FITS_IN_CELL(QT_PREPEND_NAMESPACE(QScript::QScriptActivationObject)); |
48 | } |
49 | |
50 | QT_BEGIN_NAMESPACE |
51 | |
52 | /*! |
53 | \class QScript::QScriptActivationObject |
54 | \internal |
55 | |
56 | Represent a scope for native function call. |
57 | */ |
58 | |
59 | namespace QScript |
60 | { |
61 | |
62 | const JSC::ClassInfo QScriptActivationObject::info = { .className: "QScriptActivationObject" , .parentClass: 0, .staticPropHashTable: 0, .classPropHashTableGetterFunction: 0 }; |
63 | |
64 | QScriptActivationObject::QScriptActivationObject(JSC::ExecState *callFrame, JSC::JSObject *delegate) |
65 | : JSC::JSVariableObject(callFrame->globalData().activationStructure, |
66 | new QScriptActivationObjectData(callFrame->registers(), delegate)) |
67 | { |
68 | } |
69 | |
70 | QScriptActivationObject::~QScriptActivationObject() |
71 | { |
72 | delete d_ptr(); |
73 | } |
74 | |
75 | bool QScriptActivationObject::getOwnPropertySlot(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertySlot& slot) |
76 | { |
77 | if (d_ptr()->delegate != 0) |
78 | return d_ptr()->delegate->getOwnPropertySlot(exec, propertyName, slot); |
79 | return JSC::JSVariableObject::getOwnPropertySlot(exec, propertyName, slot); |
80 | } |
81 | |
82 | bool QScriptActivationObject::getOwnPropertyDescriptor(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertyDescriptor& descriptor) |
83 | { |
84 | if (d_ptr()->delegate != 0) |
85 | return d_ptr()->delegate->getOwnPropertyDescriptor(exec, propertyName, descriptor); |
86 | return JSC::JSVariableObject::getOwnPropertyDescriptor(exec, propertyName, descriptor); |
87 | } |
88 | |
89 | void QScriptActivationObject::getOwnPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames, JSC::EnumerationMode mode) |
90 | { |
91 | if (d_ptr()->delegate != 0) { |
92 | d_ptr()->delegate->getOwnPropertyNames(exec, propertyNames, mode); |
93 | return; |
94 | } |
95 | return JSC::JSVariableObject::getOwnPropertyNames(exec, propertyNames, mode); |
96 | } |
97 | |
98 | void QScriptActivationObject::putWithAttributes(JSC::ExecState *exec, const JSC::Identifier &propertyName, JSC::JSValue value, unsigned attributes) |
99 | { |
100 | if (d_ptr()->delegate != 0) { |
101 | d_ptr()->delegate->putWithAttributes(exec, propertyName, value, attributes); |
102 | return; |
103 | } |
104 | |
105 | if (symbolTablePutWithAttributes(propertyName, value, attributes)) |
106 | return; |
107 | |
108 | JSC::PutPropertySlot slot; |
109 | JSObject::putWithAttributes(exec, propertyName, value, attributes, checkReadOnly: true, slot); |
110 | } |
111 | |
112 | void QScriptActivationObject::put(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue value, JSC::PutPropertySlot& slot) |
113 | { |
114 | if (d_ptr()->delegate != 0) { |
115 | d_ptr()->delegate->put(exec, propertyName, value, slot); |
116 | return; |
117 | } |
118 | JSC::JSVariableObject::put(exec, propertyName, value, slot); |
119 | } |
120 | |
121 | void QScriptActivationObject::put(JSC::ExecState* exec, unsigned propertyName, JSC::JSValue value) |
122 | { |
123 | if (d_ptr()->delegate != 0) { |
124 | d_ptr()->delegate->put(exec, propertyName, value); |
125 | return; |
126 | } |
127 | JSC::JSVariableObject::put(exec, propertyName, value); |
128 | } |
129 | |
130 | bool QScriptActivationObject::deleteProperty(JSC::ExecState* exec, const JSC::Identifier& propertyName) |
131 | { |
132 | if (d_ptr()->delegate != 0) |
133 | return d_ptr()->delegate->deleteProperty(exec, propertyName); |
134 | return JSC::JSVariableObject::deleteProperty(exec, propertyName); |
135 | } |
136 | |
137 | void QScriptActivationObject::defineGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction) |
138 | { |
139 | if (d_ptr()->delegate != 0) |
140 | d_ptr()->delegate->defineGetter(exec, propertyName, getterFunction); |
141 | else |
142 | JSC::JSVariableObject::defineGetter(exec, propertyName, getterFunction); |
143 | } |
144 | |
145 | void QScriptActivationObject::defineSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction) |
146 | { |
147 | if (d_ptr()->delegate != 0) |
148 | d_ptr()->delegate->defineSetter(exec, propertyName, setterFunction); |
149 | else |
150 | JSC::JSVariableObject::defineSetter(exec, propertyName, setterFunction); |
151 | } |
152 | |
153 | JSC::JSValue QScriptActivationObject::lookupGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName) |
154 | { |
155 | if (d_ptr()->delegate != 0) |
156 | return d_ptr()->delegate->lookupGetter(exec, propertyName); |
157 | return JSC::JSVariableObject::lookupGetter(exec, propertyName); |
158 | } |
159 | |
160 | JSC::JSValue QScriptActivationObject::lookupSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName) |
161 | { |
162 | if (d_ptr()->delegate != 0) |
163 | return d_ptr()->delegate->lookupSetter(exec, propertyName); |
164 | return JSC::JSVariableObject::lookupSetter(exec, propertyName); |
165 | } |
166 | |
167 | } // namespace QScript |
168 | |
169 | QT_END_NAMESPACE |
170 | |
171 | |