mirror of
https://github.com/mappu/miqt.git
synced 2025-02-23 13:00:25 +00:00
Merge pull request #135 from arnetheduck/log-blocked
Log blocked methods
This commit is contained in:
commit
422e81dc78
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -17,6 +18,12 @@ type CppParameter struct {
|
|||||||
QtCppOriginalType *CppParameter // If we rewrote QStringList->QList<String>, this field contains the original QStringList. Otherwise, it's blank
|
QtCppOriginalType *CppParameter // If we rewrote QStringList->QList<String>, this field contains the original QStringList. Otherwise, it's blank
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p CppParameter) String() string {
|
||||||
|
return "Param(" + ifv(p.Const, "const ", "") + p.ParameterType +
|
||||||
|
ifv(p.Pointer, strings.Repeat("*", p.PointerCount), "") + ifv(p.ByRef, "&", "") +
|
||||||
|
ifv(p.Optional, "?", "") + " " + p.ParameterName + ")"
|
||||||
|
}
|
||||||
|
|
||||||
func (p *CppParameter) ApplyTypedef(matchedUnderlyingType CppParameter) {
|
func (p *CppParameter) ApplyTypedef(matchedUnderlyingType CppParameter) {
|
||||||
if p.QtCppOriginalType == nil {
|
if p.QtCppOriginalType == nil {
|
||||||
tmp := *p // Copy
|
tmp := *p // Copy
|
||||||
@ -479,7 +486,8 @@ func (c *CppClass) VirtualMethods() []CppMethod {
|
|||||||
// m is copied by value. Mutate it
|
// m is copied by value. Mutate it
|
||||||
applyTypedefs_Method(&m)
|
applyTypedefs_Method(&m)
|
||||||
// Same with astTransformBlocklist
|
// Same with astTransformBlocklist
|
||||||
if !blocklist_MethodAllowed(&m) {
|
if err := blocklist_MethodAllowed(&m); err != nil {
|
||||||
|
log.Printf("Blocking method %q(%v): %s", m.MethodName, m.Parameters, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,6 +329,8 @@ func generateClangCaches(includeFiles []string, clangBin string, cflags []string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
// data/time flags make logs hard to compare across runs
|
||||||
|
log.SetFlags(log.Flags() &^ (log.Ldate | log.Ltime))
|
||||||
clang := flag.String("clang", "clang", "Custom path to clang")
|
clang := flag.String("clang", "clang", "Custom path to clang")
|
||||||
outDir := flag.String("outdir", "../../", "Output directory for generated gen_** files")
|
outDir := flag.String("outdir", "../../", "Output directory for generated gen_** files")
|
||||||
extraLibsDir := flag.String("extralibs", "/usr/local/src/", "Base directory to find extra library checkouts")
|
extraLibsDir := flag.String("extralibs", "/usr/local/src/", "Base directory to find extra library checkouts")
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func blocklist_MethodAllowed(m *CppMethod) bool {
|
import "log"
|
||||||
|
|
||||||
|
func blocklist_MethodAllowed(m *CppMethod) error {
|
||||||
if err := AllowType(m.ReturnType, true); err != nil {
|
if err := AllowType(m.ReturnType, true); err != nil {
|
||||||
return false
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, p := range m.Parameters {
|
for _, p := range m.Parameters {
|
||||||
if err := AllowType(p, false); err != nil {
|
if err := AllowType(p, false); err != nil {
|
||||||
return false
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing was blocked
|
// Nothing was blocked
|
||||||
return true
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// astTransformBlocklist filters out methods using too-complex parameter types,
|
// astTransformBlocklist filters out methods using too-complex parameter types,
|
||||||
@ -49,7 +51,9 @@ func astTransformBlocklist(parsed *CppParsedHeader) {
|
|||||||
j := 0
|
j := 0
|
||||||
nextCtor:
|
nextCtor:
|
||||||
for _, m := range c.Ctors {
|
for _, m := range c.Ctors {
|
||||||
if !blocklist_MethodAllowed(&m) {
|
if err := blocklist_MethodAllowed(&m); err != nil {
|
||||||
|
log.Printf("Blocking constructor %q(%v): %s", m.MethodName, m.Parameters, err)
|
||||||
|
|
||||||
continue nextCtor
|
continue nextCtor
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +68,8 @@ func astTransformBlocklist(parsed *CppParsedHeader) {
|
|||||||
j = 0
|
j = 0
|
||||||
nextMethod:
|
nextMethod:
|
||||||
for _, m := range c.Methods {
|
for _, m := range c.Methods {
|
||||||
if !blocklist_MethodAllowed(&m) {
|
if err := blocklist_MethodAllowed(&m); err != nil {
|
||||||
|
log.Printf("Blocking method %q(%v): %s", m.MethodName, m.Parameters, err)
|
||||||
continue nextMethod
|
continue nextMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user