aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-03-01 12:09:02 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-03-01 12:16:28 +0100
commite28e481cca6011053e3c4b11d7157d6cb3c03aa5 (patch)
tree8b4e8b3d8e6e280a768ed13d7c46e56faf2702f9
parenteolian: new APIs for class retrieval (diff)
downloadefl-e28e481cca6011053e3c4b11d7157d6cb3c03aa5.tar.gz
eolian: new variable lookup APIs
-rw-r--r--src/lib/eolian/Eolian.h197
-rw-r--r--src/lib/eolian/database_var_api.c55
-rw-r--r--src/lib/eolian/eolian_database.c117
3 files changed, 244 insertions, 125 deletions
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index b7f5b6bc66..b4581478cb 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -688,6 +688,73 @@ EAPI const Eolian_Class *eolian_state_class_by_file_get(const Eolian_State *stat
EAPI Eina_Iterator *eolian_state_classes_get(const Eolian_State *state);
/*
+ * @brief Get a global variable in a state by name.
+ *
+ * @param[in] state The state.
+ * @param[in] name the name of the variable
+ *
+ * @ingroup Eolian
+ */
+EAPI const Eolian_Variable *eolian_state_global_by_name_get(const Eolian_State *state, const char *name);
+
+/*
+ * @brief Get a constant variable in a state by name.
+ *
+ * @param[in] state The state.
+ * @param[in] name the name of the variable
+ *
+ * @ingroup Eolian
+ */
+EAPI const Eolian_Variable *eolian_state_constant_by_name_get(const Eolian_State *state, const char *name);
+
+/*
+ * @brief Get an iterator to all global variables contained in a file.
+ *
+ * @param[in] state The state.
+ * @param[in] file_name The file name.
+ *
+ * Thanks to internal caching, this is an O(1) operation.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_state_globals_by_file_get(const Eolian_State *state, const char *file_name);
+
+/*
+ * @brief Get an iterator to all constant variables contained in a file.
+ *
+ * @param[in] state The state.
+ * @param[in] file_name The file name.
+ * @return the iterator or NULL
+ *
+ * Thanks to internal caching, this is an O(1) operation.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_state_constants_by_file_get(const Eolian_State *state, const char *file_name);
+
+/*
+ * @brief Get an iterator to all constant variables in the Eolian database.
+ *
+ * @return the iterator or NULL
+ *
+ * Thanks to internal caching, this is an O(1) operation.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_state_constants_get(const Eolian_State *state);
+
+/*
+ * @brief Get an iterator to all global variables in the Eolian database.
+ *
+ * @return the iterator or NULL
+ *
+ * Thanks to internal caching, this is an O(1) operation.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_state_globals_get(const Eolian_State *state);
+
+/*
* @brief Get the children (dependencies) of a unit.
*
* The iterator is obviously again to `const Eolian_Unit *`.
@@ -730,6 +797,48 @@ EAPI const Eolian_Class *eolian_unit_class_by_name_get(const Eolian_Unit *unit,
EAPI Eina_Iterator *eolian_unit_classes_get(const Eolian_Unit *unit);
/*
+ * @brief Get a global variable in a unit by name.
+ *
+ * @param[in] unit The unit.
+ * @param[in] name the name of the variable
+ *
+ * @ingroup Eolian
+ */
+EAPI const Eolian_Variable *eolian_unit_global_by_name_get(const Eolian_Unit *unit, const char *name);
+
+/*
+ * @brief Get a constant variable in a unit by name.
+ *
+ * @param[in] unit The unit.
+ * @param[in] name the name of the variable
+ *
+ * @ingroup Eolian
+ */
+EAPI const Eolian_Variable *eolian_unit_constant_by_name_get(const Eolian_Unit *unit, const char *name);
+
+/*
+ * @brief Get an iterator to all constant variables in the Eolian database.
+ *
+ * @return the iterator or NULL
+ *
+ * Thanks to internal caching, this is an O(1) operation.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_unit_constants_get(const Eolian_Unit *unit);
+
+/*
+ * @brief Get an iterator to all global variables in the Eolian database.
+ *
+ * @return the iterator or NULL
+ *
+ * Thanks to internal caching, this is an O(1) operation.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_unit_globals_get(const Eolian_Unit *unit);
+
+/*
* @brief Returns the name of the file containing the given class.
*
* @param[in] klass the class.
@@ -2305,76 +2414,6 @@ EAPI const Eolian_Expression *eolian_expression_unary_expression_get(const Eolia
EAPI Eolian_Value eolian_expression_value_get(const Eolian_Expression *expr);
/*
- * @brief Get a global variable by name. Supports namespaces.
- *
- * @param[in] unit the unit to look in
- * @param[in] name the name of the variable
- * @return the variable handle or NULL
- *
- * @ingroup Eolian
- */
-EAPI const Eolian_Variable *eolian_variable_global_get_by_name(const Eolian_Unit *unit, const char *name);
-
-/*
- * @brief Get a constant variable by name. Supports namespaces.
- *
- * @param[in] unit the unit to look in
- * @param[in] name the name of the variable
- * @return the variable handle or NULL
- *
- * @ingroup Eolian
- */
-EAPI const Eolian_Variable *eolian_variable_constant_get_by_name(const Eolian_Unit *unit, const char *name);
-
-/*
- * @brief Get an iterator to all global variables contained in a file.
- *
- * @param[in] unit the unit to look in
- * @param[in] fname the file name without full path
- * @return the iterator or NULL
- *
- * Thanks to internal caching, this is an O(1) operation.
- *
- * @ingroup Eolian
- */
-EAPI Eina_Iterator *eolian_variable_globals_get_by_file(const Eolian_Unit *unit, const char *fname);
-
-/*
- * @brief Get an iterator to all constant variables contained in a file.
- *
- * @param[in] unit the unit to look in
- * @param[in] fname the file name without full path
- * @return the iterator or NULL
- *
- * Thanks to internal caching, this is an O(1) operation.
- *
- * @ingroup Eolian
- */
-EAPI Eina_Iterator *eolian_variable_constants_get_by_file(const Eolian_Unit *unit, const char *fname);
-
-/*
- * @brief Get an iterator to all constant variables in the Eolian database.
- *
- * @return the iterator or NULL
- *
- * Thanks to internal caching, this is an O(1) operation.
- *
- * @ingroup Eolian
- */
-EAPI Eina_Iterator *eolian_variable_all_constants_get(const Eolian_Unit *unit);
-
-/*
- * @brief Get an iterator to all global variables in the Eolian database.
- *
- * @return the iterator or NULL
- *
- * Thanks to internal caching, this is an O(1) operation.
- *
- * @ingroup Eolian
- */
-EAPI Eina_Iterator *eolian_variable_all_globals_get(const Eolian_Unit *unit);
-
-/*
* @brief Get the type of a variable (global, constant)
*
* @param[in] var the variable.
@@ -2715,6 +2754,24 @@ EAPI const Eolian_Class *eolian_class_get_by_file(const Eolian_Unit *unit, const
/* DEPRECATED */
EAPI Eina_Iterator *eolian_all_classes_get(const Eolian_Unit *unit);
+/* DEPRECATED */
+EAPI const Eolian_Variable *eolian_variable_global_get_by_name(const Eolian_Unit *unit, const char *name);
+
+/* DEPRECATED */
+EAPI const Eolian_Variable *eolian_variable_constant_get_by_name(const Eolian_Unit *unit, const char *name);
+
+/* DEPRECATED */
+EAPI Eina_Iterator *eolian_variable_globals_get_by_file(const Eolian_Unit *unit, const char *fname);
+
+/* DEPRECATED */
+EAPI Eina_Iterator *eolian_variable_constants_get_by_file(const Eolian_Unit *unit, const char *fname);
+
+/* DEPRECATED */
+EAPI Eina_Iterator *eolian_variable_all_constants_get(const Eolian_Unit *unit);
+
+/* DEPRECATED */
+EAPI Eina_Iterator *eolian_variable_all_globals_get(const Eolian_Unit *unit);
+
#endif
/**
diff --git a/src/lib/eolian/database_var_api.c b/src/lib/eolian/database_var_api.c
index 1e92c62e8b..cde46b9a0a 100644
--- a/src/lib/eolian/database_var_api.c
+++ b/src/lib/eolian/database_var_api.c
@@ -5,61 +5,6 @@
#include <Eina.h>
#include "eolian_database.h"
-EAPI const Eolian_Variable *
-eolian_variable_global_get_by_name(const Eolian_Unit *unit, const char *name)
-{
- if (!unit) return NULL;
- Eina_Stringshare *shr = eina_stringshare_add(name);
- Eolian_Variable *v = eina_hash_find(unit->globals, shr);
- eina_stringshare_del(shr);
- return v;
-}
-
-EAPI const Eolian_Variable *
-eolian_variable_constant_get_by_name(const Eolian_Unit *unit, const char *name)
-{
- if (!unit) return NULL;
- Eina_Stringshare *shr = eina_stringshare_add(name);
- Eolian_Variable *v = eina_hash_find(unit->constants, shr);
- eina_stringshare_del(shr);
- return v;
-}
-
-EAPI Eina_Iterator *
-eolian_variable_globals_get_by_file(const Eolian_Unit *unit, const char *fname)
-{
- if (!unit) return NULL;
- Eina_Stringshare *shr = eina_stringshare_add(fname);
- Eina_List *l = eina_hash_find(unit->state->globals_f, shr);
- eina_stringshare_del(shr);
- if (!l) return NULL;
- return eina_list_iterator_new(l);
-}
-
-EAPI Eina_Iterator *
-eolian_variable_constants_get_by_file(const Eolian_Unit *unit,
- const char *fname)
-{
- if (!unit) return NULL;
- Eina_Stringshare *shr = eina_stringshare_add(fname);
- Eina_List *l = eina_hash_find(unit->state->constants_f, shr);
- eina_stringshare_del(shr);
- if (!l) return NULL;
- return eina_list_iterator_new(l);
-}
-
-EAPI Eina_Iterator *
-eolian_variable_all_constants_get(const Eolian_Unit *unit)
-{
- return (unit ? eina_hash_iterator_data_new(unit->constants) : NULL);
-}
-
-EAPI Eina_Iterator *
-eolian_variable_all_globals_get(const Eolian_Unit *unit)
-{
- return (unit ? eina_hash_iterator_data_new(unit->globals) : NULL);
-}
-
EAPI Eolian_Variable_Type
eolian_variable_type_get(const Eolian_Variable *var)
{
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index ada3062f3e..578d38027d 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -956,6 +956,52 @@ eolian_state_classes_get(const Eolian_State *state)
return eolian_unit_classes_get((Eolian_Unit *)state);
}
+EAPI const Eolian_Variable *
+eolian_state_global_by_name_get(const Eolian_State *state, const char *name)
+{
+ return eolian_unit_global_by_name_get((Eolian_Unit *)state, name);
+}
+
+EAPI const Eolian_Variable *
+eolian_state_constant_by_name_get(const Eolian_State *state, const char *name)
+{
+ return eolian_unit_constant_by_name_get((Eolian_Unit *)state, name);
+}
+
+EAPI Eina_Iterator *
+eolian_state_globals_by_file_get(const Eolian_State *state, const char *file_name)
+{
+ if (!state) return NULL;
+ Eina_Stringshare *shr = eina_stringshare_add(file_name);
+ Eina_List *l = eina_hash_find(state->globals_f, shr);
+ eina_stringshare_del(shr);
+ if (!l) return NULL;
+ return eina_list_iterator_new(l);
+}
+
+EAPI Eina_Iterator *
+eolian_state_constants_by_file_get(const Eolian_State *state, const char *file_name)
+{
+ if (!state) return NULL;
+ Eina_Stringshare *shr = eina_stringshare_add(file_name);
+ Eina_List *l = eina_hash_find(state->constants_f, shr);
+ eina_stringshare_del(shr);
+ if (!l) return NULL;
+ return eina_list_iterator_new(l);
+}
+
+EAPI Eina_Iterator *
+eolian_state_constants_get(const Eolian_State *state)
+{
+ return eolian_unit_constants_get((Eolian_Unit *)state);
+}
+
+EAPI Eina_Iterator *
+eolian_state_globals_get(const Eolian_State *state)
+{
+ return eolian_unit_globals_get((Eolian_Unit *)state);
+}
+
EAPI Eina_Iterator *
eolian_unit_children_get(const Eolian_Unit *unit)
{
@@ -1005,6 +1051,77 @@ eolian_all_classes_get(const Eolian_Unit *unit)
return eolian_unit_classes_get(unit);
}
+EAPI const Eolian_Variable *
+eolian_unit_global_by_name_get(const Eolian_Unit *unit, const char *name)
+{
+ if (!unit) return NULL;
+ Eina_Stringshare *shr = eina_stringshare_add(name);
+ Eolian_Variable *v = eina_hash_find(unit->globals, shr);
+ eina_stringshare_del(shr);
+ return v;
+}
+
+EAPI const Eolian_Variable *
+eolian_unit_constant_by_name_get(const Eolian_Unit *unit, const char *name)
+{
+ if (!unit) return NULL;
+ Eina_Stringshare *shr = eina_stringshare_add(name);
+ Eolian_Variable *v = eina_hash_find(unit->constants, shr);
+ eina_stringshare_del(shr);
+ return v;
+}
+
+EAPI Eina_Iterator *
+eolian_unit_constants_get(const Eolian_Unit *unit)
+{
+ return (unit ? eina_hash_iterator_data_new(unit->constants) : NULL);
+}
+
+EAPI Eina_Iterator *
+eolian_unit_globals_get(const Eolian_Unit *unit)
+{
+ return (unit ? eina_hash_iterator_data_new(unit->globals) : NULL);
+}
+
+EAPI const Eolian_Variable *
+eolian_variable_global_get_by_name(const Eolian_Unit *unit, const char *name)
+{
+ return eolian_unit_global_by_name_get(unit, name);
+}
+
+EAPI const Eolian_Variable *
+eolian_variable_constant_get_by_name(const Eolian_Unit *unit, const char *name)
+{
+ return eolian_unit_constant_by_name_get(unit, name);
+}
+
+EAPI Eina_Iterator *
+eolian_variable_globals_get_by_file(const Eolian_Unit *unit, const char *fname)
+{
+ if (!unit) return NULL;
+ return eolian_state_globals_by_file_get(unit->state, fname);
+}
+
+EAPI Eina_Iterator *
+eolian_variable_constants_get_by_file(const Eolian_Unit *unit,
+ const char *fname)
+{
+ if (!unit) return NULL;
+ return eolian_state_constants_by_file_get(unit->state, fname);
+}
+
+EAPI Eina_Iterator *
+eolian_variable_all_constants_get(const Eolian_Unit *unit)
+{
+ return eolian_unit_constants_get(unit);
+}
+
+EAPI Eina_Iterator *
+eolian_variable_all_globals_get(const Eolian_Unit *unit)
+{
+ return eolian_unit_globals_get(unit);
+}
+
char *
database_class_to_filename(const char *cname)
{