all: replace interface{} with any (#283)
- commit
- 1f4eb8c37f1752e5ec9754b70a277a2bcfb3d76b
- author
- TotallyGamerJet · · 2024-10-18 02:40 UTC
- committer
- GitHub · · 2024-10-18 02:40 UTC
- parent
- 0196f2d
- signature
- GPG Unverified
B5690EEEBB952194The key is unknown
8 files · +20 -20
M func.go +6 -6
| @@ -22,7 +22,7 @@ var thePool = sync.Pool{New: func() any { | |||
| 22 | 22 | ||
| 23 | 23 | // RegisterLibFunc is a wrapper around RegisterFunc that uses the C function returned from Dlsym(handle, name). | |
| 24 | 24 | // It panics if it can't find the name symbol. | |
| 25 | - | func RegisterLibFunc(fptr interface{}, handle uintptr, name string) { | |
| 25 | + | func RegisterLibFunc(fptr any, handle uintptr, name string) { | |
| 26 | 26 | sym, err := loadSymbol(handle, name) | |
| 27 | 27 | if err != nil { | |
| 28 | 28 | panic(err) | |
| @@ -65,7 +65,7 @@ func RegisterLibFunc(fptr interface{}, handle uintptr, name string) { | |||
| 65 | 65 | // | |
| 66 | 66 | // There is a special case when the last argument of fptr is a variadic interface (or []interface} | |
| 67 | 67 | // it will be expanded into a call to the C function as if it had the arguments in that slice. | |
| 68 | - | // This means that using arg ...interface{} is like a cast to the function with the arguments inside arg. | |
| 68 | + | // This means that using arg ...any is like a cast to the function with the arguments inside arg. | |
| 69 | 69 | // This is not the same as C variadic. | |
| 70 | 70 | // | |
| 71 | 71 | // # Memory | |
| @@ -110,7 +110,7 @@ func RegisterLibFunc(fptr interface{}, handle uintptr, name string) { | |||
| 110 | 110 | // defer free(mustFree) | |
| 111 | 111 | // | |
| 112 | 112 | // [Cgo rules]: https://pkg.go.dev/cmd/cgo#hdr-Go_references_to_C | |
| 113 | - | func RegisterFunc(fptr interface{}, cfn uintptr) { | |
| 113 | + | func RegisterFunc(fptr any, cfn uintptr) { | |
| 114 | 114 | fn := reflect.ValueOf(fptr).Elem() | |
| 115 | 115 | ty := fn.Type() | |
| 116 | 116 | if ty.Kind() != reflect.Func { | |
| @@ -248,7 +248,7 @@ func RegisterFunc(fptr interface{}, cfn uintptr) { | |||
| 248 | 248 | addFloat = addStack | |
| 249 | 249 | } | |
| 250 | 250 | ||
| 251 | - | var keepAlive []interface{} | |
| 251 | + | var keepAlive []any | |
| 252 | 252 | defer func() { | |
| 253 | 253 | runtime.KeepAlive(keepAlive) | |
| 254 | 254 | runtime.KeepAlive(args) | |
| @@ -271,7 +271,7 @@ func RegisterFunc(fptr interface{}, cfn uintptr) { | |||
| 271 | 271 | } | |
| 272 | 272 | } | |
| 273 | 273 | for i, v := range args { | |
| 274 | - | if variadic, ok := args[i].Interface().([]interface{}); ok { | |
| 274 | + | if variadic, ok := args[i].Interface().([]any); ok { | |
| 275 | 275 | if i != len(args)-1 { | |
| 276 | 276 | panic("purego: can only expand last parameter") | |
| 277 | 277 | } | |
| @@ -347,7 +347,7 @@ func RegisterFunc(fptr interface{}, cfn uintptr) { | |||
| 347 | 347 | fn.Set(v) | |
| 348 | 348 | } | |
| 349 | 349 | ||
| 350 | - | func addValue(v reflect.Value, keepAlive []interface{}, addInt func(x uintptr), addFloat func(x uintptr), addStack func(x uintptr), numInts *int, numFloats *int, numStack *int) []interface{} { | |
| 350 | + | func addValue(v reflect.Value, keepAlive []any, addInt func(x uintptr), addFloat func(x uintptr), addStack func(x uintptr), numInts *int, numFloats *int, numStack *int) []any { | |
| 351 | 351 | switch v.Kind() { | |
| 352 | 352 | case reflect.String: | |
| 353 | 353 | ptr := strings.CString(v.String()) | |
| @@ -22,7 +22,7 @@ var thePool = sync.Pool{New: func() any { | |||||
| 22 | 22 | ||||
| 23 | // RegisterLibFunc is a wrapper around RegisterFunc that uses the C function returned from Dlsym(handle, name). | 23 | // RegisterLibFunc is a wrapper around RegisterFunc that uses the C function returned from Dlsym(handle, name). | ||
| 24 | // It panics if it can't find the name symbol. | 24 | // It panics if it can't find the name symbol. | ||
| 25 | - | func RegisterLibFunc(fptr interface{}, handle uintptr, name string) { | 25 | + | func RegisterLibFunc(fptr any, handle uintptr, name string) { |
| 26 | sym, err := loadSymbol(handle, name) | 26 | sym, err := loadSymbol(handle, name) | ||
| 27 | if err != nil { | 27 | if err != nil { | ||
| 28 | panic(err) | 28 | panic(err) | ||
| @@ -65,7 +65,7 @@ func RegisterLibFunc(fptr interface{}, handle uintptr, name string) { | |||||
| 65 | // | 65 | // | ||
| 66 | // There is a special case when the last argument of fptr is a variadic interface (or []interface} | 66 | // There is a special case when the last argument of fptr is a variadic interface (or []interface} | ||
| 67 | // it will be expanded into a call to the C function as if it had the arguments in that slice. | 67 | // it will be expanded into a call to the C function as if it had the arguments in that slice. | ||
| 68 | - | // This means that using arg ...interface{} is like a cast to the function with the arguments inside arg. | 68 | + | // This means that using arg ...any is like a cast to the function with the arguments inside arg. |
| 69 | // This is not the same as C variadic. | 69 | // This is not the same as C variadic. | ||
| 70 | // | 70 | // | ||
| 71 | // # Memory | 71 | // # Memory | ||
| @@ -110,7 +110,7 @@ func RegisterLibFunc(fptr interface{}, handle uintptr, name string) { | |||||
| 110 | // defer free(mustFree) | 110 | // defer free(mustFree) | ||
| 111 | // | 111 | // | ||
| 112 | // [Cgo rules]: https://pkg.go.dev/cmd/cgo#hdr-Go_references_to_C | 112 | // [Cgo rules]: https://pkg.go.dev/cmd/cgo#hdr-Go_references_to_C | ||
| 113 | - | func RegisterFunc(fptr interface{}, cfn uintptr) { | 113 | + | func RegisterFunc(fptr any, cfn uintptr) { |
| 114 | fn := reflect.ValueOf(fptr).Elem() | 114 | fn := reflect.ValueOf(fptr).Elem() | ||
| 115 | ty := fn.Type() | 115 | ty := fn.Type() | ||
| 116 | if ty.Kind() != reflect.Func { | 116 | if ty.Kind() != reflect.Func { | ||
| @@ -248,7 +248,7 @@ func RegisterFunc(fptr interface{}, cfn uintptr) { | |||||
| 248 | addFloat = addStack | 248 | addFloat = addStack | ||
| 249 | } | 249 | } | ||
| 250 | 250 | ||||
| 251 | - | var keepAlive []interface{} | 251 | + | var keepAlive []any |
| 252 | defer func() { | 252 | defer func() { | ||
| 253 | runtime.KeepAlive(keepAlive) | 253 | runtime.KeepAlive(keepAlive) | ||
| 254 | runtime.KeepAlive(args) | 254 | runtime.KeepAlive(args) | ||
| @@ -271,7 +271,7 @@ func RegisterFunc(fptr interface{}, cfn uintptr) { | |||||
| 271 | } | 271 | } | ||
| 272 | } | 272 | } | ||
| 273 | for i, v := range args { | 273 | for i, v := range args { | ||
| 274 | - | if variadic, ok := args[i].Interface().([]interface{}); ok { | 274 | + | if variadic, ok := args[i].Interface().([]any); ok { |
| 275 | if i != len(args)-1 { | 275 | if i != len(args)-1 { | ||
| 276 | panic("purego: can only expand last parameter") | 276 | panic("purego: can only expand last parameter") | ||
| 277 | } | 277 | } | ||
| @@ -347,7 +347,7 @@ func RegisterFunc(fptr interface{}, cfn uintptr) { | |||||
| 347 | fn.Set(v) | 347 | fn.Set(v) | ||
| 348 | } | 348 | } | ||
| 349 | 349 | ||||
| 350 | - | func addValue(v reflect.Value, keepAlive []interface{}, addInt func(x uintptr), addFloat func(x uintptr), addStack func(x uintptr), numInts *int, numFloats *int, numStack *int) []interface{} { | 350 | + | func addValue(v reflect.Value, keepAlive []any, addInt func(x uintptr), addFloat func(x uintptr), addStack func(x uintptr), numInts *int, numFloats *int, numStack *int) []any { |
| 351 | switch v.Kind() { | 351 | switch v.Kind() { | ||
| 352 | case reflect.String: | 352 | case reflect.String: | ||
| 353 | ptr := strings.CString(v.String()) | 353 | ptr := strings.CString(v.String()) | ||
M objc/objc_runtime_darwin.go +6 -6
| @@ -23,10 +23,10 @@ import ( | |||
| 23 | 23 | var ( | |
| 24 | 24 | objc_msgSend_fn uintptr | |
| 25 | 25 | objc_msgSend_stret_fn uintptr | |
| 26 | - | objc_msgSend func(obj ID, cmd SEL, args ...interface{}) ID | |
| 26 | + | objc_msgSend func(obj ID, cmd SEL, args ...any) ID | |
| 27 | 27 | objc_msgSendSuper2_fn uintptr | |
| 28 | 28 | objc_msgSendSuper2_stret_fn uintptr | |
| 29 | - | objc_msgSendSuper2 func(super *objc_super, cmd SEL, args ...interface{}) ID | |
| 29 | + | objc_msgSendSuper2 func(super *objc_super, cmd SEL, args ...any) ID | |
| 30 | 30 | objc_getClass func(name string) Class | |
| 31 | 31 | objc_getProtocol func(name string) *Protocol | |
| 32 | 32 | objc_allocateClassPair func(super Class, name string, extraBytes uintptr) Class | |
| @@ -103,7 +103,7 @@ func (id ID) Class() Class { | |||
| 103 | 103 | // Send is a convenience method for sending messages to objects. This function takes a SEL | |
| 104 | 104 | // instead of a string since RegisterName grabs the global Objective-C lock. It is best to cache the result | |
| 105 | 105 | // of RegisterName. | |
| 106 | - | func (id ID) Send(sel SEL, args ...interface{}) ID { | |
| 106 | + | func (id ID) Send(sel SEL, args ...any) ID { | |
| 107 | 107 | return objc_msgSend(id, sel, args...) | |
| 108 | 108 | } | |
| 109 | 109 | ||
| @@ -147,7 +147,7 @@ type objc_super struct { | |||
| 147 | 147 | // SendSuper is a convenience method for sending message to object's super. This function takes a SEL | |
| 148 | 148 | // instead of a string since RegisterName grabs the global Objective-C lock. It is best to cache the result | |
| 149 | 149 | // of RegisterName. | |
| 150 | - | func (id ID) SendSuper(sel SEL, args ...interface{}) ID { | |
| 150 | + | func (id ID) SendSuper(sel SEL, args ...any) ID { | |
| 151 | 151 | super := &objc_super{ | |
| 152 | 152 | receiver: id, | |
| 153 | 153 | superClass: id.Class(), | |
| @@ -449,7 +449,7 @@ func encodeType(typ reflect.Type, insidePtr bool) (string, error) { | |||
| 449 | 449 | } | |
| 450 | 450 | ||
| 451 | 451 | // encodeFunc returns a functions type as if it was given to @encode(fn) | |
| 452 | - | func encodeFunc(fn interface{}) (string, error) { | |
| 452 | + | func encodeFunc(fn any) (string, error) { | |
| 453 | 453 | typ := reflect.TypeOf(fn) | |
| 454 | 454 | if typ.Kind() != reflect.Func { | |
| 455 | 455 | return "", errors.New("not a func") | |
| @@ -551,7 +551,7 @@ type IMP uintptr | |||
| 551 | 551 | // It returns an IMP function pointer that can be called by Objective-C code. | |
| 552 | 552 | // The function panics if an error occurs. | |
| 553 | 553 | // The function pointer is never deallocated. | |
| 554 | - | func NewIMP(fn interface{}) IMP { | |
| 554 | + | func NewIMP(fn any) IMP { | |
| 555 | 555 | ty := reflect.TypeOf(fn) | |
| 556 | 556 | if ty.Kind() != reflect.Func { | |
| 557 | 557 | panic("objc: not a function") | |
| @@ -23,10 +23,10 @@ import ( | |||||
| 23 | var ( | 23 | var ( | ||
| 24 | objc_msgSend_fn uintptr | 24 | objc_msgSend_fn uintptr | ||
| 25 | objc_msgSend_stret_fn uintptr | 25 | objc_msgSend_stret_fn uintptr | ||
| 26 | - | objc_msgSend func(obj ID, cmd SEL, args ...interface{}) ID | 26 | + | objc_msgSend func(obj ID, cmd SEL, args ...any) ID |
| 27 | objc_msgSendSuper2_fn uintptr | 27 | objc_msgSendSuper2_fn uintptr | ||
| 28 | objc_msgSendSuper2_stret_fn uintptr | 28 | objc_msgSendSuper2_stret_fn uintptr | ||
| 29 | - | objc_msgSendSuper2 func(super *objc_super, cmd SEL, args ...interface{}) ID | 29 | + | objc_msgSendSuper2 func(super *objc_super, cmd SEL, args ...any) ID |
| 30 | objc_getClass func(name string) Class | 30 | objc_getClass func(name string) Class | ||
| 31 | objc_getProtocol func(name string) *Protocol | 31 | objc_getProtocol func(name string) *Protocol | ||
| 32 | objc_allocateClassPair func(super Class, name string, extraBytes uintptr) Class | 32 | objc_allocateClassPair func(super Class, name string, extraBytes uintptr) Class | ||
| @@ -103,7 +103,7 @@ func (id ID) Class() Class { | |||||
| 103 | // Send is a convenience method for sending messages to objects. This function takes a SEL | 103 | // Send is a convenience method for sending messages to objects. This function takes a SEL | ||
| 104 | // instead of a string since RegisterName grabs the global Objective-C lock. It is best to cache the result | 104 | // instead of a string since RegisterName grabs the global Objective-C lock. It is best to cache the result | ||
| 105 | // of RegisterName. | 105 | // of RegisterName. | ||
| 106 | - | func (id ID) Send(sel SEL, args ...interface{}) ID { | 106 | + | func (id ID) Send(sel SEL, args ...any) ID { |
| 107 | return objc_msgSend(id, sel, args...) | 107 | return objc_msgSend(id, sel, args...) | ||
| 108 | } | 108 | } | ||
| 109 | 109 | ||||
| @@ -147,7 +147,7 @@ type objc_super struct { | |||||
| 147 | // SendSuper is a convenience method for sending message to object's super. This function takes a SEL | 147 | // SendSuper is a convenience method for sending message to object's super. This function takes a SEL | ||
| 148 | // instead of a string since RegisterName grabs the global Objective-C lock. It is best to cache the result | 148 | // instead of a string since RegisterName grabs the global Objective-C lock. It is best to cache the result | ||
| 149 | // of RegisterName. | 149 | // of RegisterName. | ||
| 150 | - | func (id ID) SendSuper(sel SEL, args ...interface{}) ID { | 150 | + | func (id ID) SendSuper(sel SEL, args ...any) ID { |
| 151 | super := &objc_super{ | 151 | super := &objc_super{ | ||
| 152 | receiver: id, | 152 | receiver: id, | ||
| 153 | superClass: id.Class(), | 153 | superClass: id.Class(), | ||
| @@ -449,7 +449,7 @@ func encodeType(typ reflect.Type, insidePtr bool) (string, error) { | |||||
| 449 | } | 449 | } | ||
| 450 | 450 | ||||
| 451 | // encodeFunc returns a functions type as if it was given to @encode(fn) | 451 | // encodeFunc returns a functions type as if it was given to @encode(fn) | ||
| 452 | - | func encodeFunc(fn interface{}) (string, error) { | 452 | + | func encodeFunc(fn any) (string, error) { |
| 453 | typ := reflect.TypeOf(fn) | 453 | typ := reflect.TypeOf(fn) | ||
| 454 | if typ.Kind() != reflect.Func { | 454 | if typ.Kind() != reflect.Func { | ||
| 455 | return "", errors.New("not a func") | 455 | return "", errors.New("not a func") | ||
| @@ -551,7 +551,7 @@ type IMP uintptr | |||||
| 551 | // It returns an IMP function pointer that can be called by Objective-C code. | 551 | // It returns an IMP function pointer that can be called by Objective-C code. | ||
| 552 | // The function panics if an error occurs. | 552 | // The function panics if an error occurs. | ||
| 553 | // The function pointer is never deallocated. | 553 | // The function pointer is never deallocated. | ||
| 554 | - | func NewIMP(fn interface{}) IMP { | 554 | + | func NewIMP(fn any) IMP { |
| 555 | ty := reflect.TypeOf(fn) | 555 | ty := reflect.TypeOf(fn) | ||
| 556 | if ty.Kind() != reflect.Func { | 556 | if ty.Kind() != reflect.Func { | ||
| 557 | panic("objc: not a function") | 557 | panic("objc: not a function") | ||
M struct_amd64.go +1 -1
| @@ -85,7 +85,7 @@ const ( | |||
| 85 | 85 | _MEMORY = 0b1111 | |
| 86 | 86 | ) | |
| 87 | 87 | ||
| 88 | - | func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []interface{}) []interface{} { | |
| 88 | + | func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []any) []any { | |
| 89 | 89 | if v.Type().Size() == 0 { | |
| 90 | 90 | return keepAlive | |
| 91 | 91 | } | |
| @@ -85,7 +85,7 @@ const ( | |||||
| 85 | _MEMORY = 0b1111 | 85 | _MEMORY = 0b1111 | ||
| 86 | ) | 86 | ) | ||
| 87 | 87 | ||||
| 88 | - | func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []interface{}) []interface{} { | 88 | + | func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []any) []any { |
| 89 | if v.Type().Size() == 0 { | 89 | if v.Type().Size() == 0 { | ||
| 90 | return keepAlive | 90 | return keepAlive | ||
| 91 | } | 91 | } | ||
M struct_arm64.go +2 -2
| @@ -65,7 +65,7 @@ const ( | |||
| 65 | 65 | _INT = 0b11 | |
| 66 | 66 | ) | |
| 67 | 67 | ||
| 68 | - | func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []interface{}) []interface{} { | |
| 68 | + | func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []any) []any { | |
| 69 | 69 | if v.Type().Size() == 0 { | |
| 70 | 70 | return keepAlive | |
| 71 | 71 | } | |
| @@ -187,7 +187,7 @@ func placeRegisters(v reflect.Value, addFloat func(uintptr), addInt func(uintptr | |||
| 187 | 187 | } | |
| 188 | 188 | } | |
| 189 | 189 | ||
| 190 | - | func placeStack(v reflect.Value, keepAlive []interface{}, addInt func(uintptr)) []interface{} { | |
| 190 | + | func placeStack(v reflect.Value, keepAlive []any, addInt func(uintptr)) []any { | |
| 191 | 191 | // Struct is too big to be placed in registers. | |
| 192 | 192 | // Copy to heap and place the pointer in register | |
| 193 | 193 | ptrStruct := reflect.New(v.Type()) | |
| @@ -65,7 +65,7 @@ const ( | |||||
| 65 | _INT = 0b11 | 65 | _INT = 0b11 | ||
| 66 | ) | 66 | ) | ||
| 67 | 67 | ||||
| 68 | - | func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []interface{}) []interface{} { | 68 | + | func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []any) []any { |
| 69 | if v.Type().Size() == 0 { | 69 | if v.Type().Size() == 0 { | ||
| 70 | return keepAlive | 70 | return keepAlive | ||
| 71 | } | 71 | } | ||
| @@ -187,7 +187,7 @@ func placeRegisters(v reflect.Value, addFloat func(uintptr), addInt func(uintptr | |||||
| 187 | } | 187 | } | ||
| 188 | } | 188 | } | ||
| 189 | 189 | ||||
| 190 | - | func placeStack(v reflect.Value, keepAlive []interface{}, addInt func(uintptr)) []interface{} { | 190 | + | func placeStack(v reflect.Value, keepAlive []any, addInt func(uintptr)) []any { |
| 191 | // Struct is too big to be placed in registers. | 191 | // Struct is too big to be placed in registers. | ||
| 192 | // Copy to heap and place the pointer in register | 192 | // Copy to heap and place the pointer in register | ||
| 193 | ptrStruct := reflect.New(v.Type()) | 193 | ptrStruct := reflect.New(v.Type()) | ||
M struct_other.go +1 -1
| @@ -7,7 +7,7 @@ package purego | |||
| 7 | 7 | ||
| 8 | 8 | import "reflect" | |
| 9 | 9 | ||
| 10 | - | func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []interface{}) []interface{} { | |
| 10 | + | func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []any) []any { | |
| 11 | 11 | panic("purego: struct arguments are not supported") | |
| 12 | 12 | } | |
| 13 | 13 | ||
| @@ -7,7 +7,7 @@ package purego | |||||
| 7 | 7 | ||||
| 8 | import "reflect" | 8 | import "reflect" | ||
| 9 | 9 | ||||
| 10 | - | func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []interface{}) []interface{} { | 10 | + | func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFloat, addStack func(uintptr), keepAlive []any) []any { |
| 11 | panic("purego: struct arguments are not supported") | 11 | panic("purego: struct arguments are not supported") | ||
| 12 | } | 12 | } | ||
| 13 | 13 | ||||
M syscall_cgo_linux.go +1 -1
| @@ -16,6 +16,6 @@ func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a | |||
| 16 | 16 | return cgo.Syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) | |
| 17 | 17 | } | |
| 18 | 18 | ||
| 19 | - | func NewCallback(_ interface{}) uintptr { | |
| 19 | + | func NewCallback(_ any) uintptr { | |
| 20 | 20 | panic("purego: NewCallback on Linux is only supported on amd64/arm64") | |
| 21 | 21 | } | |
| @@ -16,6 +16,6 @@ func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a | |||||
| 16 | return cgo.Syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) | 16 | return cgo.Syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) | ||
| 17 | } | 17 | } | ||
| 18 | 18 | ||||
| 19 | - | func NewCallback(_ interface{}) uintptr { | 19 | + | func NewCallback(_ any) uintptr { |
| 20 | panic("purego: NewCallback on Linux is only supported on amd64/arm64") | 20 | panic("purego: NewCallback on Linux is only supported on amd64/arm64") | ||
| 21 | } | 21 | } | ||
M syscall_sysv.go +2 -2
| @@ -31,7 +31,7 @@ func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a | |||
| 31 | 31 | // of uintptr. Only a limited number of callbacks may be created in a single Go process, and any memory allocated | |
| 32 | 32 | // for these callbacks is never released. At least 2000 callbacks can always be created. Although this function | |
| 33 | 33 | // provides similar functionality to windows.NewCallback it is distinct. | |
| 34 | - | func NewCallback(fn interface{}) uintptr { | |
| 34 | + | func NewCallback(fn any) uintptr { | |
| 35 | 35 | ty := reflect.TypeOf(fn) | |
| 36 | 36 | for i := 0; i < ty.NumIn(); i++ { | |
| 37 | 37 | in := ty.In(i) | |
| @@ -71,7 +71,7 @@ type callbackArgs struct { | |||
| 71 | 71 | result uintptr | |
| 72 | 72 | } | |
| 73 | 73 | ||
| 74 | - | func compileCallback(fn interface{}) uintptr { | |
| 74 | + | func compileCallback(fn any) uintptr { | |
| 75 | 75 | val := reflect.ValueOf(fn) | |
| 76 | 76 | if val.Kind() != reflect.Func { | |
| 77 | 77 | panic("purego: the type must be a function but was not") | |
| @@ -31,7 +31,7 @@ func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a | |||||
| 31 | // of uintptr. Only a limited number of callbacks may be created in a single Go process, and any memory allocated | 31 | // of uintptr. Only a limited number of callbacks may be created in a single Go process, and any memory allocated | ||
| 32 | // for these callbacks is never released. At least 2000 callbacks can always be created. Although this function | 32 | // for these callbacks is never released. At least 2000 callbacks can always be created. Although this function | ||
| 33 | // provides similar functionality to windows.NewCallback it is distinct. | 33 | // provides similar functionality to windows.NewCallback it is distinct. | ||
| 34 | - | func NewCallback(fn interface{}) uintptr { | 34 | + | func NewCallback(fn any) uintptr { |
| 35 | ty := reflect.TypeOf(fn) | 35 | ty := reflect.TypeOf(fn) | ||
| 36 | for i := 0; i < ty.NumIn(); i++ { | 36 | for i := 0; i < ty.NumIn(); i++ { | ||
| 37 | in := ty.In(i) | 37 | in := ty.In(i) | ||
| @@ -71,7 +71,7 @@ type callbackArgs struct { | |||||
| 71 | result uintptr | 71 | result uintptr | ||
| 72 | } | 72 | } | ||
| 73 | 73 | ||||
| 74 | - | func compileCallback(fn interface{}) uintptr { | 74 | + | func compileCallback(fn any) uintptr { |
| 75 | val := reflect.ValueOf(fn) | 75 | val := reflect.ValueOf(fn) | ||
| 76 | if val.Kind() != reflect.Func { | 76 | if val.Kind() != reflect.Func { | ||
| 77 | panic("purego: the type must be a function but was not") | 77 | panic("purego: the type must be a function but was not") | ||
M syscall_windows.go +1 -1
| @@ -22,7 +22,7 @@ func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a | |||
| 22 | 22 | // allocated for these callbacks is never released. Between NewCallback and NewCallbackCDecl, at least 1024 | |
| 23 | 23 | // callbacks can always be created. Although this function is similiar to the darwin version it may act | |
| 24 | 24 | // differently. | |
| 25 | - | func NewCallback(fn interface{}) uintptr { | |
| 25 | + | func NewCallback(fn any) uintptr { | |
| 26 | 26 | isCDecl := false | |
| 27 | 27 | ty := reflect.TypeOf(fn) | |
| 28 | 28 | for i := 0; i < ty.NumIn(); i++ { | |
| @@ -22,7 +22,7 @@ func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a | |||||
| 22 | // allocated for these callbacks is never released. Between NewCallback and NewCallbackCDecl, at least 1024 | 22 | // allocated for these callbacks is never released. Between NewCallback and NewCallbackCDecl, at least 1024 | ||
| 23 | // callbacks can always be created. Although this function is similiar to the darwin version it may act | 23 | // callbacks can always be created. Although this function is similiar to the darwin version it may act | ||
| 24 | // differently. | 24 | // differently. | ||
| 25 | - | func NewCallback(fn interface{}) uintptr { | 25 | + | func NewCallback(fn any) uintptr { |
| 26 | isCDecl := false | 26 | isCDecl := false | ||
| 27 | ty := reflect.TypeOf(fn) | 27 | ty := reflect.TypeOf(fn) | ||
| 28 | for i := 0; i < ty.NumIn(); i++ { | 28 | for i := 0; i < ty.NumIn(); i++ { | ||