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
|
ret = "const " + ret
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.IsFlagType() {
|
if ft, ok := p.QFlagsOf(); ok {
|
||||||
ret = "int"
|
if e, ok := KnownEnums[ft.ParameterType]; ok {
|
||||||
|
ret = e.UnderlyingType.RenderTypeCabi()
|
||||||
|
} else {
|
||||||
|
ret = "int"
|
||||||
|
}
|
||||||
|
|
||||||
} else if e, ok := KnownEnums[p.ParameterType]; ok {
|
} else if e, ok := KnownEnums[p.ParameterType]; ok {
|
||||||
ret = e.UnderlyingType.RenderTypeCabi()
|
ret = e.UnderlyingType.RenderTypeCabi()
|
||||||
@ -216,7 +220,7 @@ func emitCABI2CppForwarding(p CppParameter, indent string) (preamble string, for
|
|||||||
preamble += indent + "}\n"
|
preamble += indent + "}\n"
|
||||||
return preamble, nameprefix + "_QList"
|
return preamble, nameprefix + "_QList"
|
||||||
|
|
||||||
} else if p.IntType() || p.IsFlagType() || p.IsKnownEnum() {
|
} else if p.IsFlagType() || p.IntType() || p.IsKnownEnum() {
|
||||||
castSrc := p.ParameterName
|
castSrc := p.ParameterName
|
||||||
castType := p.RenderTypeQtCpp()
|
castType := p.RenderTypeQtCpp()
|
||||||
|
|
||||||
|
@ -86,8 +86,8 @@ func (p CppParameter) RenderTypeGo() string {
|
|||||||
ret += "uintptr"
|
ret += "uintptr"
|
||||||
default:
|
default:
|
||||||
|
|
||||||
if p.IsFlagType() {
|
if ft, ok := p.QFlagsOf(); ok {
|
||||||
ret += "int"
|
ret += cabiClassName(ft.ParameterType)
|
||||||
|
|
||||||
} else if p.IsKnownEnum() {
|
} else if p.IsKnownEnum() {
|
||||||
ret += cabiClassName(p.ParameterType)
|
ret += cabiClassName(p.ParameterType)
|
||||||
|
@ -65,22 +65,28 @@ func (p *CppParameter) GetQtCppType() *CppParameter {
|
|||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p CppParameter) IsFlagType() bool {
|
func (p CppParameter) QFlagsOf() (CppParameter, bool) {
|
||||||
if strings.HasPrefix(p.ParameterType, `QFlags<`) ||
|
|
||||||
strings.HasPrefix(p.GetQtCppType().ParameterType, `QFlags<`) {
|
if strings.HasPrefix(p.ParameterType, `QFlags<`) {
|
||||||
return true // This catches most cases through the typedef system
|
ret := parseSingleTypeString(p.ParameterType[7 : len(p.ParameterType)-1])
|
||||||
|
ret.ParameterName = p.ParameterName + "_qf"
|
||||||
|
return ret, true
|
||||||
}
|
}
|
||||||
|
|
||||||
switch p.ParameterType {
|
if under := p.QtCppOriginalType; under != nil {
|
||||||
case "QTouchEvent::TouchPoint::InfoFlags",
|
if strings.HasPrefix(under.ParameterType, `QFlags<`) {
|
||||||
"QFile::Permissions",
|
ret := parseSingleTypeString(under.ParameterType[7 : len(under.ParameterType)-1])
|
||||||
"QWizard::WizardButton",
|
ret.ParameterName = under.ParameterName + "_qf"
|
||||||
"QFormLayout::ItemRole",
|
return ret, true
|
||||||
"QFormLayout::RowWrapPolicy":
|
}
|
||||||
return true
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return CppParameter{}, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p CppParameter) IsFlagType() bool {
|
||||||
|
_, ok := p.QFlagsOf()
|
||||||
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p CppParameter) QtClassType() bool {
|
func (p CppParameter) QtClassType() bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user