Closed
Bug 1289315
Opened 8 years ago
Closed 8 years ago
Union types in iterable<> declarations fail in WebIDL parser
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla50
Tracking | Status | |
---|---|---|
firefox50 | --- | fixed |
People
(Reporter: qdot, Assigned: qdot)
References
Details
Attachments
(2 files, 2 obsolete files)
1.12 KB,
patch
|
qdot
:
review+
|
Details | Diff | Splinter Review |
10.93 KB,
patch
|
qdot
:
review+
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
According to the spec, Union types are valid in iterable<> declarations on an interface, and are used in things like the CSS Typed OM spec. However, using union types in an iterable fails in the WebIDL parser.
Example backtrace:
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/share/code/mozbuild/1201590-webmidi-dom/python/mozbuild/mozbuild/action/webidl.py", line 19, in <module>
sys.exit(main(sys.argv[1:]))
File "/share/code/mozbuild/1201590-webmidi-dom/python/mozbuild/mozbuild/action/webidl.py", line 15, in main
manager.generate_build_files()
File "/share/code/mozbuild/1201590-webmidi-dom/dom/bindings/mozwebidlcodegen/__init__.py", line 271, in generate_build_files
written, deps = self._generate_build_files_for_webidl(filename)
File "/share/code/mozbuild/1201590-webmidi-dom/dom/bindings/mozwebidlcodegen/__init__.py", line 473, in _generate_build_files_for_webidl
root = CGBindingRoot(self._config, binding_stem, filename)
File "/share/code/mozbuild/1201590-webmidi-dom/dom/bindings/Codegen.py", line 13480, in __init__
jsImplemented)
File "/share/code/mozbuild/1201590-webmidi-dom/dom/bindings/Codegen.py", line 1165, in __init__
None))
File "/share/code/mozbuild/1201590-webmidi-dom/dom/bindings/Codegen.py", line 1060, in addHeadersForType
headerSet.add(self.getUnionDeclarationFilename(config, unrolled))
File "/share/code/mozbuild/1201590-webmidi-dom/dom/bindings/Codegen.py", line 1231, in getUnionDeclarationFilename
assert len(config.filenamesPerUnion[unionType.name]) == 1
AssertionError
Assignee | ||
Comment 1•8 years ago
|
||
From email thread between :jyc and :bz, sounds like this is due to the way header includes are created during maplike/setlike creation.
Quoting :bz, fix is:
"Change getTypesFromDescriptor in Configuration.py so that if descriptor.interface has a maplikeOrSetlikeOrIterable its key and value type (whichever exists) are added to the list of types returned from that function."
This probably means that union types will fail in maplike/setlike too. We don't have tests for unions on any of these interface types yet, so I'm also curious whether some of our autogenerated functions will fail with union types.
I'll attach a quick test patch I wrote up for this specific issue, but we should probably land this with tests for all types added to the bindings test set.
Assignee | ||
Comment 2•8 years ago
|
||
Assignee | ||
Comment 3•8 years ago
|
||
bz, not sure where you were at with this in the email chain. If you've got a quick fix, lemme know, otherwise feel free to assign to me and I'll take a look.
Flags: needinfo?(bzbarsky)
Comment 4•8 years ago
|
||
Go for it. I don't have a fix written past what comment 1 says. But I think Jonathan might have one.
Assignee: nobody → kyle
Flags: needinfo?(bzbarsky)
Comment 5•8 years ago
|
||
This is what I applied following bz's comments -- it lets me compile with the WebIDL snippet I sent. Don't know if more is needed.
diff --git a/dom/bindings/Configuration.py b/dom/bindings/Configuration.py
--- a/dom/bindings/Configuration.py
+++ b/dom/bindings/Configuration.py
@@ -706,16 +706,24 @@ def getTypesFromDescriptor(descriptor):
types = []
for s in signatures:
assert len(s) == 2
(returnType, arguments) = s
types.append(returnType)
types.extend(a.type for a in arguments)
types.extend(a.type for a in members if a.isAttr())
+
+ if descriptor.interface.maplikeOrSetlikeOrIterable:
+ maplikeOrSetlikeOrIterable = descriptor.interface.maplikeOrSetlikeOrIterable
+ if maplikeOrSetlikeOrIterable.hasKeyType():
+ types.append(maplikeOrSetlikeOrIterable.keyType)
+ if maplikeOrSetlikeOrIterable.hasValueType():
+ types.append(maplikeOrSetlikeOrIterable.valueType)
+
return types
def getFlatTypes(types):
retval = set()
for type in types:
type = type.unroll()
if type.isUnion():
Assignee | ||
Comment 6•8 years ago
|
||
Ok, I tested this fix and it works. I also didn't realize how union types were generated by the bindings, so I think generated functions will be ok (though we still need documentation, I'll file a followup for that).
Once I get the test fleshed out a little more, I'll go ahead and land the patch (which will look like a self review but isn't :) ).
Assignee | ||
Comment 7•8 years ago
|
||
Attachment #8774621 -
Attachment is obsolete: true
Assignee | ||
Comment 8•8 years ago
|
||
I'm marking this as self review, but it's actually bz/jyc's code I'm r+'ing. However, if anything does go wrong it'd probably land on me anyways. :)
Attachment #8774990 -
Flags: review+
Assignee | ||
Comment 9•8 years ago
|
||
Attachment #8774906 -
Attachment is obsolete: true
Attachment #8774993 -
Flags: review+
Assignee | ||
Comment 10•8 years ago
|
||
Comment on attachment 8774993 [details] [diff] [review]
Patch 2 (v1) - Mochitest for Union Type WebIDL Maplike/Setlike/Iterable fix; r=qdot
Just need a quick r+ on the webidl change from a DOM peer.
Attachment #8774993 -
Flags: review?(bzbarsky)
Comment 11•8 years ago
|
||
> but it's actually bz/jyc's code I'm r+'ing
Just set the user in the patch to jyc? He wrote the patch, after all.
Comment 12•8 years ago
|
||
Comment on attachment 8774993 [details] [diff] [review]
Patch 2 (v1) - Mochitest for Union Type WebIDL Maplike/Setlike/Iterable fix; r=qdot
>+TestInterfaceIterableDoubleUnion::Constructor(const GlobalObject& aGlobal,
>+ ErrorResult& aRv)
Please fix the indent.
>+ // Simple dual type iterable creation and functionality test
>+ info("IterableDoubleUnion: Testing simple iterable creation and functionality");
And here.
r=me
Attachment #8774993 -
Flags: review?(bzbarsky) → review+
Comment 13•8 years ago
|
||
Pushed by kmachulis@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/ae6fac030deb
Fix union types for maplike/setlike/iterable in WebIDL parser; r=qdot
https://hg.mozilla.org/integration/mozilla-inbound/rev/44d0ef641fa7
Tests for Iterable<> Union Types in WebIDL Interfaces; r=bz
Assignee | ||
Comment 14•8 years ago
|
||
(In reply to Boris Zbarsky [:bz] from comment #11)
> > but it's actually bz/jyc's code I'm r+'ing
>
> Just set the user in the patch to jyc? He wrote the patch, after all.
Ah, ok, did that. Sorry about that, misunderstood code trail between bug comments and email.
All patched up and pushed to inbound.
Comment 15•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/ae6fac030deb
https://hg.mozilla.org/mozilla-central/rev/44d0ef641fa7
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in
before you can comment on or make changes to this bug.
Description
•