Skip to content

Support metadata generation #1093

Closed

Description

@kennykerr

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

Activity

  1. kennykerr commented on Mar 11, 2022

    @kennykerr
    CollaboratorAuthor

    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.

  2. Alovchin91 commented on Mar 14, 2022

    @Alovchin91
    Contributor

    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)?

  3. kennykerr commented on Mar 14, 2022

    @kennykerr
    CollaboratorAuthor

    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.

  4. huiminyan2017 commented on Mar 16, 2022

    @huiminyan2017

    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!

  5. kennykerr commented on Aug 8, 2024

    @kennykerr
    CollaboratorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions