ecore_eolian_files = \
lib/ecore/efl_loop.eo \
+ lib/ecore/efl_loop_args.eo \
lib/ecore/efl_loop_user.eo \
lib/ecore/efl_loop_fd.eo \
lib/ecore/ecore_parent.eo \
lib/ecore/ecore_idler.c \
lib/ecore/ecore_job.c \
lib/ecore/ecore_main.c \
+lib/ecore/efl_loop_args.c \
lib/ecore/efl_loop_user.c \
lib/ecore/efl_loop_fd.c \
lib/ecore/ecore_pipe.c \
#include "efl_loop.eo.h"
+#include "efl_loop_args.eo.h"
+
#include "efl_loop_user.eo.h"
#include "efl_loop_fd.eo.h"
}
static void
+_efl_loop_args_job_cb(void *data, void *value EINA_UNUSED,
+ Eina_Promise *promise EINA_UNUSED)
+{
+ Efl_Loop_Args *args = data;
+ Eo *obj = eo_parent_get(args);
+
+ eo_event_callback_call(obj, EFL_LOOP_EVENT_ARGS, args);
+ eo_unref(args); // FIXME: probably eo_del()
+}
+
+EOLIAN static void
+_efl_loop_args_add(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED, int argc, const char **argv)
+{
+ Eina_Promise *job;
+ Efl_Loop_Args *args = eo_add(EFL_LOOP_ARGS_CLASS, obj);
+
+ if (!args) return;
+ efl_loop_args_set(args, argc, argv);
+ job = efl_loop_job(obj, args);
+ eina_promise_then(job, _efl_loop_args_job_cb, NULL, args);
+}
+
+static void
_efl_loop_internal_cancel(Efl_Internal_Promise *p)
{
eina_promise_owner_error_set(p->promise, _promise_canceled);
@in data: const(void)* @optional; [[The data to be given when the promise is done.]]
}
return: promise<void*>; [[The promise that will be triggered.]]
-
+ }
+ args_add {
+ [[Add a new set of arguments to the loop that makes an args event.]]
+ params {
+ argc: int; [[The number of strings in the argv array.]]
+ argv: const(char)**; [[The array of argument strings.]]
+ }
}
}
events {
idle,enter @restart; [[Event occurs once the main loop enters the idle state.]]
idle,exit @restart; [[Event occurs once the main loop exits the idle state.]]
idle @restart; [[Event occurs once the main loop is idler. Be carefull, this will spin your CPU high if you keep listening on this event.]]
+ args: Efl.Loop.Args; [[Event happens when args are provided to the loop by args_add().]]
/* TODO: All of the legacy ecore events. (Ecore.h header) */
}
implements {
--- /dev/null
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <Ecore.h>
+
+#include "ecore_private.h"
+
+#define MY_CLASS EFL_LOOP_ARGS_CLASS
+
+typedef struct _Efl_Loop_Args_Data Efl_Loop_Args_Data;
+struct _Efl_Loop_Args_Data
+{
+ int argc;
+ const char **argv;
+};
+
+EOLIAN static void
+_efl_loop_args_args_set(Eo *obj EINA_UNUSED, Efl_Loop_Args_Data *pd, int argc, const char **argv)
+{
+ int i;
+
+ if (argc < 0) return;
+ for (i = 0; i < pd->argc; i++) eina_stringshare_del(pd->argv[i]);
+ free(pd->argv);
+ pd->argc = argc;
+ if (argc > 0)
+ {
+ pd->argv = malloc(argc * sizeof(const char *));
+ for (i = 0; i < argc; i++) pd->argv[i] = eina_stringshare_add(argv[i]);
+ }
+}
+
+EOLIAN static int
+_efl_loop_args_arg_num_get(Eo *obj EINA_UNUSED, Efl_Loop_Args_Data *pd)
+{
+ return pd->argc;
+}
+
+EOLIAN const char *
+_efl_loop_args_arg_get(Eo *obj EINA_UNUSED, Efl_Loop_Args_Data *pd, int num)
+{
+ if ((num < 0) || (num >= pd->argc)) return NULL;
+ return pd->argv[num];
+}
+
+EOLIAN static void
+_efl_loop_args_eo_base_destructor(Eo *obj EINA_UNUSED, Efl_Loop_Args_Data *pd)
+{
+ int i;
+
+ for (i = 0; i < pd->argc; i++) eina_stringshare_del(pd->argv[i]);
+ free(pd->argv);
+ pd->argv = NULL;
+ pd->argc = 0;
+ eo_destructor(eo_super(obj, MY_CLASS));
+}
+
+#include "efl_loop_args.eo.c"
--- /dev/null
+class Efl.Loop.Args (Eo.Base)
+{
+ [[The object holding arguments provided to the loop.]]
+ methods {
+ args_set {
+ [[Add a new set of arguments to the loop that makes an args event.]]
+ params {
+ argc: int; [[The number of strings in the argv array.]]
+ argv: const(char)**; [[The array of argument strings.]]
+ }
+ }
+ arg_num_get {
+ return: int; [[The number of argument strings.]]
+ }
+ arg_get {
+ params {
+ num: int; [[The argument number to get.]]
+ }
+ return: const(char)*; [[The argument string.]]
+ }
+ }
+ implements {
+ Eo.Base.destructor;
+ }
+}