summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-11-23 21:57:45 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2017-11-29 15:56:57 -0300
commit99be2104a36980fd32e84da39c056f5d546dec69 (patch)
tree31b6986daff46c23ebffcd005fca9b36afc304d0
parentc1da0634e04eec2e0c839aab301fe14ffcedc956 (diff)
efl_mono: Add native support library
Buildsystem integration will come in a future commit
-rw-r--r--src/lib/efl_mono/.gitignore1
-rw-r--r--src/lib/efl_mono/efl_custom_exports_mono.c439
2 files changed, 440 insertions, 0 deletions
diff --git a/src/lib/efl_mono/.gitignore b/src/lib/efl_mono/.gitignore
new file mode 100644
index 0000000000..b48bfd5fb8
--- /dev/null
+++ b/src/lib/efl_mono/.gitignore
@@ -0,0 +1 @@
/libefl_mono.dll
diff --git a/src/lib/efl_mono/efl_custom_exports_mono.c b/src/lib/efl_mono/efl_custom_exports_mono.c
new file mode 100644
index 0000000000..16b2977db9
--- /dev/null
+++ b/src/lib/efl_mono/efl_custom_exports_mono.c
@@ -0,0 +1,439 @@
1#include "Eo.h"
2#include "Eina.h"
3
4#include <stdlib.h>
5#include <string.h>
6
7#ifdef EAPI
8# undef EAPI
9#endif
10
11#ifdef _WIN32
12# define EAPI __declspec(dllexport)
13#else
14# ifdef __GNUC__
15# if __GNUC__ >= 4
16# define EAPI __attribute__ ((visibility("default")))
17# else
18# define EAPI
19# endif
20# else
21# define EAPI
22# endif
23#endif /* ! _WIN32 */
24
25EAPI void *efl_mono_native_alloc(unsigned int size)
26{
27 return malloc(size);
28}
29
30EAPI void efl_mono_native_free(void *ptr)
31{
32 free(ptr);
33}
34
35EAPI void efl_mono_native_free_ref(void **ptr)
36{
37 if (!ptr) return;
38 free(*ptr);
39}
40
41EAPI void *efl_mono_native_alloc_copy(const void *val, unsigned int size)
42{
43 if (!val) return NULL;
44 void *r = malloc(size);
45 memcpy(r, val, size);
46 return r;
47}
48
49EAPI const char *efl_mono_native_strdup(const char *str)
50{
51 if (!str) return NULL;
52 return strdup(str);
53}
54
55EAPI int efl_mono_native_ptr_compare(const void *ptr1, const void *ptr2)
56{
57 uintptr_t addr1 = (uintptr_t)ptr1;
58 uintptr_t addr2 = (uintptr_t)ptr2;
59 return (addr1 > addr2) - (addr1 < addr2);
60}
61
62EAPI Eina_Compare_Cb efl_mono_native_ptr_compare_addr_get()
63{
64 return efl_mono_native_ptr_compare;
65}
66
67EAPI Eina_Compare_Cb efl_mono_native_str_compare_addr_get()
68{
69 return (Eina_Compare_Cb)strcmp;
70}
71
72EAPI Eina_Free_Cb efl_mono_native_free_addr_get()
73{
74 return (Eina_Free_Cb)free;
75}
76
77EAPI Eina_Free_Cb efl_mono_native_efl_unref_addr_get()
78{
79 return (Eina_Free_Cb)efl_unref;
80}
81
82// Iterator Wrapper //
83
84typedef struct _Eina_Iterator_Wrapper_Mono
85{
86 Eina_Iterator iterator; // Must be the first
87 Eina_Iterator *internal;
88} Eina_Iterator_Wrapper_Mono;
89
90static void *eina_iterator_wrapper_get_container_mono(Eina_Iterator_Wrapper_Mono *it)
91{
92 return eina_iterator_container_get(it->internal);
93}
94
95static void eina_iterator_wrapper_free_mono(Eina_Iterator_Wrapper_Mono *it)
96{
97 eina_iterator_free(it->internal);
98 free(it);
99}
100
101
102static Eina_Iterator *eina_iterator_wrapper_new_mono(Eina_Iterator *internal, Eina_Iterator_Next_Callback next_cb)
103{
104 if (!internal) return NULL;
105
106 Eina_Iterator_Wrapper_Mono *it = calloc(1, sizeof(Eina_Iterator_Wrapper_Mono));
107 if (!it)
108 {
109 eina_iterator_free(internal);
110 return NULL;
111 }
112
113 it->internal = internal;
114
115 it->iterator.next = next_cb;
116
117 it->iterator.version = EINA_ITERATOR_VERSION;
118 it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(eina_iterator_wrapper_get_container_mono);
119 it->iterator.free = FUNC_ITERATOR_FREE(eina_iterator_wrapper_free_mono);
120
121 EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
122
123 return &it->iterator;
124}
125
126// Array //
127
128EAPI void eina_array_clean_custom_export_mono(Eina_Array *array) EINA_ARG_NONNULL(1)
129{
130 eina_array_clean(array);
131}
132
133EAPI Eina_Bool eina_array_push_custom_export_mono(Eina_Array *array, const void *data) EINA_ARG_NONNULL(1, 2)
134{
135 return eina_array_push(array, data);
136}
137
138EAPI void *eina_array_pop_custom_export_mono(Eina_Array *array) EINA_ARG_NONNULL(1)
139{
140 return eina_array_pop(array);
141}
142
143EAPI void *eina_array_data_get_custom_export_mono(const Eina_Array *array, unsigned int idx) EINA_ARG_NONNULL(1)
144{
145 return eina_array_data_get(array, idx);
146}
147
148EAPI void eina_array_data_set_custom_export_mono(const Eina_Array *array, unsigned int idx, const void *data) EINA_ARG_NONNULL(1)
149{
150 eina_array_data_set(array, idx, data);
151}
152
153EAPI unsigned int eina_array_count_custom_export_mono(const Eina_Array *array) EINA_ARG_NONNULL(1)
154{
155 return eina_array_count(array);
156}
157
158EAPI Eina_Bool eina_array_foreach_custom_export_mono(Eina_Array *array, Eina_Each_Cb cb, void *fdata)
159{
160 return eina_array_foreach(array, cb, fdata);
161}
162
163// List //
164
165EAPI Eina_List *eina_list_last_custom_export_mono(const Eina_List *list)
166{
167 return eina_list_last(list);
168}
169
170EAPI Eina_List *eina_list_next_custom_export_mono(const Eina_List *list)
171{
172 return eina_list_next(list);
173}
174
175EAPI Eina_List *eina_list_prev_custom_export_mono(const Eina_List *list)
176{
177 return eina_list_prev(list);
178}
179
180EAPI void *eina_list_data_get_custom_export_mono(const Eina_List *list)
181{
182 return eina_list_data_get(list);
183}
184
185EAPI void *eina_list_data_set_custom_export_mono(Eina_List *list, const void *data)
186{
187 return eina_list_data_set(list, data);
188}
189
190EAPI unsigned int eina_list_count_custom_export_mono(const Eina_List *list)
191{
192 return eina_list_count(list);
193}
194
195EAPI void *eina_list_last_data_get_custom_export_mono(const Eina_List *list)
196{
197 return eina_list_last_data_get(list);
198}
199
200// Inlist //
201
202typedef struct _Inlist_Node_Mono
203{
204 EINA_INLIST;
205 char mem_start;
206} Inlist_Node_Mono;
207
208static Eina_Bool eina_inlist_iterator_wrapper_next_mono(Eina_Iterator_Wrapper_Mono *it, void **data)
209{
210 Inlist_Node_Mono *node = NULL;
211
212 if (!eina_iterator_next(it->internal, (void**)&node))
213 return EINA_FALSE;
214
215 if (data)
216 *data = &node->mem_start;
217
218 return EINA_TRUE;
219}
220
221EAPI Eina_Iterator *eina_inlist_iterator_wrapper_new_custom_export_mono(const Eina_Inlist *in_list)
222{
223 return eina_iterator_wrapper_new_mono(eina_inlist_iterator_new(in_list), FUNC_ITERATOR_NEXT(eina_inlist_iterator_wrapper_next_mono));
224}
225
226EAPI Eina_Inlist *eina_inlist_first_custom_export_mono(const Eina_Inlist *list)
227{
228 return eina_inlist_first(list);
229}
230
231EAPI Eina_Inlist *eina_inlist_last_custom_export_mono(const Eina_Inlist *list)
232{
233 return eina_inlist_last(list);
234}
235
236EAPI Eina_Inlist *eina_inlist_next_custom_export_mono(const Eina_Inlist *list)
237{
238 if (list)
239 return list->next;
240 return NULL;
241}
242
243EAPI Eina_Inlist *eina_inlist_prev_custom_export_mono(const Eina_Inlist *list)
244{
245 if (list)
246 return list->prev;
247 return NULL;
248}
249
250// Hash //
251
252static Eina_Bool eina_hash_iterator_ptr_key_wrapper_next_mono(Eina_Iterator_Wrapper_Mono *it, void **data)
253{
254 void **ptr = NULL;
255
256 if (!eina_iterator_next(it->internal, (void**)&ptr))
257 return EINA_FALSE;
258
259 if (data)
260 *data = *ptr;
261
262 return EINA_TRUE;
263}
264
265EAPI Eina_Iterator *eina_hash_iterator_ptr_key_wrapper_new_custom_export_mono(const Eina_Hash *hash)
266{
267 return eina_iterator_wrapper_new_mono(eina_hash_iterator_key_new(hash), FUNC_ITERATOR_NEXT(eina_hash_iterator_ptr_key_wrapper_next_mono));
268}
269
270// Eina Value //
271EAPI const Eina_Value_Type *type_byte() {
272 return EINA_VALUE_TYPE_UCHAR;
273}
274EAPI const Eina_Value_Type *type_sbyte() {
275 return EINA_VALUE_TYPE_CHAR;
276}
277EAPI const Eina_Value_Type *type_short() {
278 return EINA_VALUE_TYPE_SHORT;
279}
280EAPI const Eina_Value_Type *type_ushort() {
281 return EINA_VALUE_TYPE_USHORT;
282}
283EAPI const Eina_Value_Type *type_int32() {
284 return EINA_VALUE_TYPE_INT;
285}
286EAPI const Eina_Value_Type *type_uint32() {
287 return EINA_VALUE_TYPE_UINT;
288}
289EAPI const Eina_Value_Type *type_long() {
290 return EINA_VALUE_TYPE_LONG;
291}
292EAPI const Eina_Value_Type *type_ulong() {
293 return EINA_VALUE_TYPE_ULONG;
294}
295EAPI const Eina_Value_Type *type_int64() {
296 return EINA_VALUE_TYPE_INT64;
297}
298EAPI const Eina_Value_Type *type_uint64() {
299 return EINA_VALUE_TYPE_UINT64;
300}
301EAPI const Eina_Value_Type *type_string() {
302 return EINA_VALUE_TYPE_STRING;
303}
304EAPI const Eina_Value_Type *type_float() {
305 return EINA_VALUE_TYPE_FLOAT;
306}
307EAPI const Eina_Value_Type *type_double() {
308 return EINA_VALUE_TYPE_DOUBLE;
309}
310EAPI const Eina_Value_Type *type_array() {
311 return EINA_VALUE_TYPE_ARRAY;
312}
313EAPI const Eina_Value_Type *type_list() {
314 return EINA_VALUE_TYPE_LIST;
315}
316
317EAPI const Eina_Value_Type *type_optional() {
318 return EINA_VALUE_TYPE_OPTIONAL;
319}
320
321EAPI size_t eina_value_sizeof()
322{
323 return sizeof(Eina_Value);
324}
325
326EAPI Eina_Bool eina_value_set_wrapper(Eina_Value *value, ...)
327{
328 va_list argp;
329 va_start(argp, value);
330 Eina_Bool ret = eina_value_vset(value, argp);
331 va_end(argp);
332 return ret;
333}
334
335EAPI Eina_Bool eina_value_setup_wrapper(Eina_Value *value,
336 const Eina_Value_Type *type)
337{
338 return eina_value_setup(value, type);
339}
340
341EAPI void eina_value_flush_wrapper(Eina_Value *value)
342{
343 eina_value_flush(value);
344}
345
346EAPI const Eina_Value_Type *eina_value_type_get_wrapper(const Eina_Value *value)
347{
348 return eina_value_type_get(value);
349}
350
351EAPI Eina_Bool eina_value_get_wrapper(const Eina_Value *value, void *output)
352{
353 return eina_value_get(value, output);
354}
355
356EAPI int eina_value_compare_wrapper(const Eina_Value *this, const Eina_Value *other)
357{
358 return eina_value_compare(this, other);
359}
360
361EAPI Eina_Bool eina_value_array_setup_wrapper(Eina_Value *array, const Eina_Value_Type *subtype, unsigned int step)
362{
363 return eina_value_array_setup(array, subtype, step);
364}
365
366EAPI Eina_Bool eina_value_list_setup_wrapper(Eina_Value *list, const Eina_Value_Type *subtype)
367{
368 return eina_value_list_setup(list, subtype);
369}
370
371EAPI Eina_Bool eina_value_array_append_wrapper(Eina_Value *array, va_list argp)
372{
373 return eina_value_array_append(array, argp);
374}
375
376EAPI Eina_Bool eina_value_list_append_wrapper(Eina_Value *list, va_list argp)
377{
378 return eina_value_list_append(list, argp);
379}
380
381EAPI Eina_Bool eina_value_array_get_wrapper(const Eina_Value *array, int i, void *output)
382{
383 return eina_value_array_get(array, i, output);
384}
385
386EAPI Eina_Bool eina_value_list_get_wrapper(const Eina_Value *list, int i, void *output)
387{
388 return eina_value_list_get(list, i, output);
389}
390
391EAPI Eina_Bool eina_value_array_set_wrapper(Eina_Value *array, int i, void *value)
392{
393 return eina_value_array_set(array, i, value);
394}
395
396EAPI Eina_Bool eina_value_list_set_wrapper(Eina_Value *list, int i, void *value)
397{
398 return eina_value_list_set(list, i, value);
399}
400
401// Not actually a wrapper, but keeping the naming convention for functions on this file.
402EAPI const Eina_Value_Type* eina_value_array_subtype_get_wrapper(const Eina_Value *array)
403{
404 Eina_Value_Array array_value;
405 eina_value_get(array, &array_value);
406 return array_value.subtype;
407}
408
409EAPI const Eina_Value_Type* eina_value_list_subtype_get_wrapper(const Eina_Value *list)
410{
411 Eina_Value_List list_value;
412 eina_value_get(list, &list_value);
413 return list_value.subtype;
414}
415
416EAPI unsigned int eina_value_array_count_wrapper(const Eina_Value *array)
417{
418 return eina_value_array_count(array);
419}
420
421EAPI unsigned int eina_value_list_count_wrapper(const Eina_Value *list)
422{
423 return eina_value_list_count(list);
424}
425
426EAPI Eina_Bool eina_value_optional_empty_is_wrapper(const Eina_Value *value, Eina_Bool *empty)
427{
428 return eina_value_optional_empty_is(value, empty);
429}
430
431EAPI const Eina_Value_Type *eina_value_optional_type_get_wrapper(Eina_Value *value)
432{
433 return eina_value_optional_type_get(value);
434}
435
436EAPI Eina_Bool eina_value_pset_wrapper(Eina_Value *value, void *ptr)
437{
438 return eina_value_pset(value, ptr);
439}