forked from enlightenment/efl
Revert "efl_mono: remove class ExtensionTag"
Extension Methods' classes have methods with same names and parameters.
e.g. Text<T>(this Efl.Ui.ItemFactory<T> fac)
Although the where clause contains different classes, they cannot be
identified as different methods by C# compiler.
e.g. Text<T>(this Efl.Ui.ItemFactory<T> fac) where T : Efl.Ui.Button
e.g. Text<T>(this Efl.Ui.ItemFactory<T> fac) where T : Efl.Ui.Check
As a result, to avoid ambiguous methods, ExtensionTag should be used as
a second parameter of each method.
e.g. Text<T>(this Efl.Ui.ItemFactory<T> fac, ExtensionTag<Efl.Ui.Button, T>magic = null) where T : Efl.Ui.Button
e.g. Text<T>(this Efl.Ui.ItemFactory<T> fac, ExtensionTag<Efl.Ui.Check, T>magic = null) where T : Efl.Ui.Check
This reverts commit 76631f502a
.
This commit is contained in:
parent
cade1b3c3c
commit
700d87b370
|
@ -284,8 +284,9 @@ struct property_extension_method_definition_generator
|
||||||
if (property.setter.is_engaged())
|
if (property.setter.is_engaged())
|
||||||
{
|
{
|
||||||
attributes::type_def prop_type = property.setter->parameters[0].type;
|
attributes::type_def prop_type = property.setter->parameters[0].type;
|
||||||
if (!as_generator(scope_tab(2) << "public static Efl.BindableProperty<" << type(true) << "> " << managed_name << "<T>(this Efl.Ui.ItemFactory<T> fac) where T : "
|
if (!as_generator(scope_tab(2) << "public static Efl.BindableProperty<" << type(true) << "> " << managed_name << "<T>(this Efl.Ui.ItemFactory<T> fac, Efl.Csharp.ExtensionTag<"
|
||||||
<< name_helpers::klass_full_concrete_or_interface_name(cls) << " {\n"
|
<< name_helpers::klass_full_concrete_or_interface_name(cls)
|
||||||
|
<< ", T>magic = null) where T : " << name_helpers::klass_full_concrete_or_interface_name(cls) << " {\n"
|
||||||
<< scope_tab(2) << scope_tab << "return new Efl.BindableProperty<" << type(true) << ">(\"" << property.name << "\", fac);\n"
|
<< scope_tab(2) << scope_tab << "return new Efl.BindableProperty<" << type(true) << ">(\"" << property.name << "\", fac);\n"
|
||||||
<< scope_tab(2) << "}\n\n"
|
<< scope_tab(2) << "}\n\n"
|
||||||
).generate(sink, std::make_tuple(prop_type, prop_type), context))
|
).generate(sink, std::make_tuple(prop_type, prop_type), context))
|
||||||
|
@ -300,8 +301,9 @@ struct property_extension_method_definition_generator
|
||||||
if (property.setter.is_engaged())
|
if (property.setter.is_engaged())
|
||||||
{
|
{
|
||||||
attributes::type_def prop_type = property.setter->parameters[0].type;
|
attributes::type_def prop_type = property.setter->parameters[0].type;
|
||||||
if (!as_generator(scope_tab(2) << "public static Efl.BindableProperty<" << type(true) << "> " << managed_name << "<T>(this Efl.BindablePart<T> part) where T : "
|
if (!as_generator(scope_tab(2) << "public static Efl.BindableProperty<" << type(true) << "> " << managed_name << "<T>(this Efl.BindablePart<T> part, Efl.Csharp.ExtensionTag<"
|
||||||
<< name_helpers::klass_full_concrete_or_interface_name(cls) << " {\n"
|
<< name_helpers::klass_full_concrete_or_interface_name(cls)
|
||||||
|
<< ", T>magic = null) where T : " << name_helpers::klass_full_concrete_or_interface_name(cls) << " {\n"
|
||||||
<< scope_tab(2) << scope_tab << "Contract.Requires(part != null, nameof(part));\n"
|
<< scope_tab(2) << scope_tab << "Contract.Requires(part != null, nameof(part));\n"
|
||||||
<< scope_tab(2) << scope_tab << "return new Efl.BindableProperty<" << type(true) << ">(part.PartName, \"" << property.name << "\", part.Binder);\n"
|
<< scope_tab(2) << scope_tab << "return new Efl.BindableProperty<" << type(true) << ">(part.PartName, \"" << property.name << "\", part.Binder);\n"
|
||||||
<< scope_tab(2) << "}\n\n"
|
<< scope_tab(2) << "}\n\n"
|
||||||
|
|
|
@ -70,8 +70,9 @@ struct part_extension_method_definition_generator
|
||||||
bindableClass = "Efl.BindableFactoryPart";
|
bindableClass = "Efl.BindableFactoryPart";
|
||||||
|
|
||||||
if (!as_generator(
|
if (!as_generator(
|
||||||
scope_tab(2) << "public static " << bindableClass << "<" << part_klass_name << "> " << name_helpers::managed_part_name(part) << "<T>(this Efl.Ui.ItemFactory<T> fac) where T : "
|
scope_tab(2) << "public static " << bindableClass << "<" << part_klass_name << "> " << name_helpers::managed_part_name(part) << "<T>(this Efl.Ui.ItemFactory<T> fac, Efl.Csharp.ExtensionTag<"
|
||||||
<< name_helpers::klass_full_concrete_or_interface_name(cls) << "\n"
|
<< name_helpers::klass_full_concrete_or_interface_name(cls)
|
||||||
|
<< ", T> x=null) where T : " << name_helpers::klass_full_concrete_or_interface_name(cls) << "\n"
|
||||||
<< scope_tab(2) << "{\n"
|
<< scope_tab(2) << "{\n"
|
||||||
<< scope_tab(2) << scope_tab << "return new " << bindableClass << "<" << part_klass_name << ">(\"" << part.name << "\", fac);\n"
|
<< scope_tab(2) << scope_tab << "return new " << bindableClass << "<" << part_klass_name << ">(\"" << part.name << "\", fac);\n"
|
||||||
<< scope_tab(2) << "}\n\n"
|
<< scope_tab(2) << "}\n\n"
|
||||||
|
|
|
@ -148,6 +148,20 @@ public class BindableFactoryPart<T>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Csharp
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>Helper class to differentiate between factory extension methods.
|
||||||
|
///
|
||||||
|
/// For internal use only.</summary>
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public class ExtensionTag<TBase, TInherited>
|
||||||
|
where TInherited : TBase
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue