[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

steveblock at google.com steveblock at google.com
Thu Feb 4 21:21:27 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 951b50f59729977a6ff10fe0c49da4a914f01dd8
Author: steveblock at google.com <steveblock at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 20 09:58:40 2010 +0000

    Fixes style in WebCore/bridge/JNIUtility
    https://bugs.webkit.org/show_bug.cgi?id=33870
    
    Reviewed by David Levin.
    
    No new tests, style fixes only.
    
    * bridge/jni/JNIUtility.cpp:
    * bridge/jni/JNIUtility.h:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53533 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e266dae..dcec16d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,15 @@
+2010-01-19  Steve Block  <steveblock at google.com>
+
+        Reviewed by David Levin.
+
+        Fixes style in WebCore/bridge/JNIUtility
+        https://bugs.webkit.org/show_bug.cgi?id=33870
+
+        No new tests, style fixes only.
+
+        * bridge/jni/JNIUtility.cpp:
+        * bridge/jni/JNIUtility.h:
+
 2010-01-20  Simon Hausmann  <simon.hausmann at nokia.com>
 
         Reviewed by Tor Arne Vestbø.
diff --git a/WebCore/bridge/jni/JNIUtility.cpp b/WebCore/bridge/jni/JNIUtility.cpp
index d2ac475..ee45710 100644
--- a/WebCore/bridge/jni/JNIUtility.cpp
+++ b/WebCore/bridge/jni/JNIUtility.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -20,7 +20,7 @@
  * 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. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "config.h"
@@ -34,7 +34,7 @@ namespace JSC {
 
 namespace Bindings {
 
-static jint KJS_GetCreatedJavaVMs(JavaVM** vmBuf, jsize bufLen, jsize* nVMs)
+static jint KJSGetCreatedJavaVMs(JavaVM** vmBuf, jsize bufLen, jsize* nVMs)
 {
     static void* javaVMFramework = 0;
     if (!javaVMFramework)
@@ -42,43 +42,43 @@ static jint KJS_GetCreatedJavaVMs(JavaVM** vmBuf, jsize bufLen, jsize* nVMs)
     if (!javaVMFramework)
         return JNI_ERR;
 
-    static jint(*functionPointer)(JavaVM**, jsize, jsize *) = 0;
+    typedef jint(*FunctionPointerType)(JavaVM**, jsize, jsize*);
+    static FunctionPointerType functionPointer = 0;
     if (!functionPointer)
-        functionPointer = (jint(*)(JavaVM**, jsize, jsize *))dlsym(javaVMFramework, "JNI_GetCreatedJavaVMs");
+        functionPointer = reinterpret_cast<FunctionPointerType>(dlsym(javaVMFramework, "JNI_GetCreatedJavaVMs"));
     if (!functionPointer)
         return JNI_ERR;
     return functionPointer(vmBuf, bufLen, nVMs);
 }
 
-static JavaVM *jvm = 0;
+static JavaVM* jvm = 0;
 
 // Provide the ability for an outside component to specify the JavaVM to use
-// If the jvm value is set, the getJavaVM function below will just return. 
+// If the jvm value is set, the getJavaVM function below will just return.
 // In getJNIEnv(), if AttachCurrentThread is called to a VM that is already
 // attached, the result is a no-op.
-void setJavaVM(JavaVM *javaVM)
+void setJavaVM(JavaVM* javaVM)
 {
     jvm = javaVM;
 }
 
-JavaVM *getJavaVM()
+JavaVM* getJavaVM()
 {
     if (jvm)
         return jvm;
 
-    JavaVM *jvmArray[1];
+    JavaVM* jvmArray[1];
     jsize bufLen = 1;
     jsize nJVMs = 0;
     jint jniError = 0;
 
     // Assumes JVM is already running ..., one per process
-    jniError = KJS_GetCreatedJavaVMs(jvmArray, bufLen, &nJVMs);
-    if ( jniError == JNI_OK && nJVMs > 0 ) {
+    jniError = KJSGetCreatedJavaVMs(jvmArray, bufLen, &nJVMs);
+    if (jniError == JNI_OK && nJVMs > 0)
         jvm = jvmArray[0];
-    }
-    else 
-        fprintf(stderr, "%s: JNI_GetCreatedJavaVMs failed, returned %ld\n", __PRETTY_FUNCTION__, (long)jniError);
-        
+    else
+        fprintf(stderr, "%s: JNI_GetCreatedJavaVMs failed, returned %ld\n", __PRETTY_FUNCTION__, static_cast<long>(jniError));
+
     return jvm;
 }
 
@@ -90,29 +90,27 @@ JNIEnv* getJNIEnv()
     } u;
     jint jniError = 0;
 
-    jniError = (getJavaVM())->AttachCurrentThread(&u.dummy, NULL);
+    jniError = getJavaVM()->AttachCurrentThread(&u.dummy, 0);
     if (jniError == JNI_OK)
         return u.env;
-    else
-        fprintf(stderr, "%s: AttachCurrentThread failed, returned %ld\n", __PRETTY_FUNCTION__, (long)jniError);
-    return NULL;
+    fprintf(stderr, "%s: AttachCurrentThread failed, returned %ld\n", __PRETTY_FUNCTION__, static_cast<long>(jniError));
+    return 0;
 }
 
-jmethodID getMethodID (jobject obj, const char *name, const char *sig)
+jmethodID getMethodID(jobject obj, const char* name, const char* sig)
 {
-    JNIEnv *env = getJNIEnv();
+    JNIEnv* env = getJNIEnv();
     jmethodID mid = 0;
-        
-    if ( env != NULL) {
-    jclass cls = env->GetObjectClass(obj);
-    if ( cls != NULL ) {
+
+    if (env) {
+        jclass cls = env->GetObjectClass(obj);
+        if (cls) {
             mid = env->GetMethodID(cls, name, sig);
             if (!mid) {
                 env->ExceptionClear();
                 mid = env->GetStaticMethodID(cls, name, sig);
-                if (!mid) {
+                if (!mid)
                     env->ExceptionClear();
-                }
             }
         }
         env->DeleteLocalRef(cls);
@@ -120,118 +118,118 @@ jmethodID getMethodID (jobject obj, const char *name, const char *sig)
     return mid;
 }
 
-const char *getCharactersFromJString (jstring aJString)
+const char* getCharactersFromJString(jstring aJString)
 {
-    return getCharactersFromJStringInEnv (getJNIEnv(), aJString);
+    return getCharactersFromJStringInEnv(getJNIEnv(), aJString);
 }
 
-void releaseCharactersForJString (jstring aJString, const char *s)
+void releaseCharactersForJString(jstring aJString, const char* s)
 {
-    releaseCharactersForJStringInEnv (getJNIEnv(), aJString, s);
+    releaseCharactersForJStringInEnv(getJNIEnv(), aJString, s);
 }
 
-const char *getCharactersFromJStringInEnv (JNIEnv *env, jstring aJString)
+const char* getCharactersFromJStringInEnv(JNIEnv* env, jstring aJString)
 {
     jboolean isCopy;
-    const char *s = env->GetStringUTFChars((jstring)aJString, &isCopy);
+    const char* s = env->GetStringUTFChars(aJString, &isCopy);
     if (!s) {
         env->ExceptionDescribe();
         env->ExceptionClear();
-                fprintf (stderr, "\n");
+        fprintf(stderr, "\n");
     }
     return s;
 }
 
-void releaseCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const char *s)
+void releaseCharactersForJStringInEnv(JNIEnv* env, jstring aJString, const char* s)
 {
-    env->ReleaseStringUTFChars (aJString, s);
+    env->ReleaseStringUTFChars(aJString, s);
 }
 
-const jchar *getUCharactersFromJStringInEnv (JNIEnv *env, jstring aJString)
+const jchar* getUCharactersFromJStringInEnv(JNIEnv* env, jstring aJString)
 {
     jboolean isCopy;
-    const jchar *s = env->GetStringChars((jstring)aJString, &isCopy);
+    const jchar* s = env->GetStringChars(aJString, &isCopy);
     if (!s) {
         env->ExceptionDescribe();
         env->ExceptionClear();
-                fprintf (stderr, "\n");
+        fprintf(stderr, "\n");
     }
     return s;
 }
 
-void releaseUCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const jchar *s)
+void releaseUCharactersForJStringInEnv(JNIEnv* env, jstring aJString, const jchar* s)
 {
-    env->ReleaseStringChars (aJString, s);
+    env->ReleaseStringChars(aJString, s);
 }
 
-JNIType JNITypeFromClassName(const char *name)
+JNIType JNITypeFromClassName(const char* name)
 {
     JNIType type;
-    
-    if (strcmp("byte",name) == 0)
+
+    if (!strcmp("byte", name))
         type = byte_type;
-    else if (strcmp("short",name) == 0)
+    else if (!strcmp("short", name))
         type = short_type;
-    else if (strcmp("int",name) == 0)
+    else if (!strcmp("int", name))
         type = int_type;
-    else if (strcmp("long",name) == 0)
+    else if (!strcmp("long", name))
         type = long_type;
-    else if (strcmp("float",name) == 0)
+    else if (!strcmp("float", name))
         type = float_type;
-    else if (strcmp("double",name) == 0)
+    else if (!strcmp("double", name))
         type = double_type;
-    else if (strcmp("char",name) == 0)
+    else if (!strcmp("char", name))
         type = char_type;
-    else if (strcmp("boolean",name) == 0)
+    else if (!strcmp("boolean", name))
         type = boolean_type;
-    else if (strcmp("void",name) == 0)
+    else if (!strcmp("void", name))
         type = void_type;
-    else if ('[' == name[0]) 
+    else if ('[' == name[0])
         type = array_type;
     else
         type = object_type;
-        
+
     return type;
 }
 
-const char *signatureFromPrimitiveType(JNIType type)
+const char* signatureFromPrimitiveType(JNIType type)
 {
-    switch (type){
-        case void_type: 
-            return "V";
-        
-        case array_type:
-            return "[";
-        
-        case object_type:
-            return "L";
-        
-        case boolean_type:
-            return "Z";
-        
-        case byte_type:
-            return "B";
-            
-        case char_type:
-            return "C";
-        
-        case short_type:
-            return "S";
-        
-        case int_type:
-            return "I";
-        
-        case long_type:
-            return "J";
-        
-        case float_type:
-            return "F";
-        
-        case double_type:
-            return "D";
-
-        case invalid_type:
-        default:
+    switch (type) {
+    case void_type:
+        return "V";
+
+    case array_type:
+        return "[";
+
+    case object_type:
+        return "L";
+
+    case boolean_type:
+        return "Z";
+
+    case byte_type:
+        return "B";
+
+    case char_type:
+        return "C";
+
+    case short_type:
+        return "S";
+
+    case int_type:
+        return "I";
+
+    case long_type:
+        return "J";
+
+    case float_type:
+        return "F";
+
+    case double_type:
+        return "D";
+
+    case invalid_type:
+    default:
         break;
     }
     return "";
@@ -239,58 +237,58 @@ const char *signatureFromPrimitiveType(JNIType type)
 
 JNIType JNITypeFromPrimitiveType(char type)
 {
-    switch (type){
-        case 'V': 
-            return void_type;
-        
-        case 'L':
-            return object_type;
-            
-        case '[':
-            return array_type;
-        
-        case 'Z':
-            return boolean_type;
-        
-        case 'B':
-            return byte_type;
-            
-        case 'C':
-            return char_type;
-        
-        case 'S':
-            return short_type;
-        
-        case 'I':
-            return int_type;
-        
-        case 'J':
-            return long_type;
-        
-        case 'F':
-            return float_type;
-        
-        case 'D':
-            return double_type;
-
-        default:
+    switch (type) {
+    case 'V':
+        return void_type;
+
+    case 'L':
+        return object_type;
+
+    case '[':
+        return array_type;
+
+    case 'Z':
+        return boolean_type;
+
+    case 'B':
+        return byte_type;
+
+    case 'C':
+        return char_type;
+
+    case 'S':
+        return short_type;
+
+    case 'I':
+        return int_type;
+
+    case 'J':
+        return long_type;
+
+    case 'F':
+        return float_type;
+
+    case 'D':
+        return double_type;
+
+    default:
         break;
     }
     return invalid_type;
 }
 
-jvalue getJNIField( jobject obj, JNIType type, const char *name, const char *signature)
+jvalue getJNIField(jobject obj, JNIType type, const char* name, const char* signature)
 {
-    JavaVM *jvm = getJavaVM();
-    JNIEnv *env = getJNIEnv();
+    JavaVM* jvm = getJavaVM();
+    JNIEnv* env = getJNIEnv();
     jvalue result;
 
-    bzero (&result, sizeof(jvalue));
-    if ( obj != NULL && jvm != NULL && env != NULL) {
+    bzero(&result, sizeof(jvalue));
+    if (obj && jvm && env) {
         jclass cls = env->GetObjectClass(obj);
-        if ( cls != NULL ) {
+        if (cls) {
             jfieldID field = env->GetFieldID(cls, name, signature);
-            if ( field != NULL ) {
+            if (field) {
                 switch (type) {
                 case array_type:
                 case object_type:
@@ -321,29 +319,25 @@ jvalue getJNIField( jobject obj, JNIType type, const char *name, const char *sig
                     result.d = env->functions->GetDoubleField(env, obj, field);
                     break;
                 default:
-                    fprintf(stderr, "%s: invalid field type (%d)\n", __PRETTY_FUNCTION__, (int)type);
+                    fprintf(stderr, "%s: invalid field type (%d)\n", __PRETTY_FUNCTION__, static_cast<int>(type));
                 }
-            }
-            else
-            {
+            } else {
                 fprintf(stderr, "%s: Could not find field: %s\n", __PRETTY_FUNCTION__, name);
                 env->ExceptionDescribe();
                 env->ExceptionClear();
-                fprintf (stderr, "\n");
+                fprintf(stderr, "\n");
             }
 
             env->DeleteLocalRef(cls);
-        }
-        else {
+        } else
             fprintf(stderr, "%s: Could not find class for object\n", __PRETTY_FUNCTION__);
-        }
     }
 
     return result;
 }
 
-}  // end of namespace Bindings
+} // namespace Bindings
 
-} // end of namespace JSC
+} // namespace JSC
 
 #endif // ENABLE(MAC_JAVA_BRIDGE)
diff --git a/WebCore/bridge/jni/JNIUtility.h b/WebCore/bridge/jni/JNIUtility.h
index 4d17040..85c3533 100644
--- a/WebCore/bridge/jni/JNIUtility.h
+++ b/WebCore/bridge/jni/JNIUtility.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2008, 2009, 2010 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -20,7 +20,7 @@
  * 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. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef JNIUtility_h
@@ -56,26 +56,26 @@ namespace Bindings {
 
 class JavaParameter;
 
-const char *getCharactersFromJString(jstring aJString);
-void releaseCharactersForJString(jstring aJString, const char *s);
+const char* getCharactersFromJString(jstring);
+void releaseCharactersForJString(jstring, const char*);
 
-const char *getCharactersFromJStringInEnv(JNIEnv *env, jstring aJString);
-void releaseCharactersForJStringInEnv(JNIEnv *env, jstring aJString, const char *s);
-const jchar *getUCharactersFromJStringInEnv(JNIEnv *env, jstring aJString);
-void releaseUCharactersForJStringInEnv(JNIEnv *env, jstring aJString, const jchar *s);
+const char* getCharactersFromJStringInEnv(JNIEnv*, jstring);
+void releaseCharactersForJStringInEnv(JNIEnv*, jstring, const char*);
+const jchar* getUCharactersFromJStringInEnv(JNIEnv*, jstring);
+void releaseUCharactersForJStringInEnv(JNIEnv*, jstring, const jchar*);
 
-JNIType JNITypeFromClassName(const char *name);
+JNIType JNITypeFromClassName(const char* name);
 JNIType JNITypeFromPrimitiveType(char type);
-const char *signatureFromPrimitiveType(JNIType type);
+const char* signatureFromPrimitiveType(JNIType);
 
-jvalue getJNIField(jobject obj, JNIType type, const char *name, const char *signature);
+jvalue getJNIField(jobject, JNIType, const char* name, const char* signature);
 
-jmethodID getMethodID(jobject obj, const char *name, const char *sig);
+jmethodID getMethodID(jobject, const char* name, const char* sig);
 JNIEnv* getJNIEnv();
 JavaVM* getJavaVM();
 void setJavaVM(JavaVM*);
-    
-    
+
+
 template <typename T> struct JNICaller;
 
 template<> struct JNICaller<void> {
@@ -97,7 +97,7 @@ template<> struct JNICaller<jobject> {
     static jobject callV(jobject obj, jmethodID mid, va_list args)
     {
         return getJNIEnv()->CallObjectMethodV(obj, mid, args);
-    }    
+    }
 };
 
 template<> struct JNICaller<jboolean> {
@@ -113,7 +113,6 @@ template<> struct JNICaller<jboolean> {
     {
         return getJNIEnv()->CallStaticBooleanMethod(cls, mid, args);
     }
-    
 };
 
 template<> struct JNICaller<jbyte> {
@@ -135,7 +134,7 @@ template<> struct JNICaller<jchar> {
     static jchar callV(jobject obj, jmethodID mid, va_list args)
     {
         return getJNIEnv()->CallCharMethodV(obj, mid, args);
-    }    
+    }
 };
 
 template<> struct JNICaller<jshort> {
@@ -197,36 +196,30 @@ template<typename T> T callJNIMethodIDA(jobject obj, jmethodID mid, jvalue *args
 {
     return JNICaller<T>::callA(obj, mid, args);
 }
-    
+
 template<typename T>
-static T callJNIMethodV(jobject obj, const char *name, const char *sig, va_list args)
+static T callJNIMethodV(jobject obj, const char* name, const char* sig, va_list args)
 {
-    JavaVM *jvm = getJavaVM();
-    JNIEnv *env = getJNIEnv();
-    
-    if ( obj != NULL && jvm != NULL && env != NULL) {
+    JavaVM* jvm = getJavaVM();
+    JNIEnv* env = getJNIEnv();
+
+    if (obj && jvm && env) {
         jclass cls = env->GetObjectClass(obj);
-        if ( cls != NULL ) {
+        if (cls) {
             jmethodID mid = env->GetMethodID(cls, name, sig);
-            if ( mid != NULL )
-            {
+            if (mid) {
                 // Avoids references to cls without popping the local frame.
                 env->DeleteLocalRef(cls);
                 return JNICaller<T>::callV(obj, mid, args);
             }
-            else
-            {
-                fprintf(stderr, "%s: Could not find method: %s for %p\n", __PRETTY_FUNCTION__, name, obj);
-                env->ExceptionDescribe();
-                env->ExceptionClear();
-                fprintf (stderr, "\n");
-            }
+            fprintf(stderr, "%s: Could not find method: %s for %p\n", __PRETTY_FUNCTION__, name, obj);
+            env->ExceptionDescribe();
+            env->ExceptionClear();
+            fprintf(stderr, "\n");
 
             env->DeleteLocalRef(cls);
-        }
-        else {
+        } else
             fprintf(stderr, "%s: Could not find class for %p\n", __PRETTY_FUNCTION__, obj);
-        }
     }
 
     return 0;
@@ -237,42 +230,42 @@ T callJNIMethod(jobject obj, const char* methodName, const char* methodSignature
 {
     va_list args;
     va_start(args, methodSignature);
-    
-    T result= callJNIMethodV<T>(obj, methodName, methodSignature, args);
-    
+
+    T result = callJNIMethodV<T>(obj, methodName, methodSignature, args);
+
     va_end(args);
-    
+
     return result;
 }
-    
+
 template<typename T>
 T callJNIStaticMethod(jclass cls, const char* methodName, const char* methodSignature, ...)
 {
-    JavaVM *jvm = getJavaVM();
-    JNIEnv *env = getJNIEnv();
+    JavaVM* jvm = getJavaVM();
+    JNIEnv* env = getJNIEnv();
     va_list args;
-    
+
     va_start(args, methodSignature);
-    
+
     T result = 0;
-    
-    if (cls != NULL && jvm != NULL && env != NULL) {
+
+    if (cls && jvm && env) {
         jmethodID mid = env->GetStaticMethodID(cls, methodName, methodSignature);
-        if (mid != NULL) 
+        if (mid)
             result = JNICaller<T>::callStaticV(cls, mid, args);
         else {
             fprintf(stderr, "%s: Could not find method: %s for %p\n", __PRETTY_FUNCTION__, methodName, cls);
             env->ExceptionDescribe();
             env->ExceptionClear();
-            fprintf (stderr, "\n");
+            fprintf(stderr, "\n");
         }
     }
-    
+
     va_end(args);
-    
+
     return result;
 }
-    
+
 } // namespace Bindings
 
 } // namespace JSC

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list