summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-04-15 15:58:30 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-04-15 16:31:45 -0300
commit9e29b69c2a0c7a0ee1141b2a322f4a1e301625aa (patch)
tree3c9da505031d5b9fa41c16606c0d2809239a7b3a /src/bin
parent1dd25a9238c7fe65037740821f9d2b7641bc74fd (diff)
csharp: Remove warning about clashing GetType() methods
Summary: This changes the naming scheme to replace `GetType`/`SetType` methods with `Get<CLASS>Type`/`Set<CLASS>Type`. Like `GetGestureType`. Avoids cs compiler complaining of clashing with `System.Object.GetType`. Fixes T7727 Reviewers: segfaultxavi, felipealmeida, vitor.sousa Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7727 Differential Revision: https://phab.enlightenment.org/D8609
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_mono/eolian/mono/documentation.hh10
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh4
-rw-r--r--src/bin/eolian_mono/eolian/mono/name_helpers.hh25
3 files changed, 31 insertions, 8 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/documentation.hh b/src/bin/eolian_mono/eolian/mono/documentation.hh
index 1cea16e9e8..9646fd314f 100644
--- a/src/bin/eolian_mono/eolian/mono/documentation.hh
+++ b/src/bin/eolian_mono/eolian/mono/documentation.hh
@@ -64,6 +64,10 @@ struct documentation_generator
64 ::Eolian_Function_Type ftype = ::eolian_function_type_get(function); 64 ::Eolian_Function_Type ftype = ::eolian_function_type_get(function);
65 const char* eo_name = ::eolian_function_name_get(function); 65 const char* eo_name = ::eolian_function_name_get(function);
66 std::string name = object_ref_conversion(klass); 66 std::string name = object_ref_conversion(klass);
67
68 // Klass is needed to check the property naming rulles
69 attributes::klass_def klass_d((const ::Eolian_Class *)klass, eolian_object_unit_get(klass));
70
67 switch(ftype) 71 switch(ftype)
68 { 72 {
69 case ::EOLIAN_METHOD: 73 case ::EOLIAN_METHOD:
@@ -75,17 +79,17 @@ struct documentation_generator
75 break; 79 break;
76 case ::EOLIAN_PROP_SET: 80 case ::EOLIAN_PROP_SET:
77 name += ".Set"; 81 name += ".Set";
78 name += name_helpers::property_managed_name(eo_name); 82 name += name_helpers::property_managed_name(klass_d, eo_name);
79 break; 83 break;
80 case ::EOLIAN_PROP_GET: 84 case ::EOLIAN_PROP_GET:
81 name += ".Get"; 85 name += ".Get";
82 name += name_helpers::property_managed_name(eo_name); 86 name += name_helpers::property_managed_name(klass_d, eo_name);
83 break; 87 break;
84 case ::EOLIAN_PROPERTY: 88 case ::EOLIAN_PROPERTY:
85 { 89 {
86 int getter_params = property_num_parameters(function, ::EOLIAN_PROP_GET); 90 int getter_params = property_num_parameters(function, ::EOLIAN_PROP_GET);
87 int setter_params = property_num_parameters(function, ::EOLIAN_PROP_SET); 91 int setter_params = property_num_parameters(function, ::EOLIAN_PROP_SET);
88 std::string short_name = name_helpers::property_managed_name(eo_name); 92 std::string short_name = name_helpers::property_managed_name(klass_d, eo_name);
89 bool blacklisted = blacklist::is_property_blacklisted(name + "." + short_name); 93 bool blacklisted = blacklist::is_property_blacklisted(name + "." + short_name);
90 // EO properties with keys, with more than one value, or blacklisted, are not 94 // EO properties with keys, with more than one value, or blacklisted, are not
91 // converted into C# properties. 95 // converted into C# properties.
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 3abf82fe11..23025480c0 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -267,12 +267,12 @@ struct property_wrapper_definition_generator
267 return false; 267 return false;
268 268
269 if (property.getter.is_engaged()) 269 if (property.getter.is_engaged())
270 if (!as_generator(scope_tab << scope_tab << "get " << (interface ? ";" : "{ return Get" + managed_name + "(); }") << "\n" 270 if (!as_generator(scope_tab << scope_tab << "get " << (interface ? ";" : "{ return " + name_helpers::managed_method_name(*property.getter) + "(); }") << "\n"
271 ).generate(sink, attributes::unused, context)) 271 ).generate(sink, attributes::unused, context))
272 return false; 272 return false;
273 273
274 if (property.setter.is_engaged()) 274 if (property.setter.is_engaged())
275 if (!as_generator(scope_tab << scope_tab << "set " << (interface ? ";" : "{ Set" + managed_name + "(" + dir_mod + "value); }") << "\n" 275 if (!as_generator(scope_tab << scope_tab << "set " << (interface ? ";" : "{ " + name_helpers::managed_method_name(*property.setter) + "(" + dir_mod + "value); }") << "\n"
276 ).generate(sink, attributes::unused, context)) 276 ).generate(sink, attributes::unused, context))
277 return false; 277 return false;
278 278
diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
index 2ff2b47e1d..6e913556a2 100644
--- a/src/bin/eolian_mono/eolian/mono/name_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
@@ -38,6 +38,10 @@ inline bool is_equal(std::string const& lhs, std::string const& rhs)
38} 38}
39} 39}
40 40
41// Forward declarations
42template<typename T>
43inline std::string klass_concrete_or_interface_name(T const& klass);
44
41inline std::string identity(std::string const& str) 45inline std::string identity(std::string const& str)
42{ 46{
43 return str; 47 return str;
@@ -184,6 +188,12 @@ inline std::string managed_method_name(std::string const& klass, std::string con
184 if (candidate == klass) 188 if (candidate == klass)
185 candidate = "Do" + candidate; 189 candidate = "Do" + candidate;
186 190
191 // Avoid clashing with System.Object.GetType
192 if (candidate == "GetType" || candidate == "SetType")
193 {
194 candidate.insert(3, klass);
195 }
196
187 return candidate; 197 return candidate;
188} 198}
189 199
@@ -252,17 +262,26 @@ inline std::string to_field_name(std::string const& in)
252 return utils::capitalize(in); 262 return utils::capitalize(in);
253} 263}
254 264
255inline std::string property_managed_name(const std::string name) 265
266
267template<typename T>
268inline std::string property_managed_name(T const& klass, std::string const& name)
256{ 269{
257 auto names = utils::split(name, '_'); 270 auto names = utils::split(name, '_');
258 // No need to escape keyword here as it will be capitalized and already 271 // No need to escape keyword here as it will be capitalized and already
259 // namespaced inside the owner class. 272 // namespaced inside the owner class.
260 return utils::to_pascal_case(names); 273 auto managed_name = utils::to_pascal_case(names);
274 auto managed_klass_name = klass_concrete_or_interface_name(klass);
275
276 if (managed_name == "Type")
277 managed_name = managed_klass_name + managed_name;
278
279 return managed_name;
261} 280}
262 281
263inline std::string property_managed_name(attributes::property_def const& property) 282inline std::string property_managed_name(attributes::property_def const& property)
264{ 283{
265 return property_managed_name(property.name); 284 return property_managed_name(property.klass, property.name);
266} 285}
267 286
268inline std::string managed_part_name(attributes::part_def const& part) 287inline std::string managed_part_name(attributes::part_def const& part)