summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-01-29 19:36:46 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2019-02-28 01:09:02 +0100
commit765f16410c136b9b92b5069bf35ac943a437d814 (patch)
tree44b64ec334f4158b9cd35e44961dfd3961283903
parent70e8e86cc74efe610bda99c4bad0cee577a35272 (diff)
eolian: remove free function builtins and rework ownability checks
Eolian will not provide any builtin free functions anymore, with the exception of mstring for which it defaults to 'free'.
-rw-r--r--src/lib/eolian/database_validate.c87
1 files changed, 32 insertions, 55 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 339f1baf08..bb2abe79ab 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -218,32 +218,6 @@ _validate_typedecl(Validate_State *vals, Eolian_Typedecl *tp)
218 return _validate(&tp->base); 218 return _validate(&tp->base);
219} 219}
220 220
221static const char * const eo_complex_frees[] =
222{
223 "eina_accessor_free", "eina_array_free", "(void)", /* future */
224 "eina_iterator_free", "eina_hash_free",
225 "eina_list_free", "eina_inarray_free", "(void)"
226};
227
228static const char *eo_obj_free = "efl_del";
229static const char *eo_str_free = "free";
230static const char *eo_strshare_free = "eina_stringshare_del";
231static const char *eo_value_free = "eina_value_flush";
232static const char *eo_value_ptr_free = "eina_value_free";
233
234static Eina_Bool
235_validate_ownable(Eolian_Type *tp)
236{
237 if (tp->btype == EOLIAN_TYPE_BUILTIN_FUTURE)
238 return EINA_TRUE;
239 if (tp->owned && !tp->freefunc)
240 {
241 _eo_parser_log(&tp->base, "type '%s' is not ownable", tp->base.name);
242 return EINA_FALSE;
243 }
244 return _validate(&tp->base);
245}
246
247static Eina_Bool 221static Eina_Bool
248_validate_type(Validate_State *vals, Eolian_Type *tp) 222_validate_type(Validate_State *vals, Eolian_Type *tp)
249{ 223{
@@ -271,7 +245,7 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
271 { 245 {
272 case EOLIAN_TYPE_VOID: 246 case EOLIAN_TYPE_VOID:
273 case EOLIAN_TYPE_UNDEFINED: 247 case EOLIAN_TYPE_UNDEFINED:
274 return _validate_ownable(tp); 248 return _validate(&tp->base);
275 case EOLIAN_TYPE_REGULAR: 249 case EOLIAN_TYPE_REGULAR:
276 { 250 {
277 if (tp->base_type) 251 if (tp->base_type)
@@ -288,7 +262,7 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
288 } 262 }
289 if (!_validate_type(vals, tp->base_type)) 263 if (!_validate_type(vals, tp->base_type))
290 return EINA_FALSE; 264 return EINA_FALSE;
291 return _validate_ownable(tp); 265 return _validate(&tp->base);
292 } 266 }
293 else if (kwid == KW_inlist) 267 else if (kwid == KW_inlist)
294 { 268 {
@@ -314,7 +288,12 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
314 if (!tp->freefunc && kwid > KW_void) 288 if (!tp->freefunc && kwid > KW_void)
315 { 289 {
316 tp->freefunc = eina_stringshare_add(eo_complex_frees[ 290 tp->freefunc = eina_stringshare_add(eo_complex_frees[
317 kwid - KW_accessor]); 291 if (!tp->freefunc)
292 {
293 _eo_parser_log(&tp->base, "inlists must have a free function");
294 return EINA_FALSE;
295 }
296 return _validate(&tp->base);
318 } 297 }
319 Eolian_Type *itp = tp->base_type; 298 Eolian_Type *itp = tp->base_type;
320 /* validate types in brackets so freefuncs get written... */ 299 /* validate types in brackets so freefuncs get written... */
@@ -334,33 +313,17 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
334 } 313 }
335 itp = itp->next_type; 314 itp = itp->next_type;
336 } 315 }
337 return _validate_ownable(tp); 316 return _validate(&tp->base);
338 } 317 }
339 /* builtins */ 318 /* builtins */
340 int id = eo_lexer_keyword_str_to_id(tp->base.name); 319 int id = eo_lexer_keyword_str_to_id(tp->base.name);
341 if (id) 320 if (id)
342 { 321 {
343 if (!eo_lexer_is_type_keyword(id)) 322 if (!eo_lexer_is_type_keyword(id))
344 return EINA_FALSE; 323 return EINA_FALSE;;
345 if (!tp->freefunc) 324 if (!tp->freefunc && (id == KW_mstring))
346 switch (id) 325 tp->freefunc = eina_stringshare_add("free");
347 { 326 return _validate(&tp->base);
348 case KW_mstring:
349 tp->freefunc = eina_stringshare_add(eo_str_free);
350 break;
351 case KW_stringshare:
352 tp->freefunc = eina_stringshare_add(eo_strshare_free);
353 break;
354 case KW_any_value:
355 tp->freefunc = eina_stringshare_add(eo_value_free);
356 break;
357 case KW_any_value_ptr:
358 tp->freefunc = eina_stringshare_add(eo_value_ptr_free);
359 break;
360 default:
361 break;
362 }
363 return _validate_ownable(tp);
364 } 327 }
365 /* user defined */ 328 /* user defined */
366 tp->tdecl = database_type_decl_find(src, tp); 329 tp->tdecl = database_type_decl_find(src, tp);
@@ -373,7 +336,23 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
373 return EINA_FALSE; 336 return EINA_FALSE;
374 if (tp->tdecl->freefunc && !tp->freefunc) 337 if (tp->tdecl->freefunc && !tp->freefunc)
375 tp->freefunc = eina_stringshare_ref(tp->tdecl->freefunc); 338 tp->freefunc = eina_stringshare_ref(tp->tdecl->freefunc);
376 return _validate_ownable(tp); 339
340 /* to leave out slow checks if possible */
341 if (!tp->owned)
342 return _validate(&tp->base);
343
344 /* builtins are not required to have freefuncs, and
345 * potential ownability has already been validated before
346 */
347 if (eolian_type_aliased_base_get(tp)->btype)
348 return _validate(&tp->base);
349
350 if (!tp->freefunc)
351 {
352 _eo_parser_log(&tp->base, "type '%s' is not ownable", tp->base.name);
353 return EINA_FALSE;
354 }
355 return _validate(&tp->base);
377 } 356 }
378 case EOLIAN_TYPE_CLASS: 357 case EOLIAN_TYPE_CLASS:
379 { 358 {
@@ -384,14 +363,12 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
384 "(likely wrong namespacing)", tp->base.name); 363 "(likely wrong namespacing)", tp->base.name);
385 return EINA_FALSE; 364 return EINA_FALSE;
386 } 365 }
387 if (!tp->freefunc) 366 return _validate(&tp->base);
388 tp->freefunc = eina_stringshare_add(eo_obj_free);
389 return _validate_ownable(tp);
390 } 367 }
391 default: 368 default:
392 return EINA_FALSE; 369 return EINA_FALSE;
393 } 370 }
394 return _validate_ownable(tp); 371 return _validate(&tp->base);
395} 372}
396 373
397static Eina_Bool 374static Eina_Bool