Bug 692342 - Introduce deprecated_IsPointer() to handle the cases that are too mucky to figure out right now. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Fri, 25 Nov 2011 17:09:06 -0800
changeset 80787 e8df70ae53e2b693d2a16b2bda022cbb7e7eef47
parent 80786 42ab175e8d8108c825b18d304146ae3465e0ca61
child 80788 8790687685ee53327539a05ae6636c6f6ddfcb29
push id21530
push userbmo@edmorley.co.uk
push dateSat, 26 Nov 2011 08:27:28 +0000
treeherdermozilla-central@c58bad0b4640 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs692342
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 692342 - Introduce deprecated_IsPointer() to handle the cases that are too mucky to figure out right now. r=mrbkap
js/xpconnect/src/XPCWrappedJSClass.cpp
xpcom/reflect/xptinfo/public/xptinfo.h
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -1466,34 +1466,34 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
 pre_call_clean_up:
     // clean up any 'out' params handed in
     for (i = 0; i < paramCount; i++) {
         const nsXPTParamInfo& param = info->params[i];
         if (!param.IsOut())
             continue;
 
         const nsXPTType& type = param.GetType();
-        if (!type.IsPointer())
+        if (!type.deprecated_IsPointer())
             continue;
         void* p;
         if (!(p = nativeParams[i].val.p))
             continue;
 
         if (param.IsIn()) {
             if (type.IsArray()) {
                 void** pp;
                 if (nsnull != (pp = *((void***)p))) {
 
                     // we need to get the array length and iterate the items
                     JSUint32 array_count;
                     nsXPTType datum_type;
 
                     if (NS_SUCCEEDED(mInfo->GetTypeForParam(methodIndex, &param,
                                                             1, &datum_type)) &&
-                        datum_type.IsPointer() &&
+                        datum_type.deprecated_IsPointer() &&
                         GetArraySizeFromParam(cx, info, param, methodIndex,
                                               i, nativeParams, &array_count) &&
                         array_count) {
 
                         CleanupPointerArray(datum_type, array_count, pp);
                     }
 
                     // always release the array if it is inout
@@ -1695,32 +1695,32 @@ pre_call_clean_up:
         // We didn't manage all the result conversions!
         // We have to cleanup any junk that *did* get converted.
 
         for (uint8 k = 0; k < i; k++) {
             const nsXPTParamInfo& param = info->params[k];
             if (!param.IsOut())
                 continue;
             const nsXPTType& type = param.GetType();
-            if (!type.IsPointer())
+            if (!type.deprecated_IsPointer())
                 continue;
             void* p;
             if (!(p = nativeParams[k].val.p))
                 continue;
 
             if (type.IsArray()) {
                 void** pp;
                 if (nsnull != (pp = *((void***)p))) {
                     // we need to get the array length and iterate the items
                     JSUint32 array_count;
                     nsXPTType datum_type;
 
                     if (NS_SUCCEEDED(mInfo->GetTypeForParam(methodIndex, &param,
                                                             1, &datum_type)) &&
-                        datum_type.IsPointer() &&
+                        datum_type.deprecated_IsPointer() &&
                         GetArraySizeFromParam(cx, info, param, methodIndex,
                                               k, nativeParams, &array_count) &&
                         array_count) {
 
                         CleanupPointerArray(datum_type, array_count, pp);
                     }
                     nsMemory::Free(pp);
                 }
--- a/xpcom/reflect/xptinfo/public/xptinfo.h
+++ b/xpcom/reflect/xptinfo/public/xptinfo.h
@@ -72,19 +72,34 @@ public:
         {return flags;}
 
     bool IsPointer() const
         {return 0 != (XPT_TDP_IS_POINTER(flags));}
 
     bool IsReference() const
         {return 0 != (XPT_TDP_IS_REFERENCE(flags));}
 
-    bool IsArithmetic() const     // terminology from Harbison/Steele
+    // 'Arithmetic' here roughly means that the value is self-contained and
+    // doesn't depend on anything else in memory (ie: not a pointer, not an
+    // XPCOM object, not a jsval, etc).
+    //
+    // Supposedly this terminology comes from Harbison/Steele, but it's still
+    // a rather crappy name. We'd change it if it wasn't used all over the
+    // place in xptcall. :-(
+    bool IsArithmetic() const
         {return flags <= T_WCHAR;}
 
+    // We used to abuse 'pointer' flag bit in typelib format quite extensively.
+    // We've gotten rid of most of the cases, but there's still a fair amount
+    // of refactoring to be done in XPCWrappedJSClass before we can safely stop
+    // asking about this. In the mean time, we've got a temporary version of
+    // IsPointer() that should be equivalent to what's in the typelib.
+    bool deprecated_IsPointer() const
+        {return !IsArithmetic() && TagPart() != T_JSVAL;}
+
     bool IsInterfacePointer() const
         {  switch (TagPart()) {
              default:
                return false;
              case T_INTERFACE:
              case T_INTERFACE_IS:
                return true;
            }