Bug 692342 - Remove use of IsReference() within XPConnect. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Fri, 25 Nov 2011 17:09:06 -0800
changeset 81584 c428312abbc783d7edfda2576ef649eff98090d7
parent 81583 2040980c0792dc99409d8a3e04d4cd027c0b84c3
child 81585 42ab175e8d8108c825b18d304146ae3465e0ca61
push idunknown
push userunknown
push dateunknown
reviewersmrbkap
bugs692342
milestone11.0a1
Bug 692342 - Remove use of IsReference() within XPConnect. r=mrbkap All we're doing is checking that various types aren't flagged as reference. But xpidl makes sure this doesn't happen, so we should just trust it instead.
js/xpconnect/src/XPCConvert.cpp
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -669,22 +669,16 @@ XPCConvert::JSData2Native(XPCCallContext
             NS_ERROR("void* params not supported");
             return JS_FALSE;
         case nsXPTType::T_IID:
         {
             JSObject* obj;
             const nsID* pid=nsnull;
 
             if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
-                if (type.IsReference()) {
-                    if (pErr)
-                        *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
-                    return JS_FALSE;
-                }
-                // else ...
                 *((const nsID**)d) = nsnull;
                 return JS_TRUE;
             }
 
             if (!JSVAL_IS_OBJECT(s) ||
                 (!(obj = JSVAL_TO_OBJECT(s))) ||
                 (!(pid = xpc_JSObjectToID(cx, obj))) ||
                 (!(pid = (const nsID*) nsMemory::Clone(pid, sizeof(nsID))))) {
@@ -773,22 +767,16 @@ XPCConvert::JSData2Native(XPCCallContext
                     ws->Assign(chars, length);
             }
             return JS_TRUE;
         }
 
         case nsXPTType::T_CHAR_STR:
         {
             if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
-                if (type.IsReference()) {
-                    if (pErr)
-                        *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
-                    return JS_FALSE;
-                }
-                // else ...
                 *((char**)d) = nsnull;
                 return JS_TRUE;
             }
 
             JSString* str = JS_ValueToString(cx, s);
             if (!str) {
                 return JS_FALSE;
             }
@@ -820,22 +808,16 @@ XPCConvert::JSData2Native(XPCCallContext
         }
 
         case nsXPTType::T_WCHAR_STR:
         {
             const jschar* chars=nsnull;
             JSString* str;
 
             if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
-                if (type.IsReference()) {
-                    if (pErr)
-                        *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
-                    return JS_FALSE;
-                }
-                // else ...
                 *((jschar**)d) = nsnull;
                 return JS_TRUE;
             }
 
             if (!(str = JS_ValueToString(cx, s))) {
                 return JS_FALSE;
             }
             if (!(chars = JS_GetStringCharsZ(cx, str))) {
@@ -978,22 +960,16 @@ XPCConvert::JSData2Native(XPCCallContext
                 if (!atom && pErr)
                     *pErr = NS_ERROR_OUT_OF_MEMORY;
                 *((nsISupports**)d) = atom;
                 return atom != nsnull;
             }
             //else ...
 
             if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
-                if (type.IsReference()) {
-                    if (pErr)
-                        *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
-                    return JS_FALSE;
-                }
-                // else ...
                 *((nsISupports**)d) = nsnull;
                 return JS_TRUE;
             }
 
             // only wrap JSObjects
             if (!JSVAL_IS_OBJECT(s) || !(obj = JSVAL_TO_OBJECT(s))) {
                 if (pErr && JSVAL_IS_INT(s) && 0 == JSVAL_TO_INT(s))
                     *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL;
@@ -1989,22 +1965,16 @@ XPCConvert::JSStringWithSize2Native(XPCC
         case nsXPTType::T_PSTRING_SIZE_IS:
         {
             if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
                 if (0 != count) {
                     if (pErr)
                         *pErr = NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING;
                     return JS_FALSE;
                 }
-                if (type.IsReference()) {
-                    if (pErr)
-                        *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
-                    return JS_FALSE;
-                }
-
                 if (0 != count) {
                     len = (count + 1) * sizeof(char);
                     if (!(*((void**)d) = nsMemory::Alloc(len)))
                         return JS_FALSE;
                     return JS_TRUE;
                 }
                 // else ...
 
@@ -2049,21 +2019,16 @@ XPCConvert::JSStringWithSize2Native(XPCC
             JSString* str;
 
             if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
                 if (0 != count) {
                     if (pErr)
                         *pErr = NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING;
                     return JS_FALSE;
                 }
-                if (type.IsReference()) {
-                    if (pErr)
-                        *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
-                    return JS_FALSE;
-                }
 
                 if (0 != count) {
                     len = (count + 1) * sizeof(jschar);
                     if (!(*((void**)d) = nsMemory::Alloc(len)))
                         return JS_FALSE;
                     return JS_TRUE;
                 }