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)
downloadefl-d924100b42be59d50152fda4ad2591a5fc275db7.tar.gz
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 @@
#include <Eo.h>
-#ifdef EAPI
-# undef EAPI
-#endif
-
-#ifdef _WIN32
-# ifdef EFL_BUILD
-# ifdef DLL_EXPORT
-# define EAPI __declspec(dllexport)
-# else
-# define EAPI
-# endif
-# else
-# define EAPI __declspec(dllimport)
-# endif
-#else
-# ifdef __GNUC__
-# if __GNUC__ >= 4
-# define EAPI __attribute__ ((visibility("default")))
-# else
-# define EAPI
-# endif
-# else
-# define EAPI
-# endif
-#endif
+#include <ecore_input_api.h>
#ifdef __cplusplus
extern "C" {
@@ -47,17 +23,17 @@ extern "C" {
*
*@{
*/
- EAPI extern int ECORE_EVENT_KEY_DOWN;
- EAPI extern int ECORE_EVENT_KEY_UP;
- EAPI extern int ECORE_EVENT_MOUSE_BUTTON_DOWN;
- EAPI extern int ECORE_EVENT_MOUSE_BUTTON_UP;
- EAPI extern int ECORE_EVENT_MOUSE_MOVE;
- EAPI extern int ECORE_EVENT_MOUSE_WHEEL;
- EAPI extern int ECORE_EVENT_MOUSE_IN;
- EAPI extern int ECORE_EVENT_MOUSE_OUT;
- EAPI extern int ECORE_EVENT_AXIS_UPDATE; /**< @since 1.13 */
- EAPI extern int ECORE_EVENT_MOUSE_BUTTON_CANCEL; /**< @since 1.15 */
- EAPI extern int ECORE_EVENT_JOYSTICK; /**< @since 1.18 */
+ ECORE_INPUT_API extern int ECORE_EVENT_KEY_DOWN;
+ ECORE_INPUT_API extern int ECORE_EVENT_KEY_UP;
+ ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_BUTTON_DOWN;
+ ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_BUTTON_UP;
+ ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_MOVE;
+ ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_WHEEL;
+ ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_IN;
+ ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_OUT;
+ ECORE_INPUT_API extern int ECORE_EVENT_AXIS_UPDATE; /**< @since 1.13 */
+ ECORE_INPUT_API extern int ECORE_EVENT_MOUSE_BUTTON_CANCEL; /**< @since 1.15 */
+ ECORE_INPUT_API extern int ECORE_EVENT_JOYSTICK; /**< @since 1.18 */
#define ECORE_EVENT_MODIFIER_SHIFT 0x0001
#define ECORE_EVENT_MODIFIER_CTRL 0x0002
@@ -418,11 +394,11 @@ extern "C" {
/**
* Initializes the Ecore Event system.
*/
- EAPI int ecore_event_init(void);
+ ECORE_INPUT_API int ecore_event_init(void);
/**
* Shutdowns the Ecore Event system.
*/
- EAPI int ecore_event_shutdown(void);
+ ECORE_INPUT_API int ecore_event_shutdown(void);
/**
* Returns the Ecore modifier event integer associated to a
@@ -432,7 +408,7 @@ extern "C" {
* @return A event_modifier integer that matches with the provided modifier
* event.
*/
- EAPI unsigned int ecore_event_modifier_mask(Ecore_Event_Modifier modifier);
+ ECORE_INPUT_API unsigned int ecore_event_modifier_mask(Ecore_Event_Modifier modifier);
/**
* Update a Ecore_Event_Modifiers array with "key" modifier.
@@ -444,7 +420,7 @@ extern "C" {
* @return ECORE_NONE if the key does not match with an existing one, else
* the corresponding Ecore_Event_Modifier.
*/
- EAPI Ecore_Event_Modifier ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc);
+ ECORE_INPUT_API Ecore_Event_Modifier ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc);
/**
* Handles a sequence of key symbols to make a final compose string.
@@ -456,7 +432,7 @@ extern "C" {
* @param seqstr_ret The final compose string.
* @return The status of the composition.
*/
- EAPI Ecore_Compose_State ecore_compose_get(const Eina_List *seq, char **seqstr_ret);
+ ECORE_INPUT_API Ecore_Compose_State ecore_compose_get(const Eina_List *seq, char **seqstr_ret);
/**
* Set deadzone of joystick event for an axis.
@@ -469,7 +445,7 @@ extern "C" {
* @param event_axis_deadzone The joystick event axis deadzone.
* @since 1.19
*/
- EAPI void ecore_input_joystick_event_axis_deadzone_set(int event_axis_deadzone);
+ ECORE_INPUT_API void ecore_input_joystick_event_axis_deadzone_set(int event_axis_deadzone);
/**
* Get deadzone of joystick event for an axis.
@@ -477,7 +453,7 @@ extern "C" {
* @return deadzone of joystick event for an axis.
* @since 1.19
*/
- EAPI int ecore_input_joystick_event_axis_deadzone_get(void);
+ ECORE_INPUT_API int ecore_input_joystick_event_axis_deadzone_get(void);
/**
* Get name of joystick
@@ -489,13 +465,10 @@ extern "C" {
* @return name of joystick.
* @since 1.20
*/
- EAPI const char *ecore_input_joystick_name_get(int index);
+ ECORE_INPUT_API const char *ecore_input_joystick_name_get(int index);
#ifdef __cplusplus
}
#endif
-#undef EAPI
-#define EAPI
-
/** @} */
#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 @@
int _ecore_input_log_dom = -1;
-EAPI int ECORE_EVENT_KEY_DOWN = 0;
-EAPI int ECORE_EVENT_KEY_UP = 0;
-EAPI int ECORE_EVENT_MOUSE_BUTTON_DOWN = 0;
-EAPI int ECORE_EVENT_MOUSE_BUTTON_UP = 0;
-EAPI int ECORE_EVENT_MOUSE_MOVE = 0;
-EAPI int ECORE_EVENT_MOUSE_WHEEL = 0;
-EAPI int ECORE_EVENT_MOUSE_IN = 0;
-EAPI int ECORE_EVENT_MOUSE_OUT = 0;
-EAPI int ECORE_EVENT_AXIS_UPDATE = 0;
-EAPI int ECORE_EVENT_MOUSE_BUTTON_CANCEL = 0;
-EAPI int ECORE_EVENT_JOYSTICK = 0;
+ECORE_INPUT_API int ECORE_EVENT_KEY_DOWN = 0;
+ECORE_INPUT_API int ECORE_EVENT_KEY_UP = 0;
+ECORE_INPUT_API int ECORE_EVENT_MOUSE_BUTTON_DOWN = 0;
+ECORE_INPUT_API int ECORE_EVENT_MOUSE_BUTTON_UP = 0;
+ECORE_INPUT_API int ECORE_EVENT_MOUSE_MOVE = 0;
+ECORE_INPUT_API int ECORE_EVENT_MOUSE_WHEEL = 0;
+ECORE_INPUT_API int ECORE_EVENT_MOUSE_IN = 0;
+ECORE_INPUT_API int ECORE_EVENT_MOUSE_OUT = 0;
+ECORE_INPUT_API int ECORE_EVENT_AXIS_UPDATE = 0;
+ECORE_INPUT_API int ECORE_EVENT_MOUSE_BUTTON_CANCEL = 0;
+ECORE_INPUT_API int ECORE_EVENT_JOYSTICK = 0;
static int _ecore_event_init_count = 0;
-EAPI int
+ECORE_INPUT_API int
ecore_event_init(void)
{
if (++_ecore_event_init_count != 1)
@@ -64,7 +64,7 @@ ecore_event_init(void)
return _ecore_event_init_count;
}
-EAPI int
+ECORE_INPUT_API int
ecore_event_shutdown(void)
{
if (--_ecore_event_init_count != 0)
@@ -110,7 +110,7 @@ static const Ecore_Event_Modifier_Match matchs[] = {
{ "Scroll_Lock", ECORE_SCROLL, ECORE_EVENT_MODIFIER_SCROLL }
};
-EAPI unsigned int
+ECORE_INPUT_API unsigned int
ecore_event_modifier_mask(Ecore_Event_Modifier modifier)
{
size_t i;
@@ -122,7 +122,7 @@ ecore_event_modifier_mask(Ecore_Event_Modifier modifier)
return 0;
}
-EAPI Ecore_Event_Modifier
+ECORE_INPUT_API Ecore_Event_Modifier
ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc)
{
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 @@
+#ifndef _EFL_ECORE_INPUT_API_H
+#define _EFL_ECORE_INPUT_API_H
+
+#ifdef ECORE_INPUT_API
+#error ECORE_INPUT_API should not be already defined
+#endif
+
+#ifdef _WIN32
+# ifndef ECORE_INPUT_STATIC
+# ifdef ECORE_INPUT_BUILD
+# define ECORE_INPUT_API __declspec(dllexport)
+# else
+# define ECORE_INPUT_API __declspec(dllimport)
+# endif
+# else
+# define ECORE_INPUT_API
+# endif
+# define ECORE_INPUT_API_WEAK
+#else
+# ifdef __GNUC__
+# if __GNUC__ >= 4
+# define ECORE_INPUT_API __attribute__ ((visibility("default")))
+# define ECORE_INPUT_API_WEAK __attribute__ ((weak))
+# else
+# define ECORE_INPUT_API
+# define ECORE_INPUT_API_WEAK
+# endif
+# else
+# define ECORE_INPUT_API
+# define ECORE_INPUT_API_WEAK
+# endif
+#endif
+
+#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 @@
// isolate compose tree into its own file - hand crafted into static const c
#include "ecore_input_compose.h"
-EAPI Ecore_Compose_State
+ECORE_INPUT_API Ecore_Compose_State
ecore_compose_get(const Eina_List *seq, char **seqstr_ret)
{
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)
return _ecore_input_joystick_init_count;
}
-EAPI void
+ECORE_INPUT_API void
ecore_input_joystick_event_axis_deadzone_set(int event_axis_deadzone)
{
event_axis_deadzone = abs(event_axis_deadzone);
@@ -616,13 +616,13 @@ ecore_input_joystick_event_axis_deadzone_set(int event_axis_deadzone)
_event_axis_deadzone = event_axis_deadzone;
}
-EAPI int
+ECORE_INPUT_API int
ecore_input_joystick_event_axis_deadzone_get(void)
{
return _event_axis_deadzone;
}
-EAPI const char *
+ECORE_INPUT_API const char *
ecore_input_joystick_name_get(int index)
{
#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
ecore_input_lib = library('ecore_input',
ecore_input_src, pub_eo_file_target,
- c_args : package_c_args,
+ c_args : [package_c_args, '-DECORE_INPUT_BUILD'],
dependencies: ecore_input_pub_deps + ecore_input_deps + ecore_input_ext_deps,
include_directories : config_dir,
install: true,