|
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$ |
|
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 |
|
14 ** this package. |
|
15 ** |
|
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. |
|
23 ** |
|
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. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QSCRIPTGLOBALOBJECT_P_H |
|
43 #define QSCRIPTGLOBALOBJECT_P_H |
|
44 |
|
45 // |
|
46 // W A R N I N G |
|
47 // ------------- |
|
48 // |
|
49 // This file is not part of the Qt API. It exists purely as an |
|
50 // implementation detail. This header file may change from version to |
|
51 // version without notice, or even be removed. |
|
52 // |
|
53 // We mean it. |
|
54 // |
|
55 |
|
56 #include <QtCore/qobjectdefs.h> |
|
57 |
|
58 #include "JSGlobalObject.h" |
|
59 |
|
60 QT_BEGIN_NAMESPACE |
|
61 |
|
62 namespace QScript |
|
63 { |
|
64 |
|
65 class GlobalObject : public JSC::JSGlobalObject |
|
66 { |
|
67 public: |
|
68 GlobalObject(); |
|
69 virtual ~GlobalObject(); |
|
70 virtual JSC::UString className() const { return "global"; } |
|
71 virtual void markChildren(JSC::MarkStack&); |
|
72 virtual bool getOwnPropertySlot(JSC::ExecState*, |
|
73 const JSC::Identifier& propertyName, |
|
74 JSC::PropertySlot&); |
|
75 virtual void put(JSC::ExecState* exec, const JSC::Identifier& propertyName, |
|
76 JSC::JSValue, JSC::PutPropertySlot&); |
|
77 virtual void putWithAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, |
|
78 JSC::JSValue value, unsigned attributes); |
|
79 virtual bool deleteProperty(JSC::ExecState*, |
|
80 const JSC::Identifier& propertyName, |
|
81 bool checkDontDelete = true); |
|
82 virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier&, |
|
83 unsigned&) const; |
|
84 virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, |
|
85 bool includeNonEnumerable = false); |
|
86 virtual void defineGetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes = 0); |
|
87 virtual void defineSetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes = 0); |
|
88 virtual JSC::JSValue lookupGetter(JSC::ExecState*, const JSC::Identifier& propertyName); |
|
89 virtual JSC::JSValue lookupSetter(JSC::ExecState*, const JSC::Identifier& propertyName); |
|
90 |
|
91 public: |
|
92 JSC::JSObject *customGlobalObject; |
|
93 }; |
|
94 |
|
95 class OriginalGlobalObjectProxy : public JSC::JSObject |
|
96 { |
|
97 public: |
|
98 explicit OriginalGlobalObjectProxy(WTF::PassRefPtr<JSC::Structure> sid, |
|
99 JSC::JSGlobalObject *object) |
|
100 : JSC::JSObject(sid), originalGlobalObject(object) |
|
101 {} |
|
102 virtual ~OriginalGlobalObjectProxy() |
|
103 {} |
|
104 virtual JSC::UString className() const |
|
105 { return originalGlobalObject->className(); } |
|
106 virtual void markChildren(JSC::MarkStack& markStack) |
|
107 { |
|
108 markStack.append(originalGlobalObject); |
|
109 JSC::JSObject::markChildren(markStack); |
|
110 } |
|
111 virtual bool getOwnPropertySlot(JSC::ExecState* exec, |
|
112 const JSC::Identifier& propertyName, |
|
113 JSC::PropertySlot& slot) |
|
114 { return originalGlobalObject->JSC::JSGlobalObject::getOwnPropertySlot(exec, propertyName, slot); } |
|
115 virtual void put(JSC::ExecState* exec, const JSC::Identifier& propertyName, |
|
116 JSC::JSValue value, JSC::PutPropertySlot& slot) |
|
117 { originalGlobalObject->JSC::JSGlobalObject::put(exec, propertyName, value, slot); } |
|
118 virtual void putWithAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue value, unsigned attributes) |
|
119 { originalGlobalObject->JSC::JSGlobalObject::putWithAttributes(exec, propertyName, value, attributes); } |
|
120 virtual bool deleteProperty(JSC::ExecState* exec, |
|
121 const JSC::Identifier& propertyName, bool checkDontDelete = true) |
|
122 { return originalGlobalObject->JSC::JSGlobalObject::deleteProperty(exec, propertyName, checkDontDelete); } |
|
123 virtual bool getPropertyAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, |
|
124 unsigned& attributes) const |
|
125 { return originalGlobalObject->JSC::JSGlobalObject::getPropertyAttributes(exec, propertyName, attributes); } |
|
126 virtual void getOwnPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames, bool includeNonEnumerable = false) |
|
127 { originalGlobalObject->JSC::JSGlobalObject::getOwnPropertyNames(exec, propertyNames, includeNonEnumerable); } |
|
128 virtual void defineGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes) |
|
129 { originalGlobalObject->JSC::JSGlobalObject::defineGetter(exec, propertyName, getterFunction, attributes); } |
|
130 virtual void defineSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes) |
|
131 { originalGlobalObject->JSC::JSGlobalObject::defineSetter(exec, propertyName, setterFunction, attributes); } |
|
132 virtual JSC::JSValue lookupGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName) |
|
133 { return originalGlobalObject->JSC::JSGlobalObject::lookupGetter(exec, propertyName); } |
|
134 virtual JSC::JSValue lookupSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName) |
|
135 { return originalGlobalObject->JSC::JSGlobalObject::lookupSetter(exec, propertyName); } |
|
136 private: |
|
137 JSC::JSGlobalObject *originalGlobalObject; |
|
138 }; |
|
139 |
|
140 } // namespace QScript |
|
141 |
|
142 QT_END_NAMESPACE |
|
143 |
|
144 #endif |