mirror of
https://github.com/mappu/miqt.git
synced 2025-01-03 06:08:38 +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
|
return CppClass{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, p := range mm.Parameters {
|
mm.IsSignal = isSignal && !mm.IsStatic && AllowSignal(mm)
|
||||||
if strings.HasSuffix(p.ParameterType, "Private") {
|
|
||||||
log.Printf("Skipping method %q taking Private type", mm.MethodName)
|
// 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
|
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`
|
// Real error
|
||||||
|
return CppClass{}, err
|
||||||
if mm.IsReceiverMethod() {
|
|
||||||
log.Printf("Skipping method %q using non-projectable receiver pattern parameters", mm.MethodName)
|
|
||||||
continue nextMethod
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.Methods = append(ret.Methods, mm)
|
ret.Methods = append(ret.Methods, mm)
|
||||||
|
@ -103,6 +103,35 @@ func AllowClass(className string) bool {
|
|||||||
return true
|
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 {
|
func CheckComplexity(p CppParameter, isReturnType bool) error {
|
||||||
|
|
||||||
if p.QMapOf() {
|
if p.QMapOf() {
|
||||||
|
Loading…
Reference in New Issue
Block a user