Skip to content

Commit

Permalink
Add Extensions to end of interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Lezar <[email protected]>
  • Loading branch information
elezar committed Oct 15, 2024
1 parent 4762781 commit b240786
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gen/nvml/generateapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var GeneratableInterfaces = []GeneratableInterfacePoperties{
{
Type: "nvmlVgpuTypeId",
Interface: "VgpuTypeId",
Exclude: []string{"ID"},
},
}

Expand Down Expand Up @@ -239,7 +240,18 @@ func generateInterface(sourceDir string, input GeneratableInterfacePoperties) (s
return "", err
}

// We separate the methods into two sets to ensure that extensions are always included last.
var generatedMethods []*ast.FuncDecl
var extensions []*ast.FuncDecl
for _, method := range methods {
if method.Name.Name == "Extensions" {
extensions = append(extensions, method)
continue
}
generatedMethods = append(generatedMethods, method)
}

for _, method := range append(generatedMethods, extensions...) {
formatted := fmt.Sprintf("\t%s\n", formatMethodSignature(method))
signature.WriteString(formatted)
}
Expand Down

0 comments on commit b240786

Please sign in to comment.