Skip to content

Latest commit

 

History

History
55 lines (43 loc) · 2.25 KB

File metadata and controls

55 lines (43 loc) · 2.25 KB

RDL parser library and ECMA-335 generator

The windows-rdl crate compiles RDL (Rust Definition Language) - a Rust-like text format for describing Windows APIs - into ECMA-335 .winmd metadata, and back again.

Start by adding the following to your Cargo.toml file:

[dependencies.windows-rdl]
version = "0.100"

Use the reader to compile .rdl source into a .winmd, and the writer to regenerate canonical .rdl from a .winmd:

windows_rdl::reader()
    .input("example.rdl")
    .output("example.winmd")
    .write()
    .unwrap();

windows_rdl::writer()
    .input("example.winmd")
    .output("example.rdl")
    .write()
    .unwrap();

Use .reference("dependency.winmd") when the RDL refers to types defined by another metadata file. Use .input_text(source) or .input_texts(sources) for RDL already in memory. Use .reference_default() for the standard Windows metadata.

The winmd writer matches Param rows by ECMA-335 Param.Sequence, not table order. Sparse methods still emit every signature parameter, using pN and the reader's type-based default direction when a row is absent. Sequence 0 return attributes are emitted on the return type. Duplicate and out-of-range sequences are errors.

The writer reads raw direction and optionality through MethodParam::direction() and is_optional(). Reserved, retval, and count attributes remain separate pseudos/custom attributes; the metadata layer does not merge them with projection policy.

Canonical output spells the input direction as #[in]; the reader also accepts Rust's raw identifier spelling, #[r#in].

Some metadata states do not have a lossless RDL spelling. Parameter direction cannot be neither In nor Out because an omitted direction is inferred. Attributes on a void return row cannot be written because there is no return type to carry them. #[len_param(N)] and #[size_param(N)] store raw parameter positions, so reordering parameters also requires updating N. Pointer chains must use one constness throughout, such as *mut *mut T or *const *const T; mixed chains are rejected.