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)
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
160 function_definition_generator(bool do_super = false) 160 function_definition_generator(bool do_super = false)
161 : do_super(do_super) 161 : do_super(do_super)
162 {} 162 {}
163 163
164 template <typename OutputIterator, typename Context> 164 template <typename OutputIterator, typename Context>
165 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 165 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
166 { 166 {
@@ -185,7 +185,7 @@ struct function_definition_generator
185 self = ""; 185 self = "";
186 186
187 if(!as_generator 187 if(!as_generator
188 (scope_tab << ((do_super && !f.is_static) ? "virtual " : "") << "public " << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ") 188 (scope_tab << ((do_super && !f.is_static) ? "virtual " : "") << eolian_mono::function_scope_get(f) << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ")
189 << ") {\n " 189 << ") {\n "
190 << eolian_mono::function_definition_preamble() 190 << eolian_mono::function_definition_preamble()
191 << klass_full_native_inherit_name(f.klass) << "." << string << "_ptr.Value.Delegate(" 191 << klass_full_native_inherit_name(f.klass) << "." << string << "_ptr.Value.Delegate("
@@ -268,19 +268,51 @@ struct property_wrapper_definition_generator
268 268
269 std::string managed_name = name_helpers::property_managed_name(property); 269 std::string managed_name = name_helpers::property_managed_name(property);
270 270
271 std::string scope = "public ";
272 std::string get_scope = property.getter.is_engaged() ? eolian_mono::function_scope_get(*property.getter) : "";
273 std::string set_scope = property.setter.is_engaged() ? eolian_mono::function_scope_get(*property.setter) : "";
274 if (interface)
275 {
276 scope = "";
277 get_scope = "";
278 set_scope = "";
279 }
280 else if ((property.klass.type == attributes::class_type::mixin) ||
281 (property.klass.type == attributes::class_type::interface_))
282 {
283 get_scope = "";
284 set_scope = "";
285 }
286 else if ((get_scope != "") && (get_scope == set_scope))
287 {
288 scope = get_scope;
289 get_scope = "";
290 set_scope = "";
291 }
292 else if (!property.setter.is_engaged() || (get_scope == scope))
293 {
294 scope = get_scope;
295 get_scope = "";
296 }
297 else if (!property.getter.is_engaged() || (set_scope == scope))
298 {
299 scope = set_scope;
300 set_scope = "";
301 }
302
271 if (!as_generator( 303 if (!as_generator(
272 documentation(1) 304 documentation(1)
273 << scope_tab << (interface ? "" : "public ") << (is_static ? "static " : "") << type(true) << " " << managed_name << " {\n" 305 << scope_tab << scope << (is_static ? "static " : "") << type(true) << " " << managed_name << " {\n"
274 ).generate(sink, std::make_tuple(property, prop_type), context)) 306 ).generate(sink, std::make_tuple(property, prop_type), context))
275 return false; 307 return false;
276 308
277 if (property.getter.is_engaged()) 309 if (property.getter.is_engaged())
278 if (!as_generator(scope_tab << scope_tab << "get " << (interface ? ";" : "{ return " + name_helpers::managed_method_name(*property.getter) + "(); }") << "\n" 310 if (!as_generator(scope_tab << scope_tab << get_scope << "get " << (interface ? ";" : "{ return " + name_helpers::managed_method_name(*property.getter) + "(); }") << "\n"
279 ).generate(sink, attributes::unused, context)) 311 ).generate(sink, attributes::unused, context))
280 return false; 312 return false;
281 313
282 if (property.setter.is_engaged()) 314 if (property.setter.is_engaged())
283 if (!as_generator(scope_tab << scope_tab << "set " << (interface ? ";" : "{ " + name_helpers::managed_method_name(*property.setter) + "(" + dir_mod + "value); }") << "\n" 315 if (!as_generator(scope_tab << scope_tab << set_scope << "set " << (interface ? ";" : "{ " + name_helpers::managed_method_name(*property.setter) + "(" + dir_mod + "value); }") << "\n"
284 ).generate(sink, attributes::unused, context)) 316 ).generate(sink, attributes::unused, context))
285 return false; 317 return false;
286 318
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
163 return function_definition_epilogue_generator{}; 163 return function_definition_epilogue_generator{};
164} 164}
165 165
166inline std::string function_scope_get(attributes::function_def const& f)
167{
168 if ((f.klass.type == attributes::class_type::mixin) ||
169 (f.klass.type == attributes::class_type::interface_))
170 return "public ";
171
172 switch (f.scope)
173 {
174 case attributes::member_scope::scope_public:
175 return "public ";
176 case attributes::member_scope::scope_private:
177 return "private ";
178 case attributes::member_scope::scope_protected:
179 return "protected ";
180 case attributes::member_scope::scope_unknown:
181 return " ";
182 }
183 return " ";
184}
185
166} // namespace eolian_mono 186} // namespace eolian_mono
167 187
168namespace efl { namespace eolian { namespace grammar { 188namespace 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
647 function_pointer 647 function_pointer
648}; 648};
649 649
650enum class member_scope
651{
652 scope_unknown,
653 scope_public,
654 scope_private,
655 scope_protected,
656};
657
650struct function_def 658struct function_def
651{ 659{
652 klass_name klass; // Klass information for function_def as method 660 klass_name klass; // Klass information for function_def as method
@@ -660,6 +668,7 @@ struct function_def
660 documentation_def return_documentation; 668 documentation_def return_documentation;
661 documentation_def property_documentation; 669 documentation_def property_documentation;
662 function_type type; 670 function_type type;
671 member_scope scope;
663 bool is_beta; 672 bool is_beta;
664 bool is_protected; 673 bool is_protected;
665 bool is_static; 674 bool is_static;
@@ -678,6 +687,7 @@ struct function_def
678 && lhs.return_documentation == rhs.return_documentation 687 && lhs.return_documentation == rhs.return_documentation
679 && lhs.property_documentation == rhs.property_documentation 688 && lhs.property_documentation == rhs.property_documentation
680 && lhs.type == rhs.type 689 && lhs.type == rhs.type
690 && lhs.scope == rhs.scope
681 && lhs.is_beta == rhs.is_beta 691 && lhs.is_beta == rhs.is_beta
682 && lhs.is_protected == rhs.is_protected 692 && lhs.is_protected == rhs.is_protected
683 && lhs.is_static == rhs.is_static; 693 && lhs.is_static == rhs.is_static;
@@ -697,6 +707,7 @@ struct function_def
697 documentation_def _return_documentation, 707 documentation_def _return_documentation,
698 documentation_def _property_documentation, 708 documentation_def _property_documentation,
699 function_type _type, 709 function_type _type,
710 member_scope _scope,
700 bool _is_beta = false, 711 bool _is_beta = false,
701 bool _is_protected = false, 712 bool _is_protected = false,
702 bool _is_static = false, 713 bool _is_static = false,
@@ -708,6 +719,7 @@ struct function_def
708 return_documentation(_return_documentation), 719 return_documentation(_return_documentation),
709 property_documentation(_property_documentation), 720 property_documentation(_property_documentation),
710 type(_type), 721 type(_type),
722 scope(_scope),
711 is_beta(_is_beta), is_protected(_is_protected), 723 is_beta(_is_beta), is_protected(_is_protected),
712 is_static(_is_static), 724 is_static(_is_static),
713 unit(unit) {} 725 unit(unit) {}
@@ -718,6 +730,7 @@ struct function_def
718 Eolian_Type const* r_type = ::eolian_function_return_type_get(function, type); 730 Eolian_Type const* r_type = ::eolian_function_return_type_get(function, type);
719 name = ::eolian_function_name_get(function); 731 name = ::eolian_function_name_get(function);
720 return_documentation = eolian_function_return_documentation_get(function, type); 732 return_documentation = eolian_function_return_documentation_get(function, type);
733 scope = static_cast<member_scope>(eolian_function_scope_get(function, type));
721 if(r_type) 734 if(r_type)
722 return_type.set(r_type, unit, EOLIAN_C_TYPE_RETURN); 735 return_type.set(r_type, unit, EOLIAN_C_TYPE_RETURN);
723 if(type == EOLIAN_METHOD || type == EOLIAN_FUNCTION_POINTER) 736 if(type == EOLIAN_METHOD || type == EOLIAN_FUNCTION_POINTER)