From fa333608b78eefa836b858eca6fbd9718521d143 Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Thu, 11 Jul 2019 10:19:53 +0200 Subject: [PATCH] csharp: Respect beta for implementable functions Summary: Build fix (remove warnings) Instead of returning the beta functions in the vector and relying on function generators to skip them, filter them out when filling the implementable methods vector. This will make the code return the actual number of implementable function, skipping some unused fields in places like the NativeMethods implementations. Depends on D9258 Reviewers: vitor.sousa, felipealmeida, segfaultxavi Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl, #expertise_solutions Differential Revision: https://phab.enlightenment.org/D9259 --- src/bin/eolian_mono/eolian/mono/helpers.hh | 15 ++++++++++++--- src/bin/eolian_mono/eolian/mono/klass.hh | 8 ++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/bin/eolian_mono/eolian/mono/helpers.hh b/src/bin/eolian_mono/eolian/mono/helpers.hh index dffb38b820..c3e1114c98 100644 --- a/src/bin/eolian_mono/eolian/mono/helpers.hh +++ b/src/bin/eolian_mono/eolian/mono/helpers.hh @@ -3,6 +3,7 @@ #include "grammar/klass_def.hpp" #include "blacklist.hh" +#include "generation_contexts.hh" #include "name_helpers.hh" namespace eolian_mono { @@ -165,11 +166,19 @@ bool has_regular_ancestor(attributes::klass_def const& cls) /* * Gets all methods that this class should implement (i.e. that come from an unimplemented interface/mixin and the class itself) */ -std::vector get_all_implementable_methods(attributes::klass_def const& cls) +template +std::vector get_all_implementable_methods(attributes::klass_def const& cls, Context const& context) { + bool want_beta = efl::eolian::grammar::context_find_tag(context).want_beta; std::vector ret; + auto filter_beta = [&want_beta](attributes::function_def const& func) { + if (!want_beta) + return !func.is_beta; + else + return true; + }; - std::copy(cls.functions.begin(), cls.functions.end(), std::back_inserter(ret)); + std::copy_if(cls.functions.begin(), cls.functions.end(), std::back_inserter(ret), filter_beta); // Non implemented interfaces std::set implemented_interfaces; @@ -206,7 +215,7 @@ std::vector get_all_implementable_methods(attributes:: for (auto&& inherit : interfaces) { attributes::klass_def klass(get_klass(inherit, cls.unit), cls.unit); - std::copy(klass.functions.cbegin(), klass.functions.cend(), std::back_inserter(ret)); + std::copy_if(klass.functions.cbegin(), klass.functions.cend(), std::back_inserter(ret), filter_beta); } return ret; diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh index c34d7c06e0..831f48d85b 100644 --- a/src/bin/eolian_mono/eolian/mono/klass.hh +++ b/src/bin/eolian_mono/eolian/mono/klass.hh @@ -36,7 +36,7 @@ template static std::size_t get_implementable_function_count(grammar::attributes::klass_def const& cls, Context context) { - auto methods = helpers::get_all_implementable_methods(cls); + auto methods = helpers::get_all_implementable_methods(cls, context); return std::count_if(methods.cbegin(), methods.cend(), [&context](grammar::attributes::function_def const& func) { return !blacklist::is_function_blacklisted(func, context) && !func.is_static; @@ -230,7 +230,7 @@ struct klass .generate(sink, cls.parts, concrete_cxt)) return false; // Concrete function definitions - auto implemented_methods = helpers::get_all_implementable_methods(cls); + auto implemented_methods = helpers::get_all_implementable_methods(cls, concrete_cxt); if(!as_generator(*(function_definition)) .generate(sink, implemented_methods, concrete_cxt)) return false; @@ -302,7 +302,7 @@ struct klass .generate(sink, cls.parts, inherit_cxt)) return false; // Inherit function definitions - auto implemented_methods = helpers::get_all_implementable_methods(cls); + auto implemented_methods = helpers::get_all_implementable_methods(cls, inherit_cxt); if(!as_generator(*(function_definition(true))) .generate(sink, implemented_methods, inherit_cxt)) return false; @@ -354,7 +354,7 @@ struct klass context); auto native_inherit_name = name_helpers::klass_native_inherit_name(cls); auto inherit_name = name_helpers::klass_inherit_name(cls); - auto implementable_methods = helpers::get_all_implementable_methods(cls); + auto implementable_methods = helpers::get_all_implementable_methods(cls, context); bool root = !helpers::has_regular_ancestor(cls); auto const& indent = current_indentation(inative_cxt);