Skip to content

Commit c04c75b

Browse files
committed
Separate VmnetNetwork into pkg/vmnet
Change `NewVmnetNetworkDeviceAttachment()` to take `unsafe.Pointer` instead of `*VmnetNetwork` Signed-off-by: Norio Nomura <[email protected]>
1 parent 19f23c6 commit c04c75b

File tree

7 files changed

+485
-363
lines changed

7 files changed

+485
-363
lines changed

network.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"net"
1414
"os"
1515
"syscall"
16+
"unsafe"
1617

1718
"github.com/Code-Hex/vz/v3/internal/objc"
1819
)
@@ -279,11 +280,8 @@ func (*VmnetNetworkDeviceAttachment) String() string {
279280
return "VmnetNetworkDeviceAttachment"
280281
}
281282

282-
func (v *VmnetNetworkDeviceAttachment) Network() *VmnetNetwork {
283-
network := C.VZVmnetNetworkDeviceAttachment_network(objc.Ptr(v))
284-
return &VmnetNetwork{
285-
pointer: objc.NewPointer(network),
286-
}
283+
func (v *VmnetNetworkDeviceAttachment) Network() unsafe.Pointer {
284+
return C.VZVmnetNetworkDeviceAttachment_network(objc.Ptr(v))
287285
}
288286

289287
var _ NetworkDeviceAttachment = (*VmnetNetworkDeviceAttachment)(nil)
@@ -292,16 +290,14 @@ var _ NetworkDeviceAttachment = (*VmnetNetworkDeviceAttachment)(nil)
292290
//
293291
// This is only supported on macOS 26 and newer, error will
294292
// be returned on older versions.
295-
func NewVmnetNetworkDeviceAttachment(network *VmnetNetwork) (*VmnetNetworkDeviceAttachment, error) {
293+
func NewVmnetNetworkDeviceAttachment(network unsafe.Pointer) (*VmnetNetworkDeviceAttachment, error) {
296294
if err := macOSAvailable(26); err != nil {
297295
return nil, err
298296
}
299297

300298
attachment := &VmnetNetworkDeviceAttachment{
301299
pointer: objc.NewPointer(
302-
C.newVZVmnetNetworkDeviceAttachment(
303-
objc.Ptr(network),
304-
),
300+
C.newVZVmnetNetworkDeviceAttachment(network),
305301
),
306302
}
307303
objc.SetFinalizer(attachment, func(self *VmnetNetworkDeviceAttachment) {
@@ -423,10 +419,6 @@ func (m *MACAddress) String() string {
423419
return cstring.String()
424420
}
425421

426-
func (m *MACAddress) ethernetAddress() C.ether_addr_t {
427-
return C.getVZMACAddressEthernetAddress(objc.Ptr(m))
428-
}
429-
430422
func (m *MACAddress) HardwareAddr() net.HardwareAddr {
431423
hw, _ := net.ParseMAC(m.String())
432424
return hw

0 commit comments

Comments
 (0)