mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
*not part of the build*
fix for 80867
This commit is contained in:
parent
b568072a67
commit
7ab070f1eb
@ -19,33 +19,34 @@
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "bcIIDJava.h"
|
||||
#include "bcJavaGlobal.h"
|
||||
|
||||
jclass bcIIDJava::iidClass = NULL;
|
||||
jmethodID bcIIDJava::iidInitMID = NULL;
|
||||
jmethodID bcIIDJava::getStringMID = NULL;
|
||||
|
||||
static nsID nullID = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
|
||||
|
||||
void bcIIDJava::Init(void) {
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
if (env) {
|
||||
if (!(iidClass = env->FindClass("org/mozilla/xpcom/IID"))
|
||||
|| !(iidClass = (jclass) env->NewGlobalRef(iidClass))) {
|
||||
env->ExceptionDescribe();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
if (!(iidInitMID = env->GetMethodID(iidClass,"<init>","(Ljava/lang/String;)V"))) {
|
||||
env->ExceptionDescribe();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
if (!(getStringMID = env->GetMethodID(iidClass,"getString","()Ljava/lang/String;"))) {
|
||||
env->ExceptionDescribe();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
if (!(iidClass = env->FindClass("org/mozilla/xpcom/IID"))
|
||||
|| !(iidClass = (jclass) env->NewGlobalRef(iidClass))) {
|
||||
env->ExceptionDescribe();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
if (!(iidInitMID = env->GetMethodID(iidClass,"<init>","(Ljava/lang/String;)V"))) {
|
||||
env->ExceptionDescribe();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
if (!(getStringMID = env->GetMethodID(iidClass,"getString","()Ljava/lang/String;"))) {
|
||||
env->ExceptionDescribe();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void bcIIDJava::Destroy() {
|
||||
@ -61,18 +62,19 @@ void bcIIDJava::Destroy() {
|
||||
jobject bcIIDJava::GetObject(nsIID *iid) {
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
if (!iid
|
||||
|| !env ) {
|
||||
return NULL;
|
||||
|| !env
|
||||
|| nullID.Equals(*iid)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!iidClass) {
|
||||
Init();
|
||||
}
|
||||
Init();
|
||||
}
|
||||
char *str = iid->ToString(); //nb free ?
|
||||
jstring jstr = NULL;
|
||||
if (str) {
|
||||
char *siid = str+1; //we do need to have it. The format is {_xxx-xxx-xxx_}
|
||||
siid[strlen(siid)-1] = 0;
|
||||
jstr = env->NewStringUTF((const char *)siid);
|
||||
char *siid = str+1; //we do need to have it. The format is {_xxx-xxx-xxx_}
|
||||
siid[strlen(siid)-1] = 0;
|
||||
jstr = env->NewStringUTF((const char *)siid);
|
||||
}
|
||||
return env->NewObject(iidClass,iidInitMID,jstr);
|
||||
}
|
||||
@ -85,15 +87,18 @@ nsIID bcIIDJava::GetIID(jobject obj) {
|
||||
nsIID iid;
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
if (env) {
|
||||
if (!iidClass) {
|
||||
Init();
|
||||
}
|
||||
jstring jstr = (jstring)env->CallObjectMethod(obj, getStringMID);
|
||||
const char * str = NULL;
|
||||
str = env->GetStringUTFChars(jstr,NULL);
|
||||
iid.Parse(str);
|
||||
env->ReleaseStringUTFChars(jstr,str);
|
||||
|
||||
if (!iidClass) {
|
||||
Init();
|
||||
}
|
||||
if (obj != NULL) {
|
||||
jstring jstr = (jstring)env->CallObjectMethod(obj, getStringMID);
|
||||
const char * str = NULL;
|
||||
str = env->GetStringUTFChars(jstr,NULL);
|
||||
iid.Parse(str);
|
||||
env->ReleaseStringUTFChars(jstr,str);
|
||||
} else {
|
||||
iid = nullID;
|
||||
}
|
||||
}
|
||||
return iid;
|
||||
}
|
||||
|
@ -5,12 +5,14 @@
|
||||
[scriptable, uuid(ca1e2656-1dd1-11b2-9c4e-f49ea557abde)]
|
||||
interface bcIJavaSample : nsISupports
|
||||
{
|
||||
void test0();
|
||||
void test1(in long l);
|
||||
void test2(in bcIJavaSample o);
|
||||
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);
|
||||
void test0();
|
||||
void test1(in long l);
|
||||
void test2(in bcIJavaSample o);
|
||||
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);
|
||||
void test8(in nsCIDRef cid);
|
||||
void test9(out nsIIDPtr po);
|
||||
};
|
||||
|
@ -113,6 +113,24 @@ NS_IMETHODIMP bcJavaSample::Test6(PRUint32 count, const char **valueArray) {
|
||||
NS_IMETHODIMP bcJavaSample::Test7(PRUint32 *count, char **valueArray) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void test8 (in nsCIDRef cid); */
|
||||
NS_IMETHODIMP bcJavaSample::Test8(const nsCID & cid) {
|
||||
|
||||
printf("--[c++]bcJavaSample::Test8 %s\n",cid.ToString());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void test9 (out nsIIDPtr po); */
|
||||
NS_IMETHODIMP bcJavaSample::Test9(nsIID * *po) {
|
||||
if (po != NULL) {
|
||||
printf("--[c++]bcJavaSample::Test9 %s\n", (*po)->ToString());
|
||||
} else {
|
||||
printf("--[c++]bcJavaSample::Test9 %s\n", "null");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void test() {
|
||||
printf("--BlackConnect test start\n");
|
||||
nsresult r;
|
||||
@ -128,7 +146,7 @@ void test() {
|
||||
}
|
||||
//sigsend(P_PID, getpid(),SIGINT);
|
||||
//test->Test1(2000);
|
||||
|
||||
#if 1
|
||||
test->Test1(1000);
|
||||
bcIJavaSample *test1;
|
||||
if (NS_FAILED(r)) {
|
||||
@ -183,7 +201,20 @@ void test() {
|
||||
}
|
||||
printf("--[c++]end of test7\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
{
|
||||
printf("--[c++]about to test8\n");
|
||||
|
||||
test->Test8(NS_GET_IID(bcIJavaSample));
|
||||
printf("--[c++]end of test8\n");
|
||||
}
|
||||
{
|
||||
nsCID cid = NS_GET_IID(bcIJavaSample);
|
||||
nsCID *cidParam = &cid;
|
||||
printf("--[c++]about to test9\n");
|
||||
test->Test9(&cidParam);
|
||||
printf("--[c++]end of test9\n");
|
||||
}
|
||||
printf("--BlackConnect test end\n");
|
||||
}
|
||||
|
||||
|
@ -145,6 +145,16 @@ public class bcJavaSample implements bcIJavaSample {
|
||||
count[0] = retValue.length;
|
||||
valueArray[0] = retValue;
|
||||
}
|
||||
/* void test8 (in nsCIDRef cid); */
|
||||
public void test8(CID cid) {
|
||||
System.out.println("--[java]bcJavaSample.test8 "+cid);
|
||||
}
|
||||
|
||||
/* void test9 (out nsIIDPtr po); */
|
||||
public void test9(IID[] po) {
|
||||
System.out.println("--[java]bcJavaSample::Test9 "+po[0]);
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
Class nsIComponentManagerClass =
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "bcXPCOMLog.h"
|
||||
|
||||
static NS_DEFINE_CID(kXPCOMStubsAndProxies,BC_XPCOMSTUBSANDPROXIES_CID);
|
||||
static nsID nullID = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
|
||||
|
||||
bcXPCOMMarshalToolkit::bcXPCOMMarshalToolkit(PRUint16 _methodIndex, nsIInterfaceInfo *_interfaceInfo,
|
||||
nsXPTCMiniVariant* _params, bcIORB *_orb) {
|
||||
@ -232,7 +233,11 @@ nsresult bcXPCOMMarshalToolkit::MarshalElement(bcIMarshaler *m, void *data, nsXP
|
||||
nsresult r = NS_OK;
|
||||
switch(type) {
|
||||
case nsXPTType::T_IID :
|
||||
data = *(char**)data;
|
||||
if (data == NULL) {
|
||||
data = &nullID;
|
||||
} else {
|
||||
data = *(char**)data;
|
||||
}
|
||||
case nsXPTType::T_I8 :
|
||||
case nsXPTType::T_I16 :
|
||||
case nsXPTType::T_I32 :
|
||||
@ -258,7 +263,7 @@ nsresult bcXPCOMMarshalToolkit::MarshalElement(bcIMarshaler *m, void *data, nsXP
|
||||
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++) {
|
||||
for (unsigned 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));
|
||||
}
|
||||
@ -350,8 +355,17 @@ bcXPCOMMarshalToolkit::UnMarshalElement(void *data, bcIUnMarshaler *um, nsXPTPar
|
||||
nsresult r = NS_OK;
|
||||
switch(type) {
|
||||
case nsXPTType::T_IID :
|
||||
*(char**)data = (char*)new nsIID(); //nb memory leak. how are we going to release it
|
||||
data = *(char**)data;
|
||||
{
|
||||
nsID *id = new nsID();
|
||||
um->ReadSimple(id,XPTType2bcXPType(type));
|
||||
if (nullID.Equals(*id)) {
|
||||
delete id;
|
||||
*(char**)data = NULL;
|
||||
} else {
|
||||
*(char**)data = (char*)id;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case nsXPTType::T_I8 :
|
||||
case nsXPTType::T_I16 :
|
||||
case nsXPTType::T_I32 :
|
||||
|
Loading…
Reference in New Issue
Block a user