Reviewed by Darin and Maciej.
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Jun 2007 00:22:19 +0000 (00:22 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Jun 2007 00:22:19 +0000 (00:22 +0000)
        More cleanup. Use our Noncopyable WTF class, add a root object member
        to the Array class.

        * bindings/c/c_class.h:
        * bindings/jni/jni_class.h:
        * bindings/jni/jni_instance.h:
        * bindings/jni/jni_runtime.cpp:
        (JavaArray::JavaArray):
        * bindings/jni/jni_runtime.h:
        * bindings/objc/objc_class.h:
        * bindings/objc/objc_runtime.h:
        * bindings/objc/objc_runtime.mm:
        (ObjcArray::ObjcArray):
        * bindings/objc/objc_utility.mm:
        (KJS::Bindings::convertObjcValueToValue):
        * bindings/runtime.cpp:
        (KJS::Bindings::Array::Array):
        (KJS::Bindings::Array::~Array):
        * bindings/runtime.h:
        * bindings/runtime_object.h:
        * bindings/runtime_root.h:

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

14 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/bindings/c/c_class.h
JavaScriptCore/bindings/jni/jni_class.h
JavaScriptCore/bindings/jni/jni_instance.h
JavaScriptCore/bindings/jni/jni_runtime.cpp
JavaScriptCore/bindings/jni/jni_runtime.h
JavaScriptCore/bindings/objc/objc_class.h
JavaScriptCore/bindings/objc/objc_runtime.h
JavaScriptCore/bindings/objc/objc_runtime.mm
JavaScriptCore/bindings/objc/objc_utility.mm
JavaScriptCore/bindings/runtime.cpp
JavaScriptCore/bindings/runtime.h
JavaScriptCore/bindings/runtime_object.h
JavaScriptCore/bindings/runtime_root.h

index 08ecf2f75f4f964f8d677590d3c9d0aca26ea726..5214e190dc2327584358b267bceb6d0c4723e99a 100644 (file)
@@ -1,3 +1,29 @@
+2007-06-12  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Darin and Maciej.
+
+        More cleanup. Use our Noncopyable WTF class, add a root object member
+        to the Array class.
+        
+        * bindings/c/c_class.h:
+        * bindings/jni/jni_class.h:
+        * bindings/jni/jni_instance.h:
+        * bindings/jni/jni_runtime.cpp:
+        (JavaArray::JavaArray):
+        * bindings/jni/jni_runtime.h:
+        * bindings/objc/objc_class.h:
+        * bindings/objc/objc_runtime.h:
+        * bindings/objc/objc_runtime.mm:
+        (ObjcArray::ObjcArray):
+        * bindings/objc/objc_utility.mm:
+        (KJS::Bindings::convertObjcValueToValue):
+        * bindings/runtime.cpp:
+        (KJS::Bindings::Array::Array):
+        (KJS::Bindings::Array::~Array):
+        * bindings/runtime.h:
+        * bindings/runtime_object.h:
+        * bindings/runtime_root.h:
+
 2007-06-08  Zack Rusin  <zrusin@trolltech.com>
 
         Fix the Qt build
index 5f5c21e7aeb5449eae957fc45d4a0f27fe8f291d..3fe99543c9b933f99b1edb3987bd6ce5aa259411 100644 (file)
@@ -49,9 +49,6 @@ public:
     virtual int numConstructors() const { return 0; }
 
 private:
-    CClass(const CClass&); // prohibit copying
-    CClass& operator=(const CClass&); // prohibit assignment
-
     NPClass* _isa;
     mutable MethodMap _methods;
     mutable FieldMap _fields;
index 8180ffa4bcc9d7e2e582a898fb28be87ce03694e..4249b3965a9e08bf873745fb67cfe23f6681e435 100644 (file)
@@ -56,8 +56,6 @@ public:
     
 private:
     JavaClass ();                                 // prevent default construction
-    JavaClass (const JavaClass &other);           // prevent copying
-    JavaClass &operator=(const JavaClass &other); // prevent copying
     
     const char *_name;
     FieldMap _fields;
index 9e98bd752e98110141e2533c27751592c9defae9..6c0a3b02942b88c5bffc9ffb77eecba44fb08ce7 100644 (file)
@@ -87,9 +87,6 @@ public:
     JSValue *booleanValue() const;
         
 private:
-    JavaInstance (JavaInstance &);           // prevent copying
-    JavaInstance &operator=(JavaInstance &); // prevent copying
-    
     RefPtr<JObjectWrapper> _instance;
     mutable JavaClass *_class;
 };
index 796a85a57bf386e7b0e8468a6ce7995e3ae76479..18a52e61f65ae727544b6daa5a68a23cebc7df82 100644 (file)
@@ -380,7 +380,8 @@ jmethodID JavaMethod::methodID (jobject obj) const
 }
 
 
-JavaArray::JavaArray(jobject array, const char* type, PassRefPtr<RootObject> rootObject) 
+JavaArray::JavaArray(jobject array, const char* type, PassRefPtr<RootObject> rootObject)
+    : Array(rootObject)
 {
     _array = new JObjectWrapper(array);
     // Java array are fixed length, so we can cache length.
index b7acbe59dfceb4875a23d515eedc96b2c5643f74..91a51dbae118f874e18ff5f317131c37c4563331 100644 (file)
@@ -252,13 +252,9 @@ public:
     static JSValue* convertJObjectToArray (ExecState* exec, jobject anObject, const char* type, PassRefPtr<RootObject>);
 
 private:
-    JavaArray(const JavaArray&);
-    JavaArray& operator=(const JavaArray&);
-
     RefPtr<JObjectWrapper> _array;
     unsigned int _length;
     const char *_type;
-    RefPtr<RootObject> _rootObject;
 };
 
 } // namespace Bindings
index ccd5af8f3d36c6a5b156c968b3c64a81bd34a8f9..a520107dd6bb69c66cbfbedc1824c61ec022e70c 100644 (file)
@@ -55,9 +55,6 @@ public:
     ClassStructPtr isa() { return _isa; }
     
 private:
-    ObjcClass(const ObjcClass &other); // prohibit copying
-    ObjcClass &operator=(const ObjcClass &other); // ditto
-    
     ClassStructPtr _isa;
     CFMutableDictionaryRef _methods;
     CFMutableDictionaryRef _fields;
index 16be0eeec2ecf12e6535db27643ad8da2ba53451..d53d8805e9376257734335650355a821de63dce9 100644 (file)
@@ -121,11 +121,8 @@ private:
 class ObjcArray : public Array
 {
 public:
-    ObjcArray(ObjectStructPtr);
+    ObjcArray(ObjectStructPtr, PassRefPtr<RootObject>);
 
-    ObjcArray(const ObjcArray &);
-    ObjcArray &operator=(const ObjcArray &);
-    
     virtual ~ObjcArray();
 
     virtual void setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const;
@@ -140,7 +137,7 @@ private:
     ObjectStructPtr _array;
 };
 
-class ObjcFallbackObjectImp : public JSObject {
+class ObjcFallbackObjectImp : public JSObject, Noncopyable {
 public:
     ObjcFallbackObjectImp(ObjcInstance *i, const Identifier propertyName);
 
@@ -159,8 +156,6 @@ public:
 
 private:
     ObjcFallbackObjectImp(); // prevent default construction
-    ObjcFallbackObjectImp(const ObjcFallbackObjectImp& other); // prevent copying
-    ObjcFallbackObjectImp& operator=(const ObjcFallbackObjectImp& other); // ditto
     
     static const ClassInfo info;
 
index 0aa7cc9828c9445cc8fba503175531359d3da577..fe876a5477bce93de82b758fa3a62f732cca095b 100644 (file)
@@ -171,7 +171,8 @@ void ObjcField::setValueToInstance(ExecState* exec, const Instance* instance, JS
 
 // ---------------------- ObjcArray ----------------------
 
-ObjcArray::ObjcArray (ObjectStructPtr a) 
+ObjcArray::ObjcArray(ObjectStructPtr a, PassRefPtr<RootObject> rootObject)
+    : Array(rootObject)
 {
     _array = (id)CFRetain(a);
 }
@@ -181,21 +182,6 @@ ObjcArray::~ObjcArray ()
     CFRelease(_array);
 }
 
-ObjcArray::ObjcArray (const ObjcArray &other) : Array() 
-{
-    _array = other._array;
-    CFRetain(_array);
-}
-
-ObjcArray &ObjcArray::operator=(const ObjcArray &other)
-{
-    ObjectStructPtr _oldArray = _array;
-    _array = other._array;
-    CFRetain(_array);
-    CFRelease(_oldArray);
-    return* this;
-}
-
 void ObjcArray::setValueAt(ExecState* exec, unsigned int index, JSValue* aValue) const
 {
     if (![_array respondsToSelector:@selector(insertObject:atIndex:)]) {
index 77a3bd6940e0c63dfefbf68b5c8e1e6fb612fe38..4be850cba510cff5191de5abf233556ceeff0bf3 100644 (file)
@@ -243,7 +243,7 @@ JSValue* convertObjcValueToValue(ExecState* exec, void* buffer, ObjcValueType ty
             if ([obj isKindOfClass:[NSNumber class]])
                 return jsNumber([obj doubleValue]);
             if ([obj isKindOfClass:[NSArray class]])
-                return new RuntimeArray(exec, new ObjcArray(obj));
+                return new RuntimeArray(exec, new ObjcArray(obj, 0));
             if ([obj isKindOfClass:webScriptObjectClass()])
                 return [obj _imp];
             if ([obj isKindOfClass:[NSNull class]])
index a0f438d96477f3100e4c1809cd9d7a1ba63a574d..63453a54ae83fee47d187a0846b06f21118bb466 100644 (file)
@@ -94,6 +94,14 @@ MethodList &MethodList::operator=(const MethodList &other)
     return *this;
 }
 
+Array::Array(PassRefPtr<RootObject> rootObject)
+    : _rootObject(rootObject)
+{
+}
+
+Array::~Array()
+{
+}
 
 Instance::Instance(PassRefPtr<RootObject> rootObject)
     : _rootObject(rootObject)
index ee2083e4ea762d1f154a54d5795fa69a5dcb952b..6809bf38e28f2bb49799920aa54b280d36990e09 100644 (file)
@@ -107,7 +107,7 @@ public:
     virtual ~Method() {}
 };
 
-class Class
+class Class : Noncopyable
 {
 public:
     virtual const char *name() const = 0;
@@ -186,13 +186,17 @@ protected:
     unsigned _refCount;
 };
 
-class Array
+class Array : Noncopyable
 {
 public:
+    Array(PassRefPtr<RootObject>);
+    virtual ~Array();
+    
     virtual void setValueAt(ExecState *, unsigned index, JSValue*) const = 0;
     virtual JSValue* valueAt(ExecState *, unsigned index) const = 0;
     virtual unsigned int getLength() const = 0;
-    virtual ~Array() {}
+protected:
+    RefPtr<RootObject> _rootObject;
 };
 
 const char *signatureForParameters(const List&);
index 95a3a30d7e90f21383dd8a22438619d2fd35d192..7f54252b32ad8d4277166cab658a68e7337d31f8 100644 (file)
 #include "runtime.h"
 #include "object.h"
 
+#include <wtf/Noncopyable.h>
+
 namespace KJS {
 
-class RuntimeObjectImp : public JSObject {
+class RuntimeObjectImp : public JSObject, Noncopyable {
 public:
     RuntimeObjectImp(Bindings::Instance *i);
 
@@ -52,8 +54,6 @@ public:
 
 private:
     RuntimeObjectImp(); // prevent default construction
-    RuntimeObjectImp(const RuntimeObjectImp& other); // prevent copying
-    RuntimeObjectImp& operator=(const RuntimeObjectImp& other); // ditto
     
     static JSValue *fallbackObjectGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
     static JSValue *fieldGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
index 9dcca941695672328bdd864d6d5feabaf85044b7..2c82cc7b9cdee76adad3cd6988351c74517ac0e2 100644 (file)
@@ -32,6 +32,8 @@
 #endif
 #include "protect.h"
 
+#include <wtf/Noncopyable.h>
+
 namespace KJS {
 
 namespace Bindings {
@@ -44,7 +46,7 @@ typedef HashCountedSet<JSObject*> ProtectCountSet;
 extern RootObject* findRootObject(JSObject*);
 extern RootObject* findRootObject(Interpreter*);
 
-class RootObject
+class RootObject : Noncopyable
 {
 friend class JavaJSObject;
 public:
@@ -84,10 +86,6 @@ private:
     RootObject(const void* nativeHandle, PassRefPtr<Interpreter> interpreter);
     ~RootObject();
     
-    // Uncopyable
-    RootObject(const RootObject&);
-    RootObject& operator=(const RootObject&);
-    
     unsigned m_refCount;
     bool m_isValid;