summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWonki Kim <wonki_.kim@samsung.com>2018-11-11 20:45:38 +0200
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2018-12-11 21:06:11 +0200
commit413f1c127d7786ba418555194e08c56957b88957 (patch)
tree2cdc6e9406add09c2db4796a2e3dbd0b06a5bf59
parentee6cdd64162b2c1f7b94ef6b88d01bbe0a6b0614 (diff)
db: introduce [de]serializing _DB as a file
Summary: it's necessary to save _DB data as a file and load it later. It will provide benefits such as saving time to build _DB, easy to share a kind of a preset _DB, etc. this patch introduce de/serializing _DB as a file. Reviewers: JackDanielZ Subscribers: jsuya, bowonryu, YOhoho Differential Revision: https://phab.enlightenment.org/D6950
-rw-r--r--src/bin/db.c750
-rw-r--r--src/bin/db.h5
-rw-r--r--src/bin/gen.h1
-rw-r--r--src/bin/main.c13
-rw-r--r--src/lib/common.c2
-rw-r--r--src/lib/common.h5
6 files changed, 721 insertions, 55 deletions
diff --git a/src/bin/db.c b/src/bin/db.c
index 3789a4c..1eef56c 100644
--- a/src/bin/db.c
+++ b/src/bin/db.c
@@ -1,9 +1,30 @@
1#include <Eina.h> 1#include <Eina.h>
2#include <Eet.h>
2 3
3#include "common.h" 4#include "common.h"
4#include "gen.h" 5#include "gen.h"
5#include "db.h" 6#include "db.h"
6 7
8struct
9{
10 Ea_Value_Type t;
11 const char *name;
12} eet_map[] = {
13 {EA_VALUE_BASIC,"BASIC"},
14 {EA_VALUE_BOOLEAN,"BOOLEAN"},
15 {EA_VALUE_ENUM,"ENUM"},
16 {EA_VALUE_FUNCTION,"FUNCTION"},
17 {EA_VALUE_ALIAS,"ALIAS"},
18 {EA_VALUE_OBJECT,"OBJECT"},
19 {EA_VALUE_OBJECTS_LIST,"OBJECT_LIST"},
20 {EA_VALUE_STRINGS_ARRAY,"STRINGS_ARRAY"},
21 {EA_VALUE_NUMBERS_ARRAY,"NUMBERS_ARRAY"},
22 {EA_VALUE_POINTER,"POINTER"},
23 {EA_VALUE_STRUCT,"STRUCT"},
24 {EA_VALUE_REPEATER_VARIABLE,"REPEATER_VARIABLE"},
25 {EA_VALUE_LAST, NULL},
26};
27
7const char *_random_text = 28const char *_random_text =
8"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ullamcorper luctus nisl nec euismod. Etiam eros felis, euismod a rhoncus bibendum, sollicitudin eget quam. Nullam ac dui at tellus suscipit molestie eu eget lorem. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nam id consectetur arcu. Nullam at quam vulputate, viverra mi laoreet, viverra nunc. Maecenas ut ante pulvinar, maximus magna eget, tempor erat. Sed ante sapien, dignissim in lacinia vitae, convallis at ligula.\\n" 29"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ullamcorper luctus nisl nec euismod. Etiam eros felis, euismod a rhoncus bibendum, sollicitudin eget quam. Nullam ac dui at tellus suscipit molestie eu eget lorem. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nam id consectetur arcu. Nullam at quam vulputate, viverra mi laoreet, viverra nunc. Maecenas ut ante pulvinar, maximus magna eget, tempor erat. Sed ante sapien, dignissim in lacinia vitae, convallis at ligula.\\n"
9"Integer est nunc, fermentum quis eros vel, malesuada tempus nulla. Vivamus a rhoncus justo. Aenean tempor ipsum urna, et interdum nisl interdum sit amet. Suspendisse scelerisque leo felis, eu aliquam ante bibendum mollis. Suspendisse convallis tincidunt velit, vel rutrum justo placerat ut. Vivamus vel euismod ex, non vulputate augue. Nunc eu libero eget ligula pulvinar porttitor.\\n" 30"Integer est nunc, fermentum quis eros vel, malesuada tempus nulla. Vivamus a rhoncus justo. Aenean tempor ipsum urna, et interdum nisl interdum sit amet. Suspendisse scelerisque leo felis, eu aliquam ante bibendum mollis. Suspendisse convallis tincidunt velit, vel rutrum justo placerat ut. Vivamus vel euismod ex, non vulputate augue. Nunc eu libero eget ligula pulvinar porttitor.\\n"
@@ -12,13 +33,15 @@ const char *_random_text =
12 33
13typedef struct 34typedef struct
14{ 35{
15 const Eolian_Class *kl; 36 const Eolian_Unit *unit; // restore target #1
37 const Eolian_Class *kl; // restore target #1
38 const char *kl_name_eet; // restore hint for target #1
16 unsigned int nb_occ; 39 unsigned int nb_occ;
17 unsigned int min_depth; 40 unsigned int min_depth;
18 unsigned int max_depth; 41 unsigned int max_depth;
19 unsigned int nb_occ_max_per_ml; 42 unsigned int nb_occ_max_per_ml;
20 const char *ml_kl_name; 43 const char *ml_kl_name;
21 Eina_List *children_configs; 44 Eina_List *children_configs; /* List of _Wdg_Children_Config */
22 Eina_List *contents; /* List of _Child */ 45 Eina_List *contents; /* List of _Child */
23 Eina_List *containers; /* List of _Child */ 46 Eina_List *containers; /* List of _Child */
24 Eina_List *creator_funcs; /* List of _Wdg_Function */ 47 Eina_List *creator_funcs; /* List of _Wdg_Function */
@@ -26,8 +49,8 @@ typedef struct
26 Eina_List *funcs; /* List of _Wdg_Function */ 49 Eina_List *funcs; /* List of _Wdg_Function */
27 Eina_List *container_values; /* List of _Parameter; stored into the container */ 50 Eina_List *container_values; /* List of _Parameter; stored into the container */
28 Eina_List *events; /* List of _Event */ 51 Eina_List *events; /* List of _Event */
29 Eina_Bool is_legacy:1; 52 Eina_Bool used;
30 Eina_Bool used:1; 53 Eina_Bool is_legacy;
31} _Widget; 54} _Widget;
32 55
33/*Used during generation */ 56/*Used during generation */
@@ -46,14 +69,17 @@ typedef struct
46typedef struct 69typedef struct
47{ 70{
48 unsigned int nb_occ; 71 unsigned int nb_occ;
49 Eina_Stringshare *seq; /* Used to compare configurations, regardless to the number of occurrences, act.g cCc */ 72 char *seq; /* Used to compare configurations, regardless to the number of occurrences, act.g cCc */
50 Eina_List *items; /* List of _Wdg_Children_Config_Item */ 73 Eina_List *items; /* List of _Wdg_Children_Config_Item */
51} _Wdg_Children_Config; 74} _Wdg_Children_Config;
52 75
53typedef struct 76typedef struct
54{ 77{
55 unsigned int nb_occ; 78 unsigned int nb_occ;
56 _Widget *w; 79 _Widget *w; // restore target #1
80 char *w_kl_name_eet; // restore hint for target #1
81 const char *ml_kl_name;
82 Eina_Bool is_legacy_eet;
57} _Child; 83} _Child;
58 84
59typedef struct 85typedef struct
@@ -65,12 +91,12 @@ typedef struct
65typedef struct 91typedef struct
66{ 92{
67 double nb_occ; 93 double nb_occ;
68 union 94 /* Field or value, depending on is_field */
69 { 95 const Eolian_Enum_Type_Field *field; // restore target #3
70 const Eolian_Enum_Type_Field *field; 96 const char *field_type_eet; // restore hint for target #3
71 int value; 97 const char *field_name_eet; // restore hint for target #3
72 }; 98 int value;
73 Eina_Bool is_field:1; 99 Eina_Bool is_field;
74} _Enum_Value; 100} _Enum_Value;
75 101
76typedef struct 102typedef struct
@@ -82,13 +108,17 @@ typedef struct
82typedef struct 108typedef struct
83{ 109{
84 double nb_occ; 110 double nb_occ;
85 _Widget *val; 111 _Widget *val; // restore target #4
112 const char *val_name_eet; // restore hint for target #4
113 Eina_Bool is_legacy_eet;
86} _Obj_Value; 114} _Obj_Value;
87 115
88typedef struct 116typedef struct
89{ 117{
90 double nb_occ; 118 double nb_occ;
91 const Eolian_Event *event; 119 const Eolian_Event *event; // restore target #9
120 const char *event_kl_name_eet; // restore hint for target #9
121 const char *event_name_eet; // restore hint for target #9
92} _Event_Value; 122} _Event_Value;
93 123
94typedef enum 124typedef enum
@@ -110,16 +140,19 @@ typedef enum
110 140
111typedef struct 141typedef struct
112{ 142{
113 const Eolian_Function_Parameter *eo_param; 143 const Eolian_Function_Parameter *eo_param; // restore target #5
144 char *func_param_name_eet; // restore hint for target #5
114 Ea_Value_Type ea_type; 145 Ea_Value_Type ea_type;
115 _Basic_Type basic_type; 146 _Basic_Type basic_type;
116 union 147
117 { 148// union
149// {
118 Eina_List *bool_values; /* List of _Bool_Value */ 150 Eina_List *bool_values; /* List of _Bool_Value */
119 Eina_List *enum_values; /* List of _Enum_Value */ 151 Eina_List *enum_values; /* List of _Enum_Value */
120 Eina_List *struct_values; /* List of _Parameter */ 152 Eina_List *struct_values; /* List of _Parameter */
121 Eina_List *object_values; /* List of _Obj_Value */ 153 Eina_List *object_values; /* List of _Obj_Value */
122 Eina_List *event_values; /* List of _Event_Value */ 154 Eina_List *event_values; /* List of _Event_Value */
155
123 struct 156 struct
124 { 157 {
125 int int_min; 158 int int_min;
@@ -143,29 +176,33 @@ typedef struct
143 }; 176 };
144 Eina_List *fixed_strings; /* List of _Fixed_String */ 177 Eina_List *fixed_strings; /* List of _Fixed_String */
145 Eina_List *files_list; /* List of filenames */ 178 Eina_List *files_list; /* List of filenames */
146 }; 179// } u;
147 _Param_Mode mode; 180 _Param_Mode mode;
148 Eina_Bool is_key:1; 181 Eina_Bool is_key;
149 Eina_Bool used:1; 182 Eina_Bool used;
150} _Parameter; 183} _Parameter;
151 184
152typedef struct 185typedef struct
153{ 186{
154 const Eolian_Function *eo_func; 187 const Eolian_Function *eo_func; // restore target #7
188 char *kl_name_eet, *func_name_eet; // restore hint for target #7
155 Eina_List *params; /* List of _Parameter */ 189 Eina_List *params; /* List of _Parameter */
156} _Function; 190} _Function;
157 191
158typedef struct 192typedef struct
159{ 193{
160 unsigned int nb_occ; 194 unsigned int nb_occ;
161 _Function *func; 195 _Function *func; // Restore target #10
196 char *kl_name_eet, *func_name_eet; // restore hint for target #10
162 Eina_List *params; /* List of _Parameter: specific parameters values for this widget */ 197 Eina_List *params; /* List of _Parameter: specific parameters values for this widget */
163} _Wdg_Function; 198} _Wdg_Function;
164 199
165typedef struct 200typedef struct
166{ 201{
167 unsigned int nb_occ; 202 unsigned int nb_occ;
168 const Eolian_Event *eo_ev; 203 const Eolian_Event *eo_ev; // restore target #8
204 const char *event_kl_name_eet; // restore hint for target #8
205 const char *event_name_eet; // restore hint for target #8
169} _Event; 206} _Event;
170 207
171typedef struct 208typedef struct
@@ -194,6 +231,219 @@ typedef struct
194 231
195static Eina_TLS _thread_data_key; 232static Eina_TLS _thread_data_key;
196 233
234#define EET_DESC_DECL(dtype) \
235 Eet_Data_Descriptor *dtype##_eet_desc = NULL;
236
237 EET_DESC_DECL(_Wdg_Children_Config_Item);
238 EET_DESC_DECL(_Wdg_Children_Config);
239 EET_DESC_DECL(_Child);
240 EET_DESC_DECL(_Bool_Value);
241 EET_DESC_DECL(_Enum_Value);
242 EET_DESC_DECL(_Fixed_String);
243 EET_DESC_DECL(_Obj_Value);
244 EET_DESC_DECL(_Event_Value);
245 EET_DESC_DECL(_Parameter);
246 EET_DESC_DECL(_Function);
247 EET_DESC_DECL(_Wdg_Function);
248 EET_DESC_DECL(_Event);
249 EET_DESC_DECL(_DB);
250 EET_DESC_DECL(_Widget);
251
252#undef EET_DESC_DECL
253
254extern Eina_Bool check_content(const char*);
255
256#if 0
257static const char*
258_param_type_get(const void *data,
259 Eina_Bool *unknow)
260{
261 const Ea_Value_Type *t = data;
262
263 if (unknow)
264 *unknow = EINA_FALSE;
265
266 for (int i = 0; eet_map[i].name != NULL; i++)
267 if (*t == eet_map[i].t)
268 return eet_map[i].name;
269
270 if (unknow)
271 *unknow = EINA_TRUE;
272
273 return NULL;
274}
275
276static Eina_Bool
277_param_type_set(const char *type,
278 void *data,
279 Eina_Bool unknow)
280{
281 Ea_Value_Type *t = data;
282
283 if (unknow)
284 return EINA_FALSE;
285
286 for (int i = 0; eet_map[i].name; i++)
287 if (!strcmp(eet_map[i].name, type))
288 {
289 *t = eet_map[i].t;
290 return EINA_TRUE;
291 }
292
293 return EINA_FALSE;
294}
295#endif
296
297static void
298_init_eet_desc()
299{
300 #define EET_DESC_PRIM_ADD(dtype, member, eet_type) \
301 EET_DATA_DESCRIPTOR_ADD_BASIC \
302 (dtype##_eet_desc, dtype, # member, member, eet_type)
303
304 #define EET_DESC_TYPE_ADD(dtype, contype, member,subdtype) \
305 EET_DATA_DESCRIPTOR_ADD_##contype \
306 (dtype##_eet_desc, dtype, # member, member, subdtype##_eet_desc)
307
308 #define EET_DESC_NEW(eddc_kl, dtype) \
309 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc_kl, dtype); \
310 dtype##_eet_desc = eet_data_descriptor_file_new(&eddc_kl);
311
312 Eet_Data_Descriptor_Class eddc;
313
314 EET_DESC_NEW(eddc, _Wdg_Children_Config_Item);
315 EET_DESC_NEW(eddc, _Wdg_Children_Config);
316 EET_DESC_NEW(eddc, _Widget);
317 EET_DESC_NEW(eddc, _Child);
318 EET_DESC_NEW(eddc, _Bool_Value);
319 EET_DESC_NEW(eddc, _Enum_Value);
320 EET_DESC_NEW(eddc, _Fixed_String);
321 EET_DESC_NEW(eddc, _Obj_Value);
322 EET_DESC_NEW(eddc, _Event_Value);
323 EET_DESC_NEW(eddc, _Parameter);
324 EET_DESC_NEW(eddc, _Function);
325 EET_DESC_NEW(eddc, _Wdg_Function);
326 EET_DESC_NEW(eddc, _Event);
327 EET_DESC_NEW(eddc, _DB);
328
329 // Define Data Descriptor //
330 //_Wdg_Children_Config_Item
331 EET_DESC_PRIM_ADD(_Wdg_Children_Config_Item, min_occ, EET_T_UINT);
332 EET_DESC_PRIM_ADD(_Wdg_Children_Config_Item, max_occ, EET_T_UINT);
333 EET_DESC_PRIM_ADD(_Wdg_Children_Config_Item, is_container, EET_T_UCHAR);
334
335 //_Wdg_Children_Config
336 EET_DESC_PRIM_ADD(_Wdg_Children_Config, nb_occ, EET_T_UINT);
337 EET_DESC_PRIM_ADD(_Wdg_Children_Config, seq, EET_T_STRING);
338 EET_DESC_TYPE_ADD(_Wdg_Children_Config, LIST, items, _Wdg_Children_Config_Item);
339
340 //_Child
341 EET_DESC_PRIM_ADD(_Child, nb_occ, EET_T_UINT);
342 //EET_DESC_TYPE_ADD(_Child, SUB, w, _Widget);
343 EET_DESC_PRIM_ADD(_Child, w_kl_name_eet, EET_T_STRING);
344 EET_DESC_PRIM_ADD(_Child, is_legacy_eet, EET_T_UCHAR);
345
346 // _Widget
347 //EET_DESC_TYPE_ADD(_Widget, SUB, kl, Eolian_Class);
348 EET_DESC_PRIM_ADD(_Widget, kl_name_eet, EET_T_STRING);
349 EET_DESC_PRIM_ADD(_Widget, nb_occ, EET_T_UINT);
350 EET_DESC_PRIM_ADD(_Widget, min_depth, EET_T_UINT);
351 EET_DESC_PRIM_ADD(_Widget, max_depth, EET_T_UINT);
352 EET_DESC_TYPE_ADD(_Widget, LIST, children_configs, _Wdg_Children_Config);
353 EET_DESC_TYPE_ADD(_Widget, LIST, contents, _Child);
354 EET_DESC_TYPE_ADD(_Widget, LIST, containers, _Child);
355 EET_DESC_TYPE_ADD(_Widget, LIST, creator_funcs, _Wdg_Function);
356 EET_DESC_TYPE_ADD(_Widget, LIST, ctor_funcs, _Wdg_Function);
357 EET_DESC_TYPE_ADD(_Widget, LIST, funcs, _Wdg_Function);
358 EET_DESC_TYPE_ADD(_Widget, LIST, container_values, _Parameter);
359 EET_DESC_TYPE_ADD(_Widget, LIST, events, _Event);
360 EET_DESC_PRIM_ADD(_Widget, used, EET_T_UCHAR);
361 EET_DESC_PRIM_ADD(_Widget, is_legacy, EET_T_UCHAR);
362
363 //_Bool_Value
364 EET_DESC_PRIM_ADD(_Bool_Value, nb_occ, EET_T_DOUBLE);
365 EET_DESC_PRIM_ADD(_Bool_Value, val, EET_T_UCHAR);
366
367 // _Enum_Value
368 EET_DESC_PRIM_ADD(_Enum_Value, nb_occ, EET_T_DOUBLE);
369 //EET_DESC_TYPE_ADD(_Enum_Value, field, Eolian_Enum_Field);
370 EET_DESC_PRIM_ADD(_Enum_Value, field_type_eet, EET_T_STRING);
371 EET_DESC_PRIM_ADD(_Enum_Value, field_name_eet, EET_T_STRING);
372 EET_DESC_PRIM_ADD(_Enum_Value, value, EET_T_INT);
373 EET_DESC_PRIM_ADD(_Enum_Value, is_field, EET_T_UCHAR);
374
375 //_Fixed_String
376 EET_DESC_PRIM_ADD(_Fixed_String, nb_occ, EET_T_DOUBLE);
377 EET_DESC_PRIM_ADD(_Fixed_String, str, EET_T_STRING);
378
379 //_Obj_Value
380 EET_DESC_PRIM_ADD(_Obj_Value, nb_occ, EET_T_DOUBLE);
381 //EET_DESC_TYPE_ADD(_Obj_Value, SUB, val, _Widget);
382 EET_DESC_PRIM_ADD(_Obj_Value, val_name_eet, EET_T_STRING);
383 EET_DESC_PRIM_ADD(_Obj_Value, is_legacy_eet, EET_T_UCHAR);
384
385 //_Event_Value
386 EET_DESC_PRIM_ADD(_Event_Value, nb_occ, EET_T_DOUBLE);
387 //EET_DESC_TYPE_ADD(_Event_Value, SUB, event, Eolian_Event);
388 EET_DESC_PRIM_ADD(_Event_Value, event_kl_name_eet, EET_T_STRING);
389 EET_DESC_PRIM_ADD(_Event_Value, event_name_eet, EET_T_STRING);
390
391 // _Parameter
392 //EET_DESC_TYPE_ADD(_Parameter, SUB, eo_param, EolianFunctionParameter);
393 EET_DESC_PRIM_ADD(_Parameter, func_param_name_eet, EET_T_STRING);
394 EET_DESC_PRIM_ADD(_Parameter, ea_type, EET_T_INT);
395 EET_DESC_PRIM_ADD(_Parameter, basic_type, EET_T_INT);
396 EET_DESC_TYPE_ADD(_Parameter, LIST, bool_values, _Bool_Value);
397 EET_DESC_TYPE_ADD(_Parameter, LIST, enum_values, _Enum_Value);
398 EET_DESC_TYPE_ADD(_Parameter, LIST, struct_values, _Parameter);
399 EET_DESC_TYPE_ADD(_Parameter, LIST, object_values, _Obj_Value);
400 EET_DESC_TYPE_ADD(_Parameter, LIST, event_values, _Event_Value);
401 EET_DESC_PRIM_ADD(_Parameter, int_min, EET_T_INT);
402 EET_DESC_PRIM_ADD(_Parameter, int_max, EET_T_INT);
403 EET_DESC_PRIM_ADD(_Parameter, dbl_min, EET_T_DOUBLE);
404 EET_DESC_PRIM_ADD(_Parameter, dbl_max, EET_T_DOUBLE);
405 EET_DESC_PRIM_ADD(_Parameter, str_len_min, EET_T_UINT);
406 EET_DESC_PRIM_ADD(_Parameter, str_len_max, EET_T_UINT);
407 EET_DESC_PRIM_ADD(_Parameter, nb_elts_min, EET_T_UINT);
408 EET_DESC_PRIM_ADD(_Parameter, nb_elts_max, EET_T_UINT);
409 EET_DESC_TYPE_ADD(_Parameter, SUB, array, _Parameter);
410 EET_DESC_TYPE_ADD(_Parameter, LIST, fixed_strings, _Fixed_String);
411 EET_DATA_DESCRIPTOR_ADD_LIST_STRING(_Parameter_eet_desc, _Parameter, "files_list", files_list);
412 EET_DESC_PRIM_ADD(_Parameter, mode, EET_T_INT);
413 EET_DESC_PRIM_ADD(_Parameter, is_key, EET_T_UCHAR);
414 EET_DESC_PRIM_ADD(_Parameter, used, EET_T_UCHAR);
415
416 // _Function
417 //EET_DESC_TYPE_ADD(_Function, SUB, eo_func, Eolian_Function)
418 EET_DESC_PRIM_ADD(_Function, kl_name_eet, EET_T_STRING);
419 EET_DESC_PRIM_ADD(_Function, func_name_eet, EET_T_STRING);
420 EET_DESC_TYPE_ADD(_Function, LIST, params, _Parameter);
421
422 // _Wdg_Function
423 EET_DESC_PRIM_ADD(_Wdg_Function, nb_occ, EET_T_UINT);
424 //EET_DESC_TYPE_ADD(_Wdg_Function, SUB, func, _Function);
425 EET_DESC_PRIM_ADD(_Wdg_Function, kl_name_eet, EET_T_STRING);
426 EET_DESC_PRIM_ADD(_Wdg_Function, func_name_eet, EET_T_STRING);
427 EET_DESC_TYPE_ADD(_Wdg_Function, LIST, params, _Parameter);
428
429 // _Event
430 EET_DESC_PRIM_ADD(_Event, nb_occ, EET_T_UINT);
431 //EET_DESC_TYPE_ADD(_Event, SUB, eo_ev, Eolian_Event);
432 EET_DESC_PRIM_ADD(_Event, event_kl_name_eet, EET_T_STRING);
433 EET_DESC_PRIM_ADD(_Event, event_name_eet, EET_T_STRING);
434
435 // _DB
436 //EET_DESC_TYPE_ADD(_DB, HASH, eo_wdgs_hash, _Widget);
437 //EET_DESC_TYPE_ADD(_DB, HASH, funcs_hash, _Function);
438 EET_DESC_TYPE_ADD(_DB, LIST, wdgs, _Widget);
439 EET_DESC_TYPE_ADD(_DB, LIST, funcs, _Function);
440 EET_DESC_TYPE_ADD(_DB, SUB, start_wdg, _Widget);
441
442#undef EET_DESC_TYPE_ADD
443#undef EET_DESC_PRIM_ADD
444#undef EET_DESC_NEW
445}
446
197static unsigned int 447static unsigned int
198_log_calc(unsigned int x) 448_log_calc(unsigned int x)
199{ 449{
@@ -311,7 +561,7 @@ _wdg_free(_Widget *w)
311 { 561 {
312 _Wdg_Children_Config_Item *wci; 562 _Wdg_Children_Config_Item *wci;
313 EINA_LIST_FREE(wc->items, wci) free(wci); 563 EINA_LIST_FREE(wc->items, wci) free(wci);
314 eina_stringshare_del(wc->seq); 564 free(wc->seq);
315 } 565 }
316 EINA_LIST_FREE(w->contents, c) free(c); 566 EINA_LIST_FREE(w->contents, c) free(c);
317 EINA_LIST_FREE(w->containers, c) free(c); 567 EINA_LIST_FREE(w->containers, c) free(c);
@@ -1021,7 +1271,7 @@ found_child:
1021 1271
1022 _wdg_add(db, wc); 1272 _wdg_add(db, wc);
1023 } 1273 }
1024 if (cfg) cfg->seq = eina_stringshare_add(eina_strbuf_string_get(seq)); 1274 if (cfg) cfg->seq = eina_strbuf_string_steal(seq);
1025 EINA_LIST_FOREACH(w->children_configs, itr, wcfg) 1275 EINA_LIST_FOREACH(w->children_configs, itr, wcfg)
1026 { 1276 {
1027 if (!cfg) continue; 1277 if (!cfg) continue;
@@ -1255,8 +1505,9 @@ _value_merge(_DB *db, _Parameter *pS, _Parameter *pD)
1255 } 1505 }
1256 if (!found) 1506 if (!found)
1257 { 1507 {
1508 _Widget *oSw = oS->val;
1258 oD = calloc(1, sizeof(*oD)); 1509 oD = calloc(1, sizeof(*oD));
1259 oD->val = oS->val; 1510 if (oSw) oD->val = _wdg_get_by_kl(db, oSw->kl, oSw->is_legacy);
1260 oD->nb_occ = oS->nb_occ / total_occ; 1511 oD->nb_occ = oS->nb_occ / total_occ;
1261 pD->object_values = eina_list_append(pD->object_values, oD); 1512 pD->object_values = eina_list_append(pD->object_values, oD);
1262 } 1513 }
@@ -1429,10 +1680,10 @@ content_found:
1429 _Wdg_Children_Config_Item *itemS, *itemD; 1680 _Wdg_Children_Config_Item *itemS, *itemD;
1430 EINA_LIST_FOREACH(mdb_w->children_configs, itr2, mdb_wcfg) 1681 EINA_LIST_FOREACH(mdb_w->children_configs, itr2, mdb_wcfg)
1431 { 1682 {
1432 if (mdb_wcfg->seq == wcfg->seq) goto config_found; 1683 if (!strcmp(mdb_wcfg->seq, wcfg->seq)) goto config_found;
1433 } 1684 }
1434 mdb_wcfg = calloc(1, sizeof(*mdb_wcfg)); 1685 mdb_wcfg = calloc(1, sizeof(*mdb_wcfg));
1435 mdb_wcfg->seq = eina_stringshare_add(wcfg->seq); 1686 mdb_wcfg->seq = strdup(wcfg->seq);
1436 mdb_w->children_configs = eina_list_append(mdb_w->children_configs, mdb_wcfg); 1687 mdb_w->children_configs = eina_list_append(mdb_w->children_configs, mdb_wcfg);
1437 EINA_LIST_FOREACH(wcfg->items, itr2, itemS) 1688 EINA_LIST_FOREACH(wcfg->items, itr2, itemS)
1438 { 1689 {
@@ -1690,8 +1941,7 @@ _wdg_info_append(Eina_Strbuf *sbuf, _Widget *w)
1690 eolian_function_name_get(wf->func->eo_func), wf->nb_occ); 1941 eolian_function_name_get(wf->func->eo_func), wf->nb_occ);
1691 EINA_LIST_FOREACH(wf->params, itr2, p) 1942 EINA_LIST_FOREACH(wf->params, itr2, p)
1692 { 1943 {
1693 eina_strbuf_append_printf(sbuf, " %s:", 1944 eina_strbuf_append_printf(sbuf, " %s:", eolian_parameter_name_get(p->eo_param));
1694 p->eo_param?eolian_parameter_name_get(p->eo_param):"Unknown");
1695 _parameter_info_append(sbuf, p); 1945 _parameter_info_append(sbuf, p);
1696 eina_strbuf_append(sbuf, "\n"); 1946 eina_strbuf_append(sbuf, "\n");
1697 } 1947 }
@@ -1703,8 +1953,7 @@ _wdg_info_append(Eina_Strbuf *sbuf, _Widget *w)
1703 eina_strbuf_append(sbuf, " Container values:\n"); 1953 eina_strbuf_append(sbuf, " Container values:\n");
1704 EINA_LIST_FOREACH(w->container_values, itr, p) 1954 EINA_LIST_FOREACH(w->container_values, itr, p)
1705 { 1955 {
1706 eina_strbuf_append_printf(sbuf, " %s:", 1956 eina_strbuf_append_printf(sbuf, " %s:", eolian_parameter_name_get(p->eo_param));
1707 p->eo_param?eolian_parameter_name_get(p->eo_param):"Unknown");
1708 _parameter_info_append(sbuf, p); 1957 _parameter_info_append(sbuf, p);
1709 eina_strbuf_append(sbuf, "\n"); 1958 eina_strbuf_append(sbuf, "\n");
1710 } 1959 }
@@ -1768,8 +2017,7 @@ _wdg_info_append(Eina_Strbuf *sbuf, _Widget *w)
1768 eolian_function_name_get(wf->func->eo_func), wf->nb_occ); 2017 eolian_function_name_get(wf->func->eo_func), wf->nb_occ);
1769 EINA_LIST_FOREACH(wf->params, itr2, p) 2018 EINA_LIST_FOREACH(wf->params, itr2, p)
1770 { 2019 {
1771 eina_strbuf_append_printf(sbuf, " %s:", 2020 eina_strbuf_append_printf(sbuf, " %s:", eolian_parameter_name_get(p->eo_param));
1772 p->eo_param?eolian_parameter_name_get(p->eo_param):"Unknown");
1773 _parameter_info_append(sbuf, p); 2021 _parameter_info_append(sbuf, p);
1774 eina_strbuf_append(sbuf, "\n"); 2022 eina_strbuf_append(sbuf, "\n");
1775 } 2023 }
@@ -1787,8 +2035,7 @@ _wdg_info_append(Eina_Strbuf *sbuf, _Widget *w)
1787 eolian_function_name_get(wf->func->eo_func), wf->nb_occ); 2035 eolian_function_name_get(wf->func->eo_func), wf->nb_occ);
1788 EINA_LIST_FOREACH(wf->params, itr2, p) 2036 EINA_LIST_FOREACH(wf->params, itr2, p)
1789 { 2037 {
1790 eina_strbuf_append_printf(sbuf, " %s:", 2038 eina_strbuf_append_printf(sbuf, " %s:", eolian_parameter_name_get(p->eo_param));
1791 p->eo_param?eolian_parameter_name_get(p->eo_param):"Unknown");
1792 _parameter_info_append(sbuf, p); 2039 _parameter_info_append(sbuf, p);
1793 eina_strbuf_append(sbuf, "\n"); 2040 eina_strbuf_append(sbuf, "\n");
1794 } 2041 }
@@ -1828,7 +2075,6 @@ db_get_as_string(Ea_DB *_db)
1828 { 2075 {
1829 _function_info_append(sbuf, fst); 2076 _function_info_append(sbuf, fst);
1830 } 2077 }
1831
1832 return sbuf; 2078 return sbuf;
1833} 2079}
1834 2080
@@ -1960,7 +2206,9 @@ _value_gen(_DB *db, _Parameter *p, void *excl_ptr)
1960 nb_occ -= act->nb_occ; 2206 nb_occ -= act->nb_occ;
1961 } 2207 }
1962 if (act->is_field) 2208 if (act->is_field)
2209 {
1963 v = NEW_VAL(EA_VALUE_ENUM, act->field); 2210 v = NEW_VAL(EA_VALUE_ENUM, act->field);
2211 }
1964 else 2212 else
1965 v = NEW_BASIC_VAL(EINA_VALUE_TYPE_INT, act->value); 2213 v = NEW_BASIC_VAL(EINA_VALUE_TYPE_INT, act->value);
1966 eina_hash_set(td->all_values_hash, &v, (void *)act); 2214 eina_hash_set(td->all_values_hash, &v, (void *)act);
@@ -2155,7 +2403,7 @@ _func_gen(_DB *db, _Wdg_Function *wf, Ea_Widget *ea_wdg, Ea_Function *excl_func,
2155 } 2403 }
2156 EINA_LIST_FOREACH(wf->params, itr2, fp) 2404 EINA_LIST_FOREACH(wf->params, itr2, fp)
2157 { 2405 {
2158 if (fp->eo_param == p->eo_param) 2406 if (fp->eo_param == p->eo_param || (fp->func_param_name_eet && !strcmp(fp->func_param_name_eet, pname)))
2159 { 2407 {
2160 v = _value_gen(db, fp, excl_ptr); 2408 v = _value_gen(db, fp, excl_ptr);
2161 goto value_gened; 2409 goto value_gened;
@@ -2522,18 +2770,6 @@ excl_func_found:
2522 } 2770 }
2523} 2771}
2524 2772
2525Eina_Bool db_load(Ea_DB *_db EINA_UNUSED, const char *in_filepath EINA_UNUSED, Eina_Bool will_reload EINA_UNUSED)
2526{
2527 // TODO : impl after serializing logics
2528 return EINA_TRUE;
2529}
2530
2531Eina_Bool db_save(Ea_DB *_db EINA_UNUSED, const char *out_filepath EINA_UNUSED, Eina_Bool will_overwrite EINA_UNUSED)
2532{
2533 // TODO : impl after serializing logics
2534 return EINA_TRUE;
2535}
2536
2537Eina_Bool 2773Eina_Bool
2538db_close(Ea_DB *_db) 2774db_close(Ea_DB *_db)
2539{ 2775{
@@ -2617,3 +2853,417 @@ db_class_demote(Ea_DB *_db, const char *kl_name, Eina_Bool is_legacy, Eina_Bool
2617 *plist = eina_list_remove(*plist, w); 2853 *plist = eina_list_remove(*plist, w);
2618 return EINA_TRUE; 2854 return EINA_TRUE;
2619} 2855}
2856
2857#if 0
2858static _Basic_Type
2859db_basic_type_encode(Eina_Value_Type *type)
2860{
2861 if (type == EINA_VALUE_TYPE_INT) return BASIC_TYPE_INT;
2862 else if (type == EINA_VALUE_TYPE_DOUBLE) return BASIC_TYPE_DOUBLE;
2863 else if (type == EINA_VALUE_TYPE_STRING) return BASIC_TYPE_STRING;
2864 return BASIC_TYPE_UNKNOWN;
2865}
2866
2867static const Eina_Value_Type *
2868db_basic_type_decode(_Basic_Type type)
2869{
2870 switch(type)
2871 {
2872 case BASIC_TYPE_INT: return EINA_VALUE_TYPE_INT;
2873 case BASIC_TYPE_DOUBLE: return EINA_VALUE_TYPE_DOUBLE;
2874 case BASIC_TYPE_STRING: return EINA_VALUE_TYPE_STRING;
2875 default: break;
2876 }
2877 return EINA_VALUE_TYPE_ERROR;
2878}
2879
2880static const Eolian_Class*
2881_eokl_by_class_name_get(const char *kl_name)
2882{
2883 if (!kl_name) return NULL;
2884 const Eolian_Unit *unit = NULL;
2885 return _class_find_by_name(kl_name, &unit);
2886}
2887#endif
2888
2889static void
2890_param_eet_prepare(_Parameter *p)
2891{
2892 Eina_List *itr;
2893 if (p->func_param_name_eet) return;
2894 if (p->eo_param)
2895 p->func_param_name_eet = strdup(eolian_parameter_name_get(p->eo_param));
2896 switch (p->ea_type)
2897 {
2898 case EA_VALUE_ENUM:
2899 {
2900 _Enum_Value *val;
2901 EINA_LIST_FOREACH(p->enum_values, itr, val)
2902 {
2903 if (!val->is_field) continue;
2904 const Eolian_Type *eo_type = eolian_parameter_type_get(p->eo_param);
2905 const Eolian_Typedecl *tdecl = eolian_type_typedecl_get(eo_type);
2906 val->field_type_eet = strdup(eolian_typedecl_name_get(tdecl));
2907 val->field_name_eet = strdup(eolian_typedecl_enum_field_name_get(val->field));
2908 }
2909 break;
2910 }
2911 case EA_VALUE_OBJECT:
2912 {
2913 _Obj_Value *val;
2914 EINA_LIST_FOREACH(p->object_values, itr, val)
2915 {
2916 if (val->val)
2917 {
2918 val->val_name_eet = strdup(eolian_class_name_get(val->val->kl));
2919 val->is_legacy_eet = val->val->is_legacy;
2920 }
2921 }
2922 break;
2923 }
2924 case EA_VALUE_EVENT:
2925 {
2926 _Event_Value *val;
2927 EINA_LIST_FOREACH(p->event_values, itr, val)
2928 {
2929 val->event_kl_name_eet = strdup(eolian_class_name_get(eolian_event_class_get(val->event)));
2930 val->event_name_eet = strdup(eolian_event_name_get(val->event));
2931 }
2932 break;
2933 }
2934 case EA_VALUE_STRUCT:
2935 {
2936 _Parameter *val;
2937 EINA_LIST_FOREACH(p->struct_values, itr, val) _param_eet_prepare(val);
2938 break;
2939 }
2940 default: break;
2941 }
2942}
2943
2944Eina_Bool
2945_param_eet_load(_DB *db, const Eolian_Unit *unit, const Eolian_Function *eo_func, _Parameter *p)
2946{
2947 Eina_List *itr;
2948 const Eolian_Unit *unit2;
2949 static const Eolian_Function *_efl_content_set_func = NULL;
2950 static const Eolian_Function *_efl_text_set_func = NULL;
2951 static const Eolian_Function_Parameter *_part_param = NULL;
2952 switch (p->ea_type)
2953 {
2954 case EA_VALUE_ENUM:
2955 {
2956 _Enum_Value *val;
2957 EINA_LIST_FOREACH(p->enum_values, itr, val)
2958 {
2959 if (val->is_field)
2960 {
2961 const Eolian_Typedecl *tdecl = eolian_unit_enum_by_name_get(unit, val->field_type_eet);
2962 val->field = eolian_typedecl_enum_field_get(tdecl, val->field_name_eet);
2963 }
2964 }
2965 break;
2966 }
2967 case EA_VALUE_OBJECT:
2968 {
2969 _Obj_Value *val;
2970 EINA_LIST_FOREACH(p->object_values, itr, val)
2971 {
2972 if (!val->val)
2973 {
2974 const Eolian_Class *kl = _class_find_by_name(val->val_name_eet, &unit2);
2975 Eina_Hash *hash = val->is_legacy_eet ? db->leg_wdgs_hash : db->eo_wdgs_hash;
2976 val->val = eina_hash_find(hash, kl);
2977 }
2978 }
2979 break;
2980 }
2981 case EA_VALUE_EVENT:
2982 {
2983 _Event_Value *val;
2984 EINA_LIST_FOREACH(p->event_values, itr, val)
2985 {
2986 unit2 = NULL;
2987 const Eolian_Class *kl = _class_find_by_name(val->event_kl_name_eet, &unit2);
2988 val->event = eolian_class_event_by_name_get(kl, val->event_name_eet);
2989 }
2990 break;
2991 }
2992 case EA_VALUE_STRUCT:
2993 {
2994 _Parameter *val;
2995 EINA_LIST_FOREACH(p->struct_values, itr, val) _param_eet_load(db, unit, eo_func, val);
2996 break;
2997 }
2998 default: break;
2999 }
3000 if (eo_func && p->func_param_name_eet)
3001 {
3002 const Eolian_Function_Parameter *eo_param;
3003 Eina_Iterator *iter = NULL;
3004 if (eolian_function_type_get(eo_func) == EOLIAN_METHOD)
3005 iter = eolian_function_parameters_get(eo_func);
3006 else
3007 {
3008 iter = eolian_property_keys_get(eo_func, EOLIAN_PROP_SET);
3009 EINA_ITERATOR_FOREACH(iter, eo_param)
3010 {
3011 if (!strcmp(eolian_parameter_name_get(eo_param), p->func_param_name_eet))
3012 {
3013 p->eo_param = eo_param;
3014 goto end;
3015 }
3016 }
3017 eina_iterator_free(iter);
3018 iter = eolian_property_values_get(eo_func, EOLIAN_PROP_SET);
3019 }
3020 EINA_ITERATOR_FOREACH(iter, eo_param)
3021 {
3022 if (!strcmp(eolian_parameter_name_get(eo_param), p->func_param_name_eet))
3023 {
3024 p->eo_param = eo_param;
3025 goto end;
3026 }
3027 }
3028 if (_efl_content_set_func == eo_func ||
3029 !strcmp(eolian_function_full_c_name_get(eo_func, EOLIAN_PROP_SET, EINA_FALSE), "efl_content_set"))
3030 {
3031 _efl_content_set_func = eo_func;
3032 }
3033 if (_efl_text_set_func == eo_func ||
3034 !strcmp(eolian_function_full_c_name_get(eo_func, EOLIAN_PROP_SET, EINA_FALSE), "efl_text_set"))
3035 {
3036 _efl_text_set_func = eo_func;
3037 }
3038 if (_efl_content_set_func == eo_func || _efl_text_set_func == eo_func)
3039 {
3040 if (!_part_param)
3041 {
3042 const Eolian_Class *part_kl = _class_find_by_name("Efl.Part", &unit);
3043 const Eolian_Function *part_func = NULL;
3044 eina_iterator_free(iter);
3045 if (part_kl) part_func = _eolian_class_function_get_by_name(part_kl,
3046 "part_get", EOLIAN_METHOD);
3047 if (part_func)
3048 {
3049 iter = eolian_function_parameters_get(part_func);
3050 if (eina_iterator_next(iter, (void **)&_part_param)) {}
3051 }
3052 }
3053 p->eo_param = _part_param;
3054 }
3055end:
3056 eina_iterator_free(iter);
3057 }
3058 return EINA_TRUE;
3059}
3060
3061static void
3062_wdg_func_eet_prepare(_Wdg_Function *wf)
3063{
3064 Eina_List *itr;
3065 _Parameter *p;
3066 if (wf->kl_name_eet) return;
3067 wf->kl_name_eet = strdup(eolian_class_name_get(eolian_function_class_get(wf->func->eo_func)));
3068 wf->func_name_eet = strdup(eolian_function_name_get(wf->func->eo_func));
3069 EINA_LIST_FOREACH(wf->params, itr, p)
3070 {
3071 _param_eet_prepare(p);
3072 }
3073}
3074
3075static void
3076_wdg_func_eet_load(_DB *db, _Wdg_Function *wf)
3077{
3078 Eina_List *itr;
3079 _Parameter *p;
3080
3081 const Eolian_Unit *unit = NULL;
3082 const Eolian_Class *kl = _class_find_by_name(wf->kl_name_eet, &unit);
3083 const Eolian_Function *eo_func = eolian_class_function_by_name_get(kl, wf->func_name_eet, EOLIAN_UNRESOLVED);
3084 _Function *f = eina_hash_find(db->funcs_hash, &eo_func);
3085 if (!f)
3086 {
3087 fprintf(stderr, "ERR DB Restore - _Function for %s:%s not restored!",
3088 wf->kl_name_eet, wf->func_name_eet);
3089 return;
3090 }
3091 wf->func = f;
3092 EINA_LIST_FOREACH(wf->params, itr, p)
3093 {
3094 _param_eet_load(db, unit, eo_func, p);
3095 }
3096}
3097
3098Eina_Bool
3099db_save(Ea_DB *_db, const char *out_filepath, Eina_Bool will_overwrite EINA_UNUSED)
3100{
3101 _Widget *w;
3102 _Function *f;
3103 _Parameter *p;
3104 Eina_List *itr1, *itr2;
3105 Eet_File *ef = NULL;
3106 _DB *db = (_DB *)_db;
3107
3108 _init_eet_desc();
3109 ef = eet_open(out_filepath, EET_FILE_MODE_WRITE);
3110
3111 if (!ef)
3112 {
3113 fprintf(stderr, "ERROR: could not open '%s' for write\n", out_filepath);
3114 return EINA_FALSE;
3115 }
3116
3117 EINA_LIST_FOREACH(eina_list_prepend(db->wdgs, db->start_wdg), itr1, w)
3118 {
3119 _Child *c;
3120 _Wdg_Function *wf;
3121 _Event *ev;
3122 if (w->kl_name_eet) continue;
3123 if (w->kl) w->kl_name_eet = strdup(eolian_class_name_get(w->kl));
3124 EINA_LIST_FOREACH(w->contents, itr2, c)
3125 {
3126 if (c->w_kl_name_eet) continue;
3127 c->w_kl_name_eet = strdup(eolian_class_name_get(c->w->kl));
3128 c->is_legacy_eet = c->w->is_legacy;
3129 }
3130 EINA_LIST_FOREACH(w->containers, itr2, c)
3131 {
3132 if (c->w_kl_name_eet) continue;
3133 c->w_kl_name_eet = strdup(eolian_class_name_get(c->w->kl));
3134 c->is_legacy_eet = c->w->is_legacy;
3135 }
3136 EINA_LIST_FOREACH(w->creator_funcs, itr2, wf) _wdg_func_eet_prepare(wf);
3137 EINA_LIST_FOREACH(w->ctor_funcs, itr2, wf) _wdg_func_eet_prepare(wf);
3138 EINA_LIST_FOREACH(w->funcs, itr2, wf) _wdg_func_eet_prepare(wf);
3139 EINA_LIST_FOREACH(w->container_values, itr2, p) _param_eet_prepare(p);
3140 EINA_LIST_FOREACH(w->events, itr2, ev)
3141 {
3142 if (ev->event_kl_name_eet) continue;
3143 ev->event_kl_name_eet = strdup(eolian_class_name_get(eolian_event_class_get(ev->eo_ev)));
3144 ev->event_name_eet = strdup(eolian_event_name_get(ev->eo_ev));
3145 }
3146 }
3147
3148 EINA_LIST_FOREACH(db->funcs, itr1, f)
3149 {
3150 if (f->kl_name_eet) continue;
3151 f->kl_name_eet = strdup(eolian_class_name_get(eolian_function_class_get(f->eo_func)));
3152 f->func_name_eet = strdup(eolian_function_name_get(f->eo_func));
3153 EINA_LIST_FOREACH(f->params, itr2, p) _param_eet_prepare(p);
3154 }
3155
3156 if (eet_data_write(ef, _DB_eet_desc, "db", db, EINA_TRUE))
3157 {
3158 eet_close(ef);
3159 return EINA_FALSE;
3160 }
3161
3162 eet_close(ef);
3163 return EINA_TRUE;
3164}
3165
3166Ea_DB *
3167db_load(const char *in_filepath)
3168{
3169 _Widget *w;
3170 _Function *f;
3171 _Parameter *p;
3172 Eina_List *itr1, *itr2;
3173 Eet_File *ef = NULL;
3174 _DB *db = NULL;
3175 const Eolian_Unit *unit;
3176
3177 _init_eet_desc();
3178 ef = eet_open(in_filepath, EET_FILE_MODE_READ);
3179 if (!ef)
3180 {
3181 fprintf(stderr, "error read failed\n");
3182 return NULL;
3183 }
3184
3185 db = eet_data_read(ef, _DB_eet_desc, "db");
3186
3187 eet_close(ef);
3188 if (!db) return NULL;
3189
3190 db->eo_wdgs_hash = eina_hash_pointer_new(NULL);
3191 db->leg_wdgs_hash = eina_hash_pointer_new(NULL);
3192 db->funcs_hash = eina_hash_pointer_new(NULL);
3193
3194 EINA_LIST_FOREACH(db->wdgs, itr1, w)
3195 {
3196 Eina_Hash *hash = w->is_legacy ? db->leg_wdgs_hash : db->eo_wdgs_hash;
3197 w->kl = _class_find_by_name(w->kl_name_eet, &w->unit);
3198 if (eina_hash_find(hash, w->kl))
3199 {
3200 fprintf(stderr, "ERR DB Restore - class %s already restored!", w->kl_name_eet);
3201 return NULL;
3202 }
3203 else
3204 eina_hash_set(hash, w->kl, w);
3205 }
3206
3207 EINA_LIST_FOREACH(db->funcs, itr1, f)
3208 {
3209 unit = NULL;
3210 const Eolian_Class *kl = _class_find_by_name(f->kl_name_eet, &unit);
3211 f->eo_func = eolian_class_function_by_name_get(kl, f->func_name_eet, EOLIAN_UNRESOLVED);
3212 if (eina_hash_find(db->funcs_hash, &f->eo_func))
3213 {
3214 fprintf(stderr, "ERR DB Restore - function %s:%s already restored!",
3215 f->kl_name_eet, f->func_name_eet);
3216 return NULL;
3217 }
3218 eina_hash_set(db->funcs_hash, &f->eo_func, f);
3219 EINA_LIST_FOREACH(f->params, itr2, p) _param_eet_load(db, unit, f->eo_func, p);
3220 }
3221
3222 EINA_LIST_FOREACH(eina_list_prepend(db->wdgs, db->start_wdg), itr1, w)
3223 {
3224 _Child *c;
3225 _Wdg_Function *wf;
3226 _Event *ev;
3227
3228 EINA_LIST_FOREACH(w->contents, itr2, c)
3229 {
3230 Eina_Hash *hash = c->is_legacy_eet ? db->leg_wdgs_hash : db->eo_wdgs_hash;
3231 unit = NULL;
3232 const Eolian_Class *kl = _class_find_by_name(c->w_kl_name_eet, &unit);
3233 c->w = eina_hash_find(hash, kl);
3234 if (!c->w)
3235 {
3236 fprintf(stderr, "Widget of class %s not found\n", c->w_kl_name_eet);
3237 return NULL;
3238 }
3239 }
3240 EINA_LIST_FOREACH(w->containers, itr2, c)
3241 {
3242 Eina_Hash *hash = c->is_legacy_eet ? db->leg_wdgs_hash : db->eo_wdgs_hash;
3243 unit = NULL;
3244 const Eolian_Class *kl = _class_find_by_name(c->w_kl_name_eet, &unit);
3245 c->w = eina_hash_find(hash, kl);
3246 if (!c->w)
3247 {
3248 fprintf(stderr, "Widget of class %s not found\n", c->w_kl_name_eet);
3249 return NULL;
3250 }
3251 }
3252 EINA_LIST_FOREACH(w->creator_funcs, itr2, wf) _wdg_func_eet_load(db, wf);
3253 EINA_LIST_FOREACH(w->ctor_funcs, itr2, wf) _wdg_func_eet_load(db, wf);
3254 EINA_LIST_FOREACH(w->funcs, itr2, wf) _wdg_func_eet_load(db, wf);
3255 if (w->container_values)
3256 {
3257 const Eolian_Function *eo_func = _container_find(w->unit, w->kl);
3258 EINA_LIST_FOREACH(w->container_values, itr2, p) _param_eet_load(db, unit, eo_func, p);
3259 }
3260 EINA_LIST_FOREACH(w->events, itr2, ev)
3261 {
3262 unit = NULL;
3263 const Eolian_Class *kl = _class_find_by_name(ev->event_kl_name_eet, &unit);
3264 ev->eo_ev = eolian_class_event_by_name_get(kl, ev->event_name_eet);
3265 }
3266 }
3267
3268 return (Ea_DB *)db;
3269}
diff --git a/src/bin/db.h b/src/bin/db.h
index 668cf5d..b89b97e 100644
--- a/src/bin/db.h
+++ b/src/bin/db.h
@@ -7,10 +7,11 @@
7typedef struct _DB Ea_DB; 7typedef struct _DB Ea_DB;
8 8
9Ea_DB *db_new(); 9Ea_DB *db_new();
10Eina_Bool db_load(Ea_DB *db, const char *in_filepath, Eina_Bool will_reload);
11Eina_Bool db_save(Ea_DB *db, const char *out_filepath, Eina_Bool will_overwrite);
12Eina_Bool db_close(Ea_DB *db); 10Eina_Bool db_close(Ea_DB *db);
13 11
12Ea_DB *db_load(const char *in_filepath);
13Eina_Bool db_save(Ea_DB *db, const char *out_filepath, Eina_Bool will_overwrite);
14
14Eina_Bool db_ml_add(Ea_DB *db, const char *ml_filepath); 15Eina_Bool db_ml_add(Ea_DB *db, const char *ml_filepath);
15Eina_Bool db_ml_gen(Ea_DB *db, const char *out_ml_path); 16Eina_Bool db_ml_gen(Ea_DB *db, const char *out_ml_path);
16Eina_Strbuf *db_get_as_string(Ea_DB *db); 17Eina_Strbuf *db_get_as_string(Ea_DB *db);
diff --git a/src/bin/gen.h b/src/bin/gen.h
index 22f18f8..0afc521 100644
--- a/src/bin/gen.h
+++ b/src/bin/gen.h
@@ -34,5 +34,4 @@ void convert_to_tree(Eina_List *);
34char *ml_wdg_gen(Ea_Widget *); 34char *ml_wdg_gen(Ea_Widget *);
35char *ml_func_gen(Ea_Widget *, Ea_Function *); 35char *ml_func_gen(Ea_Widget *, Ea_Function *);
36char *ml_prop_keys_gen(Ea_Widget *, Ea_Function *); 36char *ml_prop_keys_gen(Ea_Widget *, Ea_Function *);
37
38#endif 37#endif
diff --git a/src/bin/main.c b/src/bin/main.c
index 0b763fd..abddbc3 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -190,6 +190,19 @@ int main(int argc, char **argv)
190 if (!ecore_file_is_dir(fname)) 190 if (!ecore_file_is_dir(fname))
191 db_ml_add(db, fname); 191 db_ml_add(db, fname);
192 } 192 }
193#if 0
194 Eina_Strbuf *sbuf = db_get_as_string(db);
195 FILE *fp = fopen("/tmp/toto_1.txt", "w");
196 fwrite(eina_strbuf_string_get(sbuf), eina_strbuf_length_get(sbuf), 1, fp);
197 fclose(fp);
198 db_ml_save(db, "/tmp/toto.eet");
199 Ea_DB *db2 = db_ml_load("/tmp/toto.eet");
200 sbuf = db_get_as_string(db2);
201 fp = fopen("/tmp/toto_2.txt", "w");
202 fwrite(eina_strbuf_string_get(sbuf), eina_strbuf_length_get(sbuf), 1, fp);
203 fclose(fp);
204 db_close(db2);
205#endif
193 pret = !db_ml_gen(db, _output); 206 pret = !db_ml_gen(db, _output);
194 db_close(db); 207 db_close(db);
195 goto end; 208 goto end;
diff --git a/src/lib/common.c b/src/lib/common.c
index a9a956f..d48d00f 100644
--- a/src/lib/common.c
+++ b/src/lib/common.c
@@ -355,7 +355,7 @@ end:
355 return ret; 355 return ret;
356} 356}
357 357
358static const Eolian_Function * 358const Eolian_Function *
359_container_find(const Eolian_Unit *unit, const Eolian_Class *main_kl) 359_container_find(const Eolian_Unit *unit, const Eolian_Class *main_kl)
360{ 360{
361 const char *func_name = NULL; 361 const char *func_name = NULL;
diff --git a/src/lib/common.h b/src/lib/common.h
index c839311..17fddb6 100644
--- a/src/lib/common.h
+++ b/src/lib/common.h
@@ -42,7 +42,8 @@ typedef enum
42 EA_VALUE_POINTER, 42 EA_VALUE_POINTER,
43 EA_VALUE_STRUCT, 43 EA_VALUE_STRUCT,
44 EA_VALUE_EVENT, 44 EA_VALUE_EVENT,
45 EA_VALUE_REPEATER_VARIABLE 45 EA_VALUE_REPEATER_VARIABLE,
46 EA_VALUE_LAST,
46} Ea_Value_Type; 47} Ea_Value_Type;
47 48
48typedef struct 49typedef struct
@@ -210,6 +211,8 @@ Eina_List *
210_iterator_to_list(Eina_Iterator *iter); 211_iterator_to_list(Eina_Iterator *iter);
211Eina_Bool 212Eina_Bool
212_eolian_isa(const Eolian_Class *obj_kl, const char *want_kl_name); 213_eolian_isa(const Eolian_Class *obj_kl, const char *want_kl_name);
214const Eolian_Function *
215_container_find(const Eolian_Unit *unit, const Eolian_Class *main_kl);
213void 216void
214_widget_ctor_fill(Ea_Widget *wdg, Ea_Widget *parent, const char *parsed_name, const char *creator_name); 217_widget_ctor_fill(Ea_Widget *wdg, Ea_Widget *parent, const char *parsed_name, const char *creator_name);
215Ea_Widget * 218Ea_Widget *