From 73f4fbc03879800badd9ecc5a3568c8070adf6ca Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 3 Jun 2013 17:54:46 -0400 Subject: [PATCH] Bug 861371 - Allow Web IDL enums to have names starting with a digit; r=bzbarsky --HG-- extra : rebase_source : 5ebf235e9408bdfdfd37504e2f79c65978ccf51d --- dom/bindings/Codegen.py | 2 +- dom/bindings/test/TestCodeGen.webidl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 63aacd3416bd..d19d6e6704b8 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -5582,7 +5582,7 @@ def getEnumValueName(value): 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') diff --git a/dom/bindings/test/TestCodeGen.webidl b/dom/bindings/test/TestCodeGen.webidl index b492aeda41a3..8e6c3d74246c 100644 --- a/dom/bindings/test/TestCodeGen.webidl +++ b/dom/bindings/test/TestCodeGen.webidl @@ -36,6 +36,7 @@ callback interface TestSingleOperationCallbackInterface { }; enum TestEnum { + "1", "a", "b" };