summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-05-18 16:31:03 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-05-30 17:15:53 +0200
commit653cf6bac37f6d74bd18d1088a7fb2ce6d661bc2 (patch)
tree2c170fecf5775c030743ae621c634e3e2eae7683 /src
parent6d453bc6944897c6f0de34f3c7592f608061d320 (diff)
eolian: make by-name variable lookups take unit
Diffstat (limited to 'src')
-rw-r--r--src/bindings/luajit/eolian.lua12
-rw-r--r--src/lib/eolian/Eolian.h6
-rw-r--r--src/lib/eolian/database_expr.c3
-rw-r--r--src/lib/eolian/database_var_api.c6
-rw-r--r--src/tests/eolian/eolian_parsing.c23
5 files changed, 29 insertions, 21 deletions
diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua
index d98e047..8177aa5 100644
--- a/src/bindings/luajit/eolian.lua
+++ b/src/bindings/luajit/eolian.lua
@@ -367,8 +367,8 @@ ffi.cdef [[
367 Eolian_Unary_Operator eolian_expression_unary_operator_get(const Eolian_Expression *expr); 367 Eolian_Unary_Operator eolian_expression_unary_operator_get(const Eolian_Expression *expr);
368 const Eolian_Expression *eolian_expression_unary_expression_get(const Eolian_Expression *expr); 368 const Eolian_Expression *eolian_expression_unary_expression_get(const Eolian_Expression *expr);
369 Eolian_Value_t eolian_expression_value_get(const Eolian_Expression *expr); 369 Eolian_Value_t eolian_expression_value_get(const Eolian_Expression *expr);
370 const Eolian_Variable *eolian_variable_global_get_by_name(const char *name); 370 const Eolian_Variable *eolian_variable_global_get_by_name(const Eolian_Unit *unit, const char *name);
371 const Eolian_Variable *eolian_variable_constant_get_by_name(const char *name); 371 const Eolian_Variable *eolian_variable_constant_get_by_name(const Eolian_Unit *unit, const char *name);
372 Eina_Iterator *eolian_variable_globals_get_by_file(const char *fname); 372 Eina_Iterator *eolian_variable_globals_get_by_file(const char *fname);
373 Eina_Iterator *eolian_variable_constants_get_by_file(const char *fname); 373 Eina_Iterator *eolian_variable_constants_get_by_file(const char *fname);
374 Eina_Iterator *eolian_variable_all_constants_get(void); 374 Eina_Iterator *eolian_variable_all_constants_get(void);
@@ -1362,14 +1362,14 @@ M.Expression = ffi.metatype("Eolian_Expression", {
1362 } 1362 }
1363}) 1363})
1364 1364
1365M.variable_global_get_by_name = function(name) 1365M.variable_global_get_by_name = function(unit, name)
1366 local v = eolian.eolian_variable_global_get_by_name(name) 1366 local v = eolian.eolian_variable_global_get_by_name(unit, name)
1367 if v == nil then return nil end 1367 if v == nil then return nil end
1368 return v 1368 return v
1369end 1369end
1370 1370
1371M.variable_constant_get_by_name = function(name) 1371M.variable_constant_get_by_name = function(unit, name)
1372 local v = eolian.eolian_variable_constant_get_by_name(name) 1372 local v = eolian.eolian_variable_constant_get_by_name(unit, name)
1373 if v == nil then return nil end 1373 if v == nil then return nil end
1374 return v 1374 return v
1375end 1375end
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index 630b0b4..08592a8 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -2055,22 +2055,24 @@ EAPI Eolian_Value eolian_expression_value_get(const Eolian_Expression *expr);
2055/* 2055/*
2056 * @brief Get a global variable by name. Supports namespaces. 2056 * @brief Get a global variable by name. Supports namespaces.
2057 * 2057 *
2058 * @param[in] unit the unit to look in
2058 * @param[in] name the name of the variable 2059 * @param[in] name the name of the variable
2059 * @return the variable handle or NULL 2060 * @return the variable handle or NULL
2060 * 2061 *
2061 * @ingroup Eolian 2062 * @ingroup Eolian
2062 */ 2063 */
2063EAPI const Eolian_Variable *eolian_variable_global_get_by_name(const char *name); 2064EAPI const Eolian_Variable *eolian_variable_global_get_by_name(const Eolian_Unit *unit, const char *name);
2064 2065
2065/* 2066/*
2066 * @brief Get a constant variable by name. Supports namespaces. 2067 * @brief Get a constant variable by name. Supports namespaces.
2067 * 2068 *
2069 * @param[in] unit the unit to look in
2068 * @param[in] name the name of the variable 2070 * @param[in] name the name of the variable
2069 * @return the variable handle or NULL 2071 * @return the variable handle or NULL
2070 * 2072 *
2071 * @ingroup Eolian 2073 * @ingroup Eolian
2072 */ 2074 */
2073EAPI const Eolian_Variable *eolian_variable_constant_get_by_name(const char *name); 2075EAPI const Eolian_Variable *eolian_variable_constant_get_by_name(const Eolian_Unit *unit, const char *name);
2074 2076
2075/* 2077/*
2076 * @brief Get an iterator to all global variables contained in a file. 2078 * @brief Get an iterator to all global variables contained in a file.
diff --git a/src/lib/eolian/database_expr.c b/src/lib/eolian/database_expr.c
index 45f89a9..5717f8b 100644
--- a/src/lib/eolian/database_expr.c
+++ b/src/lib/eolian/database_expr.c
@@ -493,8 +493,9 @@ eval_exp(const Eolian_Expression *expr, Eolian_Expression_Mask mask,
493 } 493 }
494 case EOLIAN_EXPR_NAME: 494 case EOLIAN_EXPR_NAME:
495 { 495 {
496 /* FIXME: pass unit properly */
496 const Eolian_Variable *var = eolian_variable_constant_get_by_name 497 const Eolian_Variable *var = eolian_variable_constant_get_by_name
497 (expr->value.s); 498 (NULL, expr->value.s);
498 const Eolian_Expression *exp = NULL; 499 const Eolian_Expression *exp = NULL;
499 500
500 if (!var) 501 if (!var)
diff --git a/src/lib/eolian/database_var_api.c b/src/lib/eolian/database_var_api.c
index 0e1af2d..4842ec5 100644
--- a/src/lib/eolian/database_var_api.c
+++ b/src/lib/eolian/database_var_api.c
@@ -6,7 +6,8 @@
6#include "eolian_database.h" 6#include "eolian_database.h"
7 7
8EAPI const Eolian_Variable * 8EAPI const Eolian_Variable *
9eolian_variable_global_get_by_name(const char *name) 9eolian_variable_global_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
10 const char *name)
10{ 11{
11 if (!_globals) return NULL; 12 if (!_globals) return NULL;
12 Eina_Stringshare *shr = eina_stringshare_add(name); 13 Eina_Stringshare *shr = eina_stringshare_add(name);
@@ -16,7 +17,8 @@ eolian_variable_global_get_by_name(const char *name)
16} 17}
17 18
18EAPI const Eolian_Variable * 19EAPI const Eolian_Variable *
19eolian_variable_constant_get_by_name(const char *name) 20eolian_variable_constant_get_by_name(const Eolian_Unit *unit EINA_UNUSED,
21 const char *name)
20{ 22{
21 if (!_constants) return NULL; 23 if (!_constants) return NULL;
22 Eina_Stringshare *shr = eina_stringshare_add(name); 24 Eina_Stringshare *shr = eina_stringshare_add(name);
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index 9c9ac54..4d80a0b 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -756,20 +756,21 @@ START_TEST(eolian_var)
756 const Eolian_Expression *exp = NULL; 756 const Eolian_Expression *exp = NULL;
757 const Eolian_Type *type = NULL; 757 const Eolian_Type *type = NULL;
758 const Eolian_Class *class; 758 const Eolian_Class *class;
759 const Eolian_Unit *unit;
759 Eolian_Value v; 760 Eolian_Value v;
760 const char *name; 761 const char *name;
761 762
762 eolian_init(); 763 eolian_init();
763 764
764 /* Parsing */ 765 /* Parsing */
765 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/var.eo")); 766 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/var.eo")));
766 767
767 /* Check that the class Dummy is still readable */ 768 /* Check that the class Dummy is still readable */
768 fail_if(!(class = eolian_class_get_by_name("Var"))); 769 fail_if(!(class = eolian_class_get_by_name("Var")));
769 fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)); 770 fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
770 771
771 /* regular constant */ 772 /* regular constant */
772 fail_if(!(var = eolian_variable_constant_get_by_name("Foo"))); 773 fail_if(!(var = eolian_variable_constant_get_by_name(unit, "Foo")));
773 fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT); 774 fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT);
774 fail_if(eolian_variable_is_extern(var)); 775 fail_if(eolian_variable_is_extern(var));
775 fail_if(!(type = eolian_variable_base_type_get(var))); 776 fail_if(!(type = eolian_variable_base_type_get(var)));
@@ -781,7 +782,7 @@ START_TEST(eolian_var)
781 fail_if(v.value.i != 5); 782 fail_if(v.value.i != 5);
782 783
783 /* regular global */ 784 /* regular global */
784 fail_if(!(var = eolian_variable_global_get_by_name("Bar"))); 785 fail_if(!(var = eolian_variable_global_get_by_name(unit, "Bar")));
785 fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL); 786 fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL);
786 fail_if(eolian_variable_is_extern(var)); 787 fail_if(eolian_variable_is_extern(var));
787 fail_if(!(type = eolian_variable_base_type_get(var))); 788 fail_if(!(type = eolian_variable_base_type_get(var)));
@@ -793,7 +794,7 @@ START_TEST(eolian_var)
793 fail_if(((int)v.value.f) != 10); 794 fail_if(((int)v.value.f) != 10);
794 795
795 /* no-value global */ 796 /* no-value global */
796 fail_if(!(var = eolian_variable_global_get_by_name("Baz"))); 797 fail_if(!(var = eolian_variable_global_get_by_name(unit, "Baz")));
797 fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL); 798 fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL);
798 fail_if(eolian_variable_is_extern(var)); 799 fail_if(eolian_variable_is_extern(var));
799 fail_if(!(type = eolian_variable_base_type_get(var))); 800 fail_if(!(type = eolian_variable_base_type_get(var)));
@@ -802,7 +803,7 @@ START_TEST(eolian_var)
802 fail_if(eolian_variable_value_get(var)); 803 fail_if(eolian_variable_value_get(var));
803 804
804 /* extern global */ 805 /* extern global */
805 fail_if(!(var = eolian_variable_global_get_by_name("Bah"))); 806 fail_if(!(var = eolian_variable_global_get_by_name(unit, "Bah")));
806 fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL); 807 fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL);
807 fail_if(!eolian_variable_is_extern(var)); 808 fail_if(!eolian_variable_is_extern(var));
808 fail_if(!(type = eolian_variable_base_type_get(var))); 809 fail_if(!(type = eolian_variable_base_type_get(var)));
@@ -822,6 +823,7 @@ START_TEST(eolian_enum)
822 const Eolian_Type *type = NULL; 823 const Eolian_Type *type = NULL;
823 const Eolian_Class *class; 824 const Eolian_Class *class;
824 const Eolian_Expression *exp; 825 const Eolian_Expression *exp;
826 const Eolian_Unit *unit;
825 Eina_Stringshare *cname; 827 Eina_Stringshare *cname;
826 const char *name; 828 const char *name;
827 Eolian_Value v; 829 Eolian_Value v;
@@ -829,7 +831,7 @@ START_TEST(eolian_enum)
829 eolian_init(); 831 eolian_init();
830 832
831 /* Parsing */ 833 /* Parsing */
832 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/enum.eo")); 834 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/enum.eo")));
833 835
834 /* Check that the class Dummy is still readable */ 836 /* Check that the class Dummy is still readable */
835 fail_if(!(class = eolian_class_get_by_name("Enum"))); 837 fail_if(!(class = eolian_class_get_by_name("Enum")));
@@ -892,7 +894,7 @@ START_TEST(eolian_enum)
892 fail_if(strcmp(cname, "NAME_SPACED_PANTS")); 894 fail_if(strcmp(cname, "NAME_SPACED_PANTS"));
893 eina_stringshare_del(cname); 895 eina_stringshare_del(cname);
894 896
895 fail_if(!(var = eolian_variable_constant_get_by_name("Bah"))); 897 fail_if(!(var = eolian_variable_constant_get_by_name(unit, "Bah")));
896 fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT); 898 fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT);
897 fail_if(eolian_variable_is_extern(var)); 899 fail_if(eolian_variable_is_extern(var));
898 fail_if(!(type = eolian_variable_base_type_get(var))); 900 fail_if(!(type = eolian_variable_base_type_get(var)));
@@ -903,7 +905,7 @@ START_TEST(eolian_enum)
903 fail_if(v.type != EOLIAN_EXPR_INT); 905 fail_if(v.type != EOLIAN_EXPR_INT);
904 fail_if(v.value.i != (1 << 0)); 906 fail_if(v.value.i != (1 << 0));
905 907
906 fail_if(!(var = eolian_variable_constant_get_by_name("Pants"))); 908 fail_if(!(var = eolian_variable_constant_get_by_name(unit, "Pants")));
907 fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT); 909 fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT);
908 fail_if(!(exp = eolian_variable_value_get(var))); 910 fail_if(!(exp = eolian_variable_value_get(var)));
909 v = eolian_expression_eval(exp, EOLIAN_MASK_ALL); 911 v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
@@ -1136,13 +1138,14 @@ START_TEST(eolian_docs)
1136 const Eolian_Function_Parameter *par; 1138 const Eolian_Function_Parameter *par;
1137 const Eolian_Struct_Type_Field *sfl; 1139 const Eolian_Struct_Type_Field *sfl;
1138 const Eolian_Enum_Type_Field *efl; 1140 const Eolian_Enum_Type_Field *efl;
1141 const Eolian_Unit *unit;
1139 Eina_Iterator *itr; 1142 Eina_Iterator *itr;
1140 1143
1141 eolian_init(); 1144 eolian_init();
1142 1145
1143 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data")); 1146 fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
1144 1147
1145 fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/docs.eo")); 1148 fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/docs.eo")));
1146 1149
1147 fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Foo"))); 1150 fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Foo")));
1148 fail_if(!(doc = eolian_typedecl_documentation_get(tdl))); 1151 fail_if(!(doc = eolian_typedecl_documentation_get(tdl)));
@@ -1277,7 +1280,7 @@ START_TEST(eolian_docs)
1277 fail_if(strcmp(eolian_documentation_since_get(doc), 1280 fail_if(strcmp(eolian_documentation_since_get(doc),
1278 "2.0")); 1281 "2.0"));
1279 1282
1280 fail_if(!(var = eolian_variable_global_get_by_name("pants"))); 1283 fail_if(!(var = eolian_variable_global_get_by_name(unit, "pants")));
1281 fail_if(!(doc = eolian_variable_documentation_get(var))); 1284 fail_if(!(doc = eolian_variable_documentation_get(var)));
1282 fail_if(strcmp(eolian_documentation_summary_get(doc), 1285 fail_if(strcmp(eolian_documentation_summary_get(doc),
1283 "Docs for var.")); 1286 "Docs for var."));