Bug 767930. Add support for typed array return values (as just JSObject*) in WebIDL bindings. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 28 Aug 2012 13:10:09 -0400
changeset 105711 cfd19083d2989e51e367f6ff0d9341ad3e8b2c75
parent 105710 62b86f439a09333d52db9d69e2023a1b0002fbc5
child 105712 561f1e6ccdc9e7efe9a4e17e35a1cc0d937a4522
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewerspeterv
bugs767930
milestone18.0a1
Bug 767930. Add support for typed array return values (as just JSObject*) in WebIDL bindings. r=peterv
dom/bindings/Codegen.py
dom/bindings/test/TestBindingHeader.h
dom/bindings/test/TestCodeGen.webidl
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -2665,17 +2665,17 @@ if (!%(resultStr)s) {
         return (setValue("JS::ObjectOrNullValue(%s)" % result, True), False)
 
     if type.tag() == IDLType.Tags.any:
         # See comments in WrapNewBindingObject explaining why we need
         # to wrap here.
         # NB: setValue(..., True) calls JS_WrapValue(), so is fallible
         return (setValue(result, True), False)
 
-    if type.isObject():
+    if type.isObject() or type.isSpiderMonkeyInterface():
         # See comments in WrapNewBindingObject explaining why we need
         # to wrap here.
         if type.nullable():
             toValue = "JS::ObjectOrNullValue(%s)"
         else:
             toValue = "JS::ObjectValue(*%s)"
         # NB: setValue(..., True) calls JS_WrapValue(), so is fallible
         return (setValue(toValue % result, True), False)
@@ -2789,17 +2789,17 @@ def getRetvalDeclarationForType(returnTy
             result = CGWrapper(result, post="*")
         return result, False
     if returnType.isCallback():
         # XXXbz we're going to assume that callback types are always
         # nullable for now.
         return CGGeneric("JSObject*"), False
     if returnType.tag() is IDLType.Tags.any:
         return CGGeneric("JS::Value"), False
-    if returnType.isObject():
+    if returnType.isObject() or returnType.isSpiderMonkeyInterface():
         return CGGeneric("JSObject*"), False
     if returnType.isSequence():
         nullable = returnType.nullable()
         if nullable:
             returnType = returnType.inner
         # If our result is already addrefed, use the right type in the
         # sequence argument here.
         (result, _) = getRetvalDeclarationForType(returnType.inner,
--- a/dom/bindings/test/TestBindingHeader.h
+++ b/dom/bindings/test/TestBindingHeader.h
@@ -325,16 +325,17 @@ public:
   void PassInt16Array(Int16Array&, ErrorResult&);
   void PassInt32Array(Int32Array&, ErrorResult&);
   void PassUint8Array(Uint8Array&, ErrorResult&);
   void PassUint16Array(Uint16Array&, ErrorResult&);
   void PassUint32Array(Uint32Array&, ErrorResult&);
   void PassUint8ClampedArray(Uint8ClampedArray&, ErrorResult&);
   void PassFloat32Array(Float32Array&, ErrorResult&);
   void PassFloat64Array(Float64Array&, ErrorResult&);
+  JSObject* ReceiveUint8Array(ErrorResult&);
 
   // String types
   void PassString(const nsAString&, ErrorResult&);
   void PassNullableString(const nsAString&, ErrorResult&);
   void PassOptionalString(const Optional<nsAString>&, ErrorResult&);
   void PassOptionalStringWithDefaultValue(const nsAString&, ErrorResult&);
   void PassOptionalNullableString(const Optional<nsAString>&, ErrorResult&);
   void PassOptionalNullableStringWithDefaultValue(const nsAString&, ErrorResult&);
--- a/dom/bindings/test/TestCodeGen.webidl
+++ b/dom/bindings/test/TestCodeGen.webidl
@@ -223,16 +223,17 @@ interface TestInterface {
   void passInt16Array(Int16Array arg);
   void passInt32Array(Int32Array arg);
   void passUint8Array(Uint8Array arg);
   void passUint16Array(Uint16Array arg);
   void passUint32Array(Uint32Array arg);
   void passUint8ClampedArray(Uint8ClampedArray arg);
   void passFloat32Array(Float32Array arg);
   void passFloat64Array(Float64Array arg);
+  Uint8Array receiveUint8Array();
 
   // String types
   void passString(DOMString arg);
   void passNullableString(DOMString? arg);
   void passOptionalString(optional DOMString arg);
   void passOptionalStringWithDefaultValue(optional DOMString arg = "abc");
   void passOptionalNullableString(optional DOMString? arg);
   void passOptionalNullableStringWithDefaultValue(optional DOMString? arg = null);