mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 08:58:37 +00:00
genbindings/qflags: emit qflags as inner type
This commit is contained in:
parent
286cfa90c9
commit
869e316715
@ -70,8 +70,12 @@ func (p CppParameter) RenderTypeCabi() string {
|
||||
ret = "const " + ret
|
||||
}
|
||||
|
||||
if p.IsFlagType() {
|
||||
ret = "int"
|
||||
if ft, ok := p.QFlagsOf(); ok {
|
||||
if e, ok := KnownEnums[ft.ParameterType]; ok {
|
||||
ret = e.UnderlyingType.RenderTypeCabi()
|
||||
} else {
|
||||
ret = "int"
|
||||
}
|
||||
|
||||
} else if e, ok := KnownEnums[p.ParameterType]; ok {
|
||||
ret = e.UnderlyingType.RenderTypeCabi()
|
||||
@ -216,7 +220,7 @@ func emitCABI2CppForwarding(p CppParameter, indent string) (preamble string, for
|
||||
preamble += indent + "}\n"
|
||||
return preamble, nameprefix + "_QList"
|
||||
|
||||
} else if p.IntType() || p.IsFlagType() || p.IsKnownEnum() {
|
||||
} else if p.IsFlagType() || p.IntType() || p.IsKnownEnum() {
|
||||
castSrc := p.ParameterName
|
||||
castType := p.RenderTypeQtCpp()
|
||||
|
||||
|
@ -86,8 +86,8 @@ func (p CppParameter) RenderTypeGo() string {
|
||||
ret += "uintptr"
|
||||
default:
|
||||
|
||||
if p.IsFlagType() {
|
||||
ret += "int"
|
||||
if ft, ok := p.QFlagsOf(); ok {
|
||||
ret += cabiClassName(ft.ParameterType)
|
||||
|
||||
} else if p.IsKnownEnum() {
|
||||
ret += cabiClassName(p.ParameterType)
|
||||
|
@ -65,22 +65,28 @@ func (p *CppParameter) GetQtCppType() *CppParameter {
|
||||
return p
|
||||
}
|
||||
|
||||
func (p CppParameter) IsFlagType() bool {
|
||||
if strings.HasPrefix(p.ParameterType, `QFlags<`) ||
|
||||
strings.HasPrefix(p.GetQtCppType().ParameterType, `QFlags<`) {
|
||||
return true // This catches most cases through the typedef system
|
||||
func (p CppParameter) QFlagsOf() (CppParameter, bool) {
|
||||
|
||||
if strings.HasPrefix(p.ParameterType, `QFlags<`) {
|
||||
ret := parseSingleTypeString(p.ParameterType[7 : len(p.ParameterType)-1])
|
||||
ret.ParameterName = p.ParameterName + "_qf"
|
||||
return ret, true
|
||||
}
|
||||
|
||||
switch p.ParameterType {
|
||||
case "QTouchEvent::TouchPoint::InfoFlags",
|
||||
"QFile::Permissions",
|
||||
"QWizard::WizardButton",
|
||||
"QFormLayout::ItemRole",
|
||||
"QFormLayout::RowWrapPolicy":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
if under := p.QtCppOriginalType; under != nil {
|
||||
if strings.HasPrefix(under.ParameterType, `QFlags<`) {
|
||||
ret := parseSingleTypeString(under.ParameterType[7 : len(under.ParameterType)-1])
|
||||
ret.ParameterName = under.ParameterName + "_qf"
|
||||
return ret, true
|
||||
}
|
||||
}
|
||||
|
||||
return CppParameter{}, false
|
||||
}
|
||||
|
||||
func (p CppParameter) IsFlagType() bool {
|
||||
_, ok := p.QFlagsOf()
|
||||
return ok
|
||||
}
|
||||
|
||||
func (p CppParameter) QtClassType() bool {
|
||||
|
Loading…
Reference in New Issue
Block a user