detached db73800

GIR: Port new property comment syntax to overrides

Signed-off-by: Felicitas Pojtinger <felicitas@pojtinger.com>
commit
db738000e9aee82a4a384f67f10fd08ae3f505bd
author
Felicitas Pojtinger · · 2025-10-30 06:52 UTC
committer
Jeroen Wijenbergh · · 2025-12-01 16:10 UTC
parent
4bdfabf
signature
unsigned
3 files · +18 -14
M internal/gir/pass/pass.go +1 -0
@@ -169,6 +169,7 @@ func (p *Pass) writeGo(r types.Repository, gotemp *template.Template, dir string
169169
170170 callbackAccessors = append(callbackAccessors, types.CallbackAccessor{
171171 Name: callbackName,
172+ CName: f.Name,
172173 Doc: doc,
173174 CallbackType: "func(" + strings.Join(apiTypes, ", ") + ") " + ret.Value,
174175 Args: args,
@@ -169,6 +169,7 @@ func (p *Pass) writeGo(r types.Repository, gotemp *template.Template, dir string
169 169
170 callbackAccessors = append(callbackAccessors, types.CallbackAccessor{170 callbackAccessors = append(callbackAccessors, types.CallbackAccessor{
171 Name: callbackName,171 Name: callbackName,
172+ CName: f.Name,
172 Doc: doc,173 Doc: doc,
173 CallbackType: "func(" + strings.Join(apiTypes, ", ") + ") " + ret.Value,174 CallbackType: "func(" + strings.Join(apiTypes, ", ") + ") " + ret.Value,
174 Args: args,175 Args: args,
M internal/gir/types/template.go +3 -0
@@ -191,6 +191,9 @@ type CallbackAccessor struct {
191191 // Name is the Go name of the callback field (without x prefix)
192192 Name string
193193
194+ // CName is the raw c name
195+ CName string
196+
194197 // Doc is the documentation for the callback
195198 Doc string
196199
@@ -191,6 +191,9 @@ type CallbackAccessor struct {
191 // Name is the Go name of the callback field (without x prefix)191 // Name is the Go name of the callback field (without x prefix)
192 Name string192 Name string
193 193
194+ // CName is the raw c name
195+ CName string
196+
194 // Doc is the documentation for the callback197 // Doc is the documentation for the callback
195 Doc string198 Doc string
196 199
M templates/go +14 -14
@@ -84,9 +84,9 @@ func (x *{{$outer.Name}}) {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
8484 {{end}}
8585
8686 {{range .CallbackAccessors -}}
87-{{if .Doc}}// Override{{.Name}} sets the callback function.
88-{{.Doc}}{{else}}// Override{{.Name}} sets the callback function.{{end}}
89-func (x *{{$outer.Name}}) Override{{.Name}}(cb {{.CallbackType}}) {
87+// Override{{.Name}} sets the "{{.CName}}" callback function.
88+{{if .Doc}}{{.Doc}}
89+{{end}}func (x *{{$outer.Name}}) Override{{.Name}}(cb {{.CallbackType}}) {
9090 if cb == nil {
9191 x.x{{.Name}} = 0
9292 } else {
@@ -100,9 +100,9 @@ func (x *{{$outer.Name}}) Override{{.Name}}(cb {{.CallbackType}}) {
100100 }
101101 }
102102
103-{{if .Doc}}// Get{{.Name}} gets the callback function.
104-{{.Doc}}{{else}}// Get{{.Name}} gets the callback function.{{end}}
105-func (x *{{$outer.Name}}) Get{{.Name}}() {{.CallbackType}} {
103+// Get{{.Name}} gets the "{{.CName}}" callback function.
104+{{if .Doc}}{{.Doc}}
105+{{end}}func (x *{{$outer.Name}}) Get{{.Name}}() {{.CallbackType}} {
106106 if x.x{{.Name}} == 0 {
107107 return nil
108108 }
@@ -167,8 +167,8 @@ func (x *{{$outer.Name}}Base) {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}}
167167 {{range .Properties -}}
168168 {{if .Writable}}
169169 // SetProperty{{.Name}} sets the "{{.CName}}" property.
170-{{.Doc}}
171-func (x *{{$outer.Name}}Base) SetProperty{{.Name}}(value {{.GoType}}) {
170+{{if .Doc}}{{.Doc}}
171+{{end}}func (x *{{$outer.Name}}Base) SetProperty{{.Name}}(value {{.GoType}}) {
172172 obj := {{if $NotGObject}}gobject.{{end}}Object{}
173173 obj.Ptr = x.GoPointer()
174174 var v {{if $NotGObject}}gobject.{{end}}Value
@@ -180,8 +180,8 @@ func (x *{{$outer.Name}}Base) SetProperty{{.Name}}(value {{.GoType}}) {
180180
181181 {{if .Readable}}
182182 // GetProperty{{.Name}} gets the "{{.CName}}" property.
183-{{.Doc}}
184-func (x *{{$outer.Name}}Base) GetProperty{{.Name}}() {{.GoType}} {
183+{{if .Doc}}{{.Doc}}
184+{{end}}func (x *{{$outer.Name}}Base) GetProperty{{.Name}}() {{.GoType}} {
185185 obj := {{if $NotGObject}}gobject.{{end}}Object{}
186186 obj.Ptr = x.GoPointer()
187187 var v {{if $NotGObject}}gobject.{{end}}Value
@@ -306,8 +306,8 @@ func (c *{{.Name}}) SetGoPointer(ptr uintptr) {
306306 {{range .Properties -}}
307307 {{if .Writable}}
308308 // SetProperty{{.Name}} sets the "{{.CName}}" property.
309-{{.Doc}}
310-func (x *{{$outer.Name}}) SetProperty{{.Name}}(value {{.GoType}}) {
309+{{if .Doc}}{{.Doc}}
310+{{end}}func (x *{{$outer.Name}}) SetProperty{{.Name}}(value {{.GoType}}) {
311311 var v {{if $NotGObject}}gobject.{{end}}Value
312312 v.Init({{if $NotGObject}}gobject.{{end}}{{.GValueType}})
313313 v.{{.SetMethod}}(value)
@@ -317,8 +317,8 @@ func (x *{{$outer.Name}}) SetProperty{{.Name}}(value {{.GoType}}) {
317317
318318 {{if .Readable}}
319319 // GetProperty{{.Name}} gets the "{{.CName}}" property.
320-{{.Doc}}
321-func (x *{{$outer.Name}}) GetProperty{{.Name}}() {{.GoType}} {
320+{{if .Doc}}{{.Doc}}
321+{{end}}func (x *{{$outer.Name}}) GetProperty{{.Name}}() {{.GoType}} {
322322 var v {{if $NotGObject}}gobject.{{end}}Value
323323 x.GetProperty("{{.CName}}", &v)
324324 return v.{{.GetMethod}}()
@@ -84,9 +84,9 @@ func (x *{{$outer.Name}}) {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}} {
84 {{end}}84 {{end}}
85 85
86 {{range .CallbackAccessors -}}86 {{range .CallbackAccessors -}}
87-{{if .Doc}}// Override{{.Name}} sets the callback function.87+// Override{{.Name}} sets the "{{.CName}}" callback function.
88-{{.Doc}}{{else}}// Override{{.Name}} sets the callback function.{{end}}88+{{if .Doc}}{{.Doc}}
89-func (x *{{$outer.Name}}) Override{{.Name}}(cb {{.CallbackType}}) {89+{{end}}func (x *{{$outer.Name}}) Override{{.Name}}(cb {{.CallbackType}}) {
90 if cb == nil {90 if cb == nil {
91 x.x{{.Name}} = 091 x.x{{.Name}} = 0
92 } else {92 } else {
@@ -100,9 +100,9 @@ func (x *{{$outer.Name}}) Override{{.Name}}(cb {{.CallbackType}}) {
100 }100 }
101 }101 }
102 102
103-{{if .Doc}}// Get{{.Name}} gets the callback function.103+// Get{{.Name}} gets the "{{.CName}}" callback function.
104-{{.Doc}}{{else}}// Get{{.Name}} gets the callback function.{{end}}104+{{if .Doc}}{{.Doc}}
105-func (x *{{$outer.Name}}) Get{{.Name}}() {{.CallbackType}} {105+{{end}}func (x *{{$outer.Name}}) Get{{.Name}}() {{.CallbackType}} {
106 if x.x{{.Name}} == 0 {106 if x.x{{.Name}} == 0 {
107 return nil107 return nil
108 }108 }
@@ -167,8 +167,8 @@ func (x *{{$outer.Name}}Base) {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Return}}
167 {{range .Properties -}}167 {{range .Properties -}}
168 {{if .Writable}}168 {{if .Writable}}
169 // SetProperty{{.Name}} sets the "{{.CName}}" property.169 // SetProperty{{.Name}} sets the "{{.CName}}" property.
170-{{.Doc}}170+{{if .Doc}}{{.Doc}}
171-func (x *{{$outer.Name}}Base) SetProperty{{.Name}}(value {{.GoType}}) {171+{{end}}func (x *{{$outer.Name}}Base) SetProperty{{.Name}}(value {{.GoType}}) {
172 obj := {{if $NotGObject}}gobject.{{end}}Object{}172 obj := {{if $NotGObject}}gobject.{{end}}Object{}
173 obj.Ptr = x.GoPointer()173 obj.Ptr = x.GoPointer()
174 var v {{if $NotGObject}}gobject.{{end}}Value174 var v {{if $NotGObject}}gobject.{{end}}Value
@@ -180,8 +180,8 @@ func (x *{{$outer.Name}}Base) SetProperty{{.Name}}(value {{.GoType}}) {
180 180
181 {{if .Readable}}181 {{if .Readable}}
182 // GetProperty{{.Name}} gets the "{{.CName}}" property.182 // GetProperty{{.Name}} gets the "{{.CName}}" property.
183-{{.Doc}}183+{{if .Doc}}{{.Doc}}
184-func (x *{{$outer.Name}}Base) GetProperty{{.Name}}() {{.GoType}} {184+{{end}}func (x *{{$outer.Name}}Base) GetProperty{{.Name}}() {{.GoType}} {
185 obj := {{if $NotGObject}}gobject.{{end}}Object{}185 obj := {{if $NotGObject}}gobject.{{end}}Object{}
186 obj.Ptr = x.GoPointer()186 obj.Ptr = x.GoPointer()
187 var v {{if $NotGObject}}gobject.{{end}}Value187 var v {{if $NotGObject}}gobject.{{end}}Value
@@ -306,8 +306,8 @@ func (c *{{.Name}}) SetGoPointer(ptr uintptr) {
306 {{range .Properties -}}306 {{range .Properties -}}
307 {{if .Writable}}307 {{if .Writable}}
308 // SetProperty{{.Name}} sets the "{{.CName}}" property.308 // SetProperty{{.Name}} sets the "{{.CName}}" property.
309-{{.Doc}}309+{{if .Doc}}{{.Doc}}
310-func (x *{{$outer.Name}}) SetProperty{{.Name}}(value {{.GoType}}) {310+{{end}}func (x *{{$outer.Name}}) SetProperty{{.Name}}(value {{.GoType}}) {
311 var v {{if $NotGObject}}gobject.{{end}}Value311 var v {{if $NotGObject}}gobject.{{end}}Value
312 v.Init({{if $NotGObject}}gobject.{{end}}{{.GValueType}})312 v.Init({{if $NotGObject}}gobject.{{end}}{{.GValueType}})
313 v.{{.SetMethod}}(value)313 v.{{.SetMethod}}(value)
@@ -317,8 +317,8 @@ func (x *{{$outer.Name}}) SetProperty{{.Name}}(value {{.GoType}}) {
317 317
318 {{if .Readable}}318 {{if .Readable}}
319 // GetProperty{{.Name}} gets the "{{.CName}}" property.319 // GetProperty{{.Name}} gets the "{{.CName}}" property.
320-{{.Doc}}320+{{if .Doc}}{{.Doc}}
321-func (x *{{$outer.Name}}) GetProperty{{.Name}}() {{.GoType}} {321+{{end}}func (x *{{$outer.Name}}) GetProperty{{.Name}}() {{.GoType}} {
322 var v {{if $NotGObject}}gobject.{{end}}Value322 var v {{if $NotGObject}}gobject.{{end}}Value
323 x.GetProperty("{{.CName}}", &v)323 x.GetProperty("{{.CName}}", &v)
324 return v.{{.GetMethod}}()324 return v.{{.GetMethod}}()

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