Saturday, December 13, 2014

Re: webidl, jsinterop and overloaded methods

It seems to be specific to JsTypes, and is not a bug, as can be seen in unit tests: https://github.com/gwtproject/gwt/blob/6fa611cf9ad7ffa077a7378a100a7ccbd95e3cb3/dev/core/test/com/google/gwt/dev/javac/JSORestrictionsTest.java#L358-L381
Not knowing JsInterop much, I must say I have no idea how you're supposed to deal with those situations; maybe it's just not supported yet?

On Saturday, December 13, 2014 12:15:11 PM UTC+1, rhmoller wrote:
and the plot thickens.

I looked into the source for GWT and found the JSORestrictionsChecker. It references jsoRestrictions.html. I read through it but if I read it correctly it does not prohibit overloading methods - only overriding methods is prohibited.

The JSORestrictionsChecker calls checkJsTypeMethodsForOverloads();

I just commented that line out, and now everything works fine. I can now run code like this:

        context.drawImage(img, 0, 0);
        context.drawImage(img, 100, 100, 16, 16);
        context.drawImage(img, 32, 32, 32, 32, 120, 120, 32, 32);

        Path2D path = createPath2D();
        path.rect(10, 10, 100, 100);
        context.stroke(path);

        context.beginPath();
        context.moveTo(0, 0);
        context.lineTo(200, 200);
        context.stroke();

So is it a bug that JSORestrictionsChecker checks for overloaded methods?

/Rene

Den fredag den 12. december 2014 23.10.24 UTC+1 skrev rhmoller:
fyi: this is with GWT build from master.

/Rene

Den fredag den 12. december 2014 23.00.15 UTC+1 skrev rhmoller:
Hi

I am toying around with generating Java interfaces annotated with @JsType and @JsProperty from webidl. But I have a problem with overloaded methods.

For example: The idl for CanvasRenderingContext2 has several overloaded methods

fx

  void stroke();
  void stroke(Path2D path);

and

  ImageData createImageData(double sw, double sh);
  ImageData createImageData(ImageData imagedata);

I can generate a corresponding Java interface with the overloaded methods, but the GWT compiler fails with this

Error:(75, 0) GWT Compiler: JsType methods cannot overload another method.

I know JS does not support function overloading as such, but on the other hand, you can pass anything to a js function regardless of the specified parameters.

Do you have any ideas for how I can resolve these issues?

/Rene

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment