xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Rosbrook <rosbrookn@ainfosec.com>
To: George Dunlap <george.dunlap@citrix.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "anthony.perard@citrix.com" <anthony.perard@citrix.com>,
	Brendan Kerrigan <kerriganb@ainfosec.com>,
	"ian.jackson@eu.citrix.com" <ian.jackson@eu.citrix.com>,
	Nicolas Belouin <nicolas.belouin@gandi.net>,
	"wl@xen.org" <wl@xen.org>
Subject: Re: [Xen-devel] [RFC] Generating Go bindings for libxl
Date: Wed, 4 Sep 2019 00:36:44 +0000	[thread overview]
Message-ID: <102c4923aacb48b9b80795e65107451a@ainfosec.com> (raw)
In-Reply-To: <76c02038-fcce-2774-c4f5-73ab9e0fdeef@citrix.com>

George,

> Are you up for taking a stab at something like `gengotypes.py`?

I have was able to make a bit of progress on this over the weekend. I've started
`gengotypes.py` in my branch[1]; the portion which generates `xenlight_types.go`
(the counterpart to _libxl_types.h) is mostly working. 

The main exception is that I am not certain how the `KeyedUnion` type from the IDL
should be translated for Go. One option is to do something similar to the `oneof` field 
in gRPC's protobuf messages[2]. Essentially, we would define a separate struct for each
of the structs that belong to the union. Then, where a union would be used in C, we use
an interface type which the previously defined structs implement. E.g.

type isDomainTypeStruct interface {
        isDomainTypeStruct()
}

type domainTypeHVMStruct struct {
        ...
}

func (d domainTypeHVMStruct) isDomainTypeStruct() {}

type DomainBuildInfo struct {
        ...
        Type DomainType
        dts    isDomainTypeStruct
}

It is a bit ugly, but I think it's semantically the closest to 'KeyedUnion'. What are your thoughts?

-NR

[1] https://github.com/enr0n/xen/blob/gen-go-types/tools/golang/gengotypes.py
[2] https://developers.google.com/protocol-buffers/docs/proto3#oneof
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-09-04  0:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 13:11 [Xen-devel] [RFC] Generating Go bindings for libxl Nicholas Rosbrook
2019-07-30 13:48 ` Tamas K Lengyel
2019-07-30 15:49   ` George Dunlap
2019-07-30 18:39     ` Tamas K Lengyel
2019-07-31 15:14       ` George Dunlap
2019-07-30 15:22 ` George Dunlap
2019-07-30 21:52   ` Nicholas Rosbrook
2019-07-31 15:06     ` George Dunlap
2019-07-31 21:22       ` Nicholas Rosbrook
2019-08-01 18:59         ` Nicholas Rosbrook
2019-08-02 15:38           ` George Dunlap
2019-08-02 19:09             ` Nicholas Rosbrook
2019-09-04  0:36             ` Nicholas Rosbrook [this message]
2019-09-04 16:52               ` George Dunlap
2019-09-04 16:59                 ` George Dunlap
2019-09-04 18:23                   ` Nicholas Rosbrook
2019-09-11 20:25                   ` Nicholas Rosbrook
2019-09-12 14:37                     ` George Dunlap
2019-09-12 17:35                       ` Nicholas Rosbrook
2019-09-13 11:21                         ` George Dunlap
2019-09-13 13:28                           ` Nicholas Rosbrook
2019-09-24  0:33                           ` Nicholas Rosbrook
2019-09-30 14:51                             ` George Dunlap
2019-09-30 18:08                               ` Nicholas Rosbrook
2019-09-04 18:15                 ` Nicholas Rosbrook
2019-08-02 15:55         ` George Dunlap
2019-07-30 16:27 ` George Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=102c4923aacb48b9b80795e65107451a@ainfosec.com \
    --to=rosbrookn@ainfosec.com \
    --cc=anthony.perard@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=kerriganb@ainfosec.com \
    --cc=nicolas.belouin@gandi.net \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).