added WrapJavaObject, which wraps a JNI global reference in a JSObject.

This commit is contained in:
beard%netscape.com 1999-03-21 19:53:28 +00:00
parent 8261c5f152
commit 7b6c84617b
3 changed files with 33 additions and 0 deletions

View File

@ -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;
};
////////////////////////////////////////////////////////////////////////////////

View File

@ -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)
{

View File

@ -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... */