mirror of
https://github.com/mappu/miqt.git
synced 2025-05-13 15:10:21 +00:00
genbindings: fixes for integer types
This commit is contained in:
parent
3121a7c610
commit
8fb92cfd3a
@ -125,8 +125,8 @@ func emitParametersCabi(m CppMethod, selfType string) string {
|
|||||||
} else if t, ok := p.QListOf(); ok {
|
} else if t, ok := p.QListOf(); ok {
|
||||||
|
|
||||||
if t.ParameterType == "QString" {
|
if t.ParameterType == "QString" {
|
||||||
// Combov
|
// Combo
|
||||||
tmp = append(tmp, "char** "+p.ParameterName+", int64_t* "+p.ParameterName+"_Lengths, size_t "+p.ParameterName+"_len")
|
tmp = append(tmp, "char** "+p.ParameterName+", uint64_t* "+p.ParameterName+"_Lengths, size_t "+p.ParameterName+"_len")
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// The Go code has called this with two arguments: T* and len
|
// The Go code has called this with two arguments: T* and len
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func goReservedWord(s string) bool {
|
func goReservedWord(s string) bool {
|
||||||
@ -22,15 +21,9 @@ func (p CppParameter) RenderTypeGo() string {
|
|||||||
if p.Pointer && p.ParameterType == "char" {
|
if p.Pointer && p.ParameterType == "char" {
|
||||||
return "string"
|
return "string"
|
||||||
}
|
}
|
||||||
if p.ParameterType == "char" {
|
|
||||||
return "byte"
|
|
||||||
}
|
|
||||||
if p.ParameterType == "QString" {
|
if p.ParameterType == "QString" {
|
||||||
return "string"
|
return "string"
|
||||||
}
|
}
|
||||||
if p.ParameterType == "uintptr_t" {
|
|
||||||
return "uintptr"
|
|
||||||
}
|
|
||||||
|
|
||||||
if t, ok := p.QListOf(); ok {
|
if t, ok := p.QListOf(); ok {
|
||||||
return "[]" + t.RenderTypeGo()
|
return "[]" + t.RenderTypeGo()
|
||||||
@ -70,7 +63,7 @@ func (p CppParameter) RenderTypeGo() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "unsigned int":
|
case "unsigned int":
|
||||||
return "uint"
|
ret += "uint"
|
||||||
case "qint32":
|
case "qint32":
|
||||||
ret += "int32"
|
ret += "int32"
|
||||||
case "quint32":
|
case "quint32":
|
||||||
@ -89,20 +82,8 @@ func (p CppParameter) RenderTypeGo() string {
|
|||||||
} else {
|
} else {
|
||||||
ret += "uint64"
|
ret += "uint64"
|
||||||
}
|
}
|
||||||
case "qintptr":
|
case "qintptr", "uintptr_t", "intptr_t", "quintptr":
|
||||||
var ptr *int
|
ret += "uintptr"
|
||||||
if unsafe.Sizeof(ptr) == 8 {
|
|
||||||
ret += "int64"
|
|
||||||
} else {
|
|
||||||
ret += "int32"
|
|
||||||
}
|
|
||||||
case "quintptr":
|
|
||||||
var ptr *int
|
|
||||||
if unsafe.Sizeof(ptr) == 8 {
|
|
||||||
ret += "uint64"
|
|
||||||
} else {
|
|
||||||
ret += "uint32"
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
// Do not transform this type
|
// Do not transform this type
|
||||||
ret += p.ParameterType
|
ret += p.ParameterType
|
||||||
|
@ -45,18 +45,26 @@ func (p CppParameter) QSetOf() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p CppParameter) IntType() bool {
|
func (p CppParameter) IntType() bool {
|
||||||
|
|
||||||
switch p.ParameterType {
|
switch p.ParameterType {
|
||||||
case "int", "unsigned int", "uint",
|
case "int", "unsigned int", "uint",
|
||||||
"short", "unsigned short", "ushort", "qint16", "quint16",
|
"short", "unsigned short", "ushort", "qint16", "quint16",
|
||||||
"qint8", "quint8",
|
"qint8", "quint8",
|
||||||
// "char", "uchar", // Don't count char or char* as integer types that need cast assertions
|
"unsigned char", "uchar",
|
||||||
"long", "unsigned long", "ulong", "qint32", "quint32",
|
"long", "unsigned long", "ulong", "qint32", "quint32",
|
||||||
"longlong", "ulonglong", "qlonglong", "qulonglong", "qint64", "quint64", "int64_t", "uint64_t", "long long", "unsigned long long",
|
"longlong", "ulonglong", "qlonglong", "qulonglong", "qint64", "quint64", "int64_t", "uint64_t", "long long", "unsigned long long",
|
||||||
"QRgb", // unsigned int
|
"QRgb", // QRgb is an unsigned int
|
||||||
"qintptr", "quintptr",
|
"qintptr", "quintptr", "uintptr_t", "intptr_t",
|
||||||
"qsizetype", "size_t",
|
"qsizetype", "size_t",
|
||||||
"double", "float", "qreal":
|
"double", "float", "qreal":
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
case "char":
|
||||||
|
// Only count char as an integer type with cast assertions if it's
|
||||||
|
// not possibly a char* string in disguise
|
||||||
|
// (However, unsigned chars are always like ints)
|
||||||
|
return !p.Pointer
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user