1 #ifndef CL_SMOKE_QT_QLIST_H
2 #define CL_SMOKE_QT_QLIST_H
4 #include "cl_smoke_qt.h"
11 /** Defines a C wrapper for the QList<@a TYPE>.
12 * @param TYPE the type of the elements of the QList
14 #define DEFINE_QLIST_WRAPPER(TYPE) \
15 DEFINE_QLIST_WRAPPER_3(TYPE, TYPE, VALUE)
17 /** Defines a C wrapper for the QList<@a TYPE*>,
18 * where @a TYPE is the of the pointer.
20 * @param NAME the name used for the wrapper functions.
21 * @param TYPE the type of the elements
23 #define DEFINE_QLIST_WRAPPER_PTR(TYPE) \
24 DEFINE_QLIST_WRAPPER_3(TYPE, TYPE*, PTR)
27 #define DEFINE_QLIST_WRAPPER_3(NAME, TYPE, PTR_VALUE) \
28 DEFINE_QLIST_WRAPPER_ALL_PART(NAME, TYPE) \
29 DEFINE_QLIST_WRAPPER_ ## PTR_VALUE ## _PART(NAME, TYPE) \
33 * size, free and make_list. */
34 #define DEFINE_QLIST_WRAPPER_ALL_PART(NAME, TYPE) \
35 CL_SMOKE_QT_EXPORT void \
36 cl_smoke_free_list_ ## NAME (void* list) \
38 delete static_cast<QList< TYPE >*>(list); \
41 CL_SMOKE_QT_EXPORT void* \
42 cl_smoke_make_list_ ## NAME () \
44 return new QList< TYPE >(); \
49 * At and append for pointer types
51 #define DEFINE_QLIST_WRAPPER_PTR_PART(NAME, TYPE) \
52 CL_SMOKE_QT_EXPORT const void* \
53 cl_smoke_list_ ## NAME ## _at(const void* list, int index) \
55 const QList< TYPE >* qlist = static_cast<const QList< TYPE > *>(list); \
56 return qlist->at(index); \
59 CL_SMOKE_QT_EXPORT void \
60 cl_smoke_list_ ## NAME ## _append(void* list, void* data) \
62 static_cast<QList< TYPE >*>(list) \
63 ->append(static_cast<TYPE>(data)); \
67 * At and append for value types.
69 #define DEFINE_QLIST_WRAPPER_VALUE_PART(NAME, TYPE) \
70 CL_SMOKE_QT_EXPORT const void* \
71 cl_smoke_list_ ## NAME ## _at(const void* list, int index) \
73 const QList< TYPE >* qlist = static_cast<const QList< TYPE > *>(list); \
74 return new TYPE(qlist->at(index)); \
77 CL_SMOKE_QT_EXPORT void \
78 cl_smoke_list_ ## NAME ## _append(void* list, void* data) \
80 static_cast<QList< TYPE >*>(list) \
81 ->append(*static_cast<TYPE*>(data)); \
84 #endif // CL_SMOKE_QT_QLIST_H