Move methods used by Java stubs to their own private class.

git-svn-id: svn://10.0.0.236/trunk@166842 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pedemont%us.ibm.com 2004-12-17 23:52:42 +00:00
parent 8c31f90f5e
commit 7aa642db5f
5 changed files with 140 additions and 70 deletions

View File

@ -64,6 +64,7 @@ CPPSRCS = \
JAVA_SRCS = \
XPCOM.java \
XPCOMPrivate.java \
XPCOMException.java \
GeckoEmbed.java \
AppFileLocProvider.java \

View File

@ -50,29 +50,6 @@ public final class XPCOM {
public static native nsIComponentRegistrar getComponentRegistrar();
public static native nsILocalFile newLocalFile(String aPath, boolean followLinks);
// 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);
/* Utility functions */

View File

@ -0,0 +1,91 @@
/* ***** 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;
/**
* This class contains methods that are used by the JavaXPCOM proxy classes.
* They are for internal JavaXPCOM use only and should not be used by
* developers.
*/
public final class XPCOMPrivate {
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);
}

View File

@ -50,6 +50,7 @@
#define GECKO_NATIVE(func) Java_org_mozilla_xpcom_GeckoEmbed_##func
#define XPCOM_NATIVE(func) Java_org_mozilla_xpcom_XPCOM_##func
#define XPCOMPRIVATE_NATIVE(func) Java_org_mozilla_xpcom_XPCOMPrivate_##func
extern "C" JNIEXPORT void JNICALL
@ -313,7 +314,7 @@ XPCOM_NATIVE(getServiceManager) (JNIEnv *env, jclass)
}
extern "C" JNIEXPORT void JNICALL
XPCOM_NATIVE(CallXPCOMMethodVoid) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodVoid) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -321,7 +322,7 @@ XPCOM_NATIVE(CallXPCOMMethodVoid) (JNIEnv *env, jclass that, jobject aJavaObject
}
extern "C" JNIEXPORT jboolean JNICALL
XPCOM_NATIVE(CallXPCOMMethodBool) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodBool) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -330,7 +331,7 @@ XPCOM_NATIVE(CallXPCOMMethodBool) (JNIEnv *env, jclass that, jobject aJavaObject
}
extern "C" JNIEXPORT jbooleanArray JNICALL
XPCOM_NATIVE(CallXPCOMMethodBoolA) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodBoolA) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -339,7 +340,7 @@ XPCOM_NATIVE(CallXPCOMMethodBoolA) (JNIEnv *env, jclass that, jobject aJavaObjec
}
extern "C" JNIEXPORT jbyte JNICALL
XPCOM_NATIVE(CallXPCOMMethodByte) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodByte) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -348,7 +349,7 @@ XPCOM_NATIVE(CallXPCOMMethodByte) (JNIEnv *env, jclass that, jobject aJavaObject
}
extern "C" JNIEXPORT jbyteArray JNICALL
XPCOM_NATIVE(CallXPCOMMethodByteA) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodByteA) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -357,7 +358,7 @@ XPCOM_NATIVE(CallXPCOMMethodByteA) (JNIEnv *env, jclass that, jobject aJavaObjec
}
extern "C" JNIEXPORT jchar JNICALL
XPCOM_NATIVE(CallXPCOMMethodChar) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodChar) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -366,7 +367,7 @@ XPCOM_NATIVE(CallXPCOMMethodChar) (JNIEnv *env, jclass that, jobject aJavaObject
}
extern "C" JNIEXPORT jcharArray JNICALL
XPCOM_NATIVE(CallXPCOMMethodCharA) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodCharA) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -375,7 +376,7 @@ XPCOM_NATIVE(CallXPCOMMethodCharA) (JNIEnv *env, jclass that, jobject aJavaObjec
}
extern "C" JNIEXPORT jshort JNICALL
XPCOM_NATIVE(CallXPCOMMethodShort) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodShort) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -384,7 +385,7 @@ XPCOM_NATIVE(CallXPCOMMethodShort) (JNIEnv *env, jclass that, jobject aJavaObjec
}
extern "C" JNIEXPORT jshortArray JNICALL
XPCOM_NATIVE(CallXPCOMMethodShortA) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodShortA) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -393,7 +394,7 @@ XPCOM_NATIVE(CallXPCOMMethodShortA) (JNIEnv *env, jclass that, jobject aJavaObje
}
extern "C" JNIEXPORT jint JNICALL
XPCOM_NATIVE(CallXPCOMMethodInt) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodInt) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -402,7 +403,7 @@ XPCOM_NATIVE(CallXPCOMMethodInt) (JNIEnv *env, jclass that, jobject aJavaObject,
}
extern "C" JNIEXPORT jintArray JNICALL
XPCOM_NATIVE(CallXPCOMMethodIntA) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodIntA) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -411,7 +412,7 @@ XPCOM_NATIVE(CallXPCOMMethodIntA) (JNIEnv *env, jclass that, jobject aJavaObject
}
extern "C" JNIEXPORT jlong JNICALL
XPCOM_NATIVE(CallXPCOMMethodLong) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodLong) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -420,7 +421,7 @@ XPCOM_NATIVE(CallXPCOMMethodLong) (JNIEnv *env, jclass that, jobject aJavaObject
}
extern "C" JNIEXPORT jlongArray JNICALL
XPCOM_NATIVE(CallXPCOMMethodLongA) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodLongA) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -429,7 +430,7 @@ XPCOM_NATIVE(CallXPCOMMethodLongA) (JNIEnv *env, jclass that, jobject aJavaObjec
}
extern "C" JNIEXPORT jfloat JNICALL
XPCOM_NATIVE(CallXPCOMMethodFloat) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodFloat) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -438,7 +439,7 @@ XPCOM_NATIVE(CallXPCOMMethodFloat) (JNIEnv *env, jclass that, jobject aJavaObjec
}
extern "C" JNIEXPORT jfloatArray JNICALL
XPCOM_NATIVE(CallXPCOMMethodFloatA) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodFloatA) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -447,7 +448,7 @@ XPCOM_NATIVE(CallXPCOMMethodFloatA) (JNIEnv *env, jclass that, jobject aJavaObje
}
extern "C" JNIEXPORT jdouble JNICALL
XPCOM_NATIVE(CallXPCOMMethodDouble) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodDouble) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -456,7 +457,7 @@ XPCOM_NATIVE(CallXPCOMMethodDouble) (JNIEnv *env, jclass that, jobject aJavaObje
}
extern "C" JNIEXPORT jdoubleArray JNICALL
XPCOM_NATIVE(CallXPCOMMethodDoubleA) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodDoubleA) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -465,7 +466,7 @@ XPCOM_NATIVE(CallXPCOMMethodDoubleA) (JNIEnv *env, jclass that, jobject aJavaObj
}
extern "C" JNIEXPORT jobject JNICALL
XPCOM_NATIVE(CallXPCOMMethodObj) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodObj) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -474,7 +475,7 @@ XPCOM_NATIVE(CallXPCOMMethodObj) (JNIEnv *env, jclass that, jobject aJavaObject,
}
extern "C" JNIEXPORT jobjectArray JNICALL
XPCOM_NATIVE(CallXPCOMMethodObjA) (JNIEnv *env, jclass that, jobject aJavaObject,
XPCOMPRIVATE_NATIVE(CallXPCOMMethodObjA) (JNIEnv *env, jclass that, jobject aJavaObject,
jint aMethodIndex, jobjectArray aParams)
{
jvalue rc;
@ -483,7 +484,7 @@ XPCOM_NATIVE(CallXPCOMMethodObjA) (JNIEnv *env, jclass that, jobject aJavaObject
}
extern "C" JNIEXPORT void JNICALL
XPCOM_NATIVE(FinalizeStub) (JNIEnv *env, jclass that, jobject aJavaObject)
XPCOMPRIVATE_NATIVE(FinalizeStub) (JNIEnv *env, jclass that, jobject aJavaObject)
{
#ifdef DEBUG
jboolean isCopy;

View File

@ -284,7 +284,7 @@ interface_declaration(TreeState *state)
* Create the finalize() method
*/
fputs(" protected void finalize() throws Throwable {\n", state->file);
fputs(" XPCOM.FinalizeStub(this);\n }", state->file);
fputs(" XPCOMPrivate.FinalizeStub(this);\n }", state->file);
/* fputs(" try {\n", state->file);
fputs(" XPCOM.FinalizeStub(this);\n", state->file);
fputs(" } finally {\n super.finalize();\n", state->file);
@ -1092,37 +1092,37 @@ method_declaration(TreeState *state)
switch (jtype) {
case JAVA_BYTE:
fputs("XPCOM.CallXPCOMMethodByte", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodByte", state->file);
break;
case JAVA_BYTEARRAY:
fputs("(byte[]) XPCOM.CallXPCOMMethodObj", state->file);
fputs("(byte[]) XPCOMPrivate.CallXPCOMMethodObj", state->file);
break;
case JAVA_SHORT:
fputs("XPCOM.CallXPCOMMethodShort", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodShort", state->file);
break;
case JAVA_INT:
fputs("XPCOM.CallXPCOMMethodInt", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodInt", state->file);
break;
case JAVA_LONG:
fputs("XPCOM.CallXPCOMMethodLong", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodLong", state->file);
break;
case JAVA_FLOAT:
fputs("XPCOM.CallXPCOMMethodFloat", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodFloat", state->file);
break;
case JAVA_DOUBLE:
fputs("XPCOM.CallXPCOMMethodDouble", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodDouble", state->file);
break;
case JAVA_CHAR:
fputs("XPCOM.CallXPCOMMethodChar", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodChar", state->file);
break;
case JAVA_BOOL:
fputs("XPCOM.CallXPCOMMethodBool", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodBool", state->file);
break;
case JAVA_STRING:
fputs("(String", state->file);
if (is_array)
fputs("[]", state->file);
fputs(") XPCOM.CallXPCOMMethodObj", state->file);
fputs(") XPCOMPrivate.CallXPCOMMethodObj", state->file);
break;
case JAVA_NSISUPPORTS:
fputs("(", state->file);
@ -1138,10 +1138,10 @@ method_declaration(TreeState *state)
}
if (is_array)
fputs("[]", state->file);
fputs(") XPCOM.CallXPCOMMethodObj", state->file);
fputs(") XPCOMPrivate.CallXPCOMMethodObj", state->file);
break;
case JAVA_OBJECT:
fputs("XPCOM.CallXPCOMMethodObj", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodObj", state->file);
break;
default:
g_error("Unknown jtype: %d\n", jtype);
@ -1153,7 +1153,7 @@ method_declaration(TreeState *state)
state->tree = orig_tree;
} else {
fputs("XPCOM.CallXPCOMMethodVoid", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodVoid", state->file);
}
fputs("(this, ", state->file);
@ -1290,44 +1290,44 @@ attribute_declaration(TreeState *state)
fputs("return ", state->file);
switch (jtype) {
case JAVA_BYTE:
fputs("XPCOM.CallXPCOMMethodByte", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodByte", state->file);
break;
case JAVA_BYTEARRAY:
fputs("(byte[]) XPCOM.CallXPCOMMethodObj", state->file);
fputs("(byte[]) XPCOMPrivate.CallXPCOMMethodObj", state->file);
break;
case JAVA_SHORT:
fputs("XPCOM.CallXPCOMMethodShort", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodShort", state->file);
break;
case JAVA_INT:
fputs("XPCOM.CallXPCOMMethodInt", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodInt", state->file);
break;
case JAVA_LONG:
fputs("XPCOM.CallXPCOMMethodLong", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodLong", state->file);
break;
case JAVA_FLOAT:
fputs("XPCOM.CallXPCOMMethodFloat", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodFloat", state->file);
break;
case JAVA_DOUBLE:
fputs("XPCOM.CallXPCOMMethodDouble", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodDouble", state->file);
break;
case JAVA_CHAR:
fputs("XPCOM.CallXPCOMMethodChar", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodChar", state->file);
break;
case JAVA_BOOL:
fputs("XPCOM.CallXPCOMMethodBool", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodBool", state->file);
break;
case JAVA_STRING:
fputs("(String) XPCOM.CallXPCOMMethodObj", state->file);
fputs("(String) XPCOMPrivate.CallXPCOMMethodObj", state->file);
break;
case JAVA_NSISUPPORTS:
fputs("(", state->file);
if (!xpcom_to_java_type(state, ATTR_TYPE_DECL(state->tree))) {
return FALSE;
}
fputs(") XPCOM.CallXPCOMMethodObj", state->file);
fputs(") XPCOMPrivate.CallXPCOMMethodObj", state->file);
break;
case JAVA_OBJECT:
fputs("XPCOM.CallXPCOMMethodObj", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodObj", state->file);
break;
default:
g_error("Unknown jtype: %d\n", jtype);
@ -1382,7 +1382,7 @@ attribute_declaration(TreeState *state)
/*
* Write CallXPCOMMethod invocation
*/
fputs("XPCOM.CallXPCOMMethodVoid(this, ", state->file);
fputs("XPCOMPrivate.CallXPCOMMethodVoid(this, ", state->file);
numMethods = PRIVDATA(state)->numMethods;
if (PRIVDATA(state)->bHasBaseClass) {
numMethods++;