mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 00:48:38 +00:00
genbindings/blocklist: refactor extract single method helper
This commit is contained in:
parent
d9bfece505
commit
0ffb24d11a
@ -1,5 +1,20 @@
|
||||
package main
|
||||
|
||||
func blocklist_MethodAllowed(m *CppMethod) bool {
|
||||
if err := AllowType(m.ReturnType, true); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, p := range m.Parameters {
|
||||
if err := AllowType(p, false); err != nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing was blocked
|
||||
return true
|
||||
}
|
||||
|
||||
// astTransformBlocklist filters out methods using too-complex parameter types,
|
||||
// and entire classes that may be disallowed.
|
||||
func astTransformBlocklist(parsed *CppParsedHeader) {
|
||||
@ -28,16 +43,10 @@ func astTransformBlocklist(parsed *CppParsedHeader) {
|
||||
j := 0
|
||||
nextCtor:
|
||||
for _, m := range c.Ctors {
|
||||
if err := AllowType(m.ReturnType, true); err != nil {
|
||||
if !blocklist_MethodAllowed(&m) {
|
||||
continue nextCtor
|
||||
}
|
||||
|
||||
for _, p := range m.Parameters {
|
||||
if err := AllowType(p, false); err != nil {
|
||||
continue nextCtor
|
||||
}
|
||||
}
|
||||
|
||||
// Keep
|
||||
c.Ctors[j] = m
|
||||
j++
|
||||
@ -49,16 +58,10 @@ func astTransformBlocklist(parsed *CppParsedHeader) {
|
||||
j = 0
|
||||
nextMethod:
|
||||
for _, m := range c.Methods {
|
||||
if err := AllowType(m.ReturnType, true); err != nil {
|
||||
if !blocklist_MethodAllowed(&m) {
|
||||
continue nextMethod
|
||||
}
|
||||
|
||||
for _, p := range m.Parameters {
|
||||
if err := AllowType(p, false); err != nil {
|
||||
continue nextMethod
|
||||
}
|
||||
}
|
||||
|
||||
// Keep
|
||||
c.Methods[j] = m
|
||||
j++
|
||||
|
Loading…
Reference in New Issue
Block a user