Qt 4.8
qscriptactivationobject.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"
26 
27 #include "JSVariableObject.h"
28 
29 namespace JSC
30 {
32 }
33 
35 
46 namespace QScript
47 {
48 
49 const JSC::ClassInfo QScriptActivationObject::info = { "QScriptActivationObject", 0, 0, 0 };
50 
51 QScriptActivationObject::QScriptActivationObject(JSC::ExecState *callFrame, JSC::JSObject *delegate)
52  : JSC::JSVariableObject(callFrame->globalData().activationStructure,
53  new QScriptActivationObjectData(callFrame->registers(), delegate))
54 {
55 }
56 
58 {
59  delete d_ptr();
60 }
61 
62 bool QScriptActivationObject::getOwnPropertySlot(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertySlot& slot)
63 {
64  if (d_ptr()->delegate != 0)
65  return d_ptr()->delegate->getOwnPropertySlot(exec, propertyName, slot);
66  return JSC::JSVariableObject::getOwnPropertySlot(exec, propertyName, slot);
67 }
68 
69 bool QScriptActivationObject::getOwnPropertyDescriptor(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertyDescriptor& descriptor)
70 {
71  if (d_ptr()->delegate != 0)
72  return d_ptr()->delegate->getOwnPropertyDescriptor(exec, propertyName, descriptor);
73  return JSC::JSVariableObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
74 }
75 
76 void QScriptActivationObject::getOwnPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames, JSC::EnumerationMode mode)
77 {
78  if (d_ptr()->delegate != 0) {
79  d_ptr()->delegate->getOwnPropertyNames(exec, propertyNames, mode);
80  return;
81  }
82  return JSC::JSVariableObject::getOwnPropertyNames(exec, propertyNames, mode);
83 }
84 
85 void QScriptActivationObject::putWithAttributes(JSC::ExecState *exec, const JSC::Identifier &propertyName, JSC::JSValue value, unsigned attributes)
86 {
87  if (d_ptr()->delegate != 0) {
88  d_ptr()->delegate->putWithAttributes(exec, propertyName, value, attributes);
89  return;
90  }
91 
92  if (symbolTablePutWithAttributes(propertyName, value, attributes))
93  return;
94 
95  JSC::PutPropertySlot slot;
96  JSObject::putWithAttributes(exec, propertyName, value, attributes, true, slot);
97 }
98 
99 void QScriptActivationObject::put(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue value, JSC::PutPropertySlot& slot)
100 {
101  if (d_ptr()->delegate != 0) {
102  d_ptr()->delegate->put(exec, propertyName, value, slot);
103  return;
104  }
105  JSC::JSVariableObject::put(exec, propertyName, value, slot);
106 }
107 
108 void QScriptActivationObject::put(JSC::ExecState* exec, unsigned propertyName, JSC::JSValue value)
109 {
110  if (d_ptr()->delegate != 0) {
111  d_ptr()->delegate->put(exec, propertyName, value);
112  return;
113  }
114  JSC::JSVariableObject::put(exec, propertyName, value);
115 }
116 
117 bool QScriptActivationObject::deleteProperty(JSC::ExecState* exec, const JSC::Identifier& propertyName)
118 {
119  if (d_ptr()->delegate != 0)
120  return d_ptr()->delegate->deleteProperty(exec, propertyName);
121  return JSC::JSVariableObject::deleteProperty(exec, propertyName);
122 }
123 
124 void QScriptActivationObject::defineGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction)
125 {
126  if (d_ptr()->delegate != 0)
127  d_ptr()->delegate->defineGetter(exec, propertyName, getterFunction);
128  else
129  JSC::JSVariableObject::defineGetter(exec, propertyName, getterFunction);
130 }
131 
132 void QScriptActivationObject::defineSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction)
133 {
134  if (d_ptr()->delegate != 0)
135  d_ptr()->delegate->defineSetter(exec, propertyName, setterFunction);
136  else
137  JSC::JSVariableObject::defineSetter(exec, propertyName, setterFunction);
138 }
139 
140 JSC::JSValue QScriptActivationObject::lookupGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName)
141 {
142  if (d_ptr()->delegate != 0)
143  return d_ptr()->delegate->lookupGetter(exec, propertyName);
144  return JSC::JSVariableObject::lookupGetter(exec, propertyName);
145 }
146 
147 JSC::JSValue QScriptActivationObject::lookupSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName)
148 {
149  if (d_ptr()->delegate != 0)
150  return d_ptr()->delegate->lookupSetter(exec, propertyName);
151  return JSC::JSVariableObject::lookupSetter(exec, propertyName);
152 }
153 
154 } // namespace QScript
155 
157 
virtual JSC::JSValue lookupGetter(JSC::ExecState *, const JSC::Identifier &propertyName)
static mach_timebase_info_data_t info
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
ASSERT_CLASS_FITS_IN_CELL(::QScript::QScriptActivationObject)
virtual JSC::JSValue lookupSetter(JSC::ExecState *, const JSC::Identifier &propertyName)
virtual void put(JSC::ExecState *, const JSC::Identifier &propertyName, JSC::JSValue value, JSC::PutPropertySlot &)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
#define QT_PREPEND_NAMESPACE(name)
This macro qualifies identifier with the full namespace.
Definition: qglobal.h:87
virtual void putWithAttributes(JSC::ExecState *exec, const JSC::Identifier &propertyName, JSC::JSValue value, unsigned attributes)
QScriptActivationObjectData * d_ptr() const
virtual bool getOwnPropertyDescriptor(JSC::ExecState *, const JSC::Identifier &propertyName, JSC::PropertyDescriptor &)
virtual void defineGetter(JSC::ExecState *, const JSC::Identifier &propertyName, JSC::JSObject *getterFunction)
virtual bool getOwnPropertySlot(JSC::ExecState *, const JSC::Identifier &propertyName, JSC::PropertySlot &)
virtual void defineSetter(JSC::ExecState *, const JSC::Identifier &propertyName, JSC::JSObject *setterFunction)
virtual bool deleteProperty(JSC::ExecState *, const JSC::Identifier &propertyName)
virtual void getOwnPropertyNames(JSC::ExecState *, JSC::PropertyNameArray &, JSC::EnumerationMode mode=JSC::ExcludeDontEnumProperties)
Represent a scope for native function call.