Bug 868715 part 9. Add tracing to WebIDL dictionary return values. r=peterv, a=lsblakk
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 20 May 2013 23:54:34 -0400
changeset 138516 6f0feec7b0b7b2831e1b64342d0474fe149c260c
parent 138515 41e2ba420e4450c9b9fcf015a4529b4c7f8d05cd
child 138517 671534d5aa664a0b4be54f33b38c1cb77203622d
push id3776
push userbzbarsky@mozilla.com
push dateTue, 21 May 2013 03:55:12 +0000
treeherdermozilla-aurora@671534d5aa66 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv, lsblakk
bugs868715
milestone23.0a2
Bug 868715 part 9. Add tracing to WebIDL dictionary return values. r=peterv, a=lsblakk
dom/bindings/Codegen.py
dom/bindings/test/TestBindingHeader.h
dom/bindings/test/TestCodeGen.webidl
dom/bindings/test/TestExampleGen.webidl
dom/bindings/test/TestJSImplGen.webidl
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -4161,23 +4161,28 @@ def getRetvalDeclarationForType(returnTy
         else:
             rooter = None
         result = CGTemplatedType("nsTArray", result)
         if nullable:
             result = CGTemplatedType("Nullable", result)
         return result, True, rooter
     if returnType.isDictionary():
         nullable = returnType.nullable()
-        result = CGGeneric(
-            CGDictionary.makeDictionaryName(returnType.unroll().inner,
-                                            descriptorProvider.workers) +
-            "Initializer")
+        dictName = (CGDictionary.makeDictionaryName(returnType.unroll().inner,
+                                                    descriptorProvider.workers) +
+                    "Initializer")
+        result = CGGeneric(dictName)
+        if not isMember and typeNeedsCx(returnType, descriptorProvider):
+            rooter = CGGeneric("DictionaryRooter<%s> resultRooter(cx);\n"
+                               "resultRooter.SetDictionary(&result);" % dictName)
+        else:
+            rooter = None
         if nullable:
             result = CGTemplatedType("Nullable", result)
-        return result, True, None
+        return result, True, rooter
     if returnType.isUnion():
         raise TypeError("Need to sort out ownership model for union retvals");
     if returnType.isDate():
         result = CGGeneric("Date")
         if returnType.nullable():
             result = CGTemplatedType("Nullable", result)
         return result, False, None
     raise TypeError("Don't know how to declare return value for %s" %
--- a/dom/bindings/test/TestBindingHeader.h
+++ b/dom/bindings/test/TestBindingHeader.h
@@ -505,16 +505,17 @@ public:
   void MethodRenamedTo(int8_t);
   int8_t AttributeGetterRenamedTo();
   int8_t AttributeRenamedTo();
   void SetAttributeRenamedTo(int8_t);
 
   // Dictionary tests
   void PassDictionary(JSContext*, const Dict&);
   void ReceiveDictionary(JSContext*, Dict&);
+  void ReceiveNullableDictionary(JSContext*, Nullable<DictInitializer>&);
   void PassOtherDictionary(const GrandparentDict&);
   void PassSequenceOfDictionaries(JSContext*, const Sequence<Dict>&);
   void PassDictionaryOrLong(JSContext*, const Dict&);
   void PassDictionaryOrLong(int32_t);
   void PassDictContainingDict(JSContext*, const DictContainingDict&);
   void PassDictContainingSequence(JSContext*, const DictContainingSequence&);
   void ReceiveDictContainingSequence(JSContext*, DictContainingSequence&);
 
--- a/dom/bindings/test/TestCodeGen.webidl
+++ b/dom/bindings/test/TestCodeGen.webidl
@@ -462,16 +462,17 @@ interface TestInterface {
   // binaryNames tests
   void methodRenamedFrom();
   void methodRenamedFrom(byte argument);
   readonly attribute byte attributeGetterRenamedFrom;
   attribute byte attributeRenamedFrom;
 
   void passDictionary(optional Dict x);
   Dict receiveDictionary();
+  Dict? receiveNullableDictionary();
   void passOtherDictionary(optional GrandparentDict x);
   void passSequenceOfDictionaries(sequence<Dict> x);
   // No support for nullable dictionaries inside a sequence (nor should there be)
   //  void passSequenceOfNullableDictionaries(sequence<Dict?> x);
   void passDictionaryOrLong(optional Dict x);
   void passDictionaryOrLong(long x);
 
   void passDictContainingDict(optional DictContainingDict arg);
--- a/dom/bindings/test/TestExampleGen.webidl
+++ b/dom/bindings/test/TestExampleGen.webidl
@@ -359,17 +359,19 @@ interface TestExampleInterface {
 
   // binaryNames tests
   void methodRenamedFrom();
   void methodRenamedFrom(byte argument);
   readonly attribute byte attributeGetterRenamedFrom;
   attribute byte attributeRenamedFrom;
 
   void passDictionary(optional Dict x);
-  //UNSUPPORTED  Dict receiveDictionary();
+  // FIXME: Bug 863949 no dictionary return values in callbacks
+  // Dict receiveDictionary();
+  // Dict? receiveNullableDictionary();
   void passOtherDictionary(optional GrandparentDict x);
   void passSequenceOfDictionaries(sequence<Dict> x);
   // No support for nullable dictionaries inside a sequence (nor should there be)
   //  void passSequenceOfNullableDictionaries(sequence<Dict?> x);
   void passDictionaryOrLong(optional Dict x);
   void passDictionaryOrLong(long x);
 
   void passDictContainingDict(optional DictContainingDict arg);
--- a/dom/bindings/test/TestJSImplGen.webidl
+++ b/dom/bindings/test/TestJSImplGen.webidl
@@ -386,16 +386,17 @@ interface TestJSImplInterface {
   void methodRenamedFrom();
   void methodRenamedFrom(byte argument);
   readonly attribute byte attributeGetterRenamedFrom;
   attribute byte attributeRenamedFrom;
 
   void passDictionary(optional Dict x);
   // FIXME: Bug 863949 no dictionary return values
   //   Dict receiveDictionary();
+  //   Dict? receiveNullableDictionary();
   void passOtherDictionary(optional GrandparentDict x);
   void passSequenceOfDictionaries(sequence<Dict> x);
   // No support for nullable dictionaries inside a sequence (nor should there be)
   //  void passSequenceOfNullableDictionaries(sequence<Dict?> x);
   void passDictionaryOrLong(optional Dict x);
   void passDictionaryOrLong(long x);
 
   void passDictContainingDict(optional DictContainingDict arg);