forked from enlightenment/efl
eolian_mono: support eo access modifiers
Summary: Because in C# interface members can't include access modifiers, eolian_mono ignore function scope tags in eo interfaces. ref T7494 Reviewers: q66, felipealmeida, lauromoura, segfaultxavi, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7494 Differential Revision: https://phab.enlightenment.org/D9128
This commit is contained in:
parent
86afeee224
commit
127209ce2b
|
@ -185,7 +185,7 @@ struct function_definition_generator
|
||||||
self = "";
|
self = "";
|
||||||
|
|
||||||
if(!as_generator
|
if(!as_generator
|
||||||
(scope_tab << ((do_super && !f.is_static) ? "virtual " : "") << "public " << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ")
|
(scope_tab << ((do_super && !f.is_static) ? "virtual " : "") << eolian_mono::function_scope_get(f) << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ")
|
||||||
<< ") {\n "
|
<< ") {\n "
|
||||||
<< eolian_mono::function_definition_preamble()
|
<< eolian_mono::function_definition_preamble()
|
||||||
<< klass_full_native_inherit_name(f.klass) << "." << string << "_ptr.Value.Delegate("
|
<< klass_full_native_inherit_name(f.klass) << "." << string << "_ptr.Value.Delegate("
|
||||||
|
@ -268,19 +268,51 @@ struct property_wrapper_definition_generator
|
||||||
|
|
||||||
std::string managed_name = name_helpers::property_managed_name(property);
|
std::string managed_name = name_helpers::property_managed_name(property);
|
||||||
|
|
||||||
|
std::string scope = "public ";
|
||||||
|
std::string get_scope = property.getter.is_engaged() ? eolian_mono::function_scope_get(*property.getter) : "";
|
||||||
|
std::string set_scope = property.setter.is_engaged() ? eolian_mono::function_scope_get(*property.setter) : "";
|
||||||
|
if (interface)
|
||||||
|
{
|
||||||
|
scope = "";
|
||||||
|
get_scope = "";
|
||||||
|
set_scope = "";
|
||||||
|
}
|
||||||
|
else if ((property.klass.type == attributes::class_type::mixin) ||
|
||||||
|
(property.klass.type == attributes::class_type::interface_))
|
||||||
|
{
|
||||||
|
get_scope = "";
|
||||||
|
set_scope = "";
|
||||||
|
}
|
||||||
|
else if ((get_scope != "") && (get_scope == set_scope))
|
||||||
|
{
|
||||||
|
scope = get_scope;
|
||||||
|
get_scope = "";
|
||||||
|
set_scope = "";
|
||||||
|
}
|
||||||
|
else if (!property.setter.is_engaged() || (get_scope == scope))
|
||||||
|
{
|
||||||
|
scope = get_scope;
|
||||||
|
get_scope = "";
|
||||||
|
}
|
||||||
|
else if (!property.getter.is_engaged() || (set_scope == scope))
|
||||||
|
{
|
||||||
|
scope = set_scope;
|
||||||
|
set_scope = "";
|
||||||
|
}
|
||||||
|
|
||||||
if (!as_generator(
|
if (!as_generator(
|
||||||
documentation(1)
|
documentation(1)
|
||||||
<< scope_tab << (interface ? "" : "public ") << (is_static ? "static " : "") << type(true) << " " << managed_name << " {\n"
|
<< scope_tab << scope << (is_static ? "static " : "") << type(true) << " " << managed_name << " {\n"
|
||||||
).generate(sink, std::make_tuple(property, prop_type), context))
|
).generate(sink, std::make_tuple(property, prop_type), context))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (property.getter.is_engaged())
|
if (property.getter.is_engaged())
|
||||||
if (!as_generator(scope_tab << scope_tab << "get " << (interface ? ";" : "{ return " + name_helpers::managed_method_name(*property.getter) + "(); }") << "\n"
|
if (!as_generator(scope_tab << scope_tab << get_scope << "get " << (interface ? ";" : "{ return " + name_helpers::managed_method_name(*property.getter) + "(); }") << "\n"
|
||||||
).generate(sink, attributes::unused, context))
|
).generate(sink, attributes::unused, context))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (property.setter.is_engaged())
|
if (property.setter.is_engaged())
|
||||||
if (!as_generator(scope_tab << scope_tab << "set " << (interface ? ";" : "{ " + name_helpers::managed_method_name(*property.setter) + "(" + dir_mod + "value); }") << "\n"
|
if (!as_generator(scope_tab << scope_tab << set_scope << "set " << (interface ? ";" : "{ " + name_helpers::managed_method_name(*property.setter) + "(" + dir_mod + "value); }") << "\n"
|
||||||
).generate(sink, attributes::unused, context))
|
).generate(sink, attributes::unused, context))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,26 @@ function_definition_epilogue_generator const as_generator(function_definition_ep
|
||||||
return function_definition_epilogue_generator{};
|
return function_definition_epilogue_generator{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string function_scope_get(attributes::function_def const& f)
|
||||||
|
{
|
||||||
|
if ((f.klass.type == attributes::class_type::mixin) ||
|
||||||
|
(f.klass.type == attributes::class_type::interface_))
|
||||||
|
return "public ";
|
||||||
|
|
||||||
|
switch (f.scope)
|
||||||
|
{
|
||||||
|
case attributes::member_scope::scope_public:
|
||||||
|
return "public ";
|
||||||
|
case attributes::member_scope::scope_private:
|
||||||
|
return "private ";
|
||||||
|
case attributes::member_scope::scope_protected:
|
||||||
|
return "protected ";
|
||||||
|
case attributes::member_scope::scope_unknown:
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace eolian_mono
|
} // namespace eolian_mono
|
||||||
|
|
||||||
namespace efl { namespace eolian { namespace grammar {
|
namespace efl { namespace eolian { namespace grammar {
|
||||||
|
|
|
@ -647,6 +647,14 @@ enum class function_type
|
||||||
function_pointer
|
function_pointer
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class member_scope
|
||||||
|
{
|
||||||
|
scope_unknown,
|
||||||
|
scope_public,
|
||||||
|
scope_private,
|
||||||
|
scope_protected,
|
||||||
|
};
|
||||||
|
|
||||||
struct function_def
|
struct function_def
|
||||||
{
|
{
|
||||||
klass_name klass; // Klass information for function_def as method
|
klass_name klass; // Klass information for function_def as method
|
||||||
|
@ -660,6 +668,7 @@ struct function_def
|
||||||
documentation_def return_documentation;
|
documentation_def return_documentation;
|
||||||
documentation_def property_documentation;
|
documentation_def property_documentation;
|
||||||
function_type type;
|
function_type type;
|
||||||
|
member_scope scope;
|
||||||
bool is_beta;
|
bool is_beta;
|
||||||
bool is_protected;
|
bool is_protected;
|
||||||
bool is_static;
|
bool is_static;
|
||||||
|
@ -678,6 +687,7 @@ struct function_def
|
||||||
&& lhs.return_documentation == rhs.return_documentation
|
&& lhs.return_documentation == rhs.return_documentation
|
||||||
&& lhs.property_documentation == rhs.property_documentation
|
&& lhs.property_documentation == rhs.property_documentation
|
||||||
&& lhs.type == rhs.type
|
&& lhs.type == rhs.type
|
||||||
|
&& lhs.scope == rhs.scope
|
||||||
&& lhs.is_beta == rhs.is_beta
|
&& lhs.is_beta == rhs.is_beta
|
||||||
&& lhs.is_protected == rhs.is_protected
|
&& lhs.is_protected == rhs.is_protected
|
||||||
&& lhs.is_static == rhs.is_static;
|
&& lhs.is_static == rhs.is_static;
|
||||||
|
@ -697,6 +707,7 @@ struct function_def
|
||||||
documentation_def _return_documentation,
|
documentation_def _return_documentation,
|
||||||
documentation_def _property_documentation,
|
documentation_def _property_documentation,
|
||||||
function_type _type,
|
function_type _type,
|
||||||
|
member_scope _scope,
|
||||||
bool _is_beta = false,
|
bool _is_beta = false,
|
||||||
bool _is_protected = false,
|
bool _is_protected = false,
|
||||||
bool _is_static = false,
|
bool _is_static = false,
|
||||||
|
@ -708,6 +719,7 @@ struct function_def
|
||||||
return_documentation(_return_documentation),
|
return_documentation(_return_documentation),
|
||||||
property_documentation(_property_documentation),
|
property_documentation(_property_documentation),
|
||||||
type(_type),
|
type(_type),
|
||||||
|
scope(_scope),
|
||||||
is_beta(_is_beta), is_protected(_is_protected),
|
is_beta(_is_beta), is_protected(_is_protected),
|
||||||
is_static(_is_static),
|
is_static(_is_static),
|
||||||
unit(unit) {}
|
unit(unit) {}
|
||||||
|
@ -718,6 +730,7 @@ struct function_def
|
||||||
Eolian_Type const* r_type = ::eolian_function_return_type_get(function, type);
|
Eolian_Type const* r_type = ::eolian_function_return_type_get(function, type);
|
||||||
name = ::eolian_function_name_get(function);
|
name = ::eolian_function_name_get(function);
|
||||||
return_documentation = eolian_function_return_documentation_get(function, type);
|
return_documentation = eolian_function_return_documentation_get(function, type);
|
||||||
|
scope = static_cast<member_scope>(eolian_function_scope_get(function, type));
|
||||||
if(r_type)
|
if(r_type)
|
||||||
return_type.set(r_type, unit, EOLIAN_C_TYPE_RETURN);
|
return_type.set(r_type, unit, EOLIAN_C_TYPE_RETURN);
|
||||||
if(type == EOLIAN_METHOD || type == EOLIAN_FUNCTION_POINTER)
|
if(type == EOLIAN_METHOD || type == EOLIAN_FUNCTION_POINTER)
|
||||||
|
|
Loading…
Reference in New Issue