mirror of
https://github.com/mappu/miqt.git
synced 2024-12-23 01:18:37 +00:00
127 lines
4.0 KiB
C++
127 lines
4.0 KiB
C++
#include <QMap>
|
|
#include <QMetaObject>
|
|
#include <QObject>
|
|
#include <QQmlWebChannel>
|
|
#include <QString>
|
|
#include <QByteArray>
|
|
#include <cstring>
|
|
#include <QVariant>
|
|
#include <QWebChannel>
|
|
#include <qqmlwebchannel.h>
|
|
#include "gen_qqmlwebchannel.h"
|
|
#include "_cgo_export.h"
|
|
|
|
QQmlWebChannel* QQmlWebChannel_new() {
|
|
return new QQmlWebChannel();
|
|
}
|
|
|
|
QQmlWebChannel* QQmlWebChannel_new2(QObject* parent) {
|
|
return new QQmlWebChannel(parent);
|
|
}
|
|
|
|
void QQmlWebChannel_virtbase(QQmlWebChannel* src, QWebChannel** outptr_QWebChannel) {
|
|
*outptr_QWebChannel = static_cast<QWebChannel*>(src);
|
|
}
|
|
|
|
QMetaObject* QQmlWebChannel_MetaObject(const QQmlWebChannel* self) {
|
|
return (QMetaObject*) self->metaObject();
|
|
}
|
|
|
|
void* QQmlWebChannel_Metacast(QQmlWebChannel* self, const char* param1) {
|
|
return self->qt_metacast(param1);
|
|
}
|
|
|
|
struct miqt_string QQmlWebChannel_Tr(const char* s) {
|
|
QString _ret = QQmlWebChannel::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 QQmlWebChannel_TrUtf8(const char* s) {
|
|
QString _ret = QQmlWebChannel::trUtf8(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;
|
|
}
|
|
|
|
void QQmlWebChannel_RegisterObjects(QQmlWebChannel* self, struct miqt_map /* of struct miqt_string to QVariant* */ objects) {
|
|
QVariantMap objects_QMap;
|
|
struct miqt_string* objects_karr = static_cast<struct miqt_string*>(objects.keys);
|
|
QVariant** objects_varr = static_cast<QVariant**>(objects.values);
|
|
for(size_t i = 0; i < objects.len; ++i) {
|
|
QString objects_karr_i_QString = QString::fromUtf8(objects_karr[i].data, objects_karr[i].len);
|
|
objects_QMap[objects_karr_i_QString] = *(objects_varr[i]);
|
|
}
|
|
self->registerObjects(objects_QMap);
|
|
}
|
|
|
|
void QQmlWebChannel_ConnectTo(QQmlWebChannel* self, QObject* transport) {
|
|
self->connectTo(transport);
|
|
}
|
|
|
|
void QQmlWebChannel_DisconnectFrom(QQmlWebChannel* self, QObject* transport) {
|
|
self->disconnectFrom(transport);
|
|
}
|
|
|
|
struct miqt_string QQmlWebChannel_Tr2(const char* s, const char* c) {
|
|
QString _ret = QQmlWebChannel::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 QQmlWebChannel_Tr3(const char* s, const char* c, int n) {
|
|
QString _ret = QQmlWebChannel::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;
|
|
}
|
|
|
|
struct miqt_string QQmlWebChannel_TrUtf82(const char* s, const char* c) {
|
|
QString _ret = QQmlWebChannel::trUtf8(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 QQmlWebChannel_TrUtf83(const char* s, const char* c, int n) {
|
|
QString _ret = QQmlWebChannel::trUtf8(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 QQmlWebChannel_Delete(QQmlWebChannel* self, bool isSubclass) {
|
|
if (isSubclass) {
|
|
delete dynamic_cast<QQmlWebChannel*>( self );
|
|
} else {
|
|
delete self;
|
|
}
|
|
}
|
|
|