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

Re: [Xen-devel] [PATCH v2 15/22] golang/xenlight: begin C to Go type marshaling



> You should probably say here explicitly what kinds of elements you're
> supporting and not supporting in this patch; specifically:
>
> - You're converting built-ins (or is this any struct-like type?)

Any struct-like type, since the fromC functions are all defined in
this patch (excluding array fields and keyed unions as you said
below).

> - You handle nested anonymous structs
> - But you're not handling keyed unions or arrays (anything else)?

I think this covers it, thanks.

> > +func (x *VncInfo) fromC(xc *C.libxl_vnc_info) error {
> > +     var defboolEnable Defbool
> > +     if err := defboolEnable.fromC(&xc.enable); err != nil {
> > +             return err
> > +     }
>
> Is there a reason in these cases that we don't simply call .fromC on the
> elemet itself?

This ensures that when we call fromC, we have an initialized variable.
This might be overkill here, as this would matter more if we had
structs with a nested struct pointer. E.g., [1] will panic since only
the outer struct is initialized.

-NR

[1]  https://play.golang.org/p/1gDVjbXgWd-

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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