diff options
author | Yeongjong Lee <yj34.lee@samsung.com> | 2020-01-28 14:46:10 +0900 |
---|---|---|
committer | WooHyun Jung <wh0705.jung@samsung.com> | 2020-01-28 14:46:10 +0900 |
commit | 581bec9598943cc9274dfe7db1a73a4c878c3cdd (patch) | |
tree | ae52675a45025659459dfb329e73538417dc625f /src/bin/eolian_mono/eolian/mono/utils.hh | |
parent | b3c0da13d80456bcbf3954698413df5ee845b8c2 (diff) |
eolian_mono: make struct immutable
Summary:
Immutable value type is recommeneded for struct type in cs world.
`DO NOT define mutable value types.`
(see, https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/struct)
Also, this patch include refactoring of generated struct types.
1. Change field type to property type that have only getter. it will fix CA1051(ref T8397).
2. Remove internal NativeStruct. there is private field for marshalling struct instead.
3. Fix some test cases that change value inside struct. because struct is immutable.
Test Plan: meson build -Dbindings=mono,cxx -Dmono-beta=true
Reviewers: woohyun, felipealmeida, Jaehyun_Cho
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T8397
Differential Revision: https://phab.enlightenment.org/D11146
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/utils.hh')
-rw-r--r-- | src/bin/eolian_mono/eolian/mono/utils.hh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/utils.hh b/src/bin/eolian_mono/eolian/mono/utils.hh index d942903aba..7905790b4c 100644 --- a/src/bin/eolian_mono/eolian/mono/utils.hh +++ b/src/bin/eolian_mono/eolian/mono/utils.hh | |||
@@ -90,6 +90,28 @@ namespace eolian_mono { namespace utils { | |||
90 | return ret; | 90 | return ret; |
91 | } | 91 | } |
92 | 92 | ||
93 | std::string to_camel_case(const std::vector<std::string> &names, std::string const& delim="") | ||
94 | { | ||
95 | std::vector<std::string> outv(names.size()); | ||
96 | std::stringstream osstream; | ||
97 | |||
98 | std::transform(names.begin(), names.end(), outv.begin(), | ||
99 | [](std::string name) { | ||
100 | name[0] = std::toupper(name[0]); | ||
101 | return name; | ||
102 | }); | ||
103 | |||
104 | std::copy(outv.begin(), outv.end(), std::ostream_iterator<std::string>(osstream, delim.c_str())); | ||
105 | |||
106 | std::string ret = osstream.str(); | ||
107 | |||
108 | if (delim != "") | ||
109 | ret.pop_back(); // We could implement an infix_iterator but this pop is enough for now. | ||
110 | |||
111 | ret[0] = std::tolower(ret[0]); | ||
112 | return ret; | ||
113 | } | ||
114 | |||
93 | inline std::string remove_all(std::string name, char target) | 115 | inline std::string remove_all(std::string name, char target) |
94 | { | 116 | { |
95 | name.erase(std::remove(name.begin(), name.end(), target), name.end()); | 117 | name.erase(std::remove(name.begin(), name.end(), target), name.end()); |