Skip to content

Commit

Permalink
Fix missing async functions regression
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed Jul 31, 2024
1 parent 0015c46 commit b9c04a8
Show file tree
Hide file tree
Showing 8 changed files with 11,534 additions and 72 deletions.
16 changes: 16 additions & 0 deletions gir/cmd/gir-generate/gendata/gendata.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package gendata

import (
"fmt"
"slices"
"strings"

"github.com/diamondburned/gotk4/gir"
Expand All @@ -12,6 +13,7 @@ import (
"github.com/diamondburned/gotk4/gir/girgen/file"
. "github.com/diamondburned/gotk4/gir/girgen/types"
. "github.com/diamondburned/gotk4/gir/girgen/types/typeconv"
"github.com/diamondburned/gotk4/gir/internal/ptr"
)

const Module = "github.com/diamondburned/gotk4/pkg"
Expand Down Expand Up @@ -211,6 +213,20 @@ var Preprocessors = []Preprocessor{
}
}
}),

// Fix GAsyncReadyCallback missing the closure bit for the user_data
// parameter.
PreprocessorFunc(func(repos gir.Repositories) {
callback := repos.FindFullType("Gio-2.AsyncReadyCallback").Type.(*gir.Callback)

userDataIx := slices.IndexFunc(
callback.Parameters.Parameters,
func(p gir.Parameter) bool { return p.Name == "data" },
)

userData := &callback.Parameters.Parameters[userDataIx]
userData.Closure = ptr.To(userDataIx)
}),
}

var ConversionProcessors = []ConversionProcessor{
Expand Down
6 changes: 6 additions & 0 deletions gir/internal/ptr/ptr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package ptr

// To returns a pointer to the given value.
func To[T any](v T) *T {
return &v
}
Loading

0 comments on commit b9c04a8

Please sign in to comment.