summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYeongjong Lee <yj34.lee@samsung.com>2019-06-24 19:19:00 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2019-06-24 19:19:00 +0900
commit127209ce2b5ec5328b38fc114cd821f469dc755b (patch)
tree8fd9a59ef9d382157a9b939f1366c5d982e131f2
parent86afeee2246ebb9d58dc5676d58df137f5ba764c (diff)
downloadefl-127209ce2b5ec5328b38fc114cd821f469dc755b.tar.gz
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
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh42
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_helpers.hh20
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp13
3 files changed, 70 insertions, 5 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 861092d40a..f2dda1e7ca 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -160,7 +160,7 @@ struct function_definition_generator
function_definition_generator(bool do_super = false)
: do_super(do_super)
{}
-
+
template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
{
@@ -185,7 +185,7 @@ struct function_definition_generator
self = "";
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 "
<< eolian_mono::function_definition_preamble()
<< 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 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(
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))
return false;
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))
return false;
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))
return false;
diff --git a/src/bin/eolian_mono/eolian/mono/function_helpers.hh b/src/bin/eolian_mono/eolian/mono/function_helpers.hh
index c83cbbbf11..0ea25da536 100644
--- a/src/bin/eolian_mono/eolian/mono/function_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_helpers.hh
@@ -163,6 +163,26 @@ function_definition_epilogue_generator const as_generator(function_definition_ep
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 efl { namespace eolian { namespace grammar {
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index d03d52da76..628e2166c5 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -647,6 +647,14 @@ enum class function_type
function_pointer
};
+enum class member_scope
+{
+ scope_unknown,
+ scope_public,
+ scope_private,
+ scope_protected,
+};
+
struct function_def
{
klass_name klass; // Klass information for function_def as method
@@ -660,6 +668,7 @@ struct function_def
documentation_def return_documentation;
documentation_def property_documentation;
function_type type;
+ member_scope scope;
bool is_beta;
bool is_protected;
bool is_static;
@@ -678,6 +687,7 @@ struct function_def
&& lhs.return_documentation == rhs.return_documentation
&& lhs.property_documentation == rhs.property_documentation
&& lhs.type == rhs.type
+ && lhs.scope == rhs.scope
&& lhs.is_beta == rhs.is_beta
&& lhs.is_protected == rhs.is_protected
&& lhs.is_static == rhs.is_static;
@@ -697,6 +707,7 @@ struct function_def
documentation_def _return_documentation,
documentation_def _property_documentation,
function_type _type,
+ member_scope _scope,
bool _is_beta = false,
bool _is_protected = false,
bool _is_static = false,
@@ -708,6 +719,7 @@ struct function_def
return_documentation(_return_documentation),
property_documentation(_property_documentation),
type(_type),
+ scope(_scope),
is_beta(_is_beta), is_protected(_is_protected),
is_static(_is_static),
unit(unit) {}
@@ -718,6 +730,7 @@ struct function_def
Eolian_Type const* r_type = ::eolian_function_return_type_get(function, type);
name = ::eolian_function_name_get(function);
return_documentation = eolian_function_return_documentation_get(function, type);
+ scope = static_cast<member_scope>(eolian_function_scope_get(function, type));
if(r_type)
return_type.set(r_type, unit, EOLIAN_C_TYPE_RETURN);
if(type == EOLIAN_METHOD || type == EOLIAN_FUNCTION_POINTER)