New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 611545 link

Starred by 3 users

Issue metadata

Status: Duplicate
Merged: issue 711464
Owner:
Closed: Jun 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Union types should be handled in the bindings as overloads, not as SuperVerboseOrVeryLongOrComicallyLargeClassNames in core and modules

Project Member Reported by esprehn@chromium.org, May 12 2016

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.
 

Comment 1 by bashi@chromium.org, May 12 2016

Cc: bashi@chromium.org
What if a method has two or more union args?

((Foo or Bar or Baz) arg1, (X or Y or Z) arg2)

You want to generate 12 overloads?

Also union can be dictionary member and return type. What would do they look like?
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.

Comment 3 by bashi@chromium.org, 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.

Comment 4 by bashi@chromium.org, May 12 2016

Cc: yukishiino@chromium.org
yukishiino@ FYI
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. :)
Owner: bashi@chromium.org
Status: Assigned (was: Untriaged)
Cc: raphael....@intel.com

Comment 8 by peria@chromium.org, Jun 2 2017

Mergedinto: 711464
Status: Duplicate (was: Assigned)

Sign in to add a comment