detached 4682f32

Gir: Return uintptr when a function returns a callback

commit
4682f322509f4850aa3dc9f3c88780c1e3b2957f
author
jwijenbergh · · 2023-10-09 15:32 UTC
parent
ea9da5c
signature
GPG Unverified1A2298F6C34F96E5 The key is unknown
7 files · +24 -18
M internal/gir/types/types.go +6 -0
@@ -689,6 +689,12 @@ func (r *ReturnValue) Template(ns string, ins string, kinds KindMap, throws bool
689689 raw = "uintptr"
690690 val += "Base"
691691 class = true
692+ // callback returns should always be uintptr
693+ // I needed this for glib.LogSetDefaultHandler
694+ // Otherwise I got 'panic: reflect.MakeFunc: value of type *glib.LogFunc is not assignable to type glib.LogFunc'
695+ case CallbackType:
696+ raw = "uintptr"
697+ val = "uintptr"
692698 }
693699 return funcRetTemplate{
694700 Raw: raw,
@@ -689,6 +689,12 @@ func (r *ReturnValue) Template(ns string, ins string, kinds KindMap, throws bool
689 raw = "uintptr"689 raw = "uintptr"
690 val += "Base"690 val += "Base"
691 class = true691 class = true
692+ // callback returns should always be uintptr
693+ // I needed this for glib.LogSetDefaultHandler
694+ // Otherwise I got 'panic: reflect.MakeFunc: value of type *glib.LogFunc is not assignable to type glib.LogFunc'
695+ case CallbackType:
696+ raw = "uintptr"
697+ val = "uintptr"
692 }698 }
693 return funcRetTemplate{699 return funcRetTemplate{
694 Raw: raw,700 Raw: raw,
M v4/glib/gmessages.go +6 -6
@@ -233,7 +233,7 @@ func LogSetDebugEnabled(EnabledVar bool) {
233233
234234 }
235235
236-var xLogSetDefaultHandler func(uintptr, uintptr) LogFunc
236+var xLogSetDefaultHandler func(uintptr, uintptr) uintptr
237237
238238 // Installs a default log handler which is used if no
239239 // log handler has been set for the particular log domain
@@ -242,7 +242,7 @@ var xLogSetDefaultHandler func(uintptr, uintptr) LogFunc
242242 //
243243 // This has no effect if structured logging is enabled; see
244244 // [Using Structured Logging][using-structured-logging].
245-func LogSetDefaultHandler(LogFuncVar LogFunc, UserDataVar uintptr) LogFunc {
245+func LogSetDefaultHandler(LogFuncVar LogFunc, UserDataVar uintptr) uintptr {
246246
247247 cret := xLogSetDefaultHandler(purego.NewCallback(LogFuncVar), UserDataVar)
248248 return cret
@@ -734,7 +734,7 @@ func ReturnIfFailWarning(LogDomainVar string, PrettyFunctionVar string, Expressi
734734
735735 }
736736
737-var xSetPrintHandler func(uintptr) PrintFunc
737+var xSetPrintHandler func(uintptr) uintptr
738738
739739 // Sets the print handler.
740740 //
@@ -743,13 +743,13 @@ var xSetPrintHandler func(uintptr) PrintFunc
743743 // the message to stdout. By providing your own handler
744744 // you can redirect the output, to a GTK+ widget or a
745745 // log file for example.
746-func SetPrintHandler(FuncVar PrintFunc) PrintFunc {
746+func SetPrintHandler(FuncVar PrintFunc) uintptr {
747747
748748 cret := xSetPrintHandler(purego.NewCallback(FuncVar))
749749 return cret
750750 }
751751
752-var xSetPrinterrHandler func(uintptr) PrintFunc
752+var xSetPrinterrHandler func(uintptr) uintptr
753753
754754 // Sets the handler for printing error messages.
755755 //
@@ -758,7 +758,7 @@ var xSetPrinterrHandler func(uintptr) PrintFunc
758758 // message to stderr. By providing your own handler you can
759759 // redirect the output, to a GTK+ widget or a log file for
760760 // example.
761-func SetPrinterrHandler(FuncVar PrintFunc) PrintFunc {
761+func SetPrinterrHandler(FuncVar PrintFunc) uintptr {
762762
763763 cret := xSetPrinterrHandler(purego.NewCallback(FuncVar))
764764 return cret
@@ -233,7 +233,7 @@ func LogSetDebugEnabled(EnabledVar bool) {
233 233
234 }234 }
235 235
236-var xLogSetDefaultHandler func(uintptr, uintptr) LogFunc236+var xLogSetDefaultHandler func(uintptr, uintptr) uintptr
237 237
238 // Installs a default log handler which is used if no238 // Installs a default log handler which is used if no
239 // log handler has been set for the particular log domain239 // log handler has been set for the particular log domain
@@ -242,7 +242,7 @@ var xLogSetDefaultHandler func(uintptr, uintptr) LogFunc
242 //242 //
243 // This has no effect if structured logging is enabled; see243 // This has no effect if structured logging is enabled; see
244 // [Using Structured Logging][using-structured-logging].244 // [Using Structured Logging][using-structured-logging].
245-func LogSetDefaultHandler(LogFuncVar LogFunc, UserDataVar uintptr) LogFunc {245+func LogSetDefaultHandler(LogFuncVar LogFunc, UserDataVar uintptr) uintptr {
246 246
247 cret := xLogSetDefaultHandler(purego.NewCallback(LogFuncVar), UserDataVar)247 cret := xLogSetDefaultHandler(purego.NewCallback(LogFuncVar), UserDataVar)
248 return cret248 return cret
@@ -734,7 +734,7 @@ func ReturnIfFailWarning(LogDomainVar string, PrettyFunctionVar string, Expressi
734 734
735 }735 }
736 736
737-var xSetPrintHandler func(uintptr) PrintFunc737+var xSetPrintHandler func(uintptr) uintptr
738 738
739 // Sets the print handler.739 // Sets the print handler.
740 //740 //
@@ -743,13 +743,13 @@ var xSetPrintHandler func(uintptr) PrintFunc
743 // the message to stdout. By providing your own handler743 // the message to stdout. By providing your own handler
744 // you can redirect the output, to a GTK+ widget or a744 // you can redirect the output, to a GTK+ widget or a
745 // log file for example.745 // log file for example.
746-func SetPrintHandler(FuncVar PrintFunc) PrintFunc {746+func SetPrintHandler(FuncVar PrintFunc) uintptr {
747 747
748 cret := xSetPrintHandler(purego.NewCallback(FuncVar))748 cret := xSetPrintHandler(purego.NewCallback(FuncVar))
749 return cret749 return cret
750 }750 }
751 751
752-var xSetPrinterrHandler func(uintptr) PrintFunc752+var xSetPrinterrHandler func(uintptr) uintptr
753 753
754 // Sets the handler for printing error messages.754 // Sets the handler for printing error messages.
755 //755 //
@@ -758,7 +758,7 @@ var xSetPrinterrHandler func(uintptr) PrintFunc
758 // message to stderr. By providing your own handler you can758 // message to stderr. By providing your own handler you can
759 // redirect the output, to a GTK+ widget or a log file for759 // redirect the output, to a GTK+ widget or a log file for
760 // example.760 // example.
761-func SetPrinterrHandler(FuncVar PrintFunc) PrintFunc {761+func SetPrinterrHandler(FuncVar PrintFunc) uintptr {
762 762
763 cret := xSetPrinterrHandler(purego.NewCallback(FuncVar))763 cret := xSetPrinterrHandler(purego.NewCallback(FuncVar))
764 return cret764 return cret
M v4/gtk/gtkbuilderscope.go +2 -2
@@ -137,11 +137,11 @@ func (x *BuilderCScope) AddCallbackSymbols(FirstCallbackNameVar string, FirstCal
137137
138138 }
139139
140-var xBuilderCScopeLookupCallbackSymbol func(uintptr, string) gobject.Callback
140+var xBuilderCScopeLookupCallbackSymbol func(uintptr, string) uintptr
141141
142142 // Fetches a symbol previously added with
143143 // gtk_builder_cscope_add_callback_symbol().
144-func (x *BuilderCScope) LookupCallbackSymbol(CallbackNameVar string) gobject.Callback {
144+func (x *BuilderCScope) LookupCallbackSymbol(CallbackNameVar string) uintptr {
145145
146146 cret := xBuilderCScopeLookupCallbackSymbol(x.GoPointer(), CallbackNameVar)
147147 return cret
@@ -137,11 +137,11 @@ func (x *BuilderCScope) AddCallbackSymbols(FirstCallbackNameVar string, FirstCal
137 137
138 }138 }
139 139
140-var xBuilderCScopeLookupCallbackSymbol func(uintptr, string) gobject.Callback140+var xBuilderCScopeLookupCallbackSymbol func(uintptr, string) uintptr
141 141
142 // Fetches a symbol previously added with142 // Fetches a symbol previously added with
143 // gtk_builder_cscope_add_callback_symbol().143 // gtk_builder_cscope_add_callback_symbol().
144-func (x *BuilderCScope) LookupCallbackSymbol(CallbackNameVar string) gobject.Callback {144+func (x *BuilderCScope) LookupCallbackSymbol(CallbackNameVar string) uintptr {
145 145
146 cret := xBuilderCScopeLookupCallbackSymbol(x.GoPointer(), CallbackNameVar)146 cret := xBuilderCScopeLookupCallbackSymbol(x.GoPointer(), CallbackNameVar)
147 return cret147 return cret
M v4/gtk/gtkcombobox.go +2 -2
@@ -287,10 +287,10 @@ func (x *ComboBox) GetPopupFixedWidth() bool {
287287 return cret
288288 }
289289
290-var xComboBoxGetRowSeparatorFunc func(uintptr) TreeViewRowSeparatorFunc
290+var xComboBoxGetRowSeparatorFunc func(uintptr) uintptr
291291
292292 // Returns the current row separator function.
293-func (x *ComboBox) GetRowSeparatorFunc() TreeViewRowSeparatorFunc {
293+func (x *ComboBox) GetRowSeparatorFunc() uintptr {
294294
295295 cret := xComboBoxGetRowSeparatorFunc(x.GoPointer())
296296 return cret
@@ -287,10 +287,10 @@ func (x *ComboBox) GetPopupFixedWidth() bool {
287 return cret287 return cret
288 }288 }
289 289
290-var xComboBoxGetRowSeparatorFunc func(uintptr) TreeViewRowSeparatorFunc290+var xComboBoxGetRowSeparatorFunc func(uintptr) uintptr
291 291
292 // Returns the current row separator function.292 // Returns the current row separator function.
293-func (x *ComboBox) GetRowSeparatorFunc() TreeViewRowSeparatorFunc {293+func (x *ComboBox) GetRowSeparatorFunc() uintptr {
294 294
295 cret := xComboBoxGetRowSeparatorFunc(x.GoPointer())295 cret := xComboBoxGetRowSeparatorFunc(x.GoPointer())
296 return cret296 return cret
M v4/gtk/gtktreeselection.go +2 -2
@@ -74,10 +74,10 @@ func (x *TreeSelection) GetMode() SelectionMode {
7474 return cret
7575 }
7676
77-var xTreeSelectionGetSelectFunction func(uintptr) TreeSelectionFunc
77+var xTreeSelectionGetSelectFunction func(uintptr) uintptr
7878
7979 // Returns the current selection function.
80-func (x *TreeSelection) GetSelectFunction() TreeSelectionFunc {
80+func (x *TreeSelection) GetSelectFunction() uintptr {
8181
8282 cret := xTreeSelectionGetSelectFunction(x.GoPointer())
8383 return cret
@@ -74,10 +74,10 @@ func (x *TreeSelection) GetMode() SelectionMode {
74 return cret74 return cret
75 }75 }
76 76
77-var xTreeSelectionGetSelectFunction func(uintptr) TreeSelectionFunc77+var xTreeSelectionGetSelectFunction func(uintptr) uintptr
78 78
79 // Returns the current selection function.79 // Returns the current selection function.
80-func (x *TreeSelection) GetSelectFunction() TreeSelectionFunc {80+func (x *TreeSelection) GetSelectFunction() uintptr {
81 81
82 cret := xTreeSelectionGetSelectFunction(x.GoPointer())82 cret := xTreeSelectionGetSelectFunction(x.GoPointer())
83 return cret83 return cret
M v4/gtk/gtktreeview.go +4 -4
@@ -617,10 +617,10 @@ func (x *TreeView) GetReorderable() bool {
617617 return cret
618618 }
619619
620-var xTreeViewGetRowSeparatorFunc func(uintptr) TreeViewRowSeparatorFunc
620+var xTreeViewGetRowSeparatorFunc func(uintptr) uintptr
621621
622622 // Returns the current row separator function.
623-func (x *TreeView) GetRowSeparatorFunc() TreeViewRowSeparatorFunc {
623+func (x *TreeView) GetRowSeparatorFunc() uintptr {
624624
625625 cret := xTreeViewGetRowSeparatorFunc(x.GoPointer())
626626 return cret
@@ -665,10 +665,10 @@ func (x *TreeView) GetSearchEntry() *EditableBase {
665665 return cls
666666 }
667667
668-var xTreeViewGetSearchEqualFunc func(uintptr) TreeViewSearchEqualFunc
668+var xTreeViewGetSearchEqualFunc func(uintptr) uintptr
669669
670670 // Returns the compare function currently in use.
671-func (x *TreeView) GetSearchEqualFunc() TreeViewSearchEqualFunc {
671+func (x *TreeView) GetSearchEqualFunc() uintptr {
672672
673673 cret := xTreeViewGetSearchEqualFunc(x.GoPointer())
674674 return cret
@@ -617,10 +617,10 @@ func (x *TreeView) GetReorderable() bool {
617 return cret617 return cret
618 }618 }
619 619
620-var xTreeViewGetRowSeparatorFunc func(uintptr) TreeViewRowSeparatorFunc620+var xTreeViewGetRowSeparatorFunc func(uintptr) uintptr
621 621
622 // Returns the current row separator function.622 // Returns the current row separator function.
623-func (x *TreeView) GetRowSeparatorFunc() TreeViewRowSeparatorFunc {623+func (x *TreeView) GetRowSeparatorFunc() uintptr {
624 624
625 cret := xTreeViewGetRowSeparatorFunc(x.GoPointer())625 cret := xTreeViewGetRowSeparatorFunc(x.GoPointer())
626 return cret626 return cret
@@ -665,10 +665,10 @@ func (x *TreeView) GetSearchEntry() *EditableBase {
665 return cls665 return cls
666 }666 }
667 667
668-var xTreeViewGetSearchEqualFunc func(uintptr) TreeViewSearchEqualFunc668+var xTreeViewGetSearchEqualFunc func(uintptr) uintptr
669 669
670 // Returns the compare function currently in use.670 // Returns the compare function currently in use.
671-func (x *TreeView) GetSearchEqualFunc() TreeViewSearchEqualFunc {671+func (x *TreeView) GetSearchEqualFunc() uintptr {
672 672
673 cret := xTreeViewGetSearchEqualFunc(x.GoPointer())673 cret := xTreeViewGetSearchEqualFunc(x.GoPointer())
674 return cret674 return cret
M v4/pangocairo/pangocairo.go +2 -2
@@ -166,7 +166,7 @@ func ContextGetResolution(ContextVar *pango.Context) float64 {
166166 return cret
167167 }
168168
169-var xContextGetShapeRenderer func(uintptr, uintptr) ShapeRendererFunc
169+var xContextGetShapeRenderer func(uintptr, uintptr) uintptr
170170
171171 // Sets callback function for context to use for rendering attributes
172172 // of type %PANGO_ATTR_SHAPE.
@@ -176,7 +176,7 @@ var xContextGetShapeRenderer func(uintptr, uintptr) ShapeRendererFunc
176176 // Retrieves callback function and associated user data for rendering
177177 // attributes of type %PANGO_ATTR_SHAPE as set by
178178 // [func@PangoCairo.context_set_shape_renderer], if any.
179-func ContextGetShapeRenderer(ContextVar *pango.Context, DataVar uintptr) ShapeRendererFunc {
179+func ContextGetShapeRenderer(ContextVar *pango.Context, DataVar uintptr) uintptr {
180180
181181 cret := xContextGetShapeRenderer(ContextVar.GoPointer(), DataVar)
182182 return cret
@@ -166,7 +166,7 @@ func ContextGetResolution(ContextVar *pango.Context) float64 {
166 return cret166 return cret
167 }167 }
168 168
169-var xContextGetShapeRenderer func(uintptr, uintptr) ShapeRendererFunc169+var xContextGetShapeRenderer func(uintptr, uintptr) uintptr
170 170
171 // Sets callback function for context to use for rendering attributes171 // Sets callback function for context to use for rendering attributes
172 // of type %PANGO_ATTR_SHAPE.172 // of type %PANGO_ATTR_SHAPE.
@@ -176,7 +176,7 @@ var xContextGetShapeRenderer func(uintptr, uintptr) ShapeRendererFunc
176 // Retrieves callback function and associated user data for rendering176 // Retrieves callback function and associated user data for rendering
177 // attributes of type %PANGO_ATTR_SHAPE as set by177 // attributes of type %PANGO_ATTR_SHAPE as set by
178 // [func@PangoCairo.context_set_shape_renderer], if any.178 // [func@PangoCairo.context_set_shape_renderer], if any.
179-func ContextGetShapeRenderer(ContextVar *pango.Context, DataVar uintptr) ShapeRendererFunc {179+func ContextGetShapeRenderer(ContextVar *pango.Context, DataVar uintptr) uintptr {
180 180
181 cret := xContextGetShapeRenderer(ContextVar.GoPointer(), DataVar)181 cret := xContextGetShapeRenderer(ContextVar.GoPointer(), DataVar)
182 return cret182 return cret

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close