mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-09 00:11:44 +00:00
added WrapJavaObject, which wraps a JNI global reference in a JSObject.
This commit is contained in:
parent
8261c5f152
commit
7b6c84617b
@ -24,7 +24,12 @@
|
||||
#ifndef nsILiveConnectManager_h___
|
||||
#define nsILiveConnectManager_h___
|
||||
|
||||
#ifndef nsISupports_h___
|
||||
#include "nsISupports.h"
|
||||
#endif
|
||||
#ifndef JNI_H
|
||||
#include "jni.h"
|
||||
#endif
|
||||
|
||||
// {d20c8081-cbcb-11d2-a5a0-e884aed9c9fc}
|
||||
#define NS_ILIVECONNECTMANAGER_IID \
|
||||
@ -65,6 +70,12 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
InitLiveConnectClasses(JSContext* context, JSObject* globalObject) = 0;
|
||||
|
||||
/**
|
||||
* Creates a JavaScript wrapper for a Java object.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
WrapJavaObject(JSContext* context, jobject javaObject, JSObject* *outJSObject) = 0;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -268,6 +268,22 @@ nsJVMManager::InitLiveConnectClasses(JSContext* context, JSObject* globalObject)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_METHOD
|
||||
nsJVMManager::WrapJavaObject(JSContext* context, jobject javaObject, JSObject* *outJSObject)
|
||||
{
|
||||
if (NULL == outJSObject) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
jsval val;
|
||||
if (JSJ_ConvertJavaObjectToJSValue(context, javaObject, &val)) {
|
||||
*outJSObject = JSVAL_TO_OBJECT(val);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_METHOD
|
||||
nsJVMManager::GetClasspathAdditions(const char* *result)
|
||||
{
|
||||
|
@ -158,6 +158,12 @@ public:
|
||||
NS_IMETHOD
|
||||
InitLiveConnectClasses(JSContext* context, JSObject* globalObject);
|
||||
|
||||
/**
|
||||
* Creates a JavaScript wrapper for a Java object.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
WrapJavaObject(JSContext* context, jobject javaObject, JSObject* *outJSObject);
|
||||
|
||||
/* JVMMgr specific methods: */
|
||||
|
||||
/* ====> From here on are things only called by the browser, not the plugin... */
|
||||
|
Loading…
x
Reference in New Issue
Block a user