Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen: fix generic input parameters #93

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/codegen/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -978,10 +978,12 @@ func (g *generator) elementType(ctx *types.Context, e types.Element) (*genParamT
defaultValue: g.elementDefaultValue(ctx, e),
}, nil
case types.ELEMENT_TYPE_VAR:
// A class variable type modifier
// Generic types are not fully supported yet,
// so we will just pass the raw unsafe.Pointer up to the user.
return &genParamType{
namespace: "unsafe",
name: "Pointer",
IsGeneric: true,
IsPointer: false,
IsPrimitive: false,
IsArray: false,
Expand Down
1 change: 1 addition & 0 deletions internal/codegen/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ type genParamType struct {
name string

IsPointer bool
IsGeneric bool
IsArray bool
IsPrimitive bool
IsEnum bool
Expand Down
2 changes: 2 additions & 0 deletions internal/codegen/templates/funcimpl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ hr, _, _ := syscall.SyscallN(
{{else -}}
uintptr({{.GoVarName}}), // in {{.GoTypeName}}
{{end -}}
{{else if .Type.IsGeneric -}}
uintptr({{.GoVarName}}), // in {{.GoTypeName}}
{{else -}}
uintptr(unsafe.Pointer(&{{.GoVarName}})), // in {{.GoTypeName}}
{{end -}}
Expand Down
18 changes: 9 additions & 9 deletions windows/foundation/collections/ivector.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion windows/foundation/collections/ivectorview.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading