Bug 816842. Clean up jsval return values in quickstubs a bit. r=bholley, a=akeybl
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 06 Dec 2012 15:21:18 -0500
changeset 82113 d5d599c8613216cb168b53346ffca845cd11755b
parent 82112 9bd7cdfc311fd359203a875b9337228457c1db15
child 82114 02cd40b937415b856fefeaf057e8ced8146d3780
push id361
push userbzbarsky@mozilla.com
push dateSat, 22 Dec 2012 02:57:11 +0000
reviewersbholley, akeybl
bugs816842
milestone10.0.11esrpre
Bug 816842. Clean up jsval return values in quickstubs a bit. r=bholley, a=akeybl
js/xpconnect/src/qsgen.py
--- a/js/xpconnect/src/qsgen.py
+++ b/js/xpconnect/src/qsgen.py
@@ -614,35 +614,32 @@ def writeResultDecl(f, type, varname):
             f.write("    %s %s;\n" % (typeName, varname))
             return
     elif t.kind == 'native':
         name = getBuiltinOrNativeTypeName(t)
         if name in ('[domstring]', '[astring]'):
             f.write("    nsString %s;\n" % varname)
             return
         elif name == '[jsval]':
-            return  # nothing to declare; see special case in outParamForm
+            f.write("    jsval %s;\n" % varname)
+            return
     elif t.kind in ('interface', 'forward'):
         f.write("    nsCOMPtr<%s> %s;\n" % (type.name, varname))
         return
 
     warn("Unable to declare result of type %s" % type.name)
     f.write("    !; // TODO - Declare out parameter `%s`.\n" % varname)
 
 def outParamForm(name, type):
     type = unaliasType(type)
-    # If we start allowing [jsval] return types here, we need to tack
-    # the return value onto the arguments list in the callers,
-    # possibly, and handle properly returning it too.  See bug 604198.
-    assert getBuiltinOrNativeTypeName(type) is not '[jsval]'
     if type.kind == 'builtin':
         return '&' + name
     elif type.kind == 'native':
         if getBuiltinOrNativeTypeName(type) == '[jsval]':
-            return 'vp'
+            return '&' + name
         elif type.modifier == 'ref':
             return name
         else:
             return '&' + name
     else:
         return 'getter_AddRefs(%s)' % name
 
 # From NativeData2JS.
@@ -687,19 +684,18 @@ resultConvTemplates = {
 
     '[astring]':
         "    return xpc_qsStringToJsval(cx, result, ${jsvalPtr});\n",
 
     '[domstring]':
         "    return xpc_qsStringToJsval(cx, result, ${jsvalPtr});\n",
 
     '[jsval]':
-        # Here there's nothing to convert, because the result has already been
-        # written directly to *rv. See the special case in outParamForm.
-        "    return JS_TRUE;\n"
+        "    ${jsvalRef} = result;\n"
+        "    return JS_WrapValue(cx, ${jsvalPtr});\n"
     }
 
 def isVariantType(t):
     return isSpecificInterfaceType(t, 'nsIVariant')
 
 def writeResultConv(f, type, jsvalPtr, jsvalRef):
     """ Emit code to convert the C++ variable `result` to a jsval.