|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [RFC PATCH 07/25] tools/xenbindgen: Add support for structs in TOML specs
Hi,
> +/// An IDL type. A type may be a primitive integer, a pointer to an IDL type,
> +/// an array of IDL types or a struct composed of IDL types. Every integer
> must
> +/// be aligned to its size.
> +///
> +/// FIXME: This enumerated type is recovered as-is from the `typ` field in
> the
> +/// TOML files. Ideally, that representation should be more ergonomic and the
> +/// parser instructed to deal with it.
> +#[allow(clippy::missing_docs_in_private_items)]
> +#[derive(Debug, serde::Deserialize, PartialEq)]
> +#[serde(rename_all = "lowercase", tag = "tag", content = "args")]
> +pub enum Typ {
> + Struct(String),
> + U8,
> + U16,
> + U32,
> + U64,
> + I8,
> + I16,
> + I32,
> + I64,
> + Ptr(Box<Typ>),
> + Array(Box<Typ>, usize),
> +}
> +
I think we can name it Type (it doesn't clash with a keyword actually)
> +
> +/// Deserialized form of a field within a hypercall struct (see
> [`StructDef`])
> +#[derive(Debug, serde::Deserialize)]
> +pub struct FieldDef {
> + /// Name of the field
> + pub name: String,
> + /// Description of what the field is for. This string is added as a
> comment
> + /// on top of the autogenerated field.
> + pub description: String,
> + /// Type of the field.
> + pub typ: Typ,
> +}
> +
regarding this "typ" name, we can either use the "raw identifier" syntax
with r#type to have it "technically" named 'type' or use
#[serde(rename = "type")]
to have it named "type" during deserialization even if the field is
still "typ"
Cheers
Teddy
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |