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

Standalone code generation depends on extension types and functions #2517

Closed
poliorcetics opened this issue May 24, 2023 · 18 comments
Closed
Labels
enhancement New feature or request

Comments

@poliorcetics
Copy link
Contributor

In recent commits (those after windows-bindgen 0.49), the standalone function is now able to handle TypeKind::Class and TypeKind:: Interface whereas it was unimplemented!() before.

I will need those for GuillaumeGomez/sysinfo#950

Not particularly urgent but IIRC releases are done on request for the crates here ?

@kennykerr
Copy link
Collaborator

Sure, I can do that - have you tested with the latest version on github to ensure that it meets your needs, and the resulting bindings work as needed?

@poliorcetics
Copy link
Contributor Author

Trying it out now

@poliorcetics
Copy link
Contributor Author

What's missing: at least

  • BOOL::ok()
  • WIN32_ERROR::ok()
  • NTSTATUS::ok()

Those methods are not generated by the windows-bindgen lib

Also, in the documentation, the need to have windows_core has a dependency alongside windows-targets is not mentioned

@poliorcetics
Copy link
Contributor Author

I'm using commit 72e9bf4 to test, if you push changes I can easily update and retest as needed :)

@kennykerr
Copy link
Collaborator

Currently those extensions, like the ok methods, are only included in the windows crate on a per-module basis rather than per-type. This is intentional to deal with a few implementation issues and would require some work to refactor to support standalone code generation. I would like to do that eventually, but that probably won't happen in the short term.

@poliorcetics
Copy link
Contributor Author

It makes bindings impossible to compile for non-sys versions because they're used in the produced bindings

@kennykerr
Copy link
Collaborator

A minimal repro would be appreciated to help me understand what you're trying to achieve. The standalone code generation is still pretty experimental compared with the windows and windows-sys crates and may not be appropriate depending on your goals.

@poliorcetics
Copy link
Contributor Author

I'll push the sysinfo branch

@kennykerr
Copy link
Collaborator

Thanks, the minimal repro involves generating bindings for Windows.Win32.Security.Authorization.ConvertSidToStringSidW with windows_bindgen::standalone_win.

@kennykerr kennykerr added the enhancement New feature or request label May 25, 2023
@kennykerr kennykerr changed the title Release a new version of windows-bindgen Standalone code generation depends on extension types and functions May 25, 2023
@MarijnS95
Copy link
Contributor

As mentioned in #1720 (comment) the standalone bindings should include pretty much everything from the extension file (e.g. https://github.com/microsoft/windows-rs/blob/78a0dbea48f856b03f3e7e650e0e385047d8a10b/crates/tools/riddle/src/rust/extensions/mod/Win32/Foundation/BOOL.rs), including From<> implementations (but I never got to report that as standalone issue per request, sorry!).

Not sure if this is still an issue since riddle, though.

@poliorcetics
Copy link
Contributor Author

poliorcetics commented Sep 21, 2023

This has been fixed now, I tried it with windows-bindgen 0.51.1 (the codegen docs are way outdated though)

@riverar
Copy link
Collaborator

riverar commented Sep 21, 2023

Thanks for following up @poliorcetics

@poliorcetics
Copy link
Contributor Author

Thanks for fixing it !

@MarijnS95
Copy link
Contributor

Yup, looks to be fixed indeed 👍

@MarijnS95
Copy link
Contributor

@kennykerr
Copy link
Collaborator

See #2517 (comment)

Now that windows-core exists, those extensions could conceivably live there.

@MarijnS95
Copy link
Contributor

MarijnS95 commented Oct 10, 2023

@kennykerr ah thanks, I've overlooked that.

Now that windows-core exists, those extensions could conceivably live there.

Sure, but only for types that themselves live in windows-core? Is that true for every type that is currently extended?

@kennykerr
Copy link
Collaborator

No. There's no easy fix - that's why I'm generally cautious about adding handwritten extensions.

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

No branches or pull requests

4 participants