Eolian: clean API.
authorDaniel Zaoui <daniel.zaoui@samsung.com>
Sun, 6 Apr 2014 14:10:05 +0000 (17:10 +0300)
committerDaniel Zaoui <daniel.zaoui@samsung.com>
Tue, 8 Apr 2014 01:27:01 +0000 (04:27 +0300)
defines used as keys for internal hash tables are now replaced by
functions giving access to the internal data.

src/lib/eolian/Eolian.h
src/lib/eolian/eo_lexer.c
src/lib/eolian/eo_lexer.rl
src/lib/eolian/eolian_database.c
src/lib/eolian/eolian_database.h

index 49749a8..45bdd25 100644 (file)
@@ -74,12 +74,6 @@ typedef struct _Implement_Legacy_Param* Eolian_Implement_Legacy_Parameter;
  */
 typedef struct _Event_Desc* Eolian_Event;
 
-#define EOLIAN_METHOD_RETURN_TYPE "method_return_type"
-#define EOLIAN_PROP_GET_RETURN_TYPE "property_get_return_type"
-#define EOLIAN_PROP_SET_RETURN_TYPE "property_set_return_type"
-#define EOLIAN_RETURN_COMMENT "method_return_comment"
-#define EOLIAN_PROP_GET_RETURN_COMMENT "property_get_return_comment"
-#define EOLIAN_PROP_SET_RETURN_COMMENT "property_set_return_comment"
 #define EOLIAN_LEGACY "legacy"
 #define EOLIAN_LEGACY_GET "legacy_get"
 #define EOLIAN_LEGACY_SET "legacy_set"
index 2b407bb..0acce19 100644 (file)
@@ -4369,7 +4369,7 @@ eo_tokenizer_database_fill(const char *filename)
           {
              Eolian_Function foo_id = database_function_new(meth->name, EOLIAN_CTOR);
              database_class_function_add(kls->name, foo_id);
-             if (meth->ret) database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret->comment);
+             if (meth->ret) database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment);
              database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy);
              EINA_LIST_FOREACH(meth->params, m, param)
                {
@@ -4381,7 +4381,7 @@ eo_tokenizer_database_fill(const char *filename)
           {
              Eolian_Function foo_id = database_function_new(meth->name, EOLIAN_DTOR);
              database_class_function_add(kls->name, foo_id);
-             if (meth->ret) database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret->comment);
+             if (meth->ret) database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment);
              database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy);
              EINA_LIST_FOREACH(meth->params, m, param)
                {
@@ -4411,17 +4411,18 @@ eo_tokenizer_database_fill(const char *filename)
                   database_function_type_set(foo_id, (accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET));
                   if (accessor->ret && accessor->ret->type)
                     {
+                       Eolian_Function_Type ftype =
+                          accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET;
                        database_function_return_type_set(foo_id,
-                             accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->type);
-                       database_function_data_set(foo_id,
-                             (accessor->type == SETTER?EOLIAN_PROP_SET_RETURN_COMMENT:EOLIAN_PROP_GET_RETURN_COMMENT),
-                             accessor->ret->comment);
+                             ftype, accessor->ret->type);
+                       database_function_return_comment_set(foo_id,
+                             ftype, accessor->ret->comment);
                        database_function_return_flag_set_as_warn_unused(foo_id,
-                             accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->warn_unused);
+                             ftype, accessor->ret->warn_unused);
                        database_function_return_flag_set_own(foo_id,
-                             accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->own);
+                             ftype, accessor->ret->own);
                        database_function_return_dflt_val_set(foo_id,
-                             accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->dflt_ret_val);
+                             ftype, accessor->ret->dflt_ret_val);
                     }
                   if (accessor->legacy)
                     {
@@ -4457,8 +4458,8 @@ eo_tokenizer_database_fill(const char *filename)
              database_class_function_add(kls->name, foo_id);
              if (meth->ret)
                {
-                  database_function_data_set(foo_id, EOLIAN_METHOD_RETURN_TYPE, meth->ret->type);
-                  database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret->comment);
+                  database_function_return_type_set(foo_id, EOLIAN_METHOD, meth->ret->type);
+                  database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment);
                   database_function_return_flag_set_as_warn_unused(foo_id,
                         EOLIAN_METHOD, meth->ret->warn_unused);
                   database_function_return_flag_set_own(foo_id, EOLIAN_METHOD, meth->ret->own);
index 5a26226..a4f6c36 100644 (file)
@@ -1351,7 +1351,7 @@ eo_tokenizer_database_fill(const char *filename)
           {
              Eolian_Function foo_id = database_function_new(meth->name, EOLIAN_CTOR);
              database_class_function_add(kls->name, foo_id);
-             if (meth->ret) database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret->comment);
+             if (meth->ret) database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment);
              database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy);
              EINA_LIST_FOREACH(meth->params, m, param)
                {
@@ -1363,7 +1363,7 @@ eo_tokenizer_database_fill(const char *filename)
           {
              Eolian_Function foo_id = database_function_new(meth->name, EOLIAN_DTOR);
              database_class_function_add(kls->name, foo_id);
-             if (meth->ret) database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret->comment);
+             if (meth->ret) database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment);
              database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy);
              EINA_LIST_FOREACH(meth->params, m, param)
                {
@@ -1393,17 +1393,18 @@ eo_tokenizer_database_fill(const char *filename)
                   database_function_type_set(foo_id, (accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET));
                   if (accessor->ret && accessor->ret->type)
                     {
+                       Eolian_Function_Type ftype =
+                          accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET;
                        database_function_return_type_set(foo_id,
-                             accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->type);
-                       database_function_data_set(foo_id,
-                             (accessor->type == SETTER?EOLIAN_PROP_SET_RETURN_COMMENT:EOLIAN_PROP_GET_RETURN_COMMENT),
-                             accessor->ret->comment);
+                             ftype, accessor->ret->type);
+                       database_function_return_comment_set(foo_id,
+                             ftype, accessor->ret->comment);
                        database_function_return_flag_set_as_warn_unused(foo_id,
-                             accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->warn_unused);
+                             ftype, accessor->ret->warn_unused);
                        database_function_return_flag_set_own(foo_id,
-                             accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->own);
+                             ftype, accessor->ret->own);
                        database_function_return_dflt_val_set(foo_id,
-                             accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET, accessor->ret->dflt_ret_val);
+                             ftype, accessor->ret->dflt_ret_val);
                     }
                   if (accessor->legacy)
                     {
@@ -1439,8 +1440,8 @@ eo_tokenizer_database_fill(const char *filename)
              database_class_function_add(kls->name, foo_id);
              if (meth->ret)
                {
-                  database_function_data_set(foo_id, EOLIAN_METHOD_RETURN_TYPE, meth->ret->type);
-                  database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret->comment);
+                  database_function_return_type_set(foo_id, EOLIAN_METHOD, meth->ret->type);
+                  database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment);
                   database_function_return_flag_set_as_warn_unused(foo_id,
                         EOLIAN_METHOD, meth->ret->warn_unused);
                   database_function_return_flag_set_own(foo_id, EOLIAN_METHOD, meth->ret->own);
index 392dd65..1dcebcb 100644 (file)
@@ -5,6 +5,14 @@
 #define PROP_SET_RETURN_DFLT_VAL "property_set_return_dflt_val"
 #define METHOD_RETURN_DFLT_VAL "method_return_dflt_val"
 
+#define EOLIAN_METHOD_RETURN_TYPE "method_return_type"
+#define EOLIAN_PROP_GET_RETURN_TYPE "property_get_return_type"
+#define EOLIAN_PROP_SET_RETURN_TYPE "property_set_return_type"
+
+#define EOLIAN_METHOD_RETURN_COMMENT "method_return_comment"
+#define EOLIAN_PROP_GET_RETURN_COMMENT "property_get_return_comment"
+#define EOLIAN_PROP_SET_RETURN_COMMENT "property_set_return_comment"
+
 static Eina_Hash *_classes = NULL;
 static int _database_init_count = 0;
 
@@ -907,12 +915,25 @@ eolian_function_return_comment_get(Eolian_Function foo_id, Eolian_Function_Type
      {
       case EOLIAN_PROP_SET: key = EOLIAN_PROP_SET_RETURN_COMMENT; break;
       case EOLIAN_PROP_GET: key = EOLIAN_PROP_GET_RETURN_COMMENT; break;
-      case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: key = EOLIAN_RETURN_COMMENT; break;
+      case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: key = EOLIAN_METHOD_RETURN_COMMENT; break;
       default: return NULL;
      }
    return eolian_function_data_get(foo_id, key);
 }
 
+void database_function_return_comment_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_comment)
+{
+   const char *key = NULL;
+   switch (ftype)
+     {
+      case EOLIAN_PROP_SET: key = EOLIAN_PROP_SET_RETURN_COMMENT; break;
+      case EOLIAN_PROP_GET: key = EOLIAN_PROP_GET_RETURN_COMMENT; break;
+      case EOLIAN_METHOD: key = EOLIAN_METHOD_RETURN_COMMENT; break;
+      default: return;
+     }
+   database_function_data_set(foo_id, key, ret_comment);
+}
+
 void database_function_return_flag_set_as_warn_unused(Eolian_Function foo_id,
       Eolian_Function_Type ftype, Eina_Bool warn_unused)
 {
@@ -1125,7 +1146,7 @@ static Eina_Bool _function_print(const _Function_Id *fid, int nb_spaces)
 {
    Eolian_Function foo_id = (Eolian_Function) fid;
    EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
-   const char *ret_desc = eolian_function_description_get(foo_id, EOLIAN_RETURN_COMMENT);
+   const char *ret_desc = eolian_function_return_comment_get(foo_id, fid->type);
    switch (fid->type)
      {
       case EOLIAN_PROPERTY:
index 5a22588..30e15b4 100644 (file)
@@ -94,6 +94,8 @@ void database_parameter_own_set(Eolian_Function_Parameter, Eina_Bool own);
 
 void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_type);
 
+void database_function_return_comment_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_comment);
+
 void database_function_return_dflt_val_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_dflt_value);
 
 void database_function_return_flag_set_as_warn_unused(Eolian_Function foo_id,