From: Nick Rosbrook <rosbrookn@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: Nick Rosbrook <rosbrookn@ainfosec.com>,
George Dunlap <george.dunlap@citrix.com>,
Ian Jackson <iwj@xenproject.org>, Wei Liu <wl@xen.org>
Subject: [PATCH 04/12] golang/xenlight: export keyed union interface types
Date: Wed, 28 Apr 2021 20:14:26 -0400 [thread overview]
Message-ID: <29a3fbc93262cb9b31f02d6c94c018b200dfa43e.1619655104.git.rosbrookn@ainfosec.com> (raw)
In-Reply-To: <cover.1619650820.git.rosbrookn@ainfosec.com>
In-Reply-To: <29e665fc1c9313f5e221e9e5e15d7c2d9c1eb4a7.1619655104.git.rosbrookn@ainfosec.com>
For structs that have a keyed union, e.g. DomainBuildInfo, the TypeUnion
field must be exported so that package users can get/set the fields
within. This means that users are aware of the existence of the
interface type used in those fields (see [1]), so it is awkward that the
interface itself is not exported. However, the single method within the
interface must remain unexported so that users cannot mistakenly "implement"
those interfaces.
Since there seems to be no reason to do otherwise, export the keyed
union interface types.
[1] https://pkg.go.dev/xenbits.xenproject.org/git-http/xen.git/tools/golang/xenlight?tab=doc#DeviceUsbdev
Signed-off-by: Nick Rosbrook <rosbrookn@ainfosec.com>
---
tools/golang/xenlight/gengotypes.py | 6 +--
tools/golang/xenlight/types.gen.go | 58 ++++++++++++++---------------
2 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py
index e6daa9b92f..3796632f7d 100644
--- a/tools/golang/xenlight/gengotypes.py
+++ b/tools/golang/xenlight/gengotypes.py
@@ -159,7 +159,7 @@ def xenlight_golang_define_union(ty = None, struct_name = '', union_name = ''):
extras = []
interface_name = '{0}_{1}_union'.format(struct_name, ty.keyvar.name)
- interface_name = xenlight_golang_fmt_name(interface_name, exported=False)
+ interface_name = xenlight_golang_fmt_name(interface_name)
s += 'type {0} interface {{\n'.format(interface_name)
s += 'is{0}()\n'.format(interface_name)
@@ -341,7 +341,7 @@ def xenlight_golang_union_from_C(ty = None, union_name = '', struct_name = ''):
field_name = xenlight_golang_fmt_name('{0}_union'.format(keyname))
interface_name = '{0}_{1}_union'.format(struct_name, keyname)
- interface_name = xenlight_golang_fmt_name(interface_name, exported=False)
+ interface_name = xenlight_golang_fmt_name(interface_name)
cgo_keyname = keyname
if cgo_keyname in go_keywords:
@@ -546,7 +546,7 @@ def xenlight_golang_union_to_C(ty = None, union_name = '',
gokeytype = xenlight_golang_fmt_name(keytype)
interface_name = '{0}_{1}_union'.format(struct_name, keyname)
- interface_name = xenlight_golang_fmt_name(interface_name, exported=False)
+ interface_name = xenlight_golang_fmt_name(interface_name)
cgo_keyname = keyname
if cgo_keyname in go_keywords:
diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.gen.go
index f2ceceb61c..a214dd9df6 100644
--- a/tools/golang/xenlight/types.gen.go
+++ b/tools/golang/xenlight/types.gen.go
@@ -337,18 +337,18 @@ State int
Evtch int
Rref int
Connection ChannelConnection
-ConnectionUnion channelinfoConnectionUnion
+ConnectionUnion ChannelinfoConnectionUnion
}
-type channelinfoConnectionUnion interface {
-ischannelinfoConnectionUnion()
+type ChannelinfoConnectionUnion interface {
+isChannelinfoConnectionUnion()
}
type ChannelinfoConnectionUnionPty struct {
Path string
}
-func (x ChannelinfoConnectionUnionPty) ischannelinfoConnectionUnion(){}
+func (x ChannelinfoConnectionUnionPty) isChannelinfoConnectionUnion(){}
type Vminfo struct {
Uuid Uuid
@@ -510,7 +510,7 @@ Apic Defbool
DmRestrict Defbool
Tee TeeType
Type DomainType
-TypeUnion domainBuildInfoTypeUnion
+TypeUnion DomainBuildInfoTypeUnion
ArchArm struct {
GicVersion GicVersion
Vuart VuartType
@@ -522,8 +522,8 @@ Altp2M Altp2MMode
VmtraceBufKb int
}
-type domainBuildInfoTypeUnion interface {
-isdomainBuildInfoTypeUnion()
+type DomainBuildInfoTypeUnion interface {
+isDomainBuildInfoTypeUnion()
}
type DomainBuildInfoTypeUnionHvm struct {
@@ -575,7 +575,7 @@ RdmMemBoundaryMemkb uint64
McaCaps uint64
}
-func (x DomainBuildInfoTypeUnionHvm) isdomainBuildInfoTypeUnion(){}
+func (x DomainBuildInfoTypeUnionHvm) isDomainBuildInfoTypeUnion(){}
type DomainBuildInfoTypeUnionPv struct {
Kernel string
@@ -588,7 +588,7 @@ Features string
E820Host Defbool
}
-func (x DomainBuildInfoTypeUnionPv) isdomainBuildInfoTypeUnion(){}
+func (x DomainBuildInfoTypeUnionPv) isDomainBuildInfoTypeUnion(){}
type DomainBuildInfoTypeUnionPvh struct {
Pvshim Defbool
@@ -597,7 +597,7 @@ PvshimCmdline string
PvshimExtra string
}
-func (x DomainBuildInfoTypeUnionPvh) isdomainBuildInfoTypeUnion(){}
+func (x DomainBuildInfoTypeUnionPvh) isDomainBuildInfoTypeUnion(){}
type DeviceVfb struct {
BackendDomid Domid
@@ -761,11 +761,11 @@ type DeviceUsbdev struct {
Ctrl Devid
Port int
Type UsbdevType
-TypeUnion deviceUsbdevTypeUnion
+TypeUnion DeviceUsbdevTypeUnion
}
-type deviceUsbdevTypeUnion interface {
-isdeviceUsbdevTypeUnion()
+type DeviceUsbdevTypeUnion interface {
+isDeviceUsbdevTypeUnion()
}
type DeviceUsbdevTypeUnionHostdev struct {
@@ -773,7 +773,7 @@ Hostbus byte
Hostaddr byte
}
-func (x DeviceUsbdevTypeUnionHostdev) isdeviceUsbdevTypeUnion(){}
+func (x DeviceUsbdevTypeUnionHostdev) isDeviceUsbdevTypeUnion(){}
type DeviceDtdev struct {
Path string
@@ -807,18 +807,18 @@ BackendDomname string
Devid Devid
Name string
Connection ChannelConnection
-ConnectionUnion deviceChannelConnectionUnion
+ConnectionUnion DeviceChannelConnectionUnion
}
-type deviceChannelConnectionUnion interface {
-isdeviceChannelConnectionUnion()
+type DeviceChannelConnectionUnion interface {
+isDeviceChannelConnectionUnion()
}
type DeviceChannelConnectionUnionSocket struct {
Path string
}
-func (x DeviceChannelConnectionUnionSocket) isdeviceChannelConnectionUnion(){}
+func (x DeviceChannelConnectionUnionSocket) isDeviceChannelConnectionUnion(){}
type ConnectorParam struct {
UniqueId string
@@ -1116,31 +1116,31 @@ Domid Domid
Domuuid Uuid
ForUser uint64
Type EventType
-TypeUnion eventTypeUnion
+TypeUnion EventTypeUnion
}
-type eventTypeUnion interface {
-iseventTypeUnion()
+type EventTypeUnion interface {
+isEventTypeUnion()
}
type EventTypeUnionDomainShutdown struct {
ShutdownReason byte
}
-func (x EventTypeUnionDomainShutdown) iseventTypeUnion(){}
+func (x EventTypeUnionDomainShutdown) isEventTypeUnion(){}
type EventTypeUnionDiskEject struct {
Vdev string
Disk DeviceDisk
}
-func (x EventTypeUnionDiskEject) iseventTypeUnion(){}
+func (x EventTypeUnionDiskEject) isEventTypeUnion(){}
type EventTypeUnionOperationComplete struct {
Rc int
}
-func (x EventTypeUnionOperationComplete) iseventTypeUnion(){}
+func (x EventTypeUnionOperationComplete) isEventTypeUnion(){}
type PsrCmtType int
const(
@@ -1175,11 +1175,11 @@ PsrFeatTypeMba PsrFeatType = 2
type PsrHwInfo struct {
Id uint32
Type PsrFeatType
-TypeUnion psrHwInfoTypeUnion
+TypeUnion PsrHwInfoTypeUnion
}
-type psrHwInfoTypeUnion interface {
-ispsrHwInfoTypeUnion()
+type PsrHwInfoTypeUnion interface {
+isPsrHwInfoTypeUnion()
}
type PsrHwInfoTypeUnionCat struct {
@@ -1188,7 +1188,7 @@ CbmLen uint32
CdpEnabled bool
}
-func (x PsrHwInfoTypeUnionCat) ispsrHwInfoTypeUnion(){}
+func (x PsrHwInfoTypeUnionCat) isPsrHwInfoTypeUnion(){}
type PsrHwInfoTypeUnionMba struct {
CosMax uint32
@@ -1196,5 +1196,5 @@ ThrtlMax uint32
Linear bool
}
-func (x PsrHwInfoTypeUnionMba) ispsrHwInfoTypeUnion(){}
+func (x PsrHwInfoTypeUnionMba) isPsrHwInfoTypeUnion(){}
--
2.17.1
next prev parent reply other threads:[~2021-04-29 0:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-29 0:14 [PATCH 00/12] golang/xenlight: domain life cycle support Nick Rosbrook
2021-04-29 0:14 ` [PATCH 01/12] golang/xenlight: update generated code Nick Rosbrook
2021-04-29 0:14 ` [PATCH 02/12] golang/xenlight: fix StringList toC conversion Nick Rosbrook
2021-04-29 0:14 ` [PATCH 03/12] golang/xenlight: fix string conversion in generated toC functions Nick Rosbrook
2021-04-29 0:14 ` Nick Rosbrook [this message]
2021-04-29 0:14 ` [PATCH 05/12] golang/xenlight: use struct pointers in keyed union fields Nick Rosbrook
2021-04-29 0:14 ` [PATCH 06/12] golang/xenlight: rename Ctx receivers to ctx Nick Rosbrook
2021-04-29 0:14 ` [PATCH 07/12] golang/xenlight: add logging conveniences for within xenlight Nick Rosbrook
2021-04-29 0:14 ` [PATCH 08/12] golang/xenlight: add functional options to configure Context Nick Rosbrook
2021-04-29 0:14 ` [PATCH 09/12] golang/xenlight: add DomainDestroy wrapper Nick Rosbrook
2021-04-29 0:14 ` [PATCH 10/12] golang/xenlight: add SendTrigger wrapper Nick Rosbrook
2021-04-29 0:14 ` [PATCH 11/12] golang/xenlight: do not negate ret when converting to Error Nick Rosbrook
2021-04-29 0:14 ` [PATCH 12/12] golang/xenlight: add NotifyDomainDeath method to Context Nick Rosbrook
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=29a3fbc93262cb9b31f02d6c94c018b200dfa43e.1619655104.git.rosbrookn@ainfosec.com \
--to=rosbrookn@gmail.com \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--cc=rosbrookn@ainfosec.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.