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 CallType (*GetCallDataFunctionPtr
)(JSCell
*, CallData
&);
43 GetCallDataFunctionPtr getCallData
;
45 typedef ConstructType (*GetConstructDataFunctionPtr
)(JSCell
*, ConstructData
&);
46 GetConstructDataFunctionPtr getConstructData
;
48 typedef void (*PutFunctionPtr
)(JSCell
*, ExecState
*, const Identifier
& propertyName
, JSValue
, PutPropertySlot
&);
51 typedef void (*PutByIndexFunctionPtr
)(JSCell
*, ExecState
*, unsigned propertyName
, JSValue
, bool shouldThrow
);
52 PutByIndexFunctionPtr putByIndex
;
54 typedef bool (*DeletePropertyFunctionPtr
)(JSCell
*, ExecState
*, const Identifier
&);
55 DeletePropertyFunctionPtr deleteProperty
;
57 typedef bool (*DeletePropertyByIndexFunctionPtr
)(JSCell
*, ExecState
*, unsigned);
58 DeletePropertyByIndexFunctionPtr deletePropertyByIndex
;
60 typedef bool (*GetOwnPropertySlotFunctionPtr
)(JSCell
*, ExecState
*, const Identifier
&, PropertySlot
&);
61 GetOwnPropertySlotFunctionPtr getOwnPropertySlot
;
63 typedef bool (*GetOwnPropertySlotByIndexFunctionPtr
)(JSCell
*, ExecState
*, unsigned, PropertySlot
&);
64 GetOwnPropertySlotByIndexFunctionPtr getOwnPropertySlotByIndex
;
66 typedef JSObject
* (*ToThisObjectFunctionPtr
)(JSCell
*, ExecState
*);
67 ToThisObjectFunctionPtr toThisObject
;
69 typedef JSValue (*DefaultValueFunctionPtr
)(const JSObject
*, ExecState
*, PreferredPrimitiveType
);
70 DefaultValueFunctionPtr defaultValue
;
72 typedef void (*GetOwnPropertyNamesFunctionPtr
)(JSObject
*, ExecState
*, PropertyNameArray
&, EnumerationMode
);
73 GetOwnPropertyNamesFunctionPtr getOwnPropertyNames
;
75 typedef void (*GetPropertyNamesFunctionPtr
)(JSObject
*, ExecState
*, PropertyNameArray
&, EnumerationMode
);
76 GetPropertyNamesFunctionPtr getPropertyNames
;
78 typedef UString (*ClassNameFunctionPtr
)(const JSObject
*);
79 ClassNameFunctionPtr className
;
81 typedef bool (*HasInstanceFunctionPtr
)(JSObject
*, ExecState
*, JSValue
, JSValue
);
82 HasInstanceFunctionPtr hasInstance
;
84 typedef void (*PutWithAttributesFunctionPtr
)(JSObject
*, ExecState
*, const Identifier
& propertyName
, JSValue
, unsigned attributes
);
85 PutWithAttributesFunctionPtr putDirectVirtual
;
87 typedef bool (*DefineOwnPropertyFunctionPtr
)(JSObject
*, ExecState
*, const Identifier
&, PropertyDescriptor
&, bool);
88 DefineOwnPropertyFunctionPtr defineOwnProperty
;
90 typedef bool (*GetOwnPropertyDescriptorFunctionPtr
)(JSObject
*, ExecState
*, const Identifier
&, PropertyDescriptor
&);
91 GetOwnPropertyDescriptorFunctionPtr getOwnPropertyDescriptor
;
94 #define CREATE_MEMBER_CHECKER(member) \
95 template <typename T> \
96 struct MemberCheck##member { \
100 struct Derived : T, Fallback { }; \
101 template <typename U, U> struct Check; \
102 typedef char Yes[2]; \
103 typedef char No[1]; \
104 template <typename U> \
105 static No &func(Check<void (Fallback::*)(...), &U::member>*); \
106 template <typename U> \
107 static Yes &func(...); \
108 enum { has = sizeof(func<Derived>(0)) == sizeof(Yes) }; \
111 #define HAS_MEMBER_NAMED(klass, name) (MemberCheck##name<klass>::has)
113 #define CREATE_METHOD_TABLE(ClassName) { \
114 &ClassName::destroy, \
115 &ClassName::visitChildren, \
116 &ClassName::getCallData, \
117 &ClassName::getConstructData, \
119 &ClassName::putByIndex, \
120 &ClassName::deleteProperty, \
121 &ClassName::deletePropertyByIndex, \
122 &ClassName::getOwnPropertySlot, \
123 &ClassName::getOwnPropertySlotByIndex, \
124 &ClassName::toThisObject, \
125 &ClassName::defaultValue, \
126 &ClassName::getOwnPropertyNames, \
127 &ClassName::getPropertyNames, \
128 &ClassName::className, \
129 &ClassName::hasInstance, \
130 &ClassName::putDirectVirtual, \
131 &ClassName::defineOwnProperty, \
132 &ClassName::getOwnPropertyDescriptor, \
134 ClassName::TypedArrayStorageType
138 * A string denoting the class name. Example: "Window".
140 const char* className
;
143 * Pointer to the class information of the base class.
144 * 0L if there is none.
146 const ClassInfo
* parentClass
;
148 * Static hash-table of properties.
149 * 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.
151 const HashTable
* propHashTable(ExecState
* exec
) const
153 if (classPropHashTableGetterFunction
)
154 return classPropHashTableGetterFunction(exec
);
155 return staticPropHashTable
;
158 bool isSubClassOf(const ClassInfo
* other
) const
160 for (const ClassInfo
* ci
= this; ci
; ci
= ci
->parentClass
) {
167 bool hasStaticProperties() const
169 for (const ClassInfo
* ci
= this; ci
; ci
= ci
->parentClass
) {
170 if (ci
->staticPropHashTable
|| ci
->classPropHashTableGetterFunction
)
176 const HashTable
* staticPropHashTable
;
177 typedef const HashTable
* (*ClassPropHashTableGetterFunction
)(ExecState
*);
178 const ClassPropHashTableGetterFunction classPropHashTableGetterFunction
;
180 MethodTable methodTable
;
182 TypedArrayType typedArrayStorageType
;
187 #endif // ClassInfo_h