EAPI Eina_Iterator *eolian_state_units_get(const Eolian_State *state);
/*
+ * @brief Get an object in a state by name.
+ *
+ * Only objects declared directly within the file can be retrieved, i.e.
+ * classes, typedecls and variables.
+ *
+ * @param[in] state The state.
+ * @param[in] name The fully namespaced object name.
+ *
+ * @ingroup Eolian
+ */
+EAPI const Eolian_Object *eolian_state_object_by_name_get(const Eolian_State *state, const char *name);
+
+/*
+ * @brief Get a list of objects from a file.
+ *
+ * The list follows declaration order in the file. Only objects declared
+ * directly within the file can be retrieved, i.e. classes, typedecls and
+ * variables.
+ *
+ * @param[in] state The state.
+ * @param[in] file_name The file name.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_state_objects_by_file_get(const Eolian_State *state, const char *file_name);
+
+/*
+ * @brief Get all objects in the state.
+ *
+ * The order is not necessarily the declaration order. Only objects declared
+ * directly within the file can be retrieved, i.e. classes, typedecls and
+ * variables.
+ *
+ * @param[in] state The state.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_state_objects_get(const Eolian_State *state);
+
+/*
* @brief Get a class within a state by name.
*
* @param[in] state The state.
EAPI const char *eolian_unit_file_get(const Eolian_Unit *unit);
/*
+ * @brief Get an object in a unit by name.
+ *
+ * Only objects declared directly within the file can be retrieved, i.e.
+ * classes, typedecls and variables.
+ *
+ * @param[in] unit The unit.
+ * @param[in] name The fully namespaced object name.
+ *
+ * @ingroup Eolian
+ */
+EAPI const Eolian_Object *eolian_unit_object_by_name_get(const Eolian_Unit *unit, const char *name);
+
+/*
+ * @brief Get all objects in the unit.
+ *
+ * The order is not necessarily the declaration order. Only objects declared
+ * directly within the file can be retrieved, i.e. classes, typedecls and
+ * variables.
+ *
+ * @param[in] unit The unit.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_unit_objects_get(const Eolian_Unit *unit);
+
+/*
* @brief Get a class within a unit by name.
*
* @param[in] unit The unit.
decl->data = ptr;
EOLIAN_OBJECT_ADD(unit, name, decl, decls);
eina_hash_set(unit->state->decls_f, file, eina_list_append
- ((Eina_List*)eina_hash_find(unit->state->decls_f, file), decl));
+ ((Eina_List *)eina_hash_find(unit->state->decls_f, file), decl));
+ /* object storage */
+ eina_hash_add(unit->objects, name, ptr);
+ eina_hash_add(unit->state->unit.objects, name, ptr);
+ eina_hash_set(unit->state->objects_f, file, eina_list_append
+ ((Eina_List *)eina_hash_find(unit->state->objects_f, file), ptr));
}
static void
unit->aliases = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
unit->structs = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
unit->enums = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
+ unit->objects = eina_hash_stringshared_new(NULL);
unit->decls = eina_hash_stringshared_new(EINA_FREE_CB(database_decl_del));
}
eina_hash_free(unit->aliases);
eina_hash_free(unit->structs);
eina_hash_free(unit->enums);
+ eina_hash_free(unit->objects);
eina_hash_free(unit->decls);
}
state->enums_f = eina_hash_stringshared_new(_hashlist_free);
state->globals_f = eina_hash_stringshared_new(_hashlist_free);
state->constants_f = eina_hash_stringshared_new(_hashlist_free);
+ state->objects_f = eina_hash_stringshared_new(_hashlist_free);
state->decls_f = eina_hash_stringshared_new(_hashlist_free);
return state;
eina_hash_free(state->enums_f);
eina_hash_free(state->globals_f);
eina_hash_free(state->constants_f);
+ eina_hash_free(state->objects_f);
eina_hash_free(state->decls_f);
free(state);
return eina_hash_iterator_data_new(state->units);
}
+EAPI const Eolian_Object *
+eolian_state_object_by_name_get(const Eolian_State *state, const char *name)
+{
+ return eolian_unit_object_by_name_get((Eolian_Unit *)state, name);
+}
+
+EAPI Eina_Iterator *
+eolian_state_objects_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->objects_f, shr);
+ eina_stringshare_del(shr);
+ if (!l) return NULL;
+ return eina_list_iterator_new(l);
+}
+
+EAPI Eina_Iterator *
+eolian_state_objects_get(const Eolian_State *state)
+{
+ return eolian_unit_objects_get((Eolian_Unit *)state);
+}
+
EAPI const Eolian_Class *
eolian_state_class_by_name_get(const Eolian_State *state, const char *class_name)
{
return unit->file;
}
+EAPI const Eolian_Object *
+eolian_unit_object_by_name_get(const Eolian_Unit *unit, const char *name)
+{
+ if (!unit) return NULL;
+ Eina_Stringshare *shr = eina_stringshare_add(name);
+ Eolian_Object *o = eina_hash_find(unit->objects, shr);
+ eina_stringshare_del(shr);
+ return o;
+}
+
+EAPI Eina_Iterator *eolian_unit_objects_get(const Eolian_Unit *unit)
+{
+ return (unit ? eina_hash_iterator_data_new(unit->objects) : NULL);
+}
+
EAPI const Eolian_Class *
eolian_unit_class_by_name_get(const Eolian_Unit *unit, const char *class_name)
{