miqt/qt6/gen_qfactoryinterface.cpp

42 lines
1.2 KiB
C++
Raw Permalink Normal View History

2024-10-20 05:21:03 +00:00
#include <QFactoryInterface>
#include <QList>
#include <QString>
#include <QByteArray>
#include <cstring>
#include <qfactoryinterface.h>
#include "gen_qfactoryinterface.h"
#ifndef _Bool
#define _Bool bool
#endif
2024-10-20 05:21:03 +00:00
#include "_cgo_export.h"
struct miqt_array /* of struct miqt_string */ QFactoryInterface_Keys(const QFactoryInterface* self) {
2024-10-20 05:21:03 +00:00
QStringList _ret = self->keys();
// Convert QList<> from C++ memory to manually-managed C memory
struct miqt_string* _arr = static_cast<struct miqt_string*>(malloc(sizeof(struct miqt_string) * _ret.length()));
for (size_t i = 0, e = _ret.length(); i < e; ++i) {
QString _lv_ret = _ret[i];
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray _lv_b = _lv_ret.toUtf8();
struct miqt_string _lv_ms;
_lv_ms.len = _lv_b.length();
_lv_ms.data = static_cast<char*>(malloc(_lv_ms.len));
memcpy(_lv_ms.data, _lv_b.data(), _lv_ms.len);
_arr[i] = _lv_ms;
}
struct miqt_array _out;
_out.len = _ret.length();
_out.data = static_cast<void*>(_arr);
2024-10-20 05:21:03 +00:00
return _out;
}
2024-11-19 06:29:06 +00:00
void QFactoryInterface_Delete(QFactoryInterface* self, bool isSubclass) {
if (isSubclass) {
delete dynamic_cast<QFactoryInterface*>( self );
} else {
delete self;
}
2024-10-20 05:21:03 +00:00
}