Mon May 11 13:21:14 CEST 2009 Tobias Rautenkranz * QList translations C wrapper diff -rN -u old-qt.core/src/lib/CMakeLists.txt new-qt.core/src/lib/CMakeLists.txt --- old-qt.core/src/lib/CMakeLists.txt 2014-11-16 03:13:40.000000000 +0100 +++ new-qt.core/src/lib/CMakeLists.txt 2014-11-16 03:13:40.000000000 +0100 @@ -2,6 +2,6 @@ set(QT_DONT_USE_QTGUI true) include(${QT_USE_FILE}) -set(QT_SMOKE_SOURCES qt-smoke.cpp qstring.cpp qstringlist.cpp lisp-object.cpp) +set(QT_SMOKE_SOURCES qt-smoke.cpp qstring.cpp qstringlist.cpp lisp-object.cpp qlist.cpp) add_library(qt-smoke-extra MODULE ${QT_SMOKE_SOURCES}) target_link_libraries(qt-smoke-extra ${QT_LIBRARIES}) diff -rN -u old-qt.core/src/lib/qlist.cpp new-qt.core/src/lib/qlist.cpp --- old-qt.core/src/lib/qlist.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new-qt.core/src/lib/qlist.cpp 2014-11-16 03:13:40.000000000 +0100 @@ -0,0 +1,15 @@ +#include "qlist.h" + +/** @file + * @brief QList conversions. */ + +#include +#include + +extern "C" { + +DEFINE_QLIST_WRAPPER(QVariant) +DEFINE_QLIST_WRAPPER_PTR(void) +DEFINE_QLIST_WRAPPER(QByteArray) + +} // extern "C" diff -rN -u old-qt.core/src/lib/qlist.h new-qt.core/src/lib/qlist.h --- old-qt.core/src/lib/qlist.h 1970-01-01 01:00:00.000000000 +0100 +++ new-qt.core/src/lib/qlist.h 2014-11-16 03:13:40.000000000 +0100 @@ -0,0 +1,88 @@ +#ifndef CL_SMOKE_QT_QLIST_H +#define CL_SMOKE_QT_QLIST_H + +#include + +/** @file + */ + +/** Defines a C wrapper for the QList<@a TYPE>. + * @param TYPE the type of the elements of the QList + */ +#define DEFINE_QLIST_WRAPPER(TYPE) \ + DEFINE_QLIST_WRAPPER_3(TYPE, TYPE, VALUE) + +/** Defines a C wrapper for the QList<@a TYPE*>, + * where @a TYPE is the of the pointer. + * + * @param NAME the name used for the wrapper functions. + * @param TYPE the type of the elements + */ +#define DEFINE_QLIST_WRAPPER_PTR(TYPE) \ + DEFINE_QLIST_WRAPPER_3(TYPE, TYPE*, PTR) + +/** @internal */ +#define DEFINE_QLIST_WRAPPER_3(NAME, TYPE, PTR_VALUE) \ + DEFINE_QLIST_WRAPPER_ALL_PART(NAME, TYPE) \ + DEFINE_QLIST_WRAPPER_ ## PTR_VALUE ## _PART(NAME, TYPE) \ + + +/** @internal + * size, free and make_list. */ +#define DEFINE_QLIST_WRAPPER_ALL_PART(NAME, TYPE) \ +int \ +qt_smoke_list_ ## NAME ## size(const void* list) \ +{ \ + return static_cast*>(list)->size(); \ +} \ +\ +void \ +qt_smoke_free_list_ ## NAME (void* list) \ +{ \ + delete static_cast*>(list); \ +} \ + \ +void* \ +qt_smoke_make_list_ ## NAME () \ +{ \ + return new QList< TYPE >(); \ +} \ + \ + +/** @internal + * At and append for pointer types + */ +#define DEFINE_QLIST_WRAPPER_PTR_PART(NAME, TYPE) \ +const void* \ +qt_smoke_list_ ## NAME ## _at(const void* list, int index) \ +{ \ + const QList< TYPE >* qlist = static_cast *>(list); \ + return qlist->at(index); \ +} \ +\ +void \ +qt_smoke_list_ ## NAME ## _append(void* list, void* data, int length) \ +{ \ + static_cast*>(list) \ + ->append(static_cast(data)); \ +} \ + +/** @internal + * At and append for value types. + */ +#define DEFINE_QLIST_WRAPPER_VALUE_PART(NAME, TYPE) \ +const void* \ +qt_smoke_list_ ## NAME ## _at(const void* list, int index) \ +{ \ + const QList< TYPE >* qlist = static_cast *>(list); \ + return &qlist->at(index); \ +} \ +\ +void \ +qt_smoke_list_ ## NAME ## _append(void* list, void* data, int length) \ +{ \ + static_cast*>(list) \ + ->append(*static_cast(data)); \ +} \ + +#endif // CL_SMOKE_QT_QLIST_H