mirror of
https://github.com/mappu/miqt.git
synced 2025-01-21 22:20:38 +00:00
genbindings: fixup pointer arithmetic for returning arrays by value
This commit is contained in:
parent
21f1914244
commit
7f552ee6a4
@ -280,11 +280,11 @@ func emitBindingCpp(src *CppParsedHeader, filename string) (string, error) {
|
||||
} else if t, ok := m.ReturnType.QListOf(); ok {
|
||||
shouldReturn = m.ReturnType.ParameterType + " ret = "
|
||||
afterCall += "\t// Convert QList<> from C++ memory to manually-managed C memory\n"
|
||||
afterCall += "\t*_out = malloc(sizeof(" + t.RenderTypeCpp() + ") * ret.length());\n"
|
||||
afterCall += "\t*_out = static_cast<" + t.RenderTypeCpp() + ">(malloc(sizeof(" + t.RenderTypeCpp() + ") * ret.length()));\n"
|
||||
afterCall += "\tfor (int i = 0, e = ret.length(); i < e; ++i) {\n"
|
||||
afterCall += "\t\t(*_out)[i] = ret[i];\n"
|
||||
afterCall += "\t\t_out[i] = ret[i];\n"
|
||||
afterCall += "\t}\n"
|
||||
afterCall += "\t*_out_len = ret.length()\n"
|
||||
afterCall += "\t*_out_len = ret.length();\n"
|
||||
|
||||
} else if m.ReturnType.QtClassType() && !m.ReturnType.Pointer {
|
||||
shouldReturn = m.ReturnType.ParameterType + " ret = "
|
||||
|
Loading…
x
Reference in New Issue
Block a user