eolian: include terminatable checks in ownable check
authorDaniel Kolesa <d.kolesa@osg.samsung.com>
Wed, 13 Sep 2017 22:28:32 +0000 (00:28 +0200)
committerDaniel Kolesa <d.kolesa@osg.samsung.com>
Wed, 13 Sep 2017 22:28:32 +0000 (00:28 +0200)
src/lib/eolian/database_type.c
src/lib/eolian/database_validate.c
src/lib/eolian/eolian_database.h

index ddff419fae33a58d1a0fbb3b543df6ba86d5f900..df7cbae83b65546ad9057bd2e5095c52a5e5f871 100644 (file)
@@ -80,13 +80,16 @@ static const Eina_Bool _ownable_types[] = {
 };
 
 Eina_Bool
-database_type_is_ownable(const Eolian_Type *tp)
+database_type_is_ownable(const Eolian_Type *tp, Eina_Bool term)
 {
    if (tp->is_ptr)
      return EINA_TRUE;
    if (tp->type == EOLIAN_TYPE_REGULAR)
      {
         int kwid = eo_lexer_keyword_str_to_id(tp->name);
+        /* don't include bool, it only has 2 values so it's useless */
+        if (term && (kwid >= KW_byte && kwid < KW_bool))
+          return EINA_TRUE;
         const char *ct = eo_lexer_get_c_type(kwid);
         if (!ct)
           return EINA_FALSE;
@@ -117,7 +120,7 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
    if ((tp->type == EOLIAN_TYPE_REGULAR
      || tp->type == EOLIAN_TYPE_VOID)
      && tp->is_const
-     && ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(tp)))
+     && ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(tp, EINA_FALSE)))
      {
         eina_strbuf_append(buf, "const ");
      }
index f8eb7fad735fef7f2f7e01aaf124040f04164a76..87d3202b8973f69bca408a73bf9870027ea6871f 100644 (file)
@@ -131,26 +131,12 @@ _validate_typedecl(Eolian_Typedecl *tp)
    return EINA_TRUE;
 }
 
-static Eina_Bool
-_type_is_terminatable(const Eolian_Type *tp)
-{
-   if (database_type_is_ownable(tp))
-     return EINA_TRUE;
-   if (tp->type == EOLIAN_TYPE_REGULAR)
-     {
-        int kwid = eo_lexer_keyword_str_to_id(tp->name);
-        /* don't include bool, it only has 2 values so it's useless */
-        return (kwid >= KW_byte && kwid < KW_bool);
-     }
-   return EINA_FALSE;
-}
-
 static Eina_Bool
 _validate_type(Eolian_Type *tp)
 {
    char buf[256];
 
-   if ((tp->is_own || tp->freefunc) && !database_type_is_ownable(tp))
+   if ((tp->is_own || tp->freefunc) && !database_type_is_ownable(tp, EINA_FALSE))
      {
         snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->full_name);
         return _type_error(tp, buf);
@@ -183,7 +169,7 @@ _validate_type(Eolian_Type *tp)
            return EINA_TRUE;
         }
       case EOLIAN_TYPE_TERMINATED_ARRAY:
-        if (!_type_is_terminatable(tp->base_type))
+        if (!database_type_is_ownable(tp->base_type, EINA_TRUE))
           {
              snprintf(buf, sizeof(buf),
                       "invalid base type '%s' for terminated array",
index 03c9c109ff10097b1b434c7670536d61fa9922b7..261f09cad2206d84152e52cc88676f83af2c8c3b 100644 (file)
@@ -314,7 +314,7 @@ void database_typedecl_del(Eolian_Typedecl *tp);
 void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eolian_C_Type_Type ctype);
 void database_typedecl_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, Eina_Strbuf *buf);
 
-Eina_Bool database_type_is_ownable(const Eolian_Type *tp);
+Eina_Bool database_type_is_ownable(const Eolian_Type *tp, Eina_Bool term);
 
 /* expressions */