source: webkit/trunk/JavaScriptCore/kjs/JSGlobalObject.h@ 30810

Last change on this file since 30810 was 30534, checked in by Darin Adler, 17 years ago

JavaScriptCore:

Reviewed by Anders.

  • API/JSCallbackObject.h: Removed attribute arguments.
  • API/JSCallbackObjectFunctions.h: (KJS::JSCallbackObject<Base>::put): Ditto.
  • API/JSObjectRef.cpp: (JSObjectSetProperty): Use initializeVariable or putDirect when necessary to set attribute values.
  • JavaScriptCore.exp: Updated.
  • bindings/objc/objc_runtime.h: Removed attribute arguments.
  • bindings/objc/objc_runtime.mm: (ObjcFallbackObjectImp::put): Ditto.
  • bindings/runtime_array.cpp: (RuntimeArray::put): Ditto.
  • bindings/runtime_array.h: Ditto.
  • bindings/runtime_object.cpp: (RuntimeObjectImp::put): Ditto.
  • bindings/runtime_object.h: Ditto. Also removed canPut which was only called from one place in WebCore that can use hasProperty instead.
  • kjs/Activation.h: Removed attribute argument from put and added the new initializeVariable function that's used to put variables in variable objects. Also made isActivationObject a const member.
  • kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::put): Removed attribute argument. (KJS::JSGlobalObject::initializeVariable): Added. Used to give variables their initial values, which can include the read-only property. (KJS::JSGlobalObject::reset): Removed obsolete comments about flags. Removed Internal flag, which is no longer needed.
  • kjs/JSGlobalObject.h: More of the same.
  • kjs/JSVariableObject.h: Added pure virtual initializeVariable function. (KJS::JSVariableObject::symbolTablePut): Removed checkReadOnly flag; we always check read-only. (KJS::JSVariableObject::symbolTableInitializeVariable): Added.
  • kjs/array_instance.cpp: (KJS::ArrayInstance::put): Removed attribute argument.
  • kjs/array_instance.h: Ditto.
  • kjs/function.cpp: (KJS::FunctionImp::put): Ditto. (KJS::Arguments::put): Ditto. (KJS::ActivationImp::put): Ditto. (KJS::ActivationImp::initializeVariable): Added.
  • kjs/function.h: Removed attribute arguments.
  • kjs/function_object.cpp: (KJS::FunctionObjectImp::construct): Removed Internal flag.
  • kjs/lookup.h: (KJS::lookupPut): Removed attributes argument. Also changed to use putDirect instead of calling JSObject::put. (KJS::cacheGlobalObject): Ditto.
  • kjs/nodes.cpp: (KJS::ConstDeclNode::handleSlowCase): Call initializeVariable to initialize the constant. (KJS::ConstDeclNode::evaluateSingle): Ditto. (KJS::TryNode::execute): Use putDirect to set up the new object. (KJS::FunctionBodyNode::processDeclarations): Removed Internal. (KJS::ProgramNode::processDeclarations): Ditto. (KJS::EvalNode::processDeclarations): Call initializeVariable to initialize the variables and functions. (KJS::FuncDeclNode::makeFunction): Removed Internal. (KJS::FuncExprNode::evaluate): Ditto.
  • kjs/object.cpp: Removed canPut, which was only being used in one code path, not the normal high speed one. (KJS::JSObject::put): Removed attribute argument. Moved the logic from canPut here, in the one code ath that was still using it.
  • kjs/object.h: Removed Internal attribute, ad canPut function. Removed the attributes argument to the put function. Made isActivationObject const.
  • kjs/regexp_object.cpp: (KJS::RegExpImp::put): Removed attributes argument. (KJS::RegExpImp::putValueProperty): Ditto. (KJS::RegExpObjectImp::put): Ditto. (KJS::RegExpObjectImp::putValueProperty): Ditto.
  • kjs/regexp_object.h: Ditto.
  • kjs/string_object.cpp: (KJS::StringInstance::put): Removed attributes argument.
  • kjs/string_object.h: Ditto.

WebCore:

Reviewed by Anders.

  • bindings/js/JSCSSStyleDeclarationCustom.cpp: (WebCore::JSCSSStyleDeclaration::customPut): Remove attributes argument.
  • bindings/js/JSCanvasPixelArrayCustom.cpp: (WebCore::JSCanvasPixelArray::indexGetter): Use early exit idiom. (WebCore::JSCanvasPixelArray::indexSetter): Moved length check into the CanvasPixelArray object, for consistency with the getter. Removed attributes argument.
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::customPut): Removed special case for variable initialization, which is not needed since that does use put any more. Removed attributes argument.
  • bindings/js/JSEventTargetBase.h: (WebCore::JSEventTargetBase::putValueProperty): Removed attributes argument. (WebCore::JSEventTargetBase::put): Ditto. (WebCore::JSEventTargetPrototype::self): Removed Internal flag.
  • bindings/js/JSEventTargetNode.cpp: (WebCore::JSEventTargetNode::put): Removed attributes argument. (WebCore::JSEventTargetNode::putValueProperty): Ditto.
  • bindings/js/JSEventTargetNode.h: Ditto.
  • bindings/js/JSHTMLAppletElementCustom.cpp: (WebCore::JSHTMLAppletElement::customPut): Ditto.
  • bindings/js/JSHTMLEmbedElementCustom.cpp: (WebCore::JSHTMLEmbedElement::customPut): Ditto.
  • bindings/js/JSHTMLInputElementBase.cpp: (WebCore::JSHTMLInputElementBase::put): Ditto. (WebCore::JSHTMLInputElementBase::putValueProperty): Ditto.
  • bindings/js/JSHTMLInputElementBase.h: Ditto.
  • bindings/js/JSHTMLObjectElementCustom.cpp: (WebCore::JSHTMLObjectElement::customPut): Ditto.
  • bindings/js/JSHTMLOptionsCollectionCustom.cpp: (WebCore::JSHTMLOptionsCollection::indexSetter): Ditto.
  • bindings/js/JSHTMLSelectElementCustom.cpp: (WebCore::JSHTMLSelectElement::indexSetter): Ditto.
  • bindings/js/JSHistoryCustom.cpp: (WebCore::JSHistory::customPut): Ditto.
  • bindings/js/JSLocation.cpp: (WebCore::JSLocation::put): Ditto.
  • bindings/js/JSLocation.h: Ditto.
  • bindings/js/JSXMLHttpRequest.cpp: (WebCore::JSXMLHttpRequest::put): Ditto. (WebCore::JSXMLHttpRequest::putValueProperty): Ditto.
  • bindings/js/JSXMLHttpRequest.h: Ditto.
  • bindings/js/kjs_dom.cpp: (WebCore::getRuntimeObject): Changed return type to JSObject*.
  • bindings/js/kjs_dom.h: Ditto.
  • bindings/js/kjs_events.cpp: (WebCore::JSClipboard::put): Removed attributes argument. (WebCore::JSClipboard::putValueProperty): Ditto.
  • bindings/js/kjs_events.h: Ditto.
  • bindings/js/kjs_html.cpp: (WebCore::runtimeObjectGetter): Updated for change to getRuntimeObject to return a JSObject. Used early exit idiom. (WebCore::runtimeObjectPropertyGetter): Ditto. (WebCore::runtimeObjectCustomGetOwnPropertySlot): Ditto. (WebCore::runtimeObjectCustomPut): Use hasProperty to check for properties that we should put with the property syntax instead of canPut. (WebCore::runtimeObjectImplementsCall): Ditto. (WebCore::runtimeObjectCallAsFunction): Ditto.
  • bindings/js/kjs_html.h: Removed attributes argument to runtimeObjectCustomPut.
  • bindings/js/kjs_window.cpp: (KJS::Window::put): Removed attributes argument.
  • bindings/js/kjs_window.h: Ditto.
  • bindings/scripts/CodeGeneratorJS.pm: Removed attributes argument from put, putValueProperty, customPut, and indexSetter.
  • html/CanvasPixelArray.h: (WebCore::CanvasPixelArray::set): Added index checking here, as in the get function. Before, the checking was done in the JavaScript bindings for set.
  • Property svn:eol-style set to native
File size: 9.7 KB
Line 
1// -*- c-basic-offset: 4 -*-
2/*
3 * Copyright (C) 2007 Eric Seidel <[email protected]>
4 * Copyright (C) 2007 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#ifndef KJS_GlobalObject_h
24#define KJS_GlobalObject_h
25
26#include "JSVariableObject.h"
27
28namespace KJS {
29
30 class ActivationImp;
31 class ArrayObjectImp;
32 class ArrayPrototype;
33 class BooleanObjectImp;
34 class BooleanPrototype;
35 class DateObjectImp;
36 class DatePrototype;
37 class Debugger;
38 class ErrorObjectImp;
39 class ErrorPrototype;
40 class EvalError;
41 class EvalErrorPrototype;
42 class FunctionObjectImp;
43 class FunctionPrototype;
44 class JSGlobalObject;
45 class NativeErrorImp;
46 class NativeErrorPrototype;
47 class NumberObjectImp;
48 class NumberPrototype;
49 class ObjectObjectImp;
50 class ObjectPrototype;
51 class RangeError;
52 class RangeErrorPrototype;
53 class ReferenceError;
54 class ReferenceError;
55 class ReferenceErrorPrototype;
56 class RegExpObjectImp;
57 class RegExpPrototype;
58 class RuntimeMethod;
59 class SavedBuiltins;
60 class ScopeChain;
61 class StringObjectImp;
62 class StringPrototype;
63 class SyntaxErrorPrototype;
64 class TypeError;
65 class TypeErrorPrototype;
66 class UriError;
67 class UriErrorPrototype;
68 struct ActivationStackNode;
69
70 class JSGlobalObject : public JSVariableObject {
71 protected:
72 using JSVariableObject::JSVariableObjectData;
73
74 struct JSGlobalObjectData : public JSVariableObjectData {
75 JSGlobalObjectData(JSGlobalObject* globalObject)
76 : JSVariableObjectData(&inlineSymbolTable)
77 , globalExec(globalObject)
78 {
79 }
80
81 JSGlobalObject* next;
82 JSGlobalObject* prev;
83
84 Debugger* debugger;
85
86 GlobalExecState globalExec;
87 int recursion;
88
89 unsigned timeoutTime;
90 unsigned timeAtLastCheckTimeout;
91 unsigned timeExecuting;
92 unsigned timeoutCheckCount;
93 unsigned tickCount;
94 unsigned ticksUntilNextTimeoutCheck;
95
96 ObjectObjectImp* objectConstructor;
97 FunctionObjectImp* functionConstructor;
98 ArrayObjectImp* arrayConstructor;
99 BooleanObjectImp* booleanConstructor;
100 StringObjectImp* stringConstructor;
101 NumberObjectImp* numberConstructor;
102 DateObjectImp* dateConstructor;
103 RegExpObjectImp* regExpConstructor;
104 ErrorObjectImp* errorConstructor;
105 NativeErrorImp* evalErrorConstructor;
106 NativeErrorImp* rangeErrorConstructor;
107 NativeErrorImp* referenceErrorConstructor;
108 NativeErrorImp* syntaxErrorConstructor;
109 NativeErrorImp* typeErrorConstructor;
110 NativeErrorImp* URIErrorConstructor;
111
112 ObjectPrototype* objectPrototype;
113 FunctionPrototype* functionPrototype;
114 ArrayPrototype* arrayPrototype;
115 BooleanPrototype* booleanPrototype;
116 StringPrototype* stringPrototype;
117 NumberPrototype* numberPrototype;
118 DatePrototype* datePrototype;
119 RegExpPrototype* regExpPrototype;
120 ErrorPrototype* errorPrototype;
121 NativeErrorPrototype* evalErrorPrototype;
122 NativeErrorPrototype* rangeErrorPrototype;
123 NativeErrorPrototype* referenceErrorPrototype;
124 NativeErrorPrototype* syntaxErrorPrototype;
125 NativeErrorPrototype* typeErrorPrototype;
126 NativeErrorPrototype* URIErrorPrototype;
127
128 SymbolTable inlineSymbolTable;
129
130 ActivationStackNode* activations;
131 size_t activationCount;
132 };
133
134 public:
135 JSGlobalObject()
136 : JSVariableObject(new JSGlobalObjectData(this))
137 {
138 init();
139 }
140
141 protected:
142 JSGlobalObject(JSValue* proto)
143 : JSVariableObject(proto, new JSGlobalObjectData(this))
144 {
145 init();
146 }
147
148 public:
149 virtual ~JSGlobalObject();
150
151 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
152 virtual void put(ExecState*, const Identifier&, JSValue*);
153 virtual void initializeVariable(ExecState*, const Identifier&, JSValue*, unsigned attributes);
154
155 // Linked list of all global objects.
156 static JSGlobalObject* head() { return s_head; }
157 JSGlobalObject* next() { return d()->next; }
158
159 // Resets the global object to contain only built-in properties, sets
160 // the global object's prototype to "prototype," then adds the
161 // default object prototype to the tail of the global object's
162 // prototype chain.
163 void reset(JSValue* prototype);
164
165 // The following accessors return pristine values, even if a script
166 // replaces the global object's associated property.
167
168 ObjectObjectImp* objectConstructor() const { return d()->objectConstructor; }
169 FunctionObjectImp* functionConstructor() const { return d()->functionConstructor; }
170 ArrayObjectImp* arrayConstructor() const { return d()->arrayConstructor; }
171 BooleanObjectImp* booleanConstructor() const { return d()->booleanConstructor; }
172 StringObjectImp* stringConstructor() const{ return d()->stringConstructor; }
173 NumberObjectImp* numberConstructor() const{ return d()->numberConstructor; }
174 DateObjectImp* dateConstructor() const{ return d()->dateConstructor; }
175 RegExpObjectImp* regExpConstructor() const { return d()->regExpConstructor; }
176 ErrorObjectImp* errorConstructor() const { return d()->errorConstructor; }
177 NativeErrorImp* evalErrorConstructor() const { return d()->evalErrorConstructor; }
178 NativeErrorImp* rangeErrorConstructor() const { return d()->rangeErrorConstructor; }
179 NativeErrorImp* referenceErrorConstructor() const { return d()->referenceErrorConstructor; }
180 NativeErrorImp* syntaxErrorConstructor() const { return d()->syntaxErrorConstructor; }
181 NativeErrorImp* typeErrorConstructor() const { return d()->typeErrorConstructor; }
182 NativeErrorImp* URIErrorConstructor() const { return d()->URIErrorConstructor; }
183
184 ObjectPrototype* objectPrototype() const { return d()->objectPrototype; }
185 FunctionPrototype* functionPrototype() const { return d()->functionPrototype; }
186 ArrayPrototype* arrayPrototype() const { return d()->arrayPrototype; }
187 BooleanPrototype* booleanPrototype() const { return d()->booleanPrototype; }
188 StringPrototype* stringPrototype() const { return d()->stringPrototype; }
189 NumberPrototype* numberPrototype() const { return d()->numberPrototype; }
190 DatePrototype* datePrototype() const { return d()->datePrototype; }
191 RegExpPrototype* regExpPrototype() const { return d()->regExpPrototype; }
192 ErrorPrototype* errorPrototype() const { return d()->errorPrototype; }
193 NativeErrorPrototype* evalErrorPrototype() const { return d()->evalErrorPrototype; }
194 NativeErrorPrototype* rangeErrorPrototype() const { return d()->rangeErrorPrototype; }
195 NativeErrorPrototype* referenceErrorPrototype() const { return d()->referenceErrorPrototype; }
196 NativeErrorPrototype* syntaxErrorPrototype() const { return d()->syntaxErrorPrototype; }
197 NativeErrorPrototype* typeErrorPrototype() const { return d()->typeErrorPrototype; }
198 NativeErrorPrototype* URIErrorPrototype() const { return d()->URIErrorPrototype; }
199
200 void saveBuiltins(SavedBuiltins&) const;
201 void restoreBuiltins(const SavedBuiltins&);
202
203 void setTimeoutTime(unsigned timeoutTime) { d()->timeoutTime = timeoutTime; }
204 void startTimeoutCheck();
205 void stopTimeoutCheck();
206 bool timedOut();
207
208 Debugger* debugger() const { return d()->debugger; }
209 void setDebugger(Debugger* debugger) { d()->debugger = debugger; }
210
211 int recursion() { return d()->recursion; }
212 void incRecursion() { ++d()->recursion; }
213 void decRecursion() { --d()->recursion; }
214
215 virtual void mark();
216
217 virtual bool isGlobalObject() const { return true; }
218
219 virtual ExecState* globalExec();
220
221 virtual bool shouldInterruptScript() const { return true; }
222
223 virtual bool allowsAccessFrom(const JSGlobalObject*) const { return true; }
224
225 ActivationImp* pushActivation(ExecState*);
226 void popActivation();
227 void tearOffActivation(ExecState*, bool markAsRelic = false);
228
229 private:
230 void init();
231
232 JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); }
233
234 bool checkTimeout();
235 void resetTimeoutCheck();
236
237 void deleteActivationStack();
238 void checkActivationCount();
239
240 static JSGlobalObject* s_head;
241 };
242
243 inline bool JSGlobalObject::timedOut()
244 {
245 d()->tickCount++;
246
247 if (d()->tickCount != d()->ticksUntilNextTimeoutCheck)
248 return false;
249
250 return checkTimeout();
251 }
252
253} // namespace KJS
254
255#endif // KJS_GlobalObject_h
Note: See TracBrowser for help on using the repository browser.