mirror of
https://github.com/mappu/miqt.git
synced 2025-01-31 02:20:22 +00:00
genbindings: treat QRgb as unsigned int
This commit is contained in:
parent
5fa7bd37eb
commit
9a78d87e00
@ -31,6 +31,8 @@ func (p CppParameter) RenderTypeCpp() string {
|
||||
ret = "uint64_t"
|
||||
case "qfloat16":
|
||||
ret = "_Float16" // No idea where this typedef comes from, but it exists
|
||||
case "QRgb":
|
||||
ret = "unsigned int"
|
||||
}
|
||||
|
||||
if p.Pointer || p.ByRef {
|
||||
@ -250,6 +252,9 @@ func getReferencedTypes(src *CppParsedHeader) []string {
|
||||
if strings.HasPrefix(ft, "QList<") {
|
||||
continue
|
||||
}
|
||||
if ft == "QRgb" {
|
||||
continue
|
||||
}
|
||||
|
||||
foundTypesList = append(foundTypesList, ft)
|
||||
}
|
||||
|
@ -21,44 +21,6 @@ func (p CppParameter) RenderTypeGo() string {
|
||||
if p.Pointer && p.ParameterType == "char" {
|
||||
return "string"
|
||||
}
|
||||
if !p.Pointer && p.IntType() {
|
||||
switch p.ParameterType {
|
||||
case "char", "qint8":
|
||||
return "byte"
|
||||
case "unsigned char", "quint8":
|
||||
return "byte"
|
||||
case "short", "qint16":
|
||||
return "int16"
|
||||
case "ushort", "quint16":
|
||||
return "uint16"
|
||||
case "long":
|
||||
// Windows ILP32 - 32-bits
|
||||
// Linux LP64 - 64-bits
|
||||
if C.sizeof_long == 4 {
|
||||
return "int32"
|
||||
} else {
|
||||
return "int64"
|
||||
}
|
||||
case "ulong", "unsigned long":
|
||||
if C.sizeof_long == 4 {
|
||||
return "uint32"
|
||||
} else {
|
||||
return "uint64"
|
||||
}
|
||||
case "qint32":
|
||||
return "int32"
|
||||
case "quint32":
|
||||
return "uint32"
|
||||
case "qlonglong", "qint64":
|
||||
return "int64"
|
||||
case "qulonglong", "quint64":
|
||||
return "uint64"
|
||||
case "float":
|
||||
return "float32"
|
||||
case "double":
|
||||
return "float64"
|
||||
}
|
||||
}
|
||||
if p.ParameterType == "char" {
|
||||
return "byte"
|
||||
}
|
||||
@ -77,7 +39,55 @@ func (p CppParameter) RenderTypeGo() string {
|
||||
if p.ByRef || p.Pointer {
|
||||
ret += "*"
|
||||
}
|
||||
ret += p.ParameterType
|
||||
|
||||
switch p.ParameterType {
|
||||
case "char", "qint8":
|
||||
ret += "byte"
|
||||
case "unsigned char", "quint8":
|
||||
ret += "byte"
|
||||
case "short", "qint16":
|
||||
ret += "int16"
|
||||
case "ushort", "quint16":
|
||||
ret += "uint16"
|
||||
case "long":
|
||||
// Windows ILP32 - 32-bits
|
||||
// Linux LP64 - 64-bits
|
||||
if C.sizeof_long == 4 {
|
||||
ret += "int32"
|
||||
} else {
|
||||
ret += "int64"
|
||||
}
|
||||
case "ulong", "unsigned long":
|
||||
if C.sizeof_long == 4 {
|
||||
ret += "uint32"
|
||||
} else {
|
||||
ret += "uint64"
|
||||
}
|
||||
case "QRgb":
|
||||
if C.sizeof_int == 4 {
|
||||
ret += "uint32"
|
||||
} else {
|
||||
ret += "uint64"
|
||||
}
|
||||
|
||||
case "qint32":
|
||||
ret += "int32"
|
||||
case "quint32":
|
||||
ret += "uint32"
|
||||
case "qlonglong", "qint64":
|
||||
ret += "int64"
|
||||
case "qulonglong", "quint64":
|
||||
ret += "uint64"
|
||||
case "float":
|
||||
ret += "float32"
|
||||
case "double":
|
||||
ret += "float64"
|
||||
default:
|
||||
// Do not transform this type
|
||||
ret += p.ParameterType
|
||||
|
||||
}
|
||||
|
||||
return ret // ignore const
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ type CppParameter struct {
|
||||
}
|
||||
|
||||
func (p CppParameter) QtClassType() bool {
|
||||
return p.ParameterType[0] == 'Q'
|
||||
return (p.ParameterType[0] == 'Q') && p.ParameterType != "QRgb"
|
||||
}
|
||||
|
||||
func (p CppParameter) QListOf() (CppParameter, bool) {
|
||||
@ -38,6 +38,7 @@ func (p CppParameter) IntType() bool {
|
||||
// "char", "uchar", // Don't count char or char* as integer types that need cast assertions
|
||||
"long", "unsigned long", "ulong", "qint32", "quint32",
|
||||
"longlong", "ulonglong", "qlonglong", "qulonglong", "qint64", "quint64", "int64_t", "uint64_t", "long long", "unsigned long long",
|
||||
"QRgb", // unsigned int
|
||||
"double", "float", "qreal":
|
||||
return true
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user