-
Notifications
You must be signed in to change notification settings - Fork 115
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
Implement IDL based generators #447
Conversation
I've just implemented a massive rework of the type-generation - it's now really powerful, and will generate borrowed versions of types for arguments and will generate generic methods when appropriate. |
Woo! This is looking great! |
I'm wondering if it might actually make sense to create a new crate instead under this repository, called |
Yeah, I don't really mind, is that what you'd prefer? |
I personally don't think it's worth creating a new repo. |
Wasn't talking about creating a new repo, just a new crate as a directory in this repo. If I'm not mistaken it seems like |
Oh sorry, yes that would make sense! |
@Diggsey As i mentioned in koute/stdweb#92, will it works in Firefox ? |
@edwin0cheng not right now - at least not if you try do anything complex. I think this can (and should) be fixed from the stdweb side though. |
Looking great so far! Let me know when this can progress forward! |
@brendanzab I've realised that the IDL files are missing information on extensions - these are described via separate IDL embedded in XML in the Khronos WebGL repo. I would like to expose a mapping from "<extension name>" => "<IDL contents>" in the |
I've opened a separate PR to add extension support to The generated bindings are now up to 10,000 lines, and include support for all accepted WebGL extensions. There's also a "version-less" I've uploaded the generated documentation as I think it's quite interesting to read: |
Oh, missed this comment! Would have been helpful if you had have linked to it in the PR of #451! Yes, that sounds great. |
One thing that might be cool would be to pull out the "summary" and "function" sections from the XML files and attach them as doc-comments to the generated code. |
Ooooh! Wondering if we could do that for all the generators 😮 |
@brendanzab stdweb 0.4.0 was released, and I've updated the PR to use that. It should be ready for you to review now! |
Woo, looking now! |
&TypeKind::Primitive(ref p) => ProcessedResult::simple(p.name()), | ||
&TypeKind::String => ProcessedResult::simple("String"), | ||
&TypeKind::ArrayBuffer | &TypeKind::ArrayBufferView => ProcessedResult::simple("ArrayBuffer"), | ||
&TypeKind::BufferSource => unimplemented!("BufferSource not supported in output"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be using unimplemented!
here? Are you planning to add support for this later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BufferSource
is not currently used in the WebGL IDL files, so I haven't bothered implementing it.
}).collect(); | ||
|
||
let rust_args = args.iter().map(|a| a.arg.clone()).collect::<Vec<_>>().join(", "); | ||
let js_args = args.iter().map(|a| a.js_arg.clone()).collect::<Vec<_>>().join(", "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
itertools has join
if you wanted to use that to skip the intermediate collect
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't seem worth it - this only happens at build time, and the cost of the extra dependency would outweigh any minor performance improvements.
|
||
// Strings | ||
DOMString | USVString => TypeKind::String, | ||
ByteString => unimplemented!(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been forgotten?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just not needed for WebGL
|
||
Some((field.name, Field { | ||
type_ | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be an Option
?
Would be nice to Run rustfmt on this if you don't mind! |
@brendanzab done |
@brendanzab hey is this good to go? |
Ack - left this one sit around in my notifications making me feel guilty for too long! Merging! |
Thanks! Are you happy to publish the new crate(s) to crates.io? |
Yup, will do. I'll add you to the crate owners too. |
What needs to be published - just the new crates? |
Hum, when publishing I get:
|
Oh, I think I need to bump the khronos_api version 🤔 |
Oh, and probably also publish those changes |
|
Done! |
Example generated bindings:
https://gist.github.com/Diggsey/c8a4cb93c7d5643d20203401ead178a7
This can't be merged until:
CanvasElement
type