From b1dc6babfdc11eca62182cfcf15bf98fcccabb3b Mon Sep 17 00:00:00 2001 From: "idk%eng.sun.com" Date: Tue, 15 May 2001 06:47:45 +0000 Subject: [PATCH] *not part of the build* fix for 57781, 57790 --- java/xpcom/connect/src/Marshaler.cpp | 52 ------------------- java/xpcom/connect/src/UnMarshaler.cpp | 53 -------------------- java/xpcom/java/src/bcJavaMarshalToolkit.cpp | 28 ++++++----- java/xpcom/java/test/bcJavaSample.cpp | 13 +++-- java/xpcom/java/test/bcJavaSample.java | 2 +- java/xpcom/xpcom/bcXPCOMMarshalToolkit.cpp | 26 ++++++---- 6 files changed, 42 insertions(+), 132 deletions(-) diff --git a/java/xpcom/connect/src/Marshaler.cpp b/java/xpcom/connect/src/Marshaler.cpp index b6e0d3d8906..e69de29bb2d 100644 --- a/java/xpcom/connect/src/Marshaler.cpp +++ b/java/xpcom/connect/src/Marshaler.cpp @@ -1,52 +0,0 @@ -/* -*- 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 - */ - -#include - -#include -#include "Marshaler.h" -#include "util.h" - -Marshaler::Marshaler(ostream *_out) { - out = _out; -} - -Marshaler::~Marshaler() { -} - -int Marshaler::WriteSimple(void *ptr, bcXPType type) { - out->write((const char*)ptr, type2size(type)); - return 0; -} - -int Marshaler::WriteString(void *ptr, size_t size) { - if (!size - && ptr) { - size = 1; - } - out->write((const char*)&size, sizeof(size_t)); - if (size) { - out->write((const char*)ptr,type2size(bc_T_CHAR)*size); - } - - return 0; -} diff --git a/java/xpcom/connect/src/UnMarshaler.cpp b/java/xpcom/connect/src/UnMarshaler.cpp index 6cbfde1486e..e69de29bb2d 100644 --- a/java/xpcom/connect/src/UnMarshaler.cpp +++ b/java/xpcom/connect/src/UnMarshaler.cpp @@ -1,53 +0,0 @@ -/* -*- 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 - */ - -#include "UnMarshaler.h" -#include "util.h" - -UnMarshaler::UnMarshaler(istream *_in) { - in = _in; -} - -UnMarshaler::~UnMarshaler() { -} - -int UnMarshaler::ReadSimple(void *ptr, bcXPType type) { - char *p = (char *)ptr; - int size = type2size(type); - in->read(p,size ); - return 0; -} -int UnMarshaler::ReadString(void *ptr, size_t *size, bcIAllocator * allocator) { - size_t length; - in->read((char*)size,sizeof(size_t)); - *(char**)ptr = (char *)allocator->Alloc(*size * type2size(bc_T_CHAR)); - if (*size) { - in->read(*(char**)ptr,*size * type2size(bc_T_CHAR)); - } - - if (*size == 1) { - if (!(*(char**)ptr)[0]) { - *size = 0; - } - } - return 0; -} diff --git a/java/xpcom/java/src/bcJavaMarshalToolkit.cpp b/java/xpcom/java/src/bcJavaMarshalToolkit.cpp index dfecb3490dc..e2b81ce8482 100644 --- a/java/xpcom/java/src/bcJavaMarshalToolkit.cpp +++ b/java/xpcom/java/src/bcJavaMarshalToolkit.cpp @@ -521,20 +521,24 @@ bcJavaMarshalToolkit::UnMarshalElement(jobject *value, uint8 ind, bcIUnMarshaler size_t size; 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)); + char *str; + um->ReadString(&str,&size,allocator); + if (str != NULL) { + { + 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*)str); + } else { + size-=2; size/=2; + data = env->NewString((const jchar*)str,size); + } + allocator->Free(str); + EXCEPTION_CHECKING(env); } - 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); } if ( ! isOut && (modifier == none) ) { diff --git a/java/xpcom/java/test/bcJavaSample.cpp b/java/xpcom/java/test/bcJavaSample.cpp index f063b10662d..cba413be22e 100644 --- a/java/xpcom/java/test/bcJavaSample.cpp +++ b/java/xpcom/java/test/bcJavaSample.cpp @@ -146,7 +146,7 @@ void test() { } //sigsend(P_PID, getpid(),SIGINT); //test->Test1(2000); -#if 1 +#if 0 test->Test1(1000); bcIJavaSample *test1; if (NS_FAILED(r)) { @@ -157,6 +157,7 @@ void test() { test->QueryInterface(NS_GET_IID(bcIJavaSample),(void**)&test1); int intArray[] = {1,2,3}; test->Test3(3, intArray); +#endif { char ** valueArray = (char **)malloc(sizeof(char*)*4); valueArray[0] = "hi"; @@ -169,6 +170,7 @@ void test() { printf("valueArray2[%d]=%s\n",i,(*valueArray2)[i]); } } +#if 0 { nsIComponentManager* cm; @@ -183,14 +185,18 @@ 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"; + //valueArray[3] = "b"; + + valueArray[3] = NULL; test->Test6(4,valueArray); } + { printf("--[c++]about to test7\n"); PRUint32 count; @@ -201,7 +207,7 @@ void test() { } printf("--[c++]end of test7\n"); } -#endif + { printf("--[c++]about to test8\n"); @@ -215,6 +221,7 @@ void test() { test->Test9(&cidParam); printf("--[c++]end of test9\n"); } +#endif printf("--BlackConnect test end\n"); } diff --git a/java/xpcom/java/test/bcJavaSample.java b/java/xpcom/java/test/bcJavaSample.java index 1709b0effcf..bb12fef93ee 100644 --- a/java/xpcom/java/test/bcJavaSample.java +++ b/java/xpcom/java/test/bcJavaSample.java @@ -97,7 +97,7 @@ public class bcJavaSample implements bcIJavaSample { for (int i = 0; i < array.length; i++) { System.out.println("--[java]bcJavaSample.test4 valueArray["+i+"] = "+array[i]); } - String[] returnArray = {"4","3","2","1"}; + String[] returnArray = {"4","3","2",null}; valueArray[0] = returnArray; } /* void test5 (in nsIComponentManager cm); */ diff --git a/java/xpcom/xpcom/bcXPCOMMarshalToolkit.cpp b/java/xpcom/xpcom/bcXPCOMMarshalToolkit.cpp index fec1256ea82..de994a62364 100644 --- a/java/xpcom/xpcom/bcXPCOMMarshalToolkit.cpp +++ b/java/xpcom/xpcom/bcXPCOMMarshalToolkit.cpp @@ -258,18 +258,22 @@ nsresult bcXPCOMMarshalToolkit::MarshalElement(bcIMarshaler *m, void *data, nsXP { data = *(char **)data; size_t length = 0; - if (type == nsXPTType::T_WCHAR_STR) { - length = nsCRT::strlen((const PRUnichar*)data); - PR_LOG(log, PR_LOG_DEBUG,("--[c++] bcXPCOMMarshalToolkit::MarshalElement T_WCHAR_STR length=%d\n",length)); - length *= 2; - length +=2; - 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)); + if (data != NULL) { + if (type == nsXPTType::T_WCHAR_STR) { + length = nsCRT::strlen((const PRUnichar*)data); + PR_LOG(log, PR_LOG_DEBUG, + ("--[c++] bcXPCOMMarshalToolkit::MarshalElement T_WCHAR_STR length=%d\n",length)); + length *= 2; + length +=2; + 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)); + } + } else { + length = nsCRT::strlen((const char*)data); + length+=1; } - } else { - length = nsCRT::strlen((const char*)data); - length+=1; } m->WriteString(data,length); break;