2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
3 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
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.
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.
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.
26 #include "CallFrame.h"
27 #include "ConstructData.h"
28 #include "CopyToken.h"
33 class JSArrayBufferView
;
37 typedef void (*DestroyFunctionPtr
)(JSCell
*);
38 DestroyFunctionPtr destroy
;
40 typedef void (*VisitChildrenFunctionPtr
)(JSCell
*, SlotVisitor
&);
41 VisitChildrenFunctionPtr visitChildren
;
43 typedef void (*CopyBackingStoreFunctionPtr
)(JSCell
*, CopyVisitor
&, CopyToken
);
44 CopyBackingStoreFunctionPtr copyBackingStore
;
46 typedef CallType (*GetCallDataFunctionPtr
)(JSCell
*, CallData
&);
47 GetCallDataFunctionPtr getCallData
;
49 typedef ConstructType (*GetConstructDataFunctionPtr
)(JSCell
*, ConstructData
&);
50 GetConstructDataFunctionPtr getConstructData
;
52 typedef void (*PutFunctionPtr
)(JSCell
*, ExecState
*, PropertyName propertyName
, JSValue
, PutPropertySlot
&);
55 typedef void (*PutByIndexFunctionPtr
)(JSCell
*, ExecState
*, unsigned propertyName
, JSValue
, bool shouldThrow
);
56 PutByIndexFunctionPtr putByIndex
;
58 typedef bool (*DeletePropertyFunctionPtr
)(JSCell
*, ExecState
*, PropertyName
);
59 DeletePropertyFunctionPtr deleteProperty
;
61 typedef bool (*DeletePropertyByIndexFunctionPtr
)(JSCell
*, ExecState
*, unsigned);
62 DeletePropertyByIndexFunctionPtr deletePropertyByIndex
;
64 typedef bool (*GetOwnPropertySlotFunctionPtr
)(JSObject
*, ExecState
*, PropertyName
, PropertySlot
&);
65 GetOwnPropertySlotFunctionPtr getOwnPropertySlot
;
67 typedef bool (*GetOwnPropertySlotByIndexFunctionPtr
)(JSObject
*, ExecState
*, unsigned, PropertySlot
&);
68 GetOwnPropertySlotByIndexFunctionPtr getOwnPropertySlotByIndex
;
70 typedef JSValue (*ToThisFunctionPtr
)(JSCell
*, ExecState
*, ECMAMode
);
71 ToThisFunctionPtr toThis
;
73 typedef JSValue (*DefaultValueFunctionPtr
)(const JSObject
*, ExecState
*, PreferredPrimitiveType
);
74 DefaultValueFunctionPtr defaultValue
;
76 typedef void (*GetOwnPropertyNamesFunctionPtr
)(JSObject
*, ExecState
*, PropertyNameArray
&, EnumerationMode
);
77 GetOwnPropertyNamesFunctionPtr getOwnPropertyNames
;
79 typedef void (*GetOwnNonIndexPropertyNamesFunctionPtr
)(JSObject
*, ExecState
*, PropertyNameArray
&, EnumerationMode
);
80 GetOwnNonIndexPropertyNamesFunctionPtr getOwnNonIndexPropertyNames
;
82 typedef void (*GetPropertyNamesFunctionPtr
)(JSObject
*, ExecState
*, PropertyNameArray
&, EnumerationMode
);
83 GetPropertyNamesFunctionPtr getPropertyNames
;
85 typedef uint32_t (*GetEnumerableLengthFunctionPtr
)(ExecState
*, JSObject
*);
86 GetEnumerableLengthFunctionPtr getEnumerableLength
;
88 GetPropertyNamesFunctionPtr getStructurePropertyNames
;
89 GetPropertyNamesFunctionPtr getGenericPropertyNames
;
91 typedef String (*ClassNameFunctionPtr
)(const JSObject
*);
92 ClassNameFunctionPtr className
;
94 typedef bool (*CustomHasInstanceFunctionPtr
)(JSObject
*, ExecState
*, JSValue
);
95 CustomHasInstanceFunctionPtr customHasInstance
;
97 typedef bool (*DefineOwnPropertyFunctionPtr
)(JSObject
*, ExecState
*, PropertyName
, const PropertyDescriptor
&, bool);
98 DefineOwnPropertyFunctionPtr defineOwnProperty
;
100 typedef ArrayBuffer
* (*SlowDownAndWasteMemory
)(JSArrayBufferView
*);
101 SlowDownAndWasteMemory slowDownAndWasteMemory
;
103 typedef PassRefPtr
<ArrayBufferView
> (*GetTypedArrayImpl
)(JSArrayBufferView
*);
104 GetTypedArrayImpl getTypedArrayImpl
;
106 typedef void (*DumpToStreamFunctionPtr
)(const JSCell
*, PrintStream
&);
107 DumpToStreamFunctionPtr dumpToStream
;
110 #define CREATE_MEMBER_CHECKER(member) \
111 template <typename T> \
112 struct MemberCheck##member { \
116 struct Derived : T, Fallback { }; \
117 template <typename U, U> struct Check; \
118 typedef char Yes[2]; \
119 typedef char No[1]; \
120 template <typename U> \
121 static No &func(Check<void (Fallback::*)(...), &U::member>*); \
122 template <typename U> \
123 static Yes &func(...); \
124 enum { has = sizeof(func<Derived>(0)) == sizeof(Yes) }; \
127 #define HAS_MEMBER_NAMED(klass, name) (MemberCheck##name<klass>::has)
129 #define CREATE_METHOD_TABLE(ClassName) { \
130 &ClassName::destroy, \
131 &ClassName::visitChildren, \
132 &ClassName::copyBackingStore, \
133 &ClassName::getCallData, \
134 &ClassName::getConstructData, \
136 &ClassName::putByIndex, \
137 &ClassName::deleteProperty, \
138 &ClassName::deletePropertyByIndex, \
139 &ClassName::getOwnPropertySlot, \
140 &ClassName::getOwnPropertySlotByIndex, \
141 &ClassName::toThis, \
142 &ClassName::defaultValue, \
143 &ClassName::getOwnPropertyNames, \
144 &ClassName::getOwnNonIndexPropertyNames, \
145 &ClassName::getPropertyNames, \
146 &ClassName::getEnumerableLength, \
147 &ClassName::getStructurePropertyNames, \
148 &ClassName::getGenericPropertyNames, \
149 &ClassName::className, \
150 &ClassName::customHasInstance, \
151 &ClassName::defineOwnProperty, \
152 &ClassName::slowDownAndWasteMemory, \
153 &ClassName::getTypedArrayImpl, \
154 &ClassName::dumpToStream \
156 ClassName::TypedArrayStorageType
159 // A string denoting the class name. Example: "Window".
160 const char* className
;
162 // Pointer to the class information of the base class.
163 // nullptrif there is none.
164 const ClassInfo
* parentClass
;
166 bool isSubClassOf(const ClassInfo
* other
) const
168 for (const ClassInfo
* ci
= this; ci
; ci
= ci
->parentClass
) {
175 bool hasStaticProperties() const
177 for (const ClassInfo
* ci
= this; ci
; ci
= ci
->parentClass
) {
178 if (ci
->staticPropHashTable
)
184 bool hasStaticSetterOrReadonlyProperties() const;
186 const HashTable
* staticPropHashTable
;
188 MethodTable methodTable
;
190 TypedArrayType typedArrayStorageType
;
195 #endif // ClassInfo_h