JsInterop Generator from webidl

364 views
Skip to first unread message

nick936

unread,
Apr 1, 2015, 5:32:55 PM4/1/15
to google-web-tool...@googlegroups.com
Hi,
while playing with the new JsInterop feature i decided to write a code generator which generate the interfaces out of webidls fetched from https://html.spec.whatwg.org/ or the mozilla repository. Yesterday i started this littel project. It's a prototype and far away from being stable, but enough to use the generated interfaces for test purposes. I did a rather quick and dirty just to use the interfaces my internal test project and the code needs some refactoring. I used ANTLR4, javasoup and javapoet. You can find the sources in this github repo https://github.com/Nickel671/JsInteropGenerator. You can find the generated Interfaces here https://github.com/Nickel671/JsInteropGenerator/tree/master/target/generated-sources/gwt/org/niklas/elemental/Elemental/client/elements. If you are interested in this i will improve it.

Stefano Ciccarelli

unread,
Apr 1, 2015, 11:39:20 PM4/1/15
to google-web-tool...@googlegroups.com
http://www.gwtproject.org/articles/elemental.html

Is it the same?

Il giorno mer 1 apr 2015 alle 23:32 nick936 <nikl...@googlemail.com> ha scritto:
Hi,
while playing with the new JsInterop feature i decided to write a code generator which generate the interfaces out of webidls fetched from https://html.spec.whatwg.org/ or the mozilla repository. Yesterday i started this littel project. It's a prototype and far away from being stable, but enough to use the generated interfaces for test purposes. I did a rather quick and dirty just to use the interfaces my internal test project and the code needs some refactoring. I used ANTLR4, javasoup and javapoet. You can find the sources in this github repo https://github.com/Nickel671/JsInteropGenerator. You can find the generated Interfaces here https://github.com/Nickel671/JsInteropGenerator/tree/master/target/generated-sources/gwt/org/niklas/elemental/Elemental/client/elements. If you are interested in this i will improve it.

--
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/d32b27c4-a1eb-40cb-9720-3d1f6c535b03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ray Cromwell

unread,
Apr 2, 2015, 4:15:28 AM4/2/15
to google-web-toolkit-contributors

nick936

unread,
Apr 2, 2015, 4:56:43 AM4/2/15
to google-web-tool...@googlegroups.com
Hey,
i know you guys develop Elemental 2.0. It's only for the people how are interested in the meantime. But you are welcome to look at the code. ( Besides it's inspired by laziness ;) )


Am Donnerstag, 2. April 2015 10:15:28 UTC+2 schrieb Ray Cromwell:
Yes, there is a version under development based on html5index.org (https://github.com/tidej/html5index)
On Wed, Apr 1, 2015 at 8:39 PM, Stefano Ciccarelli <scicc...@gmail.com> wrote:
Il giorno mer 1 apr 2015 alle 23:32 nick936 <nikl...@googlemail.com> ha scritto:
Hi,
while playing with the new JsInterop feature i decided to write a code generator which generate the interfaces out of webidls fetched from https://html.spec.whatwg.org/ or the mozilla repository. Yesterday i started this littel project. It's a prototype and far away from being stable, but enough to use the generated interfaces for test purposes. I did a rather quick and dirty just to use the interfaces my internal test project and the code needs some refactoring. I used ANTLR4, javasoup and javapoet. You can find the sources in this github repo https://github.com/Nickel671/JsInteropGenerator. You can find the generated Interfaces here https://github.com/Nickel671/JsInteropGenerator/tree/master/target/generated-sources/gwt/org/niklas/elemental/Elemental/client/elements. If you are interested in this i will improve it.

--
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscribe@googlegroups.com.

Goktug Gokdogan

unread,
Apr 6, 2015, 5:09:08 PM4/6/15
to google-web-toolkit-contributors
Cool stuff! I'll definitely take a look.

To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/b8337083-e54b-46fd-95bc-a68aae74e360%40googlegroups.com.

Jens

unread,
Apr 7, 2015, 6:21:39 AM4/7/15
to google-web-tool...@googlegroups.com
A few notes, after a quick look:

- Generated interfaces should be public
- Some interfaces have multiple methods with the same name but different parameters, e.g. Window.alert() and Window.alert(String msg). That seems to cause a compile error that "alert" is already defined. There are a couple of other interface with similar errors (mostly the Canvas stuff if I remember correctly). 
- I'm not a JS expert but could it be that things like WindowBase64 should not have @JsType(prototype="WindowBase64") applied as its just an interface/mixin that does not exist on its own? In the IDL it also has a marker "NoInterfaceObject".

-- J.

Rene Hangstrup Møller

unread,
Apr 7, 2015, 5:10:30 PM4/7/15
to google-web-tool...@googlegroups.com
Hi

I did a similar experiment a while ago, but abandoned it due to the missing support for overloads in JsInterop and I did not come up with a pleasing solution for constructors. Many parts of the DOM API use method overloading (fx the canvas API) and constructors -(fx to create a Path2D object)

Feel free to take whatever from it if you find anything useful.

https://github.com/rhmoller/webidl2gwt

It contains:
- a scraper that extract webidl snippets from https://html.spec.whatwg.org
- a quick and dirty and incomplete webidl parser based on an Antlr4 grammar
- an example with a hacked version of GWT where the method overloading guard has been removed. It does some painting using Canvas.
- a factory approach for constructing new instances of JsInterop types.

Rene Hangstrup Møller

unread,
Apr 7, 2015, 5:12:44 PM4/7/15
to google-web-tool...@googlegroups.com
oh and I think I had to massage the extracted webidl snippets, because not all of them are syntactically valid.

/Rene

nick936

unread,
Apr 8, 2015, 4:38:03 AM4/8/15
to google-web-tool...@googlegroups.com
Thank you Jens for your feedback. I expected that there is someting like method overloading because in webidl you have many optional  and union parameters.
Yes currently i don't support any markers. My current problem is how to handle union types propertly and unknown idl interfaces.At the moment i read the specs and try to find some solutions http://www.w3.org/TR/2012/WD-WebIDL-Java-20120207/ https://docs.google.com/document/d/1tir74SB-ZWrs-gQ8w-lOEV3oMY6u6lF2MmNivDEihZ4/edit.

Rene i use the IDL grammar from http://www.w3.org/TR/WebIDL/#idl-grammar and i didn't find any syntax errors in the webidls from whatwg. But i will defintly take a look.

Goktug Gokdogan

unread,
Apr 10, 2015, 4:21:21 PM4/10/15
to google-web-toolkit-contributors
In practice, the overloading is only a problem if the interface is implemented by a java class. I'm already planning to relax the rules so that the check for overloads will fail only if there is a java implementor of the interface.
For constructors and static methods see: https://groups.google.com/d/topic/google-web-toolkit-contributors/L6uh96NcZtE/discussion (not implemented yet)

--
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-co...@googlegroups.com.

Bademus l.

unread,
Jun 3, 2015, 5:43:41 AM6/3/15
to google-web-tool...@googlegroups.com

Hello,

Are you willing to generate JsInterprop for ChromeExtension API too?

thanks and sorry for offtopic,
Reply all
Reply to author
Forward
0 new messages