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

Support metadata generation #1093

Closed
kennykerr opened this issue Aug 26, 2021 · 6 comments · Fixed by #3266
Closed

Support metadata generation #1093

kennykerr opened this issue Aug 26, 2021 · 6 comments · Fixed by #3266
Labels
enhancement New feature or request

Comments

@kennykerr
Copy link
Collaborator

kennykerr commented Aug 26, 2021

Dedicating an issue to this topic. Originally part of #81 (huge thread).

@kennykerr
Copy link
Collaborator Author

Getting back to authoring (#1094) and metadata generation as originally described in #81 I'd like to support a define macro that would take the place of using MIDL and instead let you define your metadata directly in Rust as follows:

fn main() {
    define! {
        mod Microsoft {
            mod Windows {
                struct StructType { x: i32, y: i32 }

                interface IInterfaceType {
                    fn Method(&self) -> StructType;
                }

                class ClassType : IInterfaceType;
            }
        }
    }
}

The define macro would typically be called by a build script to generate the component or project's .winmd file to OUT_DIR/project.winmd and a corresponding set of Rust bindings for the implementation to use to OUT_DIR/project.rs. The project can then use that along with the implement macro to provide the implementation.

@Alovchin91
Copy link
Contributor

Alovchin91 commented Mar 14, 2022

MIDL 3.0 is pretty simple, well documented and is rather powerful. Besides, it is used in C++/WinRT so it could also be reused when rewriting components in Rust. Do you think it would make sense to support both ways of defining runtime classes (so also in an .idl file)?

@kennykerr
Copy link
Collaborator Author

kennykerr commented Mar 14, 2022

MIDL also has a lot of problems. Of course, nothing prevents you from using MIDL if you prefer. Fundamentally, the winmd format is the canonical representation for metadata. How you get to that is up to you. I'm just working on a way to do it organically in Rust so that MIDL would not be required, but first I'm working out a few minor issues to make sure that developers can start using MIDL in the short term. Basically, the same issues you ran into in your sample project and just making sure it is streamlined.

@hmyan90
Copy link

hmyan90 commented Mar 16, 2022

Thanks, Kenny for putting this together and super helpful to provide a validated short-term solution. For MIDL define, personally I also don't mind defining it, it can particularly serve as a document purpose that can share with the team who will consume it, we can add notes/comments on it. But if we define in Rust macro, it's hard to share it with another team, I think. But sure we can choose the option!

@mominshaikhdevs
Copy link

@kennykerr is the work on the "complete metadata generator" aka "the riddle tool" complete yet? or is it in backlog?

@kennykerr
Copy link
Collaborator Author

Sorry I've been working on other things but am starting to get back into this.

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

Successfully merging a pull request may close this issue.

4 participants