Remove support for method overloading from bridge code
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Sep 2012 02:18:06 +0000 (02:18 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Sep 2012 02:18:06 +0000 (02:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=97959

Reviewed by Dan Bernstein.

Source/WebCore:

The method overloading handling was only in place for the (now removed) Java bridge.
Replace MethodList everywhere with a single Method pointer.

* GNUmakefile.am:
* GNUmakefile.list.am:
* WebCore.exp.in:
* bridge/c/c_class.cpp:
(JSC::Bindings::CClass::methodNamed):
* bridge/c/c_class.h:
(CClass):
* bridge/c/c_instance.cpp:
(JSC::Bindings::CRuntimeMethod::create):
(JSC::Bindings::CRuntimeMethod::CRuntimeMethod):
(JSC::Bindings::CInstance::getMethod):
(JSC::Bindings::CInstance::invokeMethod):
* bridge/jsc/BridgeJSC.h:
(Bindings):
(Class):
* bridge/objc/objc_class.h:
(ObjcClass):
* bridge/objc/objc_class.mm:
(JSC::Bindings::ObjcClass::methodNamed):
* bridge/objc/objc_instance.mm:
(ObjCRuntimeMethod::create):
(ObjCRuntimeMethod::ObjCRuntimeMethod):
(ObjcInstance::invokeMethod):
* bridge/qt/qt_class.cpp:
(JSC::Bindings::QtClass::methodNamed):
* bridge/qt/qt_class.h:
(QtClass):
* bridge/qt/qt_instance.cpp:
(JSC::Bindings::QtInstance::getMethod):
* bridge/runtime_method.cpp:
(JSC::RuntimeMethod::RuntimeMethod):
(JSC::RuntimeMethod::lengthGetter):
(JSC::callRuntimeMethod):
* bridge/runtime_method.h:
(JSC::RuntimeMethod::create):
(JSC::RuntimeMethod::method):
(RuntimeMethod):
* bridge/runtime_object.cpp:
(JSC::Bindings::RuntimeObject::getOwnPropertySlot):
(JSC::Bindings::RuntimeObject::getOwnPropertyDescriptor):

Source/WebKit/mac:

Update for WebCore changes; MethodList has been replaced with a single Method* everywhere.

* Plugins/Hosted/ProxyInstance.h:
(ProxyInstance):
* Plugins/Hosted/ProxyInstance.mm:
(ProxyClass):
(WebKit::ProxyClass::methodNamed):
(WebKit::ProxyRuntimeMethod::create):
(WebKit::ProxyRuntimeMethod::ProxyRuntimeMethod):
(WebKit::ProxyInstance::getMethod):
(WebKit::ProxyInstance::invokeMethod):
(WebKit::ProxyInstance::methodNamed):

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

20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.am
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.exp.in
Source/WebCore/bridge/c/c_class.cpp
Source/WebCore/bridge/c/c_class.h
Source/WebCore/bridge/c/c_instance.cpp
Source/WebCore/bridge/jsc/BridgeJSC.h
Source/WebCore/bridge/objc/objc_class.h
Source/WebCore/bridge/objc/objc_class.mm
Source/WebCore/bridge/objc/objc_instance.mm
Source/WebCore/bridge/qt/qt_class.cpp
Source/WebCore/bridge/qt/qt_class.h
Source/WebCore/bridge/qt/qt_instance.cpp
Source/WebCore/bridge/runtime_method.cpp
Source/WebCore/bridge/runtime_method.h
Source/WebCore/bridge/runtime_object.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Plugins/Hosted/ProxyInstance.h
Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm

index 66b423c..dc1b8de 100644 (file)
@@ -1,3 +1,54 @@
+2012-09-28  Anders Carlsson  <andersca@apple.com>
+
+        Remove support for method overloading from bridge code
+        https://bugs.webkit.org/show_bug.cgi?id=97959
+
+        Reviewed by Dan Bernstein.
+
+        The method overloading handling was only in place for the (now removed) Java bridge. 
+        Replace MethodList everywhere with a single Method pointer.
+
+        * GNUmakefile.am:
+        * GNUmakefile.list.am:
+        * WebCore.exp.in:
+        * bridge/c/c_class.cpp:
+        (JSC::Bindings::CClass::methodNamed):
+        * bridge/c/c_class.h:
+        (CClass):
+        * bridge/c/c_instance.cpp:
+        (JSC::Bindings::CRuntimeMethod::create):
+        (JSC::Bindings::CRuntimeMethod::CRuntimeMethod):
+        (JSC::Bindings::CInstance::getMethod):
+        (JSC::Bindings::CInstance::invokeMethod):
+        * bridge/jsc/BridgeJSC.h:
+        (Bindings):
+        (Class):
+        * bridge/objc/objc_class.h:
+        (ObjcClass):
+        * bridge/objc/objc_class.mm:
+        (JSC::Bindings::ObjcClass::methodNamed):
+        * bridge/objc/objc_instance.mm:
+        (ObjCRuntimeMethod::create):
+        (ObjCRuntimeMethod::ObjCRuntimeMethod):
+        (ObjcInstance::invokeMethod):
+        * bridge/qt/qt_class.cpp:
+        (JSC::Bindings::QtClass::methodNamed):
+        * bridge/qt/qt_class.h:
+        (QtClass):
+        * bridge/qt/qt_instance.cpp:
+        (JSC::Bindings::QtInstance::getMethod):
+        * bridge/runtime_method.cpp:
+        (JSC::RuntimeMethod::RuntimeMethod):
+        (JSC::RuntimeMethod::lengthGetter):
+        (JSC::callRuntimeMethod):
+        * bridge/runtime_method.h:
+        (JSC::RuntimeMethod::create):
+        (JSC::RuntimeMethod::method):
+        (RuntimeMethod):
+        * bridge/runtime_object.cpp:
+        (JSC::Bindings::RuntimeObject::getOwnPropertySlot):
+        (JSC::Bindings::RuntimeObject::getOwnPropertyDescriptor):
+
 2012-09-28  Elliott Sprehn  <esprehn@chromium.org>
 
         Fix compilation of V8DependentRetained and JSDependentRetained.
index 66c9f47..39088f3 100644 (file)
@@ -27,7 +27,6 @@ webcore_cppflags += \
        -I$(srcdir)/Source/WebCore/bindings/js \
        -I$(srcdir)/Source/WebCore/bridge \
        -I$(srcdir)/Source/WebCore/bridge/c \
-       -I$(srcdir)/Source/WebCore/bridge/jni/jsc \
        -I$(srcdir)/Source/WebCore/bridge/jsc \
        -I$(srcdir)/Source/WebCore/css \
        -I$(srcdir)/Source/WebCore/dom \
index 3166d9a..843261e 100644 (file)
@@ -2456,15 +2456,6 @@ webcore_sources += \
        Source/WebCore/bridge/c/c_utility.h \
        Source/WebCore/bridge/IdentifierRep.cpp \
        Source/WebCore/bridge/IdentifierRep.h \
-       Source/WebCore/bridge/jni/JNIUtility.h \
-       Source/WebCore/bridge/jni/JavaType.h \
-       Source/WebCore/bridge/jni/jni_jsobject.h \
-       Source/WebCore/bridge/jni/jsc/JavaArrayJSC.h \
-       Source/WebCore/bridge/jni/jsc/JavaClassJSC.h \
-       Source/WebCore/bridge/jni/jsc/JavaFieldJSC.h \
-       Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.h \
-       Source/WebCore/bridge/jni/jsc/JavaMethodJSC.cpp \
-       Source/WebCore/bridge/jni/jsc/JavaMethodJSC.h \
        Source/WebCore/bridge/jsc/BridgeJSC.cpp \
        Source/WebCore/bridge/jsc/BridgeJSC.h \
        Source/WebCore/bridge/NP_jsobject.cpp \
index b8651bb..4c09b0e 100644 (file)
@@ -2350,8 +2350,7 @@ __ZN3JSC13RuntimeMethod14finishCreationERNS_12JSGlobalDataERKN3WTF6StringE
 __ZN3JSC13RuntimeMethod18getOwnPropertySlotEPNS_6JSCellEPNS_9ExecStateENS_12PropertyNameERNS_12PropertySlotE
 __ZN3JSC13RuntimeMethod24getOwnPropertyDescriptorEPNS_8JSObjectEPNS_9ExecStateENS_12PropertyNameERNS_18PropertyDescriptorE
 __ZN3JSC13RuntimeMethod6s_infoE
-__ZN3JSC13RuntimeMethod7destroyEPNS_6JSCellE
-__ZN3JSC13RuntimeMethodC2EPNS_14JSGlobalObjectEPNS_9StructureERN3WTF6VectorIPNS_8Bindings6MethodELm0EEE
+__ZN3JSC13RuntimeMethodC2EPNS_14JSGlobalObjectEPNS_9StructureEPNS_8Bindings6MethodE
 __ZN3JSC8Bindings10RootObjectD1Ev
 __ZN3JSC8Bindings13RuntimeObject11getCallDataEPNS_6JSCellERNS_8CallDataE
 __ZN3JSC8Bindings13RuntimeObject12defaultValueEPKNS_8JSObjectEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
index 1a16670..464d882 100644 (file)
@@ -70,28 +70,23 @@ CClass* CClass::classForIsA(NPClass* isa)
     return aClass;
 }
 
-MethodList CClass::methodsNamed(PropertyName propertyName, Instance* instance) const
+Method* CClass::methodNamed(PropertyName propertyName, Instance* instance) const
 {
     String name(propertyName.publicName());
     
-    MethodList methodList;
-
-    Method* method = _methods.get(name.impl());
-    if (method) {
-        methodList.append(method);
-        return methodList;
-    }
+    if (Method* method = _methods.get(name.impl()))
+        return method;
 
     NPIdentifier ident = _NPN_GetStringIdentifier(name.ascii().data());
     const CInstance* inst = static_cast<const CInstance*>(instance);
     NPObject* obj = inst->getObject();
     if (_isa->hasMethod && _isa->hasMethod(obj, ident)){
-        Method* aMethod = new CMethod(ident); // deleted in the CClass destructor
-        _methods.set(name.impl(), aMethod);
-        methodList.append(aMethod);
+        Method* method = new CMethod(ident); // deleted in the CClass destructor
+        _methods.set(name.impl(), method);
+        return method;
     }
     
-    return methodList;
+    return 0;
 }
 
 Field* CClass::fieldNamed(PropertyName propertyName, Instance* instance) const
index c8c2e89..f67399f 100644 (file)
@@ -43,7 +43,7 @@ public:
     static CClass* classForIsA(NPClass*);
     virtual ~CClass();
 
-    virtual MethodList methodsNamed(PropertyName, Instance*) const;
+    virtual Method* methodNamed(PropertyName, Instance*) const;
     virtual Field* fieldNamed(PropertyName, Instance*) const;
 
 private:
index 201c61e..60b4308 100644 (file)
@@ -111,14 +111,14 @@ class CRuntimeMethod : public RuntimeMethod {
 public:
     typedef RuntimeMethod Base;
 
-    static CRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const String& name, Bindings::MethodList& list)
+    static CRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const String& name, Bindings::Method* method)
     {
         // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
         // We need to pass in the right global object for "i".
         Structure* domStructure = WebCore::deprecatedGetDOMStructure<CRuntimeMethod>(exec);
-        CRuntimeMethod* method = new (NotNull, allocateCell<CRuntimeMethod>(*exec->heap())) CRuntimeMethod(globalObject, domStructure, list);
-        method->finishCreation(exec->globalData(), name);
-        return method;
+        CRuntimeMethod* runtimeMethod = new (NotNull, allocateCell<CRuntimeMethod>(*exec->heap())) CRuntimeMethod(globalObject, domStructure, method);
+        runtimeMethod->finishCreation(exec->globalData(), name);
+        return runtimeMethod;
     }
 
     static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
@@ -129,8 +129,8 @@ public:
     static const ClassInfo s_info;
 
 private:
-    CRuntimeMethod(JSGlobalObject* globalObject, Structure* structure, Bindings::MethodList& list)
-        : RuntimeMethod(globalObject, structure, list)
+    CRuntimeMethod(JSGlobalObject* globalObject, Structure* structure, Bindings::Method* method)
+        : RuntimeMethod(globalObject, structure, method)
     {
     }
 
@@ -146,8 +146,8 @@ const ClassInfo CRuntimeMethod::s_info = { "CRuntimeMethod", &RuntimeMethod::s_i
 
 JSValue CInstance::getMethod(ExecState* exec, PropertyName propertyName)
 {
-    MethodList methodList = getClass()->methodsNamed(propertyName, this);
-    return CRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.publicName(), methodList);
+    Method* method = getClass()->methodNamed(propertyName, this);
+    return CRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.publicName(), method);
 }
 
 JSValue CInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
@@ -155,13 +155,8 @@ JSValue CInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
     if (!asObject(runtimeMethod)->inherits(&CRuntimeMethod::s_info))
         return throwError(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
 
-    const MethodList& methodList = *runtimeMethod->methods();
-
-    // Overloading methods are not allowed by NPObjects.  Should only be one
-    // name match for a particular method.
-    ASSERT(methodList.size() == 1);
-
-    CMethod* method = static_cast<CMethod*>(methodList[0]);
+    CMethod* method = static_cast<CMethod*>(runtimeMethod->method());
+    ASSERT(method);
 
     NPIdentifier ident = method->identifier();
     if (!_object->_class->hasMethod(_object, ident))
index c7dfe48..39e6c98 100644 (file)
@@ -48,8 +48,6 @@ class Method;
 class RootObject;
 class RuntimeObject;
 
-typedef Vector<Method*> MethodList;
-
 class Field {
 public:
     virtual JSValue valueFromInstance(ExecState*, const Instance*) const = 0;
@@ -62,7 +60,7 @@ class Class {
     WTF_MAKE_NONCOPYABLE(Class); WTF_MAKE_FAST_ALLOCATED;
 public:
     Class() { }
-    virtual MethodList methodsNamed(PropertyName, Instance*) const = 0;
+    virtual Method* methodNamed(PropertyName, Instance*) const = 0;
     virtual Field* fieldNamed(PropertyName, Instance*) const = 0;
     virtual JSValue fallbackObject(ExecState*, Instance*, PropertyName) { return jsUndefined(); }
 
@@ -136,7 +134,6 @@ protected:
 
 const char* signatureForParameters(const ArgList&);
 
-typedef HashMap<RefPtr<StringImpl>, MethodList*> MethodListMap;
 typedef HashMap<RefPtr<StringImpl>, Method*> MethodMap;
 typedef HashMap<RefPtr<StringImpl>, Field*> FieldMap;
 
index c358ae9..838347f 100644 (file)
@@ -41,7 +41,7 @@ public:
     // Return the cached ObjC of the specified name.
     static ObjcClass *classForIsA(ClassStructPtr);
     
-    virtual MethodList methodsNamed(PropertyName, Instance*) const;
+    virtual Method* methodNamed(PropertyName, Instance*) const;
     virtual Field *fieldNamed(PropertyName, Instance*) const;
 
     virtual JSValue fallbackObject(ExecState*, Instance*, PropertyName);
index bcbd7e7..b92190b 100644 (file)
@@ -95,25 +95,24 @@ static inline void convertJSMethodNameToObjc(const CString& jsName, JSNameConver
     }
 }
 
-MethodList ObjcClass::methodsNamed(PropertyName propertyName, Instance*) const
+Method* ObjcClass::methodNamed(PropertyName propertyName, Instance*) const
 {
     String name(propertyName.publicName());
     if (name.isNull())
-        return MethodList();
+        return 0;
 
-    MethodList methodList;
-    if (Method* method = m_methodCache.get(name.impl())) {
-        methodList.append(method);
-        return methodList;
-    }
+    if (Method* method = m_methodCache.get(name.impl()))
+        return method;
 
     CString jsName = name.ascii();
     JSNameConversionBuffer buffer;
     convertJSMethodNameToObjc(jsName, buffer);
     RetainPtr<CFStringRef> methodName(AdoptCF, CFStringCreateWithCString(NULL, buffer.data(), kCFStringEncodingASCII));
 
+    Method* methodPtr = 0;
     ClassStructPtr thisClass = _isa;
-    while (thisClass && methodList.isEmpty()) {
+    
+    while (thisClass && !methodPtr) {
         unsigned numMethodsInClass = 0;
         MethodStructPtr* objcMethodList = class_copyMethodList(thisClass, &numMethodsInClass);
         for (unsigned i = 0; i < numMethodsInClass; i++) {
@@ -135,7 +134,7 @@ MethodList ObjcClass::methodsNamed(PropertyName propertyName, Instance*) const
 
             if ((mappedName && [mappedName isEqual:(NSString*)methodName.get()]) || strcmp(objcMethodSelectorName, buffer.data()) == 0) {
                 OwnPtr<Method> method = adoptPtr(new ObjcMethod(thisClass, objcMethodSelector));
-                methodList.append(method.get());
+                methodPtr = method.get();
                 m_methodCache.add(name.impl(), method.release());
                 break;
             }
@@ -144,7 +143,7 @@ MethodList ObjcClass::methodsNamed(PropertyName propertyName, Instance*) const
         free(objcMethodList);
     }
 
-    return methodList;
+    return methodPtr;
 }
 
 Field* ObjcClass::fieldNamed(PropertyName propertyName, Instance* instance) const
index 4f5beca..2b36248 100644 (file)
@@ -181,14 +181,14 @@ bool ObjcInstance::supportsInvokeDefaultMethod() const
 
 class ObjCRuntimeMethod : public RuntimeMethod {
 public:
-    static ObjCRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const String& name, Bindings::MethodList& list)
+    static ObjCRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const String& name, Bindings::Method* method)
     {
         // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
         // We need to pass in the right global object for "i".
         Structure* domStructure = WebCore::deprecatedGetDOMStructure<ObjCRuntimeMethod>(exec);
-        ObjCRuntimeMethod* method = new (NotNull, allocateCell<ObjCRuntimeMethod>(*exec->heap())) ObjCRuntimeMethod(globalObject, domStructure, list);
-        method->finishCreation(exec->globalData(), name);
-        return method;
+        ObjCRuntimeMethod* runtimeMethod = new (NotNull, allocateCell<ObjCRuntimeMethod>(*exec->heap())) ObjCRuntimeMethod(globalObject, domStructure, method);
+        runtimeMethod->finishCreation(exec->globalData(), name);
+        return runtimeMethod;
     }
 
     static Structure* createStructure(JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSValue prototype)
@@ -201,8 +201,8 @@ public:
 private:
     typedef RuntimeMethod Base;
 
-    ObjCRuntimeMethod(JSGlobalObject* globalObject, Structure* structure, Bindings::MethodList& list)
-        : RuntimeMethod(globalObject, structure, list)
+    ObjCRuntimeMethod(JSGlobalObject* globalObject, Structure* structure, Bindings::Method* method)
+        : RuntimeMethod(globalObject, structure, method)
     {
     }
 
@@ -217,8 +217,8 @@ const ClassInfo ObjCRuntimeMethod::s_info = { "ObjCRuntimeMethod", &RuntimeMetho
 
 JSValue ObjcInstance::getMethod(ExecState* exec, PropertyName propertyName)
 {
-    MethodList methodList = getClass()->methodsNamed(propertyName, this);
-    return ObjCRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.publicName(), methodList);
+    Method* method = getClass()->methodNamed(propertyName, this);
+    return ObjCRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.publicName(), method);
 }
 
 JSValue ObjcInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
@@ -226,13 +226,10 @@ JSValue ObjcInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod
     if (!asObject(runtimeMethod)->inherits(&ObjCRuntimeMethod::s_info))
         return throwError(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
 
-    const MethodList& methodList = *runtimeMethod->methods();
+    ObjcMethod *method = static_cast<ObjcMethod*>(runtimeMethod->method());
+    ASSERT(method);
 
-    // Overloading methods is not allowed in ObjectiveC.  Should only be one
-    // name match for a particular method.
-    ASSERT(methodList.size() == 1);
-
-    return invokeObjcMethod(exec, static_cast<ObjcMethod*>(methodList[0]));
+    return invokeObjcMethod(exec, method);
 }
 
 JSValue ObjcInstance::invokeObjcMethod(ExecState* exec, ObjcMethod* method)
index 7617871..da25d95 100644 (file)
@@ -122,9 +122,9 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, PropertyName id
 }
 
 // This functionality is handled by the fallback case above...
-MethodList QtClass::methodsNamed(PropertyName, Instance*) const
+Method* QtClass::methodNamed(PropertyName, Instance*) const
 {
-    return MethodList();
+    return 0;
 }
 
 // ### we may end up with a different search order than QtScript by not
index ce9bbc4..1256291 100644 (file)
@@ -41,7 +41,7 @@ public:
     virtual ~QtClass();
 
     virtual const char* name() const;
-    virtual MethodList methodsNamed(PropertyName, Instance*) const;
+    virtual Method* methodNamed(PropertyName, Instance*) const;
     virtual Field* fieldNamed(PropertyName, Instance*) const;
 
     virtual JSValue fallbackObject(ExecState*, Instance*, PropertyName);
index a13e3ff..8f1be6e 100644 (file)
@@ -223,8 +223,8 @@ JSValue QtInstance::getMethod(ExecState* exec, PropertyName propertyName)
 {
     if (!getClass())
         return jsNull();
-    MethodList methodList = m_class->methodsNamed(propertyName, this);
-    return RuntimeMethod::create(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeMethod>(exec), propertyName.publicName(), methodList);
+    Method* method = m_class->methodNamed(propertyName, this);
+    return RuntimeMethod::create(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeMethod>(exec), propertyName.publicName(), method);
 }
 
 JSValue QtInstance::invokeMethod(ExecState*, RuntimeMethod*)
index 9fdb64d..e2c0f34 100644 (file)
@@ -43,18 +43,13 @@ ASSERT_CLASS_FITS_IN_CELL(RuntimeMethod);
 
 const ClassInfo RuntimeMethod::s_info = { "RuntimeMethod", &InternalFunction::s_info, 0, 0, CREATE_METHOD_TABLE(RuntimeMethod) };
 
-RuntimeMethod::RuntimeMethod(JSGlobalObject* globalObject, Structure* structure, Bindings::MethodList& m)
-    // Callers will need to pass in the right global object corresponding to this native object "m".
+RuntimeMethod::RuntimeMethod(JSGlobalObject* globalObject, Structure* structure, Method* method)
+    // Callers will need to pass in the right global object corresponding to this native object "method".
     : InternalFunction(globalObject, structure)
-    , _methodList(adoptPtr(new MethodList(m)))
+    , m_method(method)
 {
 }
 
-void RuntimeMethod::destroy(JSCell* cell)
-{
-    static_cast<RuntimeMethod*>(cell)->RuntimeMethod::~RuntimeMethod();
-}
-
 void RuntimeMethod::finishCreation(JSGlobalData& globalData, const String& ident)
 {
     Base::finishCreation(globalData, ident);
@@ -65,13 +60,7 @@ JSValue RuntimeMethod::lengthGetter(ExecState*, JSValue slotBase, PropertyName)
 {
     RuntimeMethod* thisObj = static_cast<RuntimeMethod*>(asObject(slotBase));
 
-    // Ick!  There may be more than one method with this name.  Arbitrarily
-    // just pick the first method.  The fundamental problem here is that 
-    // JavaScript doesn't have the notion of method overloading and
-    // Java does.
-    // FIXME: a better solution might be to give the maximum number of parameters
-    // of any method
-    return jsNumber(thisObj->_methodList->at(0)->numParameters());
+    return jsNumber(thisObj->m_method->numParameters());
 }
 
 bool RuntimeMethod::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot &slot)
@@ -102,7 +91,7 @@ static EncodedJSValue JSC_HOST_CALL callRuntimeMethod(ExecState* exec)
 {
     RuntimeMethod* method = static_cast<RuntimeMethod*>(exec->callee());
 
-    if (method->methods()->isEmpty())
+    if (!method->method())
         return JSValue::encode(jsUndefined());
 
     RefPtr<Instance> instance;
index 7481605..566b656 100644 (file)
@@ -37,16 +37,14 @@ class RuntimeMethod : public InternalFunction {
 public:
     typedef InternalFunction Base;
 
-    static void destroy(JSCell*);
-
-    static RuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const String& name, Bindings::MethodList& methodList)
+    static RuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const String& name, Bindings::Method* method)
     {
-        RuntimeMethod* method = new (NotNull, allocateCell<RuntimeMethod>(*exec->heap())) RuntimeMethod(globalObject, structure, methodList);
-        method->finishCreation(exec->globalData(), name);
-        return method;
+        RuntimeMethod* runtimeMethod = new (NotNull, allocateCell<RuntimeMethod>(*exec->heap())) RuntimeMethod(globalObject, structure, method);
+        runtimeMethod->finishCreation(exec->globalData(), name);
+        return runtimeMethod;
     }
 
-    Bindings::MethodList* methods() const { return _methodList.get(); }
+    Bindings::Method* method() const { return m_method; }
 
     static const ClassInfo s_info;
 
@@ -61,7 +59,7 @@ public:
     }
 
 protected:
-    RuntimeMethod(JSGlobalObject*, Structure*, Bindings::MethodList&);
+    RuntimeMethod(JSGlobalObject*, Structure*, Bindings::Method*);
     void finishCreation(JSGlobalData&, const String&);
     static const unsigned StructureFlags = OverridesGetOwnPropertySlot | InternalFunction::StructureFlags;
     static CallType getCallData(JSCell*, CallData&);
@@ -72,7 +70,7 @@ protected:
 private:
     static JSValue lengthGetter(ExecState*, JSValue, PropertyName);
 
-    OwnPtr<Bindings::MethodList> _methodList;
+    Bindings::Method* m_method;
 };
 
 } // namespace JSC
index a1a30ce..870af10 100644 (file)
@@ -140,8 +140,7 @@ bool RuntimeObject::getOwnPropertySlot(JSCell* cell, ExecState *exec, PropertyNa
         } else {
             // Now check if a method with specified name exists, if so return a function object for
             // that method.
-            MethodList methodList = aClass->methodsNamed(propertyName, instance.get());
-            if (methodList.size() > 0) {
+            if (aClass->methodNamed(propertyName, instance.get())) {
                 slot.setCustom(thisObject, thisObject->methodGetter);
                 
                 instance->end();
@@ -187,8 +186,7 @@ bool RuntimeObject::getOwnPropertyDescriptor(JSObject* object, ExecState *exec,
         } else {
             // Now check if a method with specified name exists, if so return a function object for
             // that method.
-            MethodList methodList = aClass->methodsNamed(propertyName, instance.get());
-            if (methodList.size() > 0) {
+            if (aClass->methodNamed(propertyName, instance.get())) {
                 PropertySlot slot;
                 slot.setCustom(thisObject, methodGetter);
                 instance->end();
index e2c5ab9..66e29c9 100644 (file)
@@ -1,5 +1,25 @@
 2012-09-28  Anders Carlsson  <andersca@apple.com>
 
+        Remove support for method overloading from bridge code
+        https://bugs.webkit.org/show_bug.cgi?id=97959
+
+        Reviewed by Dan Bernstein.
+
+        Update for WebCore changes; MethodList has been replaced with a single Method* everywhere.
+
+        * Plugins/Hosted/ProxyInstance.h:
+        (ProxyInstance):
+        * Plugins/Hosted/ProxyInstance.mm:
+        (ProxyClass):
+        (WebKit::ProxyClass::methodNamed):
+        (WebKit::ProxyRuntimeMethod::create):
+        (WebKit::ProxyRuntimeMethod::ProxyRuntimeMethod):
+        (WebKit::ProxyInstance::getMethod):
+        (WebKit::ProxyInstance::invokeMethod):
+        (WebKit::ProxyInstance::methodNamed):
+
+2012-09-28  Anders Carlsson  <andersca@apple.com>
+
         Remove Java bridge
         https://bugs.webkit.org/show_bug.cgi?id=97954
 
index 92a1aba..5d0801f 100644 (file)
@@ -46,7 +46,7 @@ public:
     }
     ~ProxyInstance();
 
-    JSC::Bindings::MethodList methodsNamed(JSC::PropertyName);
+    JSC::Bindings::Method* methodNamed(JSC::PropertyName);
     JSC::Bindings::Field* fieldNamed(JSC::PropertyName);
 
     JSC::JSValue fieldValue(JSC::ExecState*, const JSC::Bindings::Field*) const;
index 49e98fe..1323f6e 100644 (file)
@@ -50,13 +50,13 @@ namespace WebKit {
 
 class ProxyClass : public JSC::Bindings::Class {
 private:
-    virtual MethodList methodsNamed(PropertyName, Instance*) const;
+    virtual Method* methodNamed(PropertyName, Instance*) const;
     virtual Field* fieldNamed(PropertyName, Instance*) const;
 };
 
-MethodList ProxyClass::methodsNamed(PropertyName propertyName, Instance* instance) const
+Method* ProxyClass::methodNamed(PropertyName propertyName, Instance* instance) const
 {
-    return static_cast<ProxyInstance*>(instance)->methodsNamed(propertyName);
+    return static_cast<ProxyInstance*>(instance)->methodNamed(propertyName);
 }
 
 Field* ProxyClass::fieldNamed(PropertyName propertyName, Instance* instance) const
@@ -181,14 +181,14 @@ class ProxyRuntimeMethod : public RuntimeMethod {
 public:
     typedef RuntimeMethod Base;
 
-    static ProxyRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const String& name, Bindings::MethodList& list)
+    static ProxyRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const String& name, Bindings::Method* method)
     {
         // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
         // exec-globalData() is also likely wrong.
         Structure* domStructure = deprecatedGetDOMStructure<ProxyRuntimeMethod>(exec);
-        ProxyRuntimeMethod* method = new (allocateCell<ProxyRuntimeMethod>(*exec->heap())) ProxyRuntimeMethod(globalObject, domStructure, list);
-        method->finishCreation(exec->globalData(), name);
-        return method;
+        ProxyRuntimeMethod* runtimeMethod = new (allocateCell<ProxyRuntimeMethod>(*exec->heap())) ProxyRuntimeMethod(globalObject, domStructure, method);
+        runtimeMethod->finishCreation(exec->globalData(), name);
+        return runtimeMethod;
     }
 
     static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
@@ -199,8 +199,8 @@ public:
     static const ClassInfo s_info;
 
 private:
-    ProxyRuntimeMethod(JSGlobalObject* globalObject, Structure* structure, Bindings::MethodList& list)
-        : RuntimeMethod(globalObject, structure, list)
+    ProxyRuntimeMethod(JSGlobalObject* globalObject, Structure* structure, Bindings::Method* method)
+        : RuntimeMethod(globalObject, structure, method)
     {
     }
 
@@ -215,8 +215,8 @@ const ClassInfo ProxyRuntimeMethod::s_info = { "ProxyRuntimeMethod", &RuntimeMet
 
 JSValue ProxyInstance::getMethod(JSC::ExecState* exec, PropertyName propertyName)
 {
-    MethodList methodList = getClass()->methodsNamed(propertyName, this);
-    return ProxyRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.publicName(), methodList);
+    Method* method = getClass()->methodNamed(propertyName, this);
+    return ProxyRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.publicName(), method);
 }
 
 JSValue ProxyInstance::invokeMethod(ExecState* exec, JSC::RuntimeMethod* runtimeMethod)
@@ -224,11 +224,8 @@ JSValue ProxyInstance::invokeMethod(ExecState* exec, JSC::RuntimeMethod* runtime
     if (!asObject(runtimeMethod)->inherits(&ProxyRuntimeMethod::s_info))
         return throwError(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
 
-    const MethodList& methodList = *runtimeMethod->methods();
-
-    ASSERT(methodList.size() == 1);
-
-    ProxyMethod* method = static_cast<ProxyMethod*>(methodList[0]);
+    ProxyMethod* method = static_cast<ProxyMethod*>(runtimeMethod->method());
+    ASSERT(method);
 
     return invoke(exec, Invoke, method->serverIdentifier(), ArgList(exec));
 }
@@ -346,22 +343,20 @@ void ProxyInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArr
     }
 }
 
-MethodList ProxyInstance::methodsNamed(PropertyName propertyName)
+Method* ProxyInstance::methodNamed(PropertyName propertyName)
 {
     String name(propertyName.publicName());
     if (name.isNull())
-        return MethodList();
+        return 0;
 
     if (!m_instanceProxy)
-        return MethodList();
+        return 0;
     
     // If we already have an entry in the map, use it.
     MethodMap::iterator existingMapEntry = m_methods.find(name.impl());
     if (existingMapEntry != m_methods.end()) {
-        MethodList methodList;
         if (existingMapEntry->second)
-            methodList.append(existingMapEntry->second);
-        return methodList;
+            return existingMapEntry->second;
     }
     
     uint64_t methodName = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(name.ascii().data()));
@@ -370,24 +365,21 @@ MethodList ProxyInstance::methodsNamed(PropertyName propertyName)
     if (_WKPHNPObjectHasMethod(m_instanceProxy->hostProxy()->port(),
                                m_instanceProxy->pluginID(), requestID,
                                m_objectID, methodName) != KERN_SUCCESS)
-        return MethodList();
+        return 0;
     
     auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
     if (!reply.get())
-        return MethodList();
+        return 0;
 
     if (!reply->m_result && !m_instanceProxy->hostProxy()->shouldCacheMissingPropertiesAndMethods())
-        return MethodList();
+        return 0;
 
     // Add a new entry to the map unless an entry was added while we were in waitForReply.
     MethodMap::AddResult mapAddResult = m_methods.add(name.impl(), 0);
     if (mapAddResult.isNewEntry && reply->m_result)
         mapAddResult.iterator->second = new ProxyMethod(methodName);
 
-    MethodList methodList;
-    if (mapAddResult.iterator->second)
-        methodList.append(mapAddResult.iterator->second);
-    return methodList;
+    return mapAddResult.iterator->second;
 }
 
 Field* ProxyInstance::fieldNamed(PropertyName propertyName)