> On 8 Jul 2015, at 15:19, Ian Campbell <ian.campb...@citrix.com> wrote:
> 
> On Wed, 2015-07-08 at 15:08 +0100, Rob Hoes wrote:
>> 
>>> On 8 Jul 2015, at 12:37, Ian Campbell <ian.campb...@citrix.com> 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.

It’s just that __anon doesn’t really mean much, because it isn’t anonymous in 
OCaml :) In hindsight, I would have probably dropped the __union as well...

Anyway, I don’t care too much about these names, because in practice you won’t 
normally use them directly.

Rob

>> 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
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to