Skip to content

Commit

Permalink
genbindings: Lint cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rcalixte committed Nov 13, 2024
1 parent 4669ec0 commit a067210
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 33 deletions.
5 changes: 1 addition & 4 deletions cmd/genbindings/clang2il.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,10 +890,7 @@ func parseSingleTypeString(p string) CppParameter {
}
}
insert.ParameterType = strings.TrimSpace(insert.ParameterType)

if strings.HasPrefix(insert.ParameterType, `::`) {
insert.ParameterType = insert.ParameterType[2:]
}
insert.ParameterType = strings.TrimPrefix(insert.ParameterType, "::")

return insert
}
17 changes: 3 additions & 14 deletions cmd/genbindings/config-libraries.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
func(fullpath string) bool {
// Only include the same json, xml, cbor files excluded above
fname := filepath.Base(fullpath)
if strings.HasPrefix(fname, "qcbor") {
return true
}

return false
return strings.HasPrefix(fname, "qcbor")
},
clangBin,
pkgConfigCflags("Qt5Core"),
Expand Down Expand Up @@ -156,11 +152,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
func(fullpath string) bool {
// Only include the same json, xml, cbor files excluded above
fname := filepath.Base(fullpath)
if strings.HasPrefix(fname, "qcbor") {
return true
}

return false
return strings.HasPrefix(fname, "qcbor")
},
clangBin,
pkgConfigCflags("Qt6Core"),
Expand Down Expand Up @@ -189,10 +181,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
},
func(fullpath string) bool {
fname := filepath.Base(fullpath)
if fname == "qtnetwork-config.h" {
return false
}
return true
return fname != "qtnetwork-config.h"
},
clangBin,
"--std=c++17 "+pkgConfigCflags("Qt6Network"),
Expand Down
2 changes: 1 addition & 1 deletion cmd/genbindings/emitgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ import "C"
// Fixup imports
if len(gfs.imports) > 0 {
allImports := make([]string, 0, len(gfs.imports))
for k, _ := range gfs.imports {
for k := range gfs.imports {
if k == "libmiqt" {
allImports = append(allImports, `"`+BaseModule+`/libmiqt"`)
} else {
Expand Down
7 changes: 1 addition & 6 deletions cmd/genbindings/intermediate.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,8 @@ func (nm CppMethod) IsReceiverMethod() bool {
}

func (nm CppMethod) SafeMethodName() string {

tmp := nm.MethodName

// Strip redundant Qt prefix, we know these are all Qt functions
if strings.HasPrefix(tmp, "qt_") {
tmp = tmp[3:]
}
tmp := strings.TrimPrefix(nm.MethodName, "qt_")

// Operator-overload methods have names not representable in binding
// languages. Replace more specific cases first
Expand Down
15 changes: 7 additions & 8 deletions cmd/genbindings/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -133,7 +132,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b

cacheFile := cacheFilePath(inputHeader)

astJson, err := ioutil.ReadFile(cacheFile)
astJson, err := os.ReadFile(cacheFile)
if err != nil {
panic("Expected cache to be created for " + inputHeader + ", but got error " + err.Error())
}
Expand Down Expand Up @@ -197,7 +196,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b
panic(err)
}

err = ioutil.WriteFile(cacheFilePath(parsed.Filename)+".ours.json", jb, 0644)
err = os.WriteFile(cacheFilePath(parsed.Filename)+".ours.json", jb, 0644)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -236,7 +235,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b
panic(err)
}

err = ioutil.WriteFile(outputName+".go", []byte(goSrc), 0644)
err = os.WriteFile(outputName+".go", []byte(goSrc), 0644)
if err != nil {
panic(err)
}
Expand All @@ -246,7 +245,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b
panic(err)
}

err = ioutil.WriteFile(outputName+".cpp", []byte(bindingCppSrc), 0644)
err = os.WriteFile(outputName+".cpp", []byte(bindingCppSrc), 0644)
if err != nil {
panic(err)
}
Expand All @@ -256,7 +255,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b
panic(err)
}

err = ioutil.WriteFile(outputName+".h", []byte(bindingHSrc), 0644)
err = os.WriteFile(outputName+".h", []byte(bindingHSrc), 0644)
if err != nil {
panic(err)
}
Expand All @@ -270,7 +269,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b

func generateClangCaches(includeFiles []string, clangBin string, cflags []string, matcher ClangMatcher) {

var clangChan = make(chan string, 0)
var clangChan = make(chan string)
var clangWg sync.WaitGroup
ctx := context.Background()

Expand Down Expand Up @@ -298,7 +297,7 @@ func generateClangCaches(includeFiles []string, clangBin string, cflags []string
panic(err)
}

err = ioutil.WriteFile(cacheFilePath(inputHeader), jb, 0644)
err = os.WriteFile(cacheFilePath(inputHeader), jb, 0644)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit a067210

Please sign in to comment.