From 4aeef553983e9d7a42b18646498bbd4b5a1c8c0a Mon Sep 17 00:00:00 2001 From: Steve Block Date: Thu, 21 Jan 2010 19:08:14 +0000 Subject: [PATCH] V8 can now use WebCore/bridge/jni/JNIBridge.h JNIBridge.h is now used by both JSC and V8 $ diff WebCore/bridge/jni/JNIBridge.h V8Binding/jni/jni_runtime.h 2d1 < * Copyright (C) 2003, 2004, 2005, 2007, 2009, 2010 Apple Inc. All rights reserved. 27,30c26,27 < #ifndef JNIBridge_h < #define JNIBridge_h < < #if ENABLE(MAC_JAVA_BRIDGE) --- > #ifndef jni_runtime_h > #define jni_runtime_h 31a29 > #include "Bridge.h" 34,35c32,33 < #if USE(JSC) < #include "JavaStringJSC.h" --- > #if USE(V8) > #include "JavaStringV8.h" 64,66d61 < #if USE(JSC) < operator UString() const { return m_impl.uString(); } < #endif 118,120c113 < #endif // ENABLE(MAC_JAVA_BRIDGE) < < #endif // JNIBridge_h --- > #endif // jni_runtime_h Change-Id: I59c7dafb295aa7c81e79283333266c3f9f5a9a52 --- Android.mk | 6 -- V8Binding/jni/jni_runtime.cpp | 2 +- V8Binding/jni/jni_runtime.h | 113 ---------------------------- WebCore/Android.v8bindings.mk | 2 + WebCore/bridge/jni/JNIBridge.h | 5 ++ WebCore/bridge/jni/v8/JNIBridgeV8.h | 4 +- WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp | 2 +- WebCore/bridge/jni/v8/JavaClassV8.cpp | 2 +- WebCore/bridge/jni/v8/JavaInstanceV8.cpp | 2 +- WebCore/bridge/jni/v8/JavaNPObjectV8.cpp | 1 - WebCore/bridge/jni/v8/JavaNPObjectV8.h | 2 +- 11 files changed, 13 insertions(+), 128 deletions(-) delete mode 100644 V8Binding/jni/jni_runtime.h diff --git a/Android.mk b/Android.mk index 58a4bb6e7..e24770e99 100644 --- a/Android.mk +++ b/Android.mk @@ -173,12 +173,6 @@ ifeq ($(JAVASCRIPT_ENGINE),v8) include $(LOCAL_PATH)/Android.v8bindings.mk # TODO: We should use the WebCore JNI code instead. JNI_PATH := V8Binding/jni -# bridge/jni path must be listed after V8Bindings, so files are preferentially -# included from V8bindings. -BINDING_C_INCLUDES += \ - $(BASE_PATH)/$(JNI_PATH) \ - $(LOCAL_PATH)/bridge/jni \ - $(LOCAL_PATH)/bridge/jni/v8 JNI_SRC_FILES := \ jni_runtime.cpp WEBKIT_SRC_FILES += $(addprefix $(JNI_PATH)/,$(JNI_SRC_FILES)) diff --git a/V8Binding/jni/jni_runtime.cpp b/V8Binding/jni/jni_runtime.cpp index 3b183bc6a..edb1b2f44 100644 --- a/V8Binding/jni/jni_runtime.cpp +++ b/V8Binding/jni/jni_runtime.cpp @@ -24,7 +24,7 @@ */ #include "config.h" -#include "jni_runtime.h" +#include "JNIBridge.h" #include "JNIUtility.h" #include "StringBuilder.h" diff --git a/V8Binding/jni/jni_runtime.h b/V8Binding/jni/jni_runtime.h deleted file mode 100644 index c6565d0dd..000000000 --- a/V8Binding/jni/jni_runtime.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2010, 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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_runtime_h -#define jni_runtime_h - -#include "Bridge.h" -#include "JNIUtility.h" - -#if USE(V8) -#include "JavaStringV8.h" -#endif - -namespace JSC { - -namespace Bindings { - -typedef const char* RuntimeType; - -class JavaString { -public: - JavaString() - { - m_impl.init(); - } - - JavaString(JNIEnv* e, jstring s) - { - m_impl.init(e, s); - } - - JavaString(jstring s) - { - m_impl.init(getJNIEnv(), s); - } - - const char* UTF8String() const { return m_impl.UTF8String(); } - const jchar* uchars() const { return m_impl.uchars(); } - int length() const { return m_impl.length(); } - -private: - JavaStringImpl m_impl; -}; - -class JavaParameter { -public: - JavaParameter() : m_JNIType(invalid_type) { } - JavaParameter(JNIEnv*, jstring type); - virtual ~JavaParameter() { } - - RuntimeType type() const { return m_type.UTF8String(); } - JNIType getJNIType() const { return m_JNIType; } - -private: - JavaString m_type; - JNIType m_JNIType; -}; - -class JavaMethod : public Method { -public: - JavaMethod(JNIEnv*, jobject aMethod); - ~JavaMethod(); - - const JavaString& name() const { return m_name; } - RuntimeType returnType() const { return m_returnType.UTF8String(); } - JavaParameter* parameterAt(int i) const { return &m_parameters[i]; } - int numParameters() const { return m_numParameters; } - - const char* signature() const; - JNIType JNIReturnType() const; - - jmethodID methodID(jobject obj) const; - - bool isStatic() const { return m_isStatic; } - -private: - JavaParameter* m_parameters; - int m_numParameters; - JavaString m_name; - mutable char* m_signature; - JavaString m_returnType; - JNIType m_JNIReturnType; - mutable jmethodID m_methodID; - bool m_isStatic; -}; - -} // namespace Bindings - -} // namespace JSC - -#endif // jni_runtime_h diff --git a/WebCore/Android.v8bindings.mk b/WebCore/Android.v8bindings.mk index ce6c42d3d..6aa18d463 100644 --- a/WebCore/Android.v8bindings.mk +++ b/WebCore/Android.v8bindings.mk @@ -31,6 +31,8 @@ BINDING_C_INCLUDES := \ $(LOCAL_PATH)/bindings/v8 \ $(LOCAL_PATH)/bindings/v8/custom \ $(LOCAL_PATH)/bridge \ + $(LOCAL_PATH)/bridge/jni \ + $(LOCAL_PATH)/bridge/jni/v8 \ $(LOCAL_PATH)/bridge/jsc \ \ $(base_intermediates)/WebCore/bindings \ diff --git a/WebCore/bridge/jni/JNIBridge.h b/WebCore/bridge/jni/JNIBridge.h index 712ee7dbf..c48ed9820 100644 --- a/WebCore/bridge/jni/JNIBridge.h +++ b/WebCore/bridge/jni/JNIBridge.h @@ -29,10 +29,15 @@ #if ENABLE(MAC_JAVA_BRIDGE) +#include "Bridge.h" #include "JNIUtility.h" +// ANDROID +// Upstream the V8 ifdef to webkit.org #if USE(JSC) #include "JavaStringJSC.h" +#elif USE(V8) +#include "JavaStringV8.h" #endif namespace JSC { diff --git a/WebCore/bridge/jni/v8/JNIBridgeV8.h b/WebCore/bridge/jni/v8/JNIBridgeV8.h index 3922d622a..eb5c77ac6 100644 --- a/WebCore/bridge/jni/v8/JNIBridgeV8.h +++ b/WebCore/bridge/jni/v8/JNIBridgeV8.h @@ -26,11 +26,9 @@ #ifndef JNIBridgeV8_h #define JNIBridgeV8_h +#include "JNIBridge.h" #include "JNIUtility.h" #include "JavaInstanceV8.h" -#include "JavaStringV8.h" -#include "jni_runtime.h" - namespace JSC { diff --git a/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp b/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp index a71814c62..a6cfb2df8 100644 --- a/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp +++ b/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp @@ -26,9 +26,9 @@ #include "config.h" #include "JNIUtilityPrivate.h" +#include "JNIBridge.h" #include "JavaInstanceV8.h" #include "JavaNPObjectV8.h" -#include "jni_runtime.h" namespace JSC { diff --git a/WebCore/bridge/jni/v8/JavaClassV8.cpp b/WebCore/bridge/jni/v8/JavaClassV8.cpp index c29cf86c0..8d794ee99 100644 --- a/WebCore/bridge/jni/v8/JavaClassV8.cpp +++ b/WebCore/bridge/jni/v8/JavaClassV8.cpp @@ -27,8 +27,8 @@ #include "config.h" #include "JavaClassV8.h" +#include "JNIBridge.h" #include "JNIUtility.h" -#include "jni_runtime.h" using namespace JSC::Bindings; diff --git a/WebCore/bridge/jni/v8/JavaInstanceV8.cpp b/WebCore/bridge/jni/v8/JavaInstanceV8.cpp index 13d498427..4d6b49f68 100644 --- a/WebCore/bridge/jni/v8/JavaInstanceV8.cpp +++ b/WebCore/bridge/jni/v8/JavaInstanceV8.cpp @@ -26,9 +26,9 @@ #include "config.h" #include "JavaInstanceV8.h" +#include "JNIBridge.h" #include "JNIUtility.h" #include "JavaClassV8.h" -#include "jni_runtime.h" #include #include diff --git a/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp b/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp index 636d07596..94c2198b6 100644 --- a/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp +++ b/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp @@ -30,7 +30,6 @@ #include "JNIUtility.h" #include "JavaClassV8.h" #include "JavaInstanceV8.h" -#include "jni_runtime.h" #include "npruntime_impl.h" namespace JSC { diff --git a/WebCore/bridge/jni/v8/JavaNPObjectV8.h b/WebCore/bridge/jni/v8/JavaNPObjectV8.h index c36ef7020..89e2f3b5f 100644 --- a/WebCore/bridge/jni/v8/JavaNPObjectV8.h +++ b/WebCore/bridge/jni/v8/JavaNPObjectV8.h @@ -26,7 +26,7 @@ #ifndef JavaNPObjectV8_h #define JavaNPObjectV8_h -#include "jni_runtime.h" +#include "JNIBridge.h" #include "npruntime.h" #include #include -- 2.11.0