mirror of
https://github.com/mappu/miqt.git
synced 2025-01-03 14:18:37 +00:00
genbindings: fixes for signed char, pointer+reference types
This commit is contained in:
parent
6c1acb9377
commit
d8c7e9e770
@ -64,11 +64,10 @@ func (p CppParameter) RenderTypeCabi() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.ByRef {
|
|
||||||
ret += "*"
|
|
||||||
}
|
|
||||||
if p.Pointer {
|
if p.Pointer {
|
||||||
ret += strings.Repeat("*", p.PointerCount)
|
ret += strings.Repeat("*", p.PointerCount)
|
||||||
|
} else if p.ByRef {
|
||||||
|
ret += "*"
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret // ignore const
|
return ret // ignore const
|
||||||
@ -242,6 +241,8 @@ func emitParametersCABI2CppForwarding(params []CppParameter) (preamble string, f
|
|||||||
preamble += "\tfor(size_t i = 0; i < " + p.ParameterName + "_len; ++i) {\n"
|
preamble += "\tfor(size_t i = 0; i < " + p.ParameterName + "_len; ++i) {\n"
|
||||||
if listType.QtClassType() && !listType.Pointer {
|
if listType.QtClassType() && !listType.Pointer {
|
||||||
preamble += "\t\t" + p.ParameterName + "_QList.push_back(*(" + p.ParameterName + "[i]));\n"
|
preamble += "\t\t" + p.ParameterName + "_QList.push_back(*(" + p.ParameterName + "[i]));\n"
|
||||||
|
} else if listType.IsFlagType() {
|
||||||
|
preamble += "\t\t" + p.ParameterName + "_QList.push_back(static_cast<" + listType.RenderTypeQtCpp() + ">(" + p.ParameterName + "[i]));\n"
|
||||||
} else {
|
} else {
|
||||||
preamble += "\t\t" + p.ParameterName + "_QList.push_back(" + p.ParameterName + "[i]);\n"
|
preamble += "\t\t" + p.ParameterName + "_QList.push_back(" + p.ParameterName + "[i]);\n"
|
||||||
}
|
}
|
||||||
@ -277,10 +278,18 @@ func emitParametersCABI2CppForwarding(params []CppParameter) (preamble string, f
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if p.ByRef {
|
} else if p.ByRef {
|
||||||
// We changed RenderTypeCabi() to render this as a pointer
|
if p.Pointer {
|
||||||
// Need to dereference so we can pass as reference to the actual Qt C++ function
|
// By ref and by pointer
|
||||||
//tmp = append(tmp, "*"+p.ParameterName)
|
// This happens for QDataStream &QDataStream::operator>>(char *&s)
|
||||||
tmp = append(tmp, "*"+p.ParameterName)
|
// We are only using one level of indirection
|
||||||
|
tmp = append(tmp, p.ParameterName)
|
||||||
|
} else {
|
||||||
|
// By ref and not by pointer
|
||||||
|
// We changed RenderTypeCabi() to render this as a pointer
|
||||||
|
// Need to dereference so we can pass as reference to the actual Qt C++ function
|
||||||
|
//tmp = append(tmp, "*"+p.ParameterName)
|
||||||
|
tmp = append(tmp, "*"+p.ParameterName)
|
||||||
|
}
|
||||||
|
|
||||||
} else if p.QtClassType() && !p.Pointer {
|
} else if p.QtClassType() && !p.Pointer {
|
||||||
// CABI takes all Qt types by pointer, even if C++ wants them by value
|
// CABI takes all Qt types by pointer, even if C++ wants them by value
|
||||||
|
@ -112,6 +112,9 @@ func (p CppParameter) parameterTypeCgo() string {
|
|||||||
if strings.HasPrefix(tmp, "unsigned ") {
|
if strings.HasPrefix(tmp, "unsigned ") {
|
||||||
tmp = "u" + tmp[9:] // Cgo uses uchar, uint instead of full name
|
tmp = "u" + tmp[9:] // Cgo uses uchar, uint instead of full name
|
||||||
}
|
}
|
||||||
|
if strings.HasPrefix(tmp, "signed ") {
|
||||||
|
tmp = "s" + tmp[7:] // Cgo uses schar
|
||||||
|
}
|
||||||
tmp = strings.Replace(tmp, `long long`, `longlong`, -1)
|
tmp = strings.Replace(tmp, `long long`, `longlong`, -1)
|
||||||
return "C." + strings.Replace(tmp, " ", "_", -1)
|
return "C." + strings.Replace(tmp, " ", "_", -1)
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ func (p CppParameter) IntType() bool {
|
|||||||
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",
|
||||||
"unsigned char", "uchar",
|
"unsigned char", "signed 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",
|
||||||
"qintptr", "quintptr", "uintptr_t", "intptr_t",
|
"qintptr", "quintptr", "uintptr_t", "intptr_t",
|
||||||
|
Loading…
Reference in New Issue
Block a user