mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 16:22:00 +00:00
* not part of tbox builds*
Fixed 57779, 58191
This commit is contained in:
parent
782a17b25a
commit
0ec50a33d4
@ -31,7 +31,7 @@ DIRS= \
|
||||
connect \
|
||||
xpcom \
|
||||
java \
|
||||
xpcom/test/ \
|
||||
# xpcom/test/ \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -31,7 +31,7 @@ DIRS= \
|
||||
connect \
|
||||
xpcom \
|
||||
java \
|
||||
xpcom/test/ \
|
||||
# xpcom/test/ \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -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
java/xpcom/java/src/org_mozilla_xpcom_Debug.cpp
Normal file
38
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
java/xpcom/java/src/org_mozilla_xpcom_Debug.h
Normal file
21
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 \
|
||||
|
@ -35,7 +35,11 @@ include $(topsrcdir)/config/config.mk
|
||||
|
||||
CXXFLAGS += -I$(CONNECT_SRC)/public
|
||||
CPPSRCS = \
|
||||
bcXPCOMProxy.cpp bcXPCOMStub.cpp bcXPCOMMarshalToolkit.cpp bcXPCOMStubsAndProxies.cpp \
|
||||
bcXPCOMProxy.cpp \
|
||||
bcXPCOMStub.cpp \
|
||||
bcXPCOMMarshalToolkit.cpp \
|
||||
bcXPCOMStubsAndProxies.cpp \
|
||||
bcXPCOMLog.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
32
java/xpcom/xpcom/bcXPCOMLog.cpp
Normal file
32
java/xpcom/xpcom/bcXPCOMLog.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
/* -*- 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 "bcXPCOMLog.h"
|
||||
|
||||
PRLogModuleInfo * bcXPCOMLog::log = NULL;
|
||||
|
||||
PRLogModuleInfo * bcXPCOMLog::GetLog() {
|
||||
if (log == NULL) {
|
||||
log = PR_NewLogModule(LOG_MODULE);
|
||||
}
|
||||
return log;
|
||||
}
|
31
java/xpcom/xpcom/bcXPCOMLog.h
Normal file
31
java/xpcom/xpcom/bcXPCOMLog.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* -*- 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 "prlog.h"
|
||||
|
||||
#define LOG_MODULE "blackConnect"
|
||||
class bcXPCOMLog {
|
||||
public:
|
||||
static PRLogModuleInfo *GetLog();
|
||||
private:
|
||||
static PRLogModuleInfo *log;
|
||||
};
|
@ -26,6 +26,7 @@
|
||||
#include "bcORB.h"
|
||||
#include "bcXPCOMStubsAndProxies.h"
|
||||
#include "nsCRT.h"
|
||||
#include "bcXPCOMLog.h"
|
||||
|
||||
static NS_DEFINE_CID(kORBCIID,BC_ORB_CID);
|
||||
static NS_DEFINE_CID(kXPCOMStubsAndProxies,BC_XPCOMSTUBSANDPROXIES_CID);
|
||||
@ -86,7 +87,8 @@ private:
|
||||
|
||||
|
||||
nsresult bcXPCOMMarshalToolkit::Marshal(bcIMarshaler *m) {
|
||||
//printf("--bcXPCOMMarshalToolkit::Marshal\n");
|
||||
PRLogModuleInfo *log = bcXPCOMLog::GetLog();
|
||||
PR_LOG(log,PR_LOG_DEBUG,("--bcXPCOMMarshalToolkit::Marshal\n"));
|
||||
nsresult r = NS_OK;
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
for (unsigned int i = 0; (i < paramCount) && NS_SUCCEEDED(r); i++) {
|
||||
@ -225,7 +227,8 @@ bcXPType bcXPCOMMarshalToolkit::XPTType2bcXPType(uint8 type) {
|
||||
|
||||
nsresult bcXPCOMMarshalToolkit::MarshalElement(bcIMarshaler *m, void *data, nsXPTParamInfo * param,
|
||||
uint8 type, uint8 ind) {
|
||||
//printf("--bcXPCOMMarshalToolkit::MarshalElement ind=%d\n",ind);
|
||||
PRLogModuleInfo * log = bcXPCOMLog::GetLog();
|
||||
PR_LOG(log,PR_LOG_DEBUG,("--bcXPCOMMarshalToolkit::MarshalElement ind=%d\n",ind));
|
||||
nsresult r = NS_OK;
|
||||
switch(type) {
|
||||
case nsXPTType::T_IID :
|
||||
@ -252,8 +255,13 @@ nsresult bcXPCOMMarshalToolkit::MarshalElement(bcIMarshaler *m, void *data, nsXP
|
||||
size_t length = 0;
|
||||
if (type == nsXPTType::T_WCHAR_STR) {
|
||||
length = nsCRT::strlen((const PRUnichar*)data);
|
||||
length *= sizeof(PRUnichar);
|
||||
PR_LOG(log, PR_LOG_DEBUG,("--[c++] bcXPCOMMarshalToolkit::MarshalElement T_WCHAR_STR length=%d\n",length));
|
||||
length *= 2;
|
||||
length +=2;
|
||||
for (int i = 0; i < length && type == nsXPTType::T_WCHAR_STR; i++) {
|
||||
char c = ((char*)data)[i];
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--[c++] bcXPCOMMarshalToolkit::MarshalElement T_WCHAR_STR [%d] = %d %c\n",i,c,c));
|
||||
}
|
||||
} else {
|
||||
length = nsCRT::strlen((const char*)data);
|
||||
length+=1;
|
||||
@ -286,7 +294,7 @@ nsresult bcXPCOMMarshalToolkit::MarshalElement(bcIMarshaler *m, void *data, nsXP
|
||||
iid = (nsID*)params[argnum].val.p;
|
||||
}
|
||||
}
|
||||
//printf("--[c++]XPCOMMarshallToolkit INTERFACE iid=%s\n",iid->ToString());
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--[c++]XPCOMMarshallToolkit INTERFACE iid=%s\n",iid->ToString()));
|
||||
bcOID oid = 0;
|
||||
if (*(char**)data != NULL) {
|
||||
NS_WITH_SERVICE(bcORB, _orb, kORBCIID, &r);
|
||||
@ -311,8 +319,7 @@ nsresult bcXPCOMMarshalToolkit::MarshalElement(bcIMarshaler *m, void *data, nsXP
|
||||
}
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
case nsXPTType::T_PWSTRING_SIZE_IS:
|
||||
case nsXPTType::T_ARRAY:
|
||||
//nb array of interfaces [to do]
|
||||
case nsXPTType::T_ARRAY: //nb array of interfaces [to do]
|
||||
{
|
||||
PRUint32 arraySize;
|
||||
if (!GetArraySizeFromParam(interfaceInfo,info, *param,methodIndex,
|
||||
@ -325,7 +332,7 @@ nsresult bcXPCOMMarshalToolkit::MarshalElement(bcIMarshaler *m, void *data, nsXP
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
m->WriteSimple(&arraySize,bc_T_U32);
|
||||
PRInt16 elemSize = GetSimpleSize(type);
|
||||
PRInt16 elemSize = GetSimpleSize(datumType);
|
||||
char *current = *(char**)data;
|
||||
for (unsigned int i = 0; i < arraySize; i++, current+=elemSize) {
|
||||
MarshalElement(m,current,param,datumType.TagPart(),0);
|
||||
@ -349,6 +356,7 @@ nsresult bcXPCOMMarshalToolkit::MarshalElement(bcIMarshaler *m, void *data, nsXP
|
||||
|
||||
nsresult
|
||||
bcXPCOMMarshalToolkit::UnMarshalElement(void *data, bcIUnMarshaler *um, nsXPTParamInfo * param, uint8 type, bcIAllocator * allocator) {
|
||||
PRLogModuleInfo *log = bcXPCOMLog::GetLog();
|
||||
nsresult r = NS_OK;
|
||||
switch(type) {
|
||||
case nsXPTType::T_IID :
|
||||
@ -368,6 +376,7 @@ bcXPCOMMarshalToolkit::UnMarshalElement(void *data, bcIUnMarshaler *um, nsXPTPar
|
||||
case nsXPTType::T_CHAR :
|
||||
case nsXPTType::T_WCHAR :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type));
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--[c++] bcXPCOMMarshalToolkit::UnMarshalElement %c\n",*(char*)data));
|
||||
break;
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
case nsXPTType::T_PWSTRING_SIZE_IS:
|
||||
@ -375,14 +384,21 @@ bcXPCOMMarshalToolkit::UnMarshalElement(void *data, bcIUnMarshaler *um, nsXPTPar
|
||||
case nsXPTType::T_WCHAR_STR :
|
||||
size_t size;
|
||||
um->ReadString(data,&size,allocator);
|
||||
{
|
||||
char *str = *(char**)data;
|
||||
for (int i = 0; i < size && type == nsXPTType::T_WCHAR_STR; i++) {
|
||||
char c = str[i];
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--[c++] bcXPCOMMarshalToolkit::UnMarshalElement T_WCHAR_STR [%d] = %d %c\n",i,(int)c,c));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE :
|
||||
case nsXPTType::T_INTERFACE_IS :
|
||||
{
|
||||
printf("--[c++] we have an interface\n");
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--[c++] we have an interface\n"));
|
||||
bcOID oid;
|
||||
um->ReadSimple(&oid,XPTType2bcXPType(type));
|
||||
printf("%d oid\n",(int) oid);
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("%d oid\n",(int) oid));
|
||||
nsIID iid;
|
||||
um->ReadSimple(&iid,bc_T_IID);
|
||||
nsISupports *proxy = NULL;
|
||||
|
@ -26,17 +26,19 @@
|
||||
#include "bcXPCOMProxy.h"
|
||||
#include "bcXPCOMMarshalToolkit.h"
|
||||
|
||||
#include "signal.h"
|
||||
//#include "signal.h"
|
||||
//NS_IMPL_ISUPPORTS(bcXPCOMProxy, NS_GET_IID(bcXPCOMProxy));
|
||||
#include "bcXPCOMLog.h"
|
||||
|
||||
|
||||
bcXPCOMProxy::bcXPCOMProxy(bcOID _oid, const nsIID &_iid, bcIORB *_orb) {
|
||||
PRLogModuleInfo *log = bcXPCOMLog::GetLog();
|
||||
NS_INIT_REFCNT();
|
||||
oid = _oid;
|
||||
iid = _iid;
|
||||
orb = _orb;
|
||||
interfaceInfo = NULL;
|
||||
printf("--[c++] bcXPCOMProxy::bcXPCOMProxy this: %p iid: %s\n",this, iid.ToString());
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--[c++] bcXPCOMProxy::bcXPCOMProxy this: %p iid: %s\n",this, iid.ToString()));
|
||||
}
|
||||
|
||||
bcXPCOMProxy::~bcXPCOMProxy() {
|
||||
@ -45,7 +47,8 @@ bcXPCOMProxy::~bcXPCOMProxy() {
|
||||
|
||||
|
||||
NS_IMETHODIMP bcXPCOMProxy::GetInterfaceInfo(nsIInterfaceInfo** info) {
|
||||
printf("--[c++] bcXPCOMProxy::GetInterfaceInfo iid=%s\n",iid.ToString());
|
||||
PRLogModuleInfo *log = bcXPCOMLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG,("--[c++] bcXPCOMProxy::GetInterfaceInfo iid=%s\n",iid.ToString()));
|
||||
if(!info) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -53,7 +56,7 @@ NS_IMETHODIMP bcXPCOMProxy::GetInterfaceInfo(nsIInterfaceInfo** info) {
|
||||
nsIInterfaceInfoManager* iimgr;
|
||||
if((iimgr = XPTI_GetInterfaceInfoManager())) {
|
||||
if (NS_FAILED(iimgr->GetInfoForIID(&iid, &interfaceInfo))) {
|
||||
printf("--bcXPCOMProxy::GetInterfaceInfo failed\n");
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--bcXPCOMProxy::GetInterfaceInfo failed\n"));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(iimgr);
|
||||
@ -69,7 +72,8 @@ NS_IMETHODIMP bcXPCOMProxy::GetInterfaceInfo(nsIInterfaceInfo** info) {
|
||||
NS_IMETHODIMP bcXPCOMProxy::CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
nsXPTCMiniVariant* params) {
|
||||
printf("--bcXPCOMProxy::CallMethod %s [%d]\n",info->GetName(),methodIndex);
|
||||
PRLogModuleInfo *log = bcXPCOMLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--bcXPCOMProxy::CallMethod %s [%d]\n",info->GetName(),methodIndex));
|
||||
bcICall *call = orb->CreateCall(&iid, &oid, methodIndex);
|
||||
bcIMarshaler *marshaler = call->GetMarshaler();
|
||||
bcXPCOMMarshalToolkit * mt = new bcXPCOMMarshalToolkit(methodIndex, interfaceInfo, params);
|
||||
@ -82,14 +86,16 @@ NS_IMETHODIMP bcXPCOMProxy::CallMethod(PRUint16 methodIndex,
|
||||
}
|
||||
|
||||
nsrefcnt bcXPCOMProxy::AddRef(void) {
|
||||
PRLogModuleInfo *log = bcXPCOMLog::GetLog();
|
||||
nsrefcnt cnt = (nsrefcnt) PR_AtomicIncrement((PRInt32*)&mRefCnt);
|
||||
printf("--[c++] bcXPCOMProxy::AddRef %d\n",(unsigned)cnt);
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--[c++] bcXPCOMProxy::AddRef %d\n",(unsigned)cnt));
|
||||
return cnt;
|
||||
}
|
||||
|
||||
nsrefcnt bcXPCOMProxy::Release(void) {
|
||||
PRLogModuleInfo *log = bcXPCOMLog::GetLog();
|
||||
nsrefcnt cnt = (nsrefcnt) PR_AtomicDecrement((PRInt32*)&mRefCnt);
|
||||
printf("--[c++] bcXPCOMProxy::Release %d\n",(unsigned)cnt);
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--[c++] bcXPCOMProxy::Release %d\n",(unsigned)cnt));
|
||||
if(0 == cnt) {
|
||||
delete this;
|
||||
}
|
||||
@ -98,6 +104,7 @@ nsrefcnt bcXPCOMProxy::Release(void) {
|
||||
|
||||
|
||||
NS_IMETHODIMP bcXPCOMProxy::QueryInterface(REFNSIID aIID, void** aInstancePtr) {
|
||||
PRLogModuleInfo *log = bcXPCOMLog::GetLog();
|
||||
PRUint16 methodIndex = 0;
|
||||
const nsXPTMethodInfo *info;
|
||||
nsIInterfaceInfo *inInfo;
|
||||
@ -111,10 +118,10 @@ NS_IMETHODIMP bcXPCOMProxy::QueryInterface(REFNSIID aIID, void** aInstancePtr) {
|
||||
params[1].val.p = aInstancePtr;
|
||||
nsresult r = CallMethod(methodIndex,info,params);
|
||||
if (*aInstancePtr == NULL) {
|
||||
printf("--bcXPCOMProxy.QueryInterface nointerface %s\n",aIID.ToString());
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--bcXPCOMProxy.QueryInterface nointerface %s\n",aIID.ToString()));
|
||||
r = NS_NOINTERFACE;
|
||||
}
|
||||
printf("--bcXPCOMProxy.QueryInterface we got interface %s\n",aIID.ToString());
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--bcXPCOMProxy.QueryInterface we got interface %s\n",aIID.ToString()));
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "xptcall.h"
|
||||
#include "bcXPCOMMarshalToolkit.h"
|
||||
#include "bcXPCOMStub.h"
|
||||
#include "bcXPCOMLog.h"
|
||||
|
||||
bcXPCOMStub::bcXPCOMStub(nsISupports *o) {
|
||||
object = o;
|
||||
@ -37,7 +38,7 @@ bcXPCOMStub::~bcXPCOMStub() {
|
||||
}
|
||||
|
||||
void bcXPCOMStub::Dispatch(bcICall *call) {
|
||||
|
||||
PRLogModuleInfo *log = bcXPCOMLog::GetLog();
|
||||
bcIID iid; bcOID oid; bcMID mid;
|
||||
call->GetParams(&iid, &oid, &mid);
|
||||
nsIInterfaceInfo *interfaceInfo;
|
||||
@ -56,7 +57,7 @@ void bcXPCOMStub::Dispatch(bcICall *call) {
|
||||
int paramCount = info->GetParamCount();
|
||||
bcXPCOMMarshalToolkit * mt = NULL;
|
||||
if (paramCount > 0) {
|
||||
printf("--[c++]bcXPCOMStub paramCount %d\n",paramCount);
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--[c++]bcXPCOMStub paramCount %d\n",paramCount));
|
||||
params = (nsXPTCVariant *) PR_Malloc(sizeof(nsXPTCVariant)*paramCount);
|
||||
mt = new bcXPCOMMarshalToolkit(mid, interfaceInfo, params);
|
||||
bcIUnMarshaler * um = call->GetUnMarshaler();
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "bcXPCOMStubsAndProxies.h"
|
||||
#include "bcXPCOMStub.h"
|
||||
#include "bcXPCOMProxy.h"
|
||||
#include "bcXPCOMLog.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(bcXPCOMStubsAndProxies);
|
||||
|
||||
@ -58,7 +59,8 @@ NS_IMETHODIMP bcXPCOMStubsAndProxies::GetStub(nsISupports *obj, bcIStub **stub)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcXPCOMStubsAndProxies::GetProxy(bcOID oid, const nsIID &iid, bcIORB *orb, nsISupports **proxy) {
|
||||
printf("--bcXPCOMStubsAndProxies::GetProxy iid=%s\n",iid.ToString());
|
||||
PRLogModuleInfo *log = bcXPCOMLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--bcXPCOMStubsAndProxies::GetProxy iid=%s\n",iid.ToString()));
|
||||
if (!proxy) {
|
||||
printf("--bcXPCOMStubsAndProxies::GetProxy failed\n");
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
@ -35,6 +35,7 @@ OBJS= \
|
||||
.\$(OBJDIR)\bcXPCOMStub.obj \
|
||||
.\$(OBJDIR)\bcXPCOMMarshalToolkit.obj \
|
||||
.\$(OBJDIR)\bcXPCOMStubsAndProxies.obj \
|
||||
.\$(OBJDIR)\bcXPCOMLog.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
Loading…
Reference in New Issue
Block a user