Skip to content

Commit b9c04a8

Browse files
committed
Fix missing async functions regression
1 parent 0015c46 commit b9c04a8

File tree

8 files changed

+11534
-72
lines changed

8 files changed

+11534
-72
lines changed

gir/cmd/gir-generate/gendata/gendata.go

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package gendata
44

55
import (
66
"fmt"
7+
"slices"
78
"strings"
89

910
"github.com/diamondburned/gotk4/gir"
@@ -12,6 +13,7 @@ import (
1213
"github.com/diamondburned/gotk4/gir/girgen/file"
1314
. "github.com/diamondburned/gotk4/gir/girgen/types"
1415
. "github.com/diamondburned/gotk4/gir/girgen/types/typeconv"
16+
"github.com/diamondburned/gotk4/gir/internal/ptr"
1517
)
1618

1719
const Module = "github.com/diamondburned/gotk4/pkg"
@@ -211,6 +213,20 @@ var Preprocessors = []Preprocessor{
211213
}
212214
}
213215
}),
216+
217+
// Fix GAsyncReadyCallback missing the closure bit for the user_data
218+
// parameter.
219+
PreprocessorFunc(func(repos gir.Repositories) {
220+
callback := repos.FindFullType("Gio-2.AsyncReadyCallback").Type.(*gir.Callback)
221+
222+
userDataIx := slices.IndexFunc(
223+
callback.Parameters.Parameters,
224+
func(p gir.Parameter) bool { return p.Name == "data" },
225+
)
226+
227+
userData := &callback.Parameters.Parameters[userDataIx]
228+
userData.Closure = ptr.To(userDataIx)
229+
}),
214230
}
215231

216232
var ConversionProcessors = []ConversionProcessor{

gir/internal/ptr/ptr.go

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package ptr
2+
3+
// To returns a pointer to the given value.
4+
func To[T any](v T) *T {
5+
return &v
6+
}

0 commit comments

Comments
 (0)