khtml/kjs: cacheGlobalObject

Peter Kümmel syntheticpp at gmx.net
Sun Feb 5 21:15:03 CET 2006


I've successfully compiled khtml with msvc.

But to make it to compile I must change the template function
cacheGlobalObject.

The old usage is:

cacheGlobalObject<NodeConstructor>(...)


the new one reads nearly like as plain English:

cacheGlobal<NodeConstructor>::Object( ... );


Are there objections against changing cacheGlobalObject.

Peter


Here the main diff:

Index: kjs/lookup.h
===================================================================
--- kjs/lookup.h	(Revision 505827)
+++ kjs/lookup.h	(Arbeitskopie)
@@ -265,8 +265,9 @@
  * that cached object. Note that the object constructor must take 1 argument, exec.
  */
 template <class ClassCtor>
-inline KJS::JSObject *cacheGlobalObject(KJS::ExecState *exec, const KJS::Identifier &propertyName)
+struct cacheGlobal
 {
+  static inline KJS::JSObject *Object(KJS::ExecState *exec, const KJS::Identifier &propertyName){
   KJS::JSObject *globalObject = static_cast<KJS::JSObject *>(exec->lexicalInterpreter()->globalObject());
   KJS::JSValue *obj = globalObject->getDirect(propertyName);
   if (obj) {
@@ -277,6 +278,7 @@
   globalObject->put(exec, propertyName, newObject, KJS::Internal);
   return newObject;
 }
+};

 /**
  * Helpers to define prototype objects (each of which simply implements
@@ -296,7 +298,7 @@
  */
 #define KJS_DEFINE_PROTOTYPE(ClassProto) \
   class ClassProto : public KJS::JSObject { \
-    friend KJS::JSObject *cacheGlobalObject<ClassProto>(KJS::ExecState *exec, const KJS::Identifier &propertyName); \
+    friend struct cacheGlobal<ClassProto>; \
   public: \
     static KJS::JSObject *self(KJS::ExecState *exec); \
     virtual const KJS::ClassInfo *classInfo() const { return &info; } \
@@ -315,7 +317,7 @@
     Identifier* ClassProto::s_name = 0; \
     JSObject *ClassProto::self(ExecState *exec) \
     { \
-      return cacheGlobalObject<ClassProto>(exec, *name()); \
+      return cacheGlobal<ClassProto>::Object(exec, *name()); \
     } \
     bool ClassProto::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) \
     { \
@@ -332,7 +334,7 @@
     Identifier* ClassProto::s_name = 0; \
     JSObject *ClassProto::self(ExecState *exec) \
     { \
-      return cacheGlobalObject<ClassProto>(exec, *name()); \
+      return cacheGlobal<ClassProto>::Object(exec, *name()); \
     } \
     bool ClassProto::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) \
     { \


More information about the Kde-buildsystem mailing list