detached 98b19e9

fix(gir): consolidate callback wrapper logic and prevent namespace prefixing of builtin types

commit
98b19e958b5cf9c79bcd810175eef320e39721a1
author
brice · · 2025-12-12 06:19 UTC
parent
b4abf4e
signature
unsigned
2 files · +32 -90
M internal/gir/util/util.go +32 -0
@@ -93,15 +93,47 @@ func AddNamespace(val, ns string) string {
9393 if ns == "" || strings.Count(val, ".") >= 1 {
9494 return val
9595 }
96+ // Don't add namespace to Go builtin types
97+ if isGoBuiltinType(val) {
98+ return val
99+ }
96100 return PrefixValue(val, ns+".")
97101 }
98102
103+// goBuiltinTypes contains Go builtin types that should never be namespace-prefixed
104+var goBuiltinTypes = map[string]bool{
105+ "bool": true, "byte": true, "complex64": true, "complex128": true,
106+ "error": true, "float32": true, "float64": true, "int": true,
107+ "int8": true, "int16": true, "int32": true, "int64": true,
108+ "rune": true, "string": true, "uint": true, "uint8": true,
109+ "uint16": true, "uint32": true, "uint64": true, "uintptr": true,
110+}
111+
112+// isGoBuiltinType checks if the given type (after stripping pointers and slices) is a Go builtin
113+func isGoBuiltinType(gotype string) bool {
114+ // Strip pointer prefixes
115+ baseType := strings.TrimLeft(gotype, "*")
116+ // Strip slice prefix
117+ baseType = strings.TrimPrefix(baseType, "[]")
118+ // Strip any remaining pointers (e.g., *[]byte -> []byte -> byte)
119+ baseType = strings.TrimLeft(baseType, "*")
120+ return goBuiltinTypes[baseType]
121+}
122+
99123 // NormalizeNamespace converts a type to one that always includes a lowercase namespace
100124 // if no namespace is found, it adds `ns`, unless if strip is True then namespaces always equaling `ns` will be removed
101125 func NormalizeNamespace(ns string, gotype string, strip bool) string {
102126 if ns == "" {
103127 return ""
104128 }
129+
130+ // Check if this is a Go builtin type before any modifications
131+ // Note: gotype here may still have * prefixes which are trimmed below
132+ trimmedForCheck := strings.Trim(gotype, "*")
133+ if isGoBuiltinType(trimmedForCheck) {
134+ return trimmedForCheck
135+ }
136+
105137 gotype = strings.Trim(gotype, "*")
106138 splt := strings.Split(gotype, ".")
107139 if len(splt) <= 1 {
@@ -93,15 +93,47 @@ func AddNamespace(val, ns string) string {
93 if ns == "" || strings.Count(val, ".") >= 1 {93 if ns == "" || strings.Count(val, ".") >= 1 {
94 return val94 return val
95 }95 }
96+ // Don't add namespace to Go builtin types
97+ if isGoBuiltinType(val) {
98+ return val
99+ }
96 return PrefixValue(val, ns+".")100 return PrefixValue(val, ns+".")
97 }101 }
98 102
103+// goBuiltinTypes contains Go builtin types that should never be namespace-prefixed
104+var goBuiltinTypes = map[string]bool{
105+ "bool": true, "byte": true, "complex64": true, "complex128": true,
106+ "error": true, "float32": true, "float64": true, "int": true,
107+ "int8": true, "int16": true, "int32": true, "int64": true,
108+ "rune": true, "string": true, "uint": true, "uint8": true,
109+ "uint16": true, "uint32": true, "uint64": true, "uintptr": true,
110+}
111+
112+// isGoBuiltinType checks if the given type (after stripping pointers and slices) is a Go builtin
113+func isGoBuiltinType(gotype string) bool {
114+ // Strip pointer prefixes
115+ baseType := strings.TrimLeft(gotype, "*")
116+ // Strip slice prefix
117+ baseType = strings.TrimPrefix(baseType, "[]")
118+ // Strip any remaining pointers (e.g., *[]byte -> []byte -> byte)
119+ baseType = strings.TrimLeft(baseType, "*")
120+ return goBuiltinTypes[baseType]
121+}
122+
99 // NormalizeNamespace converts a type to one that always includes a lowercase namespace123 // NormalizeNamespace converts a type to one that always includes a lowercase namespace
100 // if no namespace is found, it adds `ns`, unless if strip is True then namespaces always equaling `ns` will be removed124 // if no namespace is found, it adds `ns`, unless if strip is True then namespaces always equaling `ns` will be removed
101 func NormalizeNamespace(ns string, gotype string, strip bool) string {125 func NormalizeNamespace(ns string, gotype string, strip bool) string {
102 if ns == "" {126 if ns == "" {
103 return ""127 return ""
104 }128 }
129+
130+ // Check if this is a Go builtin type before any modifications
131+ // Note: gotype here may still have * prefixes which are trimmed below
132+ trimmedForCheck := strings.Trim(gotype, "*")
133+ if isGoBuiltinType(trimmedForCheck) {
134+ return trimmedForCheck
135+ }
136+
105 gotype = strings.Trim(gotype, "*")137 gotype = strings.Trim(gotype, "*")
106 splt := strings.Split(gotype, ".")138 splt := strings.Split(gotype, ".")
107 if len(splt) <= 1 {139 if len(splt) <= 1 {
M templates/go +0 -90
@@ -69,7 +69,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
6969 {{.Ret.Preamble $NotGLib}}
7070 {{- /* Generate closure wrappers for callback parameters */}}
7171 {{range .Args.Callbacks}}
72- {{if .Nullable -}}
7372 var {{.Name}}Ref uintptr
7473 if {{.Name}} != nil {
7574 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
@@ -84,20 +83,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
8483 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
8584 }
8685 }
87- {{- else -}}
88- {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
89- var {{.Name}}Ref uintptr
90- if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback({{.Name}}Ptr); ok {
91- {{.Name}}Ref = cbRefPtr
92- } else {
93- fcb := func({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}} {{$t}}{{end}}) {{.RetRaw}} {
94- cbFn := *{{.Name}}
95- {{if .RetRaw}}return {{end}}cbFn({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}}{{end}})
96- }
97- {{.Name}}Ref = purego.NewCallback(fcb)
98- {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
99- }
100- {{- end}}
10186 {{end}}
10287 {{if .Ret.Value}}cret :={{end}}x{{.Name}}({{convd .Args.API.CallWithRefs}})
10388 {{.Ret.Fmt $NotGObject}}
@@ -113,7 +98,6 @@ func (x *{{$outer.Name}}) {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
11398 {{.Ret.Preamble $NotGLib}}
11499 {{- /* Generate closure wrappers for callback parameters */}}
115100 {{range .Args.Callbacks}}
116- {{if .Nullable -}}
117101 var {{.Name}}Ref uintptr
118102 if {{.Name}} != nil {
119103 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
@@ -128,20 +112,6 @@ func (x *{{$outer.Name}}) {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
128112 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
129113 }
130114 }
131- {{- else -}}
132- {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
133- var {{.Name}}Ref uintptr
134- if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback({{.Name}}Ptr); ok {
135- {{.Name}}Ref = cbRefPtr
136- } else {
137- fcb := func({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}} {{$t}}{{end}}) {{.RetRaw}} {
138- cbFn := *{{.Name}}
139- {{if .RetRaw}}return {{end}}cbFn({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}}{{end}})
140- }
141- {{.Name}}Ref = purego.NewCallback(fcb)
142- {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
143- }
144- {{- end}}
145115 {{end}}
146116 {{if .Ret.Value}}cret :={{end}}x{{$outer.Name}}{{.Name}}(x.GoPointer() {{convcd .Args.API.CallWithRefs}})
147117 {{.Ret.Fmt $NotGObject}}
@@ -306,7 +276,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
306276 {{.Ret.Preamble $NotGLib}}
307277 {{- /* Generate closure wrappers for callback parameters */}}
308278 {{range .Args.Callbacks}}
309- {{if .Nullable -}}
310279 var {{.Name}}Ref uintptr
311280 if {{.Name}} != nil {
312281 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
@@ -321,20 +290,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
321290 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
322291 }
323292 }
324- {{- else -}}
325- {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
326- var {{.Name}}Ref uintptr
327- if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback({{.Name}}Ptr); ok {
328- {{.Name}}Ref = cbRefPtr
329- } else {
330- fcb := func({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}} {{$t}}{{end}}) {{.RetRaw}} {
331- cbFn := *{{.Name}}
332- {{if .RetRaw}}return {{end}}cbFn({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}}{{end}})
333- }
334- {{.Name}}Ref = purego.NewCallback(fcb)
335- {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
336- }
337- {{- end}}
338293 {{end}}
339294 {{if .Ret.Value}}cret := {{end}}x{{.Name}}({{convd .Args.API.CallWithRefs}})
340295 {{.Ret.Fmt $NotGObject}}
@@ -373,7 +328,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
373328 {{.Ret.Preamble $NotGLib}}
374329 {{- /* Generate closure wrappers for callback parameters */}}
375330 {{range .Args.Callbacks}}
376- {{if .Nullable -}}
377331 var {{.Name}}Ref uintptr
378332 if {{.Name}} != nil {
379333 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
@@ -388,20 +342,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
388342 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
389343 }
390344 }
391- {{- else -}}
392- {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
393- var {{.Name}}Ref uintptr
394- if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback({{.Name}}Ptr); ok {
395- {{.Name}}Ref = cbRefPtr
396- } else {
397- fcb := func({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}} {{$t}}{{end}}) {{.RetRaw}} {
398- cbFn := *{{.Name}}
399- {{if .RetRaw}}return {{end}}cbFn({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}}{{end}})
400- }
401- {{.Name}}Ref = purego.NewCallback(fcb)
402- {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
403- }
404- {{- end}}
405345 {{end}}
406346 {{if .Ret.Value}}cret :={{end}}x{{.Name}}({{convd .Args.API.CallWithRefs}})
407347 {{.Ret.Fmt $NotGObject}}
@@ -417,7 +357,6 @@ func (x *{{$outer.Name}}) {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
417357 {{.Ret.Preamble $NotGLib}}
418358 {{- /* Generate closure wrappers for callback parameters */}}
419359 {{range .Args.Callbacks}}
420- {{if .Nullable -}}
421360 var {{.Name}}Ref uintptr
422361 if {{.Name}} != nil {
423362 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
@@ -432,20 +371,6 @@ func (x *{{$outer.Name}}) {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
432371 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
433372 }
434373 }
435- {{- else -}}
436- {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
437- var {{.Name}}Ref uintptr
438- if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback({{.Name}}Ptr); ok {
439- {{.Name}}Ref = cbRefPtr
440- } else {
441- fcb := func({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}} {{$t}}{{end}}) {{.RetRaw}} {
442- cbFn := *{{.Name}}
443- {{if .RetRaw}}return {{end}}cbFn({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}}{{end}})
444- }
445- {{.Name}}Ref = purego.NewCallback(fcb)
446- {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
447- }
448- {{- end}}
449374 {{end}}
450375 {{if .Ret.Value}}cret :={{end}}x{{$outer.Name}}{{.Name}}(x.GoPointer() {{convcd .Args.API.CallWithRefs}})
451376 {{.Ret.Fmt $NotGObject}}
@@ -532,7 +457,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
532457 {{.Ret.Preamble $NotGLib}}
533458 {{- /* Generate closure wrappers for callback parameters */}}
534459 {{range .Args.Callbacks}}
535- {{if .Nullable -}}
536460 var {{.Name}}Ref uintptr
537461 if {{.Name}} != nil {
538462 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
@@ -547,20 +471,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
547471 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
548472 }
549473 }
550- {{- else -}}
551- {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
552- var {{.Name}}Ref uintptr
553- if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback({{.Name}}Ptr); ok {
554- {{.Name}}Ref = cbRefPtr
555- } else {
556- fcb := func({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}} {{$t}}{{end}}) {{.RetRaw}} {
557- cbFn := *{{.Name}}
558- {{if .RetRaw}}return {{end}}cbFn({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}}{{end}})
559- }
560- {{.Name}}Ref = purego.NewCallback(fcb)
561- {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
562- }
563- {{- end}}
564474 {{end}}
565475 {{if .Ret.Value}}cret := {{end}}x{{.Name}}({{convd .Args.API.CallWithRefs}})
566476 {{.Ret.Fmt $NotGObject}}
@@ -69,7 +69,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
69 {{.Ret.Preamble $NotGLib}}69 {{.Ret.Preamble $NotGLib}}
70 {{- /* Generate closure wrappers for callback parameters */}}70 {{- /* Generate closure wrappers for callback parameters */}}
71 {{range .Args.Callbacks}}71 {{range .Args.Callbacks}}
72- {{if .Nullable -}}
73 var {{.Name}}Ref uintptr72 var {{.Name}}Ref uintptr
74 if {{.Name}} != nil {73 if {{.Name}} != nil {
75 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))74 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
@@ -84,20 +83,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
84 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)83 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
85 }84 }
86 }85 }
87- {{- else -}}
88- {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
89- var {{.Name}}Ref uintptr
90- if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback({{.Name}}Ptr); ok {
91- {{.Name}}Ref = cbRefPtr
92- } else {
93- fcb := func({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}} {{$t}}{{end}}) {{.RetRaw}} {
94- cbFn := *{{.Name}}
95- {{if .RetRaw}}return {{end}}cbFn({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}}{{end}})
96- }
97- {{.Name}}Ref = purego.NewCallback(fcb)
98- {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
99- }
100- {{- end}}
101 {{end}}86 {{end}}
102 {{if .Ret.Value}}cret :={{end}}x{{.Name}}({{convd .Args.API.CallWithRefs}})87 {{if .Ret.Value}}cret :={{end}}x{{.Name}}({{convd .Args.API.CallWithRefs}})
103 {{.Ret.Fmt $NotGObject}}88 {{.Ret.Fmt $NotGObject}}
@@ -113,7 +98,6 @@ func (x *{{$outer.Name}}) {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
113 {{.Ret.Preamble $NotGLib}}98 {{.Ret.Preamble $NotGLib}}
114 {{- /* Generate closure wrappers for callback parameters */}}99 {{- /* Generate closure wrappers for callback parameters */}}
115 {{range .Args.Callbacks}}100 {{range .Args.Callbacks}}
116- {{if .Nullable -}}
117 var {{.Name}}Ref uintptr101 var {{.Name}}Ref uintptr
118 if {{.Name}} != nil {102 if {{.Name}} != nil {
119 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))103 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
@@ -128,20 +112,6 @@ func (x *{{$outer.Name}}) {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
128 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)112 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
129 }113 }
130 }114 }
131- {{- else -}}
132- {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
133- var {{.Name}}Ref uintptr
134- if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback({{.Name}}Ptr); ok {
135- {{.Name}}Ref = cbRefPtr
136- } else {
137- fcb := func({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}} {{$t}}{{end}}) {{.RetRaw}} {
138- cbFn := *{{.Name}}
139- {{if .RetRaw}}return {{end}}cbFn({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}}{{end}})
140- }
141- {{.Name}}Ref = purego.NewCallback(fcb)
142- {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
143- }
144- {{- end}}
145 {{end}}115 {{end}}
146 {{if .Ret.Value}}cret :={{end}}x{{$outer.Name}}{{.Name}}(x.GoPointer() {{convcd .Args.API.CallWithRefs}})116 {{if .Ret.Value}}cret :={{end}}x{{$outer.Name}}{{.Name}}(x.GoPointer() {{convcd .Args.API.CallWithRefs}})
147 {{.Ret.Fmt $NotGObject}}117 {{.Ret.Fmt $NotGObject}}
@@ -306,7 +276,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
306 {{.Ret.Preamble $NotGLib}}276 {{.Ret.Preamble $NotGLib}}
307 {{- /* Generate closure wrappers for callback parameters */}}277 {{- /* Generate closure wrappers for callback parameters */}}
308 {{range .Args.Callbacks}}278 {{range .Args.Callbacks}}
309- {{if .Nullable -}}
310 var {{.Name}}Ref uintptr279 var {{.Name}}Ref uintptr
311 if {{.Name}} != nil {280 if {{.Name}} != nil {
312 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))281 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
@@ -321,20 +290,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
321 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)290 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
322 }291 }
323 }292 }
324- {{- else -}}
325- {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
326- var {{.Name}}Ref uintptr
327- if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback({{.Name}}Ptr); ok {
328- {{.Name}}Ref = cbRefPtr
329- } else {
330- fcb := func({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}} {{$t}}{{end}}) {{.RetRaw}} {
331- cbFn := *{{.Name}}
332- {{if .RetRaw}}return {{end}}cbFn({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}}{{end}})
333- }
334- {{.Name}}Ref = purego.NewCallback(fcb)
335- {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
336- }
337- {{- end}}
338 {{end}}293 {{end}}
339 {{if .Ret.Value}}cret := {{end}}x{{.Name}}({{convd .Args.API.CallWithRefs}})294 {{if .Ret.Value}}cret := {{end}}x{{.Name}}({{convd .Args.API.CallWithRefs}})
340 {{.Ret.Fmt $NotGObject}}295 {{.Ret.Fmt $NotGObject}}
@@ -373,7 +328,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
373 {{.Ret.Preamble $NotGLib}}328 {{.Ret.Preamble $NotGLib}}
374 {{- /* Generate closure wrappers for callback parameters */}}329 {{- /* Generate closure wrappers for callback parameters */}}
375 {{range .Args.Callbacks}}330 {{range .Args.Callbacks}}
376- {{if .Nullable -}}
377 var {{.Name}}Ref uintptr331 var {{.Name}}Ref uintptr
378 if {{.Name}} != nil {332 if {{.Name}} != nil {
379 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))333 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
@@ -388,20 +342,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
388 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)342 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
389 }343 }
390 }344 }
391- {{- else -}}
392- {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
393- var {{.Name}}Ref uintptr
394- if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback({{.Name}}Ptr); ok {
395- {{.Name}}Ref = cbRefPtr
396- } else {
397- fcb := func({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}} {{$t}}{{end}}) {{.RetRaw}} {
398- cbFn := *{{.Name}}
399- {{if .RetRaw}}return {{end}}cbFn({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}}{{end}})
400- }
401- {{.Name}}Ref = purego.NewCallback(fcb)
402- {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
403- }
404- {{- end}}
405 {{end}}345 {{end}}
406 {{if .Ret.Value}}cret :={{end}}x{{.Name}}({{convd .Args.API.CallWithRefs}})346 {{if .Ret.Value}}cret :={{end}}x{{.Name}}({{convd .Args.API.CallWithRefs}})
407 {{.Ret.Fmt $NotGObject}}347 {{.Ret.Fmt $NotGObject}}
@@ -417,7 +357,6 @@ func (x *{{$outer.Name}}) {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
417 {{.Ret.Preamble $NotGLib}}357 {{.Ret.Preamble $NotGLib}}
418 {{- /* Generate closure wrappers for callback parameters */}}358 {{- /* Generate closure wrappers for callback parameters */}}
419 {{range .Args.Callbacks}}359 {{range .Args.Callbacks}}
420- {{if .Nullable -}}
421 var {{.Name}}Ref uintptr360 var {{.Name}}Ref uintptr
422 if {{.Name}} != nil {361 if {{.Name}} != nil {
423 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))362 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
@@ -432,20 +371,6 @@ func (x *{{$outer.Name}}) {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
432 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)371 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
433 }372 }
434 }373 }
435- {{- else -}}
436- {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
437- var {{.Name}}Ref uintptr
438- if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback({{.Name}}Ptr); ok {
439- {{.Name}}Ref = cbRefPtr
440- } else {
441- fcb := func({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}} {{$t}}{{end}}) {{.RetRaw}} {
442- cbFn := *{{.Name}}
443- {{if .RetRaw}}return {{end}}cbFn({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}}{{end}})
444- }
445- {{.Name}}Ref = purego.NewCallback(fcb)
446- {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
447- }
448- {{- end}}
449 {{end}}374 {{end}}
450 {{if .Ret.Value}}cret :={{end}}x{{$outer.Name}}{{.Name}}(x.GoPointer() {{convcd .Args.API.CallWithRefs}})375 {{if .Ret.Value}}cret :={{end}}x{{$outer.Name}}{{.Name}}(x.GoPointer() {{convcd .Args.API.CallWithRefs}})
451 {{.Ret.Fmt $NotGObject}}376 {{.Ret.Fmt $NotGObject}}
@@ -532,7 +457,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
532 {{.Ret.Preamble $NotGLib}}457 {{.Ret.Preamble $NotGLib}}
533 {{- /* Generate closure wrappers for callback parameters */}}458 {{- /* Generate closure wrappers for callback parameters */}}
534 {{range .Args.Callbacks}}459 {{range .Args.Callbacks}}
535- {{if .Nullable -}}
536 var {{.Name}}Ref uintptr460 var {{.Name}}Ref uintptr
537 if {{.Name}} != nil {461 if {{.Name}} != nil {
538 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))462 {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
@@ -547,20 +471,6 @@ func {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
547 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)471 {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
548 }472 }
549 }473 }
550- {{- else -}}
551- {{.Name}}Ptr := uintptr(unsafe.Pointer({{.Name}}))
552- var {{.Name}}Ref uintptr
553- if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback({{.Name}}Ptr); ok {
554- {{.Name}}Ref = cbRefPtr
555- } else {
556- fcb := func({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}} {{$t}}{{end}}) {{.RetRaw}} {
557- cbFn := *{{.Name}}
558- {{if .RetRaw}}return {{end}}cbFn({{range $i, $t := .PureTypes}}{{if $i}}, {{end}}arg{{$i}}{{end}})
559- }
560- {{.Name}}Ref = purego.NewCallback(fcb)
561- {{if $NotGLib}}glib.{{end}}SaveCallback({{.Name}}Ptr, {{.Name}}Ref)
562- }
563- {{- end}}
564 {{end}}474 {{end}}
565 {{if .Ret.Value}}cret := {{end}}x{{.Name}}({{convd .Args.API.CallWithRefs}})475 {{if .Ret.Value}}cret := {{end}}x{{.Name}}({{convd .Args.API.CallWithRefs}})
566 {{.Ret.Fmt $NotGObject}}476 {{.Ret.Fmt $NotGObject}}

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