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

code generation covering all webidl #1

Open
unicomp21 opened this issue Feb 20, 2022 · 11 comments
Open

code generation covering all webidl #1

unicomp21 opened this issue Feb 20, 2022 · 11 comments

Comments

@unicomp21
Copy link

EbramTawfik/GeckoFX#3

Is it possible to wrap everything?

@yoshiki-okawa
Copy link
Owner

Possibly. I was looking at typescript instead of WebIDL (e.g. https://github.com/microsoft/TypeScript/blob/main/lib/lib.dom.d.ts) as TS is much closer to C# than WebIDL like https://searchfox.org/mozilla-central/source/dom/webidl/Window.webidl

@unicomp21
Copy link
Author

Isn't the typescrpt generated from webidl? @yoshiki-okawa

@unicomp21
Copy link
Author

Maybe we could use this to generate the c# interop code? Am I looking at this right?
https://github.com/jsdom/webidl2js

@unicomp21
Copy link
Author

@yoshiki-okawa
Copy link
Owner

What I mean is that I think it is possible to do code gen based on https://github.com/microsoft/TypeScript/blob/main/lib/lib.dom.d.ts to cover pretty much all WebIDL. lib.dom.d.ts is generated from MDN Web APIs (https://developer.mozilla.org/en-US/docs/Web/API) but pretty much same as WebIDL.

@unicomp21
Copy link
Author

Got it, I understand. But, would this be easier than changing

https://github.com/microsoft/TypeScript-DOM-lib-generator

to generate c# rather than typescript? I think it already iterates the webidl tree? Or is there something else I'm missing?

@yoshiki-okawa
Copy link
Owner

Either way would work but I think code gen based on lib.dom.d.ts would be easier than understanding and modifying the generator.

@unicomp21
Copy link
Author

@yoshiki-okawa is this more in line w/ your thinking? From what I can tell, dart syntax looks a lot like c#? If I'm not mistaken, this project is generating dart wrappers from typescript typedefinitions?

https://github.com/Blimster/babylon_dart_gen

@unicomp21
Copy link
Author

I'm wondering if there will also be demand in the near future for wrapping c++ w/ c# pinvoke wrappers? When using webassembly?
https://emscripten.org/docs/porting/connecting_cpp_and_javascript/WebIDL-Binder.html

(ie kill two birds w/ one stone)

@yoshiki-okawa
Copy link
Owner

yes babylon_dart_gen is pretty much what's in my mind.
regarding c++, if you are talking about c# -> JS -> c++, I cannot see benefit of it.

@unicomp21
Copy link
Author

my thinking was generating c# -> c++ pinvoke wrappers, where the c++ api is described in webidl. but the more I think about it, this sort of thing is probably better filled by something like protobuf.

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