// 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" ) // Specifies the type of function passed to g_dataset_foreach(). It is // called with each #GQuark id and associated data element, together // with the @user_data parameter supplied to g_dataset_foreach(). type DataForeachFunc func(Quark, uintptr, uintptr) // The type of functions that are used to 'duplicate' an object. // What this means depends on the context, it could just be // incrementing the reference count, if @data is a ref-counted // object. type DuplicateFunc func(uintptr, uintptr) uintptr // An opaque data structure that represents a keyed data list. // // See also: [Keyed data lists](datalist-and-dataset.html). type Data struct { _ structs.HostLayout } func (x *Data) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } const ( // A bitmask that restricts the possible flags passed to // g_datalist_set_flags(). Passing a flags value where // flags & ~G_DATALIST_FLAGS_MASK != 0 is an error. DATALIST_FLAGS_MASK int = 3 ) var xDatalistClear func(**Data) // Frees all the data elements of the datalist. // The data elements' destroy functions are called // if they have been set. func DatalistClear(DatalistVar **Data) { xDatalistClear(DatalistVar) } var xDatalistForeach func(**Data, uintptr, uintptr) // Calls the given function for each data element of the datalist. The // function is called with each data element's #GQuark id and data, // together with the given @user_data parameter. Note that this // function is NOT thread-safe. So unless @datalist can be protected // from any modifications during invocation of this function, it should // not be called. // // @func can make changes to @datalist, but the iteration will not // reflect changes made during the g_datalist_foreach() call, other // than skipping over elements that are removed. func DatalistForeach(DatalistVar **Data, FuncVar *DataForeachFunc, UserDataVar uintptr) { var FuncVarRef uintptr if FuncVar != nil { FuncVarPtr := uintptr(unsafe.Pointer(FuncVar)) if cbRefPtr, ok := GetCallback(FuncVarPtr); ok { FuncVarRef = cbRefPtr } else { fcb := func(arg0 Quark, arg1 uintptr, arg2 uintptr) { cbFn := *FuncVar cbFn(arg0, arg1, arg2) } FuncVarRef = purego.NewCallback(fcb) SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar) } } xDatalistForeach(DatalistVar, FuncVarRef, UserDataVar) } var xDatalistGetData func(**Data, string) uintptr // Gets a data element, using its string identifier. This is slower than // g_datalist_id_get_data() because it compares strings. func DatalistGetData(DatalistVar **Data, KeyVar string) uintptr { cret := xDatalistGetData(DatalistVar, KeyVar) return cret } var xDatalistGetFlags func(**Data) uint // Gets flags values packed in together with the datalist. // See g_datalist_set_flags(). func DatalistGetFlags(DatalistVar **Data) uint { cret := xDatalistGetFlags(DatalistVar) return cret } var xDatalistIdDupData func(**Data, Quark, uintptr, uintptr) uintptr // This is a variant of g_datalist_id_get_data() which // returns a 'duplicate' of the value. @dup_func defines the // meaning of 'duplicate' in this context, it could e.g. // take a reference on a ref-counted object. // // If the @key_id is not set in the datalist then @dup_func // will be called with a %NULL argument. // // Note that @dup_func is called while the datalist is locked, so it // is not allowed to read or modify the datalist. // // This function can be useful to avoid races when multiple // threads are using the same datalist and the same key. func DatalistIdDupData(DatalistVar **Data, KeyIdVar Quark, DupFuncVar *DuplicateFunc, UserDataVar uintptr) uintptr { var DupFuncVarRef uintptr if DupFuncVar != nil { DupFuncVarPtr := uintptr(unsafe.Pointer(DupFuncVar)) if cbRefPtr, ok := GetCallback(DupFuncVarPtr); ok { DupFuncVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr) uintptr { cbFn := *DupFuncVar return cbFn(arg0, arg1) } DupFuncVarRef = purego.NewCallback(fcb) SaveCallbackWithClosure(DupFuncVarPtr, DupFuncVarRef, DupFuncVar) } } cret := xDatalistIdDupData(DatalistVar, KeyIdVar, DupFuncVarRef, UserDataVar) return cret } var xDatalistIdGetData func(**Data, Quark) uintptr // Retrieves the data element corresponding to @key_id. func DatalistIdGetData(DatalistVar **Data, KeyIdVar Quark) uintptr { cret := xDatalistIdGetData(DatalistVar, KeyIdVar) return cret } var xDatalistIdRemoveMultiple func(**Data, []Quark, uint) // Removes multiple keys from a datalist. // // This is more efficient than calling g_datalist_id_remove_data() // multiple times in a row. // // Before 2.80, @n_keys had to be not larger than 16. // Since 2.84, performance is improved for larger number of keys. func DatalistIdRemoveMultiple(DatalistVar **Data, KeysVar []Quark, NKeysVar uint) { xDatalistIdRemoveMultiple(DatalistVar, KeysVar, NKeysVar) } var xDatalistIdRemoveNoNotify func(**Data, Quark) uintptr // Removes an element, without calling its destroy notification // function. func DatalistIdRemoveNoNotify(DatalistVar **Data, KeyIdVar Quark) uintptr { cret := xDatalistIdRemoveNoNotify(DatalistVar, KeyIdVar) return cret } var xDatalistIdReplaceData func(**Data, Quark, uintptr, uintptr, uintptr, *DestroyNotify) bool // Compares the member that is associated with @key_id in // @datalist to @oldval, and if they are the same, replace // @oldval with @newval. // // This is like a typical atomic compare-and-exchange // operation, for a member of @datalist. // // If the previous value was replaced then ownership of the // old value (@oldval) is passed to the caller, including // the registered destroy notify for it (passed out in @old_destroy). // Its up to the caller to free this as they wish, which may // or may not include using @old_destroy as sometimes replacement // should not destroy the object in the normal way. func DatalistIdReplaceData(DatalistVar **Data, KeyIdVar Quark, OldvalVar uintptr, NewvalVar uintptr, DestroyVar *DestroyNotify, OldDestroyVar *DestroyNotify) bool { var DestroyVarRef uintptr if DestroyVar != nil { DestroyVarPtr := uintptr(unsafe.Pointer(DestroyVar)) if cbRefPtr, ok := GetCallback(DestroyVarPtr); ok { DestroyVarRef = cbRefPtr } else { fcb := func(arg0 uintptr) { cbFn := *DestroyVar cbFn(arg0) } DestroyVarRef = purego.NewCallback(fcb) SaveCallbackWithClosure(DestroyVarPtr, DestroyVarRef, DestroyVar) } } cret := xDatalistIdReplaceData(DatalistVar, KeyIdVar, OldvalVar, NewvalVar, DestroyVarRef, OldDestroyVar) return cret } var xDatalistIdSetDataFull func(**Data, Quark, uintptr, uintptr) // Sets the data corresponding to the given #GQuark id, and the // function to be called when the element is removed from the datalist. // Any previous data with the same key is removed, and its destroy // function is called. func DatalistIdSetDataFull(DatalistVar **Data, KeyIdVar Quark, DataVar uintptr, DestroyFuncVar *DestroyNotify) { var DestroyFuncVarRef uintptr if DestroyFuncVar != nil { DestroyFuncVarPtr := uintptr(unsafe.Pointer(DestroyFuncVar)) if cbRefPtr, ok := GetCallback(DestroyFuncVarPtr); ok { DestroyFuncVarRef = cbRefPtr } else { fcb := func(arg0 uintptr) { cbFn := *DestroyFuncVar cbFn(arg0) } DestroyFuncVarRef = purego.NewCallback(fcb) SaveCallbackWithClosure(DestroyFuncVarPtr, DestroyFuncVarRef, DestroyFuncVar) } } xDatalistIdSetDataFull(DatalistVar, KeyIdVar, DataVar, DestroyFuncVarRef) } var xDatalistInit func(**Data) // Resets the datalist to %NULL. It does not free any memory or call // any destroy functions. func DatalistInit(DatalistVar **Data) { xDatalistInit(DatalistVar) } var xDatalistSetFlags func(**Data, uint) // Turns on flag values for a data list. This function is used // to keep a small number of boolean flags in an object with // a data list without using any additional space. It is // not generally useful except in circumstances where space // is very tight. (It is used in the base #GObject type, for // example.) func DatalistSetFlags(DatalistVar **Data, FlagsVar uint) { xDatalistSetFlags(DatalistVar, FlagsVar) } var xDatalistUnsetFlags func(**Data, uint) // Turns off flag values for a data list. See g_datalist_unset_flags() func DatalistUnsetFlags(DatalistVar **Data, FlagsVar uint) { xDatalistUnsetFlags(DatalistVar, FlagsVar) } var xDatasetDestroy func(uintptr) // Destroys the dataset, freeing all memory allocated, and calling any // destroy functions set for data elements. func DatasetDestroy(DatasetLocationVar uintptr) { xDatasetDestroy(DatasetLocationVar) } var xDatasetForeach func(uintptr, uintptr, uintptr) // Calls the given function for each data element which is associated // with the given location. Note that this function is NOT thread-safe. // So unless @dataset_location can be protected from any modifications // during invocation of this function, it should not be called. // // @func can make changes to the dataset, but the iteration will not // reflect changes made during the g_dataset_foreach() call, other // than skipping over elements that are removed. func DatasetForeach(DatasetLocationVar uintptr, FuncVar *DataForeachFunc, UserDataVar uintptr) { var FuncVarRef uintptr if FuncVar != nil { FuncVarPtr := uintptr(unsafe.Pointer(FuncVar)) if cbRefPtr, ok := GetCallback(FuncVarPtr); ok { FuncVarRef = cbRefPtr } else { fcb := func(arg0 Quark, arg1 uintptr, arg2 uintptr) { cbFn := *FuncVar cbFn(arg0, arg1, arg2) } FuncVarRef = purego.NewCallback(fcb) SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar) } } xDatasetForeach(DatasetLocationVar, FuncVarRef, UserDataVar) } var xDatasetIdGetData func(uintptr, Quark) uintptr // Gets the data element corresponding to a #GQuark. func DatasetIdGetData(DatasetLocationVar uintptr, KeyIdVar Quark) uintptr { cret := xDatasetIdGetData(DatasetLocationVar, KeyIdVar) return cret } var xDatasetIdRemoveNoNotify func(uintptr, Quark) uintptr // Removes an element, without calling its destroy notification // function. func DatasetIdRemoveNoNotify(DatasetLocationVar uintptr, KeyIdVar Quark) uintptr { cret := xDatasetIdRemoveNoNotify(DatasetLocationVar, KeyIdVar) return cret } var xDatasetIdSetDataFull func(uintptr, Quark, uintptr, uintptr) // Sets the data element associated with the given #GQuark id, and also // the function to call when the data element is destroyed. Any // previous data with the same key is removed, and its destroy function // is called. func DatasetIdSetDataFull(DatasetLocationVar uintptr, KeyIdVar Quark, DataVar uintptr, DestroyFuncVar *DestroyNotify) { var DestroyFuncVarRef uintptr if DestroyFuncVar != nil { DestroyFuncVarPtr := uintptr(unsafe.Pointer(DestroyFuncVar)) if cbRefPtr, ok := GetCallback(DestroyFuncVarPtr); ok { DestroyFuncVarRef = cbRefPtr } else { fcb := func(arg0 uintptr) { cbFn := *DestroyFuncVar cbFn(arg0) } DestroyFuncVarRef = purego.NewCallback(fcb) SaveCallbackWithClosure(DestroyFuncVarPtr, DestroyFuncVarRef, DestroyFuncVar) } } xDatasetIdSetDataFull(DatasetLocationVar, KeyIdVar, DataVar, DestroyFuncVarRef) } 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(&xDatalistClear, libs, "g_datalist_clear") core.PuregoSafeRegister(&xDatalistForeach, libs, "g_datalist_foreach") core.PuregoSafeRegister(&xDatalistGetData, libs, "g_datalist_get_data") core.PuregoSafeRegister(&xDatalistGetFlags, libs, "g_datalist_get_flags") core.PuregoSafeRegister(&xDatalistIdDupData, libs, "g_datalist_id_dup_data") core.PuregoSafeRegister(&xDatalistIdGetData, libs, "g_datalist_id_get_data") core.PuregoSafeRegister(&xDatalistIdRemoveMultiple, libs, "g_datalist_id_remove_multiple") core.PuregoSafeRegister(&xDatalistIdRemoveNoNotify, libs, "g_datalist_id_remove_no_notify") core.PuregoSafeRegister(&xDatalistIdReplaceData, libs, "g_datalist_id_replace_data") core.PuregoSafeRegister(&xDatalistIdSetDataFull, libs, "g_datalist_id_set_data_full") core.PuregoSafeRegister(&xDatalistInit, libs, "g_datalist_init") core.PuregoSafeRegister(&xDatalistSetFlags, libs, "g_datalist_set_flags") core.PuregoSafeRegister(&xDatalistUnsetFlags, libs, "g_datalist_unset_flags") core.PuregoSafeRegister(&xDatasetDestroy, libs, "g_dataset_destroy") core.PuregoSafeRegister(&xDatasetForeach, libs, "g_dataset_foreach") core.PuregoSafeRegister(&xDatasetIdGetData, libs, "g_dataset_id_get_data") core.PuregoSafeRegister(&xDatasetIdRemoveNoNotify, libs, "g_dataset_id_remove_no_notify") core.PuregoSafeRegister(&xDatasetIdSetDataFull, libs, "g_dataset_id_set_data_full") }