From 0a08313724238fcc7e839ac28240982f12d1d8af Mon Sep 17 00:00:00 2001 From: "pedemont%us.ibm.com" Date: Wed, 27 Sep 2006 15:09:39 +0000 Subject: [PATCH] Split GeckoEmbed.java into two files, so GeckoEmbed just contains embedding functions. Better name for library. Use JAVA_HOME for location of Java includes. Not part of default build. Original committer: pedemont%us.ibm.com Original revision: 1.5 Original date: 2004/10/01 16:19:03 --- .../java/xpcom/src/nsJavaInterfaces.cpp | 135 +++++++++--------- 1 file changed, 68 insertions(+), 67 deletions(-) diff --git a/extensions/java/xpcom/src/nsJavaInterfaces.cpp b/extensions/java/xpcom/src/nsJavaInterfaces.cpp index 0012cdc2b584..0574f91b8b37 100644 --- a/extensions/java/xpcom/src/nsJavaInterfaces.cpp +++ b/extensions/java/xpcom/src/nsJavaInterfaces.cpp @@ -45,13 +45,14 @@ #include "nsIInputStream.h" #include "nsEnumeratorUtils.h" -#define XPCOM_NATIVE(func) Java_org_mozilla_xpcom_GeckoEmbed_##func +#define GECKO_NATIVE(func) Java_org_mozilla_xpcom_GeckoEmbed_##func +#define XPCOM_NATIVE(func) Java_org_mozilla_xpcom_XPCOM_##func PRBool gEmbeddingInitialized = PR_FALSE; extern "C" JNIEXPORT void JNICALL -XPCOM_NATIVE(NS_1InitEmbedding) (JNIEnv* env, jclass, jobject aMozBinDirectory, +GECKO_NATIVE(NS_1InitEmbedding) (JNIEnv* env, jclass, jobject aMozBinDirectory, jobject aAppFileLocProvider) { if (!InitializeJavaGlobals(env)) { @@ -94,7 +95,7 @@ XPCOM_NATIVE(NS_1InitEmbedding) (JNIEnv* env, jclass, jobject aMozBinDirectory, } extern "C" JNIEXPORT void JNICALL -XPCOM_NATIVE(NS_1TermEmbedding) (JNIEnv *env, jclass) +GECKO_NATIVE(NS_1TermEmbedding) (JNIEnv *env, jclass) { FreeJavaGlobals(env); @@ -111,7 +112,7 @@ XPCOM_NATIVE(NS_1TermEmbedding) (JNIEnv *env, jclass) * NULL and just create it lazily. */ extern "C" JNIEXPORT jobject JNICALL -XPCOM_NATIVE(NS_1NewLocalFile) (JNIEnv *env, jclass, jstring aPath, +GECKO_NATIVE(NS_1NewLocalFile) (JNIEnv *env, jclass, jstring aPath, jboolean aFollowLinks) { if (!InitializeJavaGlobals(env)) { @@ -161,7 +162,69 @@ XPCOM_NATIVE(NS_1NewLocalFile) (JNIEnv *env, jclass, jstring aPath, } extern "C" JNIEXPORT jobject JNICALL -XPCOM_NATIVE(NS_1NewSingletonEnumerator) (JNIEnv *env, jclass, jobject aSingleton) +GECKO_NATIVE(NS_1GetComponentManager) (JNIEnv *env, jclass) +{ + jobject java_stub = nsnull; + + // Call XPCOM method + nsCOMPtr cm; + nsresult rv = NS_GetComponentManager(getter_AddRefs(cm)); + + if (NS_SUCCEEDED(rv)) { + // wrap xpcom instance + JavaXPCOMInstance* inst; + inst = CreateJavaXPCOMInstance(cm, &NS_GET_IID(nsIComponentManager)); + + if (inst) { + // create java stub + java_stub = CreateJavaWrapper(env, "nsIComponentManager"); + + if (java_stub) { + // Associate XPCOM object w/ Java stub + AddJavaXPCOMBinding(env, java_stub, inst); + } + } + } + + if (java_stub == nsnull) + ThrowXPCOMException(env, 0); + + return java_stub; +} + +extern "C" JNIEXPORT jobject JNICALL +GECKO_NATIVE(NS_1GetServiceManager) (JNIEnv *env, jclass) +{ + jobject java_stub = nsnull; + + // Call XPCOM method + nsCOMPtr sm; + nsresult rv = NS_GetServiceManager(getter_AddRefs(sm)); + + if (NS_SUCCEEDED(rv)) { + // wrap xpcom instance + JavaXPCOMInstance* inst; + inst = CreateJavaXPCOMInstance(sm, &NS_GET_IID(nsIServiceManager)); + + if (inst) { + // create java stub + java_stub = CreateJavaWrapper(env, "nsIServiceManager"); + + if (java_stub) { + // Associate XPCOM object w/ Java stub + AddJavaXPCOMBinding(env, java_stub, inst); + } + } + } + + if (java_stub == nsnull) + ThrowXPCOMException(env, 0); + + return java_stub; +} + +extern "C" JNIEXPORT jobject JNICALL +GECKO_NATIVE(NS_1NewSingletonEnumerator) (JNIEnv *env, jclass, jobject aSingleton) { void* inst = GetMatchingXPCOMObject(env, aSingleton); if (inst == nsnull) { @@ -218,68 +281,6 @@ XPCOM_NATIVE(NS_1NewSingletonEnumerator) (JNIEnv *env, jclass, jobject aSingleto return java_stub; } -extern "C" JNIEXPORT jobject JNICALL -XPCOM_NATIVE(NS_1GetComponentManager) (JNIEnv *env, jclass) -{ - jobject java_stub = nsnull; - - // Call XPCOM method - nsCOMPtr cm; - nsresult rv = NS_GetComponentManager(getter_AddRefs(cm)); - - if (NS_SUCCEEDED(rv)) { - // wrap xpcom instance - JavaXPCOMInstance* inst; - inst = CreateJavaXPCOMInstance(cm, &NS_GET_IID(nsIComponentManager)); - - if (inst) { - // create java stub - java_stub = CreateJavaWrapper(env, "nsIComponentManager"); - - if (java_stub) { - // Associate XPCOM object w/ Java stub - AddJavaXPCOMBinding(env, java_stub, inst); - } - } - } - - if (java_stub == nsnull) - ThrowXPCOMException(env, 0); - - return java_stub; -} - -extern "C" JNIEXPORT jobject JNICALL -XPCOM_NATIVE(NS_1GetServiceManager) (JNIEnv *env, jclass) -{ - jobject java_stub = nsnull; - - // Call XPCOM method - nsCOMPtr sm; - nsresult rv = NS_GetServiceManager(getter_AddRefs(sm)); - - if (NS_SUCCEEDED(rv)) { - // wrap xpcom instance - JavaXPCOMInstance* inst; - inst = CreateJavaXPCOMInstance(sm, &NS_GET_IID(nsIServiceManager)); - - if (inst) { - // create java stub - java_stub = CreateJavaWrapper(env, "nsIServiceManager"); - - if (java_stub) { - // Associate XPCOM object w/ Java stub - AddJavaXPCOMBinding(env, java_stub, inst); - } - } - } - - if (java_stub == nsnull) - ThrowXPCOMException(env, 0); - - return java_stub; -} - // JNI wrapper for calling an nsWriteSegmentFun function extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(nsWriteSegmentFun) (JNIEnv *env, jclass that, jint aWriterFunc,