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"
36 typedef void (*DestroyFunctionPtr
)(JSCell
*);
37 DestroyFunctionPtr destroy
;
39 typedef void (*VisitChildrenFunctionPtr
)(JSCell
*, SlotVisitor
&);
40 VisitChildrenFunctionPtr visitChildren
;
42 typedef void (*CopyBackingStoreFunctionPtr
)(JSCell
*, CopyVisitor
&);
43 CopyBackingStoreFunctionPtr copyBackingStore
;
45 typedef CallType (*GetCallDataFunctionPtr
)(JSCell
*, CallData
&);
46 GetCallDataFunctionPtr getCallData
;
48 typedef ConstructType (*GetConstructDataFunctionPtr
)(JSCell
*, ConstructData
&);
49 GetConstructDataFunctionPtr getConstructData
;
51 typedef void (*PutFunctionPtr
)(JSCell
*, ExecState
*, PropertyName propertyName
, JSValue
, PutPropertySlot
&);
54 typedef void (*PutByIndexFunctionPtr
)(JSCell
*, ExecState
*, unsigned propertyName
, JSValue
, bool shouldThrow
);
55 PutByIndexFunctionPtr putByIndex
;
57 typedef bool (*DeletePropertyFunctionPtr
)(JSCell
*, ExecState
*, PropertyName
);
58 DeletePropertyFunctionPtr deleteProperty
;
60 typedef bool (*DeletePropertyByIndexFunctionPtr
)(JSCell
*, ExecState
*, unsigned);
61 DeletePropertyByIndexFunctionPtr deletePropertyByIndex
;
63 typedef bool (*GetOwnPropertySlotFunctionPtr
)(JSCell
*, ExecState
*, PropertyName
, PropertySlot
&);
64 GetOwnPropertySlotFunctionPtr getOwnPropertySlot
;
66 typedef bool (*GetOwnPropertySlotByIndexFunctionPtr
)(JSCell
*, ExecState
*, unsigned, PropertySlot
&);
67 GetOwnPropertySlotByIndexFunctionPtr getOwnPropertySlotByIndex
;
69 typedef JSObject
* (*ToThisObjectFunctionPtr
)(JSCell
*, ExecState
*);
70 ToThisObjectFunctionPtr toThisObject
;
72 typedef JSValue (*DefaultValueFunctionPtr
)(const JSObject
*, ExecState
*, PreferredPrimitiveType
);
73 DefaultValueFunctionPtr defaultValue
;
75 typedef void (*GetOwnPropertyNamesFunctionPtr
)(JSObject
*, ExecState
*, PropertyNameArray
&, EnumerationMode
);
76 GetOwnPropertyNamesFunctionPtr getOwnPropertyNames
;
78 typedef void (*GetOwnNonIndexPropertyNamesFunctionPtr
)(JSObject
*, ExecState
*, PropertyNameArray
&, EnumerationMode
);
79 GetOwnNonIndexPropertyNamesFunctionPtr getOwnNonIndexPropertyNames
;
81 typedef void (*GetPropertyNamesFunctionPtr
)(JSObject
*, ExecState
*, PropertyNameArray
&, EnumerationMode
);
82 GetPropertyNamesFunctionPtr getPropertyNames
;
84 typedef String (*ClassNameFunctionPtr
)(const JSObject
*);
85 ClassNameFunctionPtr className
;
87 typedef bool (*CustomHasInstanceFunctionPtr
)(JSObject
*, ExecState
*, JSValue
);
88 CustomHasInstanceFunctionPtr customHasInstance
;
90 typedef void (*PutWithAttributesFunctionPtr
)(JSObject
*, ExecState
*, PropertyName propertyName
, JSValue
, unsigned attributes
);
91 PutWithAttributesFunctionPtr putDirectVirtual
;
93 typedef bool (*DefineOwnPropertyFunctionPtr
)(JSObject
*, ExecState
*, PropertyName
, PropertyDescriptor
&, bool);
94 DefineOwnPropertyFunctionPtr defineOwnProperty
;
96 typedef bool (*GetOwnPropertyDescriptorFunctionPtr
)(JSObject
*, ExecState
*, PropertyName
, PropertyDescriptor
&);
97 GetOwnPropertyDescriptorFunctionPtr getOwnPropertyDescriptor
;
100 #define CREATE_MEMBER_CHECKER(member) \
101 template <typename T> \
102 struct MemberCheck##member { \
106 struct Derived : T, Fallback { }; \
107 template <typename U, U> struct Check; \
108 typedef char Yes[2]; \
109 typedef char No[1]; \
110 template <typename U> \
111 static No &func(Check<void (Fallback::*)(...), &U::member>*); \
112 template <typename U> \
113 static Yes &func(...); \
114 enum { has = sizeof(func<Derived>(0)) == sizeof(Yes) }; \
117 #define HAS_MEMBER_NAMED(klass, name) (MemberCheck##name<klass>::has)
119 #define CREATE_METHOD_TABLE(ClassName) { \
120 &ClassName::destroy, \
121 &ClassName::visitChildren, \
122 &ClassName::copyBackingStore, \
123 &ClassName::getCallData, \
124 &ClassName::getConstructData, \
126 &ClassName::putByIndex, \
127 &ClassName::deleteProperty, \
128 &ClassName::deletePropertyByIndex, \
129 &ClassName::getOwnPropertySlot, \
130 &ClassName::getOwnPropertySlotByIndex, \
131 &ClassName::toThisObject, \
132 &ClassName::defaultValue, \
133 &ClassName::getOwnPropertyNames, \
134 &ClassName::getOwnNonIndexPropertyNames, \
135 &ClassName::getPropertyNames, \
136 &ClassName::className, \
137 &ClassName::customHasInstance, \
138 &ClassName::putDirectVirtual, \
139 &ClassName::defineOwnProperty, \
140 &ClassName::getOwnPropertyDescriptor, \
142 ClassName::TypedArrayStorageType
146 * A string denoting the class name. Example: "Window".
148 const char* className
;
151 * Pointer to the class information of the base class.
152 * 0L if there is none.
154 const ClassInfo
* parentClass
;
156 * Static hash-table of properties.
157 * For classes that can be used from multiple threads, it is accessed via a getter function that would typically return a pointer to thread-specific value.
159 const HashTable
* propHashTable(ExecState
* exec
) const
161 if (classPropHashTableGetterFunction
)
162 return classPropHashTableGetterFunction(exec
);
163 return staticPropHashTable
;
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
|| ci
->classPropHashTableGetterFunction
)
184 const HashTable
* staticPropHashTable
;
185 typedef const HashTable
* (*ClassPropHashTableGetterFunction
)(ExecState
*);
186 const ClassPropHashTableGetterFunction classPropHashTableGetterFunction
;
188 MethodTable methodTable
;
190 TypedArrayType typedArrayStorageType
;
195 #endif // ClassInfo_h