cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=1451a2ee3f4feb0b9fb084ab3584fa1dd19cfa13

commit 1451a2ee3f4feb0b9fb084ab3584fa1dd19cfa13
Author: Cedric Bail <[email protected]>
Date:   Fri Oct 27 15:34:50 2017 -0700

    ecore: add infrastructure to handle an Eina_Value as an exit code.
---
 src/lib/ecore/Ecore_Eo.h   |  2 ++
 src/lib/ecore/ecore_main.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

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)
 {

-- 


Reply via email to