Changeset 92659 in webkit
- Timestamp:
- Aug 8, 2011 5:55:30 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 deleted
- 7 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r92658 r92659 1 2011-08-08 Steve Block <steveblock@google.com> 2 3 Removes V8's JavaInstanceJobject, JavaClassJobject and JavaFieldJobject. 4 https://bugs.webkit.org/show_bug.cgi?id=57859 5 6 Reviewed by Alexey Proskuryakov. 7 8 This effectively reverts the changes made in Bugs 55383, 57533 and 9 55766. These classes were only used by Android. In the future, Android 10 will use the Chromium WebKit API to implement the Java bridge. 11 12 Towards this goal, this patch ... 13 - Simplfies the JavaInstance, JavaClass and JavaField interfaces for V8. 14 These interfaces will be implemented in Chromium's WebKit layer. 15 - Adds a JavaMethod interface for V8 16 - Removes the jvalue <-> JavaValue conversion functions for V8, which are 17 now superfluous 18 - Removes the calls to JavaInstance::begin()/end() for V8, which are now 19 superfluous 20 21 Will be covered by existing tests once the Chromium WebKit layer is complete. 22 23 * WebCore.gypi: 24 * bridge/jni/v8/JNIUtilityPrivate.cpp: 25 * bridge/jni/v8/JNIUtilityPrivate.h: 26 * bridge/jni/v8/JavaClassJobjectV8.cpp: Removed. 27 * bridge/jni/v8/JavaFieldJobjectV8.cpp: Removed. 28 * bridge/jni/v8/JavaFieldJobjectV8.h: Removed. 29 * bridge/jni/v8/JavaFieldV8.h: 30 * bridge/jni/v8/JavaInstanceJobjectV8.cpp: Removed. 31 * bridge/jni/v8/JavaInstanceJobjectV8.h: Removed. 32 * bridge/jni/v8/JavaInstanceV8.h: 33 * bridge/jni/v8/JavaMethodV8.h: 34 (JSC::Bindings::JavaMethod::~JavaMethod): 35 * bridge/jni/v8/JavaNPObjectV8.cpp: 36 (JSC::Bindings::JavaNPObjectHasMethod): 37 (JSC::Bindings::JavaNPObjectInvoke): 38 (JSC::Bindings::JavaNPObjectHasProperty): 39 (JSC::Bindings::JavaNPObjectGetProperty): 40 1 41 2011-08-08 Chris Rogers <crogers@google.com> 2 42 -
trunk/Source/WebCore/WebCore.gypi
r92572 r92659 2257 2257 'bridge/jni/v8/JNIUtilityPrivate.cpp', 2258 2258 'bridge/jni/v8/JNIUtilityPrivate.h', 2259 'bridge/jni/v8/JavaClassJobjectV8.cpp',2260 'bridge/jni/v8/JavaClassJobjectV8.h',2261 2259 'bridge/jni/v8/JavaClassV8.h', 2262 'bridge/jni/v8/JavaFieldJobjectV8.cpp',2263 'bridge/jni/v8/JavaFieldJobjectV8.h',2264 2260 'bridge/jni/v8/JavaFieldV8.h', 2265 'bridge/jni/v8/JavaInstanceJobjectV8.cpp',2266 'bridge/jni/v8/JavaInstanceJobjectV8.h',2267 2261 'bridge/jni/v8/JavaInstanceV8.h', 2262 'bridge/jni/v8/JavaMethodV8.h', 2268 2263 'bridge/jni/v8/JavaNPObjectV8.cpp', 2269 2264 'bridge/jni/v8/JavaNPObjectV8.h', -
trunk/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
r91260 r92659 29 29 #if ENABLE(JAVA_BRIDGE) 30 30 31 #include "JavaInstance JobjectV8.h"31 #include "JavaInstanceV8.h" 32 32 #include "JavaNPObjectV8.h" 33 33 #include "JavaValueV8.h" … … 235 235 } 236 236 237 JavaValue jvalueToJavaValue(const jvalue& value, const JavaType& type)238 {239 JavaValue result;240 result.m_type = type;241 switch (result.m_type) {242 case JavaTypeVoid:243 break;244 case JavaTypeObject:245 result.m_objectValue = new JavaInstanceJobject(value.l);246 break;247 case JavaTypeString:248 {249 jstring javaString = static_cast<jstring>(value.l);250 const UChar* characters = getUCharactersFromJStringInEnv(getJNIEnv(), javaString);251 // We take a copy to allow the Java String to be released.252 result.m_stringValue = String(characters, getJNIEnv()->GetStringLength(javaString));253 releaseUCharactersForJStringInEnv(getJNIEnv(), javaString, characters);254 }255 break;256 case JavaTypeBoolean:257 result.m_booleanValue = value.z == JNI_FALSE ? false : true;258 break;259 case JavaTypeByte:260 result.m_byteValue = value.b;261 break;262 case JavaTypeChar:263 result.m_charValue = value.c;264 break;265 case JavaTypeShort:266 result.m_shortValue = value.s;267 break;268 case JavaTypeInt:269 result.m_intValue = value.i;270 break;271 case JavaTypeLong:272 result.m_longValue = value.j;273 break;274 case JavaTypeFloat:275 result.m_floatValue = value.f;276 break;277 case JavaTypeDouble:278 result.m_doubleValue = value.d;279 break;280 default:281 ASSERT(false);282 }283 return result;284 }285 286 jvalue javaValueToJvalue(const JavaValue& value)287 {288 jvalue result;289 memset(&result, 0, sizeof(jvalue));290 switch (value.m_type) {291 case JavaTypeVoid:292 break;293 case JavaTypeObject:294 if (value.m_objectValue) {295 // This method is used only by JavaInstanceJobject, so we know the296 // derived type of the object.297 result.l = static_cast<JavaInstanceJobject*>(value.m_objectValue.get())->javaInstance();298 }299 break;300 case JavaTypeString:301 // This creates a local reference to a new String object, which will302 // be released when the call stack returns to Java. Note that this303 // may cause leaks if invoked from a native message loop, as is the304 // case in workers.305 result.l = getJNIEnv()->NewString(value.m_stringValue.characters(), value.m_stringValue.length());306 break;307 case JavaTypeBoolean:308 result.z = value.m_booleanValue ? JNI_TRUE : JNI_FALSE;309 break;310 case JavaTypeByte:311 result.b = value.m_byteValue;312 break;313 case JavaTypeChar:314 result.c = value.m_charValue;315 break;316 case JavaTypeShort:317 result.s = value.m_shortValue;318 break;319 case JavaTypeInt:320 result.i = value.m_intValue;321 break;322 case JavaTypeLong:323 result.j = value.m_longValue;324 break;325 case JavaTypeFloat:326 result.f = value.m_floatValue;327 break;328 case JavaTypeDouble:329 result.d = value.m_doubleValue;330 break;331 default:332 ASSERT(false);333 }334 return result;335 }336 337 237 } // namespace Bindings 338 238 -
trunk/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.h
r82194 r92659 42 42 void convertJavaValueToNPVariant(JavaValue, NPVariant*); 43 43 44 JavaValue jvalueToJavaValue(const jvalue&, const JavaType&);45 jvalue javaValueToJvalue(const JavaValue&);46 47 44 } // namespace Bindings 48 45 -
trunk/Source/WebCore/bridge/jni/v8/JavaFieldV8.h
r82554 r92659 41 41 42 42 virtual String name() const = 0; 43 virtual const char* typeClassName() const = 0;44 virtual JavaType type() const = 0;45 43 }; 46 44 -
trunk/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h
r82950 r92659 50 50 // args must be an array of length greater than or equal to the number of 51 51 // arguments expected by the method. 52 virtual JavaValue invokeMethod(const JavaMethod*, JavaValue* args) = 0; 53 virtual JavaValue getField(const JavaField*) = 0; 54 55 // These functions are called before and after the main entry points into 56 // the native implementations. They can be used to establish and cleanup 57 // any needed state. 58 virtual void begin() = 0; 59 virtual void end() = 0; 52 virtual JavaValue invokeMethod(const JavaMethod&, JavaValue* args) = 0; 53 virtual JavaValue getField(const JavaField&) = 0; 60 54 }; 61 55 -
trunk/Source/WebCore/bridge/jni/v8/JavaMethodV8.h
r92658 r92659 1 1 /* 2 * Copyright (C) 2003, 2004, 2005, 2007, 2009, 2010 Apple Inc. All rights reserved. 2 3 * Copyright 2010, The Android Open Source Project 3 4 * … … 5 6 * modification, are permitted provided that the following conditions 6 7 * are met: 7 * *Redistributions of source code must retain the above copyright8 * 1. Redistributions of source code must retain the above copyright 8 9 * notice, this list of conditions and the following disclaimer. 9 * *Redistributions in binary form must reproduce the above copyright10 * 2. Redistributions in binary form must reproduce the above copyright 10 11 * notice, this list of conditions and the following disclaimer in the 11 12 * documentation and/or other materials provided with the distribution. 12 13 * 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS``AS IS'' AND ANY14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNEROR17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, … … 24 25 */ 25 26 26 #ifndef Java ClassJobjectV8_h27 #define Java ClassJobjectV8_h27 #ifndef JavaMethodV8_h 28 #define JavaMethodV8_h 28 29 29 30 #if ENABLE(JAVA_BRIDGE) 30 31 31 #include "JNIUtility.h" 32 #include "JavaClassV8.h" 32 #include "Bridge.h" 33 #include "JavaType.h" 34 35 #include <wtf/text/WTFString.h> 33 36 34 37 namespace JSC { … … 36 39 namespace Bindings { 37 40 38 class JavaClassJobject : public JavaClass { 41 typedef const char* RuntimeType; 42 43 class JavaMethod : public Method { 39 44 public: 40 JavaClassJobject(jobject); 41 virtual ~JavaClassJobject(); 45 virtual ~JavaMethod() { } 42 46 43 // JavaClass implementation 44 virtual MethodList methodsNamed(const char* name) const; 45 virtual JavaField* fieldNamed(const char* name) const; 46 47 private: 48 typedef HashMap<WTF::String, MethodList*> MethodListMap; 49 MethodListMap m_methods; 50 FieldMap m_fields; 47 virtual String name() const = 0; 48 virtual String parameterAt(int) const = 0; 51 49 }; 52 50 … … 57 55 #endif // ENABLE(JAVA_BRIDGE) 58 56 59 #endif // Java ClassJobjectV8_h57 #endif // JavaMethodV8_h -
trunk/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp
r82361 r92659 98 98 return false; 99 99 100 instance->begin();101 100 bool result = (instance->getClass()->methodsNamed(name).size() > 0); 102 instance->end();103 101 104 102 // TODO: use NPN_MemFree … … 116 114 if (!name) 117 115 return false; 118 119 instance->begin();120 116 121 117 MethodList methodList = instance->getClass()->methodsNamed(name); … … 145 141 jArgs[i] = convertNPVariantToJavaValue(args[i], jMethod->parameterAt(i)); 146 142 147 JavaValue jResult = instance->invokeMethod(jMethod, jArgs); 148 instance->end(); 143 JavaValue jResult = instance->invokeMethod(*jMethod, jArgs); 149 144 delete[] jArgs; 150 145 … … 162 157 if (!name) 163 158 return false; 164 instance->begin();165 159 bool result = instance->getClass()->fieldNamed(name); 166 instance->end();167 160 free(name); 168 161 return result; … … 179 172 return false; 180 173 181 instance->begin();182 174 JavaField* field = instance->getClass()->fieldNamed(name); 183 175 free(name); // TODO: use NPN_MemFree … … 185 177 return false; 186 178 187 JavaValue value = instance->getField(field); 188 instance->end(); 179 JavaValue value = instance->getField(*field); 189 180 190 181 convertJavaValueToNPVariant(value, result);
Note: See TracChangeset
for help on using the changeset viewer.