[webkit-changes] cvs commit: WebCore/khtml/ecma kjs_binding.h
Geoffrey
ggaren at opensource.apple.com
Fri Jul 1 11:56:38 PDT 2005
ggaren 05/07/01 11:56:38
Modified: . ChangeLog
kjs lookup.h
. ChangeLog
ForwardingHeaders qintdict.h
khtml/ecma kjs_binding.h
Log:
JavaScriptCore:
-landed patch by Eric Seidel <macdome at opendarwin.org>
-for http://bugzilla.opendarwin.org/show_bug.cgi?id=3657
GroundWork: Moving some functions from khtml->jsc following kjs TOT
- no layout test necessary yet - only groundwork
Reviewed by darin.
* kjs/lookup.h:
(KJS::cacheGlobalObject):
WebCore:
-landed patch by Eric Seidel <macdome at opendarwin.org>
-for http://bugzilla.opendarwin.org/show_bug.cgi?id=3657
GroundWork: Moving some functions from khtml->jsc following kjs TOT
- no layout test necessary yet - only groundwork
Reviewed by darin.
* ForwardingHeaders/qintdict.h:
* khtml/ecma/kjs_binding.h:
Revision Changes Path
1.736 +14 -0 JavaScriptCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
retrieving revision 1.735
retrieving revision 1.736
diff -u -r1.735 -r1.736
--- ChangeLog 1 Jul 2005 18:45:08 -0000 1.735
+++ ChangeLog 1 Jul 2005 18:56:31 -0000 1.736
@@ -1,5 +1,19 @@
2005-07-01 Geoffrey Garen <ggaren at apple.com>
+ -landed patch by Eric Seidel <macdome at opendarwin.org>
+
+ -for http://bugzilla.opendarwin.org/show_bug.cgi?id=3657
+ GroundWork: Moving some functions from khtml->jsc following kjs TOT
+
+ - no layout test necessary yet - only groundwork
+
+ Reviewed by darin.
+
+ * kjs/lookup.h:
+ (KJS::cacheGlobalObject):
+
+2005-07-01 Geoffrey Garen <ggaren at apple.com>
+
-landed patch by Carsten Guenther <cguenther at gmail.com>
-fixes http://bugzilla.opendarwin.org/show_bug.cgi?id=3477
1.10 +99 -0 JavaScriptCore/kjs/lookup.h
Index: lookup.h
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/lookup.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- lookup.h 21 Jan 2005 01:22:08 -0000 1.9
+++ lookup.h 1 Jul 2005 18:56:32 -0000 1.10
@@ -23,6 +23,7 @@
#ifndef _KJSLOOKUP_H_
#define _KJSLOOKUP_H_
+#include "interpreter.h"
#include "identifier.h"
#include "object.h"
#include <stdio.h>
@@ -239,6 +240,104 @@
else
thisObj->putValueProperty(exec, entry->value, value, attr);
}
+
+ /**
+ * This template method retrieves or create an object that is unique
+ * (for a given interpreter) The first time this is called (for a given
+ * property name), the Object will be constructed, and set as a property
+ * of the interpreter's global object. Later calls will simply retrieve
+ * that cached object. Note that the object constructor must take 1 argument, exec.
+ */
+ template <class ClassCtor>
+ inline ObjectImp *cacheGlobalObject(ExecState *exec, const Identifier &propertyName)
+ {
+ ObjectImp *globalObject = static_cast<ObjectImp *>(exec->lexicalInterpreter()->globalObject().imp());
+ ValueImp *obj = globalObject->getDirect(propertyName);
+ if (obj) {
+ assert(obj->isObject());
+ return static_cast<ObjectImp *>(obj);
+ }
+ ObjectImp *newObject = new ClassCtor(exec);
+ globalObject->put(exec, propertyName, Value(newObject), Internal);
+ return newObject;
+ }
+
+ /**
+ * Helpers to define prototype objects (each of which simply implements
+ * the functions for a type of objects).
+ * Sorry for this not being very readable, but it actually saves much copy-n-paste.
+ * ParentProto is not our base class, it's the object we use as fallback.
+ * The reason for this is that there should only be ONE DOMNode.hasAttributes (e.g.),
+ * not one in each derived class. So we link the (unique) prototypes between them.
+ *
+ * Using those macros is very simple: define the hashtable (e.g. "DOMNodeProtoTable"), then
+ * DEFINE_PROTOTYPE("DOMNode",DOMNodeProto)
+ * IMPLEMENT_PROTOFUNC(DOMNodeProtoFunc)
+ * IMPLEMENT_PROTOTYPE(DOMNodeProto,DOMNodeProtoFunc)
+ * and use DOMNodeProto::self(exec) as prototype in the DOMNode constructor.
+ * If the prototype has a "parent prototype", e.g. DOMElementProto falls back on DOMNodeProto,
+ * then the last line will use IMPLEMENT_PROTOTYPE_WITH_PARENT, with DOMNodeProto as last argument.
+ */
+#define DEFINE_PROTOTYPE(ClassName,ClassProto) \
+ class ClassProto : public ObjectImp { \
+ friend ObjectImp *cacheGlobalObject<ClassProto>(ExecState *exec, const Identifier &propertyName); \
+ public: \
+ static ObjectImp *self(ExecState *exec) \
+ { \
+ return cacheGlobalObject<ClassProto>( exec, "[[" ClassName ".prototype]]" ); \
+ } \
+ protected: \
+ ClassProto( ExecState *exec ) \
+ : ObjectImp( exec->lexicalInterpreter()->builtinObjectPrototype() ) {} \
+ \
+ public: \
+ virtual const ClassInfo *classInfo() const { return &info; } \
+ static const ClassInfo info; \
+ Value get(ExecState *exec, const Identifier &propertyName) const; \
+ bool hasProperty(ExecState *exec, const Identifier &propertyName) const; \
+ }; \
+ const ClassInfo ClassProto::info = { ClassName, 0, &ClassProto##Table, 0 };
+
+#define IMPLEMENT_PROTOTYPE(ClassProto,ClassFunc) \
+ Value ClassProto::get(ExecState *exec, const Identifier &propertyName) const \
+ { \
+ /*fprintf( stderr, "%sProto::get(%s) [in macro, no parent]\n", info.className, propertyName.ascii());*/ \
+ return lookupGetFunction<ClassFunc,ObjectImp>(exec, propertyName, &ClassProto##Table, this ); \
+ } \
+ bool ClassProto::hasProperty(ExecState *exec, const Identifier &propertyName) const \
+ { /*stupid but we need this to have a common macro for the declaration*/ \
+ return ObjectImp::hasProperty(exec, propertyName); \
+ }
+
+#define IMPLEMENT_PROTOTYPE_WITH_PARENT(ClassProto,ClassFunc,ParentProto) \
+ Value ClassProto::get(ExecState *exec, const Identifier &propertyName) const \
+ { \
+ /*fprintf( stderr, "%sProto::get(%s) [in macro]\n", info.className, propertyName.ascii());*/ \
+ Value val = lookupGetFunction<ClassFunc,ObjectImp>(exec, propertyName, &ClassProto##Table, this ); \
+ if ( val.type() != UndefinedType ) return val; \
+ /* Not found -> forward request to "parent" prototype */ \
+ return ParentProto::self(exec)->get( exec, propertyName ); \
+ } \
+ bool ClassProto::hasProperty(ExecState *exec, const Identifier &propertyName) const \
+ { \
+ if (ObjectImp::hasProperty(exec, propertyName)) \
+ return true; \
+ return ParentProto::self(exec)->hasProperty(exec, propertyName); \
+ }
+
+#define IMPLEMENT_PROTOFUNC(ClassFunc) \
+ class ClassFunc : public DOMFunction { \
+ public: \
+ ClassFunc(ExecState *exec, int i, int len) \
+ : DOMFunction( /*proto? */ ), id(i) { \
+ Value protect(this); \
+ put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum); \
+ } \
+ /** You need to implement that one */ \
+ virtual Value tryCall(ExecState *exec, Object &thisObj, const List &args); \
+ private: \
+ int id; \
+ };
/*
* List of things to do when porting an objectimp to the 'static hashtable' mechanism:
1.4347 +14 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.4346
retrieving revision 1.4347
diff -u -r1.4346 -r1.4347
--- ChangeLog 1 Jul 2005 18:45:09 -0000 1.4346
+++ ChangeLog 1 Jul 2005 18:56:32 -0000 1.4347
@@ -1,5 +1,19 @@
2005-07-01 Geoffrey Garen <ggaren at apple.com>
+ -landed patch by Eric Seidel <macdome at opendarwin.org>
+
+ -for http://bugzilla.opendarwin.org/show_bug.cgi?id=3657
+ GroundWork: Moving some functions from khtml->jsc following kjs TOT
+
+ - no layout test necessary yet - only groundwork
+
+ Reviewed by darin.
+
+ * ForwardingHeaders/qintdict.h:
+ * khtml/ecma/kjs_binding.h:
+
+2005-07-01 Geoffrey Garen <ggaren at apple.com>
+
-landed patch by Carsten Guenther <cguenther at gmail.com>
http://bugzilla.opendarwin.org/show_bug.cgi?id=3477
1.3 +2 -0 WebCore/ForwardingHeaders/qintdict.h
Index: qintdict.h
===================================================================
RCS file: /cvs/root/WebCore/ForwardingHeaders/qintdict.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- qintdict.h 23 Jun 2005 03:15:26 -0000 1.2
+++ qintdict.h 1 Jul 2005 18:56:38 -0000 1.3
@@ -1 +1,3 @@
+#import <KWQIntDict.h>
+
#import "KWQIntDict.h"
1.28 +0 -98 WebCore/khtml/ecma/kjs_binding.h
Index: kjs_binding.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_binding.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- kjs_binding.h 22 Jun 2005 00:48:44 -0000 1.27
+++ kjs_binding.h 1 Jul 2005 18:56:38 -0000 1.28
@@ -259,104 +259,6 @@
thisObj->putValue(exec, entry->value, value, attr);
}
- /**
- * This template method retrieves or create an object that is unique
- * (for a given interpreter) The first time this is called (for a given
- * property name), the Object will be constructed, and set as a property
- * of the interpreter's global object. Later calls will simply retrieve
- * that cached object. Note that the object constructor must take 1 argument, exec.
- */
- template <class ClassCtor>
- inline ObjectImp *cacheGlobalObject(ExecState *exec, const Identifier &propertyName)
- {
- ObjectImp *globalObject = static_cast<ObjectImp *>(exec->lexicalInterpreter()->globalObject().imp());
- ValueImp *obj = globalObject->getDirect(propertyName);
- if (obj) {
- assert(obj->isObject());
- return static_cast<ObjectImp *>(obj);
- }
- ObjectImp *newObject = new ClassCtor(exec);
- globalObject->put(exec, propertyName, Value(newObject), Internal);
- return newObject;
- }
-
- /**
- * Helpers to define prototype objects (each of which simply implements
- * the functions for a type of objects).
- * Sorry for this not being very readable, but it actually saves much copy-n-paste.
- * ParentProto is not our base class, it's the object we use as fallback.
- * The reason for this is that there should only be ONE DOMNode.hasAttributes (e.g.),
- * not one in each derived class. So we link the (unique) prototypes between them.
- *
- * Using those macros is very simple: define the hashtable (e.g. "DOMNodeProtoTable"), then
- * DEFINE_PROTOTYPE("DOMNode",DOMNodeProto)
- * IMPLEMENT_PROTOFUNC(DOMNodeProtoFunc)
- * IMPLEMENT_PROTOTYPE(DOMNodeProto,DOMNodeProtoFunc)
- * and use DOMNodeProto::self(exec) as prototype in the DOMNode constructor.
- * If the prototype has a "parent prototype", e.g. DOMElementProto falls back on DOMNodeProto,
- * then the last line will use IMPLEMENT_PROTOTYPE_WITH_PARENT, with DOMNodeProto as last argument.
- */
-#define DEFINE_PROTOTYPE(ClassName,ClassProto) \
- class ClassProto : public ObjectImp { \
- friend ObjectImp *cacheGlobalObject<ClassProto>(ExecState *exec, const Identifier &propertyName); \
- public: \
- static ObjectImp *self(ExecState *exec) \
- { \
- return cacheGlobalObject<ClassProto>( exec, "[[" ClassName ".prototype]]" ); \
- } \
- protected: \
- ClassProto( ExecState *exec ) \
- : ObjectImp( exec->lexicalInterpreter()->builtinObjectPrototype() ) {} \
- \
- public: \
- virtual const ClassInfo *classInfo() const { return &info; } \
- static const ClassInfo info; \
- Value get(ExecState *exec, const Identifier &propertyName) const; \
- bool hasProperty(ExecState *exec, const Identifier &propertyName) const; \
- }; \
- const ClassInfo ClassProto::info = { ClassName, 0, &ClassProto##Table, 0 };
-
-#define IMPLEMENT_PROTOTYPE(ClassProto,ClassFunc) \
- Value ClassProto::get(ExecState *exec, const Identifier &propertyName) const \
- { \
- /*fprintf( stderr, "%sProto::get(%s) [in macro, no parent]\n", info.className, propertyName.ascii());*/ \
- return lookupGetFunction<ClassFunc,ObjectImp>(exec, propertyName, &ClassProto##Table, this ); \
- } \
- bool ClassProto::hasProperty(ExecState *exec, const Identifier &propertyName) const \
- { /*stupid but we need this to have a common macro for the declaration*/ \
- return ObjectImp::hasProperty(exec, propertyName); \
- }
-
-#define IMPLEMENT_PROTOTYPE_WITH_PARENT(ClassProto,ClassFunc,ParentProto) \
- Value ClassProto::get(ExecState *exec, const Identifier &propertyName) const \
- { \
- /*fprintf( stderr, "%sProto::get(%s) [in macro]\n", info.className, propertyName.ascii());*/ \
- Value val = lookupGetFunction<ClassFunc,ObjectImp>(exec, propertyName, &ClassProto##Table, this ); \
- if ( val.type() != UndefinedType ) return val; \
- /* Not found -> forward request to "parent" prototype */ \
- return ParentProto::self(exec)->get( exec, propertyName ); \
- } \
- bool ClassProto::hasProperty(ExecState *exec, const Identifier &propertyName) const \
- { \
- if (ObjectImp::hasProperty(exec, propertyName)) \
- return true; \
- return ParentProto::self(exec)->hasProperty(exec, propertyName); \
- }
-
-#define IMPLEMENT_PROTOFUNC(ClassFunc) \
- class ClassFunc : public DOMFunction { \
- public: \
- ClassFunc(ExecState *exec, int i, int len) \
- : DOMFunction( /*proto? */ ), id(i) { \
- Value protect(this); \
- put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum); \
- } \
- /** You need to implement that one */ \
- virtual Value tryCall(ExecState *exec, Object &thisObj, const List &args); \
- private: \
- int id; \
- };
-
} // namespace
#endif
More information about the webkit-changes
mailing list