Closed Bug 861371 Opened 12 years ago Closed 11 years ago

Make it possible in the Web IDL parser to support enum values which start with an integer

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)

References

Details

Attachments

(1 file, 1 obsolete file)

See the discussion in bug 859595.
Attached patch Example of what I want to do here (obsolete) (deleted) — Splinter Review
So let's say I have a patch like this. The Web IDL parser fails like this: 0:03.37 Traceback (most recent call last): 0:03.37 File "/Users/ehsanakhgari/moz/mozilla-central/config/pythonpath.py", line 56, in <module> 0:03.37 main(sys.argv[1:]) 0:03.37 File "/Users/ehsanakhgari/moz/mozilla-central/config/pythonpath.py", line 48, in main 0:03.37 execfile(script, frozenglobals) 0:03.37 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/BindingGen.py", line 78, in <module> 0:03.37 main() 0:03.37 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/BindingGen.py", line 75, in main 0:03.37 generate_binding_files(config, outputPrefix, srcPrefix, webIDLFile); 0:03.37 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/BindingGen.py", line 18, in generate_binding_files 0:03.37 replaceFileIfChanged(outputprefix + ".h", root.declare()) 0:03.37 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 8376, in declare 0:03.37 return stripTrailingWhitespace(self.root.declare()) 0:03.37 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 444, in declare 0:03.37 decl = self.child.declare() 0:03.37 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 444, in declare 0:03.37 decl = self.child.declare() 0:03.37 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 444, in declare 0:03.37 decl = self.child.declare() 0:03.37 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 372, in declare 0:03.37 return self.join(child.declare() for child in self.children if child is not None) 0:03.37 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 370, in join 0:03.37 return self.joiner.join(filter(lambda s: len(s) > 0, (child for child in generator))) 0:03.37 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 370, in <genexpr> 0:03.37 return self.joiner.join(filter(lambda s: len(s) > 0, (child for child in generator))) 0:03.38 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 372, in <genexpr> 0:03.38 return self.join(child.declare() for child in self.children if child is not None) 0:03.38 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 444, in declare 0:03.38 decl = self.child.declare() 0:03.38 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 444, in declare 0:03.38 decl = self.child.declare() 0:03.38 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 444, in declare 0:03.38 decl = self.child.declare() 0:03.38 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 444, in declare 0:03.38 decl = self.child.declare() 0:03.38 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 444, in declare 0:03.38 decl = self.child.declare() 0:03.38 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 372, in declare 0:03.38 return self.join(child.declare() for child in self.children if child is not None) 0:03.38 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 370, in join 0:03.38 return self.joiner.join(filter(lambda s: len(s) > 0, (child for child in generator))) 0:03.38 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 370, in <genexpr> 0:03.38 return self.joiner.join(filter(lambda s: len(s) > 0, (child for child in generator))) 0:03.38 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 372, in <genexpr> 0:03.38 return self.join(child.declare() for child in self.children if child is not None) 0:03.38 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 5617, in declare 0:03.38 """ % (enumName, ",\n ".join(map(getEnumValueName, self.enum.values())), 0:03.38 File "/Users/ehsanakhgari/moz/mozilla-central/dom/bindings/Codegen.py", line 5585, in getEnumValueName 0:03.38 raise SyntaxError('Enum value "' + value + '" starts with a digit') 0:03.38 SyntaxError: Enum value "0" starts with a digit 0:03.42 make[1]: *** [.BindingGen] Error 1 0:03.42 make: *** [default] Error 2 Is there an easy way to make this work, Boris?
Flags: needinfo?(bzbarsky)
It's not a restriction in the parser, but in the codegen. If that restriction were not in place, then given the current codegen code would lead to C++ like so: MOZ_BEGIN_ENUM_CLASS(PanningModelType, uint32_t) 0, 1, Equalpower, HRTF MOZ_END_ENUM_CLASS(PanningModelType) which is obviously not going to compile. So we just need to figure out how we want to represent enum values starting with a digit in C++, and remove that restriction. Maybe prefix with '_'? Something else?
Flags: needinfo?(bzbarsky)
This makes sense, thanks!
Summary: Make it possible in the Web IDL parser to support attributes which can be an enum or an integer → Make it possible in the Web IDL parser to support enum values which start with an integer
Attached patch Patch (v1) (deleted) — Splinter Review
Assignee: nobody → ehsan
Attachment #757051 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #757595 - Flags: review?(bzbarsky)
Comment on attachment 757595 [details] [diff] [review] Patch (v1) r=me
Attachment #757595 - Flags: review?(bzbarsky) → review+
Blocks: 879014
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: