On Wed, 2015-07-08 at 15:08 +0100, Rob Hoes wrote:
>
> > On 8 Jul 2015, at 12:37, Ian Campbell <[email protected]> wrote:
> > ...
> >
> > I have a patch to genwrap.py which results in the following diff to the
> > generate ml files for the anonymous sub-struct added by the IDL change
> > above.
> >
> > Dave/Euan/Rob, is that idiomatic ocaml or is it possible to have
> > anonymous structs in ocaml like it is in C?
>
> I think that you have done the right thing. I’m not sure if you can
> define a nested record type without giving the inner one a name. But
> frankly, I don’t think there is much point to that either.
Thanks.
> In fact, I’d even drop the "__anon” and use the struct name as the
> type name directly.
I did have that to start with, see below for how the keyed union stuff
worked which lead me to suffix it.
> Or for consistency, use "type_<name>”, which is similar to what
> happens in the keyed union case (“type_hvm", “type_pv”).
Actually in this case the "type" is the name of the KeyedUnion and the
hvm|pv are the potential values of the enum which is the key.
> Incidentally, those structs are also defined as "Struct(None, [...”,
> but are probably handled specially because the struct appears inside
> the union.
Correct, they needed different special handling of the struct in order
to construct the keyedunion as an ocaml discriminated type thing, which
ends up with (for a keyedunion key field "type" of the domain type
enum):
type type_hvm = { ... }
type type_pv = { ... }
type type__union = Hvm of type_hvm | Pv of type_pv | Invalid
then the field is "xl_type : type__union";
(the xl_ prefix is because type, the name of the C field, is an ocaml
keyword...)
I added the __anon suffix for consistency with the __union suffix here.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel