summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-22 17:32:21 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-22 17:32:21 +0100
commita7dea04b2642397d3d545e2dbd0885939180d76c (patch)
treede357451c5368e2c1ca2f544db8f30729728dc71
parentd5599521172af414beb63ad52d68830e0c6fa1f4 (diff)
eolian: merge eo_file_parse and eot_file_parse
-rw-r--r--src/bin/eolian/main.c9
-rw-r--r--src/bin/eolian_cxx/eolian_cxx.cc2
-rw-r--r--src/bindings/luajit/eolian.lua15
-rw-r--r--src/lib/eolian/Eolian.h20
-rw-r--r--src/lib/eolian/eo_parser.c2
-rw-r--r--src/lib/eolian/eolian_database.c23
-rw-r--r--src/scripts/elua/modules/lualian.lua2
-rw-r--r--src/tests/eolian/eolian_parsing.c35
8 files changed, 40 insertions, 68 deletions
diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c
index b198a234ed..22675fcb0a 100644
--- a/src/bin/eolian/main.c
+++ b/src/bin/eolian/main.c
@@ -397,14 +397,7 @@ int main(int argc, char **argv)
397 397
398 is_eo = eina_str_has_suffix(eo_filename, EO_SUFFIX); 398 is_eo = eina_str_has_suffix(eo_filename, EO_SUFFIX);
399 399
400 if (!is_eo && !eina_str_has_suffix(eo_filename, EOT_SUFFIX)) 400 if (!eolian_file_parse(eo_filename))
401 {
402 ERR("The input file %s doesn't have a correct extension (.eo/.eot).\n", eo_filename);
403 goto end;
404 }
405
406 if ((is_eo && !eolian_eo_file_parse(eo_filename)) ||
407 (!is_eo && !eolian_eot_file_parse(eo_filename)))
408 { 401 {
409 ERR("Error during parsing file %s\n", eo_filename); 402 ERR("Error during parsing file %s\n", eo_filename);
410 goto end; 403 goto end;
diff --git a/src/bin/eolian_cxx/eolian_cxx.cc b/src/bin/eolian_cxx/eolian_cxx.cc
index 7afa10da10..38084f422c 100644
--- a/src/bin/eolian_cxx/eolian_cxx.cc
+++ b/src/bin/eolian_cxx/eolian_cxx.cc
@@ -230,7 +230,7 @@ database_load(options_type const& opts)
230 } 230 }
231 if (!opts.in_file.empty()) 231 if (!opts.in_file.empty())
232 { 232 {
233 if (!::eolian_eo_file_parse(opts.in_file.c_str())) 233 if (!::eolian_file_parse(opts.in_file.c_str()))
234 { 234 {
235 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain) 235 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
236 << "Failed parsing: " << opts.in_file << "."; 236 << "Failed parsing: " << opts.in_file << ".";
diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua
index 8775759546..02aae3fc2e 100644
--- a/src/bindings/luajit/eolian.lua
+++ b/src/bindings/luajit/eolian.lua
@@ -166,8 +166,7 @@ ffi.cdef [[
166 EOLIAN_UNOP_BNOT, /* ~ int */ 166 EOLIAN_UNOP_BNOT, /* ~ int */
167 } Eolian_Unary_Operator; 167 } Eolian_Unary_Operator;
168 168
169 Eina_Bool eolian_eo_file_parse(const char *filename); 169 Eina_Bool eolian_file_parse(const char *filepath);
170 Eina_Bool eolian_eot_file_parse(const char *filepath);
171 Eina_Iterator *eolian_all_eo_file_paths_get(void); 170 Eina_Iterator *eolian_all_eo_file_paths_get(void);
172 Eina_Iterator *eolian_all_eot_file_paths_get(void); 171 Eina_Iterator *eolian_all_eot_file_paths_get(void);
173 Eina_Iterator *eolian_all_eo_files_get(void); 172 Eina_Iterator *eolian_all_eo_files_get(void);
@@ -358,12 +357,12 @@ M.system_directory_scan = function()
358 return eolian.eolian_system_directory_scan() ~= 0 357 return eolian.eolian_system_directory_scan() ~= 0
359end 358end
360 359
361M.all_eo_files_parse = function() 360M.file_parse = function(fpath)
362 return eolian.eolian_all_eo_files_parse() ~= 0 361 return eolian.eolian_file_parse(fpath) ~= 0
363end 362end
364 363
365M.eo_file_parse = function(fname) 364M.all_eo_files_parse = function()
366 return eolian.eolian_eo_file_parse(fname) ~= 0 365 return eolian.eolian_all_eo_files_parse() ~= 0
367end 366end
368 367
369M.all_eot_files_parse = function() 368M.all_eot_files_parse = function()
@@ -390,10 +389,6 @@ M.database_validate = function()
390 return eolian.eolian_database_validate() ~= 0 389 return eolian.eolian_database_validate() ~= 0
391end 390end
392 391
393M.eot_file_parse = function(fname)
394 return eolian.eolian_eot_file_parse(fname) ~= 0
395end
396
397M.show_class = function(klass) 392M.show_class = function(klass)
398 return eolian.eolian_show_class(klass) ~= 0 393 return eolian.eolian_show_class(klass) ~= 0
399end 394end
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index bbe8415c17..0094ad0104 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -303,27 +303,13 @@ typedef enum
303} Eolian_Unary_Operator; 303} Eolian_Unary_Operator;
304 304
305/* 305/*
306 * @brief Parse a given .eo file and fill the database. 306 * @brief Parse the given .eo or .eot file and fill the database.
307 * 307 *
308 * During parsing, the class described into the .eo file is created with 308 * @param[in] filepath Path to the file to parse.
309 * all the information related to this class.
310 *
311 * @param[in] filename Name of the file to parse.
312 * @see eolian_eot_file_parse
313 *
314 * @ingroup Eolian
315 */
316EAPI Eina_Bool eolian_eo_file_parse(const char *filename);
317
318/*
319 * @brief Parse a given .eot file and fill the database.
320 *
321 * @param[in] filename Name of the file to parse.
322 * @see eolian_eo_file_parse
323 * 309 *
324 * @ingroup Eolian 310 * @ingroup Eolian
325 */ 311 */
326EAPI Eina_Bool eolian_eot_file_parse(const char *filepath); 312EAPI Eina_Bool eolian_file_parse(const char *filepath);
327 313
328/* 314/*
329 * @brief Get an iterator to all .eo file names with paths. 315 * @brief Get an iterator to all .eo file names with paths.
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index b72a5a738c..5ab85e2144 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -676,7 +676,7 @@ _parse_dep(Eo_Lexer *ls, const char *fname, const char *name)
676 snprintf(buf, sizeof(buf), "cyclic dependency '%s'", name); 676 snprintf(buf, sizeof(buf), "cyclic dependency '%s'", name);
677 eo_lexer_syntax_error(ls, buf); 677 eo_lexer_syntax_error(ls, buf);
678 } 678 }
679 if (!eolian_eo_file_parse(fname)) 679 if (!eo_parser_database_fill(fname, EINA_FALSE))
680 { 680 {
681 char buf[PATH_MAX]; 681 char buf[PATH_MAX];
682 eo_lexer_context_restore(ls); 682 eo_lexer_context_restore(ls);
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 5daa6d715c..94f6a9d1f1 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -206,25 +206,24 @@ database_class_name_validate(const char *class_name, const Eolian_Class **cl)
206} 206}
207 207
208EAPI Eina_Bool 208EAPI Eina_Bool
209eolian_eot_file_parse(const char *filepath) 209eolian_file_parse(const char *filepath)
210{ 210{
211 Eina_Bool is_eo;
211 if (_database_init_count <= 0) 212 if (_database_init_count <= 0)
212 return EINA_FALSE; 213 return EINA_FALSE;
213 return eo_parser_database_fill(filepath, EINA_TRUE); 214 is_eo = eina_str_has_suffix(filepath, EO_SUFFIX);
214} 215 if (!is_eo && !eina_str_has_suffix(filepath, EOT_SUFFIX))
215 216 {
216EAPI Eina_Bool 217 fprintf(stderr, "eolian: file '%s' doesn't have a correct extension\n", filepath);
217eolian_eo_file_parse(const char *filepath) 218 return EINA_FALSE;
218{ 219 }
219 if (_database_init_count <= 0) 220 return eo_parser_database_fill(filepath, !is_eo);
220 return EINA_FALSE;
221 return eo_parser_database_fill(filepath, EINA_FALSE);
222} 221}
223 222
224static Eina_Bool _tfile_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata) 223static Eina_Bool _tfile_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)
225{ 224{
226 Eina_Bool *ret = fdata; 225 Eina_Bool *ret = fdata;
227 if (*ret) *ret = eolian_eot_file_parse(data); 226 if (*ret) *ret = eo_parser_database_fill(data, EINA_TRUE);
228 return *ret; 227 return *ret;
229} 228}
230 229
@@ -243,7 +242,7 @@ eolian_all_eot_files_parse()
243static Eina_Bool _file_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata) 242static Eina_Bool _file_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)
244{ 243{
245 Eina_Bool *ret = fdata; 244 Eina_Bool *ret = fdata;
246 if (*ret) *ret = eolian_eo_file_parse(data); 245 if (*ret) *ret = eo_parser_database_fill(data, EINA_FALSE);
247 return *ret; 246 return *ret;
248} 247}
249 248
diff --git a/src/scripts/elua/modules/lualian.lua b/src/scripts/elua/modules/lualian.lua
index b2ed32491d..9ef3b7b2ee 100644
--- a/src/scripts/elua/modules/lualian.lua
+++ b/src/scripts/elua/modules/lualian.lua
@@ -689,7 +689,7 @@ M.system_directory_scan = function()
689end 689end
690 690
691M.generate = function(fname, fstream) 691M.generate = function(fname, fstream)
692 if not eolian.eo_file_parse(fname) then 692 if not eolian.file_parse(fname) then
693 error("Failed parsing file: " .. fname) 693 error("Failed parsing file: " .. fname)
694 end 694 end
695 if not eolian.database_validate() then 695 if not eolian.database_validate() then
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index e9495d788b..70c40bbfb2 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -22,7 +22,7 @@ START_TEST(eolian_namespaces)
22 eolian_init(); 22 eolian_init();
23 /* Parsing */ 23 /* Parsing */
24 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 24 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
25 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/nmsp1_class1.eo")); 25 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/nmsp1_class1.eo"));
26 26
27 /* Classes existence */ 27 /* Classes existence */
28 fail_if(!(class11 = eolian_class_get_by_name("nmsp1.class1"))); 28 fail_if(!(class11 = eolian_class_get_by_name("nmsp1.class1")));
@@ -105,7 +105,7 @@ START_TEST(eolian_events)
105 105
106 eolian_init(); 106 eolian_init();
107 /* Parsing */ 107 /* Parsing */
108 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/events.eo")); 108 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/events.eo"));
109 109
110 /* Class */ 110 /* Class */
111 fail_if(!(class = eolian_class_get_by_name("Events"))); 111 fail_if(!(class = eolian_class_get_by_name("Events")));
@@ -151,7 +151,7 @@ START_TEST(eolian_override)
151 eolian_init(); 151 eolian_init();
152 /* Parsing */ 152 /* Parsing */
153 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 153 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
154 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/override.eo")); 154 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/override.eo"));
155 155
156 /* Class */ 156 /* Class */
157 fail_if(!(class = eolian_class_get_by_name("Override"))); 157 fail_if(!(class = eolian_class_get_by_name("Override")));
@@ -257,12 +257,11 @@ END_TEST
257START_TEST(eolian_consts) 257START_TEST(eolian_consts)
258{ 258{
259 const Eolian_Function *fid = NULL; 259 const Eolian_Function *fid = NULL;
260 const Eolian_Function_Parameter *param = NULL;
261 const Eolian_Class *class; 260 const Eolian_Class *class;
262 261
263 eolian_init(); 262 eolian_init();
264 /* Parsing */ 263 /* Parsing */
265 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/consts.eo")); 264 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/consts.eo"));
266 fail_if(!(class = eolian_class_get_by_name("Consts"))); 265 fail_if(!(class = eolian_class_get_by_name("Consts")));
267 266
268 /* Method */ 267 /* Method */
@@ -286,7 +285,7 @@ START_TEST(eolian_ctor_dtor)
286 eolian_init(); 285 eolian_init();
287 /* Parsing */ 286 /* Parsing */
288 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 287 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
289 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/ctor_dtor.eo")); 288 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/ctor_dtor.eo"));
290 fail_if(!(class = eolian_class_get_by_name("Ctor_Dtor"))); 289 fail_if(!(class = eolian_class_get_by_name("Ctor_Dtor")));
291 fail_if(!(base = eolian_class_get_by_name("Base"))); 290 fail_if(!(base = eolian_class_get_by_name("Base")));
292 291
@@ -348,7 +347,7 @@ START_TEST(eolian_typedef)
348 347
349 eolian_init(); 348 eolian_init();
350 /* Parsing */ 349 /* Parsing */
351 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/typedef.eo")); 350 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/typedef.eo"));
352 351
353 /* Check that the class Dummy is still readable */ 352 /* Check that the class Dummy is still readable */
354 fail_if(!(class = eolian_class_get_by_name("Typedef"))); 353 fail_if(!(class = eolian_class_get_by_name("Typedef")));
@@ -417,7 +416,7 @@ START_TEST(eolian_complex_type)
417 416
418 eolian_init(); 417 eolian_init();
419 /* Parsing */ 418 /* Parsing */
420 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/complex_type.eo")); 419 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/complex_type.eo"));
421 fail_if(!(class = eolian_class_get_by_name("Complex_Type"))); 420 fail_if(!(class = eolian_class_get_by_name("Complex_Type")));
422 421
423 /* Properties return type */ 422 /* Properties return type */
@@ -501,7 +500,7 @@ START_TEST(eolian_scope)
501 500
502 eolian_init(); 501 eolian_init();
503 /* Parsing */ 502 /* Parsing */
504 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/scope.eo")); 503 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/scope.eo"));
505 fail_if(!(class = eolian_class_get_by_name("Scope"))); 504 fail_if(!(class = eolian_class_get_by_name("Scope")));
506 505
507 /* Property scope */ 506 /* Property scope */
@@ -538,7 +537,7 @@ START_TEST(eolian_simple_parsing)
538 537
539 eolian_init(); 538 eolian_init();
540 /* Parsing */ 539 /* Parsing */
541 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/class_simple.eo")); 540 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/class_simple.eo"));
542 fail_if(!(class = eolian_class_get_by_name("Class_Simple"))); 541 fail_if(!(class = eolian_class_get_by_name("Class_Simple")));
543 fail_if(eolian_class_get_by_file("class_simple.eo") != class); 542 fail_if(eolian_class_get_by_file("class_simple.eo") != class);
544 fail_if(strcmp(eolian_class_file_get(class), "class_simple.eo")); 543 fail_if(strcmp(eolian_class_file_get(class), "class_simple.eo"));
@@ -679,7 +678,7 @@ START_TEST(eolian_struct)
679 eolian_init(); 678 eolian_init();
680 679
681 /* Parsing */ 680 /* Parsing */
682 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/struct.eo")); 681 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/struct.eo"));
683 682
684 /* Check that the class Dummy is still readable */ 683 /* Check that the class Dummy is still readable */
685 fail_if(!(class = eolian_class_get_by_name("Struct"))); 684 fail_if(!(class = eolian_class_get_by_name("Struct")));
@@ -735,7 +734,7 @@ START_TEST(eolian_extern)
735 eolian_init(); 734 eolian_init();
736 735
737 /* Parsing */ 736 /* Parsing */
738 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/extern.eo")); 737 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/extern.eo"));
739 738
740 /* Check that the class Dummy is still readable */ 739 /* Check that the class Dummy is still readable */
741 fail_if(!(class = eolian_class_get_by_name("Extern"))); 740 fail_if(!(class = eolian_class_get_by_name("Extern")));
@@ -773,7 +772,7 @@ START_TEST(eolian_var)
773 eolian_init(); 772 eolian_init();
774 773
775 /* Parsing */ 774 /* Parsing */
776 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/var.eo")); 775 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/var.eo"));
777 776
778 /* Check that the class Dummy is still readable */ 777 /* Check that the class Dummy is still readable */
779 fail_if(!(class = eolian_class_get_by_name("Var"))); 778 fail_if(!(class = eolian_class_get_by_name("Var")));
@@ -839,7 +838,7 @@ START_TEST(eolian_enum)
839 eolian_init(); 838 eolian_init();
840 839
841 /* Parsing */ 840 /* Parsing */
842 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/enum.eo")); 841 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/enum.eo"));
843 842
844 /* Check that the class Dummy is still readable */ 843 /* Check that the class Dummy is still readable */
845 fail_if(!(class = eolian_class_get_by_name("Enum"))); 844 fail_if(!(class = eolian_class_get_by_name("Enum")));
@@ -931,7 +930,7 @@ START_TEST(eolian_class_funcs)
931 930
932 eolian_init(); 931 eolian_init();
933 /* Parsing */ 932 /* Parsing */
934 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/class_funcs.eo")); 933 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/class_funcs.eo"));
935 fail_if(!(class = eolian_class_get_by_name("Class_Funcs"))); 934 fail_if(!(class = eolian_class_get_by_name("Class_Funcs")));
936 935
937 /* Class properties */ 936 /* Class properties */
@@ -966,7 +965,7 @@ START_TEST(eolian_free_func)
966 eolian_init(); 965 eolian_init();
967 966
968 /* Parsing */ 967 /* Parsing */
969 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/free_func.eo")); 968 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/free_func.eo"));
970 969
971 /* Check that the class Dummy is still readable */ 970 /* Check that the class Dummy is still readable */
972 fail_if(!(class = eolian_class_get_by_name("Free_Func"))); 971 fail_if(!(class = eolian_class_get_by_name("Free_Func")));
@@ -1012,7 +1011,7 @@ START_TEST(eolian_null)
1012 eolian_init(); 1011 eolian_init();
1013 1012
1014 /* Parsing */ 1013 /* Parsing */
1015 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/null.eo")); 1014 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/null.eo"));
1016 1015
1017 fail_if(!(class = eolian_class_get_by_name("Null"))); 1016 fail_if(!(class = eolian_class_get_by_name("Null")));
1018 fail_if(!(func = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD))); 1017 fail_if(!(func = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
@@ -1059,7 +1058,7 @@ START_TEST(eolian_import)
1059 1058
1060 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 1059 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
1061 1060
1062 fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/import.eo")); 1061 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/import.eo"));
1063 fail_if(!(class = eolian_class_get_by_name("Import"))); 1062 fail_if(!(class = eolian_class_get_by_name("Import")));
1064 1063
1065 fail_if(!(type = eolian_type_alias_get_by_name("Imported"))); 1064 fail_if(!(type = eolian_type_alias_get_by_name("Imported")));