2024-08-27 06:44:10 +00:00
|
|
|
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 {
|
2024-08-29 05:17:35 +00:00
|
|
|
if err := CheckComplexity(m.ReturnType, true); err != nil {
|
2024-08-27 06:44:10 +00:00
|
|
|
continue nextCtor
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, p := range m.Parameters {
|
2024-08-29 05:17:35 +00:00
|
|
|
if err := CheckComplexity(p, false); err != nil {
|
2024-08-27 06:44:10 +00:00
|
|
|
continue nextCtor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Keep
|
|
|
|
c.Ctors[j] = m
|
|
|
|
j++
|
|
|
|
}
|
|
|
|
c.Ctors = c.Ctors[:j] // reslice
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
|
|
|
|
j = 0
|
|
|
|
nextMethod:
|
|
|
|
for _, m := range c.Methods {
|
2024-08-29 05:17:35 +00:00
|
|
|
if err := CheckComplexity(m.ReturnType, true); err != nil {
|
2024-08-27 06:44:10 +00:00
|
|
|
continue nextMethod
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, p := range m.Parameters {
|
2024-08-29 05:17:35 +00:00
|
|
|
if err := CheckComplexity(p, false); err != nil {
|
2024-08-27 06:44:10 +00:00
|
|
|
continue nextMethod
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Keep
|
|
|
|
c.Methods[j] = m
|
|
|
|
j++
|
|
|
|
}
|
|
|
|
c.Methods = c.Methods[:j] // reslice
|
|
|
|
|
|
|
|
parsed.Classes[i] = c
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|