[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 08/25] tools/xenbindgen: Add support for enums in TOML specs



On Mon Nov 25, 2024 at 4:39 PM GMT, Teddy Astie wrote:
> Hello,
>
> > +
> >   /// A language-agnostic specification.
> >   #[derive(Debug, serde::Deserialize)]
> >   struct InFileDef {
> >       /// List of structs described in this input specification.
> >       structs: Option<Vec<StructDef>>,
> > +    /// List of lang-agnostic enumerated descriptions.
> > +    enums: Option<Vec<EnumDef>>,
> >   }
> >   
>
> Alike for struct/..., I think we can merge that with OutFileDef using 
> the default attribute in serde :
> #[serde(default)]
> https://serde.rs/field-attrs.html#default
>
> That way, when there is no structs/... entry in the file, it is parsed 
> as a empty vec![] instead of failing which allows us to remove this 
> wrapper struct.

I didn't know about that setting. Option<T> was indeed a clutch to avoid having
to define enums = [] explicitly. I like your suggestion better.

>
> Cheers
>
> Teddy
>
>
>
> Teddy Astie | Vates XCP-ng Developer
>
> XCP-ng & Xen Orchestra - Vates solutions
>
> web: https://vates.tech

Cheers,
Alejandro



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.