genbindings: Lint cleanup

This commit is contained in:
Rick Calixte 2024-11-13 08:33:51 -05:00
parent 4669ec0632
commit a067210548
No known key found for this signature in database
5 changed files with 13 additions and 33 deletions

View File

@ -890,10 +890,7 @@ func parseSingleTypeString(p string) CppParameter {
} }
} }
insert.ParameterType = strings.TrimSpace(insert.ParameterType) insert.ParameterType = strings.TrimSpace(insert.ParameterType)
insert.ParameterType = strings.TrimPrefix(insert.ParameterType, "::")
if strings.HasPrefix(insert.ParameterType, `::`) {
insert.ParameterType = insert.ParameterType[2:]
}
return insert return insert
} }

View File

@ -42,11 +42,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
func(fullpath string) bool { func(fullpath string) bool {
// Only include the same json, xml, cbor files excluded above // Only include the same json, xml, cbor files excluded above
fname := filepath.Base(fullpath) fname := filepath.Base(fullpath)
if strings.HasPrefix(fname, "qcbor") { return strings.HasPrefix(fname, "qcbor")
return true
}
return false
}, },
clangBin, clangBin,
pkgConfigCflags("Qt5Core"), pkgConfigCflags("Qt5Core"),
@ -156,11 +152,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
func(fullpath string) bool { func(fullpath string) bool {
// Only include the same json, xml, cbor files excluded above // Only include the same json, xml, cbor files excluded above
fname := filepath.Base(fullpath) fname := filepath.Base(fullpath)
if strings.HasPrefix(fname, "qcbor") { return strings.HasPrefix(fname, "qcbor")
return true
}
return false
}, },
clangBin, clangBin,
pkgConfigCflags("Qt6Core"), pkgConfigCflags("Qt6Core"),
@ -189,10 +181,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
}, },
func(fullpath string) bool { func(fullpath string) bool {
fname := filepath.Base(fullpath) fname := filepath.Base(fullpath)
if fname == "qtnetwork-config.h" { return fname != "qtnetwork-config.h"
return false
}
return true
}, },
clangBin, clangBin,
"--std=c++17 "+pkgConfigCflags("Qt6Network"), "--std=c++17 "+pkgConfigCflags("Qt6Network"),

View File

@ -839,7 +839,7 @@ import "C"
// Fixup imports // Fixup imports
if len(gfs.imports) > 0 { if len(gfs.imports) > 0 {
allImports := make([]string, 0, len(gfs.imports)) allImports := make([]string, 0, len(gfs.imports))
for k, _ := range gfs.imports { for k := range gfs.imports {
if k == "libmiqt" { if k == "libmiqt" {
allImports = append(allImports, `"`+BaseModule+`/libmiqt"`) allImports = append(allImports, `"`+BaseModule+`/libmiqt"`)
} else { } else {

View File

@ -307,13 +307,8 @@ func (nm CppMethod) IsReceiverMethod() bool {
} }
func (nm CppMethod) SafeMethodName() string { func (nm CppMethod) SafeMethodName() string {
tmp := nm.MethodName
// Strip redundant Qt prefix, we know these are all Qt functions // Strip redundant Qt prefix, we know these are all Qt functions
if strings.HasPrefix(tmp, "qt_") { tmp := strings.TrimPrefix(nm.MethodName, "qt_")
tmp = tmp[3:]
}
// Operator-overload methods have names not representable in binding // Operator-overload methods have names not representable in binding
// languages. Replace more specific cases first // languages. Replace more specific cases first

View File

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"log" "log"
"os" "os"
"os/exec" "os/exec"
@ -133,7 +132,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b
cacheFile := cacheFilePath(inputHeader) cacheFile := cacheFilePath(inputHeader)
astJson, err := ioutil.ReadFile(cacheFile) astJson, err := os.ReadFile(cacheFile)
if err != nil { if err != nil {
panic("Expected cache to be created for " + inputHeader + ", but got error " + err.Error()) panic("Expected cache to be created for " + inputHeader + ", but got error " + err.Error())
} }
@ -197,7 +196,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b
panic(err) 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 { if err != nil {
panic(err) panic(err)
} }
@ -236,7 +235,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b
panic(err) panic(err)
} }
err = ioutil.WriteFile(outputName+".go", []byte(goSrc), 0644) err = os.WriteFile(outputName+".go", []byte(goSrc), 0644)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -246,7 +245,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b
panic(err) panic(err)
} }
err = ioutil.WriteFile(outputName+".cpp", []byte(bindingCppSrc), 0644) err = os.WriteFile(outputName+".cpp", []byte(bindingCppSrc), 0644)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -256,7 +255,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b
panic(err) panic(err)
} }
err = ioutil.WriteFile(outputName+".h", []byte(bindingHSrc), 0644) err = os.WriteFile(outputName+".h", []byte(bindingHSrc), 0644)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -270,7 +269,7 @@ func generate(packageName string, srcDirs []string, allowHeaderFn func(string) b
func generateClangCaches(includeFiles []string, clangBin string, cflags []string, matcher ClangMatcher) { 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 var clangWg sync.WaitGroup
ctx := context.Background() ctx := context.Background()
@ -298,7 +297,7 @@ func generateClangCaches(includeFiles []string, clangBin string, cflags []string
panic(err) panic(err)
} }
err = ioutil.WriteFile(cacheFilePath(inputHeader), jb, 0644) err = os.WriteFile(cacheFilePath(inputHeader), jb, 0644)
if err != nil { if err != nil {
panic(err) panic(err)
} }