GIR: Generate GLib get-type
- commit
- 02993709940347e959a44672206454d061e62cda
- author
- Jeroen Wijenbergh · · 2024-12-18 10:25 UTC
- committer
- Jeroen Wijenbergh · · 2025-04-07 12:23 UTC
- parent
- 99a6c14
- signature
- unsigned
6 files · +80 -10
M internal/gir/pass/pass.go +2 -0
| @@ -163,6 +163,7 @@ func (p *Pass) writeGo(r types.Repository, gotemp *template.Template, dir string | |||
| 163 | 163 | Constructors: constructors, | |
| 164 | 164 | Receivers: receivers, | |
| 165 | 165 | Fields: fields, | |
| 166 | + | TypeGetter: rec.GLibGetType, | |
| 166 | 167 | }) | |
| 167 | 168 | recordLookup[name] = true | |
| 168 | 169 | } | |
| @@ -298,6 +299,7 @@ func (p *Pass) writeGo(r types.Repository, gotemp *template.Template, dir string | |||
| 298 | 299 | Interfaces: interfaces, | |
| 299 | 300 | Functions: functions, | |
| 300 | 301 | Signals: signals, | |
| 302 | + | TypeGetter: cls.GLibGetType, | |
| 301 | 303 | }) | |
| 302 | 304 | } | |
| 303 | 305 | ||
| @@ -163,6 +163,7 @@ func (p *Pass) writeGo(r types.Repository, gotemp *template.Template, dir string | |||||
| 163 | Constructors: constructors, | 163 | Constructors: constructors, | ||
| 164 | Receivers: receivers, | 164 | Receivers: receivers, | ||
| 165 | Fields: fields, | 165 | Fields: fields, | ||
| 166 | + | TypeGetter: rec.GLibGetType, | |||
| 166 | }) | 167 | }) | ||
| 167 | recordLookup[name] = true | 168 | recordLookup[name] = true | ||
| 168 | } | 169 | } | ||
| @@ -298,6 +299,7 @@ func (p *Pass) writeGo(r types.Repository, gotemp *template.Template, dir string | |||||
| 298 | Interfaces: interfaces, | 299 | Interfaces: interfaces, | ||
| 299 | Functions: functions, | 300 | Functions: functions, | ||
| 300 | Signals: signals, | 301 | Signals: signals, | ||
| 302 | + | TypeGetter: cls.GLibGetType, | |||
| 301 | }) | 303 | }) | ||
| 302 | } | 304 | } | ||
| 303 | 305 | ||||
M internal/gir/types/interface.go +4 -3
| @@ -35,9 +35,10 @@ func ConvertInterface(currns string, ins string, inter Interface, implemented ma | |||
| 35 | 35 | } | |
| 36 | 36 | name := util.SnakeToCamel(inter.Name) | |
| 37 | 37 | return InterfaceTemplate{ | |
| 38 | - | Name: name, | |
| 39 | - | Doc: inter.Doc.StringSafe(), | |
| 40 | - | Methods: methods, | |
| 38 | + | Name: name, | |
| 39 | + | Doc: inter.Doc.StringSafe(), | |
| 40 | + | Methods: methods, | |
| 41 | + | TypeGetter: inter.GLibGetType, | |
| 41 | 42 | } | |
| 42 | 43 | } | |
| 43 | 44 | ||
| @@ -35,9 +35,10 @@ func ConvertInterface(currns string, ins string, inter Interface, implemented ma | |||||
| 35 | } | 35 | } | ||
| 36 | name := util.SnakeToCamel(inter.Name) | 36 | name := util.SnakeToCamel(inter.Name) | ||
| 37 | return InterfaceTemplate{ | 37 | return InterfaceTemplate{ | ||
| 38 | - | Name: name, | 38 | + | Name: name, |
| 39 | - | Doc: inter.Doc.StringSafe(), | 39 | + | Doc: inter.Doc.StringSafe(), |
| 40 | - | Methods: methods, | 40 | + | Methods: methods, |
| 41 | + | TypeGetter: inter.GLibGetType, | |||
| 41 | } | 42 | } | ||
| 42 | } | 43 | } | ||
| 43 | 44 | ||||
M internal/gir/types/template.go +12 -0
| @@ -162,6 +162,9 @@ type AliasTemplate struct { | |||
| 162 | 162 | ||
| 163 | 163 | // Value is the value for the alias as a Go type | |
| 164 | 164 | Value string | |
| 165 | + | ||
| 166 | + | // TypeGetter is the function to get the GLib type | |
| 167 | + | TypeGetter string | |
| 165 | 168 | } | |
| 166 | 169 | ||
| 167 | 170 | type RecordField struct { | |
| @@ -187,6 +190,9 @@ type RecordTemplate struct { | |||
| 187 | 190 | ||
| 188 | 191 | // Fields is the list of record fields | |
| 189 | 192 | Fields []RecordField | |
| 193 | + | ||
| 194 | + | // TypeGetter is the function to get the GLib type | |
| 195 | + | TypeGetter string | |
| 190 | 196 | } | |
| 191 | 197 | ||
| 192 | 198 | type enumValues struct { | |
| @@ -205,6 +211,8 @@ type EnumTemplate struct { | |||
| 205 | 211 | Doc string | |
| 206 | 212 | // Values are the list of values for the enumeration | |
| 207 | 213 | Values []enumValues | |
| 214 | + | // TypeGetter is the function to get the GLib type | |
| 215 | + | TypeGetter string | |
| 208 | 216 | } | |
| 209 | 217 | ||
| 210 | 218 | type ConstantTemplate struct { | |
| @@ -368,6 +376,8 @@ type ClassTemplate struct { | |||
| 368 | 376 | Functions []FuncTemplate | |
| 369 | 377 | // Signals are helpers for ConnectX receivers | |
| 370 | 378 | Signals []SignalsTemplate | |
| 379 | + | // TypeGetter is the function to get the GLib type | |
| 380 | + | TypeGetter string | |
| 371 | 381 | } | |
| 372 | 382 | ||
| 373 | 383 | type InterfaceTemplate struct { | |
| @@ -375,6 +385,8 @@ type InterfaceTemplate struct { | |||
| 375 | 385 | Name string | |
| 376 | 386 | // Methods is the methods that this interface defines | |
| 377 | 387 | Methods []InterfaceFuncTemplate | |
| 388 | + | // TypeGetter is the function to get the GLib type | |
| 389 | + | TypeGetter string | |
| 378 | 390 | } | |
| 379 | 391 | ||
| 380 | 392 | type TemplateArg struct { | |
| @@ -162,6 +162,9 @@ type AliasTemplate struct { | |||||
| 162 | 162 | ||||
| 163 | // Value is the value for the alias as a Go type | 163 | // Value is the value for the alias as a Go type | ||
| 164 | Value string | 164 | Value string | ||
| 165 | + | ||||
| 166 | + | // TypeGetter is the function to get the GLib type | |||
| 167 | + | TypeGetter string | |||
| 165 | } | 168 | } | ||
| 166 | 169 | ||||
| 167 | type RecordField struct { | 170 | type RecordField struct { | ||
| @@ -187,6 +190,9 @@ type RecordTemplate struct { | |||||
| 187 | 190 | ||||
| 188 | // Fields is the list of record fields | 191 | // Fields is the list of record fields | ||
| 189 | Fields []RecordField | 192 | Fields []RecordField | ||
| 193 | + | ||||
| 194 | + | // TypeGetter is the function to get the GLib type | |||
| 195 | + | TypeGetter string | |||
| 190 | } | 196 | } | ||
| 191 | 197 | ||||
| 192 | type enumValues struct { | 198 | type enumValues struct { | ||
| @@ -205,6 +211,8 @@ type EnumTemplate struct { | |||||
| 205 | Doc string | 211 | Doc string | ||
| 206 | // Values are the list of values for the enumeration | 212 | // Values are the list of values for the enumeration | ||
| 207 | Values []enumValues | 213 | Values []enumValues | ||
| 214 | + | // TypeGetter is the function to get the GLib type | |||
| 215 | + | TypeGetter string | |||
| 208 | } | 216 | } | ||
| 209 | 217 | ||||
| 210 | type ConstantTemplate struct { | 218 | type ConstantTemplate struct { | ||
| @@ -368,6 +376,8 @@ type ClassTemplate struct { | |||||
| 368 | Functions []FuncTemplate | 376 | Functions []FuncTemplate | ||
| 369 | // Signals are helpers for ConnectX receivers | 377 | // Signals are helpers for ConnectX receivers | ||
| 370 | Signals []SignalsTemplate | 378 | Signals []SignalsTemplate | ||
| 379 | + | // TypeGetter is the function to get the GLib type | |||
| 380 | + | TypeGetter string | |||
| 371 | } | 381 | } | ||
| 372 | 382 | ||||
| 373 | type InterfaceTemplate struct { | 383 | type InterfaceTemplate struct { | ||
| @@ -375,6 +385,8 @@ type InterfaceTemplate struct { | |||||
| 375 | Name string | 385 | Name string | ||
| 376 | // Methods is the methods that this interface defines | 386 | // Methods is the methods that this interface defines | ||
| 377 | Methods []InterfaceFuncTemplate | 387 | Methods []InterfaceFuncTemplate | ||
| 388 | + | // TypeGetter is the function to get the GLib type | |||
| 389 | + | TypeGetter string | |||
| 378 | } | 390 | } | ||
| 379 | 391 | ||||
| 380 | type TemplateArg struct { | 392 | type TemplateArg struct { | ||
M internal/gir/types/types.go +8 -6
| @@ -204,9 +204,10 @@ func (b *Bitfield) Template(ns string) EnumTemplate { | |||
| 204 | 204 | } | |
| 205 | 205 | } | |
| 206 | 206 | return EnumTemplate{ | |
| 207 | - | Name: util.SnakeToCamel(b.Name), | |
| 208 | - | Doc: b.Doc.StringSafe(), | |
| 209 | - | Values: els, | |
| 207 | + | Name: util.SnakeToCamel(b.Name), | |
| 208 | + | Doc: b.Doc.StringSafe(), | |
| 209 | + | Values: els, | |
| 210 | + | TypeGetter: b.GLibGetType, | |
| 210 | 211 | } | |
| 211 | 212 | } | |
| 212 | 213 | ||
| @@ -474,9 +475,10 @@ func (e *Enum) Template(ns string) EnumTemplate { | |||
| 474 | 475 | } | |
| 475 | 476 | } | |
| 476 | 477 | return EnumTemplate{ | |
| 477 | - | Name: util.SnakeToCamel(e.Name), | |
| 478 | - | Doc: e.Doc.StringSafe(), | |
| 479 | - | Values: els, | |
| 478 | + | Name: util.SnakeToCamel(e.Name), | |
| 479 | + | Doc: e.Doc.StringSafe(), | |
| 480 | + | Values: els, | |
| 481 | + | TypeGetter: e.GLibGetType, | |
| 480 | 482 | } | |
| 481 | 483 | } | |
| 482 | 484 | ||
| @@ -204,9 +204,10 @@ func (b *Bitfield) Template(ns string) EnumTemplate { | |||||
| 204 | } | 204 | } | ||
| 205 | } | 205 | } | ||
| 206 | return EnumTemplate{ | 206 | return EnumTemplate{ | ||
| 207 | - | Name: util.SnakeToCamel(b.Name), | 207 | + | Name: util.SnakeToCamel(b.Name), |
| 208 | - | Doc: b.Doc.StringSafe(), | 208 | + | Doc: b.Doc.StringSafe(), |
| 209 | - | Values: els, | 209 | + | Values: els, |
| 210 | + | TypeGetter: b.GLibGetType, | |||
| 210 | } | 211 | } | ||
| 211 | } | 212 | } | ||
| 212 | 213 | ||||
| @@ -474,9 +475,10 @@ func (e *Enum) Template(ns string) EnumTemplate { | |||||
| 474 | } | 475 | } | ||
| 475 | } | 476 | } | ||
| 476 | return EnumTemplate{ | 477 | return EnumTemplate{ | ||
| 477 | - | Name: util.SnakeToCamel(e.Name), | 478 | + | Name: util.SnakeToCamel(e.Name), |
| 478 | - | Doc: e.Doc.StringSafe(), | 479 | + | Doc: e.Doc.StringSafe(), |
| 479 | - | Values: els, | 480 | + | Values: els, |
| 481 | + | TypeGetter: e.GLibGetType, | |||
| 480 | } | 482 | } | ||
| 481 | } | 483 | } | ||
| 482 | 484 | ||||
M internal/gir/util/util.go +1 -1
| @@ -28,7 +28,7 @@ func StarsInFront(str string, n int) string { | |||
| 28 | 28 | e := strings.Index(str, "]") | |
| 29 | 29 | stars := strings.Repeat("*", n) | |
| 30 | 30 | if b == 0 && e != -1 { | |
| 31 | - | return str[b:e+1] + stars + str[e+1:len(str)] | |
| 31 | + | return str[b:e+1] + stars + str[e+1:] | |
| 32 | 32 | } | |
| 33 | 33 | return stars + str | |
| 34 | 34 | } | |
| @@ -28,7 +28,7 @@ func StarsInFront(str string, n int) string { | |||||
| 28 | e := strings.Index(str, "]") | 28 | e := strings.Index(str, "]") | ||
| 29 | stars := strings.Repeat("*", n) | 29 | stars := strings.Repeat("*", n) | ||
| 30 | if b == 0 && e != -1 { | 30 | if b == 0 && e != -1 { | ||
| 31 | - | return str[b:e+1] + stars + str[e+1:len(str)] | 31 | + | return str[b:e+1] + stars + str[e+1:] |
| 32 | } | 32 | } | ||
| 33 | return stars + str | 33 | return stars + str | ||
| 34 | } | 34 | } | ||
M templates/go +53 -0
| @@ -28,6 +28,13 @@ type {{.Name}} struct { | |||
| 28 | 28 | {{end}} | |
| 29 | 29 | } | |
| 30 | 30 | ||
| 31 | + | {{if .TypeGetter}} | |
| 32 | + | var x{{.Name}}GLibType func() types.GType | |
| 33 | + | func {{.Name}}GLibType() types.GType { | |
| 34 | + | return x{{.Name}}GLibType() | |
| 35 | + | } | |
| 36 | + | {{end}} | |
| 37 | + | ||
| 31 | 38 | func (x *{{.Name}}) GoPointer() uintptr { | |
| 32 | 39 | return uintptr(unsafe.Pointer(x)) | |
| 33 | 40 | } | |
| @@ -69,6 +76,14 @@ type {{.Name}} interface { | |||
| 69 | 76 | {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Value}} | |
| 70 | 77 | {{end}} | |
| 71 | 78 | } | |
| 79 | + | ||
| 80 | + | {{if .TypeGetter}} | |
| 81 | + | var x{{.Name}}GLibType func() types.GType | |
| 82 | + | func {{.Name}}GLibType() types.GType { | |
| 83 | + | return x{{.Name}}GLibType() | |
| 84 | + | } | |
| 85 | + | {{end}} | |
| 86 | + | ||
| 72 | 87 | type {{.Name}}Base struct { | |
| 73 | 88 | Ptr uintptr | |
| 74 | 89 | } | |
| @@ -99,6 +114,12 @@ var {{.Namespace}}X{{.FullName}} func(uintptr {{convc .Args.Pure.Types}}) {{.Ret | |||
| 99 | 114 | {{range .Aliases -}} | |
| 100 | 115 | {{.Doc}} | |
| 101 | 116 | type {{.Name}} = {{.Value}} | |
| 117 | + | {{if .TypeGetter}} | |
| 118 | + | var x{{.Name}}GLibType func() types.GType | |
| 119 | + | func {{.Name}}GLibType() types.GType { | |
| 120 | + | return x{{.Name}}GLibType() | |
| 121 | + | } | |
| 122 | + | {{end}} | |
| 102 | 123 | {{end}} | |
| 103 | 124 | ||
| 104 | 125 | {{if .Constants -}} | |
| @@ -113,6 +134,12 @@ const ( | |||
| 113 | 134 | {{range .Enums -}} | |
| 114 | 135 | {{.Doc}} | |
| 115 | 136 | type {{.Name}} int | |
| 137 | + | {{if .TypeGetter}} | |
| 138 | + | var x{{.Name}}GLibType func() types.GType | |
| 139 | + | func {{.Name}}GLibType() types.GType { | |
| 140 | + | return x{{.Name}}GLibType() | |
| 141 | + | } | |
| 142 | + | {{end}} | |
| 116 | 143 | const ( | |
| 117 | 144 | {{$outer := .}} | |
| 118 | 145 | {{range .Values -}} | |
| @@ -142,6 +169,13 @@ type {{.Name}} struct { | |||
| 142 | 169 | {{end}} | |
| 143 | 170 | } | |
| 144 | 171 | ||
| 172 | + | {{if .TypeGetter -}} | |
| 173 | + | var x{{.Name}}GLibType func() types.GType | |
| 174 | + | func {{.Name}}GLibType() types.GType { | |
| 175 | + | return x{{.Name}}GLibType() | |
| 176 | + | } | |
| 177 | + | {{end}} | |
| 178 | + | ||
| 145 | 179 | {{$outer := .}} | |
| 146 | 180 | func {{.Name}}NewFromInternalPtr(ptr uintptr) *{{.Name}} { | |
| 147 | 181 | cls := &{{.Name}}{} | |
| @@ -241,12 +275,25 @@ func init() { | |||
| 241 | 275 | if err != nil { | |
| 242 | 276 | panic(err) | |
| 243 | 277 | } | |
| 278 | + | {{range .Aliases -}} | |
| 279 | + | {{if .TypeGetter -}} | |
| 280 | + | core.PuregoSafeRegister(&x{{.Name}}GLibType, lib, "{{.TypeGetter}}") | |
| 281 | + | {{end}} | |
| 282 | + | {{end}} | |
| 283 | + | {{range .Enums -}} | |
| 284 | + | {{if .TypeGetter -}} | |
| 285 | + | core.PuregoSafeRegister(&x{{.Name}}GLibType, lib, "{{.TypeGetter}}") | |
| 286 | + | {{end}} | |
| 287 | + | {{end}} | |
| 244 | 288 | {{range .Functions -}} | |
| 245 | 289 | core.PuregoSafeRegister(&x{{.Name}}, lib, "{{.CName}}") | |
| 246 | 290 | {{end}} | |
| 247 | 291 | ||
| 248 | 292 | {{range .Records -}} | |
| 249 | 293 | {{$rec := .}} | |
| 294 | + | {{if .TypeGetter -}} | |
| 295 | + | core.PuregoSafeRegister(&x{{.Name}}GLibType, lib, "{{.TypeGetter}}") | |
| 296 | + | {{end}} | |
| 250 | 297 | {{range .Constructors -}} | |
| 251 | 298 | core.PuregoSafeRegister(&x{{.Name}}, lib, "{{.CName}}") | |
| 252 | 299 | {{end}} | |
| @@ -257,6 +304,9 @@ func init() { | |||
| 257 | 304 | ||
| 258 | 305 | {{range .Classes -}} | |
| 259 | 306 | {{$cls := .}} | |
| 307 | + | {{if .TypeGetter -}} | |
| 308 | + | core.PuregoSafeRegister(&x{{.Name}}GLibType, lib, "{{.TypeGetter}}") | |
| 309 | + | {{end}} | |
| 260 | 310 | {{range .Constructors -}} | |
| 261 | 311 | core.PuregoSafeRegister(&x{{.Name}}, lib, "{{.CName}}") | |
| 262 | 312 | {{end}} | |
| @@ -269,6 +319,9 @@ func init() { | |||
| 269 | 319 | {{end}} | |
| 270 | 320 | ||
| 271 | 321 | {{range .Interfaces -}} | |
| 322 | + | {{if .TypeGetter -}} | |
| 323 | + | core.PuregoSafeRegister(&x{{.Name}}GLibType, lib, "{{.TypeGetter}}") | |
| 324 | + | {{end}} | |
| 272 | 325 | {{range .Methods -}} | |
| 273 | 326 | core.PuregoSafeRegister(&{{.Namespace}}X{{.FullName}}, lib, "{{.CName}}") | |
| 274 | 327 | {{end}} | |
| @@ -28,6 +28,13 @@ type {{.Name}} struct { | |||||
| 28 | {{end}} | 28 | {{end}} | ||
| 29 | } | 29 | } | ||
| 30 | 30 | ||||
| 31 | + | {{if .TypeGetter}} | |||
| 32 | + | var x{{.Name}}GLibType func() types.GType | |||
| 33 | + | func {{.Name}}GLibType() types.GType { | |||
| 34 | + | return x{{.Name}}GLibType() | |||
| 35 | + | } | |||
| 36 | + | {{end}} | |||
| 37 | + | ||||
| 31 | func (x *{{.Name}}) GoPointer() uintptr { | 38 | func (x *{{.Name}}) GoPointer() uintptr { | ||
| 32 | return uintptr(unsafe.Pointer(x)) | 39 | return uintptr(unsafe.Pointer(x)) | ||
| 33 | } | 40 | } | ||
| @@ -69,6 +76,14 @@ type {{.Name}} interface { | |||||
| 69 | {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Value}} | 76 | {{.Name}}({{conv .Args.API.Full}}) {{.Ret.Value}} | ||
| 70 | {{end}} | 77 | {{end}} | ||
| 71 | } | 78 | } | ||
| 79 | + | ||||
| 80 | + | {{if .TypeGetter}} | |||
| 81 | + | var x{{.Name}}GLibType func() types.GType | |||
| 82 | + | func {{.Name}}GLibType() types.GType { | |||
| 83 | + | return x{{.Name}}GLibType() | |||
| 84 | + | } | |||
| 85 | + | {{end}} | |||
| 86 | + | ||||
| 72 | type {{.Name}}Base struct { | 87 | type {{.Name}}Base struct { | ||
| 73 | Ptr uintptr | 88 | Ptr uintptr | ||
| 74 | } | 89 | } | ||
| @@ -99,6 +114,12 @@ var {{.Namespace}}X{{.FullName}} func(uintptr {{convc .Args.Pure.Types}}) {{.Ret | |||||
| 99 | {{range .Aliases -}} | 114 | {{range .Aliases -}} | ||
| 100 | {{.Doc}} | 115 | {{.Doc}} | ||
| 101 | type {{.Name}} = {{.Value}} | 116 | type {{.Name}} = {{.Value}} | ||
| 117 | + | {{if .TypeGetter}} | |||
| 118 | + | var x{{.Name}}GLibType func() types.GType | |||
| 119 | + | func {{.Name}}GLibType() types.GType { | |||
| 120 | + | return x{{.Name}}GLibType() | |||
| 121 | + | } | |||
| 122 | + | {{end}} | |||
| 102 | {{end}} | 123 | {{end}} | ||
| 103 | 124 | ||||
| 104 | {{if .Constants -}} | 125 | {{if .Constants -}} | ||
| @@ -113,6 +134,12 @@ const ( | |||||
| 113 | {{range .Enums -}} | 134 | {{range .Enums -}} | ||
| 114 | {{.Doc}} | 135 | {{.Doc}} | ||
| 115 | type {{.Name}} int | 136 | type {{.Name}} int | ||
| 137 | + | {{if .TypeGetter}} | |||
| 138 | + | var x{{.Name}}GLibType func() types.GType | |||
| 139 | + | func {{.Name}}GLibType() types.GType { | |||
| 140 | + | return x{{.Name}}GLibType() | |||
| 141 | + | } | |||
| 142 | + | {{end}} | |||
| 116 | const ( | 143 | const ( | ||
| 117 | {{$outer := .}} | 144 | {{$outer := .}} | ||
| 118 | {{range .Values -}} | 145 | {{range .Values -}} | ||
| @@ -142,6 +169,13 @@ type {{.Name}} struct { | |||||
| 142 | {{end}} | 169 | {{end}} | ||
| 143 | } | 170 | } | ||
| 144 | 171 | ||||
| 172 | + | {{if .TypeGetter -}} | |||
| 173 | + | var x{{.Name}}GLibType func() types.GType | |||
| 174 | + | func {{.Name}}GLibType() types.GType { | |||
| 175 | + | return x{{.Name}}GLibType() | |||
| 176 | + | } | |||
| 177 | + | {{end}} | |||
| 178 | + | ||||
| 145 | {{$outer := .}} | 179 | {{$outer := .}} | ||
| 146 | func {{.Name}}NewFromInternalPtr(ptr uintptr) *{{.Name}} { | 180 | func {{.Name}}NewFromInternalPtr(ptr uintptr) *{{.Name}} { | ||
| 147 | cls := &{{.Name}}{} | 181 | cls := &{{.Name}}{} | ||
| @@ -241,12 +275,25 @@ func init() { | |||||
| 241 | if err != nil { | 275 | if err != nil { | ||
| 242 | panic(err) | 276 | panic(err) | ||
| 243 | } | 277 | } | ||
| 278 | + | {{range .Aliases -}} | |||
| 279 | + | {{if .TypeGetter -}} | |||
| 280 | + | core.PuregoSafeRegister(&x{{.Name}}GLibType, lib, "{{.TypeGetter}}") | |||
| 281 | + | {{end}} | |||
| 282 | + | {{end}} | |||
| 283 | + | {{range .Enums -}} | |||
| 284 | + | {{if .TypeGetter -}} | |||
| 285 | + | core.PuregoSafeRegister(&x{{.Name}}GLibType, lib, "{{.TypeGetter}}") | |||
| 286 | + | {{end}} | |||
| 287 | + | {{end}} | |||
| 244 | {{range .Functions -}} | 288 | {{range .Functions -}} | ||
| 245 | core.PuregoSafeRegister(&x{{.Name}}, lib, "{{.CName}}") | 289 | core.PuregoSafeRegister(&x{{.Name}}, lib, "{{.CName}}") | ||
| 246 | {{end}} | 290 | {{end}} | ||
| 247 | 291 | ||||
| 248 | {{range .Records -}} | 292 | {{range .Records -}} | ||
| 249 | {{$rec := .}} | 293 | {{$rec := .}} | ||
| 294 | + | {{if .TypeGetter -}} | |||
| 295 | + | core.PuregoSafeRegister(&x{{.Name}}GLibType, lib, "{{.TypeGetter}}") | |||
| 296 | + | {{end}} | |||
| 250 | {{range .Constructors -}} | 297 | {{range .Constructors -}} | ||
| 251 | core.PuregoSafeRegister(&x{{.Name}}, lib, "{{.CName}}") | 298 | core.PuregoSafeRegister(&x{{.Name}}, lib, "{{.CName}}") | ||
| 252 | {{end}} | 299 | {{end}} | ||
| @@ -257,6 +304,9 @@ func init() { | |||||
| 257 | 304 | ||||
| 258 | {{range .Classes -}} | 305 | {{range .Classes -}} | ||
| 259 | {{$cls := .}} | 306 | {{$cls := .}} | ||
| 307 | + | {{if .TypeGetter -}} | |||
| 308 | + | core.PuregoSafeRegister(&x{{.Name}}GLibType, lib, "{{.TypeGetter}}") | |||
| 309 | + | {{end}} | |||
| 260 | {{range .Constructors -}} | 310 | {{range .Constructors -}} | ||
| 261 | core.PuregoSafeRegister(&x{{.Name}}, lib, "{{.CName}}") | 311 | core.PuregoSafeRegister(&x{{.Name}}, lib, "{{.CName}}") | ||
| 262 | {{end}} | 312 | {{end}} | ||
| @@ -269,6 +319,9 @@ func init() { | |||||
| 269 | {{end}} | 319 | {{end}} | ||
| 270 | 320 | ||||
| 271 | {{range .Interfaces -}} | 321 | {{range .Interfaces -}} | ||
| 322 | + | {{if .TypeGetter -}} | |||
| 323 | + | core.PuregoSafeRegister(&x{{.Name}}GLibType, lib, "{{.TypeGetter}}") | |||
| 324 | + | {{end}} | |||
| 272 | {{range .Methods -}} | 325 | {{range .Methods -}} | ||
| 273 | core.PuregoSafeRegister(&{{.Namespace}}X{{.FullName}}, lib, "{{.CName}}") | 326 | core.PuregoSafeRegister(&{{.Namespace}}X{{.FullName}}, lib, "{{.CName}}") | ||
| 274 | {{end}} | 327 | {{end}} | ||