diff options
author | Cedric Bail <cedric@osg.samsung.com> | 2017-10-27 15:34:50 -0700 |
---|---|---|
committer | Cedric Bail <cedric@osg.samsung.com> | 2017-10-27 15:34:50 -0700 |
commit | 1451a2ee3f4feb0b9fb084ab3584fa1dd19cfa13 (patch) | |
tree | 0ab912b61b4f49960916c6c3973e8219ce9ab263 /src/lib | |
parent | 1c8225099414109c8360b078cc27410f2215040a (diff) |
ecore: add infrastructure to handle an Eina_Value as an exit code.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/ecore/Ecore_Eo.h | 2 | ||||
-rw-r--r-- | src/lib/ecore/ecore_main.c | 46 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h index ae04d6a671..f9b1428180 100644 --- a/src/lib/ecore/Ecore_Eo.h +++ b/src/lib/ecore/Ecore_Eo.h | |||
@@ -38,6 +38,8 @@ extern "C" { | |||
38 | 38 | ||
39 | #include "efl_loop.eo.h" | 39 | #include "efl_loop.eo.h" |
40 | 40 | ||
41 | EAPI int efl_loop_exit_code_process(Eina_Value *value); | ||
42 | |||
41 | #include "efl_loop_user.eo.h" | 43 | #include "efl_loop_user.eo.h" |
42 | 44 | ||
43 | EAPI Eina_Future_Scheduler *efl_loop_future_scheduler_get(Eo *obj); | 45 | EAPI Eina_Future_Scheduler *efl_loop_future_scheduler_get(Eo *obj); |
diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c index 149df63006..932744ba9e 100644 --- a/src/lib/ecore/ecore_main.c +++ b/src/lib/ecore/ecore_main.c | |||
@@ -2880,6 +2880,52 @@ _efl_loop_efl_object_provider_find(Eo *obj, Efl_Loop_Data *pd, const Efl_Object | |||
2880 | return efl_provider_find(efl_super(obj, EFL_LOOP_CLASS), klass); | 2880 | return efl_provider_find(efl_super(obj, EFL_LOOP_CLASS), klass); |
2881 | } | 2881 | } |
2882 | 2882 | ||
2883 | EAPI int | ||
2884 | efl_loop_exit_code_process(Eina_Value *value) | ||
2885 | { | ||
2886 | const Eina_Value_Type *t = eina_value_type_get(value); | ||
2887 | int r = 0; | ||
2888 | |||
2889 | if (t == EINA_VALUE_TYPE_UCHAR || | ||
2890 | t == EINA_VALUE_TYPE_USHORT || | ||
2891 | t == EINA_VALUE_TYPE_UINT || | ||
2892 | t == EINA_VALUE_TYPE_ULONG || | ||
2893 | t == EINA_VALUE_TYPE_UINT64 || | ||
2894 | t == EINA_VALUE_TYPE_CHAR || | ||
2895 | t == EINA_VALUE_TYPE_SHORT || | ||
2896 | t == EINA_VALUE_TYPE_INT || | ||
2897 | t == EINA_VALUE_TYPE_LONG || | ||
2898 | t == EINA_VALUE_TYPE_INT64 || | ||
2899 | t == EINA_VALUE_TYPE_FLOAT || | ||
2900 | t == EINA_VALUE_TYPE_DOUBLE) | ||
2901 | { | ||
2902 | Eina_Value v = EINA_VALUE_EMPTY; | ||
2903 | |||
2904 | eina_value_setup(&v, EINA_VALUE_TYPE_INT); | ||
2905 | if (!eina_value_convert(&v, value)) | ||
2906 | r = -1; | ||
2907 | else | ||
2908 | eina_value_get(&v, &v); | ||
2909 | } | ||
2910 | else | ||
2911 | { | ||
2912 | FILE *out = stdout; | ||
2913 | char *msg; | ||
2914 | |||
2915 | msg = eina_value_to_string(value); | ||
2916 | |||
2917 | if (t == EINA_VALUE_TYPE_ERROR) | ||
2918 | { | ||
2919 | r = -1; | ||
2920 | out = stderr; | ||
2921 | } | ||
2922 | |||
2923 | fprintf(out, "%s\n", msg); | ||
2924 | } | ||
2925 | |||
2926 | return r; | ||
2927 | } | ||
2928 | |||
2883 | static void | 2929 | static void |
2884 | _poll_trigger(void *data, const Efl_Event *event) | 2930 | _poll_trigger(void *data, const Efl_Event *event) |
2885 | { | 2931 | { |