Compare commits
9 Commits
master
...
devs/stefa
Author | SHA1 | Date |
---|---|---|
Stefan Schmidt | 2f7a73da91 | |
Stefan Schmidt | cf93872cdc | |
Stefan Schmidt | a5dd438d4a | |
Stefan Schmidt | 8e3ea1c9ea | |
Stefan Schmidt | 3f5204d2f7 | |
Stefan Schmidt | 4b66236c82 | |
Stefan Schmidt | be85c583bd | |
Stefan Schmidt | 1f7dca7733 | |
Stefan Schmidt | 81f5e7ed43 |
12
.travis.yml
12
.travis.yml
|
@ -76,7 +76,6 @@ jobs:
|
|||
if: type = cron
|
||||
env: DISTRO=Fedora31 CI_BUILD_TYPE=asan
|
||||
- os: linux
|
||||
if: type = cron
|
||||
env: DISTRO=Fedora31-exactness CI_BUILD_TYPE=exactness
|
||||
- os: linux
|
||||
if: type = cron
|
||||
|
@ -132,14 +131,3 @@ before_cache:
|
|||
mv $HOME/Library/Caches/Homebrew $HOME/cachedir/Homebrew
|
||||
fi
|
||||
|
||||
notifications:
|
||||
irc:
|
||||
channels:
|
||||
- "chat.freenode.net#edevelop"
|
||||
on_success: change
|
||||
on_failure: always
|
||||
template:
|
||||
- "TravisCI build %{build_number} in branch %{branch}: %{result} - %{message} (%{elapsed_time})"
|
||||
- "Commit: %{commit_subject} (%{commit}) from %{author}"
|
||||
- "Change view : %{compare_url}"
|
||||
- "Build details : %{build_url}"
|
||||
|
|
|
@ -335,7 +335,7 @@ subprojects = [
|
|||
['elua' ,['elua'] , false, true, true, false, true, false, ['eina', 'luajit'], []],
|
||||
['ecore_wayland' ,['wl-deprecated'] , false, true, false, false, false, false, ['eina'], []],
|
||||
['ecore_drm' ,['drm-deprecated'] , false, true, false, false, false, false, ['eina'], []],
|
||||
['exactness' ,[] , false, true, true, false, false, false, ['eina, evas, eet'], []],
|
||||
['exactness' ,[] , false, false, true, false, false, false, ['eina, evas, eet'], []],
|
||||
]
|
||||
|
||||
# We generate Efl_Config.h and config.h later, they will be available here
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
|
||||
static int _verbose = 0;
|
||||
|
@ -12,3 +16,490 @@ ex_printf(int verbose, const char *fmt, ...)
|
|||
vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
int
|
||||
ex_prg_invoke(const char *full_path, int argc, char **argv, Eina_Bool player)
|
||||
{
|
||||
Eina_Value *ret__;
|
||||
int real__;
|
||||
|
||||
void (*efl_main)(void *data, const Efl_Event *ev);
|
||||
int (*elm_main)(int argc, char **argv);
|
||||
int (*c_main)(int argc, char **argv);
|
||||
Eina_Module *h = eina_module_new(full_path);
|
||||
if (!h || !eina_module_load(h))
|
||||
{
|
||||
fprintf(stderr, "Failed loading %s.\n", full_path);
|
||||
if (h) eina_module_free(h);
|
||||
return 1;
|
||||
}
|
||||
efl_main = eina_module_symbol_get(h, "efl_main");
|
||||
elm_main = eina_module_symbol_get(h, "elm_main");
|
||||
c_main = eina_module_symbol_get(h, "main");
|
||||
_evas_new = eina_module_symbol_get(h, "evas_new");
|
||||
if (!_evas_new)
|
||||
{
|
||||
fprintf(stderr, "Failed loading symbol 'evas_new' from %s.\n", full_path);
|
||||
eina_module_free(h);
|
||||
return 1;
|
||||
}
|
||||
if (efl_main)
|
||||
{
|
||||
elm_init(argc, argv);
|
||||
if (player) elm_theme_overlay_add(NULL, DATA_DIR"/exactness_play.edj");
|
||||
efl_event_callback_add(efl_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL);
|
||||
ret__ = efl_loop_begin(efl_main_loop_get());
|
||||
real__ = efl_loop_exit_code_process(ret__);
|
||||
elm_shutdown();
|
||||
}
|
||||
else if (elm_main)
|
||||
{
|
||||
elm_init(argc, argv);
|
||||
if (player) elm_theme_overlay_add(NULL, DATA_DIR"/exactness_play.edj");
|
||||
real__ = elm_main(argc, argv);
|
||||
elm_shutdown();
|
||||
}
|
||||
else if (c_main)
|
||||
{
|
||||
real__ = c_main(argc, argv);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Failed loading symbol 'efl_main', 'elm_main' or 'main' from %s.\n", full_path);
|
||||
eina_module_free(h);
|
||||
real__ = 1;
|
||||
}
|
||||
return real__;
|
||||
}
|
||||
|
||||
Eina_Stringshare *
|
||||
ex_prg_full_path_guess(const char *prg)
|
||||
{
|
||||
char full_path[PATH_MAX];
|
||||
if (strchr(prg, '/')) return eina_stringshare_add(prg);
|
||||
char *env_path = eina_strdup(getenv("PATH"));
|
||||
Eina_Stringshare *ret = NULL;
|
||||
char *paths = env_path;
|
||||
|
||||
while (paths && *paths && !ret)
|
||||
{
|
||||
char *real_path;
|
||||
char *colon = strchr(paths, ':');
|
||||
if (colon) *colon = '\0';
|
||||
|
||||
sprintf(full_path, "%s/%s", paths, prg);
|
||||
real_path = ecore_file_realpath(full_path);
|
||||
if (*real_path)
|
||||
{
|
||||
ret = eina_stringshare_add(real_path);
|
||||
// check if executable
|
||||
}
|
||||
free(real_path);
|
||||
|
||||
paths += strlen(paths);
|
||||
if (colon) paths++;
|
||||
}
|
||||
free(env_path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef struct _Dummy
|
||||
{
|
||||
} _Dummy;
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_mouse_wheel_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Mouse_Wheel);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "direction", direction, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "z", z, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_key_down_up_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Key_Down_Up);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keyname", keyname, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "key", key, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "string", string, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "compose", compose, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keycode", keycode, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_multi_event_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Event);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "d", d, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "b", b, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "x", x, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "y", y, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rad", rad, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "radx", radx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rady", rady, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "pres", pres, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "ang", ang, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fx", fx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fy", fy, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "flags", flags, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_multi_move_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Move);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "d", d, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "x", x, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "y", y, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rad", rad, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "radx", radx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rady", rady, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "pres", pres, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "ang", ang, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fx", fx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fy", fy, EET_T_DOUBLE);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_efl_event_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Efl_Event);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "wdg_name", wdg_name, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "event_name", event_name, EET_T_STRING);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_click_on_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Click_On);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Click_On, "wdg_name", wdg_name, EET_T_STRING);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_dummy_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, _Dummy);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
/* !!! SAME ORDER AS Exactness_Action_Type */
|
||||
static const char *_mapping[] =
|
||||
{
|
||||
"",
|
||||
"exactness_action_mouse_in",
|
||||
"exactness_action_mouse_out",
|
||||
"exactness_action_mouse_wheel",
|
||||
"exactness_action_multi_down",
|
||||
"exactness_action_multi_up",
|
||||
"exactness_action_multi_move",
|
||||
"exactness_action_key_down",
|
||||
"exactness_action_key_up",
|
||||
"exactness_action_take_shot",
|
||||
"exactness_action_efl_event",
|
||||
"exactness_action_click_on",
|
||||
"exactness_action_stabilize"
|
||||
};
|
||||
|
||||
const char *
|
||||
_exactness_action_type_to_string_get(Exactness_Action_Type type)
|
||||
{
|
||||
if (type <= EXACTNESS_ACTION_LAST) return _mapping[type];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_variant_type_get(const void *data, Eina_Bool *unknow)
|
||||
{
|
||||
const Exactness_Action *act = data;
|
||||
|
||||
if (unknow) *unknow = EINA_FALSE;
|
||||
if (act->type <= EXACTNESS_ACTION_LAST) return _mapping[act->type];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_variant_type_set(const char *type,
|
||||
void *data,
|
||||
Eina_Bool unknow EINA_UNUSED)
|
||||
{
|
||||
int i;
|
||||
Exactness_Action *act = data;
|
||||
for (i = 0; i <= EXACTNESS_ACTION_LAST; i++)
|
||||
{
|
||||
if (!strcmp(_mapping[i], type)) act->type = i;
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_unit_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
static Eet_Data_Descriptor *unit_d = NULL;
|
||||
static Eet_Data_Descriptor *action_d = NULL, *action_variant_d = NULL;
|
||||
static Eet_Data_Descriptor *objs_d = NULL;
|
||||
static Eet_Data_Descriptor *obj_d = NULL;
|
||||
if (!obj_d)
|
||||
{
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Object);
|
||||
obj_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "kl_name", kl_name, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "id", id, EET_T_ULONG_LONG);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "parent_id", parent_id, EET_T_ULONG_LONG);
|
||||
/* Evas stuff */
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "x", x, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "y", y, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "w", w, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "h", h, EET_T_INT);
|
||||
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Objects);
|
||||
objs_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(objs_d, Exactness_Objects, "objs", objs, obj_d);
|
||||
}
|
||||
if (!unit_d)
|
||||
{
|
||||
Eet_Data_Descriptor *code_d = NULL;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Source_Code);
|
||||
code_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "language", language, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "content", content, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "command", command, EET_T_STRING);
|
||||
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action);
|
||||
action_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
|
||||
eddc.func.type_get = _variant_type_get;
|
||||
eddc.func.type_set = _variant_type_set;
|
||||
action_variant_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MOUSE_IN], _dummy_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MOUSE_OUT], _dummy_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MOUSE_WHEEL], _mouse_wheel_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MULTI_DOWN], _multi_event_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MULTI_UP], _multi_event_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MULTI_MOVE], _multi_move_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_KEY_DOWN], _key_down_up_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_KEY_UP], _key_down_up_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_TAKE_SHOT], _dummy_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_EFL_EVENT], _efl_event_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_CLICK_ON], _click_on_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_STABILIZE], _dummy_desc_make());
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "n_evas", n_evas, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "delay_ms", delay_ms, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_VARIANT(action_d, Exactness_Action, "data", data, type, action_variant_d);
|
||||
|
||||
/* Exactness_Unit */
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Unit);
|
||||
unit_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "actions", actions, action_d);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "objs", objs, objs_d);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "codes", codes, code_d);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "fonts_path", fonts_path, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "nb_shots", nb_shots, EET_T_UINT);
|
||||
}
|
||||
|
||||
return unit_d;
|
||||
}
|
||||
/* END Event struct descriptors */
|
||||
|
||||
Exactness_Unit *
|
||||
exactness_unit_file_read(const char *filename)
|
||||
{
|
||||
int i;
|
||||
Eina_List *itr, *itr2;
|
||||
Exactness_Objects *e_objs;
|
||||
Exactness_Object *e_obj, *e_parent;
|
||||
Exactness_Unit *unit = NULL;
|
||||
Eet_File *file;
|
||||
eet_init();
|
||||
file = eet_open(filename, EET_FILE_MODE_READ);
|
||||
if (!file)
|
||||
{
|
||||
fprintf(stderr, "Impossible to extract EET from %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
unit = eet_data_read(file, _unit_desc_make(), "cache");
|
||||
for (i = 0; i < unit->nb_shots; i++)
|
||||
{
|
||||
char entry[32];
|
||||
Exactness_Image *ex_img = malloc(sizeof(*ex_img));
|
||||
sprintf(entry, "images/%d", i + 1);
|
||||
ex_img->pixels = eet_data_image_read(file, entry,
|
||||
&ex_img->w, &ex_img->h, NULL,
|
||||
NULL, NULL, NULL);
|
||||
unit->imgs = eina_list_append(unit->imgs, ex_img);
|
||||
}
|
||||
EINA_LIST_FOREACH(unit->objs, itr, e_objs)
|
||||
{
|
||||
Eina_Hash *hash = eina_hash_pointer_new(NULL);
|
||||
EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj)
|
||||
{
|
||||
eina_hash_set(hash, &(e_obj->id), e_obj);
|
||||
}
|
||||
EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj)
|
||||
{
|
||||
if (!e_obj->parent_id)
|
||||
e_objs->main_objs = eina_list_append(e_objs->main_objs, e_obj);
|
||||
else
|
||||
{
|
||||
e_parent = eina_hash_find(hash, &(e_obj->parent_id));
|
||||
if (e_parent) e_parent->children = eina_list_append(e_parent->children, e_obj);
|
||||
}
|
||||
}
|
||||
eina_hash_free(hash);
|
||||
}
|
||||
eet_close(file);
|
||||
eet_shutdown();
|
||||
return unit;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
exactness_unit_file_write(Exactness_Unit *unit, const char *filename)
|
||||
{
|
||||
Eina_List *itr;
|
||||
Exactness_Image *ex_img;
|
||||
Eet_File *file;
|
||||
int i = 1;
|
||||
eet_init();
|
||||
file = eet_open(filename, EET_FILE_MODE_WRITE);
|
||||
eet_data_write(file, _unit_desc_make(), "cache", unit, EINA_TRUE);
|
||||
EINA_LIST_FOREACH(unit->imgs, itr, ex_img)
|
||||
{
|
||||
char entry[32];
|
||||
sprintf(entry, "images/%d", i++);
|
||||
eet_data_image_write(file, entry,
|
||||
ex_img->pixels, ex_img->w, ex_img->h, 0xFF,
|
||||
0, 100, EET_IMAGE_LOSSLESS);
|
||||
}
|
||||
eet_close(file);
|
||||
eet_shutdown();
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **imgO)
|
||||
{
|
||||
unsigned int w, h;
|
||||
int *pxs1, *pxs2, *pxsO = NULL;
|
||||
unsigned int w1 = img1 ? img1->w : 0, h1 = img1 ? img1->h : 0;
|
||||
unsigned int w2 = img2 ? img2->w : 0, h2 = img2 ? img2->h : 0;
|
||||
unsigned int wO = MAX(w1, w2);
|
||||
unsigned int hO = MAX(h1, h2);
|
||||
Eina_Bool ret = EINA_FALSE;
|
||||
if (imgO) *imgO = NULL;
|
||||
if (!wO || !hO) return EINA_FALSE;
|
||||
|
||||
pxs1 = img1 ? img1->pixels : NULL;
|
||||
pxs2 = img2 ? img2->pixels : NULL;
|
||||
if (imgO) pxsO = malloc(wO * hO * 4);
|
||||
|
||||
for (w = 0; w < wO; w++)
|
||||
{
|
||||
for (h = 0; h < hO; h++)
|
||||
{
|
||||
Eina_Bool valid1 = img1 ? w < w1 && h < h1 : EINA_FALSE;
|
||||
Eina_Bool valid2 = img2 ? w < w2 && h < h2 : EINA_FALSE;
|
||||
int px1 = valid1 ? pxs1[h * w1 + w] : 0;
|
||||
int px2 = valid2 ? pxs2[h * w2 + w] : 0;
|
||||
int r1 = (px1 & 0x00FF0000) >> 16;
|
||||
int r2 = (px2 & 0x00FF0000) >> 16;
|
||||
int g1 = (px1 & 0x0000FF00) >> 8;
|
||||
int g2 = (px2 & 0x0000FF00) >> 8;
|
||||
int b1 = (px1 & 0x000000FF);
|
||||
int b2 = (px2 & 0x000000FF);
|
||||
int new_r, new_g, new_b;
|
||||
if (valid1 || valid2)
|
||||
{
|
||||
if (px1 != px2)
|
||||
{
|
||||
new_r = 0xFF;
|
||||
new_g = ((g1 + g2) >> 1) >> 2;
|
||||
new_b = ((b1 + b2) >> 1) >> 2;
|
||||
ret = EINA_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_r = (((r1 + r2) >> 1) >> 2) + 0xC0;
|
||||
new_g = (((g1 + g2) >> 1) >> 2) + 0xC0;
|
||||
new_b = (((b1 + b2) >> 1) >> 2) + 0xC0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
new_r = new_g = new_b = 0x0;
|
||||
}
|
||||
if (pxsO) pxsO[h * wO + w] = 0xFF000000 | new_r << 16 | new_g << 8 | new_b;
|
||||
}
|
||||
}
|
||||
if (imgO)
|
||||
{
|
||||
Exactness_Image *imgR = calloc(1, sizeof(Exactness_Image));
|
||||
*imgO = imgR;
|
||||
imgR->w = wO;
|
||||
imgR->h = hO;
|
||||
imgR->pixels = pxsO;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void exactness_image_free(Exactness_Image *img)
|
||||
{
|
||||
if (!img) return;
|
||||
free(img->pixels);
|
||||
free(img);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <Eet.h>
|
||||
#include <Evas.h>
|
||||
#include <Elementary.h>
|
||||
#include <Exactness.h>
|
||||
#include <exactness_private.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -97,4 +97,238 @@ foo(Eina_Debug_Session *session, int srcid, void *buffer, int size) \
|
|||
_buf += __len; \
|
||||
}
|
||||
|
||||
#define SHOT_DELIMITER '+'
|
||||
|
||||
/**
|
||||
* @page exactness_main Exactness
|
||||
*
|
||||
* @date 2018 (created)
|
||||
*
|
||||
* This page describes the public structures and APIs available for Exactness.
|
||||
*
|
||||
* @addtogroup Exactness
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Type
|
||||
* The type values for an Exactness action.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
EXACTNESS_ACTION_UNKNOWN = 0,
|
||||
EXACTNESS_ACTION_MOUSE_IN,
|
||||
EXACTNESS_ACTION_MOUSE_OUT,
|
||||
EXACTNESS_ACTION_MOUSE_WHEEL,
|
||||
EXACTNESS_ACTION_MULTI_DOWN,
|
||||
EXACTNESS_ACTION_MULTI_UP,
|
||||
EXACTNESS_ACTION_MULTI_MOVE,
|
||||
EXACTNESS_ACTION_KEY_DOWN,
|
||||
EXACTNESS_ACTION_KEY_UP,
|
||||
EXACTNESS_ACTION_TAKE_SHOT,
|
||||
EXACTNESS_ACTION_EFL_EVENT,
|
||||
EXACTNESS_ACTION_CLICK_ON,
|
||||
EXACTNESS_ACTION_STABILIZE,
|
||||
EXACTNESS_ACTION_LAST = EXACTNESS_ACTION_STABILIZE
|
||||
/* Add any supported actions here and update _LAST */
|
||||
} Exactness_Action_Type;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Mouse_Wheel
|
||||
* The type for the Exactness Mouse Wheel action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int direction;
|
||||
int z;
|
||||
} Exactness_Action_Mouse_Wheel;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Key_Down_Up
|
||||
* The type for the Exactness Key Down Up action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char *keyname;
|
||||
const char *key;
|
||||
const char *string;
|
||||
const char *compose;
|
||||
unsigned int keycode;
|
||||
} Exactness_Action_Key_Down_Up;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Multi_Event
|
||||
* The type for the Exactness Multi Event action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int d;
|
||||
int b; /* In case of simple mouse down/up, corresponds to the button */
|
||||
int x;
|
||||
int y;
|
||||
double rad;
|
||||
double radx;
|
||||
double rady;
|
||||
double pres;
|
||||
double ang;
|
||||
double fx;
|
||||
double fy;
|
||||
Evas_Button_Flags flags;
|
||||
} Exactness_Action_Multi_Event;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Multi_Move
|
||||
* The type for the Exactness Multi Move action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int d;
|
||||
int x;
|
||||
int y;
|
||||
double rad;
|
||||
double radx;
|
||||
double rady;
|
||||
double pres;
|
||||
double ang;
|
||||
double fx;
|
||||
double fy;
|
||||
} Exactness_Action_Multi_Move;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Efl_Event
|
||||
* The type for the Exactness EFL Event action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *wdg_name;
|
||||
char *event_name;
|
||||
} Exactness_Action_Efl_Event;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Click_On
|
||||
* The type for the Exactness Click on (widget) action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *wdg_name;
|
||||
} Exactness_Action_Click_On;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action
|
||||
* The type for the Exactness action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Exactness_Action_Type type; /**< The action type */
|
||||
unsigned int n_evas; /**< The evas number on which the action has to be applied */
|
||||
unsigned int delay_ms; /**< The delay (in ms) to wait for this action */
|
||||
void *data; /**< The specific action data */
|
||||
} Exactness_Action;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Object
|
||||
* The type for the Exactness object.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
long long id; /**< The Eo pointer */
|
||||
long long parent_id; /**< The Eo parent pointer */
|
||||
const char *kl_name; /**< The class name */
|
||||
|
||||
Eina_List *children; /* NOT EET */
|
||||
|
||||
/* Evas stuff */
|
||||
int x; /**< The X coordinate */
|
||||
int y; /**< The Y coordinate */
|
||||
int w; /**< The object width */
|
||||
int h; /**< The object height */
|
||||
} Exactness_Object;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Objects
|
||||
* The type for the Exactness objects list.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Eina_List *objs; /**< List of all the objects */
|
||||
/* main_objs not in EET */
|
||||
Eina_List *main_objs; /**< List of the main objects */
|
||||
} Exactness_Objects;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Image
|
||||
* The type for the Exactness Image.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned int w; /**< Width of the image */
|
||||
unsigned int h; /**< Height of the image */
|
||||
void *pixels; /**< Pixels of the image */
|
||||
} Exactness_Image;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *language; /**< String describing the language of the content e.g "C"...*/
|
||||
char *content; /**< Content used as source */
|
||||
char *command; /**< Command needed to generate the application from the content */
|
||||
} Exactness_Source_Code;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Eina_List *actions; /**< List of Exactness_Action */
|
||||
/* imgs not in EET */
|
||||
Eina_List *imgs; /**< List of Exactness_Image */
|
||||
Eina_List *objs; /**< List of Exactness_Objects */
|
||||
Eina_List *codes; /**< List of Exactness_Source_Code */
|
||||
const char *fonts_path; /**< Path to the fonts to use, relative to the fonts dir given in parameter to the player/recorder */
|
||||
int nb_shots; /**< The number of shots present in the unit */
|
||||
} Exactness_Unit;
|
||||
|
||||
Evas *(*_evas_new)(void);
|
||||
const char *_exactness_action_type_to_string_get(Exactness_Action_Type type);
|
||||
|
||||
/**
|
||||
* @brief Read an unit from a given file
|
||||
*
|
||||
* @param filename Name of the file containing the unit
|
||||
*
|
||||
* @return the unit
|
||||
*/
|
||||
Exactness_Unit *exactness_unit_file_read(const char *filename);
|
||||
|
||||
/**
|
||||
* @brief Write an unit into the given file
|
||||
*
|
||||
* @param unit Unit to store
|
||||
* @param filename Name of the file containing the unit
|
||||
*
|
||||
* @return EINA_TRUE on success, EINA_FALSE otherwise
|
||||
*/
|
||||
Eina_Bool exactness_unit_file_write(Exactness_Unit *unit, const char *filename);
|
||||
|
||||
/**
|
||||
* @brief Compare two images
|
||||
*
|
||||
* @param img1 first image
|
||||
* @param img2 second image
|
||||
* @param imgO pointer for the diff image. Can be NULL
|
||||
*
|
||||
* @return EINA_TRUE if the images are different, EINA_FALSE otherwise
|
||||
*/
|
||||
Eina_Bool exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **imgO);
|
||||
|
||||
/**
|
||||
* @brief Free the given image
|
||||
*
|
||||
* @param img the image
|
||||
*
|
||||
*/
|
||||
void exactness_image_free(Exactness_Image *img);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
void ex_printf(int verbose, const char *fmt, ...);
|
||||
int ex_prg_invoke(const char *full_path, int argc, char **argv, Eina_Bool player);
|
||||
Eina_Stringshare *ex_prg_full_path_guess(const char *prg);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <Ecore_Evas.h>
|
||||
#include <Ecore_File.h>
|
||||
|
||||
#include "exactness_private.h"
|
||||
#include "common.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -184,15 +183,6 @@ _run_test_compare(const List_Entry *ent)
|
|||
_exu_imgs_unpack(path, currentdir, ent->name);
|
||||
goto found;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(path, "%s/%s.rec", base_dir, ent->name);
|
||||
if (ecore_file_exists(path))
|
||||
{
|
||||
sprintf(origdir, "%s/%s", _dest_dir, ORIG_SUBDIR);
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
}
|
||||
found:
|
||||
do
|
||||
|
@ -226,12 +216,6 @@ _run_command_prepare(const List_Entry *ent, char *buf)
|
|||
is_exu = EINA_TRUE;
|
||||
sprintf(scn_path, "%s/%s.exu", base_dir, ent->name);
|
||||
if (ecore_file_exists(scn_path)) goto ok;
|
||||
else
|
||||
{
|
||||
is_exu = EINA_FALSE;
|
||||
sprintf(scn_path, "%s/%s.rec", base_dir, ent->name);
|
||||
if (ecore_file_exists(scn_path)) goto ok;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "Test %s not found in the provided base directories\n", ent->name);
|
||||
return EINA_FALSE;
|
||||
|
@ -432,7 +416,7 @@ static const Ecore_Getopt optdesc = {
|
|||
"A pixel perfect test suite for EFL based applications.",
|
||||
0,
|
||||
{
|
||||
ECORE_GETOPT_APPEND('b', "base-dir", "The location of the exu/rec files.", ECORE_GETOPT_TYPE_STR),
|
||||
ECORE_GETOPT_APPEND('b', "base-dir", "The location of the exu files.", ECORE_GETOPT_TYPE_STR),
|
||||
ECORE_GETOPT_STORE_STR('o', "output", "The location of the images."),
|
||||
ECORE_GETOPT_STORE_STR('w', "wrap", "Use a custom command to launch the tests (e.g valgrind)."),
|
||||
ECORE_GETOPT_STORE_USHORT('j', "jobs", "The number of jobs to run in parallel."),
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <Ecore_Getopt.h>
|
||||
#include <Elementary.h>
|
||||
|
||||
#include <Exactness.h>
|
||||
#include "common.h"
|
||||
|
||||
static Eina_Stringshare *_src_filename = NULL;
|
||||
|
@ -241,10 +240,6 @@ _src_open()
|
|||
{
|
||||
_src_unit = exactness_unit_file_read(_src_filename);
|
||||
}
|
||||
else if (!strcmp(_src_filename + strlen(_src_filename) - 4,".rec"))
|
||||
{
|
||||
_src_unit = legacy_rec_file_read(_src_filename);
|
||||
}
|
||||
if (!_src_unit) return EINA_FALSE;
|
||||
_cur_event_list = _src_unit->actions;
|
||||
Exactness_Action *act = eina_list_data_get(_cur_event_list);
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <Ecore_Getopt.h>
|
||||
#include <Ecore_Evas.h>
|
||||
#include <Elementary.h>
|
||||
#include <Exactness.h>
|
||||
#include <Efl_Ui.h>
|
||||
|
||||
#include "common.h"
|
||||
|
@ -1238,7 +1237,7 @@ _image_read(const char *filename)
|
|||
|
||||
static const Ecore_Getopt optdesc = {
|
||||
"exactness_inspect",
|
||||
"%prog [options] [<rec file> | <file1 file2>]",
|
||||
"%prog [options] [<exu file> | <file1 file2>]",
|
||||
NULL,
|
||||
"(C) 2016 Enlightenment",
|
||||
"BSD",
|
||||
|
@ -1310,7 +1309,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
if ((clean || delay || shot || list_get || stabilize || pack) && args == argc)
|
||||
{
|
||||
fprintf(stderr, "Expected scenario (.rec/.exu) as the last argument.\n");
|
||||
fprintf(stderr, "Expected scenario (.exu) as the last argument.\n");
|
||||
ecore_getopt_help(stderr, &optdesc);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1370,15 +1369,6 @@ main(int argc, char *argv[])
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(ext, ".rec"))
|
||||
{
|
||||
if (!unit) unit = legacy_rec_file_read(src_file);
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s - scenario already provided\n", src_file);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(ext, ".png"))
|
||||
{
|
||||
Exactness_Image *ex_img = _image_read(src_file);
|
||||
|
@ -1391,7 +1381,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Correct extension (.exu/.rec/.png) required\n");
|
||||
fprintf(stderr, "Correct extension (.exu/.png) required\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1423,16 +1413,6 @@ main(int argc, char *argv[])
|
|||
units_filenames = eina_list_append(units_filenames, argv[arg]);
|
||||
_units = eina_list_append(_units, ex_unit);
|
||||
}
|
||||
else if (!strcmp(ext, ".rec"))
|
||||
{
|
||||
Exactness_Unit *ex_unit = legacy_rec_file_read(argv[arg]);
|
||||
if (!ex_unit)
|
||||
{
|
||||
fprintf(stderr, "Issue while reading %s\n", argv[arg]);
|
||||
goto end;
|
||||
}
|
||||
_units = eina_list_append(_units, ex_unit);
|
||||
}
|
||||
else if (!strcmp(ext, ".png"))
|
||||
{
|
||||
Exactness_Unit *ex_unit = calloc(1, sizeof(*ex_unit));
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
exactness_bin = executable('exactness',
|
||||
[ 'exactness.c', 'common.c', 'common.h' ],
|
||||
dependencies: [ ecore, ecore_evas, ecore_file, elementary, exactness ],
|
||||
dependencies: [ ecore, ecore_evas, ecore_file, elementary],
|
||||
c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"',
|
||||
install: true,
|
||||
)
|
||||
|
||||
exactness_inject_bin = executable('exactness_inject',
|
||||
[ 'injector.c', 'common.c', 'common.h' ],
|
||||
dependencies: [ elementary, exactness ],
|
||||
dependencies: [ elementary ],
|
||||
c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"',
|
||||
install: true,
|
||||
)
|
||||
|
||||
exactness_inspect_bin = executable('exactness_inspect',
|
||||
[ 'inspect.c', 'common.c', 'common.h' ],
|
||||
dependencies: [ elementary, exactness ],
|
||||
dependencies: [ elementary ],
|
||||
c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"',
|
||||
install: true,
|
||||
)
|
||||
|
@ -32,14 +32,14 @@ edjs = custom_target('player_entry',
|
|||
|
||||
exactness_play_bin = executable('exactness_play',
|
||||
[ 'player.c', 'common.c', 'common.h', edjs ],
|
||||
dependencies: [ elementary, exactness ],
|
||||
dependencies: [ elementary ],
|
||||
c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"',
|
||||
install: true,
|
||||
)
|
||||
|
||||
exactness_record_bin = executable('exactness_record',
|
||||
[ 'recorder.c', 'common.c', 'common.h' ],
|
||||
dependencies: [ elementary, exactness ],
|
||||
dependencies: [ elementary ],
|
||||
c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"',
|
||||
install: true,
|
||||
)
|
||||
|
|
|
@ -27,9 +27,7 @@
|
|||
#include <Ecore_File.h>
|
||||
#include <Ecore_Con.h>
|
||||
#include <Elementary.h>
|
||||
#include <Exactness.h>
|
||||
|
||||
#include "exactness_private.h"
|
||||
#include "common.h"
|
||||
|
||||
#define CMD_LINE_MAX 256
|
||||
|
@ -56,7 +54,6 @@ static Exactness_Unit *_src_unit = NULL;
|
|||
static const char *_test_name = NULL;
|
||||
static int _verbose = 0;
|
||||
|
||||
static Evas *(*_evas_new)(void) = NULL;
|
||||
static Eina_List *_evas_list = NULL;
|
||||
|
||||
static Eina_List *_cur_event_list = NULL;
|
||||
|
@ -771,10 +768,6 @@ _src_open()
|
|||
{
|
||||
_src_unit = exactness_unit_file_read(_src_filename);
|
||||
}
|
||||
else if (_src_type == FTYPE_REC)
|
||||
{
|
||||
_src_unit = legacy_rec_file_read(_src_filename);
|
||||
}
|
||||
if (!_src_unit) return EINA_FALSE;
|
||||
if (_stabilize_shots)
|
||||
{
|
||||
|
@ -804,115 +797,6 @@ _src_open()
|
|||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
_prg_invoke(const char *full_path, int argc, char **argv)
|
||||
{
|
||||
Eina_Value *ret__;
|
||||
int real__;
|
||||
|
||||
void (*efl_main)(void *data, const Efl_Event *ev);
|
||||
int (*elm_main)(int argc, char **argv);
|
||||
int (*c_main)(int argc, char **argv);
|
||||
Eina_Module *h = eina_module_new(full_path);
|
||||
if (!h || !eina_module_load(h))
|
||||
{
|
||||
fprintf(stderr, "Failed loading %s.\n", full_path);
|
||||
if (h) eina_module_free(h);
|
||||
return 1;
|
||||
}
|
||||
efl_main = eina_module_symbol_get(h, "efl_main");
|
||||
elm_main = eina_module_symbol_get(h, "elm_main");
|
||||
c_main = eina_module_symbol_get(h, "main");
|
||||
_evas_new = eina_module_symbol_get(h, "evas_new");
|
||||
if (!_evas_new)
|
||||
{
|
||||
fprintf(stderr, "Failed loading symbol 'evas_new' from %s.\n", full_path);
|
||||
eina_module_free(h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (efl_main)
|
||||
{
|
||||
elm_init(argc, argv);
|
||||
elm_theme_overlay_add(NULL, DATA_DIR"/exactness_play.edj");
|
||||
efl_event_callback_add(efl_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL);
|
||||
ret__ = efl_loop_begin(efl_main_loop_get());
|
||||
real__ = efl_loop_exit_code_process(ret__);
|
||||
elm_shutdown();
|
||||
}
|
||||
else if (elm_main)
|
||||
{
|
||||
elm_init(argc, argv);
|
||||
elm_theme_overlay_add(NULL, DATA_DIR"/exactness_play.edj");
|
||||
real__ = elm_main(argc, argv);
|
||||
elm_shutdown();
|
||||
}
|
||||
else if (c_main)
|
||||
{
|
||||
real__ = c_main(argc, argv);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Failed loading symbol 'efl_main', 'elm_main' or 'main' from %s.\n", full_path);
|
||||
eina_module_free(h);
|
||||
real__ = 1;
|
||||
}
|
||||
|
||||
return real__;
|
||||
}
|
||||
|
||||
static Eina_Stringshare *
|
||||
_prg_full_path_guess(const char *prg)
|
||||
{
|
||||
char full_path[PATH_MAX];
|
||||
if (strchr(prg, '/')) return eina_stringshare_add(prg);
|
||||
char *env_path = eina_strdup(getenv("PATH"));
|
||||
Eina_Stringshare *ret = NULL;
|
||||
char *paths = env_path;
|
||||
|
||||
while (paths && *paths && !ret)
|
||||
{
|
||||
char *real_path;
|
||||
char *colon = strchr(paths, ':');
|
||||
if (colon) *colon = '\0';
|
||||
|
||||
sprintf(full_path, "%s/%s", paths, prg);
|
||||
real_path = ecore_file_realpath(full_path);
|
||||
if (*real_path)
|
||||
{
|
||||
ret = eina_stringshare_add(real_path);
|
||||
// check if executable
|
||||
}
|
||||
free(real_path);
|
||||
|
||||
paths += strlen(paths);
|
||||
if (colon) paths++;
|
||||
}
|
||||
free(env_path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_mkdir(const char *path, Eina_Bool skip_last)
|
||||
{
|
||||
if (!ecore_file_exists(path))
|
||||
{
|
||||
const char *cur = path + 1;
|
||||
do
|
||||
{
|
||||
char *slash = strchr(cur, '/');
|
||||
if (slash) *slash = '\0';
|
||||
else if (skip_last) return EINA_TRUE;
|
||||
if (!ecore_file_exists(path) && !ecore_file_mkdir(path)) return EINA_FALSE;
|
||||
if (slash) *slash = '/';
|
||||
if (slash) cur = slash + 1;
|
||||
else cur = NULL;
|
||||
}
|
||||
while (cur);
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_old_shots_rm_cb(const char *name, const char *path, void *data)
|
||||
{
|
||||
|
@ -995,7 +879,7 @@ static const Ecore_Getopt optdesc = {
|
|||
" Otherwise the given path is considered as a directory\n"
|
||||
" where shots will be stored.\n"
|
||||
" If omitted, the output type (exu or dir) is determined\n"
|
||||
" by the given test extension (resp. exu or rec)."),
|
||||
" by the given test extension"),
|
||||
ECORE_GETOPT_STORE_STR('t', "test", "Test to run on the given application"),
|
||||
ECORE_GETOPT_STORE_TRUE('s', "show-on-screen", "Show on screen."),
|
||||
ECORE_GETOPT_STORE_TRUE(0, "scan-objects", "Extract information of all the objects at every shot."),
|
||||
|
@ -1022,6 +906,7 @@ int main(int argc, char **argv)
|
|||
const char *chosen_fonts = NULL;
|
||||
Eina_Bool show_on_screen = EINA_FALSE;
|
||||
Eina_Bool want_quit = EINA_FALSE, external_injection = EINA_FALSE;
|
||||
_evas_new = NULL;
|
||||
|
||||
Ecore_Getopt_Value values[] = {
|
||||
ECORE_GETOPT_VALUE_STR(dest),
|
||||
|
@ -1076,16 +961,20 @@ int main(int argc, char **argv)
|
|||
if (!strcmp(_dest + strlen(_dest) - 4,".exu"))
|
||||
{
|
||||
_dest_type = FTYPE_EXU;
|
||||
if (!_mkdir(_dest, EINA_TRUE))
|
||||
/* Cut path at the beginning of the file name */
|
||||
char *file_start = strrchr(dest, '/');
|
||||
*file_start = '\0';
|
||||
|
||||
if (!ecore_file_mkpath(dest))
|
||||
{
|
||||
fprintf(stderr, "Path for %s cannot be created\n", _dest);
|
||||
fprintf(stderr, "Path for %s cannot be created\n", dest);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_dest_type = FTYPE_DIR;
|
||||
if (!_mkdir(_dest, EINA_FALSE))
|
||||
if (!ecore_file_mkpath(_dest))
|
||||
{
|
||||
fprintf(stderr, "Directory %s cannot be created\n", _dest);
|
||||
goto end;
|
||||
|
@ -1119,15 +1008,6 @@ int main(int argc, char **argv)
|
|||
_dest = "./output.exu";
|
||||
}
|
||||
}
|
||||
else if (!strcmp(_src_filename + strlen(_src_filename) - 4,".rec"))
|
||||
{
|
||||
_src_type = FTYPE_REC;
|
||||
if (_dest_type == FTYPE_UNKNOWN)
|
||||
{
|
||||
_dest_type = FTYPE_DIR;
|
||||
_dest = ".";
|
||||
}
|
||||
}
|
||||
char *slash = strrchr(_src_filename, '/');
|
||||
if (slash) _test_name = strdup(slash + 1);
|
||||
else _test_name = strdup(_src_filename);
|
||||
|
@ -1255,7 +1135,7 @@ int main(int argc, char **argv)
|
|||
ecore_evas_callback_new_set(_my_evas_new);
|
||||
if (_src_type != FTYPE_REMOTE)
|
||||
ecore_idler_add(_src_feed, NULL);
|
||||
pret = _prg_invoke(_prg_full_path_guess(argv[0]), argc - opt_args, argv);
|
||||
pret = ex_prg_invoke(ex_prg_full_path_guess(argv[0]), argc - opt_args, argv, EINA_TRUE);
|
||||
|
||||
if (_dest && _dest_unit)
|
||||
{
|
||||
|
@ -1263,7 +1143,6 @@ int main(int argc, char **argv)
|
|||
{
|
||||
Exactness_Unit *tmp = NULL;
|
||||
if (_src_type == FTYPE_EXU) tmp = exactness_unit_file_read(_src_filename);
|
||||
if (_src_type == FTYPE_REC) tmp = legacy_rec_file_read(_src_filename);
|
||||
_dest_unit->actions = tmp->actions;
|
||||
_dest_unit->codes = tmp->codes;
|
||||
}
|
||||
|
|
|
@ -20,16 +20,13 @@
|
|||
#include <Ecore_Getopt.h>
|
||||
#include <Ecore_Con.h>
|
||||
#include <Elementary.h>
|
||||
#include <Exactness.h>
|
||||
|
||||
#include <exactness_private.h>
|
||||
#include "common.h"
|
||||
|
||||
#define STABILIZE_KEY_STR "F1"
|
||||
#define SHOT_KEY_STR "F2"
|
||||
#define SAVE_KEY_STR "F3"
|
||||
|
||||
static Evas *(*_evas_new)(void) = NULL;
|
||||
static const char *_out_filename = NULL;
|
||||
static const char *_test_name = NULL;
|
||||
static int _verbose = 0;
|
||||
|
@ -236,110 +233,6 @@ _my_evas_new(int w EINA_UNUSED, int h EINA_UNUSED)
|
|||
return e;
|
||||
}
|
||||
|
||||
static int
|
||||
_prg_invoke(const char *full_path, int argc, char **argv)
|
||||
{
|
||||
Eina_Value *ret__;
|
||||
int real__;
|
||||
|
||||
void (*efl_main)(void *data, const Efl_Event *ev);
|
||||
int (*elm_main)(int argc, char **argv);
|
||||
int (*c_main)(int argc, char **argv);
|
||||
Eina_Module *h = eina_module_new(full_path);
|
||||
if (!h || !eina_module_load(h))
|
||||
{
|
||||
fprintf(stderr, "Failed loading %s.\n", full_path);
|
||||
if (h) eina_module_free(h);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
efl_main = eina_module_symbol_get(h, "efl_main");
|
||||
elm_main = eina_module_symbol_get(h, "elm_main");
|
||||
c_main = eina_module_symbol_get(h, "main");
|
||||
_evas_new = eina_module_symbol_get(h, "evas_new");
|
||||
if (!_evas_new)
|
||||
{
|
||||
fprintf(stderr, "Failed loading symbol 'evas_new' from %s.\n", full_path);
|
||||
eina_module_free(h);
|
||||
return 1;
|
||||
}
|
||||
if (efl_main)
|
||||
{
|
||||
elm_init(argc, argv);
|
||||
efl_event_callback_add(efl_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL);
|
||||
ret__ = efl_loop_begin(efl_main_loop_get());
|
||||
real__ = efl_loop_exit_code_process(ret__);
|
||||
elm_shutdown();
|
||||
}
|
||||
else if (elm_main)
|
||||
{
|
||||
elm_init(argc, argv);
|
||||
real__ = elm_main(argc, argv);
|
||||
elm_shutdown();
|
||||
}
|
||||
else if (c_main)
|
||||
{
|
||||
real__ = c_main(argc, argv);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Failed loading symbol 'efl_main', 'elm_main' or 'main' from %s.\n", full_path);
|
||||
eina_module_free(h);
|
||||
real__ = 1;
|
||||
}
|
||||
return real__;
|
||||
}
|
||||
|
||||
static Eina_Stringshare *
|
||||
_prg_full_path_guess(const char *prg)
|
||||
{
|
||||
char full_path[PATH_MAX];
|
||||
if (strchr(prg, '/')) return eina_stringshare_add(prg);
|
||||
char *env_path = eina_strdup(getenv("PATH"));
|
||||
Eina_Stringshare *ret = NULL;
|
||||
char *paths = env_path;
|
||||
|
||||
while (paths && *paths && !ret)
|
||||
{
|
||||
char *real_path;
|
||||
char *colon = strchr(paths, ':');
|
||||
if (colon) *colon = '\0';
|
||||
|
||||
sprintf(full_path, "%s/%s", paths, prg);
|
||||
real_path = ecore_file_realpath(full_path);
|
||||
if (*real_path)
|
||||
{
|
||||
ret = eina_stringshare_add(real_path);
|
||||
// check if executable
|
||||
}
|
||||
free(real_path);
|
||||
|
||||
paths += strlen(paths);
|
||||
if (colon) paths++;
|
||||
}
|
||||
free(env_path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_mkdir(const char *dir)
|
||||
{
|
||||
if (!ecore_file_exists(dir))
|
||||
{
|
||||
const char *cur = dir + 1;
|
||||
do
|
||||
{
|
||||
char *slash = strchr(cur, '/');
|
||||
if (slash) *slash = '\0';
|
||||
if (!ecore_file_exists(dir) && !ecore_file_mkdir(dir)) return EINA_FALSE;
|
||||
if (slash) *slash = '/';
|
||||
if (slash) cur = slash + 1;
|
||||
else cur = NULL;
|
||||
}
|
||||
while (cur);
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static const Ecore_Getopt optdesc = {
|
||||
"exactness_record",
|
||||
"%prog [options] <-v|-t|-h> command",
|
||||
|
@ -370,6 +263,7 @@ int main(int argc, char **argv)
|
|||
char *fonts_dir = NULL;
|
||||
int pret = 1, opt_args = 0;
|
||||
Eina_Bool want_quit = EINA_FALSE;
|
||||
_evas_new = NULL;
|
||||
|
||||
Ecore_Getopt_Value values[] = {
|
||||
ECORE_GETOPT_VALUE_STR(dest),
|
||||
|
@ -427,7 +321,7 @@ int main(int argc, char **argv)
|
|||
if (slash)
|
||||
{
|
||||
*slash = '\0';
|
||||
if (!_mkdir(_out_filename))
|
||||
if (!ecore_file_mkpath(_out_filename))
|
||||
{
|
||||
fprintf(stderr, "Can't create %s\n", _out_filename);
|
||||
goto end;
|
||||
|
@ -500,7 +394,7 @@ int main(int argc, char **argv)
|
|||
|
||||
ecore_evas_callback_new_set(_my_evas_new);
|
||||
_last_timestamp = ecore_time_get() * 1000;
|
||||
pret = _prg_invoke(_prg_full_path_guess(argv[0]), argc - opt_args, argv);
|
||||
pret = ex_prg_invoke(ex_prg_full_path_guess(argv[0]), argc - opt_args, argv, EINA_FALSE);
|
||||
|
||||
_output_write();
|
||||
//free_events(_events_list, EINA_TRUE);
|
||||
|
|
|
@ -878,7 +878,7 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file,
|
|||
hkey = alloca(sizeof (char) * size);
|
||||
memcpy(hkey, file, file_length);
|
||||
size = file_length;
|
||||
memcpy(hkey + size, "//://", 5);
|
||||
memcpy(hkey + size, "//://", 6);
|
||||
size += 5;
|
||||
if (key) ckey = key;
|
||||
memcpy(hkey + size, ckey, key_length);
|
||||
|
|
|
@ -1,268 +0,0 @@
|
|||
#ifndef _EXACTNESS_H
|
||||
#define _EXACTNESS_H
|
||||
|
||||
#include <Evas.h>
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef EXACTNESS_BUILD
|
||||
# ifdef DLL_EXPORT
|
||||
# define EAPI __declspec(dllexport)
|
||||
# else
|
||||
# define EAPI
|
||||
# endif /* ! DLL_EXPORT */
|
||||
# else
|
||||
# define EAPI __declspec(dllimport)
|
||||
# endif /* ! EXACTNESS_BUILD */
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
#endif /* ! _WIN32 */
|
||||
|
||||
/**
|
||||
* @page exactness_main Exactness
|
||||
*
|
||||
* @date 2018 (created)
|
||||
*
|
||||
* This page describes the public structures and APIs available for Exactness.
|
||||
*
|
||||
* @addtogroup Exactness
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Type
|
||||
* The type values for an Exactness action.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
EXACTNESS_ACTION_UNKNOWN = 0,
|
||||
EXACTNESS_ACTION_MOUSE_IN,
|
||||
EXACTNESS_ACTION_MOUSE_OUT,
|
||||
EXACTNESS_ACTION_MOUSE_WHEEL,
|
||||
EXACTNESS_ACTION_MULTI_DOWN,
|
||||
EXACTNESS_ACTION_MULTI_UP,
|
||||
EXACTNESS_ACTION_MULTI_MOVE,
|
||||
EXACTNESS_ACTION_KEY_DOWN,
|
||||
EXACTNESS_ACTION_KEY_UP,
|
||||
EXACTNESS_ACTION_TAKE_SHOT,
|
||||
EXACTNESS_ACTION_EFL_EVENT,
|
||||
EXACTNESS_ACTION_CLICK_ON,
|
||||
EXACTNESS_ACTION_STABILIZE,
|
||||
EXACTNESS_ACTION_LAST = EXACTNESS_ACTION_STABILIZE
|
||||
/* Add any supported actions here and update _LAST */
|
||||
} Exactness_Action_Type;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Mouse_Wheel
|
||||
* The type for the Exactness Mouse Wheel action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int direction;
|
||||
int z;
|
||||
} Exactness_Action_Mouse_Wheel;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Key_Down_Up
|
||||
* The type for the Exactness Key Down Up action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char *keyname;
|
||||
const char *key;
|
||||
const char *string;
|
||||
const char *compose;
|
||||
unsigned int keycode;
|
||||
} Exactness_Action_Key_Down_Up;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Multi_Event
|
||||
* The type for the Exactness Multi Event action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int d;
|
||||
int b; /* In case of simple mouse down/up, corresponds to the button */
|
||||
int x;
|
||||
int y;
|
||||
double rad;
|
||||
double radx;
|
||||
double rady;
|
||||
double pres;
|
||||
double ang;
|
||||
double fx;
|
||||
double fy;
|
||||
Evas_Button_Flags flags;
|
||||
} Exactness_Action_Multi_Event;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Multi_Move
|
||||
* The type for the Exactness Multi Move action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int d;
|
||||
int x;
|
||||
int y;
|
||||
double rad;
|
||||
double radx;
|
||||
double rady;
|
||||
double pres;
|
||||
double ang;
|
||||
double fx;
|
||||
double fy;
|
||||
} Exactness_Action_Multi_Move;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Efl_Event
|
||||
* The type for the Exactness EFL Event action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *wdg_name;
|
||||
char *event_name;
|
||||
} Exactness_Action_Efl_Event;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action_Click_On
|
||||
* The type for the Exactness Click on (widget) action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *wdg_name;
|
||||
} Exactness_Action_Click_On;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Action
|
||||
* The type for the Exactness action.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Exactness_Action_Type type; /**< The action type */
|
||||
unsigned int n_evas; /**< The evas number on which the action has to be applied */
|
||||
unsigned int delay_ms; /**< The delay (in ms) to wait for this action */
|
||||
void *data; /**< The specific action data */
|
||||
} Exactness_Action;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Object
|
||||
* The type for the Exactness object.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
long long id; /**< The Eo pointer */
|
||||
long long parent_id; /**< The Eo parent pointer */
|
||||
const char *kl_name; /**< The class name */
|
||||
|
||||
Eina_List *children; /* NOT EET */
|
||||
|
||||
/* Evas stuff */
|
||||
int x; /**< The X coordinate */
|
||||
int y; /**< The Y coordinate */
|
||||
int w; /**< The object width */
|
||||
int h; /**< The object height */
|
||||
} Exactness_Object;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Objects
|
||||
* The type for the Exactness objects list.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Eina_List *objs; /**< List of all the objects */
|
||||
/* main_objs not in EET */
|
||||
Eina_List *main_objs; /**< List of the main objects */
|
||||
} Exactness_Objects;
|
||||
|
||||
/**
|
||||
* @typedef Exactness_Image
|
||||
* The type for the Exactness Image.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned int w; /**< Width of the image */
|
||||
unsigned int h; /**< Height of the image */
|
||||
void *pixels; /**< Pixels of the image */
|
||||
} Exactness_Image;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *language; /**< String describing the language of the content e.g "C"...*/
|
||||
char *content; /**< Content used as source */
|
||||
char *command; /**< Command needed to generate the application from the content */
|
||||
} Exactness_Source_Code;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Eina_List *actions; /**< List of Exactness_Action */
|
||||
/* imgs not in EET */
|
||||
Eina_List *imgs; /**< List of Exactness_Image */
|
||||
Eina_List *objs; /**< List of Exactness_Objects */
|
||||
Eina_List *codes; /**< List of Exactness_Source_Code */
|
||||
const char *fonts_path; /**< Path to the fonts to use, relative to the fonts dir given in parameter to the player/recorder */
|
||||
int nb_shots; /**< The number of shots present in the unit */
|
||||
} Exactness_Unit;
|
||||
|
||||
/**
|
||||
* @brief Read an unit from a given file
|
||||
*
|
||||
* @param filename Name of the file containing the unit
|
||||
*
|
||||
* @return the unit
|
||||
*/
|
||||
EAPI Exactness_Unit *exactness_unit_file_read(const char *filename);
|
||||
|
||||
/**
|
||||
* @brief Write an unit into the given file
|
||||
*
|
||||
* @param unit Unit to store
|
||||
* @param filename Name of the file containing the unit
|
||||
*
|
||||
* @return EINA_TRUE on success, EINA_FALSE otherwise
|
||||
*/
|
||||
EAPI Eina_Bool exactness_unit_file_write(Exactness_Unit *unit, const char *filename);
|
||||
|
||||
/**
|
||||
* @brief Compare two images
|
||||
*
|
||||
* @param img1 first image
|
||||
* @param img2 second image
|
||||
* @param imgO pointer for the diff image. Can be NULL
|
||||
*
|
||||
* @return EINA_TRUE if the images are different, EINA_FALSE otherwise
|
||||
*/
|
||||
EAPI Eina_Bool exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **imgO);
|
||||
|
||||
/**
|
||||
* @brief Free the given image
|
||||
*
|
||||
* @param img the image
|
||||
*
|
||||
*/
|
||||
EAPI void exactness_image_free(Exactness_Image *img);
|
||||
|
||||
/**
|
||||
* @brief Read a legacy file and convert it to an unit
|
||||
*
|
||||
* @param filename Name of the legacy file
|
||||
*
|
||||
* @return the unit
|
||||
*/
|
||||
EAPI Exactness_Unit *legacy_rec_file_read(const char *filename);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* _EXACTNESS_H */
|
|
@ -1,10 +0,0 @@
|
|||
#ifndef _EXACTNESS_PRIVATE_H
|
||||
#define _EXACTNESS_PRIVATE_H
|
||||
|
||||
#include <Exactness.h>
|
||||
|
||||
/* private header */
|
||||
EAPI const char *_exactness_action_type_to_string_get(Exactness_Action_Type type);
|
||||
|
||||
#define SHOT_DELIMITER '+'
|
||||
#endif
|
|
@ -1,875 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <Eina.h>
|
||||
#include <Eet.h>
|
||||
#include <Evas.h>
|
||||
|
||||
#include "Exactness.h"
|
||||
|
||||
#define CACHE_FILE_ENTRY "cache"
|
||||
|
||||
enum _Tsuite_Event_Type
|
||||
{ /* Add any supported events here */
|
||||
TSUITE_EVENT_NOT_SUPPORTED = 0,
|
||||
TSUITE_EVENT_MOUSE_IN,
|
||||
TSUITE_EVENT_MOUSE_OUT,
|
||||
TSUITE_EVENT_MOUSE_DOWN,
|
||||
TSUITE_EVENT_MOUSE_UP,
|
||||
TSUITE_EVENT_MOUSE_MOVE,
|
||||
TSUITE_EVENT_MOUSE_WHEEL,
|
||||
TSUITE_EVENT_MULTI_DOWN,
|
||||
TSUITE_EVENT_MULTI_UP,
|
||||
TSUITE_EVENT_MULTI_MOVE,
|
||||
TSUITE_EVENT_KEY_DOWN,
|
||||
TSUITE_EVENT_KEY_UP,
|
||||
TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE,
|
||||
TSUITE_EVENT_KEY_UP_WITH_KEYCODE,
|
||||
TSUITE_EVENT_TAKE_SHOT
|
||||
};
|
||||
typedef enum _Tsuite_Event_Type Tsuite_Event_Type;
|
||||
|
||||
struct _eet_event_type_mapping
|
||||
{
|
||||
Tsuite_Event_Type t;
|
||||
const char *name;
|
||||
};
|
||||
typedef struct _eet_event_type_mapping eet_event_type_mapping;
|
||||
|
||||
struct _Variant_Type_st
|
||||
{
|
||||
const char *type;
|
||||
Eina_Bool unknow : 1;
|
||||
};
|
||||
typedef struct _Variant_Type_st Variant_Type_st;
|
||||
|
||||
struct _Variant_st
|
||||
{
|
||||
Variant_Type_st t;
|
||||
void *data; /* differently than the union type, we
|
||||
* don't need to pre-allocate the memory
|
||||
* for the field*/
|
||||
};
|
||||
typedef struct _Variant_st Variant_st;
|
||||
|
||||
struct _Timer_Data
|
||||
{
|
||||
unsigned int recent_event_time;
|
||||
Eina_List *current_event;
|
||||
};
|
||||
typedef struct _Timer_Data Timer_Data;
|
||||
|
||||
struct _Tsuite_Data
|
||||
{
|
||||
int serial; /**< Serial number of current-file */
|
||||
Timer_Data *td;
|
||||
};
|
||||
typedef struct _Tsuite_Data Tsuite_Data;
|
||||
|
||||
struct _mouse_in_mouse_out
|
||||
{
|
||||
unsigned int timestamp;
|
||||
int n_evas;
|
||||
};
|
||||
|
||||
struct _mouse_down_mouse_up
|
||||
{
|
||||
int b;
|
||||
Evas_Button_Flags flags;
|
||||
unsigned int timestamp;
|
||||
int n_evas;
|
||||
};
|
||||
|
||||
struct _mouse_move
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
unsigned int timestamp;
|
||||
int n_evas;
|
||||
};
|
||||
|
||||
struct _mouse_wheel
|
||||
{
|
||||
int direction;
|
||||
int z;
|
||||
unsigned int timestamp;
|
||||
int n_evas;
|
||||
};
|
||||
|
||||
struct _key_down_key_up
|
||||
{
|
||||
unsigned int timestamp;
|
||||
const char *keyname;
|
||||
const char *key;
|
||||
const char *string;
|
||||
const char *compose;
|
||||
int n_evas;
|
||||
};
|
||||
|
||||
struct _key_down_key_up_with_keycode
|
||||
{
|
||||
unsigned int timestamp;
|
||||
const char *keyname;
|
||||
const char *key;
|
||||
const char *string;
|
||||
const char *compose;
|
||||
int n_evas;
|
||||
unsigned int keycode;
|
||||
};
|
||||
|
||||
struct _multi_event
|
||||
{
|
||||
int d;
|
||||
int b; /* In case of simple mouse down/up, corresponds to the button */
|
||||
int x;
|
||||
int y;
|
||||
double rad;
|
||||
double radx;
|
||||
double rady;
|
||||
double pres;
|
||||
double ang;
|
||||
double fx;
|
||||
double fy;
|
||||
Evas_Button_Flags flags;
|
||||
unsigned int timestamp;
|
||||
int n_evas;
|
||||
};
|
||||
|
||||
struct _multi_move
|
||||
{
|
||||
int d;
|
||||
int x;
|
||||
int y;
|
||||
double rad;
|
||||
double radx;
|
||||
double rady;
|
||||
double pres;
|
||||
double ang;
|
||||
double fx;
|
||||
double fy;
|
||||
unsigned int timestamp;
|
||||
int n_evas;
|
||||
};
|
||||
|
||||
typedef struct _mouse_in_mouse_out mouse_in_mouse_out;
|
||||
typedef struct _mouse_down_mouse_up mouse_down_mouse_up;
|
||||
typedef struct _mouse_move mouse_move;
|
||||
typedef struct _mouse_wheel mouse_wheel;
|
||||
typedef struct _multi_event multi_event;
|
||||
typedef struct _multi_move multi_move;
|
||||
typedef struct _key_down_key_up key_down_key_up;
|
||||
typedef struct _key_down_key_up_with_keycode key_down_key_up_with_keycode;
|
||||
typedef struct _mouse_in_mouse_out take_screenshot;
|
||||
|
||||
/* START - EET support typedefs */
|
||||
#define TSUITE_EVENT_MOUSE_IN_STR "tsuite_event_mouse_in"
|
||||
#define TSUITE_EVENT_MOUSE_OUT_STR "tsuite_event_mouse_out"
|
||||
#define TSUITE_EVENT_MOUSE_DOWN_STR "tsuite_event_mouse_down"
|
||||
#define TSUITE_EVENT_MOUSE_UP_STR "tsuite_event_mouse_up"
|
||||
#define TSUITE_EVENT_MOUSE_MOVE_STR "tsuite_event_mouse_move"
|
||||
#define TSUITE_EVENT_MOUSE_WHEEL_STR "tsuite_event_mouse_wheel"
|
||||
#define TSUITE_EVENT_MULTI_DOWN_STR "tsuite_event_multi_down"
|
||||
#define TSUITE_EVENT_MULTI_UP_STR "tsuite_event_multi_up"
|
||||
#define TSUITE_EVENT_MULTI_MOVE_STR "tsuite_event_multi_move"
|
||||
#define TSUITE_EVENT_KEY_DOWN_STR "tsuite_event_key_down"
|
||||
#define TSUITE_EVENT_KEY_UP_STR "tsuite_event_key_up"
|
||||
#define TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE_STR "tsuite_event_key_down_with_keycode"
|
||||
#define TSUITE_EVENT_KEY_UP_WITH_KEYCODE_STR "tsuite_event_key_up_with_keycode"
|
||||
#define TSUITE_EVENT_TAKE_SHOT_STR "tsuite_event_take_shot"
|
||||
|
||||
struct _Lists_st
|
||||
{
|
||||
Eina_List *variant_list;
|
||||
unsigned int first_timestamp;
|
||||
};
|
||||
typedef struct _Lists_st Lists_st;
|
||||
|
||||
struct _data_desc
|
||||
{
|
||||
Eet_Data_Descriptor *take_screenshot;
|
||||
Eet_Data_Descriptor *mouse_in_mouse_out;
|
||||
Eet_Data_Descriptor *mouse_down_mouse_up;
|
||||
Eet_Data_Descriptor *mouse_move;
|
||||
Eet_Data_Descriptor *mouse_wheel;
|
||||
Eet_Data_Descriptor *multi_event;
|
||||
Eet_Data_Descriptor *multi_move;
|
||||
Eet_Data_Descriptor *key_down_key_up;
|
||||
Eet_Data_Descriptor *key_down_key_up_with_keycode;
|
||||
|
||||
/* list, variant EET desc support */
|
||||
Eet_Data_Descriptor *lists_descriptor;
|
||||
Eet_Data_Descriptor *variant_descriptor;
|
||||
Eet_Data_Descriptor *variant_unified_descriptor;
|
||||
};
|
||||
typedef struct _data_desc data_desc;
|
||||
/* END - EET support typedefs */
|
||||
|
||||
static data_desc *_desc = NULL; /* this struct holds descs (alloc on init) */
|
||||
|
||||
static eet_event_type_mapping eet_mapping[] = {
|
||||
{ TSUITE_EVENT_MOUSE_IN, TSUITE_EVENT_MOUSE_IN_STR },
|
||||
{ TSUITE_EVENT_MOUSE_OUT, TSUITE_EVENT_MOUSE_OUT_STR },
|
||||
{ TSUITE_EVENT_MOUSE_DOWN, TSUITE_EVENT_MOUSE_DOWN_STR },
|
||||
{ TSUITE_EVENT_MOUSE_UP, TSUITE_EVENT_MOUSE_UP_STR },
|
||||
{ TSUITE_EVENT_MOUSE_MOVE, TSUITE_EVENT_MOUSE_MOVE_STR },
|
||||
{ TSUITE_EVENT_MOUSE_WHEEL, TSUITE_EVENT_MOUSE_WHEEL_STR },
|
||||
{ TSUITE_EVENT_MULTI_DOWN, TSUITE_EVENT_MULTI_DOWN_STR },
|
||||
{ TSUITE_EVENT_MULTI_UP, TSUITE_EVENT_MULTI_UP_STR },
|
||||
{ TSUITE_EVENT_MULTI_MOVE, TSUITE_EVENT_MULTI_MOVE_STR },
|
||||
{ TSUITE_EVENT_KEY_DOWN, TSUITE_EVENT_KEY_DOWN_STR },
|
||||
{ TSUITE_EVENT_KEY_UP, TSUITE_EVENT_KEY_UP_STR },
|
||||
{ TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE, TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE_STR },
|
||||
{ TSUITE_EVENT_KEY_UP_WITH_KEYCODE, TSUITE_EVENT_KEY_UP_WITH_KEYCODE_STR },
|
||||
{ TSUITE_EVENT_TAKE_SHOT, TSUITE_EVENT_TAKE_SHOT_STR },
|
||||
{ TSUITE_EVENT_NOT_SUPPORTED, NULL }
|
||||
};
|
||||
|
||||
static Tsuite_Event_Type
|
||||
_event_mapping_type_get(const char *name)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; eet_mapping[i].name != NULL; ++i)
|
||||
if (strcmp(name, eet_mapping[i].name) == 0)
|
||||
return eet_mapping[i].t;
|
||||
|
||||
return TSUITE_EVENT_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
_evt_time_get(unsigned int tm, Variant_st *v)
|
||||
{
|
||||
if (!v) return tm;
|
||||
switch(_event_mapping_type_get(v->t.type))
|
||||
{
|
||||
case TSUITE_EVENT_MOUSE_IN:
|
||||
{
|
||||
mouse_in_mouse_out *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_OUT:
|
||||
{
|
||||
mouse_in_mouse_out *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_DOWN:
|
||||
{
|
||||
mouse_down_mouse_up *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_UP:
|
||||
{
|
||||
mouse_down_mouse_up *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_MOVE:
|
||||
{
|
||||
mouse_move *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_WHEEL:
|
||||
{
|
||||
mouse_wheel *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_DOWN:
|
||||
{
|
||||
multi_event *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_UP:
|
||||
{
|
||||
multi_event *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_MOVE:
|
||||
{
|
||||
multi_move *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN:
|
||||
{
|
||||
key_down_key_up *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_UP:
|
||||
{
|
||||
key_down_key_up *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE:
|
||||
{
|
||||
key_down_key_up_with_keycode *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_UP_WITH_KEYCODE:
|
||||
{
|
||||
key_down_key_up_with_keycode *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
case TSUITE_EVENT_TAKE_SHOT:
|
||||
{
|
||||
take_screenshot *t = v->data;
|
||||
return t->timestamp;
|
||||
}
|
||||
default: /* All non-input events are not handeled */
|
||||
return tm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static Lists_st *
|
||||
_free_events(Lists_st *st)
|
||||
{
|
||||
Variant_st *v;
|
||||
if (!st) goto end;
|
||||
EINA_LIST_FREE(st->variant_list, v)
|
||||
{
|
||||
free(v->data);
|
||||
free(v);
|
||||
}
|
||||
|
||||
free(st); /* Allocated when reading data from EET file */
|
||||
end:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_variant_type_get(const void *data, Eina_Bool *unknow)
|
||||
{
|
||||
const Variant_Type_st *type = data;
|
||||
int i;
|
||||
|
||||
if (unknow)
|
||||
*unknow = type->unknow;
|
||||
|
||||
for (i = 0; eet_mapping[i].name != NULL; ++i)
|
||||
if (strcmp(type->type, eet_mapping[i].name) == 0)
|
||||
return eet_mapping[i].name;
|
||||
|
||||
if (unknow)
|
||||
*unknow = EINA_FALSE;
|
||||
|
||||
return type->type;
|
||||
} /* _variant_type_get */
|
||||
|
||||
static Eina_Bool
|
||||
_variant_type_set(const char *type,
|
||||
void *data,
|
||||
Eina_Bool unknow)
|
||||
{
|
||||
Variant_Type_st *vt = data;
|
||||
|
||||
vt->type = type;
|
||||
vt->unknow = unknow;
|
||||
return EINA_TRUE;
|
||||
} /* _variant_type_set */
|
||||
|
||||
/* START Event struct descriptors */
|
||||
static Eet_Data_Descriptor *
|
||||
_take_screenshot_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, take_screenshot);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, take_screenshot, "timestamp",
|
||||
timestamp, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, take_screenshot, "n_evas",
|
||||
n_evas, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_mouse_in_mouse_out_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, mouse_in_mouse_out);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_in_mouse_out, "timestamp",
|
||||
timestamp, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_in_mouse_out, "n_evas",
|
||||
n_evas, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_mouse_down_mouse_up_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, mouse_down_mouse_up);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_down_mouse_up, "b", b, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_down_mouse_up, "flags",
|
||||
flags, EET_T_INT);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_down_mouse_up, "timestamp",
|
||||
timestamp, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_down_mouse_up, "n_evas",
|
||||
n_evas, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_mouse_move_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, mouse_move);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_move, "x", x, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_move, "y", y, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_move, "timestamp",
|
||||
timestamp, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_move, "n_evas",
|
||||
n_evas, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_mouse_wheel_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, mouse_wheel);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_wheel, "direction",
|
||||
direction, EET_T_INT);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_wheel, "z", z, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_wheel, "timestamp",
|
||||
timestamp, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, mouse_wheel, "n_evas",
|
||||
n_evas, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_key_down_key_up_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, key_down_key_up);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up, "timestamp",
|
||||
timestamp, EET_T_UINT);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up, "keyname",
|
||||
keyname, EET_T_STRING);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up, "key",
|
||||
key, EET_T_STRING);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up, "string",
|
||||
string, EET_T_STRING);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up, "compose",
|
||||
compose, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up, "n_evas",
|
||||
n_evas, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_key_down_key_up_with_keycode_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, key_down_key_up_with_keycode);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "timestamp",
|
||||
timestamp, EET_T_UINT);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "keyname",
|
||||
keyname, EET_T_STRING);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "key",
|
||||
key, EET_T_STRING);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "string",
|
||||
string, EET_T_STRING);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "compose",
|
||||
compose, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "n_evas",
|
||||
n_evas, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, key_down_key_up_with_keycode, "keycode",
|
||||
keycode, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_multi_event_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, multi_event);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "d", d, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "b", b, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "x", x, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "y", y, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "rad", rad, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "radx", radx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "rady", rady, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "pres", pres, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "ang", ang, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "fx", fx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "fy", fy, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "flags", flags, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "timestamp",
|
||||
timestamp, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_event, "n_evas",
|
||||
n_evas, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_multi_move_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, multi_move);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "d", d, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "x", x, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "y", y, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "rad", rad, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "radx", radx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "rady", rady, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "pres", pres, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "ang", ang, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "fx", fx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "fy", fy, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "timestamp",
|
||||
timestamp, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, multi_move, "n_evas",
|
||||
n_evas, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
/* declaring types */
|
||||
static data_desc *
|
||||
_data_descriptors_init(void)
|
||||
{
|
||||
if (_desc) /* Was allocated */
|
||||
return _desc;
|
||||
|
||||
_desc = calloc(1, sizeof(data_desc));
|
||||
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
|
||||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Lists_st);
|
||||
_desc->lists_descriptor = eet_data_descriptor_file_new(&eddc);
|
||||
|
||||
_desc->take_screenshot = _take_screenshot_desc_make();
|
||||
_desc->mouse_in_mouse_out = _mouse_in_mouse_out_desc_make();
|
||||
_desc->mouse_down_mouse_up = _mouse_down_mouse_up_desc_make();
|
||||
_desc->mouse_move = _mouse_move_desc_make();
|
||||
_desc->mouse_wheel = _mouse_wheel_desc_make();
|
||||
_desc->multi_event = _multi_event_desc_make();
|
||||
_desc->multi_move = _multi_move_desc_make();
|
||||
_desc->key_down_key_up = _key_down_key_up_desc_make();
|
||||
_desc->key_down_key_up_with_keycode = _key_down_key_up_with_keycode_desc_make();
|
||||
|
||||
/* for variant */
|
||||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Variant_st);
|
||||
_desc->variant_descriptor = eet_data_descriptor_file_new(&eddc);
|
||||
|
||||
eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
|
||||
eddc.func.type_get = _variant_type_get;
|
||||
eddc.func.type_set = _variant_type_set;
|
||||
_desc->variant_unified_descriptor = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_MOUSE_IN_STR, _desc->mouse_in_mouse_out);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_MOUSE_OUT_STR, _desc->mouse_in_mouse_out);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_MOUSE_DOWN_STR, _desc->mouse_down_mouse_up);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_MOUSE_UP_STR, _desc->mouse_down_mouse_up);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_MOUSE_MOVE_STR, _desc->mouse_move);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_MOUSE_WHEEL_STR, _desc->mouse_wheel);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_MULTI_DOWN_STR, _desc->multi_event);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_MULTI_UP_STR, _desc->multi_event);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_MULTI_MOVE_STR, _desc->multi_move);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_KEY_DOWN_STR, _desc->key_down_key_up);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_KEY_UP_STR, _desc->key_down_key_up);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE_STR, _desc->key_down_key_up_with_keycode);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_KEY_UP_WITH_KEYCODE_STR, _desc->key_down_key_up_with_keycode);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(_desc->variant_unified_descriptor,
|
||||
TSUITE_EVENT_TAKE_SHOT_STR, _desc->take_screenshot);
|
||||
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_VARIANT(_desc->variant_descriptor,
|
||||
Variant_st, "data", data, t, _desc->variant_unified_descriptor);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_desc->lists_descriptor,
|
||||
Lists_st, "first_timestamp", first_timestamp, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(_desc->lists_descriptor,
|
||||
Lists_st, "variant_list", variant_list, _desc->variant_descriptor);
|
||||
|
||||
return _desc;
|
||||
}
|
||||
|
||||
static void
|
||||
_data_descriptors_shutdown(void)
|
||||
{
|
||||
if (_desc)
|
||||
{
|
||||
eet_data_descriptor_free(_desc->mouse_in_mouse_out);
|
||||
eet_data_descriptor_free(_desc->mouse_down_mouse_up);
|
||||
eet_data_descriptor_free(_desc->mouse_move);
|
||||
eet_data_descriptor_free(_desc->mouse_wheel);
|
||||
eet_data_descriptor_free(_desc->multi_event);
|
||||
eet_data_descriptor_free(_desc->multi_move);
|
||||
eet_data_descriptor_free(_desc->key_down_key_up);
|
||||
eet_data_descriptor_free(_desc->key_down_key_up_with_keycode);
|
||||
eet_data_descriptor_free(_desc->take_screenshot);
|
||||
eet_data_descriptor_free(_desc->lists_descriptor);
|
||||
eet_data_descriptor_free(_desc->variant_descriptor);
|
||||
eet_data_descriptor_free(_desc->variant_unified_descriptor);
|
||||
|
||||
free(_desc);
|
||||
_desc = NULL;
|
||||
/* FIXME: Should probably only init and shutdown once */
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Exactness_Unit *
|
||||
legacy_rec_file_read(const char *filename)
|
||||
{
|
||||
Lists_st *vr_list;
|
||||
Eina_List *itr;
|
||||
Variant_st *v, *prev_v = NULL;
|
||||
Exactness_Unit *unit = NULL;
|
||||
Eet_File *fp = eet_open(filename, EET_FILE_MODE_READ);
|
||||
if (!fp)
|
||||
{
|
||||
printf("Failed to open input file <%s>.\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Read events list */
|
||||
_data_descriptors_init();
|
||||
vr_list = eet_data_read(fp, _desc->lists_descriptor, CACHE_FILE_ENTRY);
|
||||
eet_close(fp);
|
||||
_data_descriptors_shutdown();
|
||||
|
||||
unit = calloc(1, sizeof(*unit));
|
||||
|
||||
EINA_LIST_FOREACH(vr_list->variant_list, itr, v)
|
||||
{
|
||||
Exactness_Action *act = calloc(1, sizeof(*act));
|
||||
Tsuite_Event_Type old_type = _event_mapping_type_get(v->t.type);
|
||||
unsigned int vtm = _evt_time_get(0, v);
|
||||
if (!vtm) continue;
|
||||
switch (old_type)
|
||||
{
|
||||
case TSUITE_EVENT_MOUSE_IN:
|
||||
{
|
||||
mouse_in_mouse_out *d_i = v->data;
|
||||
act->type = EXACTNESS_ACTION_MOUSE_IN;
|
||||
act->n_evas = d_i->n_evas;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_OUT:
|
||||
{
|
||||
mouse_in_mouse_out *d_i = v->data;
|
||||
act->type = EXACTNESS_ACTION_MOUSE_OUT;
|
||||
act->n_evas = d_i->n_evas;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_DOWN:
|
||||
case TSUITE_EVENT_MOUSE_UP:
|
||||
{
|
||||
mouse_down_mouse_up *d_i = v->data;
|
||||
Exactness_Action_Multi_Event *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->b = d_i->b;
|
||||
d_o->flags = d_i->flags;
|
||||
if (old_type == TSUITE_EVENT_MOUSE_DOWN)
|
||||
act->type = EXACTNESS_ACTION_MULTI_DOWN;
|
||||
else
|
||||
act->type = EXACTNESS_ACTION_MULTI_UP;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_MOVE:
|
||||
{
|
||||
mouse_move *d_i = v->data;
|
||||
Exactness_Action_Multi_Move *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->x = d_i->x;
|
||||
d_o->y = d_i->y;
|
||||
act->type = EXACTNESS_ACTION_MULTI_MOVE;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MOUSE_WHEEL:
|
||||
{
|
||||
mouse_wheel *d_i = v->data;
|
||||
Exactness_Action_Mouse_Wheel *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->direction = d_i->direction;
|
||||
d_o->z = d_i->z;
|
||||
act->type = EXACTNESS_ACTION_MOUSE_WHEEL;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_DOWN:
|
||||
case TSUITE_EVENT_MULTI_UP:
|
||||
{
|
||||
multi_event *d_i = v->data;
|
||||
Exactness_Action_Multi_Event *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->d = d_i->d;
|
||||
d_o->b = d_i->b;
|
||||
d_o->x = d_i->x;
|
||||
d_o->y = d_i->y;
|
||||
d_o->rad = d_i->rad;
|
||||
d_o->radx = d_i->radx;
|
||||
d_o->rady = d_i->rady;
|
||||
d_o->pres = d_i->pres;
|
||||
d_o->ang = d_i->ang;
|
||||
d_o->fx = d_i->fx;
|
||||
d_o->fy = d_i->fy;
|
||||
d_o->flags = d_i->flags;
|
||||
if (old_type == TSUITE_EVENT_MULTI_DOWN)
|
||||
act->type = EXACTNESS_ACTION_MULTI_DOWN;
|
||||
else
|
||||
act->type = EXACTNESS_ACTION_MULTI_UP;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_MULTI_MOVE:
|
||||
{
|
||||
multi_move *d_i = v->data;
|
||||
Exactness_Action_Multi_Move *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->d = d_i->d;
|
||||
d_o->x = d_i->x;
|
||||
d_o->y = d_i->y;
|
||||
d_o->rad = d_i->rad;
|
||||
d_o->radx = d_i->radx;
|
||||
d_o->rady = d_i->rady;
|
||||
d_o->pres = d_i->pres;
|
||||
d_o->ang = d_i->ang;
|
||||
d_o->fx = d_i->fx;
|
||||
d_o->fy = d_i->fy;
|
||||
act->type = EXACTNESS_ACTION_MULTI_MOVE;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN:
|
||||
case TSUITE_EVENT_KEY_UP:
|
||||
{
|
||||
key_down_key_up *d_i = v->data;
|
||||
Exactness_Action_Key_Down_Up *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->keyname = d_i->keyname;
|
||||
d_o->key = d_i->key;
|
||||
d_o->string = d_i->string;
|
||||
d_o->compose = d_i->compose;
|
||||
if (old_type == TSUITE_EVENT_KEY_DOWN)
|
||||
act->type = EXACTNESS_ACTION_KEY_DOWN;
|
||||
else
|
||||
act->type = EXACTNESS_ACTION_KEY_UP;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE:
|
||||
case TSUITE_EVENT_KEY_UP_WITH_KEYCODE:
|
||||
{
|
||||
key_down_key_up_with_keycode *d_i = v->data;
|
||||
Exactness_Action_Key_Down_Up *d_o = calloc(1, sizeof(*d_o));
|
||||
d_o->keyname = d_i->keyname;
|
||||
d_o->key = d_i->key;
|
||||
d_o->string = d_i->string;
|
||||
d_o->compose = d_i->compose;
|
||||
d_o->keycode = d_i->keycode;
|
||||
if (old_type == TSUITE_EVENT_KEY_DOWN_WITH_KEYCODE)
|
||||
act->type = EXACTNESS_ACTION_KEY_DOWN;
|
||||
else
|
||||
act->type = EXACTNESS_ACTION_KEY_UP;
|
||||
act->n_evas = d_i->n_evas;
|
||||
act->data = d_o;
|
||||
break;
|
||||
}
|
||||
case TSUITE_EVENT_TAKE_SHOT:
|
||||
{
|
||||
take_screenshot *d_i = v->data;
|
||||
act->type = EXACTNESS_ACTION_TAKE_SHOT;
|
||||
act->n_evas = d_i->n_evas;
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
if (!prev_v)
|
||||
{
|
||||
if (vr_list->first_timestamp)
|
||||
act->delay_ms = _evt_time_get(0, v) - vr_list->first_timestamp;
|
||||
else
|
||||
act->delay_ms = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (vtm > _evt_time_get(0, prev_v))
|
||||
act->delay_ms = vtm - _evt_time_get(0, prev_v);
|
||||
else act->delay_ms = 0;
|
||||
}
|
||||
unit->actions = eina_list_append(unit->actions, act);
|
||||
prev_v = v;
|
||||
}
|
||||
#ifdef DEBUG_TSUITE
|
||||
printf("%s number of actions in the scenario <%d>\n", __func__, eina_list_count(unit->actions));
|
||||
#endif
|
||||
_free_events(vr_list);
|
||||
|
||||
return unit;
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
exactness_pub_deps = [eina, evas]
|
||||
exactness_deps = []
|
||||
|
||||
exactness_src = [
|
||||
'Exactness.h',
|
||||
'exactness_private.h',
|
||||
'legacy_file.c',
|
||||
'unit.c'
|
||||
]
|
||||
|
||||
exactness_lib = library('exactness', exactness_src,
|
||||
dependencies: [ eina, eet, evas ],
|
||||
install: true,
|
||||
version : meson.project_version()
|
||||
)
|
||||
|
||||
exactness = declare_dependency(
|
||||
include_directories: include_directories('.'),
|
||||
link_with : exactness_lib,
|
||||
dependencies: [ eina, evas, eet ],
|
||||
)
|
||||
|
||||
exactness_include_dir = join_paths(dir_data, 'exactness', 'include')
|
||||
|
||||
exactness_header_src = [
|
||||
'Exactness.h',
|
||||
]
|
||||
|
||||
install_headers(exactness_header_src,
|
||||
install_dir : dir_package_include
|
||||
)
|
|
@ -1,409 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <Eet.h>
|
||||
|
||||
#include "Exactness.h"
|
||||
#include "exactness_private.h"
|
||||
|
||||
typedef struct _Dummy
|
||||
{
|
||||
} _Dummy;
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_mouse_wheel_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Mouse_Wheel);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "direction", direction, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "z", z, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_key_down_up_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Key_Down_Up);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keyname", keyname, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "key", key, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "string", string, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "compose", compose, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keycode", keycode, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_multi_event_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Event);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "d", d, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "b", b, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "x", x, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "y", y, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rad", rad, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "radx", radx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rady", rady, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "pres", pres, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "ang", ang, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fx", fx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fy", fy, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "flags", flags, EET_T_INT);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_multi_move_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Move);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "d", d, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "x", x, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "y", y, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rad", rad, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "radx", radx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rady", rady, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "pres", pres, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "ang", ang, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fx", fx, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fy", fy, EET_T_DOUBLE);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_efl_event_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Efl_Event);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "wdg_name", wdg_name, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "event_name", event_name, EET_T_STRING);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_click_on_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Click_On);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Click_On, "wdg_name", wdg_name, EET_T_STRING);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_dummy_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
Eet_Data_Descriptor *_d;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, _Dummy);
|
||||
_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
return _d;
|
||||
}
|
||||
|
||||
/* !!! SAME ORDER AS Exactness_Action_Type */
|
||||
static const char *_mapping[] =
|
||||
{
|
||||
"",
|
||||
"exactness_action_mouse_in",
|
||||
"exactness_action_mouse_out",
|
||||
"exactness_action_mouse_wheel",
|
||||
"exactness_action_multi_down",
|
||||
"exactness_action_multi_up",
|
||||
"exactness_action_multi_move",
|
||||
"exactness_action_key_down",
|
||||
"exactness_action_key_up",
|
||||
"exactness_action_take_shot",
|
||||
"exactness_action_efl_event",
|
||||
"exactness_action_click_on",
|
||||
"exactness_action_stabilize"
|
||||
};
|
||||
|
||||
const char *
|
||||
_exactness_action_type_to_string_get(Exactness_Action_Type type)
|
||||
{
|
||||
if (type <= EXACTNESS_ACTION_LAST) return _mapping[type];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_variant_type_get(const void *data, Eina_Bool *unknow)
|
||||
{
|
||||
const Exactness_Action *act = data;
|
||||
|
||||
if (unknow) *unknow = EINA_FALSE;
|
||||
if (act->type <= EXACTNESS_ACTION_LAST) return _mapping[act->type];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_variant_type_set(const char *type,
|
||||
void *data,
|
||||
Eina_Bool unknow EINA_UNUSED)
|
||||
{
|
||||
int i;
|
||||
Exactness_Action *act = data;
|
||||
for (i = 0; i <= EXACTNESS_ACTION_LAST; i++)
|
||||
{
|
||||
if (!strcmp(_mapping[i], type)) act->type = i;
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eet_Data_Descriptor *
|
||||
_unit_desc_make(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
static Eet_Data_Descriptor *unit_d = NULL;
|
||||
static Eet_Data_Descriptor *action_d = NULL, *action_variant_d = NULL;
|
||||
static Eet_Data_Descriptor *objs_d = NULL;
|
||||
static Eet_Data_Descriptor *obj_d = NULL;
|
||||
if (!obj_d)
|
||||
{
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Object);
|
||||
obj_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "kl_name", kl_name, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "id", id, EET_T_ULONG_LONG);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "parent_id", parent_id, EET_T_ULONG_LONG);
|
||||
/* Evas stuff */
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "x", x, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "y", y, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "w", w, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "h", h, EET_T_INT);
|
||||
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Objects);
|
||||
objs_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(objs_d, Exactness_Objects, "objs", objs, obj_d);
|
||||
}
|
||||
if (!unit_d)
|
||||
{
|
||||
Eet_Data_Descriptor *code_d = NULL;
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Source_Code);
|
||||
code_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "language", language, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "content", content, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "command", command, EET_T_STRING);
|
||||
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action);
|
||||
action_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
|
||||
eddc.func.type_get = _variant_type_get;
|
||||
eddc.func.type_set = _variant_type_set;
|
||||
action_variant_d = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MOUSE_IN], _dummy_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MOUSE_OUT], _dummy_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MOUSE_WHEEL], _mouse_wheel_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MULTI_DOWN], _multi_event_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MULTI_UP], _multi_event_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_MULTI_MOVE], _multi_move_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_KEY_DOWN], _key_down_up_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_KEY_UP], _key_down_up_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_TAKE_SHOT], _dummy_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_EFL_EVENT], _efl_event_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_CLICK_ON], _click_on_desc_make());
|
||||
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
|
||||
_mapping[EXACTNESS_ACTION_STABILIZE], _dummy_desc_make());
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "n_evas", n_evas, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "delay_ms", delay_ms, EET_T_UINT);
|
||||
EET_DATA_DESCRIPTOR_ADD_VARIANT(action_d, Exactness_Action, "data", data, type, action_variant_d);
|
||||
|
||||
/* Exactness_Unit */
|
||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Unit);
|
||||
unit_d = eet_data_descriptor_stream_new(&eddc);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "actions", actions, action_d);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "objs", objs, objs_d);
|
||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "codes", codes, code_d);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "fonts_path", fonts_path, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "nb_shots", nb_shots, EET_T_UINT);
|
||||
}
|
||||
|
||||
return unit_d;
|
||||
}
|
||||
/* END Event struct descriptors */
|
||||
|
||||
EAPI Exactness_Unit *
|
||||
exactness_unit_file_read(const char *filename)
|
||||
{
|
||||
int i;
|
||||
Eina_List *itr, *itr2;
|
||||
Exactness_Objects *e_objs;
|
||||
Exactness_Object *e_obj, *e_parent;
|
||||
Exactness_Unit *unit = NULL;
|
||||
Eet_File *file;
|
||||
eet_init();
|
||||
file = eet_open(filename, EET_FILE_MODE_READ);
|
||||
if (!file)
|
||||
{
|
||||
fprintf(stderr, "Impossible to extract EET from %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
unit = eet_data_read(file, _unit_desc_make(), "cache");
|
||||
for (i = 0; i < unit->nb_shots; i++)
|
||||
{
|
||||
char entry[32];
|
||||
Exactness_Image *ex_img = malloc(sizeof(*ex_img));
|
||||
sprintf(entry, "images/%d", i + 1);
|
||||
ex_img->pixels = eet_data_image_read(file, entry,
|
||||
&ex_img->w, &ex_img->h, NULL,
|
||||
NULL, NULL, NULL);
|
||||
unit->imgs = eina_list_append(unit->imgs, ex_img);
|
||||
}
|
||||
EINA_LIST_FOREACH(unit->objs, itr, e_objs)
|
||||
{
|
||||
Eina_Hash *hash = eina_hash_pointer_new(NULL);
|
||||
EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj)
|
||||
{
|
||||
eina_hash_set(hash, &(e_obj->id), e_obj);
|
||||
}
|
||||
EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj)
|
||||
{
|
||||
if (!e_obj->parent_id)
|
||||
e_objs->main_objs = eina_list_append(e_objs->main_objs, e_obj);
|
||||
else
|
||||
{
|
||||
e_parent = eina_hash_find(hash, &(e_obj->parent_id));
|
||||
if (e_parent) e_parent->children = eina_list_append(e_parent->children, e_obj);
|
||||
}
|
||||
}
|
||||
eina_hash_free(hash);
|
||||
}
|
||||
eet_close(file);
|
||||
eet_shutdown();
|
||||
return unit;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
exactness_unit_file_write(Exactness_Unit *unit, const char *filename)
|
||||
{
|
||||
Eina_List *itr;
|
||||
Exactness_Image *ex_img;
|
||||
Eet_File *file;
|
||||
int i = 1;
|
||||
eet_init();
|
||||
file = eet_open(filename, EET_FILE_MODE_WRITE);
|
||||
eet_data_write(file, _unit_desc_make(), "cache", unit, EINA_TRUE);
|
||||
EINA_LIST_FOREACH(unit->imgs, itr, ex_img)
|
||||
{
|
||||
char entry[32];
|
||||
sprintf(entry, "images/%d", i++);
|
||||
eet_data_image_write(file, entry,
|
||||
ex_img->pixels, ex_img->w, ex_img->h, 0xFF,
|
||||
0, 100, EET_IMAGE_LOSSLESS);
|
||||
}
|
||||
eet_close(file);
|
||||
eet_shutdown();
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **imgO)
|
||||
{
|
||||
unsigned int w, h;
|
||||
int *pxs1, *pxs2, *pxsO = NULL;
|
||||
unsigned int w1 = img1 ? img1->w : 0, h1 = img1 ? img1->h : 0;
|
||||
unsigned int w2 = img2 ? img2->w : 0, h2 = img2 ? img2->h : 0;
|
||||
unsigned int wO = MAX(w1, w2);
|
||||
unsigned int hO = MAX(h1, h2);
|
||||
Eina_Bool ret = EINA_FALSE;
|
||||
if (imgO) *imgO = NULL;
|
||||
if (!wO || !hO) return EINA_FALSE;
|
||||
|
||||
pxs1 = img1 ? img1->pixels : NULL;
|
||||
pxs2 = img2 ? img2->pixels : NULL;
|
||||
if (imgO) pxsO = malloc(wO * hO * 4);
|
||||
|
||||
for (w = 0; w < wO; w++)
|
||||
{
|
||||
for (h = 0; h < hO; h++)
|
||||
{
|
||||
Eina_Bool valid1 = img1 ? w < w1 && h < h1 : EINA_FALSE;
|
||||
Eina_Bool valid2 = img2 ? w < w2 && h < h2 : EINA_FALSE;
|
||||
int px1 = valid1 ? pxs1[h * w1 + w] : 0;
|
||||
int px2 = valid2 ? pxs2[h * w2 + w] : 0;
|
||||
int r1 = (px1 & 0x00FF0000) >> 16;
|
||||
int r2 = (px2 & 0x00FF0000) >> 16;
|
||||
int g1 = (px1 & 0x0000FF00) >> 8;
|
||||
int g2 = (px2 & 0x0000FF00) >> 8;
|
||||
int b1 = (px1 & 0x000000FF);
|
||||
int b2 = (px2 & 0x000000FF);
|
||||
int new_r, new_g, new_b;
|
||||
if (valid1 || valid2)
|
||||
{
|
||||
if (px1 != px2)
|
||||
{
|
||||
new_r = 0xFF;
|
||||
new_g = ((g1 + g2) >> 1) >> 2;
|
||||
new_b = ((b1 + b2) >> 1) >> 2;
|
||||
ret = EINA_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_r = (((r1 + r2) >> 1) >> 2) + 0xC0;
|
||||
new_g = (((g1 + g2) >> 1) >> 2) + 0xC0;
|
||||
new_b = (((b1 + b2) >> 1) >> 2) + 0xC0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
new_r = new_g = new_b = 0x0;
|
||||
}
|
||||
if (pxsO) pxsO[h * wO + w] = 0xFF000000 | new_r << 16 | new_g << 8 | new_b;
|
||||
}
|
||||
}
|
||||
if (imgO)
|
||||
{
|
||||
Exactness_Image *imgR = calloc(1, sizeof(Exactness_Image));
|
||||
*imgO = imgR;
|
||||
imgR->w = wO;
|
||||
imgR->h = hO;
|
||||
imgR->pixels = pxsO;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
EAPI void exactness_image_free(Exactness_Image *img)
|
||||
{
|
||||
if (!img) return;
|
||||
free(img->pixels);
|
||||
free(img);
|
||||
}
|
Loading…
Reference in New Issue