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