Mercurial > projects > qtd
comparison include/qtd_core.h @ 384:d2f48c4cb3e3
Same behavior of shared libs on linux and windows. Minor build script fixes.
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Fri, 16 Jul 2010 20:04:29 +0300 |
parents | 7341c47790d4 |
children |
comparison
equal
deleted
inserted
replaced
383:bd7f485e3573 | 384:d2f48c4cb3e3 |
---|---|
7 #define QTD_CORE_H | 7 #define QTD_CORE_H |
8 | 8 |
9 #include <QAbstractItemModel> | 9 #include <QAbstractItemModel> |
10 | 10 |
11 #define QTD_EXTERN extern "C" | 11 #define QTD_EXTERN extern "C" |
12 | |
12 QTD_EXTERN typedef void (*VoidFunc)(); | 13 QTD_EXTERN typedef void (*VoidFunc)(); |
13 | 14 |
14 #ifdef WIN32 | 15 #ifdef WIN32 |
15 | 16 #define QTD_EXPORT __declspec(dllexport) |
16 #define QTD_DLL_EXPORT __declspec(dllexport) | 17 #define QTD_IMPORT __declspec(dllimport) |
17 #define QTD_DLL_IMPORT __declspec(dllimport) | |
18 | |
19 #ifdef CPP_SHARED | |
20 | |
21 #define QTD_EXPORT_DECL(MODULE, TYPE, NAME, ARGS) \ | |
22 QTD_EXTERN typedef TYPE (*qtd_##NAME##_t)ARGS; \ | |
23 QTD_EXTERN { extern QTD_##MODULE##_DLL_PUBLIC qtd_##NAME##_t qtd_##NAME; } | |
24 | |
25 #define QTD_EXPORT(MODULE, NAME) \ | |
26 QTD_EXTERN { QTD_##MODULE##_DLL_PUBLIC qtd_##NAME##_t qtd_##NAME; } \ | |
27 QTD_EXTERN QTD_DLL_EXPORT void qtd_set_##NAME(VoidFunc func) { qtd_##NAME = (qtd_##NAME##_t)func; } | |
28 | |
29 #endif | |
30 | |
31 #else | 18 #else |
32 | 19 #define QTD_EXPORT |
33 #define QTD_DLL_EXPORT | 20 #define QTD_IMPORT |
34 #define QTD_DLL_IMPORT | |
35 | |
36 #define QTD_EXPORT_DECL(MODULE, TYPE, NAME, ARGS) \ | |
37 QTD_EXTERN TYPE qtd_##NAME ARGS; | |
38 | |
39 #define QTD_EXPORT(MODULE, NAME) | |
40 | |
41 #endif | 21 #endif |
42 | 22 |
43 #define QTD_DLL_PUBLIC QTD_DLL_EXPORT | 23 #ifdef CPP_SHARED |
24 #define QTD_FUNC_DECL(MODULE, TYPE, NAME, ARGS) \ | |
25 QTD_EXTERN typedef TYPE (*qtd_##NAME##_t)ARGS; \ | |
26 QTD_EXTERN { extern QTD_##MODULE##_PUBLIC qtd_##NAME##_t qtd_##NAME; } | |
27 #define QTD_FUNC(MODULE, NAME) \ | |
28 QTD_EXTERN { QTD_##MODULE##_PUBLIC qtd_##NAME##_t qtd_##NAME; } \ | |
29 QTD_EXTERN QTD_EXPORT void qtd_set_##NAME(VoidFunc func) { qtd_##NAME = (qtd_##NAME##_t)func; } | |
30 #else | |
31 #define QTD_FUNC_DECL(MODULE, TYPE, NAME, ARGS) \ | |
32 QTD_EXTERN TYPE qtd_##NAME ARGS; | |
33 #define QTD_FUNC(MODULE, NAME) | |
34 #endif | |
44 | 35 |
36 //TODO: these should be moved to module-specific includes | |
45 #ifdef QTD_CORE | 37 #ifdef QTD_CORE |
46 #define QTD_CORE_DLL_PUBLIC QTD_DLL_EXPORT | 38 #define QTD_CORE_PUBLIC QTD_EXPORT |
47 #else | 39 #else |
48 #define QTD_CORE_DLL_PUBLIC QTD_DLL_IMPORT | 40 #define QTD_CORE_PUBLIC QTD_IMPORT |
49 #endif | 41 #endif |
50 | 42 |
51 #ifdef QTD_GUI | 43 #ifdef QTD_GUI |
52 #define QTD_GUI_DLL_PUBLIC QTD_DLL_EXPORT | 44 #define QTD_GUI_PUBLIC QTD_EXPORT |
53 #else | 45 #else |
54 #define QTD_GUI_DLL_PUBLIC QTD_DLL_IMPORT | 46 #define QTD_GUI_PUBLIC QTD_IMPORT |
55 #endif | 47 #endif |
56 | 48 |
57 #ifdef QTD_OPENGL | 49 #ifdef QTD_OPENGL |
58 #define QTD_OPENGL_DLL_PUBLIC QTD_DLL_EXPORT | 50 #define QTD_OPENGL_PUBLIC QTD_EXPORT |
59 #else | 51 #else |
60 #define QTD_OPENGL_DLL_PUBLIC QTD_DLL_IMPORT | 52 #define QTD_OPENGL_PUBLIC QTD_IMPORT |
61 #endif | 53 #endif |
62 | 54 |
63 #ifdef QTD_NETWORK | 55 #ifdef QTD_NETWORK |
64 #define QTD_NETWORK_DLL_PUBLIC QTD_DLL_EXPORT | 56 #define QTD_NETWORK_PUBLIC QTD_EXPORT |
65 #else | 57 #else |
66 #define QTD_NETWORK_DLL_PUBLIC QTD_DLL_IMPORT | 58 #define QTD_NETWORK_PUBLIC QTD_IMPORT |
67 #endif | 59 #endif |
68 | 60 |
69 #ifdef QTD_SVG | 61 #ifdef QTD_SVG |
70 #define QTD_SVG_DLL_PUBLIC QTD_DLL_EXPORT | 62 #define QTD_SVG_PUBLIC QTD_EXPORT |
71 #else | 63 #else |
72 #define QTD_SVG_DLL_PUBLIC QTD_DLL_IMPORT | 64 #define QTD_SVG_PUBLIC QTD_IMPORT |
73 #endif | 65 #endif |
74 | 66 |
75 #ifdef QTD_XML | 67 #ifdef QTD_XML |
76 #define QTD_XML_DLL_PUBLIC QTD_DLL_EXPORT | 68 #define QTD_XML_PUBLIC QTD_EXPORT |
77 #else | 69 #else |
78 #define QTD_XML_DLL_PUBLIC QTD_DLL_IMPORT | 70 #define QTD_XML_PUBLIC QTD_IMPORT |
79 #endif | 71 #endif |
80 | 72 |
81 #ifdef QTD_WEBKIT | 73 #ifdef QTD_WEBKIT |
82 #define QTD_WEBKIT_DLL_PUBLIC QTD_DLL_EXPORT | 74 #define QTD_WEBKIT_PUBLIC QTD_EXPORT |
83 #else | 75 #else |
84 #define QTD_WEBKIT_DLL_PUBLIC QTD_DLL_IMPORT | 76 #define QTD_WEBKIT_PUBLIC QTD_IMPORT |
85 #endif | 77 #endif |
86 | 78 |
87 #ifdef QTD_QWT | 79 #ifdef QTD_QWT |
88 #define QTD_QWT_DLL_PUBLIC QTD_DLL_EXPORT | 80 #define QTD_QWT_PUBLIC QTD_EXPORT |
89 #else | 81 #else |
90 #define QTD_QWT_DLL_PUBLIC QTD_DLL_IMPORT | 82 #define QTD_QWT_PUBLIC QTD_IMPORT |
91 #endif | 83 #endif |
92 | 84 |
93 //TODO: ditch | 85 //TODO: ditch |
94 struct QModelIndexAccessor { | 86 struct QModelIndexAccessor { |
95 int row; | 87 int row; |
101 struct DArray { | 93 struct DArray { |
102 size_t length; | 94 size_t length; |
103 void* ptr; | 95 void* ptr; |
104 }; | 96 }; |
105 | 97 |
106 enum QtdObjectFlags | 98 class QTD_CORE_PUBLIC QtdObjectLink |
107 { | |
108 qNone, | |
109 qNativeOwnership = 0x01, | |
110 qDOwnership = 0x02 | |
111 //gcManaged = 0x04 | |
112 }; | |
113 | |
114 class QTD_CORE_DLL_PUBLIC QtdObjectLink | |
115 { | 99 { |
116 public: | 100 public: |
117 void* dId; | 101 void* dId; |
118 | 102 |
119 QtdObjectLink(void* id) : dId(id) {} | 103 QtdObjectLink(void* id) : dId(id) {} |
130 QtdObjectLink *link = getLink((T*)object); | 114 QtdObjectLink *link = getLink((T*)object); |
131 return link ? link->dId : NULL; | 115 return link ? link->dId : NULL; |
132 } | 116 } |
133 }; | 117 }; |
134 | 118 |
135 class QTD_CORE_DLL_PUBLIC QObjectLink : public QtdObjectLink, public QObjectUserData | 119 class QTD_CORE_PUBLIC QObjectLink : public QtdObjectLink, public QObjectUserData |
136 { | 120 { |
137 public: | 121 public: |
138 enum Flags | 122 enum Flags |
139 { | 123 { |
140 None, | 124 None, |
152 static void* getDId(const QObject* qObject); | 136 static void* getDId(const QObject* qObject); |
153 }; | 137 }; |
154 | 138 |
155 #define Array DArray | 139 #define Array DArray |
156 | 140 |
157 QTD_EXPORT_DECL(CORE, void, toUtf8, (const unsigned short* arr, uint size, void* str)) | 141 QTD_FUNC_DECL(CORE, void, toUtf8, (const unsigned short* arr, uint size, void* str)) |
158 QTD_EXPORT_DECL(CORE, void, QtdObject_delete, (void* dId)) | 142 QTD_FUNC_DECL(CORE, void, QtdObject_delete, (void* dId)) |
159 | 143 |
160 QTD_EXTERN QModelIndex qtd_to_QModelIndex(QModelIndexAccessor mia); | 144 QTD_EXTERN QModelIndex qtd_to_QModelIndex(QModelIndexAccessor mia); |
161 QTD_EXTERN QModelIndexAccessor qtd_from_QModelIndex(const QModelIndex &index); | 145 QTD_EXTERN QModelIndexAccessor qtd_from_QModelIndex(const QModelIndex &index); |
162 | 146 |
163 QTD_EXTERN typedef void (*EmitCallback)(void*, void**); | 147 QTD_EXTERN typedef void (*EmitCallback)(void*, void**); |