Skip to main content

winrt_gen/
lib.rs

1mod blob;
2mod case;
3mod codes;
4mod element_type;
5mod file;
6mod flags;
7mod row;
8mod tables;
9mod type_limits;
10mod type_namespaces;
11mod type_reader;
12mod type_stage;
13mod type_tree;
14mod types;
15
16pub mod dependencies;
17pub mod load_winmd;
18pub use file::WinmdFile;
19pub use tables::AttributeArg;
20pub use type_limits::{NamespaceTypes, TypeLimit, TypeLimits};
21pub use type_reader::TypeReader;
22pub use type_stage::TypeStage;
23
24fn format_ident(name: &str) -> proc_macro2::Ident {
25    if name == "Self" {
26        quote::format_ident!("{}_", name)
27    } else {
28        // keywords list based on https://doc.rust-lang.org/reference/keywords.html
29        match name {
30            "abstract" | "as" | "become" | "box" | "break" | "const" | "continue" | "crate"
31            | "do" | "else" | "enum" | "extern" | "false" | "final" | "fn" | "for" | "if"
32            | "impl" | "in" | "let" | "loop" | "macro" | "match" | "mod" | "move" | "mut"
33            | "override" | "priv" | "pub" | "ref" | "return" | "Self" | "self" | "static"
34            | "struct" | "super" | "trait" | "true" | "type" | "typeof" | "unsafe" | "unsized"
35            | "use" | "virtual" | "where" | "while" | "yield" | "try" | "async" | "await"
36            | "dyn" => quote::format_ident!("r#{}", name),
37            _ => quote::format_ident!("{}", name),
38        }
39    }
40}
41
42#[cfg(target_pointer_width = "64")]
43const SYSTEM32: &str = "System32";
44
45#[cfg(target_pointer_width = "32")]
46const SYSTEM32: &str = "SysNative";