diff options
author | Jeeyong Um <conr2d@gmail.com> | 2018-04-30 19:36:03 +0900 |
---|---|---|
committer | Jeeyong Um <conr2d@gmail.com> | 2018-05-01 04:46:47 +0900 |
commit | 6d6f32fad3ff3751ca0a2bd8cf5f1a446b5a6389 (patch) | |
tree | 79347a5c31a238eb3871209c6b805d112fbc4f2a | |
parent | 5fc667a093aff9a36fbfd2159e3d3861397fb587 (diff) | |
download | efl-6d6f32fad3ff3751ca0a2bd8cf5f1a446b5a6389.tar.gz |
edje_cc: Add import statement
-rw-r--r-- | src/bin/edje/edje_cc.h | 1 | ||||
-rw-r--r-- | src/bin/edje/edje_cc_handlers.c | 66 | ||||
-rw-r--r-- | src/bin/edje/edje_cc_out.c | 1 |
3 files changed, 68 insertions, 0 deletions
diff --git a/src/bin/edje/edje_cc.h b/src/bin/edje/edje_cc.h index 6208d139d1..caaa93ce16 100644 --- a/src/bin/edje/edje_cc.h +++ b/src/bin/edje/edje_cc.h @@ -331,6 +331,7 @@ extern int max_quality; extern int line; extern Eina_List *stack; extern Edje_File *edje_file; +extern Edje_File *edje_file_import; extern Eina_List *edje_collections; extern Eina_Hash *edje_collections_lookup; extern Eina_List *externals; diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c index efefe32b29..dc65c7978f 100644 --- a/src/bin/edje/edje_cc_handlers.c +++ b/src/bin/edje/edje_cc_handlers.c @@ -205,6 +205,7 @@ static void check_has_anchors(void); static void st_id(void); static void st_requires(void); static void st_efl_version(void); +static void st_import(void); static void st_externals_external(void); static void st_images_image(void); @@ -706,6 +707,7 @@ New_Statement_Handler statement_handlers[] = {"id", st_id}, {"requires", st_requires}, {"efl_version", st_efl_version}, + {"import", st_import}, {"externals.external", st_externals_external}, IMAGE_STATEMENTS("") FONT_STYLE_CC_STATEMENTS("") @@ -2288,6 +2290,70 @@ st_requires(void) eina_array_push(requires, str); } +/** @edcsubsection{toplevel_import, + * import} */ + +/** + @page edcref + + @property + import + @parameters + [edj file path] + @effect + Import compiled edj with give file path. Users can inherit from + imported edj, and resources and classes used by inherited group + will be copied to currunt file. + Importing signle edj file is allowed and "import" statement should + be at the top of edc file. + @since 1.22 + @endproperty + */ +static void +st_import(void) +{ + char *name; + Eina_Strbuf *path; + Eina_File *f; + int error_ret; + + if (!beta) + error_and_abort(NULL, "\"import\" edj is currently a beta feature, please enable it by running edje_cc with -beta."); + + if (edje_file->collection) + { + ERR("parse error %s:%i. \"import\" statement should be at the top of edc", + file_in, line - 1); + exit(-1); + } + + name = parse_str(0); + path = eina_strbuf_new(); + + if (((name[0] == '~') && (name[1] == '/'))) + { + const char *home = eina_environment_home_get(); + eina_strbuf_append_printf(path, "%s/%s", home, name); + } + else + { + eina_strbuf_append(path, name); + } + + f = eina_file_open(eina_strbuf_string_get(path), EINA_FALSE); + if (!f) + { + ERR("parse error %s:%i. Failed to load \"%s\"", file_in, line - 1, name); + exit(-1); + } + + edje_file_import = _edje_file_open(f, &error_ret, eina_file_mtime_get(f), + EINA_TRUE); + + eina_strbuf_free(path); + free(name); +} + /** @edcsubsection{toplevel_externals, * Externals} */ diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c index f315526e4f..0baf221216 100644 --- a/src/bin/edje/edje_cc_out.c +++ b/src/bin/edje/edje_cc_out.c @@ -216,6 +216,7 @@ static void data_process_string(Edje_Part_Collection *pc, const char *prefix, ch extern Eina_List *po_files; Edje_File *edje_file = NULL; +Edje_File *edje_file_import = NULL; Eina_List *edje_collections = NULL; Eina_Hash *edje_collections_lookup = NULL; Eina_List *externals = NULL; |