summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-10-24 17:48:57 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-10-24 17:49:21 +0200
commit903fd9065cce45820503ddb510fc56b3d2db26de (patch)
treea74efa58e4e18880af7fa0dc115090e7226f714c
parenta417af04e86e3974476471867d90637017138403 (diff)
eolian: keep track of which objects are validated
-rw-r--r--src/lib/eolian/database_validate.c109
-rw-r--r--src/lib/eolian/eolian_database.h1
2 files changed, 74 insertions, 36 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 3df9eb65b2..274c563dba 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -7,6 +7,13 @@
7#include "eo_lexer.h" 7#include "eo_lexer.h"
8 8
9static Eina_Bool 9static Eina_Bool
10_validate(Eolian_Object *obj)
11{
12 obj->validated = EINA_TRUE;
13 return EINA_TRUE;
14}
15
16static Eina_Bool
10_validate_docstr(Eina_Stringshare *str, const Eolian_Object *info) 17_validate_docstr(Eina_Stringshare *str, const Eolian_Object *info)
11{ 18{
12 if (!str || !str[0]) return EINA_TRUE; 19 if (!str || !str[0]) return EINA_TRUE;
@@ -38,20 +45,21 @@ _validate_docstr(Eina_Stringshare *str, const Eolian_Object *info)
38} 45}
39 46
40static Eina_Bool 47static Eina_Bool
41_validate_doc(const Eolian_Documentation *doc) 48_validate_doc(Eolian_Documentation *doc)
42{ 49{
43 if (!doc) return EINA_TRUE; 50 if (!doc || doc->base.validated)
51 return EINA_TRUE;
44 52
45 if (!_validate_docstr(doc->summary, &doc->base)) 53 if (!_validate_docstr(doc->summary, &doc->base))
46 return EINA_FALSE; 54 return EINA_FALSE;
47 if (!_validate_docstr(doc->description, &doc->base)) 55 if (!_validate_docstr(doc->description, &doc->base))
48 return EINA_FALSE; 56 return EINA_FALSE;
49 57
50 return EINA_TRUE; 58 return _validate(&doc->base);
51} 59}
52 60
53static Eina_Bool _validate_type(Eolian_Type *tp); 61static Eina_Bool _validate_type(Eolian_Type *tp);
54static Eina_Bool _validate_expr(const Eolian_Expression *expr, 62static Eina_Bool _validate_expr(Eolian_Expression *expr,
55 const Eolian_Type *tp, 63 const Eolian_Type *tp,
56 Eolian_Expression_Mask msk); 64 Eolian_Expression_Mask msk);
57 65
@@ -97,6 +105,9 @@ _type_error(const Eolian_Type *tp, const char *msg)
97static Eina_Bool 105static Eina_Bool
98_validate_typedecl(Eolian_Typedecl *tp) 106_validate_typedecl(Eolian_Typedecl *tp)
99{ 107{
108 if (tp->base.validated)
109 return EINA_TRUE;
110
100 if (!_validate_doc(tp->doc)) 111 if (!_validate_doc(tp->doc))
101 return EINA_FALSE; 112 return EINA_FALSE;
102 113
@@ -107,28 +118,32 @@ _validate_typedecl(Eolian_Typedecl *tp)
107 return EINA_FALSE; 118 return EINA_FALSE;
108 if (!tp->freefunc && tp->base_type->freefunc) 119 if (!tp->freefunc && tp->base_type->freefunc)
109 tp->freefunc = eina_stringshare_ref(tp->base_type->freefunc); 120 tp->freefunc = eina_stringshare_ref(tp->base_type->freefunc);
110 return EINA_TRUE; 121 return _validate(&tp->base);
111 case EOLIAN_TYPEDECL_STRUCT: 122 case EOLIAN_TYPEDECL_STRUCT:
112 { 123 {
113 Eina_Bool succ = EINA_TRUE; 124 Eina_Bool succ = EINA_TRUE;
114 eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_sf_map_cb, &succ); 125 eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_sf_map_cb, &succ);
115 return succ; 126 if (!succ)
127 return EINA_FALSE;
128 return _validate(&tp->base);
116 } 129 }
117 case EOLIAN_TYPEDECL_STRUCT_OPAQUE: 130 case EOLIAN_TYPEDECL_STRUCT_OPAQUE:
118 return EINA_TRUE; 131 return _validate(&tp->base);
119 case EOLIAN_TYPEDECL_ENUM: 132 case EOLIAN_TYPEDECL_ENUM:
120 { 133 {
121 Eina_Bool succ = EINA_TRUE; 134 Eina_Bool succ = EINA_TRUE;
122 eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_ef_map_cb, &succ); 135 eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_ef_map_cb, &succ);
123 return succ; 136 if (!succ)
137 return EINA_FALSE;
138 return _validate(&tp->base);
124 } 139 }
125 case EOLIAN_TYPEDECL_FUNCTION_POINTER: 140 case EOLIAN_TYPEDECL_FUNCTION_POINTER:
126 // FIXME validate functions here 141 // FIXME validate functions here
127 return EINA_TRUE; 142 return _validate(&tp->base);
128 default: 143 default:
129 return EINA_FALSE; 144 return EINA_FALSE;
130 } 145 }
131 return EINA_TRUE; 146 return _validate(&tp->base);
132} 147}
133 148
134static const char * const eo_complex_frees[] = 149static const char * const eo_complex_frees[] =
@@ -150,6 +165,9 @@ _validate_type(Eolian_Type *tp)
150{ 165{
151 char buf[256]; 166 char buf[256];
152 167
168 if (tp->base.validated)
169 return EINA_TRUE;
170
153 if (tp->owned && !database_type_is_ownable(tp)) 171 if (tp->owned && !database_type_is_ownable(tp))
154 { 172 {
155 snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->full_name); 173 snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->full_name);
@@ -160,7 +178,7 @@ _validate_type(Eolian_Type *tp)
160 { 178 {
161 case EOLIAN_TYPE_VOID: 179 case EOLIAN_TYPE_VOID:
162 case EOLIAN_TYPE_UNDEFINED: 180 case EOLIAN_TYPE_UNDEFINED:
163 return EINA_TRUE; 181 return _validate(&tp->base);
164 case EOLIAN_TYPE_REGULAR: 182 case EOLIAN_TYPE_REGULAR:
165 { 183 {
166 if (tp->base_type) 184 if (tp->base_type)
@@ -178,7 +196,7 @@ _validate_type(Eolian_Type *tp)
178 return EINA_FALSE; 196 return EINA_FALSE;
179 itp = itp->next_type; 197 itp = itp->next_type;
180 } 198 }
181 return EINA_TRUE; 199 return _validate(&tp->base);
182 } 200 }
183 Eolian_Typedecl *tpp; 201 Eolian_Typedecl *tpp;
184 /* builtins */ 202 /* builtins */
@@ -205,7 +223,7 @@ _validate_type(Eolian_Type *tp)
205 default: 223 default:
206 break; 224 break;
207 } 225 }
208 return EINA_TRUE; 226 return _validate(&tp->base);
209 } 227 }
210 /* user defined */ 228 /* user defined */
211 tpp = (Eolian_Typedecl *)eolian_type_typedecl_get(tp); 229 tpp = (Eolian_Typedecl *)eolian_type_typedecl_get(tp);
@@ -218,7 +236,7 @@ _validate_type(Eolian_Type *tp)
218 return EINA_FALSE; 236 return EINA_FALSE;
219 if (tpp->freefunc && !tp->freefunc) 237 if (tpp->freefunc && !tp->freefunc)
220 tp->freefunc = eina_stringshare_ref(tpp->freefunc); 238 tp->freefunc = eina_stringshare_ref(tpp->freefunc);
221 return EINA_TRUE; 239 return _validate(&tp->base);
222 } 240 }
223 case EOLIAN_TYPE_CLASS: 241 case EOLIAN_TYPE_CLASS:
224 { 242 {
@@ -231,16 +249,16 @@ _validate_type(Eolian_Type *tp)
231 } 249 }
232 if (!tp->freefunc) 250 if (!tp->freefunc)
233 tp->freefunc = eina_stringshare_add(eo_obj_free); 251 tp->freefunc = eina_stringshare_add(eo_obj_free);
234 return EINA_TRUE; 252 return _validate(&tp->base);
235 } 253 }
236 default: 254 default:
237 return EINA_FALSE; 255 return EINA_FALSE;
238 } 256 }
239 return EINA_TRUE; 257 return _validate(&tp->base);
240} 258}
241 259
242static Eina_Bool 260static Eina_Bool
243_validate_expr(const Eolian_Expression *expr, 261_validate_expr(Eolian_Expression *expr,
244 const Eolian_Type *tp, Eolian_Expression_Mask msk) 262 const Eolian_Type *tp, Eolian_Expression_Mask msk)
245{ 263{
246 Eolian_Value val; 264 Eolian_Value val;
@@ -249,11 +267,15 @@ _validate_expr(const Eolian_Expression *expr,
249 val = eolian_expression_eval_type(NULL, expr, tp); 267 val = eolian_expression_eval_type(NULL, expr, tp);
250 else 268 else
251 val = eolian_expression_eval(NULL, expr, msk); 269 val = eolian_expression_eval(NULL, expr, msk);
252 return (val.type != EOLIAN_EXPR_UNKNOWN); 270
271 if (val.type == EOLIAN_EXPR_UNKNOWN)
272 return EINA_FALSE;
273
274 return _validate(&expr->base);
253} 275}
254 276
255static Eina_Bool 277static Eina_Bool
256_validate_param(const Eolian_Function_Parameter *param) 278_validate_param(Eolian_Function_Parameter *param)
257{ 279{
258 if (!_validate_type(param->type)) 280 if (!_validate_type(param->type))
259 return EINA_FALSE; 281 return EINA_FALSE;
@@ -261,14 +283,17 @@ _validate_param(const Eolian_Function_Parameter *param)
261 if (!_validate_doc(param->doc)) 283 if (!_validate_doc(param->doc))
262 return EINA_FALSE; 284 return EINA_FALSE;
263 285
264 return EINA_TRUE; 286 return _validate(&param->base);
265} 287}
266 288
267static Eina_Bool 289static Eina_Bool
268_validate_function(const Eolian_Function *func) 290_validate_function(Eolian_Function *func)
269{ 291{
270 Eina_List *l; 292 Eina_List *l;
271 const Eolian_Function_Parameter *param; 293 Eolian_Function_Parameter *param;
294
295 if (func->base.validated)
296 return EINA_TRUE;
272 297
273 if (func->get_ret_type && !_validate_type(func->get_ret_type)) 298 if (func->get_ret_type && !_validate_type(func->get_ret_type))
274 return EINA_FALSE; 299 return EINA_FALSE;
@@ -303,24 +328,30 @@ _validate_function(const Eolian_Function *func)
303 if (!_validate_doc(func->set_return_doc)) 328 if (!_validate_doc(func->set_return_doc))
304 return EINA_FALSE; 329 return EINA_FALSE;
305 330
306 return EINA_TRUE; 331 return _validate(&func->base);
307} 332}
308 333
309static Eina_Bool 334static Eina_Bool
310_validate_event(const Eolian_Event *event) 335_validate_event(Eolian_Event *event)
311{ 336{
337 if (event->base.validated)
338 return EINA_TRUE;
339
312 if (event->type && !_validate_type(event->type)) 340 if (event->type && !_validate_type(event->type))
313 return EINA_FALSE; 341 return EINA_FALSE;
314 342
315 if (!_validate_doc(event->doc)) 343 if (!_validate_doc(event->doc))
316 return EINA_FALSE; 344 return EINA_FALSE;
317 345
318 return EINA_TRUE; 346 return _validate(&event->base);
319} 347}
320 348
321static Eina_Bool 349static Eina_Bool
322_validate_implement(const Eolian_Implement *impl) 350_validate_implement(Eolian_Implement *impl)
323{ 351{
352 if (impl->base.validated)
353 return EINA_TRUE;
354
324 if (!_validate_doc(impl->common_doc)) 355 if (!_validate_doc(impl->common_doc))
325 return EINA_FALSE; 356 return EINA_FALSE;
326 if (!_validate_doc(impl->get_doc)) 357 if (!_validate_doc(impl->get_doc))
@@ -328,16 +359,19 @@ _validate_implement(const Eolian_Implement *impl)
328 if (!_validate_doc(impl->set_doc)) 359 if (!_validate_doc(impl->set_doc))
329 return EINA_FALSE; 360 return EINA_FALSE;
330 361
331 return EINA_TRUE; 362 return _validate(&impl->base);
332} 363}
333 364
334static Eina_Bool 365static Eina_Bool
335_validate_class(const Eolian_Class *cl) 366_validate_class(Eolian_Class *cl)
336{ 367{
337 Eina_List *l; 368 Eina_List *l;
338 const Eolian_Function *func; 369 Eolian_Function *func;
339 const Eolian_Event *event; 370 Eolian_Event *event;
340 const Eolian_Implement *impl; 371 Eolian_Implement *impl;
372
373 if (cl->base.validated)
374 return EINA_TRUE;
341 375
342 EINA_LIST_FOREACH(cl->properties, l, func) 376 EINA_LIST_FOREACH(cl->properties, l, func)
343 if (!_validate_function(func)) 377 if (!_validate_function(func))
@@ -358,12 +392,15 @@ _validate_class(const Eolian_Class *cl)
358 if (!_validate_doc(cl->doc)) 392 if (!_validate_doc(cl->doc))
359 return EINA_FALSE; 393 return EINA_FALSE;
360 394
361 return EINA_TRUE; 395 return _validate(&cl->base);
362} 396}
363 397
364static Eina_Bool 398static Eina_Bool
365_validate_variable(const Eolian_Variable *var) 399_validate_variable(Eolian_Variable *var)
366{ 400{
401 if (var->base.validated)
402 return EINA_TRUE;
403
367 if (!_validate_type(var->base_type)) 404 if (!_validate_type(var->base_type))
368 return EINA_FALSE; 405 return EINA_FALSE;
369 406
@@ -373,7 +410,7 @@ _validate_variable(const Eolian_Variable *var)
373 if (!_validate_doc(var->doc)) 410 if (!_validate_doc(var->doc))
374 return EINA_FALSE; 411 return EINA_FALSE;
375 412
376 return EINA_TRUE; 413 return _validate(&var->base);
377} 414}
378 415
379static Eina_Bool 416static Eina_Bool
@@ -385,7 +422,7 @@ _typedecl_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
385 422
386static Eina_Bool 423static Eina_Bool
387_var_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, 424_var_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
388 const Eolian_Variable *var, Eina_Bool *sc) 425 Eolian_Variable *var, Eina_Bool *sc)
389{ 426{
390 return (*sc = _validate_variable(var)); 427 return (*sc = _validate_variable(var));
391} 428}
@@ -393,7 +430,7 @@ _var_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
393Eina_Bool 430Eina_Bool
394database_validate() 431database_validate()
395{ 432{
396 const Eolian_Class *cl; 433 Eolian_Class *cl;
397 434
398 /* FIXME: pass unit properly */ 435 /* FIXME: pass unit properly */
399 Eina_Iterator *iter = eolian_all_classes_get(NULL); 436 Eina_Iterator *iter = eolian_all_classes_get(NULL);
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 1970034bd5..301caf4294 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -61,6 +61,7 @@ typedef struct _Eolian_Object
61 const char *file; 61 const char *file;
62 int line; 62 int line;
63 int column; 63 int column;
64 Eina_Bool validated;
64} Eolian_Object; 65} Eolian_Object;
65 66
66struct _Eolian_Documentation 67struct _Eolian_Documentation