forked from enlightenment/efl
eolian: add event type call convention checks for non-beta classes
This commit is contained in:
parent
1066e5be60
commit
3f083b3ccb
|
@ -524,6 +524,66 @@ _validate_event(Validate_State *vals, Eolian_Event *event, Eina_Hash *nhash)
|
|||
if (!_validate_type(vals, event->type))
|
||||
return _reset_stable(vals, was_stable, EINA_FALSE);
|
||||
|
||||
/* if this is an alias we need the lowest type in the stack, this is
|
||||
* after validation so all the necessary fields are properly filled in
|
||||
*/
|
||||
const Eolian_Type *tp = eolian_type_aliased_base_get(event->type);
|
||||
|
||||
/* event types are specially restricted
|
||||
* but stuff like pointer-to-pointer is alrady handled by _validate_type
|
||||
*/
|
||||
if (tp->type == EOLIAN_TYPE_REGULAR && vals->stable)
|
||||
{
|
||||
/* explicit pointers never allowed */
|
||||
if (tp->is_ptr)
|
||||
{
|
||||
_eo_parser_log(&tp->base, "pointers not allowed in events");
|
||||
return _reset_stable(vals, was_stable, EINA_FALSE);
|
||||
}
|
||||
/* require containers to be const for now...
|
||||
*
|
||||
* this is FIXME, and decision wasn't reached before 1.22
|
||||
* it is a simple search-replace anyway
|
||||
*/
|
||||
if (database_type_is_ownable(tp->base.unit, tp, EINA_FALSE))
|
||||
{
|
||||
if (!tp->is_const)
|
||||
{
|
||||
_eo_parser_log(&tp->base, "event container types must be const");
|
||||
return _reset_stable(vals, was_stable, EINA_FALSE);
|
||||
}
|
||||
}
|
||||
else if (tp->is_const)
|
||||
{
|
||||
_eo_parser_log(&tp->base, "event value types cannot be const");
|
||||
return _reset_stable(vals, was_stable, EINA_FALSE);
|
||||
}
|
||||
int kwid = eo_lexer_keyword_str_to_id(tp->base.name);
|
||||
/* containers are allowed but not iterators/lists */
|
||||
if (kwid == KW_iterator || kwid == KW_list)
|
||||
{
|
||||
_eo_parser_log(&tp->base, "sequence containers not allowed in events");
|
||||
return _reset_stable(vals, was_stable, EINA_FALSE);
|
||||
}
|
||||
/* rw slices are not allowed as regular types are always immutable */
|
||||
if (kwid == KW_rw_slice)
|
||||
{
|
||||
_eo_parser_log(&tp->base, "mutable slices not allowed in events");
|
||||
return _reset_stable(vals, was_stable, EINA_FALSE);
|
||||
}
|
||||
/* any type past builtin value types and containers is not allowed,
|
||||
* any_value is allowed but passed as const reference, any_value_ptr
|
||||
* is not; string is allowed, but mutable strings or stringshares are
|
||||
* not and neither are string buffers, the type is never owned by the
|
||||
* callee, so all strings passed in are unowned and read-only
|
||||
*/
|
||||
if (kwid >= KW_any_value_ptr && kwid != KW_string)
|
||||
{
|
||||
_eo_parser_log(&tp->base, "forbidden event type");
|
||||
return _reset_stable(vals, was_stable, EINA_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_validate_doc(event->doc))
|
||||
return _reset_stable(vals, was_stable, EINA_FALSE);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class Callback extends Efl.Object
|
|||
prefix,event1: void;
|
||||
prefix,event2: Callback;
|
||||
prefix,event3: int;
|
||||
prefix,event4: list<int*>;
|
||||
prefix,event4: const(array<ptr(int)>);
|
||||
prefix,event5: Callback_Event;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ EFL_START_TEST(eolian_cxx_test_type_callback)
|
|||
event3 = true;
|
||||
ck_assert(v == 42);
|
||||
});
|
||||
efl::eolian::event_add(g.prefix_event4_event, g, [&] (nonamespace::Generic, efl::eina::range_list<const int &> e)
|
||||
efl::eolian::event_add(g.prefix_event4_event, g, [&] (nonamespace::Generic, efl::eina::range_array<const int &> e)
|
||||
{
|
||||
event4 = true;
|
||||
ck_assert(e.size() == 1);
|
||||
|
|
|
@ -115,10 +115,10 @@ static void _generic_call_event3(Eo *obj, Generic_Data* pd EINA_UNUSED)
|
|||
static void _generic_call_event4(Eo *obj, Generic_Data* pd EINA_UNUSED)
|
||||
{
|
||||
int i = 42;
|
||||
Eina_List* p = eina_list_append(NULL, &i);
|
||||
ck_assert(p != NULL);
|
||||
Eina_Array* p = eina_array_new(1);
|
||||
ck_assert(eina_array_push(p, &i));
|
||||
efl_event_callback_call(obj, GENERIC_EVENT_PREFIX_EVENT4, p);
|
||||
eina_list_free(p);
|
||||
eina_array_free(p);
|
||||
}
|
||||
static void _generic_call_event5(Eo *obj, Generic_Data* pd EINA_UNUSED)
|
||||
{
|
||||
|
|
|
@ -108,7 +108,7 @@ class Generic extends Efl.Object implements Generic_Interface
|
|||
prefix,event1: void;
|
||||
prefix,event2: Generic;
|
||||
prefix,event3: int;
|
||||
prefix,event4: list<ptr(int)>;
|
||||
prefix,event4: const(array<ptr(int)>);
|
||||
prefix,event5: Generic.Event;
|
||||
protected,event1 @protected: void;
|
||||
beta,event1 @beta: void;
|
||||
|
|
Loading…
Reference in New Issue