summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2015-09-01 21:58:25 +0300
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2015-09-01 21:58:25 +0300
commitd11b9eb4810aa7eb71a06b5ee93a40d861ee4855 (patch)
treeaaa6678b3ff0f2815f4e6a373f1a671bc6c3015b
parentdfdf5846b44d557283eaf51c499aa61c879b30f6 (diff)
Improve legacy lookupdevs/yakov/legacy_generate
-rw-r--r--src/lib/generator.c157
1 files changed, 77 insertions, 80 deletions
diff --git a/src/lib/generator.c b/src/lib/generator.c
index addd775..0499c18 100644
--- a/src/lib/generator.c
+++ b/src/lib/generator.c
@@ -219,15 +219,58 @@ _op_name_compare(const Op_Desc *_op_desc, const char *_class_name, const char *_
219{ 219{
220 const char *class_name = db_op_desc_class_name_get(_op_desc); 220 const char *class_name = db_op_desc_class_name_get(_op_desc);
221 const char *op_name = db_op_desc_op_name_get(_op_desc); 221 const char *op_name = db_op_desc_op_name_get(_op_desc);
222 //ERR("%s %s || %s %s", _class_name, _op_name, class_name, op_name);
223 if (!strcmp(class_name, _class_name) && 222 if (!strcmp(class_name, _class_name) &&
224 !strcmp(op_name, _op_name)) 223 !strcmp(op_name, _op_name))
225 { 224 {
226 return EINA_TRUE; 225 return EINA_TRUE;
227 } 226 }
228 return EINA_FALSE; 227 return EINA_FALSE;
229} 228}
230 229
230typedef struct
231{
232 const char *legacy_name;
233 const char *fklass;
234 const char *fname;
235 const char *klass;
236} _Eo_Legacy_Info;
237
238static _Eo_Legacy_Info eo_legacy_infos[] =
239{
240 { "evas_object_resize", DB_DEF_EFL_GFX_BASE_CLASS, SIZE_SET, NULL },
241 { "evas_object_move", DB_DEF_EFL_GFX_BASE_CLASS, POSITION_SET, NULL },
242 { "evas_object_color_set", DB_DEF_EFL_GFX_BASE_CLASS, COLOR_SET, NULL },
243 { "elm_layout_file_set", DB_DEF_EFL_FILE_INTERFACE, FILE_SET, DB_DEF_LAYOUT_CLASS},
244 { "elm_bg_file_set", DB_DEF_EFL_FILE_INTERFACE, FILE_SET, DB_DEF_BG_CLASS},
245 { "elm_icon_file_set", DB_DEF_EFL_FILE_INTERFACE, FILE_SET, DB_DEF_ICON_CLASS},
246 { "elm_image_file_set", DB_DEF_EFL_FILE_INTERFACE, FILE_SET, DB_DEF_IMAGE_CLASS},
247 { "evas_object_image_file_set", DB_DEF_EFL_FILE_INTERFACE, FILE_SET, DB_DEF_EVAS_IMAGE_CLASS},
248 { "elm_scroller_policy_set", "Elm_Interface_Scrollable", "policy", NULL},
249 { "elm_scroller_bounce_set", "Elm_Interface_Scrollable", "bounce_allow", NULL},
250 { "elm_fileselector_entry_path_set", "Elm_Interface_Fileselector", "path", DB_DEF_FILESELECTOR_ENTRY_CLASS},
251 { "elm_fileselector_path_set", "Elm_Interface_Fileselector", "path", DB_DEF_FILESELECTOR_CLASS},
252 { NULL, NULL, NULL, NULL }
253};
254
255static const char *
256_legacy_name_find(const char *kl_name, const Op_Desc *op_desc)
257{
258 _Eo_Legacy_Info *info = &eo_legacy_infos[0];
259 const char *class_name = db_op_desc_class_name_get(op_desc);
260 const char *op_name = db_op_desc_op_name_get(op_desc);
261 while (info && info->legacy_name)
262 {
263 if (!strcmp(class_name, info->fklass) &&
264 !strcmp(op_name, info->fname) &&
265 (!info->klass || !strcmp(info->klass, kl_name)))
266 {
267 return info->legacy_name;
268 }
269 info++;
270 }
271 return NULL;
272}
273
231/* Generate string for current property. */ 274/* Generate string for current property. */
232static Eina_Bool 275static Eina_Bool
233_wdg_prop_add_generate(Gui_Session *session EINA_UNUSED, const Gui_Widget *wdg, const Gui_Widget_Property *prop, void *data) 276_wdg_prop_add_generate(Gui_Session *session EINA_UNUSED, const Gui_Widget *wdg, const Gui_Widget_Property *prop, void *data)
@@ -260,92 +303,46 @@ _wdg_prop_add_generate(Gui_Session *session EINA_UNUSED, const Gui_Widget *wdg,
260 } 303 }
261 304
262 Eina_Strbuf *buf = eina_strbuf_new(); 305 Eina_Strbuf *buf = eina_strbuf_new();
306 const char *legacy_name = NULL;
263 if (gl_ctx->generate_legacy) 307 if (gl_ctx->generate_legacy)
264 { 308 {
265 const char *legacy_name = db_op_desc_func_legacy_name_get(op_desc); 309 legacy_name = db_op_desc_func_legacy_name_get(op_desc);
266 if (_op_name_compare(op_desc, DB_DEF_EFL_GFX_BASE_CLASS, VISIBLE_SET)) 310 if (!legacy_name) legacy_name = _legacy_name_find(wdg_class_name_get(wdg), op_desc);
311 if (!legacy_name)
267 { 312 {
268 Eina_Bool visible = EINA_FALSE; 313 if (_op_name_compare(op_desc, DB_DEF_EFL_GFX_BASE_CLASS, VISIBLE_SET))
269 Gui_Widget_Property *prop2;
270 prop2 = wdg_prop_get(wdg, DB_DEF_EFL_GFX_BASE_CLASS, VISIBLE_SET);
271 if (prop2)
272 { 314 {
273 visible = INT_GET(prop_value_nth_get(prop2, 0)); 315 Eina_Bool visible = EINA_FALSE;
316 Gui_Widget_Property *prop2;
317 prop2 = wdg_prop_get(wdg, DB_DEF_EFL_GFX_BASE_CLASS, VISIBLE_SET);
318 if (prop2)
319 {
320 visible = INT_GET(prop_value_nth_get(prop2, 0));
321 }
322 legacy_name = visible ? "evas_object_show" : "evas_object_hide";
323 eina_strbuf_append_printf(buf, " %s(%s", legacy_name, wdg_name_get(wdg));
324 goto finalize;
274 } 325 }
275 legacy_name = visible ? "evas_object_show" : "evas_object_hide";
276 eina_strbuf_append_printf(buf, " %s(%s", legacy_name, wdg_name_get(wdg));
277 goto finalize;
278 }
279 else if (_op_name_compare(op_desc, DB_DEF_EFL_GFX_BASE_CLASS, SIZE_SET))
280 {
281 legacy_name = "evas_object_resize";
282 }
283 else if (_op_name_compare(op_desc, DB_DEF_EFL_GFX_BASE_CLASS, POSITION_SET))
284 {
285 legacy_name = "evas_object_move";
286 }
287 else if (_op_name_compare(op_desc, DB_DEF_EFL_FILE_INTERFACE, FILE_SET) && IS_LAYOUT(wdg))
288 {
289 legacy_name = "elm_layout_file_set";
290 }
291 else if (_op_name_compare(op_desc, DB_DEF_EFL_FILE_INTERFACE, FILE_SET) &&
292 !strcmp(wdg_class_name_get(wdg), DB_DEF_BG_CLASS))
293 {
294 legacy_name = "elm_bg_file_set";
295 }
296 else if (_op_name_compare(op_desc, DB_DEF_EFL_FILE_INTERFACE, FILE_SET) &&
297 !strcmp(wdg_class_name_get(wdg), DB_DEF_ICON_CLASS))
298 {
299 legacy_name = "elm_icon_file_set";
300 }
301 else if (_op_name_compare(op_desc, DB_DEF_EFL_FILE_INTERFACE, FILE_SET) &&
302 !strcmp(wdg_class_name_get(wdg), DB_DEF_IMAGE_CLASS))
303 {
304 legacy_name = "elm_image_file_set";
305 }
306 else if (_op_name_compare(op_desc, DB_DEF_EFL_FILE_INTERFACE, FILE_SET) &&
307 !strcmp(wdg_class_name_get(wdg), DB_DEF_EVAS_IMAGE_CLASS))
308 {
309 legacy_name = "evas_object_image_file_set";
310 }
311 else if (_op_name_compare(op_desc, "Elm_Interface_Scrollable", "policy"))
312 {
313 legacy_name = "elm_scroller_policy_set";
314 }
315 else if (_op_name_compare(op_desc, "Elm_Interface_Scrollable", "bounce_allow"))
316 {
317 legacy_name = "elm_scroller_bounce_set";
318 }
319 326
320 else if (_op_name_compare(op_desc, "Elm_Interface_Fileselector", "path") && 327 else if (_op_name_compare(op_desc, DB_DEF_BG_CLASS, COLOR_SET))
321 !strcmp(wdg_class_name_get(wdg), DB_DEF_FILESELECTOR_ENTRY_CLASS))
322 {
323
324 legacy_name = "elm_fileselector_entry_path_set";
325 }
326 else if (_op_name_compare(op_desc, "Elm_Interface_Fileselector", "path") &&
327 !strcmp(wdg_class_name_get(wdg), DB_DEF_FILESELECTOR_CLASS))
328 {
329
330 legacy_name = "elm_fileselector_path_set";
331 }
332
333 else if (_op_name_compare(op_desc, DB_DEF_BG_CLASS, COLOR_SET))
334 {
335 legacy_name = "elm_bg_color_set";
336 int r = 0, b = 0, g = 0;
337 Gui_Widget_Property *prop2;
338 prop2 = wdg_prop_get(wdg, DB_DEF_BG_CLASS, COLOR_SET);
339 if (prop2)
340 { 328 {
341 r = INT_GET(prop_value_nth_get(prop2, 0)); 329 legacy_name = "elm_bg_color_set";
342 g = INT_GET(prop_value_nth_get(prop2, 1)); 330 int r = 0, b = 0, g = 0;
343 b = INT_GET(prop_value_nth_get(prop2, 2)); 331 Gui_Widget_Property *prop2;
332 prop2 = wdg_prop_get(wdg, DB_DEF_BG_CLASS, COLOR_SET);
333 if (prop2)
334 {
335 r = INT_GET(prop_value_nth_get(prop2, 0));
336 g = INT_GET(prop_value_nth_get(prop2, 1));
337 b = INT_GET(prop_value_nth_get(prop2, 2));
338 }
339 eina_strbuf_append_printf(buf, " %s(%s, %d, %d, %d", legacy_name, wdg_name_get(wdg), r, g, b);
340 goto finalize;
344 } 341 }
345 eina_strbuf_append_printf(buf, " %s(%s, %d, %d, %d", legacy_name, wdg_name_get(wdg), r, g, b);
346 goto finalize;
347 } 342 }
348 343 }
344 if (legacy_name)
345 {
349 eina_strbuf_append_printf(buf, " %s(%s, ", legacy_name, wdg_name_get(wdg)); 346 eina_strbuf_append_printf(buf, " %s(%s, ", legacy_name, wdg_name_get(wdg));
350 } 347 }
351 else 348 else
@@ -385,7 +382,7 @@ _wdg_prop_add_generate(Gui_Session *session EINA_UNUSED, const Gui_Widget *wdg,
385 } 382 }
386 383
387finalize: 384finalize:
388 if (gl_ctx->generate_legacy) 385 if (legacy_name)
389 { 386 {
390 eina_strbuf_append_printf(wdg_ctx->buf, "%s);\n", 387 eina_strbuf_append_printf(wdg_ctx->buf, "%s);\n",
391 eina_strbuf_string_get(buf)); 388 eina_strbuf_string_get(buf));