Bug 1048437. Allow dictionary members with '-' in the name. r=khuey
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 04 Aug 2014 15:02:58 -0400
changeset 198206 dadbbe7b22f186faa9ae1738d4510df4ecf3bf55
parent 198205 43529d2194a0ada7256e0e6e940a8984883cfef2
child 198207 7fbd6ef4f882d535a452c5232016fad2300547ac
push id27264
push usernigelbabu@gmail.com
push dateThu, 07 Aug 2014 03:31:37 +0000
treeherdermozilla-central@afcb3af79d09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1048437
milestone34.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 1048437. Allow dictionary members with '-' in the name. r=khuey
dom/bindings/Codegen.py
dom/bindings/parser/WebIDL.py
dom/bindings/test/TestCodeGen.webidl
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -11162,17 +11162,17 @@ class CGDictionary(CGThing):
     def makeDictionaryName(dictionary):
         return dictionary.identifier.name
 
     def makeClassName(self, dictionary):
         return self.makeDictionaryName(dictionary)
 
     @staticmethod
     def makeMemberName(name):
-        return "m" + name[0].upper() + name[1:]
+        return "m" + name[0].upper() + name[1:].replace("-", "_")
 
     def getMemberType(self, memberInfo):
         _, conversionInfo = memberInfo
         # We can't handle having a holderType here
         assert conversionInfo.holderType is None
         declType = conversionInfo.declType
         if conversionInfo.dealWithOptional:
             declType = CGTemplatedType("Optional", declType)
@@ -11346,17 +11346,17 @@ class CGDictionary(CGThing):
         if type.isAny():
             return "JS::UndefinedValue()"
         if type.isObject():
             return "nullptr"
         return None
 
     @staticmethod
     def makeIdName(name):
-        return name + "_id"
+        return name.replace("-", "_") + "_id"
 
     @staticmethod
     def getDictionaryDependenciesFromType(type):
         if type.isDictionary():
             return set([type.unroll().inner])
         if type.isSequence() or type.isArray():
             return CGDictionary.getDictionaryDependenciesFromType(type.unroll())
         return set()
--- a/dom/bindings/parser/WebIDL.py
+++ b/dom/bindings/parser/WebIDL.py
@@ -4054,17 +4054,17 @@ class Tokenizer(object):
             raise WebIDLError("Invalid integer literal",
                               [Location(lexer=self.lexer,
                                         lineno=self.lexer.lineno,
                                         lexpos=self.lexer.lexpos,
                                         filename=self._filename)])
         return t
 
     def t_IDENTIFIER(self, t):
-        r'[A-Z_a-z][0-9A-Z_a-z]*'
+        r'[A-Z_a-z][0-9A-Z_a-z-]*'
         t.type = self.keywords.get(t.value, 'IDENTIFIER')
         return t
 
     def t_STRING(self, t):
         r'"[^"]*"'
         t.value = t.value[1:-1]
         return t
 
--- a/dom/bindings/test/TestCodeGen.webidl
+++ b/dom/bindings/test/TestCodeGen.webidl
@@ -916,16 +916,18 @@ dictionary Dict : ParentDict {
   Uint8Array uint8Array;
   Float64Array? float64Array = null;
 
   sequence<long> seq1;
   sequence<long> seq2 = [];
   sequence<long>? seq3;
   sequence<long>? seq4 = null;
   sequence<long>? seq5 = [];
+
+  long dashed-name;
 };
 
 dictionary ParentDict : GrandparentDict {
   long c = 5;
   TestInterface someInterface;
   TestInterface? someNullableInterface = null;
   TestExternalInterface someExternalInterface;
   any parentAny;