summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Levin <avi.levin@samsung.com>2015-09-02 14:55:24 +0300
committerAvi Levin <avi.levin@samsung.com>2015-09-02 14:55:24 +0300
commitf4738ea75213138db1ef184574bd78411650f0b6 (patch)
treeb4a7c4178e5ce12e7503c910e6c48b440ba2c10d
parentae7fd63eaa75247bc309365db23e54624bbaf0e2 (diff)
Get list of object by regex
I added new field to Obj_Info: ptr_parent_regex - closest Eo parent that matches current regex.
-rw-r--r--src/bin/cli.c2
-rw-r--r--src/lib/debug_eo.c35
-rw-r--r--src/lib/debug_eo.h1
3 files changed, 32 insertions, 6 deletions
diff --git a/src/bin/cli.c b/src/bin/cli.c
index d016218..efb04e0 100644
--- a/src/bin/cli.c
+++ b/src/bin/cli.c
@@ -446,7 +446,7 @@ _list_resp_handler(const void *buf, int size, void **buf_ret, int *size_ret)
446 /* Fill children lists */ 446 /* Fill children lists */
447 EINA_LIST_FOREACH(objs, l, info) 447 EINA_LIST_FOREACH(objs, l, info)
448 { 448 {
449 Obj_Info *info_parent = eina_hash_find(objects_hash, &info->ptr_parent); 449 Obj_Info *info_parent = eina_hash_find(objects_hash, &info->ptr_parent_regex);
450 450
451 if(info_parent) 451 if(info_parent)
452 info_parent->children = eina_list_append(info_parent->children, info); 452 info_parent->children = eina_list_append(info_parent->children, info);
diff --git a/src/lib/debug_eo.c b/src/lib/debug_eo.c
index 2675662..4355827 100644
--- a/src/lib/debug_eo.c
+++ b/src/lib/debug_eo.c
@@ -1,4 +1,5 @@
1#include <Eet.h> 1#include <Eet.h>
2#include <regex.h>
2 3
3#include "debug_eo.h" 4#include "debug_eo.h"
4#include "debug_common.h" 5#include "debug_common.h"
@@ -27,11 +28,33 @@ _list_req_handle(const void *buf, int size, void **buf_ret, int *size_ret)
27 Eina_List *itr; 28 Eina_List *itr;
28 Obj_Info *info; 29 Obj_Info *info;
29 if (req->classname) 30 if (req->classname)
30 EINA_LIST_FOREACH(objs_list, itr, info) 31 {
31 { 32 regex_t regex;
32 if (!strcmp(info->kl_name, req->classname)) 33
33 resp.objs = eina_list_append(resp.objs, info); 34 if (regcomp(&regex, req->classname, 0))
35 {
36 fprintf(stderr, "Could not compile regex\n");
37 resp.objs = objs_list;;
38 }
39 else
40 {
41 EINA_LIST_FOREACH(objs_list, itr, info)
42 {
43 if (!regexec(&regex, info->kl_name, 0, NULL, 0)){
44 /* Update regex parent */
45 Eo *curr_parent = info->ptr_parent;
46 while (curr_parent && regexec(&regex,
47 eo_class_name_get(curr_parent), 0, NULL, 0))
48 {
49 eo_do(curr_parent, curr_parent = eo_parent_get());
50 }
51 info->ptr_parent_regex = curr_parent;
52 resp.objs = eina_list_append(resp.objs, info);
53 }
54 }
34 } 55 }
56 regfree(&regex);
57 }
35 else resp.objs = objs_list; 58 else resp.objs = objs_list;
36 59
37 *buf_ret = eet_data_descriptor_encode(_list_resp_edd, &resp, size_ret); 60 *buf_ret = eet_data_descriptor_encode(_list_resp_edd, &resp, size_ret);
@@ -59,9 +82,10 @@ _info_del(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA
59void 82void
60debug_eo_object_add(Eo *obj) 83debug_eo_object_add(Eo *obj)
61{ 84{
62 Obj_Info *info = calloc(1, sizeof(info)); 85 Obj_Info *info = calloc(1, sizeof(*info));
63 info->ptr = obj; 86 info->ptr = obj;
64 eo_do(obj, info->ptr_parent = eo_parent_get()); 87 eo_do(obj, info->ptr_parent = eo_parent_get());
88 info->ptr_parent_regex = info->ptr_parent;
65 info->kl_name = eo_class_name_get(obj); 89 info->kl_name = eo_class_name_get(obj);
66 objs_list = eina_list_append(objs_list, info); 90 objs_list = eina_list_append(objs_list, info);
67 91
@@ -85,6 +109,7 @@ debug_eo_init()
85 109
86 EET_DATA_DESCRIPTOR_ADD_BASIC(_obj_info_edd, Obj_Info, "ptr", ptr, EET_T_ULONG_LONG); 110 EET_DATA_DESCRIPTOR_ADD_BASIC(_obj_info_edd, Obj_Info, "ptr", ptr, EET_T_ULONG_LONG);
87 EET_DATA_DESCRIPTOR_ADD_BASIC(_obj_info_edd, Obj_Info, "ptr_parent", ptr_parent, EET_T_ULONG_LONG); 111 EET_DATA_DESCRIPTOR_ADD_BASIC(_obj_info_edd, Obj_Info, "ptr_parent", ptr_parent, EET_T_ULONG_LONG);
112 EET_DATA_DESCRIPTOR_ADD_BASIC(_obj_info_edd, Obj_Info, "ptr_parent_regex", ptr_parent_regex, EET_T_ULONG_LONG);
88 EET_DATA_DESCRIPTOR_ADD_BASIC(_obj_info_edd, Obj_Info, "kl_name", kl_name, EET_T_STRING); 113 EET_DATA_DESCRIPTOR_ADD_BASIC(_obj_info_edd, Obj_Info, "kl_name", kl_name, EET_T_STRING);
89 EET_DATA_DESCRIPTOR_ADD_LIST(_list_resp_edd, _List_Response, "objects", objs, _obj_info_edd); 114 EET_DATA_DESCRIPTOR_ADD_LIST(_list_resp_edd, _List_Response, "objects", objs, _obj_info_edd);
90 115
diff --git a/src/lib/debug_eo.h b/src/lib/debug_eo.h
index 2152065..7ca6a33 100644
--- a/src/lib/debug_eo.h
+++ b/src/lib/debug_eo.h
@@ -8,6 +8,7 @@ typedef struct
8{ 8{
9 Eo *ptr; 9 Eo *ptr;
10 Eo *ptr_parent; 10 Eo *ptr_parent;
11 Eo *ptr_parent_regex;/* ptr_parent_regex - closest parent that matches current regex */
11 const char *kl_name; 12 const char *kl_name;
12 Eina_List *children; 13 Eina_List *children;
13} Obj_Info; 14} Obj_Info;