mirror of
https://github.com/mappu/miqt.git
synced 2025-04-17 11:00:23 +00:00
genbindings: add noexcept
support for overrides
This commit is contained in:
parent
6cb0296e6d
commit
88c6d51dc1
@ -669,7 +669,7 @@ func parseMethod(node map[string]interface{}, mm *CppMethod) error {
|
|||||||
// If anything here is too complicated, skip the whole method
|
// If anything here is too complicated, skip the whole method
|
||||||
|
|
||||||
var err error = nil
|
var err error = nil
|
||||||
mm.ReturnType, mm.Parameters, mm.IsConst, err = parseTypeString(qualType)
|
mm.ReturnType, mm.Parameters, mm.IsConst, mm.IsNoExcept, err = parseTypeString(qualType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -767,10 +767,10 @@ func parseMethod(node map[string]interface{}, mm *CppMethod) error {
|
|||||||
// into its (A) return type and (B) separate parameter types.
|
// into its (A) return type and (B) separate parameter types.
|
||||||
// These clang strings never contain the parameter's name, so the names here are
|
// These clang strings never contain the parameter's name, so the names here are
|
||||||
// not filled in.
|
// not filled in.
|
||||||
func parseTypeString(typeString string) (CppParameter, []CppParameter, bool, error) {
|
func parseTypeString(typeString string) (CppParameter, []CppParameter, bool, bool, error) {
|
||||||
|
|
||||||
if strings.Contains(typeString, `&&`) { // TODO Rvalue references
|
if strings.Contains(typeString, `&&`) { // TODO Rvalue references
|
||||||
return CppParameter{}, nil, false, ErrTooComplex
|
return CppParameter{}, nil, false, false, ErrTooComplex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cut to exterior-most (, ) pair
|
// Cut to exterior-most (, ) pair
|
||||||
@ -778,13 +778,11 @@ func parseTypeString(typeString string) (CppParameter, []CppParameter, bool, err
|
|||||||
epos := strings.LastIndex(typeString, `)`)
|
epos := strings.LastIndex(typeString, `)`)
|
||||||
|
|
||||||
if opos == -1 || epos == -1 {
|
if opos == -1 || epos == -1 {
|
||||||
return CppParameter{}, nil, false, fmt.Errorf("Type string %q missing brackets", typeString)
|
return CppParameter{}, nil, false, false, fmt.Errorf("Type string %q missing brackets", typeString)
|
||||||
}
|
}
|
||||||
|
|
||||||
isConst := false
|
isConst := strings.Contains(typeString[epos:], `const`)
|
||||||
if strings.Contains(typeString[epos:], `const`) {
|
isNoExcept := strings.Contains(typeString[epos:], `noexcept`)
|
||||||
isConst = true
|
|
||||||
}
|
|
||||||
|
|
||||||
returnType := parseSingleTypeString(strings.TrimSpace(typeString[0:opos]))
|
returnType := parseSingleTypeString(strings.TrimSpace(typeString[0:opos]))
|
||||||
|
|
||||||
@ -792,7 +790,7 @@ func parseTypeString(typeString string) (CppParameter, []CppParameter, bool, err
|
|||||||
|
|
||||||
// Should be no more brackets
|
// Should be no more brackets
|
||||||
if strings.ContainsAny(inner, `()`) {
|
if strings.ContainsAny(inner, `()`) {
|
||||||
return CppParameter{}, nil, false, ErrTooComplex
|
return CppParameter{}, nil, false, false, ErrTooComplex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parameters are separated by commas and nesting can not be possible
|
// Parameters are separated by commas and nesting can not be possible
|
||||||
@ -808,7 +806,7 @@ func parseTypeString(typeString string) (CppParameter, []CppParameter, bool, err
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnType, ret, isConst, nil
|
return returnType, ret, isConst, isNoExcept, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// tokenizeMultipleParameters is like strings.Split by comma, except it does not
|
// tokenizeMultipleParameters is like strings.Split by comma, except it does not
|
||||||
@ -898,6 +896,10 @@ func parseSingleTypeString(p string) CppParameter {
|
|||||||
// QNetwork has some references to 'class QSslCertificate'. Flatten
|
// QNetwork has some references to 'class QSslCertificate'. Flatten
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
} else if tok == "noexcept" {
|
||||||
|
// Used by ScintillaEdit
|
||||||
|
insert.NoExcept = true
|
||||||
|
|
||||||
} else if tok == "&" { // U+0026
|
} else if tok == "&" { // U+0026
|
||||||
insert.ByRef = true
|
insert.ByRef = true
|
||||||
|
|
||||||
|
@ -1045,7 +1045,7 @@ extern "C" {
|
|||||||
|
|
||||||
ret.WriteString(
|
ret.WriteString(
|
||||||
"\t// Subclass to allow providing a Go implementation\n" +
|
"\t// Subclass to allow providing a Go implementation\n" +
|
||||||
"\tvirtual " + m.ReturnType.RenderTypeQtCpp() + " " + m.CppCallTarget() + "(" + emitParametersCpp(m) + ") " + ifv(m.IsConst, "const ", "") + "override {\n",
|
"\tvirtual " + m.ReturnType.RenderTypeQtCpp() + " " + m.CppCallTarget() + "(" + emitParametersCpp(m) + ") " + ifv(m.IsConst, "const ", "") + ifv(m.IsNoExcept, "noexcept ", "") + "override {\n",
|
||||||
)
|
)
|
||||||
|
|
||||||
ret.WriteString("\t\tif (" + handleVarname + " == 0) {\n")
|
ret.WriteString("\t\tif (" + handleVarname + " == 0) {\n")
|
||||||
|
@ -14,6 +14,7 @@ type CppParameter struct {
|
|||||||
PointerCount int
|
PointerCount int
|
||||||
ByRef bool
|
ByRef bool
|
||||||
Optional bool
|
Optional bool
|
||||||
|
NoExcept bool
|
||||||
|
|
||||||
QtCppOriginalType *CppParameter // If we rewrote QStringList->QList<String>, this field contains the original QStringList. Otherwise, it's blank
|
QtCppOriginalType *CppParameter // If we rewrote QStringList->QList<String>, this field contains the original QStringList. Otherwise, it's blank
|
||||||
}
|
}
|
||||||
@ -245,6 +246,7 @@ type CppMethod struct {
|
|||||||
IsStatic bool
|
IsStatic bool
|
||||||
IsSignal bool
|
IsSignal bool
|
||||||
IsConst bool
|
IsConst bool
|
||||||
|
IsNoExcept bool
|
||||||
IsVirtual bool
|
IsVirtual bool
|
||||||
IsPureVirtual bool // Virtual method was declared with = 0 i.e. there is no base method here to call
|
IsPureVirtual bool // Virtual method was declared with = 0 i.e. there is no base method here to call
|
||||||
IsProtected bool // If true, we can't call this method but we may still be able to overload it
|
IsProtected bool // If true, we can't call this method but we may still be able to overload it
|
||||||
|
Loading…
x
Reference in New Issue
Block a user