// Code generated by cmd/cgo; DO NOT EDIT. //line /home/josie/.cache/paru/clone/wiiudownloader/src/pkg/mod/github.com/gotk3/gotk3@v0.6.5-0.20240618185848-ff349ae13f56/glib/list.go:1:1 package glib // #include // #include // #include "glib.go.h" import _ "unsafe" import ( "unsafe" ) /* * Linked Lists */ // List is a representation of Glib's GList. type List struct { list * /*line :17:8*/_Ctype_struct__GList /*line :17:23*/ // If set, dataWrap is called every time NthData() // or Data() is called to wrap raw underlying // value into appropriate type. dataWrap func(unsafe.Pointer) interface{} } func WrapList(obj uintptr) *List { return wrapList((* /*line :25:20*/_Ctype_struct__GList /*line :25:35*/)(unsafe.Pointer(obj))) } func wrapList(obj * /*line :28:20*/_Ctype_struct__GList /*line :28:35*/) *List { if obj == nil { return nil } return &List{list: obj} } func (v *List) wrapNewHead(obj * /*line :35:33*/_Ctype_struct__GList /*line :35:48*/) *List { if obj == nil { return nil } return &List{ list: obj, dataWrap: v.dataWrap, } } func (v *List) Native() uintptr { return uintptr(unsafe.Pointer(v.list)) } func (v *List) native() * /*line :49:26*/_Ctype_struct__GList /*line :49:41*/ { if v == nil || v.list == nil { return nil } return v.list } // DataWapper sets wrap functions, which is called during NthData() // and Data(). It's used to cast raw C data into appropriate // Go structures and types every time that data is retreived. func (v *List) DataWrapper(fn func(unsafe.Pointer) interface{}) { if v == nil { return } v.dataWrap = fn } // Append is a wrapper around g_list_append(). func (v *List) Append(data uintptr) *List { glist := func() *_Ctype_struct__GList{ _cgo0 := /*line :68:27*/v.native(); _cgo1 := _Ctype_gpointer /*line :68:49*/(data); _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgo1, nil); return /*line :68:56*/_Cfunc_g_list_append(_cgo0, _cgo1); }() return v.wrapNewHead(glist) } // Prepend is a wrapper around g_list_prepend(). func (v *List) Prepend(data uintptr) *List { glist := func() *_Ctype_struct__GList{ _cgo0 := /*line :74:28*/v.native(); _cgo1 := _Ctype_gpointer /*line :74:50*/(data); _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgo1, nil); return /*line :74:57*/_Cfunc_g_list_prepend(_cgo0, _cgo1); }() return v.wrapNewHead(glist) } // Insert is a wrapper around g_list_insert(). func (v *List) Insert(data uintptr, position int) *List { glist := func() *_Ctype_struct__GList{ _cgo0 := /*line :80:27*/v.native(); _cgo1 := _Ctype_gpointer /*line :80:49*/(data); var _cgo2 _Ctype_gint = _Ctype_gint /*line :80:63*/(position); _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgo1, nil); return /*line :80:74*/_Cfunc_g_list_insert(_cgo0, _cgo1, _cgo2); }() return v.wrapNewHead(glist) } // Length is a wrapper around g_list_length(). func (v *List) Length() uint { return uint(func() _Ctype_guint{ _cgo0 := /*line :86:30*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :86:41*/_Cfunc_g_list_length(_cgo0); }()) } // nthDataRaw is a wrapper around g_list_nth_data(). func (v *List) nthDataRaw(n uint) unsafe.Pointer { return unsafe.Pointer(func() _Ctype_gpointer{ _cgo0 := /*line :91:42*/v.native(); var _cgo1 _Ctype_guint = _Ctype_guint /*line :91:61*/(n); _cgoCheckPointer(_cgo0, nil); return /*line :91:65*/_Cfunc_g_list_nth_data(_cgo0, _cgo1); }()) } // Nth() is a wrapper around g_list_nth(). func (v *List) Nth(n uint) *List { list := wrapList(func() *_Ctype_struct__GList{ _cgo0 := /*line :96:32*/v.native(); var _cgo1 _Ctype_guint = _Ctype_guint /*line :96:51*/(n); _cgoCheckPointer(_cgo0, nil); return /*line :96:55*/_Cfunc_g_list_nth(_cgo0, _cgo1); }()) list.DataWrapper(v.dataWrap) return list } // NthData acts the same as g_list_nth_data(), but passes // retrieved value before returning through wrap function, set by DataWrapper(). // If no wrap function is set, it returns raw unsafe.Pointer. func (v *List) NthData(n uint) interface{} { ptr := v.nthDataRaw(n) if v.dataWrap != nil { return v.dataWrap(ptr) } return ptr } // Free is a wrapper around g_list_free(). func (v *List) Free() { func() { _cgo0 := /*line :114:16*/v.native(); _cgoCheckPointer(_cgo0, nil); /*line :114:27*/_Cfunc_g_list_free(_cgo0); }() } // Next is a wrapper around the next struct field func (v *List) Next() *List { return v.wrapNewHead(v.native().next) } // Previous is a wrapper around the prev struct field func (v *List) Previous() *List { return v.wrapNewHead(v.native().prev) } // First is a wrapper around g_list_first(). func (v *List) First() *List { return v.wrapNewHead(func() *_Ctype_struct__GList{ _cgo0 := /*line :129:38*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :129:49*/_Cfunc_g_list_first(_cgo0); }()) } // Last is a wrapper around g_list_last(). func (v *List) Last() *List { return v.wrapNewHead(func() *_Ctype_struct__GList{ _cgo0 := /*line :134:37*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :134:48*/_Cfunc_g_list_last(_cgo0); }()) } // Reverse is a wrapper around g_list_reverse(). func (v *List) Reverse() *List { return v.wrapNewHead(func() *_Ctype_struct__GList{ _cgo0 := /*line :139:40*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :139:51*/_Cfunc_g_list_reverse(_cgo0); }()) } // dataRaw is a wrapper around the data struct field func (v *List) dataRaw() unsafe.Pointer { return unsafe.Pointer(v.native().data) } // Data acts the same as data struct field, but passes // retrieved value before returning through wrap function, set by DataWrapper(). // If no wrap function is set, it returns raw unsafe.Pointer. func (v *List) Data() interface{} { ptr := v.dataRaw() if v.dataWrap != nil { return v.dataWrap(ptr) } return ptr } // Foreach acts the same as g_list_foreach(). // No user_data argument is implemented because of Go clojure capabilities. func (v *List) Foreach(fn func(item interface{})) { for l := v; l != nil; l = l.Next() { fn(l.Data()) } } // FreeFull acts the same as g_list_free_full(). // Calling list.FreeFull(fn) is equivalent to calling list.Foreach(fn) and // list.Free() sequentially. func (v *List) FreeFull(fn func(item interface{})) { v.Foreach(fn) v.Free() } // CompareDataFunc is a representation of GCompareDataFunc type CompareDataFunc func(a, b uintptr) int