summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-03-11 19:22:28 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-03-11 19:28:02 -0300
commit305749f049ceb73071febe2ac723dadff7b69dbc (patch)
tree8b00566c34032b6ccf0ccbe452c1ca07dcade2c8
parentd96c71c37ced7c9b630a25a9dc650a880903889a (diff)
downloadefl-305749f049ceb73071febe2ac723dadff7b69dbc.tar.gz
csharp: Fix event names with underscore.
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
-rw-r--r--src/bin/eolian_mono/eolian/mono/name_helpers.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/utils.hh22
-rw-r--r--src/tests/efl_mono/Events.cs21
-rw-r--r--src/tests/efl_mono/dummy_test_object.eo4
-rw-r--r--src/tests/efl_mono/libefl_mono_native_test.c5
5 files changed, 47 insertions, 7 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
index 5fc1f18d22..074fd4f7ed 100644
--- a/src/bin/eolian_mono/eolian/mono/name_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
@@ -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)
diff --git a/src/bin/eolian_mono/eolian/mono/utils.hh b/src/bin/eolian_mono/eolian/mono/utils.hh
index cbea48afa3..392cb00f11 100644
--- a/src/bin/eolian_mono/eolian/mono/utils.hh
+++ b/src/bin/eolian_mono/eolian/mono/utils.hh
@@ -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());
diff --git a/src/tests/efl_mono/Events.cs b/src/tests/efl_mono/Events.cs
index 2cf881804b..2d6dedb8e9 100644
--- a/src/tests/efl_mono/Events.cs
+++ b/src/tests/efl_mono/Events.cs
@@ -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);
+
+ }
+}
}
diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo
index d0311e96ac..0d6ced8e62 100644
--- a/src/tests/efl_mono/dummy_test_object.eo
+++ b/src/tests/efl_mono/dummy_test_object.eo
@@ -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;
}
}
diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c
index 8968e46801..11190c9124 100644
--- a/src/tests/efl_mono/libefl_mono_native_test.c
+++ b/src/tests/efl_mono/libefl_mono_native_test.c
@@ -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);