Gir: Return uintptr when a function returns a callback
- commit
- 4682f322509f4850aa3dc9f3c88780c1e3b2957f
- author
- jwijenbergh · · 2023-10-09 15:32 UTC
- parent
- ea9da5c
- signature
- GPG Unverified
1A2298F6C34F96E5The 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 | |||
| 689 | 689 | raw = "uintptr" | |
| 690 | 690 | val += "Base" | |
| 691 | 691 | 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 | 699 | return funcRetTemplate{ | |
| 694 | 700 | 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 = true | 691 | 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) { | |||
| 233 | 233 | ||
| 234 | 234 | } | |
| 235 | 235 | ||
| 236 | - | var xLogSetDefaultHandler func(uintptr, uintptr) LogFunc | |
| 236 | + | var xLogSetDefaultHandler func(uintptr, uintptr) uintptr | |
| 237 | 237 | ||
| 238 | 238 | // Installs a default log handler which is used if no | |
| 239 | 239 | // log handler has been set for the particular log domain | |
| @@ -242,7 +242,7 @@ var xLogSetDefaultHandler func(uintptr, uintptr) LogFunc | |||
| 242 | 242 | // | |
| 243 | 243 | // This has no effect if structured logging is enabled; see | |
| 244 | 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 | 247 | cret := xLogSetDefaultHandler(purego.NewCallback(LogFuncVar), UserDataVar) | |
| 248 | 248 | return cret | |
| @@ -734,7 +734,7 @@ func ReturnIfFailWarning(LogDomainVar string, PrettyFunctionVar string, Expressi | |||
| 734 | 734 | ||
| 735 | 735 | } | |
| 736 | 736 | ||
| 737 | - | var xSetPrintHandler func(uintptr) PrintFunc | |
| 737 | + | var xSetPrintHandler func(uintptr) uintptr | |
| 738 | 738 | ||
| 739 | 739 | // Sets the print handler. | |
| 740 | 740 | // | |
| @@ -743,13 +743,13 @@ var xSetPrintHandler func(uintptr) PrintFunc | |||
| 743 | 743 | // the message to stdout. By providing your own handler | |
| 744 | 744 | // you can redirect the output, to a GTK+ widget or a | |
| 745 | 745 | // log file for example. | |
| 746 | - | func SetPrintHandler(FuncVar PrintFunc) PrintFunc { | |
| 746 | + | func SetPrintHandler(FuncVar PrintFunc) uintptr { | |
| 747 | 747 | ||
| 748 | 748 | cret := xSetPrintHandler(purego.NewCallback(FuncVar)) | |
| 749 | 749 | return cret | |
| 750 | 750 | } | |
| 751 | 751 | ||
| 752 | - | var xSetPrinterrHandler func(uintptr) PrintFunc | |
| 752 | + | var xSetPrinterrHandler func(uintptr) uintptr | |
| 753 | 753 | ||
| 754 | 754 | // Sets the handler for printing error messages. | |
| 755 | 755 | // | |
| @@ -758,7 +758,7 @@ var xSetPrinterrHandler func(uintptr) PrintFunc | |||
| 758 | 758 | // message to stderr. By providing your own handler you can | |
| 759 | 759 | // redirect the output, to a GTK+ widget or a log file for | |
| 760 | 760 | // example. | |
| 761 | - | func SetPrinterrHandler(FuncVar PrintFunc) PrintFunc { | |
| 761 | + | func SetPrinterrHandler(FuncVar PrintFunc) uintptr { | |
| 762 | 762 | ||
| 763 | 763 | cret := xSetPrinterrHandler(purego.NewCallback(FuncVar)) | |
| 764 | 764 | return cret | |
| @@ -233,7 +233,7 @@ func LogSetDebugEnabled(EnabledVar bool) { | |||||
| 233 | 233 | ||||
| 234 | } | 234 | } | ||
| 235 | 235 | ||||
| 236 | - | var xLogSetDefaultHandler func(uintptr, uintptr) LogFunc | 236 | + | var xLogSetDefaultHandler func(uintptr, uintptr) uintptr |
| 237 | 237 | ||||
| 238 | // Installs a default log handler which is used if no | 238 | // Installs a default log handler which is used if no | ||
| 239 | // log handler has been set for the particular log domain | 239 | // 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; see | 243 | // 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 cret | 248 | return cret | ||
| @@ -734,7 +734,7 @@ func ReturnIfFailWarning(LogDomainVar string, PrettyFunctionVar string, Expressi | |||||
| 734 | 734 | ||||
| 735 | } | 735 | } | ||
| 736 | 736 | ||||
| 737 | - | var xSetPrintHandler func(uintptr) PrintFunc | 737 | + | 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 handler | 743 | // the message to stdout. By providing your own handler | ||
| 744 | // you can redirect the output, to a GTK+ widget or a | 744 | // 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 cret | 749 | return cret | ||
| 750 | } | 750 | } | ||
| 751 | 751 | ||||
| 752 | - | var xSetPrinterrHandler func(uintptr) PrintFunc | 752 | + | 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 can | 758 | // message to stderr. By providing your own handler you can | ||
| 759 | // redirect the output, to a GTK+ widget or a log file for | 759 | // 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 cret | 764 | return cret | ||
M v4/gtk/gtkbuilderscope.go +2 -2
| @@ -137,11 +137,11 @@ func (x *BuilderCScope) AddCallbackSymbols(FirstCallbackNameVar string, FirstCal | |||
| 137 | 137 | ||
| 138 | 138 | } | |
| 139 | 139 | ||
| 140 | - | var xBuilderCScopeLookupCallbackSymbol func(uintptr, string) gobject.Callback | |
| 140 | + | var xBuilderCScopeLookupCallbackSymbol func(uintptr, string) uintptr | |
| 141 | 141 | ||
| 142 | 142 | // Fetches a symbol previously added with | |
| 143 | 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 | 146 | cret := xBuilderCScopeLookupCallbackSymbol(x.GoPointer(), CallbackNameVar) | |
| 147 | 147 | 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.Callback | 140 | + | var xBuilderCScopeLookupCallbackSymbol func(uintptr, string) uintptr |
| 141 | 141 | ||||
| 142 | // Fetches a symbol previously added with | 142 | // 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 cret | 147 | return cret | ||
M v4/gtk/gtkcombobox.go +2 -2
| @@ -287,10 +287,10 @@ func (x *ComboBox) GetPopupFixedWidth() bool { | |||
| 287 | 287 | return cret | |
| 288 | 288 | } | |
| 289 | 289 | ||
| 290 | - | var xComboBoxGetRowSeparatorFunc func(uintptr) TreeViewRowSeparatorFunc | |
| 290 | + | var xComboBoxGetRowSeparatorFunc func(uintptr) uintptr | |
| 291 | 291 | ||
| 292 | 292 | // Returns the current row separator function. | |
| 293 | - | func (x *ComboBox) GetRowSeparatorFunc() TreeViewRowSeparatorFunc { | |
| 293 | + | func (x *ComboBox) GetRowSeparatorFunc() uintptr { | |
| 294 | 294 | ||
| 295 | 295 | cret := xComboBoxGetRowSeparatorFunc(x.GoPointer()) | |
| 296 | 296 | return cret | |
| @@ -287,10 +287,10 @@ func (x *ComboBox) GetPopupFixedWidth() bool { | |||||
| 287 | return cret | 287 | return cret | ||
| 288 | } | 288 | } | ||
| 289 | 289 | ||||
| 290 | - | var xComboBoxGetRowSeparatorFunc func(uintptr) TreeViewRowSeparatorFunc | 290 | + | 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 cret | 296 | return cret | ||
M v4/gtk/gtktreeselection.go +2 -2
| @@ -74,10 +74,10 @@ func (x *TreeSelection) GetMode() SelectionMode { | |||
| 74 | 74 | return cret | |
| 75 | 75 | } | |
| 76 | 76 | ||
| 77 | - | var xTreeSelectionGetSelectFunction func(uintptr) TreeSelectionFunc | |
| 77 | + | var xTreeSelectionGetSelectFunction func(uintptr) uintptr | |
| 78 | 78 | ||
| 79 | 79 | // Returns the current selection function. | |
| 80 | - | func (x *TreeSelection) GetSelectFunction() TreeSelectionFunc { | |
| 80 | + | func (x *TreeSelection) GetSelectFunction() uintptr { | |
| 81 | 81 | ||
| 82 | 82 | cret := xTreeSelectionGetSelectFunction(x.GoPointer()) | |
| 83 | 83 | return cret | |
| @@ -74,10 +74,10 @@ func (x *TreeSelection) GetMode() SelectionMode { | |||||
| 74 | return cret | 74 | return cret | ||
| 75 | } | 75 | } | ||
| 76 | 76 | ||||
| 77 | - | var xTreeSelectionGetSelectFunction func(uintptr) TreeSelectionFunc | 77 | + | 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 cret | 83 | return cret | ||
M v4/gtk/gtktreeview.go +4 -4
| @@ -617,10 +617,10 @@ func (x *TreeView) GetReorderable() bool { | |||
| 617 | 617 | return cret | |
| 618 | 618 | } | |
| 619 | 619 | ||
| 620 | - | var xTreeViewGetRowSeparatorFunc func(uintptr) TreeViewRowSeparatorFunc | |
| 620 | + | var xTreeViewGetRowSeparatorFunc func(uintptr) uintptr | |
| 621 | 621 | ||
| 622 | 622 | // Returns the current row separator function. | |
| 623 | - | func (x *TreeView) GetRowSeparatorFunc() TreeViewRowSeparatorFunc { | |
| 623 | + | func (x *TreeView) GetRowSeparatorFunc() uintptr { | |
| 624 | 624 | ||
| 625 | 625 | cret := xTreeViewGetRowSeparatorFunc(x.GoPointer()) | |
| 626 | 626 | return cret | |
| @@ -665,10 +665,10 @@ func (x *TreeView) GetSearchEntry() *EditableBase { | |||
| 665 | 665 | return cls | |
| 666 | 666 | } | |
| 667 | 667 | ||
| 668 | - | var xTreeViewGetSearchEqualFunc func(uintptr) TreeViewSearchEqualFunc | |
| 668 | + | var xTreeViewGetSearchEqualFunc func(uintptr) uintptr | |
| 669 | 669 | ||
| 670 | 670 | // Returns the compare function currently in use. | |
| 671 | - | func (x *TreeView) GetSearchEqualFunc() TreeViewSearchEqualFunc { | |
| 671 | + | func (x *TreeView) GetSearchEqualFunc() uintptr { | |
| 672 | 672 | ||
| 673 | 673 | cret := xTreeViewGetSearchEqualFunc(x.GoPointer()) | |
| 674 | 674 | return cret | |
| @@ -617,10 +617,10 @@ func (x *TreeView) GetReorderable() bool { | |||||
| 617 | return cret | 617 | return cret | ||
| 618 | } | 618 | } | ||
| 619 | 619 | ||||
| 620 | - | var xTreeViewGetRowSeparatorFunc func(uintptr) TreeViewRowSeparatorFunc | 620 | + | 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 cret | 626 | return cret | ||
| @@ -665,10 +665,10 @@ func (x *TreeView) GetSearchEntry() *EditableBase { | |||||
| 665 | return cls | 665 | return cls | ||
| 666 | } | 666 | } | ||
| 667 | 667 | ||||
| 668 | - | var xTreeViewGetSearchEqualFunc func(uintptr) TreeViewSearchEqualFunc | 668 | + | 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 cret | 674 | return cret | ||
M v4/pangocairo/pangocairo.go +2 -2
| @@ -166,7 +166,7 @@ func ContextGetResolution(ContextVar *pango.Context) float64 { | |||
| 166 | 166 | return cret | |
| 167 | 167 | } | |
| 168 | 168 | ||
| 169 | - | var xContextGetShapeRenderer func(uintptr, uintptr) ShapeRendererFunc | |
| 169 | + | var xContextGetShapeRenderer func(uintptr, uintptr) uintptr | |
| 170 | 170 | ||
| 171 | 171 | // Sets callback function for context to use for rendering attributes | |
| 172 | 172 | // of type %PANGO_ATTR_SHAPE. | |
| @@ -176,7 +176,7 @@ var xContextGetShapeRenderer func(uintptr, uintptr) ShapeRendererFunc | |||
| 176 | 176 | // Retrieves callback function and associated user data for rendering | |
| 177 | 177 | // attributes of type %PANGO_ATTR_SHAPE as set by | |
| 178 | 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 | 181 | cret := xContextGetShapeRenderer(ContextVar.GoPointer(), DataVar) | |
| 182 | 182 | return cret | |
| @@ -166,7 +166,7 @@ func ContextGetResolution(ContextVar *pango.Context) float64 { | |||||
| 166 | return cret | 166 | return cret | ||
| 167 | } | 167 | } | ||
| 168 | 168 | ||||
| 169 | - | var xContextGetShapeRenderer func(uintptr, uintptr) ShapeRendererFunc | 169 | + | var xContextGetShapeRenderer func(uintptr, uintptr) uintptr |
| 170 | 170 | ||||
| 171 | // Sets callback function for context to use for rendering attributes | 171 | // 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 rendering | 176 | // Retrieves callback function and associated user data for rendering | ||
| 177 | // attributes of type %PANGO_ATTR_SHAPE as set by | 177 | // 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 cret | 182 | return cret | ||