Skip to content

Commit

Permalink
darwin: moved type definitions near methods definition
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Aug 10, 2023
1 parent 80a3721 commit c1ded5f
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions enumerator/usb_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,6 @@ import (
"unsafe"
)

type io_iterator_t struct {
ioiterator C.io_iterator_t
}

type io_object_t struct {
ioobject C.io_object_t
}

type io_registry_entry_t struct {
ioregistryentry C.io_registry_entry_t
}

type cfStringRef struct {
cfs C.CFStringRef
}

type cfTypeRef struct {
cft C.CFTypeRef
}

func nativeGetDetailedPortsList() ([]*PortDetails, error) {
var ports []*PortDetails

Expand Down Expand Up @@ -158,6 +138,10 @@ func getMatchingServices(matcher C.CFMutableDictionaryRef) (io_iterator_t, error

// cfStringRef

type cfStringRef struct {
cfs C.CFStringRef
}

func CFStringCreateWithString(s string) cfStringRef {
c := C.CString(s)
defer C.free(unsafe.Pointer(c))
Expand All @@ -172,12 +156,20 @@ func (ref cfStringRef) Release() {

// CFTypeRef

type cfTypeRef struct {
cft C.CFTypeRef
}

func (ref cfTypeRef) Release() {
C.CFRelease(C.CFTypeRef(ref.cft))
}

// io_registry_entry_t

type io_registry_entry_t struct {
ioregistryentry C.io_registry_entry_t
}

func (me *io_registry_entry_t) GetParent(plane string) (io_registry_entry_t, error) {
cPlane := C.CString(plane)
defer C.free(unsafe.Pointer(cPlane))
Expand Down Expand Up @@ -234,6 +226,10 @@ func (me *io_registry_entry_t) GetIntProperty(key string, intType C.CFNumberType

// io_iterator_t

type io_iterator_t struct {
ioiterator C.io_iterator_t
}

// IsValid checks if an iterator is still valid.
// Some iterators will be made invalid if changes are made to the
// structure they are iterating over. This function checks the iterator
Expand All @@ -258,6 +254,10 @@ func (me *io_iterator_t) Release() {

// io_object_t

type io_object_t struct {
ioobject C.io_object_t
}

func (me *io_object_t) Release() {
C.IOObjectRelease(me.ioobject)
}
Expand Down

0 comments on commit c1ded5f

Please sign in to comment.