[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

steveblock at google.com steveblock at google.com
Thu Apr 8 00:22:58 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit df0bd1ce4073af4e52e6e55c5fa1bd41f6894e71
Author: steveblock at google.com <steveblock at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Dec 7 12:36:56 2009 +0000

    Moves JSC-specific functions from jni_utility and moves them to new jsc/jni_utility_private files.
    https://bugs.webkit.org/show_bug.cgi?id=32157
    
    Reviewed by Adam Barth.
    
    Build fix only, no new tests.
    
    * WebCore.xcodeproj/project.pbxproj: Modified. Add jni_utility_private.[cpp|h].
    * bridge/jni/jni_instance.cpp: Modified. Include jni_utility_private.h for JSC.
    * bridge/jni/jni_jsobject.mm: Modified. Include jni_utility_private.h for JSC.
    * bridge/jni/jni_objc.mm: Modified. Include jni_utility_private.h for JSC.
    * bridge/jni/jni_runtime.cpp: Modified. Include jni_utility_private.h for JSC.
    * bridge/jni/jni_utility.cpp: Modified. Removed convertValueToJValue and convertArrayInstanceToJavaArray.
    * bridge/jni/jni_utility.h: Modified. Removed convertValueToJValue and dispatchJNICall.
    * bridge/jni/jsc: Added.
    * bridge/jni/jsc/jni_utility_private.cpp: Added.
    (JSC::Bindings::convertArrayInstanceToJavaArray):
    (JSC::Bindings::convertValueToJValue):
    * bridge/jni/jsc/jni_utility_private.h: Added. Header for convertValueToJValue and dispatchJNICall.
    * platform/android/TemporaryLinkStubs.cpp: Modified. Include jni_utility_private.h for JSC.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51756 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 82f5285..9b34358 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2009-12-07  Steve Block  <steveblock at google.com>
+
+        Reviewed by Adam Barth.
+
+        Moves JSC-specific functions from jni_utility and moves them to new jsc/jni_utility_private files.
+        https://bugs.webkit.org/show_bug.cgi?id=32157
+
+        Build fix only, no new tests.
+
+        * WebCore.xcodeproj/project.pbxproj: Modified. Add jni_utility_private.[cpp|h].
+        * bridge/jni/jni_instance.cpp: Modified. Include jni_utility_private.h for JSC.
+        * bridge/jni/jni_jsobject.mm: Modified. Include jni_utility_private.h for JSC.
+        * bridge/jni/jni_objc.mm: Modified. Include jni_utility_private.h for JSC.
+        * bridge/jni/jni_runtime.cpp: Modified. Include jni_utility_private.h for JSC.
+        * bridge/jni/jni_utility.cpp: Modified. Removed convertValueToJValue and convertArrayInstanceToJavaArray.
+        * bridge/jni/jni_utility.h: Modified. Removed convertValueToJValue and dispatchJNICall.
+        * bridge/jni/jsc: Added.
+        * bridge/jni/jsc/jni_utility_private.cpp: Added.
+        (JSC::Bindings::convertArrayInstanceToJavaArray):
+        (JSC::Bindings::convertValueToJValue):
+        * bridge/jni/jsc/jni_utility_private.h: Added. Header for convertValueToJValue and dispatchJNICall.
+        * platform/android/TemporaryLinkStubs.cpp: Modified. Include jni_utility_private.h for JSC.
+
 2009-12-06  Oliver Hunt  <oliver at apple.com>
 
         Reviewed by Maciej Stachowiak.
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 4b7d4d0..92e6810 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1102,6 +1102,8 @@
 		54C50F7B0E801DF3009832A0 /* XMLTokenizerLibxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 54C50F7A0E801DF3009832A0 /* XMLTokenizerLibxml2.cpp */; };
 		550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
 		550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		599D1E3210C97D6E00E0EF12 /* jni_utility_private.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 599D1E3010C97D6E00E0EF12 /* jni_utility_private.cpp */; };
+		599D1E3310C97D6E00E0EF12 /* jni_utility_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 599D1E3110C97D6E00E0EF12 /* jni_utility_private.h */; };
 		59C77F2A10545B3B00506104 /* GeolocationServiceMock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59C77F2810545B3B00506104 /* GeolocationServiceMock.cpp */; };
 		59C77F2B10545B3B00506104 /* GeolocationServiceMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 59C77F2910545B3B00506104 /* GeolocationServiceMock.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		5D15E3AB0F9E6AC1009E0E3F /* XMLTokenizerScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D15E3A90F9E6AC1009E0E3F /* XMLTokenizerScope.cpp */; };
@@ -6426,6 +6428,8 @@
 		54C50F7A0E801DF3009832A0 /* XMLTokenizerLibxml2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLTokenizerLibxml2.cpp; sourceTree = "<group>"; };
 		550A0BC7085F6039007353D6 /* QualifiedName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedName.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		550A0BC8085F6039007353D6 /* QualifiedName.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedName.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+		599D1E3010C97D6E00E0EF12 /* jni_utility_private.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jni_utility_private.cpp; path = jsc/jni_utility_private.cpp; sourceTree = "<group>"; };
+		599D1E3110C97D6E00E0EF12 /* jni_utility_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jni_utility_private.h; path = jsc/jni_utility_private.h; sourceTree = "<group>"; };
 		59C77F2810545B3B00506104 /* GeolocationServiceMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GeolocationServiceMock.cpp; path = mock/GeolocationServiceMock.cpp; sourceTree = "<group>"; };
 		59C77F2910545B3B00506104 /* GeolocationServiceMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GeolocationServiceMock.h; path = mock/GeolocationServiceMock.h; sourceTree = "<group>"; };
 		5D15E3A90F9E6AC1009E0E3F /* XMLTokenizerScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLTokenizerScope.cpp; sourceTree = "<group>"; };
@@ -10294,6 +10298,7 @@
 		1A569CCE0D7E2B82007C3983 /* jni */ = {
 			isa = PBXGroup;
 			children = (
+				599D1E2F10C97D4C00E0EF12 /* jsc */,
 				1A569CCF0D7E2B82007C3983 /* jni_class.cpp */,
 				1A569CD00D7E2B82007C3983 /* jni_class.h */,
 				1A569CD10D7E2B82007C3983 /* jni_instance.cpp */,
@@ -10993,6 +10998,15 @@
 			path = websockets;
 			sourceTree = "<group>";
 		};
+		599D1E2F10C97D4C00E0EF12 /* jsc */ = {
+			isa = PBXGroup;
+			children = (
+				599D1E3010C97D6E00E0EF12 /* jni_utility_private.cpp */,
+				599D1E3110C97D6E00E0EF12 /* jni_utility_private.h */,
+			);
+			name = jsc;
+			sourceTree = "<group>";
+		};
 		59C77F101054591C00506104 /* mock */ = {
 			isa = PBXGroup;
 			children = (
@@ -18243,6 +18257,7 @@
 				7A0E770F10C00A8800A0276E /* InspectorFrontendHost.h in Headers */,
 				7A0E771F10C00DB100A0276E /* JSInspectorFrontendHost.h in Headers */,
 				F4EAF4AF10C742B1009100D3 /* OpenTypeSanitizer.h in Headers */,
+				599D1E3310C97D6E00E0EF12 /* jni_utility_private.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -20399,6 +20414,7 @@
 				7A0E770E10C00A8800A0276E /* InspectorFrontendHost.cpp in Sources */,
 				7A0E771E10C00DB100A0276E /* JSInspectorFrontendHost.cpp in Sources */,
 				F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */,
+				599D1E3210C97D6E00E0EF12 /* jni_utility_private.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/bridge/jni/jni_instance.cpp b/WebCore/bridge/jni/jni_instance.cpp
index d0bcfcb..3783d10 100644
--- a/WebCore/bridge/jni/jni_instance.cpp
+++ b/WebCore/bridge/jni/jni_instance.cpp
@@ -31,6 +31,7 @@
 #include "jni_class.h"
 #include "jni_runtime.h"
 #include "jni_utility.h"
+#include "jni_utility_private.h"
 #include "runtime_object.h"
 #include "runtime_root.h"
 #include <runtime/ArgList.h>
diff --git a/WebCore/bridge/jni/jni_jsobject.mm b/WebCore/bridge/jni/jni_jsobject.mm
index b626693..6683af6 100644
--- a/WebCore/bridge/jni/jni_jsobject.mm
+++ b/WebCore/bridge/jni/jni_jsobject.mm
@@ -35,6 +35,7 @@
 #include "WebCoreFrameView.h"
 #include "jni_runtime.h"
 #include "jni_utility.h"
+#include "jni_utility_private.h"
 #include "runtime_object.h"
 #include "runtime_root.h"
 #include <interpreter/CallFrame.h>
diff --git a/WebCore/bridge/jni/jni_objc.mm b/WebCore/bridge/jni/jni_objc.mm
index 0306bfd..fb2d694 100644
--- a/WebCore/bridge/jni/jni_objc.mm
+++ b/WebCore/bridge/jni/jni_objc.mm
@@ -29,6 +29,7 @@
 
 #import <Foundation/Foundation.h>
 #import "jni_utility.h"
+#import "jni_utility_private.h"
 #import "objc_utility.h"
 #include <runtime/JSLock.h>
 
diff --git a/WebCore/bridge/jni/jni_runtime.cpp b/WebCore/bridge/jni/jni_runtime.cpp
index d7d0696..be11981 100644
--- a/WebCore/bridge/jni/jni_runtime.cpp
+++ b/WebCore/bridge/jni/jni_runtime.cpp
@@ -28,8 +28,8 @@
 
 #if ENABLE(MAC_JAVA_BRIDGE)
 
-#include <jni_utility.h>
-
+#include "jni_utility.h"
+#include "jni_utility_private.h"
 #include "runtime_array.h"
 #include "runtime_object.h"
 #include "runtime_root.h"
diff --git a/WebCore/bridge/jni/jni_utility.cpp b/WebCore/bridge/jni/jni_utility.cpp
index 86075c9..faa7a8b 100644
--- a/WebCore/bridge/jni/jni_utility.cpp
+++ b/WebCore/bridge/jni/jni_utility.cpp
@@ -28,11 +28,6 @@
 
 #if ENABLE(MAC_JAVA_BRIDGE)
 
-#include "jni_runtime.h"
-#include "runtime_array.h"
-#include "runtime_object.h"
-#include <runtime/JSArray.h>
-#include <runtime/JSLock.h>
 #include <dlfcn.h>
 
 namespace JSC {
@@ -347,236 +342,6 @@ jvalue getJNIField( jobject obj, JNIType type, const char *name, const char *sig
     return result;
 }
 
-static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray, const char* javaClassName)
-{
-    JNIEnv *env = getJNIEnv();
-    // As JS Arrays can contain a mixture of objects, assume we can convert to
-    // the requested Java Array type requested, unless the array type is some object array
-    // other than a string.
-    unsigned length = jsArray->length();
-    jobjectArray jarray = 0;
-    
-    // Build the correct array type
-    switch (JNITypeFromPrimitiveType(javaClassName[1])) { 
-        case object_type: {
-        // Only support string object types
-        if (0 == strcmp("[Ljava.lang.String;", javaClassName)) {
-            jarray = (jobjectArray)env->NewObjectArray(length,
-                env->FindClass("java/lang/String"),
-                env->NewStringUTF(""));
-            for(unsigned i = 0; i < length; i++) {
-                JSValue item = jsArray->get(exec, i);
-                UString stringValue = item.toString(exec);
-                env->SetObjectArrayElement(jarray,i,
-                    env->functions->NewString(env, (const jchar *)stringValue.data(), stringValue.size()));
-                }
-            }
-            break;
-        }
-        
-        case boolean_type: {
-            jarray = (jobjectArray)env->NewBooleanArray(length);
-            for(unsigned i = 0; i < length; i++) {
-                JSValue item = jsArray->get(exec, i);
-                jboolean value = (jboolean)item.toNumber(exec);
-                env->SetBooleanArrayRegion((jbooleanArray)jarray, (jsize)i, (jsize)1, &value);
-            }
-            break;
-        }
-        
-        case byte_type: {
-            jarray = (jobjectArray)env->NewByteArray(length);
-            for(unsigned i = 0; i < length; i++) {
-                JSValue item = jsArray->get(exec, i);
-                jbyte value = (jbyte)item.toNumber(exec);
-                env->SetByteArrayRegion((jbyteArray)jarray, (jsize)i, (jsize)1, &value);
-            }
-            break;
-        }
-
-        case char_type: {
-            jarray = (jobjectArray)env->NewCharArray(length);
-            for(unsigned i = 0; i < length; i++) {
-                JSValue item = jsArray->get(exec, i);
-                UString stringValue = item.toString(exec);
-                jchar value = 0;
-                if (stringValue.size() > 0)
-                    value = ((const jchar*)stringValue.data())[0];
-                env->SetCharArrayRegion((jcharArray)jarray, (jsize)i, (jsize)1, &value);
-            }
-            break;
-        }
-
-        case short_type: {
-            jarray = (jobjectArray)env->NewShortArray(length);
-            for(unsigned i = 0; i < length; i++) {
-                JSValue item = jsArray->get(exec, i);
-                jshort value = (jshort)item.toNumber(exec);
-                env->SetShortArrayRegion((jshortArray)jarray, (jsize)i, (jsize)1, &value);
-            }
-            break;
-        }
-
-        case int_type: {
-            jarray = (jobjectArray)env->NewIntArray(length);
-            for(unsigned i = 0; i < length; i++) {
-                JSValue item = jsArray->get(exec, i);
-                jint value = (jint)item.toNumber(exec);
-                env->SetIntArrayRegion((jintArray)jarray, (jsize)i, (jsize)1, &value);
-            }
-            break;
-        }
-
-        case long_type: {
-            jarray = (jobjectArray)env->NewLongArray(length);
-            for(unsigned i = 0; i < length; i++) {
-                JSValue item = jsArray->get(exec, i);
-                jlong value = (jlong)item.toNumber(exec);
-                env->SetLongArrayRegion((jlongArray)jarray, (jsize)i, (jsize)1, &value);
-            }
-            break;
-        }
-
-        case float_type: {
-            jarray = (jobjectArray)env->NewFloatArray(length);
-            for(unsigned i = 0; i < length; i++) {
-                JSValue item = jsArray->get(exec, i);
-                jfloat value = (jfloat)item.toNumber(exec);
-                env->SetFloatArrayRegion((jfloatArray)jarray, (jsize)i, (jsize)1, &value);
-            }
-            break;
-        }
-    
-        case double_type: {
-            jarray = (jobjectArray)env->NewDoubleArray(length);
-            for(unsigned i = 0; i < length; i++) {
-                JSValue item = jsArray->get(exec, i);
-                jdouble value = (jdouble)item.toNumber(exec);
-                env->SetDoubleArrayRegion((jdoubleArray)jarray, (jsize)i, (jsize)1, &value);
-            }
-            break;
-        }
-        
-        case array_type: // don't handle embedded arrays
-        case void_type: // Don't expect arrays of void objects
-        case invalid_type: // Array of unknown objects
-            break;
-    }
-    
-    // if it was not one of the cases handled, then null is returned
-    return jarray;
-}
-
-
-jvalue convertValueToJValue(ExecState* exec, JSValue value, JNIType _JNIType, const char* javaClassName)
-{
-    JSLock lock(SilenceAssertionsOnly);
-    
-    jvalue result;
-   
-    switch (_JNIType){
-        case array_type:
-        case object_type: {
-            result.l = (jobject)0;
-            
-            // First see if we have a Java instance.
-            if (value.isObject()){
-                JSObject* objectImp = asObject(value);
-                if (objectImp->classInfo() == &RuntimeObjectImp::s_info) {
-                    RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(objectImp);
-                    JavaInstance *instance = static_cast<JavaInstance*>(imp->getInternalInstance());
-                    if (instance)
-                        result.l = instance->javaInstance();
-                }
-                else if (objectImp->classInfo() == &RuntimeArray::s_info) {
-                // Input is a JavaScript Array that was originally created from a Java Array
-                    RuntimeArray* imp = static_cast<RuntimeArray*>(objectImp);
-                    JavaArray *array = static_cast<JavaArray*>(imp->getConcreteArray());
-                    result.l = array->javaArray();
-                } 
-                else if (objectImp->classInfo() == &JSArray::info) {
-                    // Input is a Javascript Array. We need to create it to a Java Array.
-                    result.l = convertArrayInstanceToJavaArray(exec, asArray(value), javaClassName);
-                }
-            }
-            
-            // Now convert value to a string if the target type is a java.lang.string, and we're not
-            // converting from a Null.
-            if (result.l == 0 && strcmp(javaClassName, "java.lang.String") == 0) {
-#ifdef CONVERT_NULL_TO_EMPTY_STRING
-                if (value->isNull()) {
-                    JNIEnv *env = getJNIEnv();
-                    jchar buf[2];
-                    jobject javaString = env->functions->NewString (env, buf, 0);
-                    result.l = javaString;
-                }
-                else 
-#else
-                if (!value.isNull())
-#endif
-                {
-                    UString stringValue = value.toString(exec);
-                    JNIEnv *env = getJNIEnv();
-                    jobject javaString = env->functions->NewString (env, (const jchar *)stringValue.data(), stringValue.size());
-                    result.l = javaString;
-                }
-            } else if (result.l == 0) 
-                bzero (&result, sizeof(jvalue)); // Handle it the same as a void case
-        }
-        break;
-        
-        case boolean_type: {
-            result.z = (jboolean)value.toNumber(exec);
-        }
-        break;
-            
-        case byte_type: {
-            result.b = (jbyte)value.toNumber(exec);
-        }
-        break;
-        
-        case char_type: {
-            result.c = (jchar)value.toNumber(exec);
-        }
-        break;
-
-        case short_type: {
-            result.s = (jshort)value.toNumber(exec);
-        }
-        break;
-
-        case int_type: {
-            result.i = (jint)value.toNumber(exec);
-        }
-        break;
-
-        case long_type: {
-            result.j = (jlong)value.toNumber(exec);
-        }
-        break;
-
-        case float_type: {
-            result.f = (jfloat)value.toNumber(exec);
-        }
-        break;
-
-        case double_type: {
-            result.d = (jdouble)value.toNumber(exec);
-        }
-        break;
-            
-        break;
-
-        case invalid_type:
-        default:
-        case void_type: {
-            bzero (&result, sizeof(jvalue));
-        }
-        break;
-    }
-    return result;
-}
-
 }  // end of namespace Bindings
 
 } // end of namespace JSC
diff --git a/WebCore/bridge/jni/jni_utility.h b/WebCore/bridge/jni/jni_utility.h
index 940cdc9..66b3b2f 100644
--- a/WebCore/bridge/jni/jni_utility.h
+++ b/WebCore/bridge/jni/jni_utility.h
@@ -28,7 +28,6 @@
 
 #if ENABLE(MAC_JAVA_BRIDGE)
 
-#include <runtime/JSValue.h>
 #include <JavaVM/jni.h>
 
 // The order of these items can not be modified as they are tightly
@@ -53,9 +52,6 @@ typedef enum {
 
 namespace JSC {
 
-class ExecState;
-class JSObject;    
-
 namespace Bindings {
 
 class JavaParameter;
@@ -72,8 +68,6 @@ JNIType JNITypeFromClassName(const char *name);
 JNIType JNITypeFromPrimitiveType(char type);
 const char *signatureFromPrimitiveType(JNIType type);
 
-jvalue convertValueToJValue(ExecState*, JSValue, JNIType, const char* javaClassName);
-
 jvalue getJNIField(jobject obj, JNIType type, const char *name, const char *signature);
 
 jmethodID getMethodID(jobject obj, const char *name, const char *sig);
@@ -279,8 +273,6 @@ T callJNIStaticMethod(jclass cls, const char* methodName, const char* methodSign
     return result;
 }
     
-bool dispatchJNICall(ExecState*, const void* targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue* args, jvalue& result, const char* callingURL, JSValue& exceptionDescription);
-
 } // namespace Bindings
 
 } // namespace JSC
diff --git a/WebCore/bridge/jni/jsc/jni_utility_private.cpp b/WebCore/bridge/jni/jsc/jni_utility_private.cpp
new file mode 100644
index 0000000..7f8afd5
--- /dev/null
+++ b/WebCore/bridge/jni/jsc/jni_utility_private.cpp
@@ -0,0 +1,291 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "jni_utility_private.h"
+
+#if ENABLE(MAC_JAVA_BRIDGE)
+
+#include "jni_runtime.h"
+#include "runtime_array.h"
+#include "runtime_object.h"
+#include <runtime/JSArray.h>
+#include <runtime/JSLock.h>
+
+namespace JSC {
+
+namespace Bindings {
+
+static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray, const char* javaClassName)
+{
+    JNIEnv* env = getJNIEnv();
+    // As JS Arrays can contain a mixture of objects, assume we can convert to
+    // the requested Java Array type requested, unless the array type is some object array
+    // other than a string.
+    unsigned length = jsArray->length();
+    jobjectArray jarray = 0;
+
+    // Build the correct array type
+    switch (JNITypeFromPrimitiveType(javaClassName[1])) {
+    case object_type:
+            {
+            // Only support string object types
+            if (!strcmp("[Ljava.lang.String;", javaClassName)) {
+                jarray = (jobjectArray)env->NewObjectArray(length,
+                    env->FindClass("java/lang/String"),
+                    env->NewStringUTF(""));
+                for (unsigned i = 0; i < length; i++) {
+                    JSValue item = jsArray->get(exec, i);
+                    UString stringValue = item.toString(exec);
+                    env->SetObjectArrayElement(jarray, i,
+                        env->functions->NewString(env, (const jchar *)stringValue.data(), stringValue.size()));
+                }
+            }
+            break;
+        }
+
+    case boolean_type:
+        {
+            jarray = (jobjectArray)env->NewBooleanArray(length);
+            for (unsigned i = 0; i < length; i++) {
+                JSValue item = jsArray->get(exec, i);
+                jboolean value = (jboolean)item.toNumber(exec);
+                env->SetBooleanArrayRegion((jbooleanArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+    case byte_type:
+        {
+            jarray = (jobjectArray)env->NewByteArray(length);
+            for (unsigned i = 0; i < length; i++) {
+                JSValue item = jsArray->get(exec, i);
+                jbyte value = (jbyte)item.toNumber(exec);
+                env->SetByteArrayRegion((jbyteArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+    case char_type:
+        {
+            jarray = (jobjectArray)env->NewCharArray(length);
+            for (unsigned i = 0; i < length; i++) {
+                JSValue item = jsArray->get(exec, i);
+                UString stringValue = item.toString(exec);
+                jchar value = 0;
+                if (stringValue.size() > 0)
+                    value = ((const jchar*)stringValue.data())[0];
+                env->SetCharArrayRegion((jcharArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+    case short_type:
+        {
+            jarray = (jobjectArray)env->NewShortArray(length);
+            for (unsigned i = 0; i < length; i++) {
+                JSValue item = jsArray->get(exec, i);
+                jshort value = (jshort)item.toNumber(exec);
+                env->SetShortArrayRegion((jshortArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+    case int_type:
+        {
+            jarray = (jobjectArray)env->NewIntArray(length);
+            for (unsigned i = 0; i < length; i++) {
+                JSValue item = jsArray->get(exec, i);
+                jint value = (jint)item.toNumber(exec);
+                env->SetIntArrayRegion((jintArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+    case long_type:
+        {
+            jarray = (jobjectArray)env->NewLongArray(length);
+            for (unsigned i = 0; i < length; i++) {
+                JSValue item = jsArray->get(exec, i);
+                jlong value = (jlong)item.toNumber(exec);
+                env->SetLongArrayRegion((jlongArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+    case float_type:
+        {
+            jarray = (jobjectArray)env->NewFloatArray(length);
+            for (unsigned i = 0; i < length; i++) {
+                JSValue item = jsArray->get(exec, i);
+                jfloat value = (jfloat)item.toNumber(exec);
+                env->SetFloatArrayRegion((jfloatArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+    case double_type:
+        {
+            jarray = (jobjectArray)env->NewDoubleArray(length);
+            for (unsigned i = 0; i < length; i++) {
+                JSValue item = jsArray->get(exec, i);
+                jdouble value = (jdouble)item.toNumber(exec);
+                env->SetDoubleArrayRegion((jdoubleArray)jarray, (jsize)i, (jsize)1, &value);
+            }
+            break;
+        }
+
+    case array_type: // don't handle embedded arrays
+    case void_type: // Don't expect arrays of void objects
+    case invalid_type: // Array of unknown objects
+        break;
+    }
+
+    // if it was not one of the cases handled, then null is returned
+    return jarray;
+}
+
+jvalue convertValueToJValue(ExecState* exec, JSValue value, JNIType jniType, const char* javaClassName)
+{
+    JSLock lock(SilenceAssertionsOnly);
+
+    jvalue result;
+
+    switch (jniType) {
+    case array_type:
+    case object_type:
+        {
+            result.l = (jobject)0;
+
+            // First see if we have a Java instance.
+            if (value.isObject()) {
+                JSObject* objectImp = asObject(value);
+                if (objectImp->classInfo() == &RuntimeObjectImp::s_info) {
+                    RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(objectImp);
+                    JavaInstance* instance = static_cast<JavaInstance*>(imp->getInternalInstance());
+                    if (instance)
+                        result.l = instance->javaInstance();
+                } else if (objectImp->classInfo() == &RuntimeArray::s_info) {
+                // Input is a JavaScript Array that was originally created from a Java Array
+                    RuntimeArray* imp = static_cast<RuntimeArray*>(objectImp);
+                    JavaArray* array = static_cast<JavaArray*>(imp->getConcreteArray());
+                    result.l = array->javaArray();
+                } else if (objectImp->classInfo() == &JSArray::info) {
+                    // Input is a Javascript Array. We need to create it to a Java Array.
+                    result.l = convertArrayInstanceToJavaArray(exec, asArray(value), javaClassName);
+                }
+            }
+
+            // Now convert value to a string if the target type is a java.lang.string, and we're not
+            // converting from a Null.
+            if (!result.l && !strcmp(javaClassName, "java.lang.String")) {
+#ifdef CONVERT_NULL_TO_EMPTY_STRING
+                if (value->isNull()) {
+                    JNIEnv* env = getJNIEnv();
+                    jchar buf[2];
+                    jobject javaString = env->functions->NewString(env, buf, 0);
+                    result.l = javaString;
+                } else
+#else
+                if (!value.isNull())
+#endif
+                {
+                    UString stringValue = value.toString(exec);
+                    JNIEnv* env = getJNIEnv();
+                    jobject javaString = env->functions->NewString(env, (const jchar *)stringValue.data(), stringValue.size());
+                    result.l = javaString;
+                }
+            } else if (!result.l)
+                bzero(&result, sizeof(jvalue)); // Handle it the same as a void case
+        }
+        break;
+
+    case boolean_type:
+        {
+            result.z = (jboolean)value.toNumber(exec);
+        }
+        break;
+
+    case byte_type:
+        {
+            result.b = (jbyte)value.toNumber(exec);
+        }
+        break;
+
+    case char_type:
+        {
+            result.c = (jchar)value.toNumber(exec);
+        }
+        break;
+
+    case short_type:
+        {
+            result.s = (jshort)value.toNumber(exec);
+        }
+        break;
+
+    case int_type:
+        {
+            result.i = (jint)value.toNumber(exec);
+        }
+        break;
+
+    case long_type:
+        {
+            result.j = (jlong)value.toNumber(exec);
+        }
+        break;
+
+    case float_type:
+        {
+            result.f = (jfloat)value.toNumber(exec);
+        }
+        break;
+
+    case double_type:
+        {
+            result.d = (jdouble)value.toNumber(exec);
+        }
+        break;
+
+        break;
+
+    case invalid_type:
+    default:
+    case void_type:
+        {
+            bzero(&result, sizeof(jvalue));
+        }
+        break;
+    }
+    return result;
+}
+
+}  // end of namespace Bindings
+
+} // end of namespace JSC
+
+#endif // ENABLE(MAC_JAVA_BRIDGE)
diff --git a/WebCore/bridge/jni/jsc/jni_utility_private.h b/WebCore/bridge/jni/jsc/jni_utility_private.h
new file mode 100644
index 0000000..647852e
--- /dev/null
+++ b/WebCore/bridge/jni/jsc/jni_utility_private.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _JNI_UTILITY_PRIVATE_H_
+#define _JNI_UTILITY_PRIVATE_H_
+
+#if ENABLE(MAC_JAVA_BRIDGE)
+
+#include "jni_utility.h"
+#include <runtime/JSValue.h>
+
+namespace JSC {
+
+class ExecState;
+class JSObject;
+
+namespace Bindings {
+
+jvalue convertValueToJValue(ExecState*, JSValue, JNIType, const char* javaClassName);
+bool dispatchJNICall(ExecState*, const void* targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue* args, jvalue& result, const char* callingURL, JSValue& exceptionDescription);
+
+} // namespace Bindings
+
+} // namespace JSC
+
+#endif // ENABLE(MAC_JAVA_BRIDGE)
+
+#endif // _JNI_UTILITY_H_
diff --git a/WebCore/platform/android/TemporaryLinkStubs.cpp b/WebCore/platform/android/TemporaryLinkStubs.cpp
index e1889f0..366368b 100644
--- a/WebCore/platform/android/TemporaryLinkStubs.cpp
+++ b/WebCore/platform/android/TemporaryLinkStubs.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007, The Android Open Source Project
+ * Copyright 2009, The Android Open Source Project
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -85,7 +85,7 @@
 #include "JavaScriptCallFrame.h"
 #include "JavaScriptDebugServer.h"
 #include "JavaScriptProfile.h"
-#include "jni_utility.h"
+#include "jni_utility_private.h"
 #endif
 
 using namespace WebCore;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list