mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 08:58:37 +00:00
genbindings: move checkComplexity into separate ast pass post-typedefs
This commit is contained in:
parent
d1d0c24e76
commit
150dab7c46
@ -575,9 +575,6 @@ func parseTypeString(typeString string) (CppParameter, []CppParameter, error) {
|
||||
if returnType.IntType() && returnType.ByRef {
|
||||
return CppParameter{}, nil, ErrTooComplex // e.g. QSize::rheight()
|
||||
}
|
||||
if err := CheckComplexity(returnType); err != nil {
|
||||
return CppParameter{}, nil, err
|
||||
}
|
||||
|
||||
inner := typeString[opos+1 : epos]
|
||||
|
||||
@ -594,10 +591,6 @@ func parseTypeString(typeString string) (CppParameter, []CppParameter, error) {
|
||||
|
||||
insert := parseSingleTypeString(p)
|
||||
|
||||
if err := CheckComplexity(insert); err != nil {
|
||||
return CppParameter{}, nil, err
|
||||
}
|
||||
|
||||
if insert.ParameterType != "" {
|
||||
ret = append(ret, insert)
|
||||
}
|
||||
|
@ -158,6 +158,7 @@ func main() {
|
||||
|
||||
// More AST transforms on our IL
|
||||
astTransformTypedefs(parsed)
|
||||
astTransformBlocklist(parsed) // Must happen after typedef transformation
|
||||
|
||||
{
|
||||
// Save the IL file for debug inspection
|
||||
|
54
cmd/genbindings/transformblocklist.go
Normal file
54
cmd/genbindings/transformblocklist.go
Normal file
@ -0,0 +1,54 @@
|
||||
package main
|
||||
|
||||
// astTransformBlocklist filters out methods using too-complex parameter types,
|
||||
// and entire classes that may be disallowed.
|
||||
func astTransformBlocklist(parsed *CppParsedHeader) {
|
||||
|
||||
for i, c := range parsed.Classes {
|
||||
|
||||
// Constructors
|
||||
|
||||
j := 0
|
||||
nextCtor:
|
||||
for _, m := range c.Ctors {
|
||||
if err := CheckComplexity(m.ReturnType); err != nil {
|
||||
continue nextCtor
|
||||
}
|
||||
|
||||
for _, p := range m.Parameters {
|
||||
if err := CheckComplexity(p); err != nil {
|
||||
continue nextCtor
|
||||
}
|
||||
}
|
||||
|
||||
// Keep
|
||||
c.Ctors[j] = m
|
||||
j++
|
||||
}
|
||||
c.Ctors = c.Ctors[:j] // reslice
|
||||
|
||||
// Methods
|
||||
|
||||
j = 0
|
||||
nextMethod:
|
||||
for _, m := range c.Methods {
|
||||
if err := CheckComplexity(m.ReturnType); err != nil {
|
||||
continue nextMethod
|
||||
}
|
||||
|
||||
for _, p := range m.Parameters {
|
||||
if err := CheckComplexity(p); err != nil {
|
||||
continue nextMethod
|
||||
}
|
||||
}
|
||||
|
||||
// Keep
|
||||
c.Methods[j] = m
|
||||
j++
|
||||
}
|
||||
c.Methods = c.Methods[:j] // reslice
|
||||
|
||||
parsed.Classes[i] = c
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user