Bug 861371 - Allow Web IDL enums to have names starting with a digit; r=bzbarsky
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 03 Jun 2013 17:54:46 -0400
changeset 145351 7e3a4ebcf067f387ddceabb22c2b4bf440315511
parent 145350 c6e087e836f91bcd953b81f23eaf88c001b25825
child 145352 40216a220b803dd729f33962cc52ba951c0d8829
child 145354 a608b5d810e66f6a11fc752aa2bd253c5897a770
child 145364 20ce72ffb6fbe1cc40798ac1739d8c723403a722
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs861371
milestone24.0a1
first release with
nightly linux32
7e3a4ebcf067 / 24.0a1 / 20130604031112 / files
nightly linux64
7e3a4ebcf067 / 24.0a1 / 20130604031112 / files
nightly mac
7e3a4ebcf067 / 24.0a1 / 20130604031112 / files
nightly win32
7e3a4ebcf067 / 24.0a1 / 20130604031112 / files
nightly win64
7e3a4ebcf067 / 24.0a1 / 20130604031112 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 861371 - Allow Web IDL enums to have names starting with a digit; r=bzbarsky
dom/bindings/Codegen.py
dom/bindings/test/TestCodeGen.webidl
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -5577,17 +5577,17 @@ def getEnumValueName(value):
     # characters in them.  Deal with the former by returning "_empty",
     # deal with possible name collisions from that by throwing if the
     # enum value is actually "_empty", and throw on any value
     # containing non-ASCII chars for now. Replace all chars other than
     # [0-9A-Za-z_] with '_'.
     if re.match("[^\x20-\x7E]", value):
         raise SyntaxError('Enum value "' + value + '" contains non-ASCII characters')
     if re.match("^[0-9]", value):
-        raise SyntaxError('Enum value "' + value + '" starts with a digit')
+        return '_' + value
     value = re.sub(r'[^0-9A-Za-z_]', '_', value)
     if re.match("^_[A-Z]|__", value):
         raise SyntaxError('Enum value "' + value + '" is reserved by the C++ spec')
     if value == "_empty":
         raise SyntaxError('"_empty" is not an IDL enum value we support yet')
     if value == "":
         return "_empty"
     return MakeNativeName(value)
--- a/dom/bindings/test/TestCodeGen.webidl
+++ b/dom/bindings/test/TestCodeGen.webidl
@@ -31,16 +31,17 @@ callback interface TestCallbackInterface
   sequence<TestCallbackInterface?>? getNullableSequenceOfNullableCallbackInterfaces();
 };
 
 callback interface TestSingleOperationCallbackInterface {
   TestInterface doSomething(short arg, sequence<double> anotherArg);
 };
 
 enum TestEnum {
+  "1",
   "a",
   "b"
 };
 
 callback TestCallback = void();
 [TreatNonCallableAsNull] callback TestTreatAsNullCallback = void();
 
 // Callback return value tests