forked from enlightenment/efl
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
This commit is contained in:
parent
2ee3bce648
commit
93bbf71b72
|
@ -64,6 +64,10 @@ struct documentation_generator
|
|||
::Eolian_Function_Type ftype = ::eolian_function_type_get(function);
|
||||
const char* eo_name = ::eolian_function_name_get(function);
|
||||
std::string name = object_ref_conversion(klass);
|
||||
|
||||
// Klass is needed to check the property naming rulles
|
||||
attributes::klass_def klass_d((const ::Eolian_Class *)klass, eolian_object_unit_get(klass));
|
||||
|
||||
switch(ftype)
|
||||
{
|
||||
case ::EOLIAN_METHOD:
|
||||
|
@ -75,17 +79,17 @@ struct documentation_generator
|
|||
break;
|
||||
case ::EOLIAN_PROP_SET:
|
||||
name += ".Set";
|
||||
name += name_helpers::property_managed_name(eo_name);
|
||||
name += name_helpers::property_managed_name(klass_d, eo_name);
|
||||
break;
|
||||
case ::EOLIAN_PROP_GET:
|
||||
name += ".Get";
|
||||
name += name_helpers::property_managed_name(eo_name);
|
||||
name += name_helpers::property_managed_name(klass_d, eo_name);
|
||||
break;
|
||||
case ::EOLIAN_PROPERTY:
|
||||
{
|
||||
int getter_params = property_num_parameters(function, ::EOLIAN_PROP_GET);
|
||||
int setter_params = property_num_parameters(function, ::EOLIAN_PROP_SET);
|
||||
std::string short_name = name_helpers::property_managed_name(eo_name);
|
||||
std::string short_name = name_helpers::property_managed_name(klass_d, eo_name);
|
||||
bool blacklisted = blacklist::is_property_blacklisted(name + "." + short_name);
|
||||
// EO properties with keys, with more than one value, or blacklisted, are not
|
||||
// converted into C# properties.
|
||||
|
|
|
@ -267,12 +267,12 @@ struct property_wrapper_definition_generator
|
|||
return false;
|
||||
|
||||
if (property.getter.is_engaged())
|
||||
if (!as_generator(scope_tab << scope_tab << "get " << (interface ? ";" : "{ return Get" + managed_name + "(); }") << "\n"
|
||||
if (!as_generator(scope_tab << scope_tab << "get " << (interface ? ";" : "{ return " + name_helpers::managed_method_name(*property.getter) + "(); }") << "\n"
|
||||
).generate(sink, attributes::unused, context))
|
||||
return false;
|
||||
|
||||
if (property.setter.is_engaged())
|
||||
if (!as_generator(scope_tab << scope_tab << "set " << (interface ? ";" : "{ Set" + managed_name + "(" + dir_mod + "value); }") << "\n"
|
||||
if (!as_generator(scope_tab << scope_tab << "set " << (interface ? ";" : "{ " + name_helpers::managed_method_name(*property.setter) + "(" + dir_mod + "value); }") << "\n"
|
||||
).generate(sink, attributes::unused, context))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -38,6 +38,10 @@ inline bool is_equal(std::string const& lhs, std::string const& rhs)
|
|||
}
|
||||
}
|
||||
|
||||
// Forward declarations
|
||||
template<typename T>
|
||||
inline std::string klass_concrete_or_interface_name(T const& klass);
|
||||
|
||||
inline std::string identity(std::string const& str)
|
||||
{
|
||||
return str;
|
||||
|
@ -184,6 +188,12 @@ inline std::string managed_method_name(std::string const& klass, std::string con
|
|||
if (candidate == klass)
|
||||
candidate = "Do" + candidate;
|
||||
|
||||
// Avoid clashing with System.Object.GetType
|
||||
if (candidate == "GetType" || candidate == "SetType")
|
||||
{
|
||||
candidate.insert(3, klass);
|
||||
}
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
|
@ -252,17 +262,26 @@ inline std::string to_field_name(std::string const& in)
|
|||
return utils::capitalize(in);
|
||||
}
|
||||
|
||||
inline std::string property_managed_name(const std::string name)
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline std::string property_managed_name(T const& klass, std::string const& name)
|
||||
{
|
||||
auto names = utils::split(name, '_');
|
||||
// No need to escape keyword here as it will be capitalized and already
|
||||
// namespaced inside the owner class.
|
||||
return utils::to_pascal_case(names);
|
||||
auto managed_name = utils::to_pascal_case(names);
|
||||
auto managed_klass_name = klass_concrete_or_interface_name(klass);
|
||||
|
||||
if (managed_name == "Type")
|
||||
managed_name = managed_klass_name + managed_name;
|
||||
|
||||
return managed_name;
|
||||
}
|
||||
|
||||
inline std::string property_managed_name(attributes::property_def const& property)
|
||||
{
|
||||
return property_managed_name(property.name);
|
||||
return property_managed_name(property.klass, property.name);
|
||||
}
|
||||
|
||||
inline std::string managed_part_name(attributes::part_def const& part)
|
||||
|
|
Loading…
Reference in New Issue