Gir: Quick hack to make gobject.Type an alias of types.GType
Co-authored-by: Peter Fern <github@0xc0dedbad.com>
- commit
- 0c73bf8173c265cf7f051df077cfe4d9e6937631
- author
- Jeroen Wijenbergh · · 2025-04-07 12:16 UTC
- committer
- Jeroen Wijenbergh · · 2025-04-07 12:23 UTC
- parent
- c67787d
- signature
- unsigned
2 files · +8 -1
M internal/gir/pass/pass.go +1 -1
| @@ -205,7 +205,7 @@ func (p *Pass) writeGo(r types.Repository, gotemp *template.Template, dir string | |||
| 205 | 205 | for _, alias := range ns.Aliases { | |
| 206 | 206 | fn := alias.FilenameSafe() | |
| 207 | 207 | files = append(files, fn) | |
| 208 | - | typeName := alias.Type.Template(ns.Name, p.Types, false) | |
| 208 | + | typeName := alias.Template(ns.Name, p.Types) | |
| 209 | 209 | if typeName == "" { | |
| 210 | 210 | typeName = "uintptr" | |
| 211 | 211 | } | |
| @@ -205,7 +205,7 @@ func (p *Pass) writeGo(r types.Repository, gotemp *template.Template, dir string | |||||
| 205 | for _, alias := range ns.Aliases { | 205 | for _, alias := range ns.Aliases { | ||
| 206 | fn := alias.FilenameSafe() | 206 | fn := alias.FilenameSafe() | ||
| 207 | files = append(files, fn) | 207 | files = append(files, fn) | ||
| 208 | - | typeName := alias.Type.Template(ns.Name, p.Types, false) | 208 | + | typeName := alias.Template(ns.Name, p.Types) |
| 209 | if typeName == "" { | 209 | if typeName == "" { | ||
| 210 | typeName = "uintptr" | 210 | typeName = "uintptr" | ||
| 211 | } | 211 | } | ||
M internal/gir/types/types.go +7 -0
| @@ -87,6 +87,13 @@ type Alias struct { | |||
| 87 | 87 | Type Type `xml:"http://www.gtk.org/introspection/core/1.0 type"` | |
| 88 | 88 | } | |
| 89 | 89 | ||
| 90 | + | func (a *Alias) Template(ns string, kinds KindMap) string { | |
| 91 | + | if v, ok := convList[a.CType]; ok { | |
| 92 | + | return util.NormalizeNamespace(ns, v, true) | |
| 93 | + | } | |
| 94 | + | return a.Type.Template(ns, kinds, false) | |
| 95 | + | } | |
| 96 | + | ||
| 90 | 97 | type AnyType struct { | |
| 91 | 98 | // Possible variants. | |
| 92 | 99 | Type *Type `xml:"http://www.gtk.org/introspection/core/1.0 type"` | |
| @@ -87,6 +87,13 @@ type Alias struct { | |||||
| 87 | Type Type `xml:"http://www.gtk.org/introspection/core/1.0 type"` | 87 | Type Type `xml:"http://www.gtk.org/introspection/core/1.0 type"` | ||
| 88 | } | 88 | } | ||
| 89 | 89 | ||||
| 90 | + | func (a *Alias) Template(ns string, kinds KindMap) string { | |||
| 91 | + | if v, ok := convList[a.CType]; ok { | |||
| 92 | + | return util.NormalizeNamespace(ns, v, true) | |||
| 93 | + | } | |||
| 94 | + | return a.Type.Template(ns, kinds, false) | |||
| 95 | + | } | |||
| 96 | + | ||||
| 90 | type AnyType struct { | 97 | type AnyType struct { | ||
| 91 | // Possible variants. | 98 | // Possible variants. | ||
| 92 | Type *Type `xml:"http://www.gtk.org/introspection/core/1.0 type"` | 99 | Type *Type `xml:"http://www.gtk.org/introspection/core/1.0 type"` | ||