2004-09-02 16:34:11 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Java XPCOM Bindings.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* IBM Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2004
|
|
|
|
* IBM Corporation. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Javier Pedemonte (jhpedemonte@gmail.com)
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "nsJavaWrapper.h"
|
|
|
|
#include "nsJavaXPCOMBindingUtils.h"
|
|
|
|
#include "nsJavaXPTCStub.h"
|
|
|
|
#include "nsEmbedAPI.h"
|
2004-12-17 22:25:12 +00:00
|
|
|
#include "nsIComponentRegistrar.h"
|
2004-09-02 16:34:11 +00:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsISimpleEnumerator.h"
|
|
|
|
#include "nsIInterfaceInfoManager.h"
|
|
|
|
#include "nsIInputStream.h"
|
|
|
|
#include "nsEnumeratorUtils.h"
|
2004-10-01 22:59:12 +00:00
|
|
|
#include "nsArray.h"
|
2004-12-17 22:25:12 +00:00
|
|
|
#include "nsAppFileLocProviderProxy.h"
|
2004-09-02 16:34:11 +00:00
|
|
|
|
2004-10-01 16:19:03 +00:00
|
|
|
#define GECKO_NATIVE(func) Java_org_mozilla_xpcom_GeckoEmbed_##func
|
|
|
|
#define XPCOM_NATIVE(func) Java_org_mozilla_xpcom_XPCOM_##func
|
2004-12-17 23:52:42 +00:00
|
|
|
#define XPCOMPRIVATE_NATIVE(func) Java_org_mozilla_xpcom_XPCOMPrivate_##func
|
2004-09-02 16:34:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2004-10-15 21:50:15 +00:00
|
|
|
GECKO_NATIVE(initEmbedding) (JNIEnv* env, jclass, jobject aMozBinDirectory,
|
|
|
|
jobject aAppFileLocProvider)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
2004-12-17 22:25:12 +00:00
|
|
|
nsresult rv = NS_OK;
|
2005-01-12 17:59:01 +00:00
|
|
|
if (!InitializeJavaGlobals(env)) {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
} else {
|
2004-12-17 22:25:12 +00:00
|
|
|
// Create an nsILocalFile from given java.io.File
|
|
|
|
nsCOMPtr<nsILocalFile> directory;
|
|
|
|
if (aMozBinDirectory) {
|
|
|
|
rv = File_to_nsILocalFile(env, aMozBinDirectory, getter_AddRefs(directory));
|
2004-09-02 16:34:11 +00:00
|
|
|
}
|
2004-09-15 21:06:30 +00:00
|
|
|
|
2004-12-17 22:25:12 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsAppFileLocProviderProxy* provider = nsnull;
|
|
|
|
if (aAppFileLocProvider) {
|
|
|
|
provider = new nsAppFileLocProviderProxy(env, aAppFileLocProvider);
|
2005-01-12 17:59:01 +00:00
|
|
|
if (!provider)
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
2004-12-17 22:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2005-01-12 17:59:01 +00:00
|
|
|
rv = NS_InitEmbedding(directory, provider);
|
|
|
|
if (provider) {
|
|
|
|
delete provider;
|
|
|
|
}
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
return;
|
|
|
|
}
|
2004-12-17 22:25:12 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-02 16:34:11 +00:00
|
|
|
}
|
|
|
|
|
2005-01-12 17:59:01 +00:00
|
|
|
ThrowException(env, rv, "Failure in initEmbedding");
|
2004-12-21 23:35:02 +00:00
|
|
|
FreeJavaGlobals(env);
|
2004-12-17 22:25:12 +00:00
|
|
|
}
|
2004-09-02 16:34:11 +00:00
|
|
|
|
2004-12-17 22:25:12 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
|
|
|
GECKO_NATIVE(termEmbedding) (JNIEnv *env, jclass)
|
|
|
|
{
|
2004-12-23 17:09:54 +00:00
|
|
|
nsresult rv = NS_TermEmbedding();
|
2004-09-02 16:34:11 +00:00
|
|
|
if (NS_FAILED(rv))
|
2005-01-12 17:59:01 +00:00
|
|
|
ThrowException(env, rv, "NS_TermEmbedding failed");
|
2004-09-02 16:34:11 +00:00
|
|
|
|
2004-12-17 22:25:12 +00:00
|
|
|
FreeJavaGlobals(env);
|
2004-09-02 16:34:11 +00:00
|
|
|
}
|
|
|
|
|
2004-12-17 22:25:12 +00:00
|
|
|
extern "C" JNIEXPORT jobject JNICALL
|
|
|
|
XPCOM_NATIVE(initXPCOM) (JNIEnv* env, jclass, jobject aMozBinDirectory,
|
|
|
|
jobject aAppFileLocProvider)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
2004-12-17 22:25:12 +00:00
|
|
|
nsresult rv = NS_OK;
|
2005-01-12 17:59:01 +00:00
|
|
|
if (!InitializeJavaGlobals(env)) {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
} else {
|
2004-12-17 22:25:12 +00:00
|
|
|
// Create an nsILocalFile from given java.io.File
|
|
|
|
nsCOMPtr<nsILocalFile> directory;
|
|
|
|
if (aMozBinDirectory) {
|
|
|
|
rv = File_to_nsILocalFile(env, aMozBinDirectory, getter_AddRefs(directory));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsAppFileLocProviderProxy* provider = nsnull;
|
|
|
|
if (aAppFileLocProvider) {
|
|
|
|
provider = new nsAppFileLocProviderProxy(env, aAppFileLocProvider);
|
2005-01-12 17:59:01 +00:00
|
|
|
if (!provider)
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
2004-12-17 22:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2005-01-12 17:59:01 +00:00
|
|
|
nsIServiceManager* servMan = nsnull;
|
|
|
|
rv = NS_InitXPCOM2(&servMan, directory, provider);
|
|
|
|
if (provider) {
|
|
|
|
delete provider;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// wrap xpcom instance
|
|
|
|
JavaXPCOMInstance* inst;
|
|
|
|
rv = CreateJavaXPCOMInstance(servMan, &NS_GET_IID(nsIServiceManager),
|
|
|
|
&inst);
|
|
|
|
NS_RELEASE(servMan); // JavaXPCOMInstance has owning ref
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// create java stub
|
2005-01-14 00:09:49 +00:00
|
|
|
jobject java_stub = CreateJavaWrapper(env, "nsIServiceManager");
|
2005-01-12 17:59:01 +00:00
|
|
|
|
|
|
|
if (java_stub) {
|
|
|
|
// Associate XPCOM object w/ Java stub
|
2005-01-14 00:09:49 +00:00
|
|
|
rv = gBindings->AddBinding(env, java_stub, inst);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
return java_stub;
|
2005-01-12 17:59:01 +00:00
|
|
|
}
|
2004-12-17 22:25:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-12 17:59:01 +00:00
|
|
|
ThrowException(env, rv, "Failure in initXPCOM");
|
2004-12-21 23:35:02 +00:00
|
|
|
FreeJavaGlobals(env);
|
2004-12-17 22:25:12 +00:00
|
|
|
return nsnull;
|
|
|
|
}
|
2004-09-02 16:34:11 +00:00
|
|
|
|
2004-12-17 22:25:12 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
|
|
|
XPCOM_NATIVE(shutdownXPCOM) (JNIEnv *env, jclass, jobject aServMgr)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIServiceManager> servMgr;
|
|
|
|
if (aServMgr) {
|
|
|
|
// Find corresponding XPCOM object
|
2005-01-14 00:09:49 +00:00
|
|
|
void* xpcomObj = gBindings->GetXPCOMObject(env, aServMgr);
|
|
|
|
NS_ASSERTION(xpcomObj != nsnull, "Failed to get XPCOM obj for ServiceMgr.");
|
2004-12-17 22:25:12 +00:00
|
|
|
|
2005-01-12 17:59:01 +00:00
|
|
|
// Even if we failed to get the matching xpcom object, we don't abort this
|
|
|
|
// function. Just call NS_ShutdownXPCOM with a null service manager.
|
|
|
|
|
|
|
|
if (xpcomObj) {
|
|
|
|
NS_ASSERTION(!IsXPTCStub(xpcomObj),
|
|
|
|
"Expected JavaXPCOMInstance, but got nsJavaXPTCStub");
|
|
|
|
servMgr = do_QueryInterface(((JavaXPCOMInstance*) xpcomObj)->GetInstance());
|
|
|
|
}
|
2004-12-17 22:25:12 +00:00
|
|
|
}
|
|
|
|
|
2004-12-23 17:09:54 +00:00
|
|
|
nsresult rv = NS_ShutdownXPCOM(servMgr);
|
2004-09-02 16:34:11 +00:00
|
|
|
if (NS_FAILED(rv))
|
2005-01-12 17:59:01 +00:00
|
|
|
ThrowException(env, rv, "NS_ShutdownXPCOM failed");
|
2004-12-17 22:25:12 +00:00
|
|
|
|
|
|
|
FreeJavaGlobals(env);
|
2004-09-02 16:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jobject JNICALL
|
2004-12-17 22:25:12 +00:00
|
|
|
XPCOM_NATIVE(newLocalFile) (JNIEnv *env, jclass, jstring aPath,
|
2004-10-15 21:50:15 +00:00
|
|
|
jboolean aFollowLinks)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
// Create a Mozilla string from the jstring
|
|
|
|
jboolean isCopy;
|
|
|
|
const PRUnichar* buf = nsnull;
|
|
|
|
if (aPath) {
|
|
|
|
buf = env->GetStringChars(aPath, &isCopy);
|
2005-01-12 17:59:01 +00:00
|
|
|
if (!buf)
|
|
|
|
return nsnull; // exception already thrown
|
2004-09-02 16:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString path_str(buf);
|
|
|
|
if (isCopy) {
|
|
|
|
env->ReleaseStringChars(aPath, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make call to given function
|
2004-10-27 17:10:03 +00:00
|
|
|
nsILocalFile* file = nsnull;
|
|
|
|
nsresult rv = NS_NewLocalFile(path_str, aFollowLinks, &file);
|
2004-09-02 16:34:11 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// wrap xpcom instance
|
|
|
|
JavaXPCOMInstance* inst;
|
2005-01-12 17:59:01 +00:00
|
|
|
rv = CreateJavaXPCOMInstance(file, &NS_GET_IID(nsILocalFile), &inst);
|
2004-10-27 17:10:03 +00:00
|
|
|
NS_RELEASE(file); // JavaXPCOMInstance has owning ref
|
2004-09-02 16:34:11 +00:00
|
|
|
|
2005-01-12 17:59:01 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2004-09-02 16:34:11 +00:00
|
|
|
// create java stub
|
2005-01-14 00:09:49 +00:00
|
|
|
jobject java_stub = CreateJavaWrapper(env, "nsILocalFile");
|
2004-09-02 16:34:11 +00:00
|
|
|
|
|
|
|
if (java_stub) {
|
|
|
|
// Associate XPCOM object w/ Java stub
|
2005-01-14 00:09:49 +00:00
|
|
|
rv = gBindings->AddBinding(env, java_stub, inst);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
return java_stub;
|
2004-09-02 16:34:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-14 00:09:49 +00:00
|
|
|
ThrowException(env, rv, "Failure in newLocalFile");
|
|
|
|
return nsnull;
|
2004-09-02 16:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jobject JNICALL
|
2004-12-17 22:25:12 +00:00
|
|
|
XPCOM_NATIVE(getComponentManager) (JNIEnv *env, jclass)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
// Call XPCOM method
|
2004-10-27 17:10:03 +00:00
|
|
|
nsIComponentManager* cm = nsnull;
|
|
|
|
nsresult rv = NS_GetComponentManager(&cm);
|
2004-09-02 16:34:11 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// wrap xpcom instance
|
|
|
|
JavaXPCOMInstance* inst;
|
2005-01-12 17:59:01 +00:00
|
|
|
rv = CreateJavaXPCOMInstance(cm, &NS_GET_IID(nsIComponentManager), &inst);
|
2004-10-27 17:10:03 +00:00
|
|
|
NS_RELEASE(cm); // JavaXPCOMInstance has owning ref
|
2004-09-02 16:34:11 +00:00
|
|
|
|
2005-01-12 17:59:01 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2004-09-02 16:34:11 +00:00
|
|
|
// create java stub
|
2005-01-14 00:09:49 +00:00
|
|
|
jobject java_stub = CreateJavaWrapper(env, "nsIComponentManager");
|
2004-09-02 16:34:11 +00:00
|
|
|
|
|
|
|
if (java_stub) {
|
|
|
|
// Associate XPCOM object w/ Java stub
|
2005-01-14 00:09:49 +00:00
|
|
|
rv = gBindings->AddBinding(env, java_stub, inst);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
return java_stub;
|
2004-09-02 16:34:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-14 00:09:49 +00:00
|
|
|
ThrowException(env, rv, "Failure in getComponentManager");
|
|
|
|
return nsnull;
|
2004-09-02 16:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jobject JNICALL
|
2004-12-17 22:25:12 +00:00
|
|
|
XPCOM_NATIVE(getComponentRegistrar) (JNIEnv *env, jclass)
|
|
|
|
{
|
|
|
|
// Call XPCOM method
|
|
|
|
nsIComponentRegistrar* cr = nsnull;
|
|
|
|
nsresult rv = NS_GetComponentRegistrar(&cr);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// wrap xpcom instance
|
|
|
|
JavaXPCOMInstance* inst;
|
2005-01-12 17:59:01 +00:00
|
|
|
rv = CreateJavaXPCOMInstance(cr, &NS_GET_IID(nsIComponentRegistrar), &inst);
|
2004-12-17 22:25:12 +00:00
|
|
|
NS_RELEASE(cr); // JavaXPCOMInstance has owning ref
|
|
|
|
|
2005-01-12 17:59:01 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2004-12-17 22:25:12 +00:00
|
|
|
// create java stub
|
2005-01-14 00:09:49 +00:00
|
|
|
jobject java_stub = CreateJavaWrapper(env, "nsIComponentRegistrar");
|
2004-12-17 22:25:12 +00:00
|
|
|
|
|
|
|
if (java_stub) {
|
|
|
|
// Associate XPCOM object w/ Java stub
|
2005-01-14 00:09:49 +00:00
|
|
|
rv = gBindings->AddBinding(env, java_stub, inst);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
return java_stub;
|
2004-12-17 22:25:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-14 00:09:49 +00:00
|
|
|
ThrowException(env, rv, "Failure in getComponentRegistrar");
|
|
|
|
return nsnull;
|
2004-12-17 22:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jobject JNICALL
|
|
|
|
XPCOM_NATIVE(getServiceManager) (JNIEnv *env, jclass)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
// Call XPCOM method
|
2004-10-27 17:10:03 +00:00
|
|
|
nsIServiceManager* sm = nsnull;
|
|
|
|
nsresult rv = NS_GetServiceManager(&sm);
|
2004-09-02 16:34:11 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// wrap xpcom instance
|
|
|
|
JavaXPCOMInstance* inst;
|
2005-01-12 17:59:01 +00:00
|
|
|
rv = CreateJavaXPCOMInstance(sm, &NS_GET_IID(nsIServiceManager), &inst);
|
2004-10-27 17:10:03 +00:00
|
|
|
NS_RELEASE(sm); // JavaXPCOMInstance has owning ref
|
2004-09-02 16:34:11 +00:00
|
|
|
|
2005-01-12 17:59:01 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2004-09-02 16:34:11 +00:00
|
|
|
// create java stub
|
2005-01-14 00:09:49 +00:00
|
|
|
jobject java_stub = CreateJavaWrapper(env, "nsIServiceManager");
|
2004-09-02 16:34:11 +00:00
|
|
|
|
|
|
|
if (java_stub) {
|
|
|
|
// Associate XPCOM object w/ Java stub
|
2005-01-14 00:09:49 +00:00
|
|
|
rv = gBindings->AddBinding(env, java_stub, inst);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
return java_stub;
|
2004-09-02 16:34:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-14 00:09:49 +00:00
|
|
|
ThrowException(env, rv, "Failure in getServiceManager");
|
|
|
|
return nsnull;
|
2004-09-02 16:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodVoid) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jboolean JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodBool) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return rc.z;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jbooleanArray JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodBoolA) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return (jbooleanArray) rc.l;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jbyte JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodByte) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return rc.b;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jbyteArray JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodByteA) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return (jbyteArray) rc.l;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jchar JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodChar) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return rc.c;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jcharArray JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodCharA) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return (jcharArray) rc.l;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jshort JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodShort) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return rc.s;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jshortArray JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodShortA) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return (jshortArray) rc.l;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jint JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodInt) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return rc.i;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jintArray JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodIntA) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return (jintArray) rc.l;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jlong JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodLong) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return rc.j;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jlongArray JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodLongA) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return (jlongArray) rc.l;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jfloat JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodFloat) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return rc.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jfloatArray JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodFloatA) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return (jfloatArray) rc.l;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jdouble JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodDouble) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return rc.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jdoubleArray JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodDoubleA) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return (jdoubleArray) rc.l;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jobject JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodObj) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return rc.l;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jobjectArray JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(CallXPCOMMethodObjA) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject,
|
|
|
|
jint aMethodIndex,
|
|
|
|
jobjectArray aParams)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
|
|
|
jvalue rc;
|
|
|
|
CallXPCOMMethod(env, that, aJavaObject, aMethodIndex, aParams, rc);
|
|
|
|
return (jobjectArray) rc.l;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2005-01-12 17:59:01 +00:00
|
|
|
XPCOMPRIVATE_NATIVE(FinalizeStub) (JNIEnv *env, jclass that,
|
|
|
|
jobject aJavaObject)
|
2004-09-02 16:34:11 +00:00
|
|
|
{
|
2005-01-14 00:09:49 +00:00
|
|
|
#ifdef DEBUG_pedemonte
|
2004-09-02 16:34:11 +00:00
|
|
|
jboolean isCopy;
|
|
|
|
jclass clazz = env->GetObjectClass(aJavaObject);
|
|
|
|
jstring name = (jstring) env->CallObjectMethod(clazz, getNameMID);
|
|
|
|
const char* javaObjectName = env->GetStringUTFChars(name, &isCopy);
|
2004-11-23 17:02:21 +00:00
|
|
|
LOG(("*** Finalize(java_obj=%s)\n", javaObjectName));
|
2004-09-02 16:34:11 +00:00
|
|
|
if (isCopy)
|
|
|
|
env->ReleaseStringUTFChars(name, javaObjectName);
|
|
|
|
#endif
|
2004-09-30 23:34:47 +00:00
|
|
|
|
2005-01-14 00:09:49 +00:00
|
|
|
void* obj = gBindings->GetXPCOMObject(env, aJavaObject);
|
2005-01-12 17:59:01 +00:00
|
|
|
NS_ASSERTION(!IsXPTCStub(obj),
|
|
|
|
"Expecting JavaXPCOMInstance, got nsJavaXPTCStub");
|
2005-01-14 00:09:49 +00:00
|
|
|
gBindings->RemoveBinding(env, aJavaObject, nsnull);
|
2004-10-06 22:13:00 +00:00
|
|
|
delete (JavaXPCOMInstance*) obj;
|
2004-09-02 16:34:11 +00:00
|
|
|
}
|
|
|
|
|