bridge/jni/JNIUtility.cpp \
bridge/jni/v8/JNIBridgeV8.cpp \
bridge/jni/v8/JNIUtilityPrivate.cpp \
- bridge/jni/v8/JavaNPObjectV8.cpp \
bridge/jni/v8/JavaClassV8.cpp \
- bridge/jni/v8/JavaInstanceV8.cpp
+ bridge/jni/v8/JavaInstanceV8.cpp \
+ bridge/jni/v8/JavaNPObjectV8.cpp
#include "Bridge.h"
#include "JNIUtility.h"
-// ANDROID
-// Upstream the V8 ifdef to webkit.org
#if USE(JSC)
#include "JavaStringJSC.h"
#elif USE(V8)
size_t numMethods = methodList.size();
// Try to find a good match for the overloaded method. The
- // fundamental problem is that JavaScript doesn have 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 does some
// type checking as we as checking the number of parameters.
#ifndef JNIBridgeV8_h
#define JNIBridgeV8_h
-#include "JNIBridge.h"
-#include "JNIUtility.h"
-#include "JavaInstanceV8.h"
+#include "JNIBridge.h" // For JavaString
+#include "JavaInstanceV8.h" // For JObjectWrapper
namespace JSC {
namespace Bindings {
-class JavaField
-{
+class JavaField {
public:
JavaField(JNIEnv*, jobject aField);
/*
- * Copyright 2009, The Android Open Source Project
+ * 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
#include "config.h"
#include "JNIUtilityPrivate.h"
-#include "JNIBridge.h"
#include "JavaInstanceV8.h"
#include "JavaNPObjectV8.h"
STRINGZ_TO_NPVARIANT(s, *result);
} else
OBJECT_TO_NPVARIANT(JavaInstanceToNPObject(new JavaInstance(value.l)), *result);
- }
- else
+ } else
VOID_TO_NPVARIANT(*result);
}
break;
}
}
-} // end of namespace Bindings
+} // end of namespace Bindings
} // end of namespace JSC
/*
- * Copyright 2009, The Android Open Source Project
+ * 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
/*
- * Copyright (C) 2010 Apple Computer, Inc. All rights reserved.
* Copyright 2010, The Android Open Source Project
*
* Redistribution and use in source and binary forms, with or without
#include "config.h"
#include "JavaClassV8.h"
-#include "JNIBridge.h"
-#include "JNIUtility.h"
using namespace JSC::Bindings;
return;
}
- jstring className = (jstring)callJNIMethod<jobject>(aClass, "getName", "()Ljava/lang/String;");
+ jstring className = static_cast<jstring>(callJNIMethod<jobject>(aClass, "getName", "()Ljava/lang/String;"));
const char* classNameC = getCharactersFromJString(className);
m_name = strdup(classNameC);
releaseCharactersForJString(className, classNameC);
JNIEnv* env = getJNIEnv();
// Get the fields
- jarray fields = (jarray)callJNIMethod<jobject>(aClass, "getFields", "()[Ljava/lang/reflect/Field;");
+ jarray fields = static_cast<jarray>(callJNIMethod<jobject>(aClass, "getFields", "()[Ljava/lang/reflect/Field;"));
int numFields = env->GetArrayLength(fields);
for (i = 0; i < numFields; i++) {
- jobject aJField = env->GetObjectArrayElement((jobjectArray)fields, i);
+ jobject aJField = env->GetObjectArrayElement(static_cast<jobjectArray>(fields), i);
JavaField* aField = new JavaField(env, aJField); // deleted in the JavaClass destructor
{
m_fields.set(aField->name().UTF8String(), aField);
}
// Get the methods
- jarray methods = (jarray)callJNIMethod<jobject>(aClass, "getMethods", "()[Ljava/lang/reflect/Method;");
+ jarray methods = static_cast<jarray>(callJNIMethod<jobject>(aClass, "getMethods", "()[Ljava/lang/reflect/Method;"));
int numMethods = env->GetArrayLength(methods);
for (i = 0; i < numMethods; i++) {
- jobject aJMethod = env->GetObjectArrayElement((jobjectArray)methods, i);
+ jobject aJMethod = env->GetObjectArrayElement(static_cast<jobjectArray>(methods), i);
JavaMethod* aMethod = new JavaMethod(env, aJMethod); // deleted in the JavaClass destructor
MethodList* methodList;
{
JavaClass::~JavaClass()
{
- free((void*)m_name);
+ free(const_cast<char*>(m_name));
deleteAllValues(m_fields);
m_fields.clear();
/*
- * Copyright (C) 2010 Apple Computer, Inc. All rights reserved.
* Copyright 2010, The Android Open Source Project
*
* Redistribution and use in source and binary forms, with or without
/*
+ * Copyright (C) 2003, 2008, 2010 Apple Inc. All rights reserved.
* 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
+ * * 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
+ * * 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
+ * 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 APPLE COMPUTER, INC. OR
+ * 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
#include "JavaInstanceV8.h"
#include "JNIBridge.h"
-#include "JNIUtility.h"
+#include "JNIUtilityPrivate.h"
#include "JavaClassV8.h"
#include <assert.h>
JavaClass* JavaInstance::getClass() const
{
- if (!m_class) {
+ if (!m_class)
m_class = new JavaClass(javaInstance());
- }
return m_class;
}
size_t numMethods = methodList.size();
// Try to find a good match for the overloaded method. The
- // fundamental problem is that JavaScript doesn have 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 does some
// type checking as we as checking the number of parameters.
jvalue* jArgs = 0;
if (count > 0)
- jArgs = (jvalue*)malloc (count * sizeof(jvalue));
+ jArgs = static_cast<jvalue*>(malloc(count * sizeof(jvalue)));
for (int i = 0; i < count; i++) {
JavaParameter* aParameter = jMethod->parameterAt(i);
LOGV("new global ref %p for %p\n", m_instance, instance);
if (!m_instance)
- fprintf (stderr, "%s: could not get GlobalRef for %p\n", __PRETTY_FUNCTION__, instance);
+ fprintf(stderr, "%s: could not get GlobalRef for %p\n", __PRETTY_FUNCTION__, instance);
}
-JObjectWrapper::~JObjectWrapper() {
+JObjectWrapper::~JObjectWrapper()
+{
LOGV("deleting global ref %p\n", m_instance);
m_env->DeleteGlobalRef(m_instance);
}
/*
+ * Copyright (C) 2003, 2008, 2010 Apple Inc. All rights reserved.
* 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
+ * * 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
+ * * 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
+ * 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 APPLE COMPUTER, INC. OR
+ * 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
#ifndef JavaInstanceV8_h
#define JavaInstanceV8_h
-#include "JNIUtilityPrivate.h"
+#include "npruntime.h"
#include <JavaVM/jni.h>
#include <wtf/RefCounted.h>
void setInstance(jobject instance) { m_instance = instance; }
protected:
- JObjectWrapper(jobject instance);
+ JObjectWrapper(jobject);
~JObjectWrapper();
void ref() { m_refCount++; }
/*
- * Copyright 2009, The Android Open Source Project
+ * 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
* 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 APPLE COMPUTER, INC. OR
+ * 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
#include "config.h"
#include "JavaNPObjectV8.h"
-#include "JNIUtility.h"
+#include "JNIUtilityPrivate.h"
#include "JavaClassV8.h"
#include "JavaInstanceV8.h"
#include "npruntime_impl.h"
static void FreeJavaNPObject(NPObject* npobj)
{
JavaNPObject* obj = reinterpret_cast<JavaNPObject*>(npobj);
- obj->m_instance = 0; // free does not call the destructor
+ obj->m_instance = 0; // free does not call the destructor
free(obj);
}
static NPClass JavaNPObjectClass = {
NP_CLASS_STRUCT_VERSION,
- AllocJavaNPObject, // allocate,
- FreeJavaNPObject, // free,
- 0, // invalidate
- JavaNPObject_HasMethod,
- JavaNPObject_Invoke,
- 0, // invokeDefault,
- JavaNPObject_HasProperty,
- JavaNPObject_GetProperty,
- 0, // setProperty
- 0, // removeProperty
- 0, // enumerate
- 0 // construct
+ AllocJavaNPObject, // allocate,
+ FreeJavaNPObject, // free,
+ 0, // invalidate
+ JavaNPObjectHasMethod,
+ JavaNPObjectInvoke,
+ 0, // invokeDefault,
+ JavaNPObjectHasProperty,
+ JavaNPObjectGetProperty,
+ 0, // setProperty
+ 0, // removeProperty
+ 0, // enumerate
+ 0 // construct
};
-
-NPObject* JavaInstanceToNPObject(JavaInstance* instance) {
+NPObject* JavaInstanceToNPObject(JavaInstance* instance)
+{
JavaNPObject* object = reinterpret_cast<JavaNPObject*>(_NPN_CreateObject(0, &JavaNPObjectClass));
object->m_instance = instance;
return reinterpret_cast<NPObject*>(object);
}
-
// Returns null if obj is not a wrapper of JavaInstance
-JavaInstance* ExtractJavaInstance(NPObject* obj) {
- if (obj->_class == &JavaNPObjectClass) {
+JavaInstance* ExtractJavaInstance(NPObject* obj)
+{
+ if (obj->_class == &JavaNPObjectClass)
return reinterpret_cast<JavaNPObject*>(obj)->m_instance.get();
- }
return 0;
}
-bool JavaNPObject_HasMethod(NPObject* obj, NPIdentifier identifier) {
+bool JavaNPObjectHasMethod(NPObject* obj, NPIdentifier identifier)
+{
JavaInstance* instance = ExtractJavaInstance(obj);
if (!instance)
return false;
return result;
}
-bool JavaNPObject_Invoke(NPObject* obj, NPIdentifier identifier, const NPVariant* args, uint32_t argCount, NPVariant* result) {
+bool JavaNPObjectInvoke(NPObject* obj, NPIdentifier identifier, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
JavaInstance* instance = ExtractJavaInstance(obj);
if (!instance)
return false;
return r;
}
-bool JavaNPObject_HasProperty(NPObject* obj, NPIdentifier identifier) {
+bool JavaNPObjectHasProperty(NPObject* obj, NPIdentifier identifier)
+{
JavaInstance* instance = ExtractJavaInstance(obj);
if (!instance)
return false;
return result;
}
-bool JavaNPObject_GetProperty(NPObject* obj, NPIdentifier identifier, NPVariant* result) {
+bool JavaNPObjectGetProperty(NPObject* obj, NPIdentifier identifier, NPVariant* result)
+{
VOID_TO_NPVARIANT(*result);
JavaInstance* instance = ExtractJavaInstance(obj);
if (!instance)
instance->begin();
JavaField* field = instance->getClass()->fieldNamed(name);
instance->end();
- free(name); // TODO: use NPN_MemFree
+ free(name); // TODO: use NPN_MemFree
if (!field)
return false;
return true;
}
-} // namespace Bindings
+} // namespace Bindings
-} // namespace JSC
+} // namespace JSC
* 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 APPLE COMPUTER, INC. OR
+ * 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
#ifndef JavaNPObjectV8_h
#define JavaNPObjectV8_h
-#include "JNIBridge.h"
#include "npruntime.h"
-#include <JavaVM/jni.h>
#include <wtf/RefPtr.h>
NPObject* JavaInstanceToNPObject(JavaInstance*);
JavaInstance* ExtractJavaInstance(NPObject*);
-bool JavaNPObject_HasMethod(NPObject*, NPIdentifier name);
-bool JavaNPObject_Invoke(NPObject*, NPIdentifier methodName, const NPVariant* args, uint32_t argCount, NPVariant* result);
-bool JavaNPObject_HasProperty(NPObject*, NPIdentifier name);
-bool JavaNPObject_GetProperty(NPObject*, NPIdentifier name, NPVariant* result);
+bool JavaNPObjectHasMethod(NPObject*, NPIdentifier name);
+bool JavaNPObjectInvoke(NPObject*, NPIdentifier methodName, const NPVariant* args, uint32_t argCount, NPVariant* result);
+bool JavaNPObjectHasProperty(NPObject*, NPIdentifier name);
+bool JavaNPObjectGetProperty(NPObject*, NPIdentifier name, NPVariant* result);
} // namespace Bindings
/*
- * Copyright (C) 2010 Apple Computer, Inc. All rights reserved.
+ * 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
{
int size = e->GetStringLength(s);
const char* cs = getCharactersFromJStringInEnv(e, s);
- {
- m_utf8String = WebCore::CString(cs, size);
- }
+ m_utf8String = WebCore::CString(cs, size);
releaseCharactersForJStringInEnv(e, s, cs);
}