// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT package glib import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" ) // Defines the type of a hook function that can be invoked // by g_hook_list_invoke_check(). type HookCheckFunc func(uintptr) bool // Defines the type of function used by g_hook_list_marshal_check(). type HookCheckMarshaller func(*Hook, uintptr) bool // Defines the type of function used to compare #GHook elements in // g_hook_insert_sorted(). type HookCompareFunc func(*Hook, *Hook) int // Defines the type of function to be called when a hook in a // list of hooks gets finalized. type HookFinalizeFunc func(*HookList, *Hook) // Defines the type of the function passed to g_hook_find(). type HookFindFunc func(*Hook, uintptr) bool // Defines the type of a hook function that can be invoked // by g_hook_list_invoke(). type HookFunc func(uintptr) // Defines the type of function used by g_hook_list_marshal(). type HookMarshaller func(*Hook, uintptr) // The #GHook struct represents a single hook function in a #GHookList. type Hook struct { _ structs.HostLayout Data uintptr Next *Hook Prev *Hook RefCount uint HookId uint Flags uint Func uintptr Destroy DestroyNotify } func (x *Hook) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } var xHookCompareIds func(uintptr, *Hook) int // Compares the ids of two #GHook elements, returning a negative value // if the second id is greater than the first. func (x *Hook) CompareIds(SiblingVar *Hook) int { cret := xHookCompareIds(x.GoPointer(), SiblingVar) return cret } // The #GHookList struct represents a list of hook functions. type HookList struct { _ structs.HostLayout SeqId uint HookSize uint IsSetup uint Hooks *Hook Dummy3 uintptr FinalizeHook HookFinalizeFunc Dummy [2]uintptr } func (x *HookList) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } var xHookListClear func(uintptr) // Removes all the #GHook elements from a #GHookList. func (x *HookList) Clear() { xHookListClear(x.GoPointer()) } var xHookListInit func(uintptr, uint) // Initializes a #GHookList. // This must be called before the #GHookList is used. func (x *HookList) Init(HookSizeVar uint) { xHookListInit(x.GoPointer(), HookSizeVar) } var xHookListInvoke func(uintptr, bool) // Calls all of the #GHook functions in a #GHookList. func (x *HookList) Invoke(MayRecurseVar bool) { xHookListInvoke(x.GoPointer(), MayRecurseVar) } var xHookListInvokeCheck func(uintptr, bool) // Calls all of the #GHook functions in a #GHookList. // Any function which returns %FALSE is removed from the #GHookList. func (x *HookList) InvokeCheck(MayRecurseVar bool) { xHookListInvokeCheck(x.GoPointer(), MayRecurseVar) } var xHookListMarshal func(uintptr, bool, uintptr, uintptr) // Calls a function on each valid #GHook. func (x *HookList) Marshal(MayRecurseVar bool, MarshallerVar *HookMarshaller, MarshalDataVar uintptr) { var MarshallerVarRef uintptr if MarshallerVar != nil { MarshallerVarPtr := uintptr(unsafe.Pointer(MarshallerVar)) if cbRefPtr, ok := GetCallback(MarshallerVarPtr); ok { MarshallerVarRef = cbRefPtr } else { fcb := func(arg0 *Hook, arg1 uintptr) { cbFn := *MarshallerVar cbFn(arg0, arg1) } MarshallerVarRef = purego.NewCallback(fcb) SaveCallbackWithClosure(MarshallerVarPtr, MarshallerVarRef, MarshallerVar) } } xHookListMarshal(x.GoPointer(), MayRecurseVar, MarshallerVarRef, MarshalDataVar) } var xHookListMarshalCheck func(uintptr, bool, uintptr, uintptr) // Calls a function on each valid #GHook and destroys it if the // function returns %FALSE. func (x *HookList) MarshalCheck(MayRecurseVar bool, MarshallerVar *HookCheckMarshaller, MarshalDataVar uintptr) { var MarshallerVarRef uintptr if MarshallerVar != nil { MarshallerVarPtr := uintptr(unsafe.Pointer(MarshallerVar)) if cbRefPtr, ok := GetCallback(MarshallerVarPtr); ok { MarshallerVarRef = cbRefPtr } else { fcb := func(arg0 *Hook, arg1 uintptr) bool { cbFn := *MarshallerVar return cbFn(arg0, arg1) } MarshallerVarRef = purego.NewCallback(fcb) SaveCallbackWithClosure(MarshallerVarPtr, MarshallerVarRef, MarshallerVar) } } xHookListMarshalCheck(x.GoPointer(), MayRecurseVar, MarshallerVarRef, MarshalDataVar) } const ( // The position of the first bit which is not reserved for internal // use be the #GHook implementation, i.e. // `1 << G_HOOK_FLAG_USER_SHIFT` is the first // bit which can be used for application-defined flags. HOOK_FLAG_USER_SHIFT int = 4 ) // Flags used internally in the #GHook implementation. type HookFlagMask int const ( // set if the hook has not been destroyed GHookFlagActiveValue HookFlagMask = 1 // set if the hook is currently being run GHookFlagInCallValue HookFlagMask = 2 // A mask covering all bits reserved for // hook flags; see %G_HOOK_FLAG_USER_SHIFT GHookFlagMaskValue HookFlagMask = 15 ) var xHookDestroy func(*HookList, uint) bool // Destroys a #GHook, given its ID. func HookDestroy(HookListVar *HookList, HookIdVar uint) bool { cret := xHookDestroy(HookListVar, HookIdVar) return cret } var xHookDestroyLink func(*HookList, *Hook) // Removes one #GHook from a #GHookList, marking it // inactive and calling g_hook_unref() on it. func HookDestroyLink(HookListVar *HookList, HookVar *Hook) { xHookDestroyLink(HookListVar, HookVar) } var xHookFree func(*HookList, *Hook) // Calls the #GHookList @finalize_hook function if it exists, // and frees the memory allocated for the #GHook. func HookFree(HookListVar *HookList, HookVar *Hook) { xHookFree(HookListVar, HookVar) } var xHookInsertBefore func(*HookList, *Hook, *Hook) // Inserts a #GHook into a #GHookList, before a given #GHook. func HookInsertBefore(HookListVar *HookList, SiblingVar *Hook, HookVar *Hook) { xHookInsertBefore(HookListVar, SiblingVar, HookVar) } var xHookInsertSorted func(*HookList, *Hook, uintptr) // Inserts a #GHook into a #GHookList, sorted by the given function. func HookInsertSorted(HookListVar *HookList, HookVar *Hook, FuncVar *HookCompareFunc) { var FuncVarRef uintptr if FuncVar != nil { FuncVarPtr := uintptr(unsafe.Pointer(FuncVar)) if cbRefPtr, ok := GetCallback(FuncVarPtr); ok { FuncVarRef = cbRefPtr } else { fcb := func(arg0 *Hook, arg1 *Hook) int { cbFn := *FuncVar return cbFn(arg0, arg1) } FuncVarRef = purego.NewCallback(fcb) SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar) } } xHookInsertSorted(HookListVar, HookVar, FuncVarRef) } var xHookPrepend func(*HookList, *Hook) // Prepends a #GHook on the start of a #GHookList. func HookPrepend(HookListVar *HookList, HookVar *Hook) { xHookPrepend(HookListVar, HookVar) } var xHookUnref func(*HookList, *Hook) // Decrements the reference count of a #GHook. // If the reference count falls to 0, the #GHook is removed // from the #GHookList and g_hook_free() is called to free it. func HookUnref(HookListVar *HookList, HookVar *Hook) { xHookUnref(HookListVar, HookVar) } func init() { core.SetPackageName("GLIB", "glib-2.0") core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("GLIB") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xHookDestroy, libs, "g_hook_destroy") core.PuregoSafeRegister(&xHookDestroyLink, libs, "g_hook_destroy_link") core.PuregoSafeRegister(&xHookFree, libs, "g_hook_free") core.PuregoSafeRegister(&xHookInsertBefore, libs, "g_hook_insert_before") core.PuregoSafeRegister(&xHookInsertSorted, libs, "g_hook_insert_sorted") core.PuregoSafeRegister(&xHookPrepend, libs, "g_hook_prepend") core.PuregoSafeRegister(&xHookUnref, libs, "g_hook_unref") core.PuregoSafeRegister(&xHookCompareIds, libs, "g_hook_compare_ids") core.PuregoSafeRegister(&xHookListClear, libs, "g_hook_list_clear") core.PuregoSafeRegister(&xHookListInit, libs, "g_hook_list_init") core.PuregoSafeRegister(&xHookListInvoke, libs, "g_hook_list_invoke") core.PuregoSafeRegister(&xHookListInvokeCheck, libs, "g_hook_list_invoke_check") core.PuregoSafeRegister(&xHookListMarshal, libs, "g_hook_list_marshal") core.PuregoSafeRegister(&xHookListMarshalCheck, libs, "g_hook_list_marshal_check") }