diff options
author | Lauro Moura <lauromoura@expertisesolutions.com.br> | 2019-03-11 19:22:28 -0300 |
---|---|---|
committer | Vitor Sousa <vitorsousa@expertisesolutions.com.br> | 2019-03-11 19:28:02 -0300 |
commit | 305749f049ceb73071febe2ac723dadff7b69dbc (patch) | |
tree | 8b00566c34032b6ccf0ccbe452c1ca07dcade2c8 | |
parent | d96c71c37ced7c9b630a25a9dc650a880903889a (diff) |
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.hh | 2 | ||||
-rw-r--r-- | src/bin/eolian_mono/eolian/mono/utils.hh | 22 | ||||
-rw-r--r-- | src/tests/efl_mono/Events.cs | 21 | ||||
-rw-r--r-- | src/tests/efl_mono/dummy_test_object.eo | 4 | ||||
-rw-r--r-- | src/tests/efl_mono/libefl_mono_native_test.c | 5 |
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) | |||
402 | // Events | 402 | // Events |
403 | inline std::string managed_event_name(std::string const& name) | 403 | inline std::string managed_event_name(std::string const& name) |
404 | { | 404 | { |
405 | return utils::to_pascal_case(utils::split(name, ','), "") + "Evt"; | 405 | return utils::to_pascal_case(utils::split(name, "_,"), "") + "Evt"; |
406 | } | 406 | } |
407 | 407 | ||
408 | inline std::string managed_event_args_short_name(attributes::event_def const& evt) | 408 | 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 { | |||
30 | return ret; | 30 | return ret; |
31 | } | 31 | } |
32 | 32 | ||
33 | std::vector<std::string> split(std::string const &input, char delim) | 33 | std::vector<std::string> split(std::string const &input, std::string delims) |
34 | { | 34 | { |
35 | std::stringstream ss(input); | ||
36 | std::string name; | ||
37 | std::vector<std::string> names; | 35 | std::vector<std::string> names; |
36 | size_t pos = 0; | ||
38 | 37 | ||
39 | while (std::getline(ss, name, delim)) | 38 | while(pos != std::string::npos) |
40 | { | 39 | { |
41 | if (!name.empty()) | 40 | size_t newpos = input.find_first_of(delims, pos); |
42 | names.push_back(name); | 41 | names.push_back(input.substr(pos, newpos-pos)); |
42 | pos = newpos; | ||
43 | |||
44 | if (pos != std::string::npos) | ||
45 | pos++; | ||
43 | } | 46 | } |
47 | |||
44 | return names; | 48 | return names; |
45 | } | 49 | } |
46 | 50 | ||
51 | std::vector<std::string> split(std::string const &input, char delim) | ||
52 | { | ||
53 | return split(input, {1, delim}); | ||
54 | } | ||
55 | |||
56 | |||
47 | std::string to_pascal_case(const std::vector<std::string> &names, std::string const& delim="") | 57 | std::string to_pascal_case(const std::vector<std::string> &names, std::string const& delim="") |
48 | { | 58 | { |
49 | std::vector<std::string> outv(names.size()); | 59 | 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 | |||
253 | Test.Assert(another_called); | 253 | Test.Assert(another_called); |
254 | } | 254 | } |
255 | } | 255 | } |
256 | |||
257 | class TestEventNaming | ||
258 | { | ||
259 | // For events named line focus_geometry,changed | ||
260 | public static void test_event_naming() | ||
261 | { | ||
262 | var obj = new Dummy.TestObject(); | ||
263 | var test_called = false; | ||
264 | |||
265 | EventHandler cb = (object sender, EventArgs e) => { | ||
266 | test_called = true; | ||
267 | }; | ||
268 | |||
269 | obj.EvtWithUnderEvt += cb; | ||
270 | |||
271 | obj.EmitEventWithUnder(); | ||
272 | |||
273 | Test.Assert(test_called); | ||
274 | |||
275 | } | ||
276 | } | ||
256 | } | 277 | } |
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 | |||
1310 | } | 1310 | } |
1311 | } | 1311 | } |
1312 | 1312 | ||
1313 | emit_event_with_under { | ||
1314 | } | ||
1315 | |||
1313 | append_to_strbuf { | 1316 | append_to_strbuf { |
1314 | params { | 1317 | params { |
1315 | @in buf: strbuf; | 1318 | @in buf: strbuf; |
@@ -1406,5 +1409,6 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface, Dummy.An | |||
1406 | evt,with,struct @hot: Dummy.StructSimple; | 1409 | evt,with,struct @hot: Dummy.StructSimple; |
1407 | evt,with,struct,complex @hot: Dummy.StructComplex; | 1410 | evt,with,struct,complex @hot: Dummy.StructComplex; |
1408 | evt,with,list @hot: list<string>; | 1411 | evt,with,list @hot: list<string>; |
1412 | evt_with,under @hot: void; | ||
1409 | } | 1413 | } |
1410 | } | 1414 | } |
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 | |||
3789 | efl_event_callback_legacy_call(obj, DUMMY_TEST_OBJECT_EVENT_EVT_WITH_LIST, data); | 3789 | efl_event_callback_legacy_call(obj, DUMMY_TEST_OBJECT_EVENT_EVT_WITH_LIST, data); |
3790 | } | 3790 | } |
3791 | 3791 | ||
3792 | void _dummy_test_object_emit_event_with_under(Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd) | ||
3793 | { | ||
3794 | efl_event_callback_legacy_call(obj, DUMMY_TEST_OBJECT_EVENT_EVT_WITH_UNDER, NULL); | ||
3795 | } | ||
3796 | |||
3792 | void _dummy_test_object_append_to_strbuf(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, Eina_Strbuf *buf, const char *str) | 3797 | void _dummy_test_object_append_to_strbuf(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, Eina_Strbuf *buf, const char *str) |
3793 | { | 3798 | { |
3794 | eina_strbuf_append(buf, str); | 3799 | eina_strbuf_append(buf, str); |