diff options
author | Cedric Bail <cedric@osg.samsung.com> | 2017-10-27 15:34:50 -0700 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2017-10-30 15:52:44 +0900 |
commit | 0607aace83dec2c2e2a53cdb49877ea160260a75 (patch) | |
tree | 8905f82d6517d0730601cdb72669784130eb5a8d | |
parent | 87a65b112f72b925962a744c9f6d05096fb2b995 (diff) | |
download | efl-0607aace83dec2c2e2a53cdb49877ea160260a75.tar.gz |
ecore: add infrastructure to handle an Eina_Value as an exit code.
-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" { #include "efl_loop.eo.h" +EAPI int efl_loop_exit_code_process(Eina_Value *value); + #include "efl_loop_user.eo.h" 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 return efl_provider_find(efl_super(obj, EFL_LOOP_CLASS), klass); } +EAPI int +efl_loop_exit_code_process(Eina_Value *value) +{ + const Eina_Value_Type *t = eina_value_type_get(value); + int r = 0; + + if (t == EINA_VALUE_TYPE_UCHAR || + t == EINA_VALUE_TYPE_USHORT || + t == EINA_VALUE_TYPE_UINT || + t == EINA_VALUE_TYPE_ULONG || + t == EINA_VALUE_TYPE_UINT64 || + t == EINA_VALUE_TYPE_CHAR || + t == EINA_VALUE_TYPE_SHORT || + t == EINA_VALUE_TYPE_INT || + t == EINA_VALUE_TYPE_LONG || + t == EINA_VALUE_TYPE_INT64 || + t == EINA_VALUE_TYPE_FLOAT || + t == EINA_VALUE_TYPE_DOUBLE) + { + Eina_Value v = EINA_VALUE_EMPTY; + + eina_value_setup(&v, EINA_VALUE_TYPE_INT); + if (!eina_value_convert(&v, value)) + r = -1; + else + eina_value_get(&v, &v); + } + else + { + FILE *out = stdout; + char *msg; + + msg = eina_value_to_string(value); + + if (t == EINA_VALUE_TYPE_ERROR) + { + r = -1; + out = stderr; + } + + fprintf(out, "%s\n", msg); + } + + return r; +} + static void _poll_trigger(void *data, const Efl_Event *event) { |