summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/klass.hh
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-09-10 19:30:46 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-09-10 19:30:47 -0300
commitdfb856158c8ea37d9caa170a6794447ec18ecdd9 (patch)
tree7d9130fac1c8d4a46341192feb965d842279f2fc /src/bin/eolian_mono/eolian/mono/klass.hh
parentd1890f5eca0b439c902999716ed0a49634e848a1 (diff)
csharp: Skip non-public members from interfaces
Summary: Eolian allows non-public members in interfaces and mixins (usually @protected). As both kinds are converted to C# interfaces, this causes problem as non-public members are forbidden in C# interfaces. This commit changes eolian_mono by removing those members from the C# interfaces. If a generated class implements the interface, the method is generated as if it were a protected member of the class directly. For mixed properties like `Efl.Io.Reader.CanRead { get; set @protected; }`, the interface has only the public getter and the the implementing class has both the public getter and the protected setter. With this, C# devs won't be able to directly implement protected Eo methods from interfaces. (But this really does not make sense from the C# point of view). ref T7494 Reviewers: segfaultxavi, felipealmeida, YOhoho Reviewed By: YOhoho Subscribers: cedric, brunobelo, Jaehyun_Cho, #reviewers, woohyun, #committers Tags: #efl Maniphest Tasks: T7494 Differential Revision: https://phab.enlightenment.org/D9800
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/klass.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index 81d1070..80ac37c 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -31,18 +31,6 @@
31 31
32namespace eolian_mono { 32namespace eolian_mono {
33 33
34/* Get the actual number of functions of a class, checking for blacklisted ones */
35template<typename Context>
36static std::size_t
37get_implementable_function_count(grammar::attributes::klass_def const& cls, Context context)
38{
39 auto methods = helpers::get_all_implementable_methods(cls, context);
40 return std::count_if(methods.cbegin(), methods.cend(), [&context](grammar::attributes::function_def const& func)
41 {
42 return !blacklist::is_function_blacklisted(func, context) && !func.is_static;
43 });
44}
45
46template<typename Context> 34template<typename Context>
47static bool 35static bool
48is_inherit_context(Context const& context) 36is_inherit_context(Context const& context)
@@ -239,6 +227,9 @@ struct klass
239 if (!generate_events(sink, cls, concrete_cxt)) 227 if (!generate_events(sink, cls, concrete_cxt))
240 return false; 228 return false;
241 229
230 if (!as_generator(lit("#pragma warning disable CS0628\n")).generate(sink, attributes::unused, concrete_cxt))
231 return false;
232
242 // Parts 233 // Parts
243 if(!as_generator(*(part_definition)) 234 if(!as_generator(*(part_definition))
244 .generate(sink, cls.parts, concrete_cxt)) return false; 235 .generate(sink, cls.parts, concrete_cxt)) return false;
@@ -263,6 +254,9 @@ struct klass
263 return false; 254 return false;
264 } 255 }
265 256
257 if (!as_generator(lit("#pragma warning restore CS0628\n")).generate(sink, attributes::unused, concrete_cxt))
258 return false;
259
266 // Copied from nativeinherit class, used when setting up providers. 260 // Copied from nativeinherit class, used when setting up providers.
267 if(!as_generator( 261 if(!as_generator(
268 scope_tab << "private static IntPtr GetEflClassStatic()\n" 262 scope_tab << "private static IntPtr GetEflClassStatic()\n"
@@ -398,7 +392,7 @@ struct klass
398 context); 392 context);
399 auto native_inherit_name = name_helpers::klass_native_inherit_name(cls); 393 auto native_inherit_name = name_helpers::klass_native_inherit_name(cls);
400 auto inherit_name = name_helpers::klass_inherit_name(cls); 394 auto inherit_name = name_helpers::klass_inherit_name(cls);
401 auto implementable_methods = cls.functions; 395 auto implementable_methods = helpers::get_all_registerable_methods(cls, context);
402 bool root = !helpers::has_regular_ancestor(cls); 396 bool root = !helpers::has_regular_ancestor(cls);
403 auto const& indent = current_indentation(inative_cxt); 397 auto const& indent = current_indentation(inative_cxt);
404 398