mirror of
https://github.com/mappu/miqt.git
synced 2025-01-03 06:08:38 +00:00
genbindings/qset: fixes for qset marshalling
This commit is contained in:
parent
eae85ac325
commit
e2fd134509
@ -340,14 +340,15 @@ func emitAssignCppToCabi(assignExpression string, p CppParameter, rvalue string)
|
|||||||
shouldReturn = p.RenderTypeQtCpp() + " " + namePrefix + "_ret = "
|
shouldReturn = p.RenderTypeQtCpp() + " " + namePrefix + "_ret = "
|
||||||
|
|
||||||
afterCall += indent + "// Convert QList<> from C++ memory to manually-managed C memory\n"
|
afterCall += indent + "// Convert QList<> from C++ memory to manually-managed C memory\n"
|
||||||
afterCall += indent + "" + t.RenderTypeCabi() + "* " + namePrefix + "_arr = static_cast<" + t.RenderTypeCabi() + "*>(malloc(sizeof(" + t.RenderTypeCabi() + ") * " + namePrefix + "_ret.length()));\n"
|
afterCall += indent + "" + t.RenderTypeCabi() + "* " + namePrefix + "_arr = static_cast<" + t.RenderTypeCabi() + "*>(malloc(sizeof(" + t.RenderTypeCabi() + ") * " + namePrefix + "_ret.size()));\n"
|
||||||
afterCall += indent + "int " + namePrefix + "_ctr = 0;\n"
|
afterCall += indent + "int " + namePrefix + "_ctr = 0;\n"
|
||||||
afterCall += indent + "for (const auto " + namePrefix + "_elem& : " + rvalue + " ) {\n"
|
afterCall += indent + "QSetIterator<" + t.RenderTypeQtCpp() + "> " + namePrefix + "_itr(" + namePrefix + "_ret);\n"
|
||||||
afterCall += emitAssignCppToCabi(indent+"\t"+namePrefix+"_arr["+namePrefix+"_ctr++] = ", t, namePrefix+"_elem")
|
afterCall += indent + "while (" + namePrefix + "_itr.hasNext()) {\n"
|
||||||
|
afterCall += emitAssignCppToCabi(indent+"\t"+namePrefix+"_arr["+namePrefix+"_ctr++] = ", t, namePrefix+"_itr.next()")
|
||||||
afterCall += indent + "}\n"
|
afterCall += indent + "}\n"
|
||||||
|
|
||||||
afterCall += indent + "struct miqt_array* " + namePrefix + "_out = static_cast<struct miqt_array*>(malloc(sizeof(struct miqt_array)));\n"
|
afterCall += indent + "struct miqt_array* " + namePrefix + "_out = static_cast<struct miqt_array*>(malloc(sizeof(struct miqt_array)));\n"
|
||||||
afterCall += indent + "" + namePrefix + "_out->len = " + namePrefix + "_ret.length();\n"
|
afterCall += indent + "" + namePrefix + "_out->len = " + namePrefix + "_ret.size();\n"
|
||||||
afterCall += indent + "" + namePrefix + "_out->data = static_cast<void*>(" + namePrefix + "_arr);\n"
|
afterCall += indent + "" + namePrefix + "_out->data = static_cast<void*>(" + namePrefix + "_arr);\n"
|
||||||
|
|
||||||
afterCall += indent + assignExpression + "" + namePrefix + "_out;\n"
|
afterCall += indent + assignExpression + "" + namePrefix + "_out;\n"
|
||||||
|
@ -129,13 +129,14 @@ bool QStateMachine_CancelDelayedEvent(QStateMachine* self, int id) {
|
|||||||
struct miqt_array* QStateMachine_Configuration(const QStateMachine* self) {
|
struct miqt_array* QStateMachine_Configuration(const QStateMachine* self) {
|
||||||
QSet<QAbstractState *> _ret = self->configuration();
|
QSet<QAbstractState *> _ret = self->configuration();
|
||||||
// Convert QList<> from C++ memory to manually-managed C memory
|
// Convert QList<> from C++ memory to manually-managed C memory
|
||||||
QAbstractState** _arr = static_cast<QAbstractState**>(malloc(sizeof(QAbstractState*) * _ret.length()));
|
QAbstractState** _arr = static_cast<QAbstractState**>(malloc(sizeof(QAbstractState*) * _ret.size()));
|
||||||
int _ctr = 0;
|
int _ctr = 0;
|
||||||
for (const auto _elem& : self->configuration() ) {
|
QSetIterator<QAbstractState*> _itr(_ret);
|
||||||
_arr[_ctr++] = _elem;
|
while (_itr.hasNext()) {
|
||||||
|
_arr[_ctr++] = _itr.next();
|
||||||
}
|
}
|
||||||
struct miqt_array* _out = static_cast<struct miqt_array*>(malloc(sizeof(struct miqt_array)));
|
struct miqt_array* _out = static_cast<struct miqt_array*>(malloc(sizeof(struct miqt_array)));
|
||||||
_out->len = _ret.length();
|
_out->len = _ret.size();
|
||||||
_out->data = static_cast<void*>(_arr);
|
_out->data = static_cast<void*>(_arr);
|
||||||
return _out;
|
return _out;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user