summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-09-14 00:28:32 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-09-14 00:28:32 +0200
commit59347d4c4b4f31c6dbb57d3357d80290ac2ab469 (patch)
tree9d682f767e10a1560d907c37c060499de81f8200 /src
parent8ff2bf35fecf62157363f83f2e370394840f3d4f (diff)
eolian: include terminatable checks in ownable check
Diffstat (limited to 'src')
-rw-r--r--src/lib/eolian/database_type.c7
-rw-r--r--src/lib/eolian/database_validate.c18
-rw-r--r--src/lib/eolian/eolian_database.h2
3 files changed, 8 insertions, 19 deletions
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index ddff419fae..df7cbae83b 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -80,13 +80,16 @@ static const Eina_Bool _ownable_types[] = {
80}; 80};
81 81
82Eina_Bool 82Eina_Bool
83database_type_is_ownable(const Eolian_Type *tp) 83database_type_is_ownable(const Eolian_Type *tp, Eina_Bool term)
84{ 84{
85 if (tp->is_ptr) 85 if (tp->is_ptr)
86 return EINA_TRUE; 86 return EINA_TRUE;
87 if (tp->type == EOLIAN_TYPE_REGULAR) 87 if (tp->type == EOLIAN_TYPE_REGULAR)
88 { 88 {
89 int kwid = eo_lexer_keyword_str_to_id(tp->name); 89 int kwid = eo_lexer_keyword_str_to_id(tp->name);
90 /* don't include bool, it only has 2 values so it's useless */
91 if (term && (kwid >= KW_byte && kwid < KW_bool))
92 return EINA_TRUE;
90 const char *ct = eo_lexer_get_c_type(kwid); 93 const char *ct = eo_lexer_get_c_type(kwid);
91 if (!ct) 94 if (!ct)
92 return EINA_FALSE; 95 return EINA_FALSE;
@@ -117,7 +120,7 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
117 if ((tp->type == EOLIAN_TYPE_REGULAR 120 if ((tp->type == EOLIAN_TYPE_REGULAR
118 || tp->type == EOLIAN_TYPE_VOID) 121 || tp->type == EOLIAN_TYPE_VOID)
119 && tp->is_const 122 && tp->is_const
120 && ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(tp))) 123 && ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(tp, EINA_FALSE)))
121 { 124 {
122 eina_strbuf_append(buf, "const "); 125 eina_strbuf_append(buf, "const ");
123 } 126 }
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index f8eb7fad73..87d3202b89 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -132,25 +132,11 @@ _validate_typedecl(Eolian_Typedecl *tp)
132} 132}
133 133
134static Eina_Bool 134static Eina_Bool
135_type_is_terminatable(const Eolian_Type *tp)
136{
137 if (database_type_is_ownable(tp))
138 return EINA_TRUE;
139 if (tp->type == EOLIAN_TYPE_REGULAR)
140 {
141 int kwid = eo_lexer_keyword_str_to_id(tp->name);
142 /* don't include bool, it only has 2 values so it's useless */
143 return (kwid >= KW_byte && kwid < KW_bool);
144 }
145 return EINA_FALSE;
146}
147
148static Eina_Bool
149_validate_type(Eolian_Type *tp) 135_validate_type(Eolian_Type *tp)
150{ 136{
151 char buf[256]; 137 char buf[256];
152 138
153 if ((tp->is_own || tp->freefunc) && !database_type_is_ownable(tp)) 139 if ((tp->is_own || tp->freefunc) && !database_type_is_ownable(tp, EINA_FALSE))
154 { 140 {
155 snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->full_name); 141 snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->full_name);
156 return _type_error(tp, buf); 142 return _type_error(tp, buf);
@@ -183,7 +169,7 @@ _validate_type(Eolian_Type *tp)
183 return EINA_TRUE; 169 return EINA_TRUE;
184 } 170 }
185 case EOLIAN_TYPE_TERMINATED_ARRAY: 171 case EOLIAN_TYPE_TERMINATED_ARRAY:
186 if (!_type_is_terminatable(tp->base_type)) 172 if (!database_type_is_ownable(tp->base_type, EINA_TRUE))
187 { 173 {
188 snprintf(buf, sizeof(buf), 174 snprintf(buf, sizeof(buf),
189 "invalid base type '%s' for terminated array", 175 "invalid base type '%s' for terminated array",
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 03c9c109ff..261f09cad2 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -314,7 +314,7 @@ void database_typedecl_del(Eolian_Typedecl *tp);
314void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eolian_C_Type_Type ctype); 314void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eolian_C_Type_Type ctype);
315void database_typedecl_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, Eina_Strbuf *buf); 315void database_typedecl_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, Eina_Strbuf *buf);
316 316
317Eina_Bool database_type_is_ownable(const Eolian_Type *tp); 317Eina_Bool database_type_is_ownable(const Eolian_Type *tp, Eina_Bool term);
318 318
319/* expressions */ 319/* expressions */
320 320