mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 17:08:38 +00:00
19 lines
542 B
Go
19 lines
542 B
Go
package qt
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
type miqtCallbackFunc func(argc C.int, args *C.void)
|
|
|
|
//export miqt_exec_callback
|
|
func miqt_exec_callback(cb *C.void, argc C.int, args *C.void) {
|
|
// Our CABI for all callbacks is void(int, void*).
|
|
// Our Go ABI is CallbackFunc
|
|
// Then the Go bindings can unmarshal the arguments and C.free() them as necessary
|
|
cfunc, ok := (cgo.Handle(uintptr(unsafe.Pointer(cb))).Value()).(miqtCallbackFunc)
|
|
if !ok {
|
|
panic("miqt: callback of non-callback type (heap corruption?)")
|
|
}
|
|
|
|
cfunc(argc, args)
|
|
}
|