mirror of
https://github.com/status-im/dotherside.git
synced 2025-02-12 04:26:43 +00:00
Cleanedup the DOtherSide.h C interface from C++ references types
This commit is contained in:
parent
95aeef5db0
commit
634cc3ea39
@ -8,15 +8,16 @@
|
||||
#include <QtQml/QQmlApplicationEngine>
|
||||
#include <QtQuick/QQuickView>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <iostream>
|
||||
|
||||
#include "DynamicQObject.h"
|
||||
#include "BaseQAbstractListModel.h"
|
||||
|
||||
void convert_to_cstring(const QString& source, CharPtr& destination, int& length)
|
||||
void convert_to_cstring(const QString& source, char** destination, int* length)
|
||||
{
|
||||
QByteArray array = source.toUtf8();
|
||||
destination = qstrdup(array.data());
|
||||
length = qstrlen(array.data());
|
||||
*destination = qstrdup(array.data());
|
||||
*length = qstrlen(array.data());
|
||||
}
|
||||
|
||||
void dos_qguiapplication_create()
|
||||
@ -106,7 +107,7 @@ void dos_qquickview_delete(void* vptr)
|
||||
delete view;
|
||||
}
|
||||
|
||||
void dos_qquickview_source(void *vptr, CharPtr& result, int& length)
|
||||
void dos_qquickview_source(void *vptr, char** result, int* length)
|
||||
{
|
||||
QQuickView* view = reinterpret_cast<QQuickView*>(vptr);
|
||||
QUrl url = view->source();
|
||||
@ -125,25 +126,25 @@ void dos_qquickview_rootContext(void* vptr, void** context)
|
||||
*context = view->rootContext();
|
||||
}
|
||||
|
||||
void dos_chararray_create(CharPtr& ptr)
|
||||
void dos_chararray_create(char** ptr)
|
||||
{
|
||||
ptr = 0;
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
void dos_chararray_create(CharPtr& ptr, int size)
|
||||
void dos_chararray_create(char** ptr, int size)
|
||||
{
|
||||
if (size > 0)
|
||||
ptr = new char[size];
|
||||
*ptr = new char[size];
|
||||
else
|
||||
ptr = 0;
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
void dos_chararray_delete(CharPtr ptr)
|
||||
void dos_chararray_delete(char* ptr)
|
||||
{
|
||||
if (ptr) delete[] ptr;
|
||||
}
|
||||
|
||||
void dos_qqmlcontext_baseUrl(void* vptr, CharPtr& result, int& length)
|
||||
void dos_qqmlcontext_baseUrl(void* vptr, char** result, int* length)
|
||||
{
|
||||
QQmlContext* context = reinterpret_cast<QQmlContext*>(vptr);
|
||||
QUrl url = context->baseUrl();
|
||||
@ -179,10 +180,10 @@ void dos_qvariant_create_string(void** vptr, const char* value)
|
||||
|
||||
void dos_qvariant_create_qvariant(void** vptr, void* other)
|
||||
{
|
||||
auto newQVariant = new QVariant();
|
||||
auto otherQVariant = reinterpret_cast<QVariant*>(other);
|
||||
*newQVariant = *otherQVariant;
|
||||
*vptr = newQVariant;
|
||||
auto newQVariant = new QVariant();
|
||||
auto otherQVariant = reinterpret_cast<QVariant*>(other);
|
||||
*newQVariant = *otherQVariant;
|
||||
*vptr = newQVariant;
|
||||
}
|
||||
|
||||
void dos_qvariant_create_qobject(void **vptr, void* value)
|
||||
@ -211,10 +212,10 @@ void dos_qvariant_create_qabstractlistmodel(void** vptr, void* value)
|
||||
*vptr = variant;
|
||||
}
|
||||
|
||||
void dos_qvariant_isnull(void* vptr, bool& isNull)
|
||||
void dos_qvariant_isnull(void* vptr, bool* isNull)
|
||||
{
|
||||
auto variant = reinterpret_cast<QVariant*>(vptr);
|
||||
isNull = variant->isNull();
|
||||
*isNull = variant->isNull();
|
||||
}
|
||||
|
||||
void dos_qvariant_delete(void *vptr)
|
||||
@ -225,36 +226,36 @@ void dos_qvariant_delete(void *vptr)
|
||||
|
||||
void dos_qvariant_assign(void* vptr, void* other)
|
||||
{
|
||||
auto leftQVariant = reinterpret_cast<QVariant*>(vptr);
|
||||
auto rightQVariant = reinterpret_cast<QVariant*>(other);
|
||||
*leftQVariant = *rightQVariant;
|
||||
auto leftQVariant = reinterpret_cast<QVariant*>(vptr);
|
||||
auto rightQVariant = reinterpret_cast<QVariant*>(other);
|
||||
*leftQVariant = *rightQVariant;
|
||||
}
|
||||
|
||||
void dos_qvariant_toInt(void* vptr, int& value)
|
||||
void dos_qvariant_toInt(void* vptr, int* value)
|
||||
{
|
||||
auto variant = reinterpret_cast<QVariant*>(vptr);
|
||||
value = variant->toInt();
|
||||
*value = variant->toInt();
|
||||
}
|
||||
|
||||
void dos_qvariant_toBool(void* vptr, bool& value)
|
||||
void dos_qvariant_toBool(void* vptr, bool* value)
|
||||
{
|
||||
auto variant = reinterpret_cast<QVariant*>(vptr);
|
||||
value = variant->toBool();
|
||||
*value = variant->toBool();
|
||||
}
|
||||
|
||||
void dos_qvariant_toFloat(void* vptr, float& value)
|
||||
void dos_qvariant_toFloat(void* vptr, float* value)
|
||||
{
|
||||
auto variant = reinterpret_cast<QVariant*>(vptr);
|
||||
value = variant->toFloat();
|
||||
auto variant = reinterpret_cast<QVariant*>(vptr);
|
||||
*value = variant->toFloat();
|
||||
}
|
||||
|
||||
void dos_qvariant_toDouble(void* vptr, double& value)
|
||||
void dos_qvariant_toDouble(void* vptr, double* value)
|
||||
{
|
||||
auto variant = reinterpret_cast<QVariant*>(vptr);
|
||||
value = variant->toDouble();
|
||||
auto variant = reinterpret_cast<QVariant*>(vptr);
|
||||
*value = variant->toDouble();
|
||||
}
|
||||
|
||||
void dos_qvariant_toString(void* vptr, CharPtr& ptr, int& size)
|
||||
void dos_qvariant_toString(void* vptr, char** ptr, int* size)
|
||||
{
|
||||
auto variant = reinterpret_cast<QVariant*>(vptr);
|
||||
convert_to_cstring(variant->toString(), ptr, size);
|
||||
@ -292,9 +293,9 @@ void dos_qvariant_setString(void* vptr, const char* value)
|
||||
|
||||
void dos_qvariant_setQObject(void* vptr, void* value)
|
||||
{
|
||||
auto variant = reinterpret_cast<QVariant*>(vptr);
|
||||
auto qobject = reinterpret_cast<QObject*>(value);
|
||||
variant->setValue<QObject*>(qobject);
|
||||
auto variant = reinterpret_cast<QVariant*>(vptr);
|
||||
auto qobject = reinterpret_cast<QObject*>(value);
|
||||
variant->setValue<QObject*>(qobject);
|
||||
}
|
||||
|
||||
void dos_qvariant_setQAbstractListModel(void* vptr, void* value)
|
||||
@ -376,60 +377,60 @@ void dos_qobject_property_create(void* vptr,
|
||||
|
||||
void dos_qmodelindex_create(void** vptr)
|
||||
{
|
||||
auto index = new QModelIndex();
|
||||
*vptr = index;
|
||||
auto index = new QModelIndex();
|
||||
*vptr = index;
|
||||
}
|
||||
|
||||
void dos_qmodelindex_delete(void* vptr)
|
||||
{
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
delete index;
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
delete index;
|
||||
}
|
||||
|
||||
void dos_qmodelindex_row(void* vptr, int& row)
|
||||
void dos_qmodelindex_row(void* vptr, int* row)
|
||||
{
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
row = index->row();
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
*row = index->row();
|
||||
}
|
||||
|
||||
void dos_qmodelindex_column(void* vptr, int& column)
|
||||
void dos_qmodelindex_column(void* vptr, int* column)
|
||||
{
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
column = index->column();
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
*column = index->column();
|
||||
}
|
||||
|
||||
void dos_qmodelindex_isValid(void* vptr, bool& isValid)
|
||||
void dos_qmodelindex_isValid(void* vptr, bool* isValid)
|
||||
{
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
isValid = index->isValid();
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
*isValid = index->isValid();
|
||||
}
|
||||
|
||||
void dos_qmodelindex_data(void* vptr, int role, void* data)
|
||||
{
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
auto result = reinterpret_cast<QVariant*>(data);
|
||||
*result = index->data(role);
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
auto result = reinterpret_cast<QVariant*>(data);
|
||||
*result = index->data(role);
|
||||
}
|
||||
|
||||
void dos_qmodelindex_parent(void* vptr, void* parent)
|
||||
{
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
auto parentIndex = reinterpret_cast<QModelIndex*>(parent);
|
||||
*parentIndex = index->parent();
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
auto parentIndex = reinterpret_cast<QModelIndex*>(parent);
|
||||
*parentIndex = index->parent();
|
||||
}
|
||||
|
||||
void dos_qmodelindex_child(void* vptr, int row, int column, void* child)
|
||||
{
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
auto childIndex = reinterpret_cast<QModelIndex*>(child);
|
||||
*childIndex = index->child(row, column);
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
auto childIndex = reinterpret_cast<QModelIndex*>(child);
|
||||
*childIndex = index->child(row, column);
|
||||
}
|
||||
|
||||
void dos_qmodelindex_sibling(void* vptr, int row, int column, void* sibling)
|
||||
{
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
auto siblingIndex = reinterpret_cast<QModelIndex*>(sibling);
|
||||
*siblingIndex = index->sibling(row, column);
|
||||
auto index = reinterpret_cast<QModelIndex*>(vptr);
|
||||
auto siblingIndex = reinterpret_cast<QModelIndex*>(sibling);
|
||||
*siblingIndex = index->sibling(row, column);
|
||||
}
|
||||
|
||||
void dos_qabstractlistmodel_create(void** vptr,
|
||||
@ -437,14 +438,14 @@ void dos_qabstractlistmodel_create(void** vptr,
|
||||
RowCountCallback rowCountCallback,
|
||||
DataCallback dataCallback)
|
||||
{
|
||||
auto model = new BaseQAbstractListModel(modelObject, rowCountCallback, dataCallback);
|
||||
*vptr = model;
|
||||
auto model = new BaseQAbstractListModel(modelObject, rowCountCallback, dataCallback);
|
||||
*vptr = model;
|
||||
}
|
||||
|
||||
void dos_qabstractlistmodel_delete(void* vptr)
|
||||
{
|
||||
auto model = reinterpret_cast<BaseQAbstractListModel*>(vptr);
|
||||
delete model;
|
||||
auto model = reinterpret_cast<BaseQAbstractListModel*>(vptr);
|
||||
delete model;
|
||||
}
|
||||
|
||||
void dos_qhash_int_qbytearray_create(QHashIntQByteArrayVoidPtr* vptr)
|
||||
@ -458,9 +459,16 @@ void dos_qhash_int_qbytearray_delete(QHashIntQByteArrayVoidPtr vptr)
|
||||
delete qHash;
|
||||
}
|
||||
|
||||
void dos_qhash_int_qbytearray_insert(QHashIntQByteArrayVoidPtr vptr, int key, ConstCharPtr value)
|
||||
void dos_qhash_int_qbytearray_insert(QHashIntQByteArrayVoidPtr vptr, int key, const char* value)
|
||||
{
|
||||
auto qHash = reinterpret_cast<QHash<int, QByteArray>*>(vptr);
|
||||
qHash->insert(key, QByteArray(value));
|
||||
}
|
||||
|
||||
void dos_qhash_int_qbytearray_value(QHashIntQByteArrayVoidPtr vptr, int key, char** result)
|
||||
{
|
||||
auto qHash = reinterpret_cast<QHash<int, QByteArray>*>(vptr);
|
||||
QByteArray value = qHash->value(key);
|
||||
*result = qstrdup(value.data());
|
||||
}
|
||||
|
||||
|
@ -8,122 +8,123 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef char* CharPtr;
|
||||
typedef void(*Function)(void*);
|
||||
typedef void(*DObjectCallback)(void*, void*, int, void**);
|
||||
typedef char* CharPtr;
|
||||
typedef void(*Function)(void*);
|
||||
typedef void(*DObjectCallback)(void*, void*, int, void**);
|
||||
|
||||
// QGuiApplication
|
||||
void dos_qguiapplication_create();
|
||||
void dos_qguiapplication_exec();
|
||||
void dos_qguiapplication_quit();
|
||||
void dos_qguiapplication_delete();
|
||||
// QGuiApplication
|
||||
void dos_qguiapplication_create();
|
||||
void dos_qguiapplication_exec();
|
||||
void dos_qguiapplication_quit();
|
||||
void dos_qguiapplication_delete();
|
||||
|
||||
// QApplication
|
||||
void dos_qapplication_create();
|
||||
void dos_qapplication_exec();
|
||||
void dos_qapplication_quit();
|
||||
void dos_qapplication_delete();
|
||||
|
||||
// QQmlApplicationEngine
|
||||
void dos_qqmlapplicationengine_create(void** vptr);
|
||||
void dos_qqmlapplicationengine_load(void* vptr, const char* filename);
|
||||
void dos_qqmlapplicationengine_context(void* vptr, void** context);
|
||||
void dos_qqmlapplicationengine_delete(void* vptr);
|
||||
// QApplication
|
||||
void dos_qapplication_create();
|
||||
void dos_qapplication_exec();
|
||||
void dos_qapplication_quit();
|
||||
void dos_qapplication_delete();
|
||||
|
||||
// QQuickView
|
||||
void dos_qquickview_create(void** vptr);
|
||||
void dos_qquickview_show(void* vptr);
|
||||
void dos_qquickview_source(void* vptr, CharPtr& result, int& length);
|
||||
void dos_qquickview_set_source(void* vptr, const char* filename);
|
||||
void dos_qquickview_delete(void* vptr);
|
||||
void dos_qquickview_rootContext(void* vptr, void** context);
|
||||
// QQmlApplicationEngine
|
||||
void dos_qqmlapplicationengine_create(void** vptr);
|
||||
void dos_qqmlapplicationengine_load(void* vptr, const char* filename);
|
||||
void dos_qqmlapplicationengine_context(void* vptr, void** context);
|
||||
void dos_qqmlapplicationengine_delete(void* vptr);
|
||||
|
||||
// QQmlContext
|
||||
void dos_qqmlcontext_baseUrl(void* vptr, CharPtr& result, int& length);
|
||||
void dos_qqmlcontext_setcontextproperty(void* vptr, const char* name, void* value);
|
||||
// QQuickView
|
||||
void dos_qquickview_create(void** vptr);
|
||||
void dos_qquickview_show(void* vptr);
|
||||
void dos_qquickview_source(void* vptr, char** result, int* length);
|
||||
void dos_qquickview_set_source(void* vptr, const char* filename);
|
||||
void dos_qquickview_delete(void* vptr);
|
||||
void dos_qquickview_rootContext(void* vptr, void** context);
|
||||
|
||||
// CharArray
|
||||
void dos_chararray_create(CharPtr& ptr, int size);
|
||||
void dos_chararray_delete(CharPtr ptr);
|
||||
// QQmlContext
|
||||
void dos_qqmlcontext_baseUrl(void* vptr, char** result, int* length);
|
||||
void dos_qqmlcontext_setcontextproperty(void* vptr, const char* name, void* value);
|
||||
|
||||
// QVariant
|
||||
void dos_qvariant_create(void **vptr);
|
||||
void dos_qvariant_create_int(void **vptr, int value);
|
||||
void dos_qvariant_create_bool(void **vptr, bool value);
|
||||
void dos_qvariant_create_string(void **vptr, const char* value);
|
||||
void dos_qvariant_create_qobject(void **vptr, void* value);
|
||||
void dos_qvariant_create_qvariant(void **vptr, void* value);
|
||||
void dos_qvariant_create_float(void **vptr, float value);
|
||||
void dos_qvariant_create_double(void **vptr, double value);
|
||||
void dos_qvariant_create_qabstractlistmodel(void **vptr, void* value);
|
||||
void dos_qvariant_toInt(void* vptr, int& value);
|
||||
void dos_qvariant_setInt(void* vptr, int value);
|
||||
void dos_qvariant_toBool(void* vptr, bool& value);
|
||||
void dos_qvariant_setBool(void* vptr, bool value);
|
||||
void dos_qvariant_toFloat(void* vptr, float& value);
|
||||
void dos_qvariant_setFloat(void* vptr, float value);
|
||||
void dos_qvariant_toDouble(void* vptr, double& value);
|
||||
void dos_qvariant_setDouble(void* vptr, double value);
|
||||
void dos_qvariant_toString(void* vptr, CharPtr& ptr, int& size);
|
||||
void dos_qvariant_setString(void* vptr, const char* value);
|
||||
void dos_qvariant_setQObject(void* vptr, void* value);
|
||||
void dos_qvariant_setQAbstractListModel(void* vptr, void* value);
|
||||
void dos_qvariant_isnull(void *vptr, bool& isNull);
|
||||
void dos_qvariant_delete(void *vptr);
|
||||
void dos_qvariant_assign(void* vptr, void* other);
|
||||
// CharArray
|
||||
void dos_chararray_create(char** ptr, int size);
|
||||
void dos_chararray_delete(char* ptr);
|
||||
|
||||
// QObject
|
||||
void dos_qobject_create(void** vptr,
|
||||
void* dObjectPointer,
|
||||
DObjectCallback dObjectCallback);
|
||||
// QVariant
|
||||
void dos_qvariant_create(void **vptr);
|
||||
void dos_qvariant_create_int(void **vptr, int value);
|
||||
void dos_qvariant_create_bool(void **vptr, bool value);
|
||||
void dos_qvariant_create_string(void **vptr, const char* value);
|
||||
void dos_qvariant_create_qobject(void **vptr, void* value);
|
||||
void dos_qvariant_create_qvariant(void **vptr, void* value);
|
||||
void dos_qvariant_create_float(void **vptr, float value);
|
||||
void dos_qvariant_create_double(void **vptr, double value);
|
||||
void dos_qvariant_create_qabstractlistmodel(void **vptr, void* value);
|
||||
void dos_qvariant_toInt(void* vptr, int* value);
|
||||
void dos_qvariant_setInt(void* vptr, int value);
|
||||
void dos_qvariant_toBool(void* vptr, bool* value);
|
||||
void dos_qvariant_setBool(void* vptr, bool value);
|
||||
void dos_qvariant_toFloat(void* vptr, float* value);
|
||||
void dos_qvariant_setFloat(void* vptr, float value);
|
||||
void dos_qvariant_toDouble(void* vptr, double* value);
|
||||
void dos_qvariant_setDouble(void* vptr, double value);
|
||||
void dos_qvariant_toString(void* vptr, char** ptr, int* size);
|
||||
void dos_qvariant_setString(void* vptr, const char* value);
|
||||
void dos_qvariant_setQObject(void* vptr, void* value);
|
||||
void dos_qvariant_setQAbstractListModel(void* vptr, void* value);
|
||||
void dos_qvariant_isnull(void *vptr, bool* isNull);
|
||||
void dos_qvariant_delete(void *vptr);
|
||||
void dos_qvariant_assign(void* vptr, void* other);
|
||||
|
||||
void dos_qobject_slot_create(void* vptr,
|
||||
const char* name,
|
||||
int parametersCount,
|
||||
int* parametersMetaTypes,
|
||||
int* slotIndex);
|
||||
// QObject
|
||||
void dos_qobject_create(void** vptr,
|
||||
void* dObjectPointer,
|
||||
DObjectCallback dObjectCallback);
|
||||
|
||||
void dos_qobject_signal_create(void* vptr,
|
||||
const char* name,
|
||||
int parametersCount,
|
||||
int* parametersMetaTypes,
|
||||
int* signalIndex);
|
||||
void dos_qobject_slot_create(void* vptr,
|
||||
const char* name,
|
||||
int parametersCount,
|
||||
int* parametersMetaTypes,
|
||||
int* slotIndex);
|
||||
|
||||
void dos_qobject_signal_emit(void* vptr,
|
||||
const char* name,
|
||||
int parametersCount,
|
||||
void** parameters);
|
||||
void dos_qobject_signal_create(void* vptr,
|
||||
const char* name,
|
||||
int parametersCount,
|
||||
int* parametersMetaTypes,
|
||||
int* signalIndex);
|
||||
|
||||
void dos_qobject_property_create(void* vptr,
|
||||
const char* name,
|
||||
int propertyMetaType,
|
||||
const char* readSlot,
|
||||
const char* writeSlot,
|
||||
const char* notifySignal);
|
||||
void dos_qobject_delete(void *vptr);
|
||||
void dos_qobject_signal_emit(void* vptr,
|
||||
const char* name,
|
||||
int parametersCount,
|
||||
void** parameters);
|
||||
|
||||
// QModelIndex
|
||||
void dos_qmodelindex_create(void** vptr);
|
||||
void dos_qmodelindex_delete(void* vptr);
|
||||
void dos_qmodelindex_row(void* vptr, int& row);
|
||||
void dos_qmodelindex_column(void* vptr, int& column);
|
||||
void dos_qmodelindex_isValid(void* vptr, bool& isValid);
|
||||
void dos_qmodelindex_data(void* vptr, int role, void* data);
|
||||
void dos_qmodelindex_parent(void* vptr, void* parent);
|
||||
void dos_qmodelindex_child(void* vptr, int row, int column, void* child);
|
||||
void dos_qmodelindex_sibling(void* vptr, int row, int column, void* sibling);
|
||||
|
||||
// QHash<int, QByteArray>
|
||||
void dos_qhash_int_qbytearray_create(QHashIntQByteArrayVoidPtr* vptr);
|
||||
void dos_qhash_int_qbytearray_delete(QHashIntQByteArrayVoidPtr vptr);
|
||||
void dos_qhash_int_qbytearray_insert(QHashIntQByteArrayVoidPtr vptr, int key, ConstCharPtr value);
|
||||
|
||||
// QAbstractListModel
|
||||
void dos_qabstractlistmodel_create(void** vptr,
|
||||
void* callbackObject,
|
||||
RowCountCallback rowCountCallback,
|
||||
DataCallback dataCallback);
|
||||
void dos_qabstractlistmodel_delete(void* vptr);
|
||||
void dos_qobject_property_create(void* vptr,
|
||||
const char* name,
|
||||
int propertyMetaType,
|
||||
const char* readSlot,
|
||||
const char* writeSlot,
|
||||
const char* notifySignal);
|
||||
void dos_qobject_delete(void *vptr);
|
||||
|
||||
// QModelIndex
|
||||
void dos_qmodelindex_create(void** vptr);
|
||||
void dos_qmodelindex_delete(void* vptr);
|
||||
void dos_qmodelindex_row(void* vptr, int* row);
|
||||
void dos_qmodelindex_column(void* vptr, int* column);
|
||||
void dos_qmodelindex_isValid(void* vptr, bool* isValid);
|
||||
void dos_qmodelindex_data(void* vptr, int role, void* data);
|
||||
void dos_qmodelindex_parent(void* vptr, void* parent);
|
||||
void dos_qmodelindex_child(void* vptr, int row, int column, void* child);
|
||||
void dos_qmodelindex_sibling(void* vptr, int row, int column, void* sibling);
|
||||
|
||||
// QHash<int, QByteArray>
|
||||
void dos_qhash_int_qbytearray_create(QHashIntQByteArrayVoidPtr* vptr);
|
||||
void dos_qhash_int_qbytearray_delete(QHashIntQByteArrayVoidPtr vptr);
|
||||
void dos_qhash_int_qbytearray_insert(QHashIntQByteArrayVoidPtr vptr, int key, const char* value);
|
||||
void dos_qhash_int_qbytearray_value(QHashIntQByteArrayVoidPtr vptr, int key, char** result);
|
||||
|
||||
// QAbstractListModel
|
||||
void dos_qabstractlistmodel_create(void** vptr,
|
||||
void* callbackObject,
|
||||
RowCountCallback rowCountCallback,
|
||||
DataCallback dataCallback);
|
||||
void dos_qabstractlistmodel_delete(void* vptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
22
DOtherSide/DOtherSide/DOtherSideTypes.h
Normal file
22
DOtherSide/DOtherSide/DOtherSideTypes.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef DOTHERSIDETYPES_H
|
||||
#define DOTHERSIDETYPES_H
|
||||
|
||||
// Raw data types
|
||||
typedef int* IntPtr;
|
||||
typedef char* CharPtr;
|
||||
typedef const char* ConstCharPtr;
|
||||
typedef void* QVariantVoidPtr;
|
||||
typedef void* QModelIndexVoidPtr;
|
||||
typedef void* QAbstractListModelVoidPtr;
|
||||
typedef void* QQmlApplicationEngineVoidPtr;
|
||||
typedef void* QQuickViewVoidPtr;
|
||||
typedef void* QQmlContextVoidPtr;
|
||||
typedef void* QHashIntQByteArrayVoidPtr;
|
||||
|
||||
// Raw function types
|
||||
typedef void (*Function)(void*);
|
||||
typedef void (*DObjectCallback)(void*, void*, int, void**);
|
||||
typedef void (*RowCountCallback) (void* model, QModelIndexVoidPtr index, IntPtr result);
|
||||
typedef void (*DataCallback) (void* model, QModelIndexVoidPtr index, int role, QVariantVoidPtr result);
|
||||
|
||||
#endif
|
@ -106,6 +106,4 @@ void DynamicSlot::_initSignature()
|
||||
}
|
||||
|
||||
d->signature = signature.arg(d->name, arguments).toUtf8();
|
||||
|
||||
qDebug() << "C++: slot signature is " << d->signature;
|
||||
}
|
||||
|
@ -41,8 +41,16 @@ proc mainProc() =
|
||||
engine.load("main.qml")
|
||||
|
||||
app.exec()
|
||||
|
||||
proc mainProc2() =
|
||||
var qhash = newQHashIntQByteArray()
|
||||
defer: qHash.delete
|
||||
qhash.insert(0,"Name")
|
||||
qhash.insert(1, "Surname")
|
||||
echo qhash.value(0)
|
||||
echo qhash.value(1)
|
||||
|
||||
when isMainModule:
|
||||
mainProc()
|
||||
mainProc2()
|
||||
GC_fullcollect()
|
||||
|
||||
|
@ -26,22 +26,37 @@ type QMetaType* {.pure.} = enum ## \
|
||||
|
||||
var qobjectRegistry = initTable[ptr QObjectObj, bool]()
|
||||
|
||||
proc debugMsg(message: string) =
|
||||
echo "NimQml: ", message
|
||||
template debugMsg(message: string) =
|
||||
{.push warning[user]: off.} # workaround to remove warnings; this won't be needed soon
|
||||
when defined(debug):
|
||||
{.pop.}
|
||||
echo "NimQml: ", message
|
||||
else:
|
||||
{.pop.}
|
||||
|
||||
template debugMsg(typeName: string, procName: string) =
|
||||
{.push warning[user]: off.} # workaround to remove warnings; this won't be needed soon
|
||||
when defined(debug):
|
||||
{.pop.}
|
||||
var message = typeName
|
||||
message &= ": "
|
||||
message &= procName
|
||||
debugMsg(message)
|
||||
else:
|
||||
{.pop.}
|
||||
|
||||
proc debugMsg(typeName: string, procName: string) =
|
||||
var message = typeName
|
||||
message &= ": "
|
||||
message &= procName
|
||||
debugMsg(message)
|
||||
|
||||
proc debugMsg(typeName: string, procName: string, userMessage: string) =
|
||||
var message = typeName
|
||||
message &= ": "
|
||||
message &= procName
|
||||
message &= " "
|
||||
message &= userMessage
|
||||
debugMsg(message)
|
||||
template debugMsg(typeName: string, procName: string, userMessage: string) =
|
||||
{.push warning[user]: off.} # workaround to remove warnings; this won't be needed soon
|
||||
when defined(debug):
|
||||
{.pop.}
|
||||
var message = typeName
|
||||
message &= ": "
|
||||
message &= procName
|
||||
message &= " "
|
||||
message &= userMessage
|
||||
debugMsg(message)
|
||||
else:
|
||||
{.pop.}
|
||||
|
||||
template newWithCondFinalizer(variable: expr, finalizer: expr) =
|
||||
## calls ``new`` but only setting a finalizer when ``nimqml_use_finalizers``
|
||||
@ -632,22 +647,30 @@ proc newQAbstractListModel*(): QAbstractListModel =
|
||||
result.create()
|
||||
|
||||
# RoleNames QHash
|
||||
proc dos_qhash_int_qbytearray_create(qHash: RawQHashIntByteArray) {.cdecl, dynlib:"libDOtherSide.so", importc.}
|
||||
proc dos_qhash_int_qbytearray_create(qHash: var RawQHashIntByteArray) {.cdecl, dynlib:"libDOtherSide.so", importc.}
|
||||
proc dos_qhash_int_qbytearray_delete(qHash: RawQHashIntByteArray) {.cdecl, dynlib:"libDOtherSide.so", importc.}
|
||||
proc dos_qhash_int_qbytearray_insert(qHash: RawQHashIntByteArray, key: int, value: cstring) {.cdecl, dynlib:"libDOtherSide.so", importc.}
|
||||
proc dos_qhash_int_qbytearray_value(qHash: RawQHashIntByteArray, key: int, value: var cstring) {.cdecl, dynlib:"libDOtherSide.so", importc.}
|
||||
|
||||
proc create(qHash: var QHashIntByteArray) =
|
||||
proc create*(qHash: var QHashIntByteArray) =
|
||||
debugMsg("QHashIntByteArray", "create")
|
||||
dos_qhash_int_qbytearray_create(qHash.data)
|
||||
qHash.deleted = false
|
||||
|
||||
proc delete(qHash: QHashIntByteArray) =
|
||||
proc delete*(qHash: QHashIntByteArray) =
|
||||
debugMsg("QHashIntByteArray", "delete")
|
||||
dos_qhash_int_qbytearray_delete(qHash.data)
|
||||
qHash.deleted = true
|
||||
|
||||
proc insert(qHash: QHashIntByteArray, key: int, value: cstring) =
|
||||
proc insert*(qHash: QHashIntByteArray, key: int, value: cstring) =
|
||||
dos_qhash_int_qbytearray_insert(qHash.data, key, value)
|
||||
|
||||
proc newQHashIntQByteArray(): QHashIntByteArray =
|
||||
proc value*(qHash: QHashIntByteArray, key: int): string =
|
||||
var rawString: cstring
|
||||
dos_qhash_int_qbytearray_value(qHash.data, key, rawString)
|
||||
result = $rawString
|
||||
dos_chararray_delete(rawString)
|
||||
|
||||
proc newQHashIntQByteArray*(): QHashIntByteArray =
|
||||
newWithCondFinalizer(result, delete)
|
||||
result.create()
|
||||
|
@ -48,4 +48,4 @@ type
|
||||
QHashIntByteArrayObj = object of RootObj
|
||||
data: RawQHashIntByteArray
|
||||
deleted: bool
|
||||
QHashIntByteArray = ref QHashIntByteArrayObj ## A QHash<int,QByteArray>
|
||||
QHashIntByteArray* = ref QHashIntByteArrayObj ## A QHash<int,QByteArray>
|
||||
|
Loading…
x
Reference in New Issue
Block a user