diff options
Diffstat (limited to 'Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp')
-rw-r--r-- | Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp b/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp index 7a7adc5..b02d059 100644 --- a/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp +++ b/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp @@ -33,6 +33,8 @@ #include "JavaClassV8.h" #include "JavaFieldV8.h" #include "JavaInstanceV8.h" +#include "JavaMethod.h" +#include "JavaValueV8.h" #include "npruntime_impl.h" namespace JSC { @@ -115,12 +117,40 @@ bool JavaNPObjectInvoke(NPObject* obj, NPIdentifier identifier, const NPVariant* return false; instance->begin(); - bool r = instance->invokeMethod(name, args, argCount, result); - instance->end(); + MethodList methodList = instance->getClass()->methodsNamed(name); // TODO: use NPN_MemFree free(name); - return r; + + // Try to find a good match for the overloaded method. The + // fundamental problem is that JavaScript doesn't have the + // notion of method overloading and Java does. We could + // get a bit more sophisticated and attempt to do some + // type checking as well as checking the number of parameters. + size_t numMethods = methodList.size(); + JavaMethod* aMethod; + JavaMethod* jMethod = 0; + for (size_t methodIndex = 0; methodIndex < numMethods; methodIndex++) { + aMethod = methodList[methodIndex]; + if (aMethod->numParameters() == static_cast<int>(argCount)) { + jMethod = aMethod; + break; + } + } + if (!jMethod) + return false; + + JavaValue* jArgs = new JavaValue[argCount]; + for (unsigned int i = 0; i < argCount; i++) + jArgs[i] = convertNPVariantToJavaValue(args[i], jMethod->parameterAt(i)); + + JavaValue jResult = instance->invokeMethod(jMethod, jArgs); + instance->end(); + delete[] jArgs; + + VOID_TO_NPVARIANT(*result); + convertJavaValueToNPVariant(jResult, result); + return true; } bool JavaNPObjectHasProperty(NPObject* obj, NPIdentifier identifier) @@ -150,12 +180,11 @@ bool JavaNPObjectGetProperty(NPObject* obj, NPIdentifier identifier, NPVariant* instance->begin(); JavaField* field = instance->getClass()->fieldNamed(name); - instance->end(); free(name); // TODO: use NPN_MemFree - if (!field) return false; +<<<<<<< HEAD #if PLATFORM(ANDROID) // JSC does not seem to support returning object properties so we emulate that // behaviour here. @@ -167,6 +196,12 @@ bool JavaNPObjectGetProperty(NPObject* obj, NPIdentifier identifier, NPVariant* field->type()); #endif // PLATFORM(ANDROID) convertJValueToNPVariant(value, field->getJNIType(), field->type(), result); +======= + JavaValue value = instance->getField(field); + instance->end(); + + convertJavaValueToNPVariant(value, result); +>>>>>>> webkit.org at r82507 return true; } |