Bug 816842. Clean up jsval return values in quickstubs a bit. r=bholley, a=bajaj
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 06 Dec 2012 15:21:18 -0500
changeset 109921 69f1c373450db03a9b00a7e52b56441981ef49a7
parent 109920 93926d2bb8ce24c0064ea2ed446bbed0178a0594
child 109922 807edeff94f6aa1aa0f63431c2d2bb5ca19d4f89
push id58
push userbzbarsky@mozilla.com
push dateTue, 11 Dec 2012 22:16:54 +0000
reviewersbholley, bajaj
bugs816842
milestone17.0.1esrpre
Bug 816842. Clean up jsval return values in quickstubs a bit. r=bholley, a=bajaj
js/xpconnect/src/qsgen.py
--- a/js/xpconnect/src/qsgen.py
+++ b/js/xpconnect/src/qsgen.py
@@ -592,35 +592,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.
@@ -669,19 +666,18 @@ resultConvTemplates = {
 
     '[astring]':
         "    return xpc::StringToJsval(cx, result, ${jsvalPtr});\n",
 
     '[domstring]':
         "    return xpc::StringToJsval(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.