Changeset 18912 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Jan 17, 2007, 11:34:43 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/lookup.h
r16711 r18912 297 297 * the functions for a type of objects). 298 298 * Sorry for this not being very readable, but it actually saves much copy-n-paste. 299 * ParentProto is not our base class, it's the object we use as fallback.299 * ParentPrototype is not our base class, it's the object we use as fallback. 300 300 * The reason for this is that there should only be ONE DOMNode.hasAttributes (e.g.), 301 301 * not one in each derived class. So we link the (unique) prototypes between them. 302 302 * 303 * Using those macros is very simple: define the hashtable (e.g. "DOMNodeProto Table"), then304 * KJS_DEFINE_PROTOTYPE(DOMNodeProto )305 * KJS_IMPLEMENT_PROTOFUNC(DOMNodeProto Func)306 * KJS_IMPLEMENT_PROTOTYPE("DOMNode", DOMNodeProto ,DOMNodeProtoFunc)307 * and use DOMNodeProto ::self(exec) as prototype in the DOMNode constructor.308 * If the prototype has a "parent prototype", e.g. DOMElementProto falls back on DOMNodeProto,309 * then the first line will use KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE, with DOMNodeProto as the second argument.303 * Using those macros is very simple: define the hashtable (e.g. "DOMNodePrototypeTable"), then 304 * KJS_DEFINE_PROTOTYPE(DOMNodePrototype) 305 * KJS_IMPLEMENT_PROTOFUNC(DOMNodePrototypeFunction) 306 * KJS_IMPLEMENT_PROTOTYPE("DOMNode", DOMNodePrototype, DOMNodePrototypeFunction) 307 * and use DOMNodePrototype::self(exec) as prototype in the DOMNode constructor. 308 * If the prototype has a "parent prototype", e.g. DOMElementPrototype falls back on DOMNodePrototype, 309 * then the first line will use KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE, with DOMNodePrototype as the second argument. 310 310 */ 311 311 312 312 // These macros assume that a prototype's only properties are functions 313 #define KJS_DEFINE_PROTOTYPE(ClassProto ) \314 class ClassProto : public KJS::JSObject { \313 #define KJS_DEFINE_PROTOTYPE(ClassPrototype) \ 314 class ClassPrototype : public KJS::JSObject { \ 315 315 public: \ 316 316 static KJS::JSObject* self(KJS::ExecState* exec); \ … … 318 318 static const KJS::ClassInfo info; \ 319 319 bool getOwnPropertySlot(KJS::ExecState* , const KJS::Identifier&, KJS::PropertySlot&); \ 320 ClassProto (KJS::ExecState* exec) \320 ClassPrototype(KJS::ExecState* exec) \ 321 321 : KJS::JSObject(exec->lexicalInterpreter()->builtinObjectPrototype()) { } \ 322 322 \ 323 323 }; 324 324 325 #define KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(ClassProto , ClassProtoProto) \326 class ClassProto : public KJS::JSObject { \325 #define KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(ClassPrototype, ClassPrototypePrototype) \ 326 class ClassPrototype : public KJS::JSObject { \ 327 327 public: \ 328 328 static KJS::JSObject* self(KJS::ExecState* exec); \ … … 330 330 static const KJS::ClassInfo info; \ 331 331 bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&); \ 332 ClassProto (KJS::ExecState* exec) \333 : KJS::JSObject(ClassProto Proto::self(exec)) { } \332 ClassPrototype(KJS::ExecState* exec) \ 333 : KJS::JSObject(ClassPrototypePrototype::self(exec)) { } \ 334 334 \ 335 335 }; 336 336 337 #define KJS_IMPLEMENT_PROTOTYPE(ClassName, ClassProto , ClassFunc) \338 const ClassInfo ClassProto ::info = { ClassName, 0, &ClassProto##Table, 0 }; \339 JSObject* ClassProto ::self(ExecState* exec) \337 #define KJS_IMPLEMENT_PROTOTYPE(ClassName, ClassPrototype, ClassFunction) \ 338 const ClassInfo ClassPrototype::info = { ClassName"Prototype", 0, &ClassPrototype##Table, 0 }; \ 339 JSObject* ClassPrototype::self(ExecState* exec) \ 340 340 { \ 341 return KJS::cacheGlobalObject<ClassProto >(exec, "[[" ClassName ".prototype]]"); \341 return KJS::cacheGlobalObject<ClassPrototype>(exec, "[[" ClassName ".prototype]]"); \ 342 342 } \ 343 bool ClassProto ::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) \343 bool ClassPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) \ 344 344 { \ 345 return getStaticFunctionSlot<ClassFunc , JSObject>(exec, &ClassProto##Table, this, propertyName, slot); \345 return getStaticFunctionSlot<ClassFunction, JSObject>(exec, &ClassPrototype##Table, this, propertyName, slot); \ 346 346 } 347 347 348 #define KJS_IMPLEMENT_PROTO FUNC(ClassFunc) \349 class ClassFunc : public InternalFunctionImp { \348 #define KJS_IMPLEMENT_PROTOTYPE_FUNCTION(ClassFunction) \ 349 class ClassFunction : public InternalFunctionImp { \ 350 350 public: \ 351 ClassFunc (ExecState* exec, int i, int len, const Identifier& name) \351 ClassFunction(ExecState* exec, int i, int len, const Identifier& name) \ 352 352 : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name) \ 353 353 , id(i) \
Note:
See TracChangeset
for help on using the changeset viewer.