Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recode parser to closer map to web_sys #2

Open
jonathanKingston opened this issue Sep 9, 2018 · 3 comments
Open

Recode parser to closer map to web_sys #2

jonathanKingston opened this issue Sep 9, 2018 · 3 comments

Comments

@jonathanKingston
Copy link
Owner

jonathanKingston commented Sep 9, 2018

The parser code I wrote in: https://github.com/jonathanKingston/wurst/blob/master/crates/parser/src/lib.rs reparses webidl when it's basically just trying to wrap the code that web_sys is generating. (both methods parse and method_calls are responsible for generating the web_sys method names etc)

Currently I am:

  • Checking the interfaces
  • Getting setter names set_id

I tried using the backend of web_sys but most of it is private, having some form of AST which represents the code generation would save people from writing this code.

/cc @fitzgen this is the issue we discussed on irc.

@jonathanKingston
Copy link
Owner Author

@alexcrichton I also added you to this repo as this impacts yourself.

I can create an issue on the wasm bindgen repo if we all agree adding a public interface of the web_sys interfaces is worthwhile.

@alexcrichton
Copy link
Collaborator

When you say public interface of web_sys interfaces, do you mean public interfaces to the webidl parsing code?

@jonathanKingston
Copy link
Owner Author

I created a public issue here: rustwasm/wasm-bindgen#807

Essentially my current code in parse creates a hashmap:

{
  "HTMLInputElement" => [
     "value",
     "placeholder",
     ...
   ],
  "HTMLElement" => [
     "lang",
     "title",
     ...
   ],
}

Then I end up code generating set_id in codegen and I'm also getting the generated struct interface name to change HTML to Html.
However already fragile code isn't handling other types that accept other than DOMString and I also need to handle the methods like add_event_handler eventually too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants