eolian: expose short_name/namespaces via object
authorDaniel Kolesa <d.kolesa@osg.samsung.com>
Mon, 12 Mar 2018 12:55:01 +0000 (13:55 +0100)
committerWonki Kim <wonki_.kim@samsung.com>
Tue, 10 Apr 2018 11:10:53 +0000 (20:10 +0900)
src/lib/eolian/Eolian.h
src/lib/eolian/database_class_api.c
src/lib/eolian/database_type.c
src/lib/eolian/database_type_api.c
src/lib/eolian/database_var_api.c
src/lib/eolian/eo_parser.c
src/lib/eolian/eolian_database.c
src/lib/eolian/eolian_database.h

index bde88ca..0faa901 100644 (file)
@@ -569,12 +569,42 @@ EAPI int eolian_object_column_get(const Eolian_Object *obj);
  * @see eolian_object_file_get
  * @see eolian_object_line_get
  * @see eolian_object_column_get
+ * @see eolian_object_short_name_get
+ * @see eolian_object_namespaces_get
  *
  * @ingroup Eolian
  */
 EAPI const char *eolian_object_name_get(const Eolian_Object *obj);
 
 /*
+ * @brief Get the short name of an object.
+ *
+ * This means a name without namespaces. If the object's name is not
+ * namespaced in the first place, this is equivalent to getting the full name.
+ * So for `Foo.Bar.baz` this is `baz`, for `foo` it's again just `foo`.
+ *
+ * @see eolian_object_name_get
+ * @see eolian_object_namespaces_get
+ *
+ * @ingroup Eolian
+ */
+EAPI const char *eolian_object_short_name_get(const Eolian_Object *obj);
+
+/*
+ * @brief Get a list of namespaces for the object.
+ *
+ * Each item of the iterator is the next more inner namespace. So for
+ * example if the full name is `Foo.Bar.baz`, the iterator will first
+ * give you `Foo` and then `Bar`.
+ *
+ * @see eolian_object_name_get
+ * @see eolian_object_short_name_get
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_object_namespaces_get(const Eolian_Object *obj);
+
+/*
  * @brief Scan the given directory for .eo and .eot files.
  *
  * You need to add every directory you plan to use .eo/.eot files from.
index 4c2ca98..dd01dc4 100644 (file)
@@ -15,13 +15,13 @@ eolian_class_full_name_get(const Eolian_Class *cl)
 EAPI Eina_Stringshare *
 eolian_class_name_get(const Eolian_Class *cl)
 {
-   return database_object_short_name_get((const Eolian_Object *)cl);
+   return eolian_object_short_name_get((const Eolian_Object *)cl);
 }
 
 EAPI Eina_Iterator *
 eolian_class_namespaces_get(const Eolian_Class *cl)
 {
-   return database_object_namespaces_get((const Eolian_Object *)cl);
+   return eolian_object_namespaces_get((const Eolian_Object *)cl);
 }
 
 EAPI Eolian_Class_Type
@@ -114,7 +114,7 @@ eolian_class_function_get_by_name(const Eolian_Class *cl, const char *func_name,
      }
 
    _eolian_log("function '%s' not found in class '%s'", func_name,
-               database_object_short_name_get(&cl->base));
+               eolian_object_short_name_get(&cl->base));
    return NULL;
 }
 
index b29dc87..5970159 100644 (file)
@@ -97,14 +97,14 @@ _buf_add_suffix(Eina_Strbuf *buf, const char *suffix)
 static void
 _append_name(const Eolian_Object *obj, Eina_Strbuf *buf)
 {
-   Eina_Iterator *itr = database_object_namespaces_get(obj);
+   Eina_Iterator *itr = eolian_object_namespaces_get(obj);
    const char *sp;
    EINA_ITERATOR_FOREACH(itr, sp)
      {
         eina_strbuf_append(buf, sp);
         eina_strbuf_append_char(buf, '_');
      }
-   eina_strbuf_append(buf, database_object_short_name_get(obj));
+   eina_strbuf_append(buf, eolian_object_short_name_get(obj));
 }
 
 void
index e0df501..4a01707 100644 (file)
@@ -268,13 +268,13 @@ eolian_typedecl_c_type_get(const Eolian_Typedecl *tp)
 EAPI Eina_Stringshare *
 eolian_type_name_get(const Eolian_Type *tp)
 {
-   return database_object_short_name_get((const Eolian_Object *)tp);
+   return eolian_object_short_name_get((const Eolian_Object *)tp);
 }
 
 EAPI Eina_Stringshare *
 eolian_typedecl_name_get(const Eolian_Typedecl *tp)
 {
-   return database_object_short_name_get((const Eolian_Object *)tp);
+   return eolian_object_short_name_get((const Eolian_Object *)tp);
 }
 
 EAPI Eina_Stringshare *
@@ -294,13 +294,13 @@ eolian_typedecl_full_name_get(const Eolian_Typedecl *tp)
 EAPI Eina_Iterator *
 eolian_type_namespaces_get(const Eolian_Type *tp)
 {
-   return database_object_namespaces_get((const Eolian_Object *)tp);
+   return eolian_object_namespaces_get((const Eolian_Object *)tp);
 }
 
 EAPI Eina_Iterator *
 eolian_typedecl_namespaces_get(const Eolian_Typedecl *tp)
 {
-   return database_object_namespaces_get((const Eolian_Object *)tp);
+   return eolian_object_namespaces_get((const Eolian_Object *)tp);
 }
 
 EAPI Eina_Stringshare *
index 7228a8e..944d8ac 100644 (file)
@@ -36,7 +36,7 @@ eolian_variable_value_get(const Eolian_Variable *var)
 EAPI Eina_Stringshare *
 eolian_variable_name_get(const Eolian_Variable *var)
 {
-   return database_object_short_name_get((const Eolian_Object *)var);
+   return eolian_object_short_name_get((const Eolian_Object *)var);
 }
 
 EAPI Eina_Stringshare *
@@ -49,7 +49,7 @@ eolian_variable_full_name_get(const Eolian_Variable *var)
 EAPI Eina_Iterator *
 eolian_variable_namespaces_get(const Eolian_Variable *var)
 {
-   return database_object_namespaces_get((const Eolian_Object *)var);
+   return eolian_object_namespaces_get((const Eolian_Object *)var);
 }
 
 EAPI Eina_Bool
index c148630..00a7d69 100644 (file)
@@ -1353,7 +1353,7 @@ parse_function_pointer(Eo_Lexer *ls)
    meth->klass = NULL;
    meth->type = EOLIAN_FUNCTION_POINTER;
    meth->get_scope = meth->set_scope = EOLIAN_SCOPE_PUBLIC;
-   meth->base.name = eina_stringshare_add(database_object_short_name_get(&def->base));
+   meth->base.name = eina_stringshare_add(eolian_object_short_name_get(&def->base));
 
    def->function_pointer = meth;
    eolian_object_ref(&meth->base);
index d99c849..e5cd1c0 100644 (file)
@@ -18,6 +18,41 @@ database_object_add(Eolian_Unit *unit, const Eolian_Object *obj)
                  ((Eina_List *)eina_hash_find(unit->state->objects_f, obj->file), obj));
 }
 
+EAPI Eolian_Object_Type
+eolian_object_type_get(const Eolian_Object *obj)
+{
+   if (!obj) return EOLIAN_OBJECT_UNKNOWN;
+   return obj->type;
+}
+
+EAPI const char *
+eolian_object_file_get(const Eolian_Object *obj)
+{
+   if (!obj) return NULL;
+   return obj->file;
+}
+
+EAPI int
+eolian_object_line_get(const Eolian_Object *obj)
+{
+   if (!obj) return 0;
+   return obj->line;
+}
+
+EAPI int
+eolian_object_column_get(const Eolian_Object *obj)
+{
+   if (!obj) return 0;
+   return obj->column;
+}
+
+EAPI const char *
+eolian_object_name_get(const Eolian_Object *obj)
+{
+   if (!obj) return NULL;
+   return obj->name;
+}
+
 typedef struct _Eolian_Namespace_List
 {
    Eina_Iterator itr;
@@ -46,8 +81,18 @@ _nmsp_container_get(Eina_Iterator *it EINA_UNUSED)
    return NULL;
 }
 
-Eina_Iterator *
-database_object_namespaces_get(const Eolian_Object *obj)
+EAPI const char *
+eolian_object_short_name_get(const Eolian_Object *obj)
+{
+   if (!obj || !obj->name) return NULL;
+   const char *ldot = strrchr(obj->name, '.');
+   if (ldot)
+     return ldot + 1;
+   return obj->name;
+}
+
+EAPI Eina_Iterator *
+eolian_object_namespaces_get(const Eolian_Object *obj)
 {
    if (!obj || !obj->name || !strchr(obj->name, '.')) return NULL;
 
@@ -67,16 +112,6 @@ database_object_namespaces_get(const Eolian_Object *obj)
    return &it->itr;
 }
 
-const char *
-database_object_short_name_get(const Eolian_Object *obj)
-{
-   if (!obj || !obj->name) return NULL;
-   const char *ldot = strrchr(obj->name, '.');
-   if (ldot)
-     return ldot + 1;
-   return obj->name;
-}
-
 void database_doc_del(Eolian_Documentation *doc)
 {
    if (!doc) return;
@@ -572,41 +607,6 @@ eolian_state_free(Eolian_State *state)
    free(state);
 }
 
-EAPI Eolian_Object_Type
-eolian_object_type_get(const Eolian_Object *obj)
-{
-   if (!obj) return EOLIAN_OBJECT_UNKNOWN;
-   return obj->type;
-}
-
-EAPI const char *
-eolian_object_file_get(const Eolian_Object *obj)
-{
-   if (!obj) return NULL;
-   return obj->file;
-}
-
-EAPI int
-eolian_object_line_get(const Eolian_Object *obj)
-{
-   if (!obj) return 0;
-   return obj->line;
-}
-
-EAPI int
-eolian_object_column_get(const Eolian_Object *obj)
-{
-   if (!obj) return 0;
-   return obj->column;
-}
-
-EAPI const char *
-eolian_object_name_get(const Eolian_Object *obj)
-{
-   if (!obj) return NULL;
-   return obj->name;
-}
-
 #define EO_SUFFIX ".eo"
 #define EOT_SUFFIX ".eot"
 
index bed0c20..259caee 100644 (file)
@@ -317,9 +317,6 @@ Eina_Bool database_validate(Eolian_State *state, const Eolian_Unit *src);
 
 void database_object_add(Eolian_Unit *unit, const Eolian_Object *obj);
 
-Eina_Iterator *database_object_namespaces_get(const Eolian_Object *obj);
-const char *database_object_short_name_get(const Eolian_Object *obj);
-
 void database_doc_del(Eolian_Documentation *doc);
 
 void database_unit_init(Eolian_State *state, Eolian_Unit *unit, const char *file);