summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertise.dev>2020-10-29 19:37:44 -0300
committerFelipe Magno de Almeida <felipe@expertise.dev>2020-12-14 13:22:42 -0300
commitd924100b42be59d50152fda4ad2591a5fc275db7 (patch)
treeb3b59a11b62fe191b828e7b3939abee7786523dd
parentff840ba26ccd6060bfe28d0903b81e83fd7c2a48 (diff)
ecore_input: Rename EAPI macro to ECORE_INPUT_API in Ecore Input library
Patch from a series of patches to rename EAPI symbols to specific library DSOs. EAPI was designed to be able to pass ```__attribute__ ((visibility ("default")))``` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as ```__atttribute__((visibility("default")))```. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why EAPI is the only solution that worked for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
-rw-r--r--src/lib/ecore_input/Ecore_Input.h67
-rw-r--r--src/lib/ecore_input/ecore_input.c30
-rw-r--r--src/lib/ecore_input/ecore_input_api.h34
-rw-r--r--src/lib/ecore_input/ecore_input_compose.c2
-rw-r--r--src/lib/ecore_input/ecore_input_joystick.c6
-rw-r--r--src/lib/ecore_input/meson.build2
6 files changed, 74 insertions, 67 deletions
diff --git a/src/lib/ecore_input/Ecore_Input.h b/src/lib/ecore_input/Ecore_Input.h
index 1c8763818b..d30c06bc37 100644
--- a/src/lib/ecore_input/Ecore_Input.h
+++ b/src/lib/ecore_input/Ecore_Input.h
@@ -11,31 +11,7 @@
11 11
12#include <Eo.h> 12#include <Eo.h>
13 13
14#ifdef EAPI 14#include <ecore_input_api.h>
15# undef EAPI
16#endif
17
18#ifdef _WIN32
19# ifdef EFL_BUILD
20# ifdef DLL_EXPORT
21# define EAPI __declspec(dllexport)
22# else
23# define EAPI
24# endif
25# else
26# define EAPI __declspec(dllimport)
27# endif
28#else
29# ifdef __GNUC__
30# if __GNUC__ >= 4
31# define EAPI __attribute__ ((visibility("default")))
32# else
33# define EAPI
34# endif
35# else
36# define EAPI
37# endif
38#endif
39 15
40#ifdef __cplusplus 16#ifdef __cplusplus
41extern "C" { 17extern "C" {
@@ -47,17 +23,17 @@ extern "C" {
47 * 23 *
48 *@{ 24 *@{
49 */ 25 */
50 EAPI extern int ECORE_EVENT_KEY_DOWN; 26 ECORE_INPUT_API extern int ECORE_EVENT_KEY_DOWN;
51 EAPI extern int ECORE_EVENT_KEY_UP; 27 ECORE_INPUT_API extern int ECORE_EVENT_KEY_UP;
52 EAPI extern int ECORE_EVENT_MOUSE_BUTTON_DOWN; 28 ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_BUTTON_DOWN;
53 EAPI extern int ECORE_EVENT_MOUSE_BUTTON_UP; 29 ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_BUTTON_UP;
54 EAPI extern int ECORE_EVENT_MOUSE_MOVE; 30 ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_MOVE;
55 EAPI extern int ECORE_EVENT_MOUSE_WHEEL; 31 ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_WHEEL;
56 EAPI extern int ECORE_EVENT_MOUSE_IN; 32 ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_IN;
57 EAPI extern int ECORE_EVENT_MOUSE_OUT; 33 ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_OUT;
58 EAPI extern int ECORE_EVENT_AXIS_UPDATE; /**< @since 1.13 */ 34 ECORE_INPUT_API extern int ECORE_EVENT_AXIS_UPDATE; /**< @since 1.13 */
59 EAPI extern int ECORE_EVENT_MOUSE_BUTTON_CANCEL; /**< @since 1.15 */ 35 ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_BUTTON_CANCEL; /**< @since 1.15 */
60 EAPI extern int ECORE_EVENT_JOYSTICK; /**< @since 1.18 */ 36 ECORE_INPUT_API extern int ECORE_EVENT_JOYSTICK; /**< @since 1.18 */
61 37
62#define ECORE_EVENT_MODIFIER_SHIFT 0x0001 38#define ECORE_EVENT_MODIFIER_SHIFT 0x0001
63#define ECORE_EVENT_MODIFIER_CTRL 0x0002 39#define ECORE_EVENT_MODIFIER_CTRL 0x0002
@@ -418,11 +394,11 @@ extern "C" {
418 /** 394 /**
419 * Initializes the Ecore Event system. 395 * Initializes the Ecore Event system.
420 */ 396 */
421 EAPI int ecore_event_init(void); 397 ECORE_INPUT_API int ecore_event_init(void);
422 /** 398 /**
423 * Shutdowns the Ecore Event system. 399 * Shutdowns the Ecore Event system.
424 */ 400 */
425 EAPI int ecore_event_shutdown(void); 401 ECORE_INPUT_API int ecore_event_shutdown(void);
426 402
427 /** 403 /**
428 * Returns the Ecore modifier event integer associated to a 404 * Returns the Ecore modifier event integer associated to a
@@ -432,7 +408,7 @@ extern "C" {
432 * @return A event_modifier integer that matches with the provided modifier 408 * @return A event_modifier integer that matches with the provided modifier
433 * event. 409 * event.
434 */ 410 */
435 EAPI unsigned int ecore_event_modifier_mask(Ecore_Event_Modifier modifier); 411 ECORE_INPUT_API unsigned int ecore_event_modifier_mask(Ecore_Event_Modifier modifier);
436 412
437 /** 413 /**
438 * Update a Ecore_Event_Modifiers array with "key" modifier. 414 * Update a Ecore_Event_Modifiers array with "key" modifier.
@@ -444,7 +420,7 @@ extern "C" {
444 * @return ECORE_NONE if the key does not match with an existing one, else 420 * @return ECORE_NONE if the key does not match with an existing one, else
445 * the corresponding Ecore_Event_Modifier. 421 * the corresponding Ecore_Event_Modifier.
446 */ 422 */
447 EAPI Ecore_Event_Modifier ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc); 423 ECORE_INPUT_API Ecore_Event_Modifier ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc);
448 424
449 /** 425 /**
450 * Handles a sequence of key symbols to make a final compose string. 426 * Handles a sequence of key symbols to make a final compose string.
@@ -456,7 +432,7 @@ extern "C" {
456 * @param seqstr_ret The final compose string. 432 * @param seqstr_ret The final compose string.
457 * @return The status of the composition. 433 * @return The status of the composition.
458 */ 434 */
459 EAPI Ecore_Compose_State ecore_compose_get(const Eina_List *seq, char **seqstr_ret); 435 ECORE_INPUT_API Ecore_Compose_State ecore_compose_get(const Eina_List *seq, char **seqstr_ret);
460 436
461 /** 437 /**
462 * Set deadzone of joystick event for an axis. 438 * Set deadzone of joystick event for an axis.
@@ -469,7 +445,7 @@ extern "C" {
469 * @param event_axis_deadzone The joystick event axis deadzone. 445 * @param event_axis_deadzone The joystick event axis deadzone.
470 * @since 1.19 446 * @since 1.19
471 */ 447 */
472 EAPI void ecore_input_joystick_event_axis_deadzone_set(int event_axis_deadzone); 448 ECORE_INPUT_API void ecore_input_joystick_event_axis_deadzone_set(int event_axis_deadzone);
473 449
474 /** 450 /**
475 * Get deadzone of joystick event for an axis. 451 * Get deadzone of joystick event for an axis.
@@ -477,7 +453,7 @@ extern "C" {
477 * @return deadzone of joystick event for an axis. 453 * @return deadzone of joystick event for an axis.
478 * @since 1.19 454 * @since 1.19
479 */ 455 */
480 EAPI int ecore_input_joystick_event_axis_deadzone_get(void); 456 ECORE_INPUT_API int ecore_input_joystick_event_axis_deadzone_get(void);
481 457
482 /** 458 /**
483 * Get name of joystick 459 * Get name of joystick
@@ -489,13 +465,10 @@ extern "C" {
489 * @return name of joystick. 465 * @return name of joystick.
490 * @since 1.20 466 * @since 1.20
491 */ 467 */
492 EAPI const char *ecore_input_joystick_name_get(int index); 468 ECORE_INPUT_API const char *ecore_input_joystick_name_get(int index);
493#ifdef __cplusplus 469#ifdef __cplusplus
494} 470}
495#endif 471#endif
496 472
497#undef EAPI
498#define EAPI
499
500/** @} */ 473/** @} */
501#endif 474#endif
diff --git a/src/lib/ecore_input/ecore_input.c b/src/lib/ecore_input/ecore_input.c
index 2954bcd2fc..188d4599d1 100644
--- a/src/lib/ecore_input/ecore_input.c
+++ b/src/lib/ecore_input/ecore_input.c
@@ -14,21 +14,21 @@
14 14
15int _ecore_input_log_dom = -1; 15int _ecore_input_log_dom = -1;
16 16
17EAPI int ECORE_EVENT_KEY_DOWN = 0; 17ECORE_INPUT_API int ECORE_EVENT_KEY_DOWN = 0;
18EAPI int ECORE_EVENT_KEY_UP = 0; 18ECORE_INPUT_API int ECORE_EVENT_KEY_UP = 0;
19EAPI int ECORE_EVENT_MOUSE_BUTTON_DOWN = 0; 19ECORE_INPUT_API int ECORE_EVENT_MOUSE_BUTTON_DOWN = 0;
20EAPI int ECORE_EVENT_MOUSE_BUTTON_UP = 0; 20ECORE_INPUT_API int ECORE_EVENT_MOUSE_BUTTON_UP = 0;
21EAPI int ECORE_EVENT_MOUSE_MOVE = 0; 21ECORE_INPUT_API int ECORE_EVENT_MOUSE_MOVE = 0;
22EAPI int ECORE_EVENT_MOUSE_WHEEL = 0; 22ECORE_INPUT_API int ECORE_EVENT_MOUSE_WHEEL = 0;
23EAPI int ECORE_EVENT_MOUSE_IN = 0; 23ECORE_INPUT_API int ECORE_EVENT_MOUSE_IN = 0;
24EAPI int ECORE_EVENT_MOUSE_OUT = 0; 24ECORE_INPUT_API int ECORE_EVENT_MOUSE_OUT = 0;
25EAPI int ECORE_EVENT_AXIS_UPDATE = 0; 25ECORE_INPUT_API int ECORE_EVENT_AXIS_UPDATE = 0;
26EAPI int ECORE_EVENT_MOUSE_BUTTON_CANCEL = 0; 26ECORE_INPUT_API int ECORE_EVENT_MOUSE_BUTTON_CANCEL = 0;
27EAPI int ECORE_EVENT_JOYSTICK = 0; 27ECORE_INPUT_API int ECORE_EVENT_JOYSTICK = 0;
28 28
29static int _ecore_event_init_count = 0; 29static int _ecore_event_init_count = 0;
30 30
31EAPI int 31ECORE_INPUT_API int
32ecore_event_init(void) 32ecore_event_init(void)
33{ 33{
34 if (++_ecore_event_init_count != 1) 34 if (++_ecore_event_init_count != 1)
@@ -64,7 +64,7 @@ ecore_event_init(void)
64 return _ecore_event_init_count; 64 return _ecore_event_init_count;
65} 65}
66 66
67EAPI int 67ECORE_INPUT_API int
68ecore_event_shutdown(void) 68ecore_event_shutdown(void)
69{ 69{
70 if (--_ecore_event_init_count != 0) 70 if (--_ecore_event_init_count != 0)
@@ -110,7 +110,7 @@ static const Ecore_Event_Modifier_Match matchs[] = {
110 { "Scroll_Lock", ECORE_SCROLL, ECORE_EVENT_MODIFIER_SCROLL } 110 { "Scroll_Lock", ECORE_SCROLL, ECORE_EVENT_MODIFIER_SCROLL }
111}; 111};
112 112
113EAPI unsigned int 113ECORE_INPUT_API unsigned int
114ecore_event_modifier_mask(Ecore_Event_Modifier modifier) 114ecore_event_modifier_mask(Ecore_Event_Modifier modifier)
115{ 115{
116 size_t i; 116 size_t i;
@@ -122,7 +122,7 @@ ecore_event_modifier_mask(Ecore_Event_Modifier modifier)
122 return 0; 122 return 0;
123} 123}
124 124
125EAPI Ecore_Event_Modifier 125ECORE_INPUT_API Ecore_Event_Modifier
126ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc) 126ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc)
127{ 127{
128 size_t i; 128 size_t i;
diff --git a/src/lib/ecore_input/ecore_input_api.h b/src/lib/ecore_input/ecore_input_api.h
new file mode 100644
index 0000000000..d0c863d555
--- /dev/null
+++ b/src/lib/ecore_input/ecore_input_api.h
@@ -0,0 +1,34 @@
1#ifndef _EFL_ECORE_INPUT_API_H
2#define _EFL_ECORE_INPUT_API_H
3
4#ifdef ECORE_INPUT_API
5#error ECORE_INPUT_API should not be already defined
6#endif
7
8#ifdef _WIN32
9# ifndef ECORE_INPUT_STATIC
10# ifdef ECORE_INPUT_BUILD
11# define ECORE_INPUT_API __declspec(dllexport)
12# else
13# define ECORE_INPUT_API __declspec(dllimport)
14# endif
15# else
16# define ECORE_INPUT_API
17# endif
18# define ECORE_INPUT_API_WEAK
19#else
20# ifdef __GNUC__
21# if __GNUC__ >= 4
22# define ECORE_INPUT_API __attribute__ ((visibility("default")))
23# define ECORE_INPUT_API_WEAK __attribute__ ((weak))
24# else
25# define ECORE_INPUT_API
26# define ECORE_INPUT_API_WEAK
27# endif
28# else
29# define ECORE_INPUT_API
30# define ECORE_INPUT_API_WEAK
31# endif
32#endif
33
34#endif
diff --git a/src/lib/ecore_input/ecore_input_compose.c b/src/lib/ecore_input/ecore_input_compose.c
index 1c52f550dd..842e8352f3 100644
--- a/src/lib/ecore_input/ecore_input_compose.c
+++ b/src/lib/ecore_input/ecore_input_compose.c
@@ -16,7 +16,7 @@
16// isolate compose tree into its own file - hand crafted into static const c 16// isolate compose tree into its own file - hand crafted into static const c
17#include "ecore_input_compose.h" 17#include "ecore_input_compose.h"
18 18
19EAPI Ecore_Compose_State 19ECORE_INPUT_API Ecore_Compose_State
20ecore_compose_get(const Eina_List *seq, char **seqstr_ret) 20ecore_compose_get(const Eina_List *seq, char **seqstr_ret)
21{ 21{
22 const char *p, *pend; 22 const char *p, *pend;
diff --git a/src/lib/ecore_input/ecore_input_joystick.c b/src/lib/ecore_input/ecore_input_joystick.c
index 7793c3bf35..3ab6267c28 100644
--- a/src/lib/ecore_input/ecore_input_joystick.c
+++ b/src/lib/ecore_input/ecore_input_joystick.c
@@ -607,7 +607,7 @@ ecore_input_joystick_shutdown(void)
607 return _ecore_input_joystick_init_count; 607 return _ecore_input_joystick_init_count;
608} 608}
609 609
610EAPI void 610ECORE_INPUT_API void
611ecore_input_joystick_event_axis_deadzone_set(int event_axis_deadzone) 611ecore_input_joystick_event_axis_deadzone_set(int event_axis_deadzone)
612{ 612{
613 event_axis_deadzone = abs(event_axis_deadzone); 613 event_axis_deadzone = abs(event_axis_deadzone);
@@ -616,13 +616,13 @@ ecore_input_joystick_event_axis_deadzone_set(int event_axis_deadzone)
616 _event_axis_deadzone = event_axis_deadzone; 616 _event_axis_deadzone = event_axis_deadzone;
617} 617}
618 618
619EAPI int 619ECORE_INPUT_API int
620ecore_input_joystick_event_axis_deadzone_get(void) 620ecore_input_joystick_event_axis_deadzone_get(void)
621{ 621{
622 return _event_axis_deadzone; 622 return _event_axis_deadzone;
623} 623}
624 624
625EAPI const char * 625ECORE_INPUT_API const char *
626ecore_input_joystick_name_get(int index) 626ecore_input_joystick_name_get(int index)
627{ 627{
628#if defined(HAVE_EEZE) && defined(JSIOCGNAME) 628#if defined(HAVE_EEZE) && defined(JSIOCGNAME)
diff --git a/src/lib/ecore_input/meson.build b/src/lib/ecore_input/meson.build
index d1250c3591..f23bccd2aa 100644
--- a/src/lib/ecore_input/meson.build
+++ b/src/lib/ecore_input/meson.build
@@ -20,7 +20,7 @@ endif
20 20
21ecore_input_lib = library('ecore_input', 21ecore_input_lib = library('ecore_input',
22 ecore_input_src, pub_eo_file_target, 22 ecore_input_src, pub_eo_file_target,
23 c_args : package_c_args, 23 c_args : [package_c_args, '-DECORE_INPUT_BUILD'],
24 dependencies: ecore_input_pub_deps + ecore_input_deps + ecore_input_ext_deps, 24 dependencies: ecore_input_pub_deps + ecore_input_deps + ecore_input_ext_deps,
25 include_directories : config_dir, 25 include_directories : config_dir,
26 install: true, 26 install: true,