summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-07-03 15:03:59 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2019-07-08 16:06:42 +0200
commit2bfa55582cb2286dced2b97be6b80d96ae8f5a91 (patch)
tree899f1d8868cbee7dcc1bb25eced367635d770112
parent38223ed693b8ab1f48d6fc0180056bbe3f608a32 (diff)
eolian: remove builtin freefuncs
For now this does not alter API behavior, so freefuncs are still transitive to aliases etc., this will get removed later.
-rw-r--r--src/lib/eolian/database_validate.c63
-rw-r--r--src/lib/eolian/eo_parser.c10
-rw-r--r--src/lib/eolian/eolian_database.h2
3 files changed, 33 insertions, 42 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index c7254ed220..7e73347f2d 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -167,6 +167,8 @@ _validate_typedecl(Validate_State *vals, Eolian_Typedecl *tp)
167 return _reset_stable(vals, was_stable, EINA_FALSE); 167 return _reset_stable(vals, was_stable, EINA_FALSE);
168 if (!tp->freefunc && tp->base_type->freefunc) 168 if (!tp->freefunc && tp->base_type->freefunc)
169 tp->freefunc = eina_stringshare_ref(tp->base_type->freefunc); 169 tp->freefunc = eina_stringshare_ref(tp->base_type->freefunc);
170 if (tp->base_type->ownable)
171 tp->ownable = EINA_TRUE;
170 _reset_stable(vals, was_stable, EINA_TRUE); 172 _reset_stable(vals, was_stable, EINA_TRUE);
171 return _validate(&tp->base); 173 return _validate(&tp->base);
172 case EOLIAN_TYPEDECL_STRUCT: 174 case EOLIAN_TYPEDECL_STRUCT:
@@ -203,25 +205,12 @@ _validate_typedecl(Validate_State *vals, Eolian_Typedecl *tp)
203 return EINA_FALSE; 205 return EINA_FALSE;
204} 206}
205 207
206static const char * const eo_complex_frees[] =
207{
208 "eina_accessor_free", "eina_array_free", "(void)", /* future */
209 "eina_iterator_free", "eina_hash_free",
210 "eina_list_free"
211};
212
213static const char *eo_obj_free = "efl_del";
214static const char *eo_str_free = "free";
215static const char *eo_strshare_free = "eina_stringshare_del";
216static const char *eo_value_free = "eina_value_flush";
217static const char *eo_value_ptr_free = "eina_value_free";
218
219static Eina_Bool 208static Eina_Bool
220_validate_ownable(Eolian_Type *tp) 209_validate_ownable(Eolian_Type *tp)
221{ 210{
222 if (tp->btype == EOLIAN_TYPE_BUILTIN_FUTURE) 211 if (tp->btype == EOLIAN_TYPE_BUILTIN_FUTURE)
223 return EINA_TRUE; 212 return EINA_TRUE;
224 if (tp->owned && !tp->freefunc) 213 if (tp->owned && !tp->ownable)
225 { 214 {
226 _eo_parser_log(&tp->base, "type '%s' is not ownable", tp->base.name); 215 _eo_parser_log(&tp->base, "type '%s' is not ownable", tp->base.name);
227 return EINA_FALSE; 216 return EINA_FALSE;
@@ -262,13 +251,10 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
262 if (tp->base_type) 251 if (tp->base_type)
263 { 252 {
264 int kwid = eo_lexer_keyword_str_to_id(tp->base.name); 253 int kwid = eo_lexer_keyword_str_to_id(tp->base.name);
265 if (!tp->freefunc && kwid > KW_void) 254 if (kwid > KW_void)
266 { 255 tp->ownable = EINA_TRUE;
267 tp->freefunc = eina_stringshare_add(eo_complex_frees[
268 kwid - KW_accessor]);
269 }
270 Eolian_Type *itp = tp->base_type; 256 Eolian_Type *itp = tp->base_type;
271 /* validate types in brackets so freefuncs get written... */ 257 /* validate types in brackets so transitive fields get written */
272 while (itp) 258 while (itp)
273 { 259 {
274 if (!_validate_type(vals, itp)) 260 if (!_validate_type(vals, itp))
@@ -293,24 +279,20 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
293 { 279 {
294 if (!eo_lexer_is_type_keyword(id)) 280 if (!eo_lexer_is_type_keyword(id))
295 return EINA_FALSE; 281 return EINA_FALSE;
296 if (!tp->freefunc) 282 switch (id)
297 switch (id) 283 {
298 { 284 case KW_mstring:
299 case KW_mstring: 285 case KW_stringshare:
300 tp->freefunc = eina_stringshare_add(eo_str_free); 286 case KW_any_value:
301 break; 287 case KW_any_value_ptr:
302 case KW_stringshare: 288 tp->ownable = EINA_TRUE;
303 tp->freefunc = eina_stringshare_add(eo_strshare_free); 289 break;
304 break; 290 default:
305 case KW_any_value: 291 break;
306 tp->freefunc = eina_stringshare_add(eo_value_free); 292 }
307 break; 293 /* FIXME: remove this after c++/c# has fixed their stuff */
308 case KW_any_value_ptr: 294 if (tp->freefunc)
309 tp->freefunc = eina_stringshare_add(eo_value_ptr_free); 295 tp->ownable = EINA_TRUE;
310 break;
311 default:
312 break;
313 }
314 return _validate_ownable(tp); 296 return _validate_ownable(tp);
315 } 297 }
316 /* user defined */ 298 /* user defined */
@@ -331,6 +313,8 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
331 return EINA_FALSE; 313 return EINA_FALSE;
332 if (tp->tdecl->freefunc && !tp->freefunc) 314 if (tp->tdecl->freefunc && !tp->freefunc)
333 tp->freefunc = eina_stringshare_ref(tp->tdecl->freefunc); 315 tp->freefunc = eina_stringshare_ref(tp->tdecl->freefunc);
316 if (tp->tdecl->ownable || tp->freefunc)
317 tp->ownable = EINA_TRUE;
334 tp->base.c_name = eina_stringshare_ref(tp->tdecl->base.c_name); 318 tp->base.c_name = eina_stringshare_ref(tp->tdecl->base.c_name);
335 return _validate_ownable(tp); 319 return _validate_ownable(tp);
336 } 320 }
@@ -349,8 +333,7 @@ _validate_type(Validate_State *vals, Eolian_Type *tp)
349 tp->klass->base.name); 333 tp->klass->base.name);
350 return EINA_FALSE; 334 return EINA_FALSE;
351 } 335 }
352 if (!tp->freefunc) 336 tp->ownable = EINA_TRUE;
353 tp->freefunc = eina_stringshare_add(eo_obj_free);
354 tp->base.c_name = eina_stringshare_ref(tp->klass->base.c_name); 337 tp->base.c_name = eina_stringshare_ref(tp->klass->base.c_name);
355 return _validate_ownable(tp); 338 return _validate_ownable(tp);
356 } 339 }
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 6b5d920409..90920924b0 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -475,7 +475,10 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
475 def->type = EOLIAN_TYPEDECL_STRUCT; 475 def->type = EOLIAN_TYPEDECL_STRUCT;
476 def->fields = eina_hash_string_small_new(EINA_FREE_CB(_struct_field_free)); 476 def->fields = eina_hash_string_small_new(EINA_FREE_CB(_struct_field_free));
477 if (freefunc) 477 if (freefunc)
478 def->freefunc = eina_stringshare_ref(freefunc); 478 {
479 def->freefunc = eina_stringshare_ref(freefunc);
480 def->ownable = EINA_TRUE;
481 }
479 if (cname) 482 if (cname)
480 { 483 {
481 def->base.c_name = cname; 484 def->base.c_name = cname;
@@ -2449,7 +2452,10 @@ postparams:
2449 def->base.is_beta = has_beta; 2452 def->base.is_beta = has_beta;
2450 def->type = EOLIAN_TYPEDECL_STRUCT_OPAQUE; 2453 def->type = EOLIAN_TYPEDECL_STRUCT_OPAQUE;
2451 if (freefunc) 2454 if (freefunc)
2452 def->freefunc = eina_stringshare_ref(freefunc); 2455 {
2456 def->freefunc = eina_stringshare_ref(freefunc);
2457 def->ownable = EINA_TRUE;
2458 }
2453 def->base.name = name; 2459 def->base.name = name;
2454 if (cname) 2460 if (cname)
2455 def->base.c_name = cname; 2461 def->base.c_name = cname;
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 950e4114d4..d1902655d1 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -274,6 +274,7 @@ struct _Eolian_Type
274 Eina_Bool is_const :1; 274 Eina_Bool is_const :1;
275 Eina_Bool is_ptr :1; 275 Eina_Bool is_ptr :1;
276 Eina_Bool owned :1; 276 Eina_Bool owned :1;
277 Eina_Bool ownable :1;
277}; 278};
278 279
279struct _Eolian_Typedecl 280struct _Eolian_Typedecl
@@ -288,6 +289,7 @@ struct _Eolian_Typedecl
288 Eina_Stringshare *legacy; 289 Eina_Stringshare *legacy;
289 Eina_Stringshare *freefunc; 290 Eina_Stringshare *freefunc;
290 Eina_Bool is_extern :1; 291 Eina_Bool is_extern :1;
292 Eina_Bool ownable :1;
291}; 293};
292 294
293struct _Eolian_Implement 295struct _Eolian_Implement