TEMP: support Debug Eolian values in clouseau gui

This commit is contained in:
Avi Levin 2015-11-15 14:24:11 +02:00
parent 481bdef39c
commit 2af058297d
4 changed files with 215 additions and 39 deletions

View File

@ -47,14 +47,28 @@ typedef struct
{
Obj_Info *info;
Eina_List *children;
} _Obj_list_node;
typedef enum
{
CLOUSEAU_OBJ_CLASS = 0,
CLOUSEAU_OBJ_FUNC,
CLOUSEAU_OBJ_PARAM
} Clouseau_Obj_Info_Type;
typedef struct
{
Clouseau_Obj_Info_Type type;
void *data;
} _Obj_info_node;
static Eina_List *_pending = NULL;
static Eina_Debug_Session *_session = NULL;
static int _selected_app = -1;
static Elm_Genlist_Item_Class *_objs_itc = NULL;
static Eina_List *_objs_info_tree = NULL;
static Elm_Genlist_Item_Class *_obj_info_itc = NULL;
static Eina_List *_objs_list_tree = NULL;
static Eolian_Debug_Object_Information *obj_info = NULL;
static Eina_Debug_Client *_current_client = NULL;
static void
@ -87,32 +101,156 @@ _pending_add(uint32_t *opcode, void *buffer, int size)
_pending = eina_list_append(_pending, req);
}
static Eina_Bool
_obj_info_expand_request_cb(void *data EINA_UNUSED,
Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
void *event_info)
{
Elm_Object_Item *glit = event_info;
elm_genlist_item_expanded_set(glit, EINA_TRUE);
return EINA_TRUE;
}
static Eina_Bool
_obj_info_contract_request_cb(void *data EINA_UNUSED,
Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
void *event_info)
{
Elm_Object_Item *glit = event_info;
elm_genlist_item_expanded_set(glit, EINA_FALSE);
return EINA_TRUE;
}
static Eina_Bool
_obj_info_expanded_cb(void *data EINA_UNUSED,
Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
void *event_info)
{
Elm_Object_Item *glit = event_info;
_Obj_info_node *node = elm_object_item_data_get(glit);
Evas_Object *list = elm_object_item_widget_get(glit);
Eolian_Debug_Class *kl;
Eina_List *func_itr, *param_itr;
Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_TREE;
Eolian_Debug_Function *func;
if(node->type == CLOUSEAU_OBJ_CLASS)
{
kl = (Eolian_Debug_Class *)(node->data);
EINA_LIST_FOREACH(kl->functions, func_itr, func)
{
node = calloc(1, sizeof(*node));
node->type = CLOUSEAU_OBJ_FUNC;
node->data = func;
Elm_Object_Item *glg = elm_genlist_item_append(
list, _obj_info_itc,
(void *)node, glit,
type,
NULL, NULL);
elm_genlist_item_expanded_set(glg, EINA_FALSE);
}
}
else if(node->type == CLOUSEAU_OBJ_FUNC)
{
func = (Eolian_Debug_Function *)(node->data);
type = ELM_GENLIST_ITEM_NONE;
Eolian_Debug_Parameter *param;
EINA_LIST_FOREACH(func->params, param_itr, param)
{
node = calloc(1, sizeof(*node));
node->type = CLOUSEAU_OBJ_PARAM;
node->data = param;
elm_genlist_item_append(
list, _obj_info_itc,
(void *)node, glit,
type,
NULL, NULL);
}
}
return EINA_TRUE;
}
static Eina_Bool
_obj_info_contracted_cb(void *data EINA_UNUSED,
Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
void *event_info)
{
Elm_Object_Item *glit = event_info;
elm_genlist_item_subitems_clear(glit);
return EINA_TRUE;
}
static void _obj_info_item_del(void *data, Evas_Object *obj EINA_UNUSED)
{
_Obj_info_node *node = data;
free(node);
}
#define _MAX_LABEL 50
static char *_obj_info_item_label_get(void *data, Evas_Object *obj EINA_UNUSED,
const char *part EINA_UNUSED)
{
_Obj_info_node *node = data;
char name[_MAX_LABEL]; name[0] = '\0';
Eolian_Debug_Parameter *param;
char *print_format;
switch(node->type)
{
case CLOUSEAU_OBJ_CLASS : strncpy(name,
((Eolian_Debug_Class *)(node->data))->name, _MAX_LABEL); break;
case CLOUSEAU_OBJ_FUNC : strncpy(name,
((Eolian_Debug_Function *)(node->data))->name, _MAX_LABEL);
break;
case CLOUSEAU_OBJ_PARAM : param = node->data;
if (param->type == EOLIAN_DEBUG_STRING)
print_format = "%s";
else
print_format = "%lX";
snprintf(name, _MAX_LABEL,
print_format, param->value.value);
}
return (char *)(long)strdup(name);
}
#undef _MAX_LABEL
static Eina_Bool
_debug_obj_info_cb(Eina_Debug_Client *src EINA_UNUSED,
void *buffer, int size)
{
Eolian_Debug_Object_Information *info = eolian_debug_object_information_decode(buffer, size);
if(obj_info)
{
elm_genlist_clear(pub_widgets->elm_win1->elm_genlist2);
eolian_debug_object_information_free(obj_info);
obj_info = NULL;
}
obj_info = eolian_debug_object_information_decode(buffer, size);
Eolian_Debug_Class *kl;
Eina_List *kl_itr, *func_itr, *param_itr;
EINA_LIST_FOREACH(info->classes, kl_itr, kl)
Eina_List *kl_itr;
EINA_LIST_FOREACH(obj_info->classes, kl_itr, kl)
{
Eolian_Debug_Function *func;
printf("Class %s:\n", kl->name);
EINA_LIST_FOREACH(kl->functions, func_itr, func)
{
Eolian_Debug_Parameter *param;
printf(" Function %s:\n", func->name);
EINA_LIST_FOREACH(func->params, param_itr, param)
{
if (param->type == EOLIAN_DEBUG_STRING)
printf(" %s\n", (char *)param->value.value);
else
printf(" %lX\n", param->value.value);
}
}
Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_TREE;
_Obj_info_node *node = NULL;
node = calloc(1, sizeof(*node));
node->type = CLOUSEAU_OBJ_CLASS;
node->data = kl;
Elm_Object_Item *glg = elm_genlist_item_append(
pub_widgets->elm_win1->elm_genlist2, _obj_info_itc,
(void *)node, NULL,
type,
NULL, NULL);
elm_genlist_item_expanded_set(glg, EINA_FALSE);
}
eolian_debug_object_information_free(info);
return EINA_TRUE;
}
@ -142,7 +280,7 @@ static void
_objs_sel_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Elm_Object_Item *glit = event_info;
_Obj_info_node *info_node = elm_object_item_data_get(glit);
_Obj_list_node *info_node = elm_object_item_data_get(glit);
uint64_t ptr = (uint64_t)info_node->info->ptr;
@ -157,7 +295,7 @@ _objs_expanded_cb(void *data EINA_UNUSED,
{
Eina_List *l;
Elm_Object_Item *glit = event_info;
_Obj_info_node *info_node = elm_object_item_data_get(glit), *it_data;
_Obj_list_node *info_node = elm_object_item_data_get(glit), *it_data;
Evas_Object *list = elm_object_item_widget_get(glit);
EINA_LIST_FOREACH(info_node->children, l, it_data)
{
@ -192,14 +330,14 @@ static char *
_objs_item_label_get(void *data, Evas_Object *obj EINA_UNUSED,
const char *part EINA_UNUSED)
{
_Obj_info_node *info_node = data;
_Obj_list_node *info_node = data;
return (char *)(long)strdup(info_node->info->kl_name);
}
static void
_objs_nodes_free(Eina_List *parents)
{
_Obj_info_node *info_node;
_Obj_list_node *info_node;
EINA_LIST_FREE(parents, info_node)
{
@ -216,10 +354,10 @@ _hoversel_selected_app(void *data EINA_UNUSED,
Elm_Object_Item *hoversel_it = event_info;
_selected_app = (int)(long)elm_object_item_data_get(hoversel_it);
if(_objs_info_tree)
if(_objs_list_tree)
{
_objs_nodes_free(_objs_info_tree);
_objs_info_tree = NULL;
_objs_nodes_free(_objs_list_tree);
_objs_list_tree = NULL;
elm_genlist_clear(pub_widgets->elm_win1->elm_genlist1);
}
@ -298,12 +436,12 @@ _elm_objects_list_cb(Eina_Debug_Client *src EINA_UNUSED, void *buffer, int size)
Eina_Hash *objects_hash = NULL;
Eina_List *l = NULL;
objects_hash = eina_hash_pointer_new(NULL);
_Obj_info_node *info_node;
_Obj_list_node *info_node;
/* Add all objects to hash table */
EINA_LIST_FOREACH(objs, l, info)
{
info_node = calloc(1, sizeof(_Obj_info_node));
info_node = calloc(1, sizeof(_Obj_list_node));
info_node->info = info;
info_node->children = NULL;
eina_hash_add(objects_hash, &(info_node->info->ptr),
@ -313,17 +451,17 @@ _elm_objects_list_cb(Eina_Debug_Client *src EINA_UNUSED, void *buffer, int size)
/* Fill children lists */
EINA_LIST_FOREACH(objs, l, info)
{
_Obj_info_node *info_parent = eina_hash_find(objects_hash, &(info->parent));
_Obj_list_node *info_parent = eina_hash_find(objects_hash, &(info->parent));
info_node = eina_hash_find(objects_hash, &(info->ptr));
if(info_parent)
info_parent->children = eina_list_append(info_parent->children, info_node);
else
_objs_info_tree = eina_list_append(_objs_info_tree, info_node);
_objs_list_tree = eina_list_append(_objs_list_tree, info_node);
}
/* Add to Genlist */
EINA_LIST_FOREACH(_objs_info_tree, l, info_node)
EINA_LIST_FOREACH(_objs_list_tree, l, info_node)
{
Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE;
@ -406,7 +544,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
pub_widgets = gui_gui_get();
//Init objects Genlist
Evas_Object *genlist = pub_widgets->elm_win1->elm_genlist1;
Evas_Object *objs_list_genlist = pub_widgets->elm_win1->elm_genlist1;
if (!_objs_itc)
{
_objs_itc = elm_genlist_item_class_new();
@ -416,13 +554,30 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
_objs_itc->func.state_get = NULL;
_objs_itc->func.del = NULL;
}
eo_do(genlist,
eo_do(objs_list_genlist,
eo_event_callback_add(ELM_GENLIST_EVENT_EXPAND_REQUEST, _objs_expand_request_cb, NULL),
eo_event_callback_add(ELM_GENLIST_EVENT_CONTRACT_REQUEST, _objs_contract_request_cb, NULL),
eo_event_callback_add(ELM_GENLIST_EVENT_EXPANDED, _objs_expanded_cb, NULL),
eo_event_callback_add(ELM_GENLIST_EVENT_CONTRACTED, _objs_contracted_cb, NULL)
);
//Init object info Genlist
Evas_Object *obj_info_genlist = pub_widgets->elm_win1->elm_genlist2;
if (!_obj_info_itc)
{
_obj_info_itc = elm_genlist_item_class_new();
_obj_info_itc->item_style = "default";
_obj_info_itc->func.text_get = _obj_info_item_label_get;
_obj_info_itc->func.content_get = NULL;
_obj_info_itc->func.state_get = NULL;
_obj_info_itc->func.del = _obj_info_item_del;
}
eo_do(obj_info_genlist,
eo_event_callback_add(ELM_GENLIST_EVENT_EXPAND_REQUEST, _obj_info_expand_request_cb, NULL),
eo_event_callback_add(ELM_GENLIST_EVENT_CONTRACT_REQUEST, _obj_info_contract_request_cb, NULL),
eo_event_callback_add(ELM_GENLIST_EVENT_EXPANDED, _obj_info_expanded_cb, NULL),
eo_event_callback_add(ELM_GENLIST_EVENT_CONTRACTED, _obj_info_contracted_cb, NULL)
);
_session = eina_debug_session_new();
if (!eina_debug_local_connect(_session))
@ -436,7 +591,8 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
elm_run();
error:
_objs_nodes_free(_objs_info_tree);
eolian_debug_object_information_free(obj_info);
_objs_nodes_free(_objs_list_tree);
eina_debug_session_free(_session);
eina_shutdown();
eolian_shutdown();

View File

@ -71,7 +71,7 @@
{
"Elm.Widget.part_text":[null, "Hoversel"],
"Evas.Object.size_hint_weight":[1, 0],
"Evas.Object.size_hint_align":[0.5, 0],
"Evas.Object.size_hint_align":[0.50, 0],
"Efl.Gfx.Base.visible":[true],
"Efl.Gfx.Base.size":[1174, 643],
"Efl.Gfx.Base.position":[-8, -2],
@ -99,7 +99,21 @@
"Contains":
{
"elm_genlist1":["left"],
"__dummy":["right"]
"elm_genlist2":["right"]
}
},
"elm_genlist2":
{
"Desc":
{
"parent":"elm_panes1",
"class":"Elm.Genlist",
"public":true
},
"Properties":
{
"Evas.Object.size_hint_weight":[1, 1],
"Efl.Gfx.Base.visible":[true]
}
},
"elm_genlist1":
@ -117,4 +131,4 @@
}
}
}
}
}

View File

@ -32,6 +32,7 @@ gui_elm_win1_create(Eo *__main_parent)
Eo *elm_box1;
Eo *elm_hoversel1;
Eo *elm_panes1;
Eo *elm_genlist2;
Eo *elm_genlist1;
@ -75,12 +76,16 @@ gui_elm_win1_create(Eo *__main_parent)
eo_do(elm_panes1, evas_obj_size_hint_align_set(-1.000000, -1.000000));
eo_do(elm_box1, elm_obj_box_pack_end(elm_hoversel1));
eo_do(elm_box1, elm_obj_box_pack_end(elm_panes1));
elm_genlist2 = eo_add(ELM_GENLIST_CLASS, elm_panes1);
pub_widgets->elm_genlist2 = elm_genlist2;
eo_do(elm_genlist2, evas_obj_size_hint_weight_set(1.000000, 1.000000));
eo_do(elm_genlist2, efl_gfx_visible_set(EINA_TRUE));
elm_genlist1 = eo_add(ELM_GENLIST_CLASS, elm_panes1);
pub_widgets->elm_genlist1 = elm_genlist1;
eo_do(elm_genlist1, evas_obj_size_hint_weight_set(1.000000, 1.000000));
eo_do(elm_genlist1, efl_gfx_visible_set(EINA_TRUE));
eo_do(elm_panes1, elm_obj_container_content_set("left", elm_genlist1));
eo_do(elm_panes1, elm_obj_container_content_set("right", NULL));
eo_do(elm_panes1, elm_obj_container_content_set("right", elm_genlist2));
eo_do(elm_win1, efl_gfx_visible_set(EINA_TRUE));
eo_do(elm_win1, eo_event_callback_add(EO_BASE_EVENT_DEL, _pubs_free_cb, pub_widgets));

View File

@ -9,6 +9,7 @@ typedef struct
Eo *elm_box1;
Eo *elm_hoversel1;
Eo *elm_panes1;
Eo *elm_genlist2;
Eo *elm_genlist1;
} Gui_Elm_Win1_Widgets;