Issue metadata
Sign in to add a comment
|
Union types should be handled in the bindings as overloads, not as SuperVerboseOrVeryLongOrComicallyLargeClassNames in core and modules |
||||||||||||||||||||||||
Issue description
ex.
If you write:
interface X {
void parse(DOMString or Object or sequence<unsigned>);
}
we should code generate a switch on the data type in the bindings.
Your C++ should look like:
class X {
void parse(String);
void parse(Object);
void parse(Vector<unsigned>);
}
and the bindings should figure out which overload to call for you. Today we generate extremely verbose unions and then bleed that detail down into core. This complicates the code in core, breaks the build on windows (see issue 611437), and makes writing WebModules harder since C++ code that wants to invoke that method has to deal with the super long union type which is just a detail of the JS API overload model.
,
May 12 2016
Yes, I'd like us to have all the C++ combinations enumerated. If you need to call the method from C++ it should call based on the correct type pattern. How many of those very long ones exist in practice though? For dictionaries I think we should consider exposing the type checking methods on the Dictionary. For return types we can expose a type + wrapper and the bindings can handle the unwrapping if needed. ex. return UnionType<X>, and people can check by doing .is(X::Type) or some such. Code generating huge unions is bad. We can do it with templates and type fields.
,
May 12 2016
Using wrapper (variadic template args) is what I was tried first to fix dependency cycles. I just gave up bacause it's difficult for me to implement in 2-3 days :( btw, we discussed the design before. https://docs.google.com/a/chromium.org/document/d/1hBBFlueguEELjBqN_csSIxj7te1KmOafl9_vvVTO0J0/edit?usp=docslist_api I agree with huge unions are not good, but not sure we want to add extra logic for union overloads.
,
May 12 2016
yukishiino@ FYI
,
May 12 2016
Yeah, that was a few years ago though, and we're older and wiser now. We're also pushing for things like webmodules and being more primitive based. :)
,
May 26 2016
,
Mar 13 2017
,
Jun 2 2017
|
|||||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||||
Comment 1 by bashi@chromium.org
, May 12 2016