eolian: APIs to check auto/empty on a function
authorDaniel Kolesa <d.kolesa@samsung.com>
Wed, 3 Sep 2014 13:25:50 +0000 (14:25 +0100)
committerDaniel Kolesa <d.kolesa@samsung.com>
Wed, 3 Sep 2014 13:26:09 +0000 (14:26 +0100)
src/lib/eolian/Eolian.h
src/lib/eolian/database_fill.c
src/lib/eolian/database_function_api.c
src/lib/eolian/eolian_database.h

index c05e14a37cce1a77d2d19f7ea8e281624356253b..047a1b07c95931ecef6cfe3949d92c899c681dd8 100644 (file)
@@ -734,6 +734,28 @@ EAPI Eina_Stringshare *eolian_function_description_get(const Eolian_Function *fu
  */
 EAPI Eina_Bool eolian_function_is_virtual_pure(const Eolian_Function *function_id, Eolian_Function_Type f_type);
 
+/*
+ * @brief Indicates if a function is auto.
+ *
+ * @param[in] function_id Id of the function
+ * @param[in] f_type The function type, for property get/set distinction.
+ * @return EINA_TRUE if auto, EINA_FALSE othrewise.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Bool eolian_function_is_auto(const Eolian_Function *function_id, Eolian_Function_Type f_type);
+
+/*
+ * @brief Indicates if a function is empty.
+ *
+ * @param[in] function_id Id of the function
+ * @param[in] f_type The function type, for property get/set distinction.
+ * @return EINA_TRUE if empty, EINA_FALSE othrewise.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Bool eolian_function_is_empty(const Eolian_Function *function_id, Eolian_Function_Type f_type);
+
 /*
  * @brief Indicates if a function is legacy only.
  *
index 78e6d5f2fdf7a48d7cf6c319bd3c57512c62de6f..e4b1438ca9e33b3383b810a79947b6a5bc6c8c8b 100644 (file)
@@ -224,31 +224,34 @@ _db_fill_methods(Eolian_Class *cl, Eo_Class_Def *kls)
    return EINA_TRUE;
 }
 
+static int
+_func_error(Eolian_Class *cl, Eolian_Implement *impl)
+{
+   ERR("Error - %s%s not known in class %s", impl->full_name,
+       eolian_class_name_get(cl), (impl->is_prop_get ? ".get"
+              : (impl->is_prop_set ? ".set" : "")));
+   return -1;
+}
+
 static int
 _db_fill_implement(Eolian_Class *cl, Eolian_Implement *impl)
 {
    const char *impl_name = impl->full_name;
 
-   if (impl->is_virtual)
-     {
-        Eolian_Function_Type ftype = EOLIAN_UNRESOLVED;
+   Eolian_Function_Type ftype = EOLIAN_UNRESOLVED;
 
-        if (impl->is_prop_get)
-          ftype = EOLIAN_PROP_GET;
-        else if (impl->is_prop_set)
-          ftype = EOLIAN_PROP_SET;
+   if (impl->is_prop_get)
+     ftype = EOLIAN_PROP_GET;
+   else if (impl->is_prop_set)
+     ftype = EOLIAN_PROP_SET;
 
+   if (impl->is_virtual)
+     {
         Eolian_Function *foo_id = (Eolian_Function*)
                                    eolian_class_function_get_by_name(cl,
                                                                      impl_name,
                                                                      ftype);
-        if (!foo_id)
-          {
-             ERR("Error - %s%s not known in class %s", impl_name,
-                 eolian_class_name_get(cl), (impl->is_prop_get ? ".get"
-                        : (impl->is_prop_set ? ".set" : "")));
-             return -1;
-          }
+        if (!foo_id) return _func_error(cl, impl);
 
         if (impl->is_prop_set)
           foo_id->set_virtual_pure = EINA_TRUE;
@@ -257,6 +260,34 @@ _db_fill_implement(Eolian_Class *cl, Eolian_Implement *impl)
 
         return 1;
      }
+   else if (impl->is_auto)
+     {
+        const char *inm = impl_name;
+        if (inm[0] == '.') ++inm;
+        if (strchr(inm, '.')) goto pasttags;
+        Eolian_Function *foo_id = (Eolian_Function*)
+                                   eolian_class_function_get_by_name(cl, inm,
+                                                                     ftype);
+        if (!foo_id) return _func_error(cl, impl);
+        if (impl->is_auto)
+          foo_id->set_auto = EINA_TRUE;
+        else
+          foo_id->get_auto = EINA_TRUE;
+     }
+   else if (impl->is_empty)
+     {
+        const char *inm = impl_name;
+        if (inm[0] == '.') ++inm;
+        if (strchr(inm, '.')) goto pasttags;
+        Eolian_Function *foo_id = (Eolian_Function*)
+                                   eolian_class_function_get_by_name(cl, inm,
+                                                                     ftype);
+        if (!foo_id) return _func_error(cl, impl);
+        if (impl->is_auto)
+          foo_id->set_empty = EINA_TRUE;
+        else
+          foo_id->get_empty = EINA_TRUE;
+     }
    else if (impl->is_class_ctor)
      {
         cl->class_ctor_enable = EINA_TRUE;
@@ -268,6 +299,7 @@ _db_fill_implement(Eolian_Class *cl, Eolian_Implement *impl)
         return 1;
      }
 
+pasttags:
    if (impl_name[0] == '.')
      {
         impl->full_name = eina_stringshare_printf("%s%s", cl->full_name,
index d467eaf23739d1de0e921e1e72ef16cdda8c1b97..7a253535b0e030d429aa95bc7a5a0a81f476038a 100644 (file)
@@ -92,6 +92,30 @@ eolian_function_is_virtual_pure(const Eolian_Function *fid, Eolian_Function_Type
      }
 }
 
+EAPI Eina_Bool
+eolian_function_is_auto(const Eolian_Function *fid, Eolian_Function_Type ftype)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
+   switch (ftype)
+     {
+      case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROPERTY: case EOLIAN_PROP_GET: return fid->get_auto; break;
+      case EOLIAN_PROP_SET: return fid->set_auto; break;
+      default: return EINA_FALSE;
+     }
+}
+
+EAPI Eina_Bool
+eolian_function_is_empty(const Eolian_Function *fid, Eolian_Function_Type ftype)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
+   switch (ftype)
+     {
+      case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROPERTY: case EOLIAN_PROP_GET: return fid->get_empty; break;
+      case EOLIAN_PROP_SET: return fid->set_empty; break;
+      default: return EINA_FALSE;
+     }
+}
+
 EAPI Eina_Bool
 eolian_function_is_legacy_only(const Eolian_Function *fid, Eolian_Function_Type ftype)
 {
index 46276b39881a7db50cac285360a8495ad7aed88c..e5cbcfe0d6ad92340c0c320970249a3cccc0bdb9 100644 (file)
@@ -106,6 +106,10 @@ struct _Eolian_Function
    Eina_Bool obj_is_const :1; /* True if the object has to be const. Useful for a few methods. */
    Eina_Bool get_virtual_pure :1;
    Eina_Bool set_virtual_pure :1;
+   Eina_Bool get_auto :1;
+   Eina_Bool set_auto :1;
+   Eina_Bool get_empty :1;
+   Eina_Bool set_empty :1;
    Eina_Bool get_return_warn_unused :1; /* also used for methods */
    Eina_Bool set_return_warn_unused :1;
    Eina_Bool get_only_legacy: 1;