eolian_mono: Fix event argument for strings
authorLauro Moura <lauromoura@expertisesolutions.com.br>
Mon, 22 Jan 2018 17:56:38 +0000 (14:56 -0300)
committerWonki Kim <wonki_.kim@samsung.com>
Tue, 3 Apr 2018 09:50:11 +0000 (18:50 +0900)
src/bin/eolian_mono/eolian/mono/klass.hh
src/tests/efl_mono/Events.cs
src/tests/efl_mono/libefl_mono_native_test.c
src/tests/efl_mono/test_testing.eo

index 8657faf..003f59f 100644 (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
index 5719745..c0e9146 100644 (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);
+    }
 }
 }
index f9b50dc..e3543fc 100644 (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"
 
index fec5f90..a65b4db 100644 (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;
+   }
 }