-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
wasm-bindgen-webidl doesn't seem to support typedefs #498
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
Comments
wasm-bindgen-webidl
doesn't seem to support typedefs
It should only remove aliases of undefined types. For example, your snippet should work OK: typedef long MyInt; But this example should not: typedef SomeUnknownThing MyThing; Are you seeing cases that should work but aren't? If so, can you construct a failing test in |
I've put a test in my |
Doh, I totally did it backwards and we are always removing Check out @blm768 fixing this bug should be as easy as s/ |
I figured it might be that simple. Of course, that wouldn't handle the case of "chained" typedefs, but those should be considerably rarer. Anyway, I should be able to work on that tonight. |
Double d'oh. We should have: impl ImportedTypes for ast::TypeAlias {
fn imported_types<F>(&self, f: &mut F)
where
F: FnMut(&Ident, ImportedTypeKind),
{
f(&self.dest, ImportedTypeKind::Definition);
self.src.imported_types(f);
}
} |
We also might need to make // This will end up getting removed.
typedef UnknownType Whatever;
// But this won't because `Whatever` is considered defined..
typedef Whatever UhOh; |
|
Actually, on a second review, it looks like the WebIDL spec doesn't permit |
Actually, I just noticed the following line:
So we should probably not be including these typedefs at all, but replacing all their appearances with their underlying type. |
That's ok, we implement |
Oh; I missed that one. That would take care of it. While I was thinking about the problem, though, it occurred to me that instead of storing a |
Another reason to consider using a custom type is that
|
@blm768 oh no need to worry about that panic, it's expected for now. Otherwise having a custom type seems reasonable to me! I wouldn't bank too much on generating bindings for other languages, but if it makes the code cleaner for now feel free! |
Well, after playing with it a bit, I'm not totally sure about cleaner anymore. I thought we'd be able to get away without having to go from |
Sure thing, either way's fine by me! |
This issue is probably suppressed by #623 (at least the main issue, one that is in the title). |
Indeed, thanks @afdw! |
It appears that
wasm_bindgen_webidl::compile_ast
removes alltypedef
s viaremove_undefined_imports
, which preventstypedef
bindings from being emitted. This occurs even when working withtypedef
s that directly reference defined types, such as:The text was updated successfully, but these errors were encountered: