detached 867f32f

Templates: early return from Connect method for readability.

commit
867f32f8d086a68579c99d7e266b552e86b668a5
author
Peter Fern · · 2024-03-05 10:35 UTC
committer
Jeroen Wijenbergh · · 2024-03-05 11:56 UTC
parent
fcf8a96
signature
unsigned
1 file · +18 -17
M templates/go +18 -17
@@ -186,24 +186,25 @@ func (c *{{.Name}}) SetGoPointer(ptr uintptr) {
186186 {{.Doc}}
187187 func (x *{{$outer.Name}}) Connect{{.Name}}(cb *func({{$outer.Name}} {{convc .Args.API.Types}}) {{.Ret.Value}}) uint32 {
188188 cbPtr := uintptr(unsafe.Pointer(cb))
189- cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback(cbPtr)
190- if !ok {
191- fcb := func(clsPtr uintptr {{convc .Args.Pure.Full}}) {{.Ret.Raw}} {
192- fa := {{$outer.Name}}{}
193- fa.Ptr = clsPtr
194- cbFn := *cb
195- {{if .Ret.Class}}
196- {{.Name}}Cls := cbFn(fa {{convc .Args.Pure.Call}})
197- return {{.Name}}Cls.Ptr
198- {{else if .Ret.Value}}
199- return cbFn(fa {{convc .Args.Pure.Call}})
200- {{else}}
201- cbFn(fa {{convc .Args.Pure.Call}})
202- {{end}}
203- }
204- cbRefPtr = purego.NewCallback(fcb)
205- {{if $NotGLib}}glib.{{end}}SaveCallback(cbPtr, cbRefPtr)
189+ if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback(cbPtr); ok {
190+ return {{if $NotGObject}}gobject.{{end}}SignalConnect(x.GoPointer(), "{{.CName}}", cbRefPtr)
206191 }
192+
193+ fcb := func(clsPtr uintptr {{convc .Args.Pure.Full}}) {{.Ret.Raw}} {
194+ fa := {{$outer.Name}}{}
195+ fa.Ptr = clsPtr
196+ cbFn := *cb
197+ {{if .Ret.Class}}
198+ {{.Name}}Cls := cbFn(fa {{convc .Args.Pure.Call}})
199+ return {{.Name}}Cls.Ptr
200+ {{else if .Ret.Value}}
201+ return cbFn(fa {{convc .Args.Pure.Call}})
202+ {{else}}
203+ cbFn(fa {{convc .Args.Pure.Call}})
204+ {{end}}
205+ }
206+ cbRefPtr := purego.NewCallback(fcb)
207+ {{if $NotGLib}}glib.{{end}}SaveCallback(cbPtr, cbRefPtr)
207208 return {{if $NotGObject}}gobject.{{end}}SignalConnect(x.GoPointer(), "{{.CName}}", cbRefPtr)
208209 }
209210 {{end}}
@@ -186,24 +186,25 @@ func (c *{{.Name}}) SetGoPointer(ptr uintptr) {
186 {{.Doc}}186 {{.Doc}}
187 func (x *{{$outer.Name}}) Connect{{.Name}}(cb *func({{$outer.Name}} {{convc .Args.API.Types}}) {{.Ret.Value}}) uint32 {187 func (x *{{$outer.Name}}) Connect{{.Name}}(cb *func({{$outer.Name}} {{convc .Args.API.Types}}) {{.Ret.Value}}) uint32 {
188 cbPtr := uintptr(unsafe.Pointer(cb))188 cbPtr := uintptr(unsafe.Pointer(cb))
189- cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback(cbPtr)189+ if cbRefPtr, ok := {{if $NotGLib}}glib.{{end}}GetCallback(cbPtr); ok {
190- if !ok {190+ return {{if $NotGObject}}gobject.{{end}}SignalConnect(x.GoPointer(), "{{.CName}}", cbRefPtr)
191- fcb := func(clsPtr uintptr {{convc .Args.Pure.Full}}) {{.Ret.Raw}} {
192- fa := {{$outer.Name}}{}
193- fa.Ptr = clsPtr
194- cbFn := *cb
195- {{if .Ret.Class}}
196- {{.Name}}Cls := cbFn(fa {{convc .Args.Pure.Call}})
197- return {{.Name}}Cls.Ptr
198- {{else if .Ret.Value}}
199- return cbFn(fa {{convc .Args.Pure.Call}})
200- {{else}}
201- cbFn(fa {{convc .Args.Pure.Call}})
202- {{end}}
203- }
204- cbRefPtr = purego.NewCallback(fcb)
205- {{if $NotGLib}}glib.{{end}}SaveCallback(cbPtr, cbRefPtr)
206 }191 }
192+
193+ fcb := func(clsPtr uintptr {{convc .Args.Pure.Full}}) {{.Ret.Raw}} {
194+ fa := {{$outer.Name}}{}
195+ fa.Ptr = clsPtr
196+ cbFn := *cb
197+ {{if .Ret.Class}}
198+ {{.Name}}Cls := cbFn(fa {{convc .Args.Pure.Call}})
199+ return {{.Name}}Cls.Ptr
200+ {{else if .Ret.Value}}
201+ return cbFn(fa {{convc .Args.Pure.Call}})
202+ {{else}}
203+ cbFn(fa {{convc .Args.Pure.Call}})
204+ {{end}}
205+ }
206+ cbRefPtr := purego.NewCallback(fcb)
207+ {{if $NotGLib}}glib.{{end}}SaveCallback(cbPtr, cbRefPtr)
207 return {{if $NotGObject}}gobject.{{end}}SignalConnect(x.GoPointer(), "{{.CName}}", cbRefPtr)208 return {{if $NotGObject}}gobject.{{end}}SignalConnect(x.GoPointer(), "{{.CName}}", cbRefPtr)
208 }209 }
209 {{end}}210 {{end}}

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