mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 08:58:37 +00:00
genbindings: centralize AllowSignal/AllowMethod exceptions, block metacast signal
This commit is contained in:
parent
aadc37eb2d
commit
9055f6e2ae
@ -442,22 +442,18 @@ nextMethod:
|
||||
return CppClass{}, err
|
||||
}
|
||||
|
||||
for _, p := range mm.Parameters {
|
||||
if strings.HasSuffix(p.ParameterType, "Private") {
|
||||
log.Printf("Skipping method %q taking Private type", mm.MethodName)
|
||||
mm.IsSignal = isSignal && !mm.IsStatic && AllowSignal(mm)
|
||||
|
||||
// Once all processing is complete, pass to exceptions for final decision
|
||||
|
||||
if err := AllowMethod(mm); err != nil {
|
||||
if errors.Is(err, ErrTooComplex) {
|
||||
log.Printf("Skipping method %q with complex type", mm.MethodName)
|
||||
continue nextMethod
|
||||
}
|
||||
}
|
||||
if strings.HasSuffix(mm.ReturnType.ParameterType, "Private") {
|
||||
log.Printf("Skipping method %q returning Private type", mm.MethodName)
|
||||
continue nextMethod
|
||||
}
|
||||
|
||||
mm.IsSignal = isSignal && !mm.IsStatic && mm.MethodName != `metaObject`
|
||||
|
||||
if mm.IsReceiverMethod() {
|
||||
log.Printf("Skipping method %q using non-projectable receiver pattern parameters", mm.MethodName)
|
||||
continue nextMethod
|
||||
// Real error
|
||||
return CppClass{}, err
|
||||
}
|
||||
|
||||
ret.Methods = append(ret.Methods, mm)
|
||||
|
@ -103,6 +103,35 @@ func AllowClass(className string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func AllowSignal(mm CppMethod) bool {
|
||||
switch mm.MethodName {
|
||||
case `metaObject`, `qt_metacast`:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func AllowMethod(mm CppMethod) error {
|
||||
|
||||
for _, p := range mm.Parameters {
|
||||
if strings.HasSuffix(p.ParameterType, "Private") {
|
||||
return ErrTooComplex // Skip private type
|
||||
}
|
||||
}
|
||||
if strings.HasSuffix(mm.ReturnType.ParameterType, "Private") {
|
||||
return ErrTooComplex // Skip private type
|
||||
}
|
||||
|
||||
if mm.IsReceiverMethod() {
|
||||
// Non-projectable receiver pattern parameters
|
||||
return ErrTooComplex
|
||||
}
|
||||
|
||||
return nil // OK, allow
|
||||
|
||||
}
|
||||
|
||||
func CheckComplexity(p CppParameter, isReturnType bool) error {
|
||||
|
||||
if p.QMapOf() {
|
||||
|
Loading…
Reference in New Issue
Block a user