eolian_mono: Fix event argument for strings

This commit is contained in:
Lauro Moura 2018-01-22 14:56:38 -03:00
parent 4cd760c9a7
commit eaf41d9bce
4 changed files with 135 additions and 0 deletions

View File

@ -116,6 +116,10 @@ struct get_event_args_visitor
typedef std::string result_type;
std::string operator()(grammar::attributes::regular_type_def const&) const
{
if (arg_type == "string")
{
return "eina.StringConversion.NativeUtf8ToManagedString(evt.Info)";
}
return "(" + arg_type + ")Marshal.PtrToStructure(evt.Info, typeof(" + arg_type + "))";
}
std::string operator()(grammar::attributes::klass_name const&) const

View File

@ -33,5 +33,76 @@ class TestEoEvents
Test.Assert(listener.correct_sender);
Test.AssertEquals("loop_called", loop.GetName());
}
public static void event_with_string_payload()
{
test.Testing obj = new test.TestingConcrete();
string received_string = null;
obj.EVT_WITH_STRING += (object sender, test.EVT_WITH_STRING_Args e) => {
received_string = e.arg;
};
obj.EmitEventWithString("Some args");
Test.AssertEquals("Some args", received_string);
}
public static void event_with_int_payload()
{
test.Testing obj = new test.TestingConcrete();
int received_int= 0;
obj.EVT_WITH_INT += (object sender, test.EVT_WITH_INT_Args e) => {
received_int = e.arg;
};
obj.EmitEventWithInt(-1984);
Test.AssertEquals(-1984, received_int);
}
public static void event_with_uint_payload()
{
test.Testing obj = new test.TestingConcrete();
uint received_uint = 0;
obj.EVT_WITH_UINT += (object sender, test.EVT_WITH_UINT_Args e) => {
received_uint = e.arg;
};
obj.EmitEventWithUint(0xbeef);
Test.AssertEquals<uint>(0xbeef, received_uint);
}
public static void event_with_float_payload()
{
test.Testing obj = new test.TestingConcrete();
float received_float= 0;
obj.EVT_WITH_FLOAT += (object sender, test.EVT_WITH_FLOAT_Args e) => {
received_float = e.arg;
};
obj.EmitEventWithFloat(3.14f);
Test.AssertEquals(3.14f, received_float);
}
public static void event_with_object_payload()
{
test.Testing obj = new test.TestingConcrete();
test.Testing received_obj = null;
obj.EVT_WITH_OBJ += (object sender, test.EVT_WITH_OBJ_Args e) => {
received_obj = e.arg;
};
test.Testing sent_obj = new test.TestingConcrete();
obj.EmitEventWithObj(sent_obj);
Test.AssertEquals(sent_obj, received_obj);
}
}
}

View File

@ -3669,6 +3669,33 @@ void _test_testing_out_value(EINA_UNUSED Eo *obj, Test_Testing_Data *pd, Eina_Va
*value = *pd->stored_value;
}
void _test_testing_emit_event_with_string(Eo *obj, EINA_UNUSED Test_Testing_Data *pd, const char *data)
{
char *ptr = strdup(data);
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_STRING, ptr);
free(ptr);
}
void _test_testing_emit_event_with_int(Eo *obj, EINA_UNUSED Test_Testing_Data *pd, int data)
{
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_INT, &data);
}
void _test_testing_emit_event_with_uint(Eo *obj, EINA_UNUSED Test_Testing_Data *pd, unsigned int data)
{
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_UINT, &data);
}
void _test_testing_emit_event_with_float(Eo *obj, EINA_UNUSED Test_Testing_Data *pd, float data)
{
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_FLOAT, &data);
}
void _test_testing_emit_event_with_obj(Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eo *data)
{
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_OBJ, data);
}
#include "test_testing.eo.c"
#include "test_numberwrapper.eo.c"

View File

@ -1455,9 +1455,42 @@ class Test.Testing (Efl.Object) {
// struct_complex_ptr_return_own {
// return: ptr(Test.StructComplex) @owned;
// }
emit_event_with_string {
params {
@in data: string;
}
}
emit_event_with_int {
params {
@in data: int;
}
}
emit_event_with_uint {
params {
@in data: uint;
}
}
emit_event_with_float {
params {
@in data: float;
}
}
emit_event_with_obj {
params {
@in data: Test.Testing;
}
}
}
implements {
class.constructor;
class.destructor;
}
events {
evt,with,string @hot: string;
evt,with,int @hot: int;
evt,with,uint @hot: uint;
evt,with,float @hot: float;
evt,with,obj @hot: Test.Testing;
}
}