Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added more strict type hinting #4

Merged
merged 1 commit into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bootloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ import (
// see: LinuxBootLoader
type BootLoader interface {
NSObject

bootLoader()
}

type baseBootLoader struct{}

func (*baseBootLoader) bootLoader() {}

var _ BootLoader = (*LinuxBootLoader)(nil)

// LinuxBootLoader Boot loader configuration for a Linux kernel.
Expand All @@ -25,6 +31,8 @@ type LinuxBootLoader struct {
initrdPath string
cmdLine string
pointer

*baseBootLoader
}

func (b *LinuxBootLoader) String() string {
Expand Down
10 changes: 10 additions & 0 deletions console.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ import (
// A serial port attachment defines how the virtual machine's serial port interfaces with the host system.
type SerialPortAttachment interface {
NSObject

serialPortAttachment()
}

type baseSerialPortAttachment struct{}

func (*baseSerialPortAttachment) serialPortAttachment() {}

var _ SerialPortAttachment = (*FileHandleSerialPortAttachment)(nil)

// FileHandleSerialPortAttachment defines a serial port attachment from a file handle.
Expand All @@ -26,6 +32,8 @@ var _ SerialPortAttachment = (*FileHandleSerialPortAttachment)(nil)
// see: https://developer.apple.com/documentation/virtualization/vzfilehandleserialportattachment?language=objc
type FileHandleSerialPortAttachment struct {
pointer

*baseSerialPortAttachment
}

// NewFileHandleSerialPortAttachment intialize the FileHandleSerialPortAttachment from file handles.
Expand Down Expand Up @@ -56,6 +64,8 @@ var _ SerialPortAttachment = (*FileSerialPortAttachment)(nil)
// see: https://developer.apple.com/documentation/virtualization/vzfileserialportattachment?language=objc
type FileSerialPortAttachment struct {
pointer

*baseSerialPortAttachment
}

// NewFileSerialPortAttachment initialize the FileSerialPortAttachment from a path of a file.
Expand Down
8 changes: 8 additions & 0 deletions memory_balloon.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@ import "runtime"
// MemoryBalloonDeviceConfiguration for a memory balloon device configuration.
type MemoryBalloonDeviceConfiguration interface {
NSObject

memoryBalloonDeviceConfiguration()
}

type baseMemoryBalloonDeviceConfiguration struct{}

func (*baseMemoryBalloonDeviceConfiguration) memoryBalloonDeviceConfiguration() {}

var _ MemoryBalloonDeviceConfiguration = (*VirtioTraditionalMemoryBalloonDeviceConfiguration)(nil)

// VirtioTraditionalMemoryBalloonDeviceConfiguration is a configuration of the Virtio traditional memory balloon device.
//
// see: https://developer.apple.com/documentation/virtualization/vzvirtiotraditionalmemoryballoondeviceconfiguration?language=objc
type VirtioTraditionalMemoryBalloonDeviceConfiguration struct {
pointer

*baseMemoryBalloonDeviceConfiguration
}

// NewVirtioTraditionalMemoryBalloonDeviceConfiguration creates a new VirtioTraditionalMemoryBalloonDeviceConfiguration.
Expand Down
12 changes: 12 additions & 0 deletions network.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type BridgedNetwork interface {
// see: https://developer.apple.com/documentation/virtualization/vznatnetworkdeviceattachment?language=objc
type NATNetworkDeviceAttachment struct {
pointer

*baseNetworkDeviceAttachment
}

var _ NetworkDeviceAttachment = (*NATNetworkDeviceAttachment)(nil)
Expand Down Expand Up @@ -69,6 +71,8 @@ func NewNATNetworkDeviceAttachment() *NATNetworkDeviceAttachment {
// see: https://developer.apple.com/documentation/virtualization/vzbridgednetworkdeviceattachment?language=objc
type BridgedNetworkDeviceAttachment struct {
pointer

*baseNetworkDeviceAttachment
}

var _ NetworkDeviceAttachment = (*BridgedNetworkDeviceAttachment)(nil)
Expand All @@ -95,6 +99,8 @@ func NewBridgedNetworkDeviceAttachment(networkInterface BridgedNetwork) *Bridged
// see: https://developer.apple.com/documentation/virtualization/vzfilehandlenetworkdeviceattachment?language=objc
type FileHandleNetworkDeviceAttachment struct {
pointer

*baseNetworkDeviceAttachment
}

var _ NetworkDeviceAttachment = (*FileHandleNetworkDeviceAttachment)(nil)
Expand All @@ -120,8 +126,14 @@ func NewFileHandleNetworkDeviceAttachment(file *os.File) *FileHandleNetworkDevic
// see: https://developer.apple.com/documentation/virtualization/vznetworkdeviceattachment?language=objc
type NetworkDeviceAttachment interface {
NSObject

networkDeviceAttachment()
}

type baseNetworkDeviceAttachment struct{}

func (*baseNetworkDeviceAttachment) networkDeviceAttachment() {}

// VirtioNetworkDeviceConfiguration is configuration of a paravirtualized network device of type Virtio Network Device.
//
// The communication channel used on the host is defined through the attachment.
Expand Down
8 changes: 8 additions & 0 deletions socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ import "runtime"
// SocketDeviceConfiguration for a socket device configuration.
type SocketDeviceConfiguration interface {
NSObject

socketDeviceConfiguration()
}

type baseSocketDeviceConfiguration struct{}

func (*baseSocketDeviceConfiguration) socketDeviceConfiguration() {}

var _ SocketDeviceConfiguration = (*VirtioSocketDeviceConfiguration)(nil)

// VirtioSocketDeviceConfiguration is a configuration of the Virtio socket device.
Expand All @@ -22,6 +28,8 @@ var _ SocketDeviceConfiguration = (*VirtioSocketDeviceConfiguration)(nil)
// see: https://developer.apple.com/documentation/virtualization/vzvirtiosocketdeviceconfiguration?language=objc
type VirtioSocketDeviceConfiguration struct {
pointer

*baseSocketDeviceConfiguration
}

// NewVirtioSocketDeviceConfiguration creates a new VirtioSocketDeviceConfiguration.
Expand Down
16 changes: 16 additions & 0 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ package vz
import "C"
import "runtime"

type baseStorageDeviceAttachment struct{}

func (*baseStorageDeviceAttachment) storageDeviceAttachment() {}

// StorageDeviceAttachment for a storage device attachment.
//
// A storage device attachment defines how a virtual machine storage device interfaces with the host system.
// see: https://developer.apple.com/documentation/virtualization/vzstoragedeviceattachment?language=objc
type StorageDeviceAttachment interface {
NSObject

storageDeviceAttachment()
}

var _ StorageDeviceAttachment = (*DiskImageStorageDeviceAttachment)(nil)
Expand All @@ -25,6 +31,8 @@ var _ StorageDeviceAttachment = (*DiskImageStorageDeviceAttachment)(nil)
// see: https://developer.apple.com/documentation/virtualization/vzdiskimagestoragedeviceattachment?language=objc
type DiskImageStorageDeviceAttachment struct {
pointer

*baseStorageDeviceAttachment
}

// NewDiskImageStorageDeviceAttachment initialize the attachment from a local file path.
Expand Down Expand Up @@ -59,8 +67,14 @@ func NewDiskImageStorageDeviceAttachment(diskPath string, readOnly bool) (*DiskI
// StorageDeviceConfiguration for a storage device configuration.
type StorageDeviceConfiguration interface {
NSObject

storageDeviceConfiguration()
}

type baseStorageDeviceConfiguration struct{}

func (*baseStorageDeviceConfiguration) storageDeviceConfiguration() {}

var _ StorageDeviceConfiguration = (*VirtioBlockDeviceConfiguration)(nil)

// VirtioBlockDeviceConfiguration is a configuration of a paravirtualized storage device of type Virtio Block Device.
Expand All @@ -73,6 +87,8 @@ var _ StorageDeviceConfiguration = (*VirtioBlockDeviceConfiguration)(nil)
// see: https://developer.apple.com/documentation/virtualization/vzvirtioblockdeviceconfiguration?language=objc
type VirtioBlockDeviceConfiguration struct {
pointer

*baseStorageDeviceConfiguration
}

// NewVirtioBlockDeviceConfiguration initialize a VZVirtioBlockDeviceConfiguration with a device attachment.
Expand Down