Skip to content

Commit

Permalink
Merge pull request #93 from saltosystems/feature/fix-generic-input-pa…
Browse files Browse the repository at this point in the history
…rameters

codegen: fix generic input parameters
  • Loading branch information
jagobagascon committed May 9, 2024
2 parents c45669f + 2be6f8e commit 45c2d7a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
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.

0 comments on commit 45c2d7a

Please sign in to comment.