Reviewed by Geoff.
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2007 23:16:37 +0000 (23:16 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2007 23:16:37 +0000 (23:16 +0000)
        Get rid of Instance::setRootObject and pass the root object to the instance constructor instead.

        * bindings/c/c_instance.cpp:
        (KJS::Bindings::CInstance::CInstance):
        * bindings/c/c_instance.h:
        * bindings/jni/jni_instance.cpp:
        (JavaInstance::JavaInstance):
        * bindings/jni/jni_instance.h:
        * bindings/jni/jni_jsobject.cpp:
        (JavaJSObject::convertJObjectToValue):
        * bindings/objc/objc_instance.h:
        * bindings/objc/objc_instance.mm:
        (ObjcInstance::ObjcInstance):
        * bindings/runtime.cpp:
        (KJS::Bindings::Instance::Instance):
        (KJS::Bindings::Instance::createBindingForLanguageInstance):
        * bindings/runtime.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@22056 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/bindings/c/c_instance.cpp
JavaScriptCore/bindings/c/c_instance.h
JavaScriptCore/bindings/jni/jni_instance.cpp
JavaScriptCore/bindings/jni/jni_instance.h
JavaScriptCore/bindings/jni/jni_jsobject.cpp
JavaScriptCore/bindings/objc/objc_instance.h
JavaScriptCore/bindings/objc/objc_instance.mm
JavaScriptCore/bindings/runtime.cpp
JavaScriptCore/bindings/runtime.h

index 85b42edbc7cd384e9942ef61ae426d95782a7ad3..98080bc0de5fa43273a072c9dc5686f87ef62b7c 100644 (file)
@@ -1,3 +1,25 @@
+2007-06-07  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Geoff.
+
+        Get rid of Instance::setRootObject and pass the root object to the instance constructor instead.
+        
+        * bindings/c/c_instance.cpp:
+        (KJS::Bindings::CInstance::CInstance):
+        * bindings/c/c_instance.h:
+        * bindings/jni/jni_instance.cpp:
+        (JavaInstance::JavaInstance):
+        * bindings/jni/jni_instance.h:
+        * bindings/jni/jni_jsobject.cpp:
+        (JavaJSObject::convertJObjectToValue):
+        * bindings/objc/objc_instance.h:
+        * bindings/objc/objc_instance.mm:
+        (ObjcInstance::ObjcInstance):
+        * bindings/runtime.cpp:
+        (KJS::Bindings::Instance::Instance):
+        (KJS::Bindings::Instance::createBindingForLanguageInstance):
+        * bindings/runtime.h:
+
 2007-06-07  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Adam.
index 2024a033baa5153ae84a3af9197493831cafd143..c6a7c12b3673c4c96512d55e44e3d9947dd731b3 100644 (file)
 namespace KJS {
 namespace Bindings {
 
-CInstance::CInstance(NPObject* o) 
+CInstance::CInstance(NPObject* o, PassRefPtr<RootObject> rootObject)
+    : Instance(rootObject)
 {
     _object = _NPN_RetainObject(o);
     _class = 0;
-    setRootObject(0);
 }
 
 CInstance::~CInstance() 
index 7a9e96b0833d24bcb6b94f7d1058cff100462cd2..8a8bdb7ce3acf074cc011f5f64ef5577d006f50e 100644 (file)
@@ -39,7 +39,7 @@ class CClass;
 
 class CInstance : public Instance {
 public:
-    CInstance (NPObject*);
+    CInstance (NPObject*, PassRefPtr<RootObject>);
     ~CInstance ();
     
     virtual Class *getClass() const;
index 990131959c1a96e2fe619f3a6462cc114d93fb95..dd44e5f7f0628bd443a09e0fce2780540ddd2cdc 100644 (file)
@@ -43,7 +43,8 @@
 using namespace KJS::Bindings;
 using namespace KJS;
 
-JavaInstance::JavaInstance (jobject instance) 
+JavaInstance::JavaInstance (jobject instance, PassRefPtr<RootObject> rootObject)
+    : Instance(rootObject)
 {
     _instance = new JObjectWrapper (instance);
     _class = 0;
index f6ea715e048d7ce4cb6220509a62a29ec4fa7e19..9e98bd752e98110141e2533c27751592c9defae9 100644 (file)
@@ -67,7 +67,7 @@ private:
 class JavaInstance : public Instance
 {
 public:
-    JavaInstance(jobject instance);
+    JavaInstance(jobject instance, PassRefPtr<RootObject>);
     ~JavaInstance();
     
     virtual Class *getClass() const;
index 44e7bec96cc84bf014e9b13ebce27ba67f8f00ec..84f1e0a0e4cc5d0d500c62a390786d2a02944c43 100644 (file)
@@ -455,8 +455,7 @@ JSValue *JavaJSObject::convertJObjectToValue (jobject theObject) const
     }
 
     JSLock lock;
-    JavaInstance* javaInstance = new JavaInstance(theObject);
-    javaInstance->setRootObject(rootObject());
+    JavaInstance* javaInstance = new JavaInstance(theObject, _rootObject);
     RuntimeObjectImp* newImp = new RuntimeObjectImp(javaInstance);
 
     return newImp;
index 014c7599eef526f893e5ceeff07e2532d0c69fce..c2e1c4ddd0da693ef7ffe756721b2b8967ecfed2 100644 (file)
@@ -37,7 +37,7 @@ class ObjcClass;
 
 class ObjcInstance : public Instance {
 public:
-    ObjcInstance(ObjectStructPtr instance);
+    ObjcInstance(ObjectStructPtr instance, PassRefPtr<RootObject>);
         
     ~ObjcInstance();
     
index a85d574bfda8cde06ff6e5e6c37b60e6cfb1f294..ec12fb76d9802dd0659a1b72832ac5980110b6f1 100644 (file)
@@ -40,7 +40,8 @@
 using namespace KJS::Bindings;
 using namespace KJS;
 
-ObjcInstance::ObjcInstance(ObjectStructPtr instance) 
+ObjcInstance::ObjcInstance(ObjectStructPtr instance, PassRefPtr<RootObject> rootObject) 
+    : Instance(rootObject)
 {
     _instance = instance;
     if (_instance)
index 9d0f4ad489c858b25552a6949377a8c4b17d80fc..a0f438d96477f3100e4c1809cd9d7a1ba63a574d 100644 (file)
@@ -95,8 +95,9 @@ MethodList &MethodList::operator=(const MethodList &other)
 }
 
 
-Instance::Instance()
-    : _refCount(0)
+Instance::Instance(PassRefPtr<RootObject> rootObject)
+    : _rootObject(rootObject)
+    , _refCount(0)
 {
 }
 
@@ -126,23 +127,23 @@ Instance* Instance::createBindingForLanguageInstance(BindingLanguage language, v
     switch (language) {
 #if HAVE(JNI)
         case Instance::JavaLanguage: {
-            newInstance = new Bindings::JavaInstance((jobject)nativeInstance);
+            newInstance = new Bindings::JavaInstance((jobject)nativeInstance, rootObject);
             break;
         }
 #endif
 #if PLATFORM(MAC)
         case Instance::ObjectiveCLanguage: {
-            newInstance = new Bindings::ObjcInstance((ObjectStructPtr)nativeInstance);
+            newInstance = new Bindings::ObjcInstance((ObjectStructPtr)nativeInstance, rootObject);
             break;
         }
 #endif
         case Instance::CLanguage: {
-            newInstance = new Bindings::CInstance((NPObject *)nativeInstance);
+            newInstance = new Bindings::CInstance((NPObject *)nativeInstance, rootObject);
             break;
         }
 #if PLATFORM(QT)
         case Instance::QtLanguage: {
-            newInstance = new Bindings::QtInstance((QObject *)nativeInstance);
+            newInstance = new Bindings::QtInstance((QObject *)nativeInstance, rootObject);
             break;
         }
 #endif
@@ -150,9 +151,6 @@ Instance* Instance::createBindingForLanguageInstance(BindingLanguage language, v
             break;
     }
 
-    if (newInstance)
-        newInstance->setRootObject(rootObject);
-        
     return newInstance;
 }
 
@@ -164,11 +162,6 @@ JSObject* Instance::createRuntimeObject(BindingLanguage language, void* nativeIn
     return new RuntimeObjectImp(instance);
 }
 
-void Instance::setRootObject(PassRefPtr<RootObject> rootObject)
-{
-    _rootObject = rootObject;
-}
-
 RootObject* Instance::rootObject() const 
 { 
     return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0;
index 2e3a769c23847ed78d28d651a391ad31f7fab7d7..ee2083e4ea762d1f154a54d5795fa69a5dcb952b 100644 (file)
@@ -137,7 +137,7 @@ public:
 #endif
     } BindingLanguage;
 
-    Instance();
+    Instance(PassRefPtr<RootObject>);
 
     static void setDidExecuteFunction(KJSDidExecuteFunctionPtr func);
     static KJSDidExecuteFunctionPtr didExecuteFunction();
@@ -177,7 +177,6 @@ public:
     
     virtual JSValue* valueOf() const { return jsString(getClass()->name()); }
     
-    void setRootObject(PassRefPtr<RootObject>);
     RootObject* rootObject() const;
     
     virtual ~Instance();