csharp: Fix event names with underscore.
authorLauro Moura <lauromoura@expertisesolutions.com.br>
Mon, 11 Mar 2019 22:22:28 +0000 (19:22 -0300)
committerJunsuChoi <jsuya.choi@samsung.com>
Fri, 15 Mar 2019 04:23:20 +0000 (13:23 +0900)
Summary:
names like `focus_geometry,changed` shoud be converted to
FocusGeometryChanged instead of Focus_geometryChanged.

Fixes T7735

Test Plan: run tests

Reviewers: vitor.sousa, felipealmeida, segfaultxavi

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T7735

Differential Revision: https://phab.enlightenment.org/D8301

src/bin/eolian_mono/eolian/mono/name_helpers.hh
src/bin/eolian_mono/eolian/mono/utils.hh
src/tests/efl_mono/Events.cs
src/tests/efl_mono/dummy_test_object.eo
src/tests/efl_mono/libefl_mono_native_test.c

index 5fc1f18..074fd4f 100644 (file)
@@ -402,7 +402,7 @@ inline std::string klass_get_full_name(T const& clsname)
 // Events
 inline std::string managed_event_name(std::string const& name)
 {
-   return utils::to_pascal_case(utils::split(name, ','), "") + "Evt";
+   return utils::to_pascal_case(utils::split(name, "_,"), "") + "Evt";
 }
 
 inline std::string managed_event_args_short_name(attributes::event_def const& evt)
index cbea48a..392cb00 100644 (file)
@@ -30,20 +30,30 @@ namespace eolian_mono { namespace utils {
       return ret;
    }
 
-   std::vector<std::string> split(std::string const &input, char delim)
+   std::vector<std::string> split(std::string const &input, std::string delims)
    {
-      std::stringstream ss(input);
-      std::string name;
       std::vector<std::string> names;
+      size_t pos = 0;
 
-      while (std::getline(ss, name, delim))
+      while(pos != std::string::npos)
         {
-           if (!name.empty())
-             names.push_back(name);
+           size_t newpos = input.find_first_of(delims, pos);
+           names.push_back(input.substr(pos, newpos-pos));
+           pos = newpos;
+
+           if (pos != std::string::npos)
+             pos++;
         }
+
       return names;
    }
 
+   std::vector<std::string> split(std::string const &input, char delim)
+   {
+      return split(input, {1, delim});
+   }
+
+
    std::string to_pascal_case(const std::vector<std::string> &names, std::string const& delim="")
    {
      std::vector<std::string> outv(names.size());
index 2cf8818..2d6dedb 100644 (file)
@@ -253,4 +253,25 @@ class TestInterfaceEvents
         Test.Assert(another_called);
     }
 }
+
+class TestEventNaming
+{
+    // For events named line focus_geometry,changed
+    public static void test_event_naming()
+    {
+        var obj = new Dummy.TestObject();
+        var test_called = false;
+
+        EventHandler cb = (object sender, EventArgs e) => {
+            test_called = true;
+        };
+
+        obj.EvtWithUnderEvt += cb;
+
+        obj.EmitEventWithUnder();
+
+        Test.Assert(test_called);
+
+    }
+}
 }
index d0311e9..0d6ced8 100644 (file)
@@ -1310,6 +1310,9 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface, Dummy.An
          }
       }
 
+      emit_event_with_under {
+      }
+
       append_to_strbuf {
          params {
             @in buf: strbuf;
@@ -1406,5 +1409,6 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface, Dummy.An
       evt,with,struct @hot: Dummy.StructSimple;
       evt,with,struct,complex @hot: Dummy.StructComplex;
       evt,with,list @hot: list<string>;
+      evt_with,under @hot: void;
    }
 }
index 8968e46..11190c9 100644 (file)
@@ -3789,6 +3789,11 @@ void _dummy_test_object_emit_event_with_list(Eo *obj, EINA_UNUSED Dummy_Test_Obj
     efl_event_callback_legacy_call(obj, DUMMY_TEST_OBJECT_EVENT_EVT_WITH_LIST, data);
 }
 
+void _dummy_test_object_emit_event_with_under(Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd)
+{
+    efl_event_callback_legacy_call(obj, DUMMY_TEST_OBJECT_EVENT_EVT_WITH_UNDER, NULL);
+}
+
 void _dummy_test_object_append_to_strbuf(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, Eina_Strbuf *buf, const char *str)
 {
     eina_strbuf_append(buf, str);