mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 17:08:38 +00:00
genbindings: support 'signed char'
This commit is contained in:
parent
7b5db7c7ea
commit
daff305d36
@ -698,6 +698,8 @@ func tokenizeSingleParameter(p string) []string {
|
|||||||
}
|
}
|
||||||
func parseSingleTypeString(p string) CppParameter {
|
func parseSingleTypeString(p string) CppParameter {
|
||||||
|
|
||||||
|
isSigned := false
|
||||||
|
|
||||||
tokens := tokenizeSingleParameter(p) // strings.Split(strings.TrimSpace(p), " ")
|
tokens := tokenizeSingleParameter(p) // strings.Split(strings.TrimSpace(p), " ")
|
||||||
insert := CppParameter{}
|
insert := CppParameter{}
|
||||||
for _, tok := range tokens {
|
for _, tok := range tokens {
|
||||||
@ -714,7 +716,8 @@ func parseSingleTypeString(p string) CppParameter {
|
|||||||
insert.ByRef = true
|
insert.ByRef = true
|
||||||
|
|
||||||
} else if tok == "signed" {
|
} else if tok == "signed" {
|
||||||
// continue
|
// We don't need this - UNLESS it's 'signed char'
|
||||||
|
isSigned = true
|
||||||
|
|
||||||
} else if tok == "*" {
|
} else if tok == "*" {
|
||||||
insert.Pointer = true
|
insert.Pointer = true
|
||||||
@ -740,6 +743,10 @@ func parseSingleTypeString(p string) CppParameter {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Valid part of the type name
|
// Valid part of the type name
|
||||||
|
if tok == "char" && isSigned {
|
||||||
|
tok = "signed char"
|
||||||
|
isSigned = false
|
||||||
|
}
|
||||||
insert.ParameterType += " " + tok
|
insert.ParameterType += " " + tok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,10 +252,15 @@ func emitParametersCABI2CppForwarding(params []CppParameter) (preamble string, f
|
|||||||
castSrc = "*" + castSrc
|
castSrc = "*" + castSrc
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.ParameterType == "qint64" || p.ParameterType == "quint64" || p.ParameterType == "qlonglong" || p.ParameterType == "qulonglong" {
|
if p.ParameterType == "qint64" ||
|
||||||
|
p.ParameterType == "quint64" ||
|
||||||
|
p.ParameterType == "qlonglong" ||
|
||||||
|
p.ParameterType == "qulonglong" ||
|
||||||
|
p.ParameterType == "qint8" {
|
||||||
// QDataStream::operator>>() by reference (qint64)
|
// QDataStream::operator>>() by reference (qint64)
|
||||||
// QLockFile::getLockInfo() by pointer
|
// QLockFile::getLockInfo() by pointer
|
||||||
// QTextStream::operator>>() by reference (qlonglong + qulonglong)
|
// QTextStream::operator>>() by reference (qlonglong + qulonglong)
|
||||||
|
// QDataStream::operator>>() qint8
|
||||||
// CABI has these as int64_t* (long int) which fails a static_cast to qint64& (long long int&)
|
// CABI has these as int64_t* (long int) which fails a static_cast to qint64& (long long int&)
|
||||||
// Hack a hard C-style cast
|
// Hack a hard C-style cast
|
||||||
tmp = append(tmp, "("+castType+")("+castSrc+")")
|
tmp = append(tmp, "("+castType+")("+castSrc+")")
|
||||||
|
@ -36,7 +36,7 @@ func (p CppParameter) RenderTypeGo() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch p.ParameterType {
|
switch p.ParameterType {
|
||||||
case "char", "qint8", "unsigned char", "uchar", "quint8":
|
case "char", "qint8", "signed char", "unsigned char", "uchar", "quint8":
|
||||||
ret += "byte" // Strictly speaking, Go byte is unsigned and char may be signed
|
ret += "byte" // Strictly speaking, Go byte is unsigned and char may be signed
|
||||||
case "short", "qint16":
|
case "short", "qint16":
|
||||||
ret += "int16"
|
ret += "int16"
|
||||||
|
Loading…
Reference in New Issue
Block a user