* not part of tbox builds*
Fixed 57779, 58191 git-svn-id: svn://10.0.0.236/trunk@83932 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -27,6 +27,6 @@ srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS= src loader classes test
|
||||
DIRS= src loader classes
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -197,7 +197,7 @@ public class InterfaceRegistry {
|
||||
|
||||
private static void printMethod(Method m) {
|
||||
if (m == null) {
|
||||
System.out.println("<null>");
|
||||
Debug.log("<null>");
|
||||
return;
|
||||
}
|
||||
Class retType = m.getReturnType();
|
||||
@@ -210,12 +210,12 @@ public class InterfaceRegistry {
|
||||
if (j > 0) System.out.print(", ");
|
||||
System.out.print(paramTypes[j].getName());
|
||||
}
|
||||
System.out.println(");");
|
||||
Debug.log(");");
|
||||
}
|
||||
|
||||
private static void debug(String str) {
|
||||
if (debug) {
|
||||
System.out.println(str);
|
||||
Debug.log(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,13 +48,13 @@ class ProxyKey {
|
||||
|
||||
public class ProxyFactory {
|
||||
public static Class getInterface(IID iid) {
|
||||
System.out.println("--[java] ProxyFactory.getInterface "+iid);
|
||||
Debug.log("--[java] ProxyFactory.getInterface "+iid);
|
||||
return InterfaceRegistry.getInterface(iid);
|
||||
}
|
||||
|
||||
public static Object getProxy(long oid, IID iid, long orb) {
|
||||
try {
|
||||
System.out.println("--[java] ProxyFactory.getProxy "+iid);
|
||||
Debug.log("--[java] ProxyFactory.getProxy "+iid);
|
||||
ProxyKey key = new ProxyKey(oid, iid);
|
||||
Object obj = null;
|
||||
Object result = null;
|
||||
@@ -70,17 +70,17 @@ public class ProxyFactory {
|
||||
if (result == null) {
|
||||
Class inter = getInterface(iid);
|
||||
if (inter == null) {
|
||||
System.out.println("--[java] ProxyFactory.getProxy we did not find interface for iid="+iid+"returing null");
|
||||
Debug.log("--[java] ProxyFactory.getProxy we did not find interface for iid="+iid+"returing null");
|
||||
return null;
|
||||
}
|
||||
InvocationHandler handler = new ProxyHandler(oid, iid, orb);
|
||||
result = Proxy.newProxyInstance(inter.getClassLoader(), new Class[] {inter},handler);
|
||||
proxies.put(new WeakReference(result), key);
|
||||
}
|
||||
System.out.println("--[java] ProxyFactory.getProxy we got proxy "+result);
|
||||
Debug.log("--[java] ProxyFactory.getProxy we got proxy "+result);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
System.out.println("--[java] ProxyFactory.getProxy we got exception "+e);
|
||||
Debug.log("--[java] ProxyFactory.getProxy we got exception "+e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class ProxyHandler implements InvocationHandler {
|
||||
public Object invoke(Object proxy,
|
||||
Method method,
|
||||
Object[] args) throws Throwable {
|
||||
System.out.println("--[java]ProxyHandler.invoke "+method);
|
||||
Debug.log("--[java]ProxyHandler.invoke "+method);
|
||||
String str = method.getName();
|
||||
if (str.equals("toString")) {
|
||||
return "ProxyObject@{oid = "+oid+" iid = "+iid+"}";
|
||||
|
||||
@@ -24,35 +24,54 @@ package org.mozilla.xpcom;
|
||||
import java.lang.reflect.*;
|
||||
|
||||
public class Utilities {
|
||||
|
||||
static Class objectArrayClass = (new Object[1]).getClass();
|
||||
static Object callMethodByIndex(Object obj, IID iid, int mid, Object[] args) {
|
||||
System.out.println("--[java]org.mozilla.xpcom.Utilities.callMethodByIndex "+args.length+" "+mid);
|
||||
Debug.log("--[java]org.mozilla.xpcom.Utilities.callMethodByIndex "+args.length+" "+mid);
|
||||
Object retObject = null;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
System.out.println("--[java]callMethodByIndex args["+i+"] = "+args[i]);
|
||||
Debug.log("--[java]callMethodByIndex args["+i+"] = "+args[i]);
|
||||
}
|
||||
Method method = InterfaceRegistry.getMethodByIndex(mid,iid);
|
||||
System.out.println("--[java] org.mozilla.xpcom.Utilities.callMethodByIndex method "+method);
|
||||
Debug.log("--[java] org.mozilla.xpcom.Utilities.callMethodByIndex method "+method);
|
||||
try {
|
||||
|
||||
if (method != null) {
|
||||
for (int i = 0 ; i < args.length; i++) {
|
||||
/* this is hack. at the time we are doing holders for [out] interfaces
|
||||
we might do not know the expected type and we are producing Object[] insted of
|
||||
nsISupports[] for example. Here we are taking care about it.
|
||||
If args[i] is Object[] of size 1 we are checking with expected type from method.
|
||||
In case it is not expeceted type we are creating object[] of expected type.
|
||||
*/
|
||||
|
||||
if (objectArrayClass.equals(args[i].getClass())
|
||||
&& ((Object[])args[i]).length == 1) {
|
||||
Class[] parameterTypes = method.getParameterTypes();
|
||||
if (!objectArrayClass.equals(parameterTypes[i])
|
||||
&& parameterTypes[i].isArray()) {
|
||||
Class componentType = parameterTypes[i].getComponentType();
|
||||
args[i] = java.lang.reflect.Array.newInstance(componentType,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
retObject = method.invoke(obj,args);
|
||||
System.out.println("--[java] Utilities.callMethodByIndex: retObject = " + retObject);
|
||||
Debug.log("--[java] Utilities.callMethodByIndex: retObject = " + retObject);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("--[java] Utilities.callMethodByIndex method finished"+method);
|
||||
Debug.log("--[java] Utilities.callMethodByIndex method finished"+method);
|
||||
return retObject;
|
||||
}
|
||||
|
||||
static Object callMethod(long oid, Method method, IID iid, long orb , Object[] args) {
|
||||
System.out.println("--[java]Utilities.callMethod "+method);
|
||||
Debug.log("--[java]Utilities.callMethod "+method);
|
||||
int mid = InterfaceRegistry.getIndexByMethod(method, iid);
|
||||
if (mid < 0) {
|
||||
System.out.println("--[java]Utilities.callMethod we do not have implementation for "+method);
|
||||
Debug.log("--[java]Utilities.callMethod we do not have implementation for "+method);
|
||||
return null;
|
||||
}
|
||||
System.out.println("--[java]Utilities.callMethod "+mid);
|
||||
Debug.log("--[java]Utilities.callMethod "+mid);
|
||||
return callMethodByIndex(oid,mid,iid.getString(), orb, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ CPPSRCS = \
|
||||
bcJavaStubsAndProxies.cpp \
|
||||
bcIIDJava.cpp \
|
||||
org_mozilla_xpcom_Utilities.cpp \
|
||||
org_mozilla_xpcom_Debug.cpp \
|
||||
$(NULL)
|
||||
|
||||
JDKINCLUDE= -I$(JDKHOME)/include
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
|
||||
JavaVM *bcJavaGlobal::jvm = NULL;
|
||||
|
||||
PRLogModuleInfo* bcJavaGlobal::log = NULL;
|
||||
#ifdef XP_PC
|
||||
#define PATH_SEPARATOR ';'
|
||||
#else
|
||||
@@ -51,12 +51,13 @@ JNIEnv * bcJavaGlobal::GetJNIEnv(void) {
|
||||
|
||||
|
||||
void bcJavaGlobal::StartJVM() {
|
||||
printf("--bcJavaGlobal::StartJVM begin\n");
|
||||
PRLogModuleInfo * l = GetLog();
|
||||
PR_LOG(l,PR_LOG_DEBUG,("--bcJavaGlobal::StartJVM begin\n"));
|
||||
JNIEnv *env = NULL;
|
||||
jint res;
|
||||
jsize jvmCount;
|
||||
JNI_GetCreatedJavaVMs(&jvm, 1, &jvmCount);
|
||||
printf("--bcJavaGlobal::StartJVM after GetCreatedJavaVMs\n");
|
||||
PR_LOG(l,PR_LOG_DEBUG,("--bcJavaGlobal::StartJVM after GetCreatedJavaVMs\n"));
|
||||
if (jvmCount) {
|
||||
return;
|
||||
}
|
||||
@@ -64,12 +65,12 @@ void bcJavaGlobal::StartJVM() {
|
||||
JDK1_1InitArgs vm_args;
|
||||
char classpath[1024];
|
||||
JNI_GetDefaultJavaVMInitArgs(&vm_args);
|
||||
printf("--[c++] version %d",(int)vm_args.version);
|
||||
PR_LOG(l,PR_LOG_DEBUG,("--[c++] version %d",(int)vm_args.version));
|
||||
vm_args.version = 0x00010001;
|
||||
/* Append USER_CLASSPATH to the default system class path */
|
||||
sprintf(classpath, "%s%c%s",
|
||||
vm_args.classpath, PATH_SEPARATOR, PR_GetEnv("CLASSPATH"));
|
||||
printf("--[c++] classpath %s\n",classpath);
|
||||
PR_LOG(l,PR_LOG_DEBUG,("--[c++] classpath %s\n",classpath));
|
||||
char **props = new char*[2];
|
||||
props[0]="java.compiler=NONE";
|
||||
props[1]=0;
|
||||
@@ -82,7 +83,7 @@ void bcJavaGlobal::StartJVM() {
|
||||
JavaVMInitArgs vm_args;
|
||||
JavaVMOption options[2];
|
||||
sprintf(classpath, "-Djava.class.path=%s",PR_GetEnv("CLASSPATH"));
|
||||
printf("--[c++] classpath %s\n",classpath);
|
||||
PR_LOG(l,PR_LOG_DEBUG,("--[c++] classpath %s\n",classpath));
|
||||
options[0].optionString = classpath;
|
||||
options[1].optionString=""; //-Djava.compiler=NONE";
|
||||
vm_args.version = 0x00010002;
|
||||
@@ -92,7 +93,16 @@ void bcJavaGlobal::StartJVM() {
|
||||
/* Create the Java VM */
|
||||
res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
|
||||
#endif
|
||||
printf("--bcJavaGlobal::StartJVM jvm started res %d\n",res);
|
||||
|
||||
PR_LOG(l,PR_LOG_DEBUG,("--bcJavaGlobal::StartJVM jvm started res %d\n",res));
|
||||
}
|
||||
|
||||
|
||||
PRLogModuleInfo* bcJavaGlobal::GetLog() {
|
||||
if (log == NULL) {
|
||||
log = PR_NewLogModule(LOG_MODULE);
|
||||
}
|
||||
return log;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,4 +120,3 @@ void bcJavaGlobal::StartJVM() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,10 @@
|
||||
#define __bcJavaGlobal_h_
|
||||
#include "nscore.h"
|
||||
#include "jni.h"
|
||||
#include "prlog.h"
|
||||
|
||||
|
||||
#define LOG_MODULE "blackConnect"
|
||||
#define EXCEPTION_CHECKING(env) \
|
||||
do { \
|
||||
if ((env)->ExceptionOccurred()) { \
|
||||
@@ -31,10 +34,13 @@
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
|
||||
class bcJavaGlobal {
|
||||
public:
|
||||
static JNIEnv * GetJNIEnv(void);
|
||||
static PRLogModuleInfo * GetLog();
|
||||
private:
|
||||
static PRLogModuleInfo* log;
|
||||
static JavaVM *jvm;
|
||||
static void StartJVM(void);
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "bcJavaStubsAndProxies.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "bcJavaGlobal.h"
|
||||
#include <string.h>
|
||||
|
||||
jclass bcJavaMarshalToolkit::objectClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::objectArrayClass = NULL;
|
||||
@@ -164,7 +165,8 @@ nsresult bcJavaMarshalToolkit::UnMarshal(bcIUnMarshaler *um, jobject *retval) {
|
||||
}
|
||||
|
||||
nsresult bcJavaMarshalToolkit::UnMarshal(bcIUnMarshaler *um) {
|
||||
printf("--nsresult bcJavaMarshalToolkit::UnMarshal\n");
|
||||
PRLogModuleInfo * log = bcJavaGlobal::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG,("--nsresult bcJavaMarshalToolkit::UnMarshal\n"));
|
||||
bcIAllocator * allocator = new javaAllocator(nsAllocator::GetGlobalAllocator());
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
retV = NULL;
|
||||
@@ -174,8 +176,8 @@ nsresult bcJavaMarshalToolkit::UnMarshal(bcIUnMarshaler *um) {
|
||||
PRBool isOut = param.IsOut();
|
||||
nsXPTType type = param.GetType();
|
||||
if (param.IsRetval() && callSide == onServer) {
|
||||
printf("** bcJavaMarshalToolkit::UnMarshal skipping retval\n");
|
||||
printf("**unmarshall: call side: %d\n", callSide);
|
||||
PR_LOG(log,PR_LOG_DEBUG,("** bcJavaMarshalToolkit::UnMarshal skipping retval\n"));
|
||||
PR_LOG(log,PR_LOG_DEBUG,("**unmarshall: call side: %d\n", callSide));
|
||||
continue;
|
||||
}
|
||||
if ( (callSide == onServer && !param.IsIn()
|
||||
@@ -235,6 +237,7 @@ nsresult
|
||||
bcJavaMarshalToolkit::MarshalElement(bcIMarshaler *m, jobject value, PRBool isOut, nsXPTParamInfo * param,
|
||||
bcXPType type, uint8 ind, ArrayModifier modifier) {
|
||||
nsresult r = NS_OK;
|
||||
PRLogModuleInfo * log = bcJavaGlobal::GetLog();
|
||||
|
||||
switch(type) {
|
||||
case bc_T_I8:
|
||||
@@ -298,23 +301,36 @@ bcJavaMarshalToolkit::MarshalElement(bcIMarshaler *m, jobject value, PRBool isO
|
||||
EXCEPTION_CHECKING(env);
|
||||
}
|
||||
char * str = NULL;
|
||||
char * tmpStr = NULL;
|
||||
if (data) {
|
||||
size_t length = 0;
|
||||
if (type == bc_T_CHAR_STR) {
|
||||
str = (char*)env->GetStringUTFChars((jstring)data,NULL);
|
||||
length = strlen(str)+1;
|
||||
tmpStr = str;
|
||||
} else {
|
||||
str = (char*)env->GetStringChars((jstring)data,NULL);
|
||||
length = env->GetStringLength((jstring)data);
|
||||
length *= sizeof(jchar);
|
||||
length *= 2; //nb
|
||||
length += 2;
|
||||
tmpStr = new char[length];
|
||||
memcpy(tmpStr,str,length-2);
|
||||
tmpStr[length-1] = tmpStr[length-2] = 0;
|
||||
{
|
||||
for (int i = 0; i < length && type == bc_T_WCHAR_STR; i++) {
|
||||
char c = tmpStr[i];
|
||||
PR_LOG(log,PR_LOG_DEBUG,("--[c++] bcJavaMarshalToolkit::MarshalElement T_WCHAR_STR [%d] = %d %c\n",i,c,c));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
EXCEPTION_CHECKING(env);
|
||||
m->WriteString(str,length);
|
||||
m->WriteString(tmpStr,length);
|
||||
if (type == bc_T_CHAR_STR) {
|
||||
env->ReleaseStringUTFChars(data,str);
|
||||
} else {
|
||||
env->ReleaseStringChars(data,(const jchar*)str);
|
||||
delete[] tmpStr;
|
||||
}
|
||||
EXCEPTION_CHECKING(env);
|
||||
} else {
|
||||
@@ -344,7 +360,7 @@ bcJavaMarshalToolkit::MarshalElement(bcIMarshaler *m, jobject value, PRBool isO
|
||||
{
|
||||
int indexInArray;
|
||||
jobject data = NULL;
|
||||
printf("--marshalElement we got interface\n");
|
||||
PR_LOG(log,PR_LOG_DEBUG,("--marshalElement we got interface\n"));
|
||||
bcOID oid = 0;
|
||||
nsIID *iid;
|
||||
if (! isOut
|
||||
@@ -409,7 +425,7 @@ bcJavaMarshalToolkit::MarshalElement(bcIMarshaler *m, jobject value, PRBool isO
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printf("--it should not happend\n");
|
||||
PR_LOG(log,PR_LOG_DEBUG,("--it should not happend\n"));
|
||||
;
|
||||
}
|
||||
return r;
|
||||
@@ -450,6 +466,7 @@ bcJavaMarshalToolkit::MarshalElement(bcIMarshaler *m, jobject value, PRBool isO
|
||||
nsresult
|
||||
bcJavaMarshalToolkit::UnMarshalElement(jobject *value, uint8 ind, bcIUnMarshaler *um, int isOut, nsXPTParamInfo * param,
|
||||
bcXPType type, bcIAllocator *allocator, ArrayModifier modifier) {
|
||||
PRLogModuleInfo *log = bcJavaGlobal::GetLog();
|
||||
switch(type) {
|
||||
case bc_T_I8:
|
||||
case bc_T_U8:
|
||||
@@ -505,9 +522,16 @@ bcJavaMarshalToolkit::UnMarshalElement(jobject *value, uint8 ind, bcIUnMarshaler
|
||||
jstring data = NULL;
|
||||
if (um) {
|
||||
um->ReadString(&data,&size,allocator);
|
||||
{
|
||||
for (int i = 0; i < size && type == bc_T_WCHAR_STR; i++) {
|
||||
char c = ((char*)data)[i];
|
||||
PR_LOG(log, PR_LOG_DEBUG,("--[c++] bcJavaMarshalToolkit::UnMarshalElement T_WCHAR_STR [%d] = %d %c\n",i,c,c));
|
||||
}
|
||||
}
|
||||
if (type == bc_T_CHAR_STR) {
|
||||
data = env->NewStringUTF((const char*)data);
|
||||
} else {
|
||||
size-=2; size/=2;
|
||||
data = env->NewString((const jchar*)data,size);
|
||||
}
|
||||
EXCEPTION_CHECKING(env);
|
||||
@@ -568,7 +592,7 @@ bcJavaMarshalToolkit::UnMarshalElement(jobject *value, uint8 ind, bcIUnMarshaler
|
||||
|
||||
case bc_T_INTERFACE:
|
||||
{
|
||||
printf("--[c++] bcJavaMarshalToolkit::UnMarshalElement we have an interface\n");
|
||||
PR_LOG(log, PR_LOG_DEBUG,("--[c++] bcJavaMarshalToolkit::UnMarshalElement we have an interface\n"));
|
||||
int indexInArray = 0;
|
||||
jobject data = NULL;
|
||||
bcOID oid = 0;
|
||||
@@ -578,7 +602,7 @@ bcJavaMarshalToolkit::UnMarshalElement(jobject *value, uint8 ind, bcIUnMarshaler
|
||||
if (um) {
|
||||
um->ReadSimple(&oid,type);
|
||||
um->ReadSimple(&iid,bc_T_IID);
|
||||
printf("%d oid\n",(int) oid);
|
||||
PR_LOG(log,PR_LOG_DEBUG,("%d oid\n",(int) oid));
|
||||
NS_WITH_SERVICE(bcJavaStubsAndProxies, javaStubsAndProxies, kJavaStubsAndProxies, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@@ -877,6 +901,7 @@ void bcJavaMarshalToolkit::InitializeStatic() {
|
||||
}
|
||||
|
||||
void bcJavaMarshalToolkit::DeInitializeStatic() { //nb need to do
|
||||
printf("--[c++]void bcJavaMarshalToolkit::DeInitializeStatic() - boomer \n");
|
||||
PRLogModuleInfo * log = bcJavaGlobal::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG,("--[c++]void bcJavaMarshalToolkit::DeInitializeStatic() - boomer \n"));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,10 @@ jclass bcJavaStub::utilitiesClass = NULL;
|
||||
jmethodID bcJavaStub::callMethodByIndexMID = NULL;
|
||||
|
||||
bcJavaStub::bcJavaStub(jobject obj) {
|
||||
printf("--bcJavaStub::bcJavaStub \n");
|
||||
PRLogModuleInfo *log = bcJavaGlobal::GetLog();
|
||||
PR_LOG(log,PR_LOG_DEBUG,("--bcJavaStub::bcJavaStub \n"));
|
||||
if (!obj) {
|
||||
printf("--bcJavaStub::bcJavaStub obj== 0\n");
|
||||
PR_LOG(log,PR_LOG_DEBUG,("--bcJavaStub::bcJavaStub obj== 0\n"));
|
||||
return;
|
||||
}
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
@@ -51,6 +52,7 @@ bcJavaStub::~bcJavaStub() {
|
||||
|
||||
void bcJavaStub::Dispatch(bcICall *call) {
|
||||
//sigsend(P_PID, getpid(),SIGINT);
|
||||
PRLogModuleInfo *log = bcJavaGlobal::GetLog();
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
bcIID iid; bcOID oid; bcMID mid;
|
||||
jobjectArray args;
|
||||
@@ -74,7 +76,7 @@ void bcJavaStub::Dispatch(bcICall *call) {
|
||||
nsXPTMethodInfo* info;
|
||||
interfaceInfo->GetMethodInfo(mid,(const nsXPTMethodInfo **)&info);
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
printf("\n**[c++]hasRetval: %d\n", HasRetval(paramCount, info));
|
||||
PR_LOG(log, PR_LOG_DEBUG,("\n**[c++]hasRetval: %d\n", HasRetval(paramCount, info)));
|
||||
if (HasRetval(paramCount, info))
|
||||
// do not pass retval param
|
||||
paramCount--;
|
||||
@@ -86,7 +88,6 @@ void bcJavaStub::Dispatch(bcICall *call) {
|
||||
jobject retval = bcJavaGlobal::GetJNIEnv()->CallStaticObjectMethod(utilitiesClass, callMethodByIndexMID, object, jiid, (jint)mid, args);
|
||||
//nb return value; excepion handling
|
||||
bcIMarshaler * m = call->GetMarshaler();
|
||||
// mt->Marshal(m);
|
||||
mt->Marshal(m, retval);
|
||||
//nb memory deallocation
|
||||
delete m; delete um; delete mt;
|
||||
|
||||
@@ -68,7 +68,8 @@ NS_IMETHODIMP bcJavaStubsAndProxies::GetStub(jobject obj, bcIStub **stub) {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaStubsAndProxies::GetProxy(bcOID oid, const nsIID &iid, bcIORB *orb, jobject *proxy) {
|
||||
printf("--[c++] bcJavaStubsAndProxies::GetProxy\n");
|
||||
PRLogModuleInfo *log = bcJavaGlobal::GetLog();
|
||||
PR_LOG(log,PR_LOG_DEBUG,("--[c++] bcJavaStubsAndProxies::GetProxy\n"));
|
||||
if (!componentLoader) {
|
||||
Init();
|
||||
}
|
||||
@@ -80,7 +81,8 @@ NS_IMETHODIMP bcJavaStubsAndProxies::GetProxy(bcOID oid, const nsIID &iid, bcIOR
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaStubsAndProxies::GetInterface(const nsIID &iid, jclass *clazz) {
|
||||
printf("--[c++] bcJavaStubsAndProxies::GetInterface\n");
|
||||
PRLogModuleInfo *log = bcJavaGlobal::GetLog();
|
||||
PR_LOG(log,PR_LOG_DEBUG,("--[c++] bcJavaStubsAndProxies::GetInterface\n"));
|
||||
if (!componentLoader) {
|
||||
Init();
|
||||
}
|
||||
@@ -98,7 +100,8 @@ NS_IMETHODIMP bcJavaStubsAndProxies::GetOID(jobject object, bcIORB *orb, bcOID
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaStubsAndProxies::GetOID(char *location, bcOID *oid) {
|
||||
printf("--bcJavaStubsAndProxies::GetOID %s\n",location);
|
||||
PRLogModuleInfo *log = bcJavaGlobal::GetLog();
|
||||
PR_LOG(log,PR_LOG_DEBUG,("--bcJavaStubsAndProxies::GetOID %s\n",location));
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
nsresult result;
|
||||
|
||||
@@ -112,7 +115,7 @@ NS_IMETHODIMP bcJavaStubsAndProxies::GetOID(char *location, bcOID *oid) {
|
||||
bcIStub *stub = new bcJavaStub(object);
|
||||
NS_WITH_SERVICE(bcORB,_orb,kORBCIID,&result);
|
||||
if (NS_FAILED(result)) {
|
||||
printf("--bcJavaStubsAndProxies::GetOID failed\n");
|
||||
PR_LOG(log,PR_LOG_DEBUG,("--bcJavaStubsAndProxies::GetOID failed\n"));
|
||||
return result;
|
||||
}
|
||||
bcIORB *orb;
|
||||
@@ -122,13 +125,14 @@ NS_IMETHODIMP bcJavaStubsAndProxies::GetOID(char *location, bcOID *oid) {
|
||||
}
|
||||
|
||||
void bcJavaStubsAndProxies::Init(void) {
|
||||
printf("--[c++]bcJavaStubsAndProxies::Init\n");
|
||||
PRLogModuleInfo *log = bcJavaGlobal::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG,("--[c++]bcJavaStubsAndProxies::Init\n"));
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
componentLoader = env->FindClass("org/mozilla/xpcom/ComponentLoader");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
printf("--Did you set CLASSPATH correctly\n");
|
||||
PR_LOG(log,PR_LOG_ALWAYS,("--Did you set CLASSPATH correctly\n"));
|
||||
return;
|
||||
}
|
||||
componentLoader = (jclass)env->NewGlobalRef(componentLoader);
|
||||
|
||||
@@ -40,6 +40,7 @@ OBJS= \
|
||||
.\$(OBJDIR)\bcJavaStubsAndProxies.obj \
|
||||
.\$(OBJDIR)\bcIIDJava.obj \
|
||||
.\$(OBJDIR)\org_mozilla_xpcom_Utilities.obj \
|
||||
.\$(OBJDIR)\org_mozilla_xpcom_Debug.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(JDKHOME)\include -I$(JDKHOME)\include\win32
|
||||
|
||||
38
mozilla/java/xpcom/java/src/org_mozilla_xpcom_Debug.cpp
Normal file
38
mozilla/java/xpcom/java/src/org_mozilla_xpcom_Debug.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "org_mozilla_xpcom_Debug.h"
|
||||
#include "bcJavaGlobal.h"
|
||||
/*
|
||||
* Class: org_mozilla_xpcom_Debug
|
||||
* Method: log
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_xpcom_Debug_log
|
||||
(JNIEnv *env, jclass, jstring jstr) {
|
||||
PRLogModuleInfo *log = bcJavaGlobal::GetLog();
|
||||
char * str = NULL;
|
||||
str = (char*)env->GetStringUTFChars(jstr,NULL);
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("%s\n",str));
|
||||
env->ReleaseStringUTFChars(jstr,str);
|
||||
}
|
||||
21
mozilla/java/xpcom/java/src/org_mozilla_xpcom_Debug.h
Normal file
21
mozilla/java/xpcom/java/src/org_mozilla_xpcom_Debug.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_mozilla_xpcom_Debug */
|
||||
|
||||
#ifndef _Included_org_mozilla_xpcom_Debug
|
||||
#define _Included_org_mozilla_xpcom_Debug
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_mozilla_xpcom_Debug
|
||||
* Method: log
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_xpcom_Debug_log
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "bcJavaMarshalToolkit.h"
|
||||
#include "ctype.h"
|
||||
#include "bcJavaGlobal.h"
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_xpcom_Utilities
|
||||
@@ -42,7 +43,8 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_xpcom_Utilities_callMethodByIndex
|
||||
bcIORB * orb = (bcIORB*) _orb;
|
||||
bcOID oid = (bcOID)_oid;
|
||||
nsIID iid;
|
||||
printf("--[c++] jni Java_org_mozilla_xpcom_Utilities_callMethodByIndex %d\n",(int)mid);
|
||||
PRLogModuleInfo *log = bcJavaGlobal::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--[c++] jni Java_org_mozilla_xpcom_Utilities_callMethodByIndex %d\n",(int)mid));
|
||||
const char * str = NULL;
|
||||
str = env->GetStringUTFChars(jiid,NULL);
|
||||
iid.Parse(str);
|
||||
@@ -66,11 +68,10 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_xpcom_Utilities_callMethodByIndex
|
||||
mt->Marshal(m);
|
||||
orb->SendReceive(call);
|
||||
bcIUnMarshaler * um = call->GetUnMarshaler();
|
||||
// mt->UnMarshal(um);
|
||||
jobject retval;
|
||||
mt->UnMarshal(um, &retval);
|
||||
delete m; delete um; delete mt;
|
||||
// return NULL;
|
||||
delete call; delete m; delete um; delete mt;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,4 +10,6 @@ interface bcIJavaSample : nsISupports
|
||||
void test3(in PRUint32 count,[array, size_is(count)] in long valueArray);
|
||||
void test4(in PRUint32 count,[array, size_is(count)] inout string valueArray);
|
||||
void test5(in nsIComponentManager cm);
|
||||
void test6(in PRUint32 count,[array, size_is(count)] in string valueArray);
|
||||
void test7(out PRUint32 count,[array, size_is(count)] out char valueArray);
|
||||
};
|
||||
|
||||
@@ -4,15 +4,16 @@
|
||||
* This file was automatically generated from bcIJavaSample.idl.
|
||||
*/
|
||||
|
||||
|
||||
import org.mozilla.xpcom.*;
|
||||
|
||||
|
||||
/**
|
||||
* Interface bcIJavaSample
|
||||
*
|
||||
* IID: 0xca1e2656-1dd1-11b2-9c4e-f49ea557abde
|
||||
*/
|
||||
|
||||
|
||||
public interface bcIJavaSample extends nsISupports
|
||||
{
|
||||
public static final String IID =
|
||||
@@ -37,6 +38,12 @@ public interface bcIJavaSample extends nsISupports
|
||||
/* void test5 (in nsIComponentManager cm); */
|
||||
public void test5(nsIComponentManager cm);
|
||||
|
||||
/* void test6 (in PRUint32 count, [array, size_is (count)] in string valueArray); */
|
||||
public void test6(int count, String[] valueArray);
|
||||
|
||||
/* void test7 (out PRUint32 count, [array, size_is (count)] out char valueArray); */
|
||||
public void test7(int[] count, char[][] valueArray);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -100,6 +100,19 @@ NS_IMETHODIMP bcJavaSample::Test5(nsIComponentManager *cm) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void test6 (in PRUint32 count, [array, size_is (count)] in string valueArray); */
|
||||
NS_IMETHODIMP bcJavaSample::Test6(PRUint32 count, const char **valueArray) {
|
||||
printf("--[c++] bcJavaSample.test6 coutn %d\n",count);
|
||||
for(unsigned int i = 0; i < count; i++) {
|
||||
printf("--[c++] valueArray[%d]=%s\n",i,valueArray[i]);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void test7 (in PRUint32 count, [array, size_is (count)] out char valueArray); */
|
||||
NS_IMETHODIMP bcJavaSample::Test7(PRUint32 *count, char **valueArray) {
|
||||
return NS_OK;
|
||||
}
|
||||
void test() {
|
||||
printf("--BlackConnect test start\n");
|
||||
nsresult r;
|
||||
@@ -151,6 +164,25 @@ void test() {
|
||||
}
|
||||
printf("--[c++] bcJavaSample after test->Test5(cm)\n");
|
||||
}
|
||||
{
|
||||
const char ** valueArray = (const char **)malloc(sizeof(char*)*4);
|
||||
valueArray[0] = "hi";
|
||||
valueArray[1] = "there";
|
||||
valueArray[2] = "a";
|
||||
valueArray[3] = "b";
|
||||
test->Test6(4,valueArray);
|
||||
}
|
||||
{
|
||||
printf("--[c++]about to test7\n");
|
||||
PRUint32 count;
|
||||
char *charArray;
|
||||
test->Test7(&count,&charArray);
|
||||
for (int i = 0; i < count; i++) {
|
||||
printf("--[c++] charArray[%d]=%c\n",i,charArray[i]);
|
||||
}
|
||||
printf("--[c++]end of test7\n");
|
||||
}
|
||||
|
||||
printf("--BlackConnect test end\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,10 @@ public class bcJavaSample implements bcIJavaSample {
|
||||
o.test2(this);
|
||||
int[] array={3,2,1};
|
||||
o.test3(3,array);
|
||||
{
|
||||
String[] strings = {"4","3","2","1"};
|
||||
o.test6(4, strings);
|
||||
}
|
||||
} else {
|
||||
System.out.println("--[java]bcJavaSample.test2 o = null");
|
||||
}
|
||||
@@ -70,7 +74,7 @@ public class bcJavaSample implements bcIJavaSample {
|
||||
System.out.println("--[java]bcJavaSample.test4");
|
||||
String[] array = valueArray[0];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
System.out.println("--[java]callMethodByIndex args["+i+"] = "+array[i]);
|
||||
System.out.println("--[java]bcJavaSample.test4 valueArray["+i+"] = "+array[i]);
|
||||
}
|
||||
String[] returnArray = {"4","3","2","1"};
|
||||
valueArray[0] = returnArray;
|
||||
@@ -103,6 +107,22 @@ public class bcJavaSample implements bcIJavaSample {
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
}
|
||||
public void test6(int count, String[] valueArray) {
|
||||
System.out.println("--[java]bcJavaSample.test6");
|
||||
String[] array = valueArray;
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
System.out.println("--[java]bcJavaSample.test6 valueArray["+i+"] = "+array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* void test7 (out PRUint32 count, [array, size_is (count)] out char valueArray); */
|
||||
public void test7(int[] count, char[][] valueArray) {
|
||||
System.out.println("--[java]bcJavaSample.test7");
|
||||
char [] retValue = {'1','b','c','d'};
|
||||
count[0] = retValue.length;
|
||||
valueArray[0] = retValue;
|
||||
}
|
||||
|
||||
static IID bcIJavaSampleIID = new IID(bcIJavaSample.IID);
|
||||
|
||||
@@ -26,12 +26,13 @@ VPATH = .
|
||||
XPIDLDIR = $(DEPTH)/xpcom/typelib/xpidl
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
PROGRAM = xpidl$(BIN_SUFFIX)
|
||||
INTERNAL_TOOLS = 1
|
||||
|
||||
CSRCS = \
|
||||
$(XPIDLDIR)/xpidl.c \
|
||||
xpidl.c \
|
||||
xpidl_idl.c \
|
||||
$(XPIDLDIR)/xpidl_util.c \
|
||||
$(XPIDLDIR)/xpidl_header.c \
|
||||
|
||||
Reference in New Issue
Block a user