From 121c854382a54528330b2f2b9d212186df4c9767 Mon Sep 17 00:00:00 2001 From: "nisheeth%netscape.com" Date: Fri, 8 Mar 2002 21:28:37 +0000 Subject: [PATCH] Fix for bug 125466. r=dougt, sr=jband, a=asa. Add AString, CString, and UTF8String support to the XPCOM proxy event mechanism VS: ---------------------------------------------------------------------- git-svn-id: svn://10.0.0.236/trunk@116186 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/proxy/src/nsProxyEvent.cpp | 84 +++++++++++++++++------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/mozilla/xpcom/proxy/src/nsProxyEvent.cpp b/mozilla/xpcom/proxy/src/nsProxyEvent.cpp index 8ca363d5ed6..e1ea6c7e117 100644 --- a/mozilla/xpcom/proxy/src/nsProxyEvent.cpp +++ b/mozilla/xpcom/proxy/src/nsProxyEvent.cpp @@ -49,6 +49,14 @@ #include "nsIAtom.h" //hack! Need a way to define a component as threadsafe (ie. sta). +/** + * Map the nsAUTF8String, nsUTF8String classes to the nsACString and + * nsCString classes respectively for now. These defines need to be removed + * once Jag lands his nsUTF8String implementation. + */ +#define nsAUTF8String nsACString +#define nsUTF8String nsCString + static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static void* PR_CALLBACK EventHandler(PLEvent *self); @@ -138,30 +146,62 @@ nsProxyObjectCallInfo::CopyStrings(PRBool copy) { const nsXPTType& type = paramInfo.GetType(); uint8 type_tag = type.TagPart(); + void *ptr = mParameterList[i].val.p; - if (type_tag == nsXPTType::T_CHAR_STR || type_tag == nsXPTType::T_WCHAR_STR) - { - if (mParameterList[i].val.p != nsnull) + if (!ptr) + continue; + + if (copy) + { + switch (type_tag) { - if (copy) - { - void *ptr = mParameterList[i].val.p; - - if (type_tag == nsXPTType::T_CHAR_STR) - { - mParameterList[i].val.p = - nsCRT::strdup((const char *)ptr); - } - else if (type_tag == nsXPTType::T_WCHAR_STR) - { - mParameterList[i].val.p = - nsCRT::strdup((const PRUnichar *)ptr); - } - } - else - { - Recycle((char*)mParameterList[i].val.p); - } + case nsXPTType::T_CHAR_STR: + mParameterList[i].val.p = + PL_strdup((const char *)ptr); + break; + case nsXPTType::T_WCHAR_STR: + mParameterList[i].val.p = + nsCRT::strdup((const PRUnichar *)ptr); + break; + case nsXPTType::T_DOMSTRING: + case nsXPTType::T_ASTRING: + mParameterList[i].val.p = + new nsString(*((nsAString*) ptr)); + break; + case nsXPTType::T_CSTRING: + mParameterList[i].val.p = + new nsCString(*((nsACString*) ptr)); + break; + case nsXPTType::T_UTF8STRING: + mParameterList[i].val.p = + new nsUTF8String(*((nsAUTF8String*) ptr)); + break; + default: + // Other types are ignored + break; + } + } + else + { + switch (type_tag) + { + case nsXPTType::T_CHAR_STR: + case nsXPTType::T_WCHAR_STR: + PL_strfree((char*) ptr); + break; + case nsXPTType::T_DOMSTRING: + case nsXPTType::T_ASTRING: + delete (nsString*) ptr; + break; + case nsXPTType::T_CSTRING: + delete (nsCString*) ptr; + break; + case nsXPTType::T_UTF8STRING: + delete (nsUTF8String*) ptr; + break; + default: + // Other types are ignored + break; } } }