Bug 779573 - Fix generated code for empty string as default dictionary member in WebIDL. r=khuey
authorWilliam Chen <wchen@mozilla.com>
Wed, 01 Aug 2012 14:34:36 -0400
changeset 101192 71531b2ece95f1f3058758d4fba9135d904ecebd
parent 101191 88e900fd365e2086ce4933e686891e429b30e585
child 101193 4141cfa136851e0265e85797e8c16fcd1ea65bc3
push id12890
push userryanvm@gmail.com
push dateThu, 02 Aug 2012 02:23:58 +0000
treeherdermozilla-inbound@71531b2ece95 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs779573
milestone17.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 779573 - Fix generated code for empty string as default dictionary member in WebIDL. r=khuey
dom/bindings/Codegen.py
dom/bindings/test/TestCodeGen.webidl
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -2051,19 +2051,19 @@ for (uint32_t i = 0; i < length; ++i) {
                 return conversionCode
 
             if isinstance(defaultValue, IDLNullValue):
                 assert(type.nullable())
                 return handleDefault(conversionCode,
                                      "%s.SetNull()" % varName)
             return handleDefault(
                 conversionCode,
-                ("static const PRUnichar data[] = { %s, 0 };\n"
+                ("static const PRUnichar data[] = { %s };\n"
                  "%s.SetData(data, ArrayLength(data) - 1)" %
-                 (", ".join("'" + char + "'" for char in defaultValue.value),
+                 (", ".join(["'" + char + "'" for char in defaultValue.value] + ["0"]),
                   varName)))
 
         if isMember:
             # We have to make a copy, because our jsval may well not
             # live as long as our string needs to.
             declType = CGGeneric("nsString")
             return (
                 "{\n"
--- a/dom/bindings/test/TestCodeGen.webidl
+++ b/dom/bindings/test/TestCodeGen.webidl
@@ -352,16 +352,17 @@ DiamondBranch1B implements DiamondImplem
 
 dictionary Dict : ParentDict {
   TestEnum someEnum;
   long x;
   long a;
   long b = 8;
   long z = 9;
   DOMString str;
+  DOMString empty = "";
   TestEnum otherEnum = "b";
   DOMString otherStr = "def";
   DOMString? yetAnotherStr = null;
 };
 
 dictionary ParentDict : GrandparentDict {
   long c = 5;
   TestInterface someInterface;