summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-02-25 13:59:51 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2019-02-25 14:00:28 +0100
commitd0709d61101bd9f93134b6b49566965078847a65 (patch)
tree9914681ecd00d6090ee08442de1e3edab98c75e7 /src
parent8d2d5ae3b8fca44bce9643b159cb130434eadb1f (diff)
eolian: validate betaness
Summary: if there is a none beta class, then this class should not depend on beta classes in parameters / event types / return types, parent inherits. This adds this validation, so we can start to slowly to unbeta more and more classes. Reviewers: q66, zmike, cedric, segfaultxavi Reviewed By: q66 Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7999
Diffstat (limited to 'src')
-rw-r--r--src/lib/elementary/efl_ui_relative_layout.eo2
-rw-r--r--src/lib/eolian/database_validate.c34
-rw-r--r--src/tests/ecore/efl_app_test_cml.eo2
3 files changed, 32 insertions, 6 deletions
diff --git a/src/lib/elementary/efl_ui_relative_layout.eo b/src/lib/elementary/efl_ui_relative_layout.eo
index 967f23d623..dff9c60801 100644
--- a/src/lib/elementary/efl_ui_relative_layout.eo
+++ b/src/lib/elementary/efl_ui_relative_layout.eo
@@ -1,4 +1,4 @@
1class Efl.Ui.Relative_Layout extends Efl.Ui.Widget implements Efl.Pack_Layout 1class @beta Efl.Ui.Relative_Layout extends Efl.Ui.Widget implements Efl.Pack_Layout
2{ 2{
3 [[The relative layout class. 3 [[The relative layout class.
4 4
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 7805a407ab..319b45a802 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -73,6 +73,27 @@ _validate_docstr(Eina_Stringshare *str, const Eolian_Object *info, Eina_List **r
73} 73}
74 74
75static Eina_Bool 75static Eina_Bool
76_class_is_legacy(Eolian_Class *klass)
77{
78 return !!strncmp(klass->base.name, "Efl.", strlen("Efl."));
79}
80
81static Eina_Bool
82_validate_beta_usage(Eolian_Class *klass, Eolian_Type *type)
83{
84 if (!klass) return EINA_TRUE;
85 if (_class_is_legacy(klass)) return EINA_TRUE;
86 if (klass->is_beta) return EINA_TRUE;
87
88 if (type->type == EOLIAN_TYPE_CLASS && type->klass->is_beta)
89 {
90 _eo_parser_log(&type->base, "beta class used in public API");
91 return EINA_FALSE;
92 }
93 return EINA_TRUE;
94}
95
96static Eina_Bool
76_validate_doc(Eolian_Documentation *doc) 97_validate_doc(Eolian_Documentation *doc)
77{ 98{
78 if (!doc) 99 if (!doc)
@@ -378,10 +399,10 @@ _validate_function(Validate_State *vals, Eolian_Function *func, Eina_Hash *nhash
378 return EINA_TRUE; 399 return EINA_TRUE;
379 } 400 }
380 401
381 if (func->get_ret_type && !_validate_type(vals, func->get_ret_type)) 402 if (func->get_ret_type && (!_validate_type(vals, func->get_ret_type) || !_validate_beta_usage(func->klass, func->get_ret_type)))
382 return EINA_FALSE; 403 return EINA_FALSE;
383 404
384 if (func->set_ret_type && !_validate_type(vals, func->set_ret_type)) 405 if (func->set_ret_type && (!_validate_type(vals, func->set_ret_type) || !_validate_beta_usage(func->klass, func->set_ret_type)))
385 return EINA_FALSE; 406 return EINA_FALSE;
386 407
387 if (func->get_ret_val && !_validate_expr(func->get_ret_val, 408 if (func->get_ret_val && !_validate_expr(func->get_ret_val,
@@ -394,7 +415,7 @@ _validate_function(Validate_State *vals, Eolian_Function *func, Eina_Hash *nhash
394 415
395#define EOLIAN_PARAMS_VALIDATE(params) \ 416#define EOLIAN_PARAMS_VALIDATE(params) \
396 EINA_LIST_FOREACH(params, l, param) \ 417 EINA_LIST_FOREACH(params, l, param) \
397 if (!_validate_param(vals, param)) \ 418 if (!_validate_param(vals, param) || !_validate_beta_usage(func->klass, param->type)) \
398 return EINA_FALSE; 419 return EINA_FALSE;
399 420
400 EOLIAN_PARAMS_VALIDATE(func->prop_values); 421 EOLIAN_PARAMS_VALIDATE(func->prop_values);
@@ -482,7 +503,7 @@ _validate_event(Validate_State *vals, Eolian_Event *event, Eina_Hash *nhash)
482 return EINA_TRUE; 503 return EINA_TRUE;
483 } 504 }
484 505
485 if (!_validate_type(vals, event->type)) 506 if (!_validate_type(vals, event->type) || !_validate_beta_usage(event->klass, event->type))
486 return EINA_FALSE; 507 return EINA_FALSE;
487 508
488 if (!_validate_doc(event->doc)) 509 if (!_validate_doc(event->doc))
@@ -1159,6 +1180,11 @@ _validate_class(Validate_State *vals, Eolian_Class *cl,
1159 default: 1180 default:
1160 break; 1181 break;
1161 } 1182 }
1183 if (!_class_is_legacy(cl) && !cl->is_beta && cl->parent->is_beta)
1184 {
1185 _eo_parser_log(&cl->base, "non-beta class cannot have beta parent");
1186 return EINA_FALSE;
1187 }
1162 if (!_validate_class(vals, cl->parent, nhash, ehash, chash)) 1188 if (!_validate_class(vals, cl->parent, nhash, ehash, chash))
1163 return EINA_FALSE; 1189 return EINA_FALSE;
1164 } 1190 }
diff --git a/src/tests/ecore/efl_app_test_cml.eo b/src/tests/ecore/efl_app_test_cml.eo
index b0877e0cf7..ade7426a89 100644
--- a/src/tests/ecore/efl_app_test_cml.eo
+++ b/src/tests/ecore/efl_app_test_cml.eo
@@ -1,4 +1,4 @@
1class Efl.App.Test.CML extends Efl.Object implements Efl.Core.Command_Line 1class @beta Efl.App.Test.CML extends Efl.Object implements Efl.Core.Command_Line
2{ 2{
3 3
4} 4}