Title: [129969] trunk/Source
Revision
129969
Author
[email protected]
Date
2012-09-28 19:18:06 -0700 (Fri, 28 Sep 2012)

Log Message

Remove support for method overloading from bridge code
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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (129968 => 129969)


--- trunk/Source/WebCore/ChangeLog	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/ChangeLog	2012-09-29 02:18:06 UTC (rev 129969)
@@ -1,3 +1,54 @@
+2012-09-28  Anders Carlsson  <[email protected]>
+
+        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  <[email protected]>
 
         Fix compilation of V8DependentRetained and JSDependentRetained.

Modified: trunk/Source/WebCore/GNUmakefile.am (129968 => 129969)


--- trunk/Source/WebCore/GNUmakefile.am	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/GNUmakefile.am	2012-09-29 02:18:06 UTC (rev 129969)
@@ -27,7 +27,6 @@
 	-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 \

Modified: trunk/Source/WebCore/GNUmakefile.list.am (129968 => 129969)


--- trunk/Source/WebCore/GNUmakefile.list.am	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2012-09-29 02:18:06 UTC (rev 129969)
@@ -2456,15 +2456,6 @@
 	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 \

Modified: trunk/Source/WebCore/WebCore.exp.in (129968 => 129969)


--- trunk/Source/WebCore/WebCore.exp.in	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-09-29 02:18:06 UTC (rev 129969)
@@ -2350,8 +2350,7 @@
 __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

Modified: trunk/Source/WebCore/bridge/c/c_class.cpp (129968 => 129969)


--- trunk/Source/WebCore/bridge/c/c_class.cpp	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/c/c_class.cpp	2012-09-29 02:18:06 UTC (rev 129969)
@@ -70,28 +70,23 @@
     return aClass;
 }
 
-MethodList CClass::methodsNamed(PropertyName propertyName, Instance* instance) const
+Method* CClass::methodNamed(PropertyName propertyName, Instance* instance) const
 {
     String name(propertyName.publicName());
     
-    MethodList methodList;
+    if (Method* method = _methods.get(name.impl()))
+        return method;
 
-    Method* method = _methods.get(name.impl());
-    if (method) {
-        methodList.append(method);
-        return methodList;
-    }
-
     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

Modified: trunk/Source/WebCore/bridge/c/c_class.h (129968 => 129969)


--- trunk/Source/WebCore/bridge/c/c_class.h	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/c/c_class.h	2012-09-29 02:18:06 UTC (rev 129969)
@@ -43,7 +43,7 @@
     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:

Modified: trunk/Source/WebCore/bridge/c/c_instance.cpp (129968 => 129969)


--- trunk/Source/WebCore/bridge/c/c_instance.cpp	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/c/c_instance.cpp	2012-09-29 02:18:06 UTC (rev 129969)
@@ -111,14 +111,14 @@
 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 @@
     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 @@
 
 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,14 +155,9 @@
     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();
+    CMethod* method = static_cast<CMethod*>(runtimeMethod->method());
+    ASSERT(method);
 
-    // 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]);
-
     NPIdentifier ident = method->identifier();
     if (!_object->_class->hasMethod(_object, ident))
         return jsUndefined();

Modified: trunk/Source/WebCore/bridge/jsc/BridgeJSC.h (129968 => 129969)


--- trunk/Source/WebCore/bridge/jsc/BridgeJSC.h	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/jsc/BridgeJSC.h	2012-09-29 02:18:06 UTC (rev 129969)
@@ -48,8 +48,6 @@
 class RootObject;
 class RuntimeObject;
 
-typedef Vector<Method*> MethodList;
-
 class Field {
 public:
     virtual JSValue valueFromInstance(ExecState*, const Instance*) const = 0;
@@ -62,7 +60,7 @@
     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 @@
 
 const char* signatureForParameters(const ArgList&);
 
-typedef HashMap<RefPtr<StringImpl>, MethodList*> MethodListMap;
 typedef HashMap<RefPtr<StringImpl>, Method*> MethodMap;
 typedef HashMap<RefPtr<StringImpl>, Field*> FieldMap;
 

Modified: trunk/Source/WebCore/bridge/objc/objc_class.h (129968 => 129969)


--- trunk/Source/WebCore/bridge/objc/objc_class.h	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/objc/objc_class.h	2012-09-29 02:18:06 UTC (rev 129969)
@@ -41,7 +41,7 @@
     // 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);

Modified: trunk/Source/WebCore/bridge/objc/objc_class.mm (129968 => 129969)


--- trunk/Source/WebCore/bridge/objc/objc_class.mm	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/objc/objc_class.mm	2012-09-29 02:18:06 UTC (rev 129969)
@@ -95,25 +95,24 @@
     }
 }
 
-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 @@
 
             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 @@
         free(objcMethodList);
     }
 
-    return methodList;
+    return methodPtr;
 }
 
 Field* ObjcClass::fieldNamed(PropertyName propertyName, Instance* instance) const

Modified: trunk/Source/WebCore/bridge/objc/objc_instance.mm (129968 => 129969)


--- trunk/Source/WebCore/bridge/objc/objc_instance.mm	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/objc/objc_instance.mm	2012-09-29 02:18:06 UTC (rev 129969)
@@ -181,14 +181,14 @@
 
 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 @@
 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 @@
 
 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 @@
     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)

Modified: trunk/Source/WebCore/bridge/qt/qt_class.cpp (129968 => 129969)


--- trunk/Source/WebCore/bridge/qt/qt_class.cpp	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/qt/qt_class.cpp	2012-09-29 02:18:06 UTC (rev 129969)
@@ -122,9 +122,9 @@
 }
 
 // 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

Modified: trunk/Source/WebCore/bridge/qt/qt_class.h (129968 => 129969)


--- trunk/Source/WebCore/bridge/qt/qt_class.h	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/qt/qt_class.h	2012-09-29 02:18:06 UTC (rev 129969)
@@ -41,7 +41,7 @@
     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);

Modified: trunk/Source/WebCore/bridge/qt/qt_instance.cpp (129968 => 129969)


--- trunk/Source/WebCore/bridge/qt/qt_instance.cpp	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/qt/qt_instance.cpp	2012-09-29 02:18:06 UTC (rev 129969)
@@ -223,8 +223,8 @@
 {
     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*)

Modified: trunk/Source/WebCore/bridge/runtime_method.cpp (129968 => 129969)


--- trunk/Source/WebCore/bridge/runtime_method.cpp	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/runtime_method.cpp	2012-09-29 02:18:06 UTC (rev 129969)
@@ -43,18 +43,13 @@
 
 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 @@
 {
     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 @@
 {
     RuntimeMethod* method = static_cast<RuntimeMethod*>(exec->callee());
 
-    if (method->methods()->isEmpty())
+    if (!method->method())
         return JSValue::encode(jsUndefined());
 
     RefPtr<Instance> instance;

Modified: trunk/Source/WebCore/bridge/runtime_method.h (129968 => 129969)


--- trunk/Source/WebCore/bridge/runtime_method.h	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/runtime_method.h	2012-09-29 02:18:06 UTC (rev 129969)
@@ -37,16 +37,14 @@
 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 @@
     }
 
 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 @@
 private:
     static JSValue lengthGetter(ExecState*, JSValue, PropertyName);
 
-    OwnPtr<Bindings::MethodList> _methodList;
+    Bindings::Method* m_method;
 };
 
 } // namespace JSC

Modified: trunk/Source/WebCore/bridge/runtime_object.cpp (129968 => 129969)


--- trunk/Source/WebCore/bridge/runtime_object.cpp	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebCore/bridge/runtime_object.cpp	2012-09-29 02:18:06 UTC (rev 129969)
@@ -140,8 +140,7 @@
         } 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 @@
         } 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();

Modified: trunk/Source/WebKit/mac/ChangeLog (129968 => 129969)


--- trunk/Source/WebKit/mac/ChangeLog	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-09-29 02:18:06 UTC (rev 129969)
@@ -1,5 +1,25 @@
 2012-09-28  Anders Carlsson  <[email protected]>
 
+        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  <[email protected]>
+
         Remove Java bridge
         https://bugs.webkit.org/show_bug.cgi?id=97954
 

Modified: trunk/Source/WebKit/mac/Plugins/Hosted/ProxyInstance.h (129968 => 129969)


--- trunk/Source/WebKit/mac/Plugins/Hosted/ProxyInstance.h	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebKit/mac/Plugins/Hosted/ProxyInstance.h	2012-09-29 02:18:06 UTC (rev 129969)
@@ -46,7 +46,7 @@
     }
     ~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;

Modified: trunk/Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm (129968 => 129969)


--- trunk/Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm	2012-09-29 02:16:19 UTC (rev 129968)
+++ trunk/Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm	2012-09-29 02:18:06 UTC (rev 129969)
@@ -50,13 +50,13 @@
 
 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 @@
 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 @@
     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 @@
 
 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,12 +224,9 @@
     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();
+    ProxyMethod* method = static_cast<ProxyMethod*>(runtimeMethod->method());
+    ASSERT(method);
 
-    ASSERT(methodList.size() == 1);
-
-    ProxyMethod* method = static_cast<ProxyMethod*>(methodList[0]);
-
     return invoke(exec, Invoke, method->serverIdentifier(), ArgList(exec));
 }
 
@@ -346,22 +343,20 @@
     }
 }
 
-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 @@
     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)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to