miqt/qt6/gen_qfileselector.cpp
2024-10-21 19:10:31 +13:00

133 lines
4.6 KiB
C++

#include <QFileSelector>
#include <QList>
#include <QMetaObject>
#include <QObject>
#include <QString>
#include <QByteArray>
#include <cstring>
#include <QUrl>
#include <qfileselector.h>
#include "gen_qfileselector.h"
#include "_cgo_export.h"
QFileSelector* QFileSelector_new() {
return new QFileSelector();
}
QFileSelector* QFileSelector_new2(QObject* parent) {
return new QFileSelector(parent);
}
QMetaObject* QFileSelector_MetaObject(const QFileSelector* self) {
return (QMetaObject*) self->metaObject();
}
void* QFileSelector_Metacast(QFileSelector* self, const char* param1) {
return self->qt_metacast(param1);
}
struct miqt_string QFileSelector_Tr(const char* s) {
QString _ret = QFileSelector::tr(s);
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray _b = _ret.toUtf8();
struct miqt_string _ms;
_ms.len = _b.length();
_ms.data = static_cast<char*>(malloc(_ms.len));
memcpy(_ms.data, _b.data(), _ms.len);
return _ms;
}
struct miqt_string QFileSelector_Select(const QFileSelector* self, struct miqt_string filePath) {
QString filePath_QString = QString::fromUtf8(filePath.data, filePath.len);
QString _ret = self->select(filePath_QString);
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray _b = _ret.toUtf8();
struct miqt_string _ms;
_ms.len = _b.length();
_ms.data = static_cast<char*>(malloc(_ms.len));
memcpy(_ms.data, _b.data(), _ms.len);
return _ms;
}
QUrl* QFileSelector_SelectWithFilePath(const QFileSelector* self, QUrl* filePath) {
return new QUrl(self->select(*filePath));
}
struct miqt_array* QFileSelector_ExtraSelectors(const QFileSelector* self) {
QStringList _ret = self->extraSelectors();
// 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 = static_cast<struct miqt_array*>(malloc(sizeof(struct miqt_array)));
_out->len = _ret.length();
_out->data = static_cast<void*>(_arr);
return _out;
}
void QFileSelector_SetExtraSelectors(QFileSelector* self, struct miqt_array* /* of struct miqt_string */ list) {
QStringList list_QList;
list_QList.reserve(list->len);
struct miqt_string* list_arr = static_cast<struct miqt_string*>(list->data);
for(size_t i = 0; i < list->len; ++i) {
QString list_arr_i_QString = QString::fromUtf8(list_arr[i].data, list_arr[i].len);
list_QList.push_back(list_arr_i_QString);
}
self->setExtraSelectors(list_QList);
}
struct miqt_array* QFileSelector_AllSelectors(const QFileSelector* self) {
QStringList _ret = self->allSelectors();
// 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 = static_cast<struct miqt_array*>(malloc(sizeof(struct miqt_array)));
_out->len = _ret.length();
_out->data = static_cast<void*>(_arr);
return _out;
}
struct miqt_string QFileSelector_Tr2(const char* s, const char* c) {
QString _ret = QFileSelector::tr(s, c);
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray _b = _ret.toUtf8();
struct miqt_string _ms;
_ms.len = _b.length();
_ms.data = static_cast<char*>(malloc(_ms.len));
memcpy(_ms.data, _b.data(), _ms.len);
return _ms;
}
struct miqt_string QFileSelector_Tr3(const char* s, const char* c, int n) {
QString _ret = QFileSelector::tr(s, c, static_cast<int>(n));
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray _b = _ret.toUtf8();
struct miqt_string _ms;
_ms.len = _b.length();
_ms.data = static_cast<char*>(malloc(_ms.len));
memcpy(_ms.data, _b.data(), _ms.len);
return _ms;
}
void QFileSelector_Delete(QFileSelector* self) {
delete self;
}