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.

git-svn-id: svn://10.0.0.236/trunk@163084 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pedemont%us.ibm.com
2004-10-01 16:19:03 +00:00
parent 2391b0b289
commit 0824d4c802
4 changed files with 149 additions and 99 deletions

View File

@@ -39,36 +39,10 @@ package org.mozilla.xpcom;
public final class GeckoEmbed {
// XPCOM Utility functions
public static native void NS_InitEmbedding(nsILocalFile aMozBinDirectory, nsISupports aAppFileLocProvider);
public static native void NS_TermEmbedding();
public static native nsILocalFile NS_NewLocalFile(String aPath, boolean followLinks);
public static native nsIComponentManager NS_GetComponentManager();
public static native nsIServiceManager NS_GetServiceManager();
public static native nsISimpleEnumerator NS_NewSingletonEnumerator(nsISupports aSingleton);
// Calling functions used by Java stub classes
public static native void CallXPCOMMethodVoid(Object thisObj, int fnNumber, Object[] params);
public static native boolean CallXPCOMMethodBool(Object thisObj, int fnNumber, Object[] params);
public static native boolean[] CallXPCOMMethodBoolA(Object thisObj, int fnNumber, Object[] params);
public static native byte CallXPCOMMethodByte(Object thisObj, int fnNumber, Object[] params);
public static native byte[] CallXPCOMMethodByteA(Object thisObj, int fnNumber, Object[] params);
public static native char CallXPCOMMethodChar(Object thisObj, int fnNumber, Object[] params);
public static native char[] CallXPCOMMethodCharA(Object thisObj, int fnNumber, Object[] params);
public static native short CallXPCOMMethodShort(Object thisObj, int fnNumber, Object[] params);
public static native short[] CallXPCOMMethodShortA(Object thisObj, int fnNumber, Object[] params);
public static native int CallXPCOMMethodInt(Object thisObj, int fnNumber, Object[] params);
public static native int[] CallXPCOMMethodIntA(Object thisObj, int fnNumber, Object[] params);
public static native long CallXPCOMMethodLong(Object thisObj, int fnNumber, Object[] params);
public static native long[] CallXPCOMMethodLongA(Object thisObj, int fnNumber, Object[] params);
public static native float CallXPCOMMethodFloat(Object thisObj, int fnNumber, Object[] params);
public static native float[] CallXPCOMMethodFloatA(Object thisObj, int fnNumber, Object[] params);
public static native double CallXPCOMMethodDouble(Object thisObj, int fnNumber, Object[] params);
public static native double[] CallXPCOMMethodDoubleA(Object thisObj, int fnNumber, Object[] params);
public static native Object CallXPCOMMethodObj(Object thisObj, int fnNumber, Object[] params);
public static native Object[] CallXPCOMMethodObjA(Object thisObj, int fnNumber, Object[] params);
public static native void FinalizeStub(Object thisObj);
public static native int nsWriteSegmentFun(int ptr, Object aInStream, int aClosure, byte[] aFromSegment, int aToOffset, int aCount);
}

View File

@@ -43,8 +43,8 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
MODULE = javaembed
LIBRARY_NAME = javaembed
MODULE = javaxpcom
LIBRARY_NAME = javaxpcom
EMBED_JAR = mozembed.jar
EMBED_JAR_SRC = $(patsubst %.jar,%-src.jar,$(EMBED_JAR))
@@ -62,12 +62,18 @@ CPPSRCS = \
nsJavaXPCOMBindingUtils.cpp \
$(NULL)
JAVA_LOC = /opt/IBMJava2-141
# Can't use JAVA_SRCS for now, since that one is referenced in config.mk
JAVA_SRCS_ = \
XPCOM.java \
GeckoEmbed.java \
$(NULL)
LOCAL_INCLUDES = \
-I$(JAVA_LOC)/include \
-I$(JAVA_HOME)/include \
$(NULL)
LOCAL_INCLUDES += -I$(JAVA_HOME)/include/linux
EXTRA_DSO_LIBS = \
embed_base_s \
$(NULL)
@@ -130,12 +136,12 @@ $(XPIDL_GEN_DIR)/org/mozilla/xpcom/stubs/.java_done: $(XPIDL_COMPILE) $(XPIDL_GE
#$(XPIDL_GEN_DIR)/org/mozilla/xpcom/%.java: $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
# $(ELOG) $(XPIDL_COMPILE) -m java -w -I$(srcdir) -I$(IDL_DIR) -o $(XPIDL_GEN_DIR)/org/mozilla/xpcom/$* $(_VPATH_SRCS)
$(XPIDL_GEN_DIR)/org/mozilla/xpcom/.java_done: $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/org/mozilla/xpcom/.done GeckoEmbed.java
$(XPIDL_GEN_DIR)/org/mozilla/xpcom/.java_done: $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/org/mozilla/xpcom/.done $(JAVA_SRCS_)
@echo Making Java interface files
@for idl in $(IDL_FILES); do \
$(XPIDL_COMPILE) -m java -w -I$(srcdir) -I$(IDL_DIR) -o $(XPIDL_GEN_DIR)/org/mozilla/xpcom/`basename $$idl` $$idl; \
done
@$(INSTALL) -m 644 $(srcdir)/GeckoEmbed.java $(XPIDL_GEN_DIR)/org/mozilla/xpcom
@$(INSTALL) -m 644 $(addprefix $(srcdir)/,$(JAVA_SRCS_)) $(XPIDL_GEN_DIR)/org/mozilla/xpcom
@touch $@
#org/mozilla/xpcom/stubs/%.class: $(XPIDL_GEN_DIR)/org/mozilla/xpcom/stubs/.java_done org/mozilla/xpcom/stubs/.done

View File

@@ -0,0 +1,69 @@
/* ***** 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 ***** */
package org.mozilla.xpcom;
import java.lang.reflect.*;
public final class XPCOM {
// Calling functions used by Java stub classes
public static native void CallXPCOMMethodVoid(Object thisObj, int fnNumber, Object[] params);
public static native boolean CallXPCOMMethodBool(Object thisObj, int fnNumber, Object[] params);
public static native boolean[] CallXPCOMMethodBoolA(Object thisObj, int fnNumber, Object[] params);
public static native byte CallXPCOMMethodByte(Object thisObj, int fnNumber, Object[] params);
public static native byte[] CallXPCOMMethodByteA(Object thisObj, int fnNumber, Object[] params);
public static native char CallXPCOMMethodChar(Object thisObj, int fnNumber, Object[] params);
public static native char[] CallXPCOMMethodCharA(Object thisObj, int fnNumber, Object[] params);
public static native short CallXPCOMMethodShort(Object thisObj, int fnNumber, Object[] params);
public static native short[] CallXPCOMMethodShortA(Object thisObj, int fnNumber, Object[] params);
public static native int CallXPCOMMethodInt(Object thisObj, int fnNumber, Object[] params);
public static native int[] CallXPCOMMethodIntA(Object thisObj, int fnNumber, Object[] params);
public static native long CallXPCOMMethodLong(Object thisObj, int fnNumber, Object[] params);
public static native long[] CallXPCOMMethodLongA(Object thisObj, int fnNumber, Object[] params);
public static native float CallXPCOMMethodFloat(Object thisObj, int fnNumber, Object[] params);
public static native float[] CallXPCOMMethodFloatA(Object thisObj, int fnNumber, Object[] params);
public static native double CallXPCOMMethodDouble(Object thisObj, int fnNumber, Object[] params);
public static native double[] CallXPCOMMethodDoubleA(Object thisObj, int fnNumber, Object[] params);
public static native Object CallXPCOMMethodObj(Object thisObj, int fnNumber, Object[] params);
public static native Object[] CallXPCOMMethodObjA(Object thisObj, int fnNumber, Object[] params);
public static native void FinalizeStub(Object thisObj);
public static native int nsWriteSegmentFun(int ptr, Object aInStream, int aClosure, byte[] aFromSegment, int aToOffset, int aCount);
}

View File

@@ -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<nsIComponentManager> 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<nsIServiceManager> 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<nsIComponentManager> 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<nsIServiceManager> 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,