genbindings/ints: ssize_t support

This commit is contained in:
mappu 2024-10-08 18:21:59 +13:00
parent 6eb60232a9
commit 60600530c6
3 changed files with 10 additions and 4 deletions

View File

@ -51,15 +51,13 @@ func (p CppParameter) RenderTypeCabi() string {
ret = "uint64_t"
case "qfloat16":
ret = "_Float16" // No idea where this typedef comes from, but it exists
case "qsizetype":
ret = "size_t"
case "qreal":
ret = "double"
case "qintptr", "QIntegerForSizeof<void *>::Signed":
ret = "intptr_t"
case "quintptr", "uintptr", "QIntegerForSizeof<void *>::Unsigned":
ret = "uintptr_t"
case "qptrdiff":
case "qsizetype", "qptrdiff", "QIntegerForSizeof<std::size_t>::Signed":
ret = "ptrdiff_t"
}

View File

@ -80,12 +80,19 @@ func (p CppParameter) RenderTypeGo() string {
ret += "float32"
case "double", "qreal":
ret += "float64"
case "qsizetype", "size_t", "qptrdiff", "ptrdiff_t":
case "size_t": // size_t is unsigned
if C.sizeof_size_t == 4 {
ret += "uint32"
} else {
ret += "uint64"
}
case "qsizetype", "QIntegerForSizeof<std::size_t>::Signed", "qptrdiff", "ptrdiff_t": // all signed
if C.sizeof_size_t == 4 {
ret += "int32"
} else {
ret += "int64"
}
case "qintptr", "uintptr_t", "intptr_t", "quintptr", "QIntegerForSizeof<void *>::Unsigned", "QIntegerForSizeof<void *>::Signed":
ret += "uintptr"
default:

View File

@ -160,6 +160,7 @@ func (p CppParameter) IntType() bool {
"qsizetype", "size_t",
"QIntegerForSizeof<void *>::Unsigned",
"QIntegerForSizeof<void *>::Signed",
"QIntegerForSizeof<std::size_t>::Signed",
"qptrdiff", "ptrdiff_t",
"double", "float", "qreal":
return true