summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-07-11 10:19:53 +0200
committerXavi Artigas <xavierartigas@yahoo.es>2019-07-11 10:19:53 +0200
commitfa333608b78eefa836b858eca6fbd9718521d143 (patch)
treedf72232df837e9f8484365b7e2d6d782bfd28428
parent15e5d29f886b296ce2e0d084367e529f550c3307 (diff)
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
-rw-r--r--src/bin/eolian_mono/eolian/mono/helpers.hh15
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh8
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 @@
3 3
4#include "grammar/klass_def.hpp" 4#include "grammar/klass_def.hpp"
5#include "blacklist.hh" 5#include "blacklist.hh"
6#include "generation_contexts.hh"
6#include "name_helpers.hh" 7#include "name_helpers.hh"
7 8
8namespace eolian_mono { 9namespace eolian_mono {
@@ -165,11 +166,19 @@ bool has_regular_ancestor(attributes::klass_def const& cls)
165/* 166/*
166 * Gets all methods that this class should implement (i.e. that come from an unimplemented interface/mixin and the class itself) 167 * Gets all methods that this class should implement (i.e. that come from an unimplemented interface/mixin and the class itself)
167 */ 168 */
168std::vector<attributes::function_def> get_all_implementable_methods(attributes::klass_def const& cls) 169template<typename Context>
170std::vector<attributes::function_def> get_all_implementable_methods(attributes::klass_def const& cls, Context const& context)
169{ 171{
172 bool want_beta = efl::eolian::grammar::context_find_tag<options_context>(context).want_beta;
170 std::vector<attributes::function_def> ret; 173 std::vector<attributes::function_def> ret;
174 auto filter_beta = [&want_beta](attributes::function_def const& func) {
175 if (!want_beta)
176 return !func.is_beta;
177 else
178 return true;
179 };
171 180
172 std::copy(cls.functions.begin(), cls.functions.end(), std::back_inserter(ret)); 181 std::copy_if(cls.functions.begin(), cls.functions.end(), std::back_inserter(ret), filter_beta);
173 182
174 // Non implemented interfaces 183 // Non implemented interfaces
175 std::set<attributes::klass_name, attributes::compare_klass_name_by_name> implemented_interfaces; 184 std::set<attributes::klass_name, attributes::compare_klass_name_by_name> implemented_interfaces;
@@ -206,7 +215,7 @@ std::vector<attributes::function_def> get_all_implementable_methods(attributes::
206 for (auto&& inherit : interfaces) 215 for (auto&& inherit : interfaces)
207 { 216 {
208 attributes::klass_def klass(get_klass(inherit, cls.unit), cls.unit); 217 attributes::klass_def klass(get_klass(inherit, cls.unit), cls.unit);
209 std::copy(klass.functions.cbegin(), klass.functions.cend(), std::back_inserter(ret)); 218 std::copy_if(klass.functions.cbegin(), klass.functions.cend(), std::back_inserter(ret), filter_beta);
210 } 219 }
211 220
212 return ret; 221 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<typename Context>
36static std::size_t 36static std::size_t
37get_implementable_function_count(grammar::attributes::klass_def const& cls, Context context) 37get_implementable_function_count(grammar::attributes::klass_def const& cls, Context context)
38{ 38{
39 auto methods = helpers::get_all_implementable_methods(cls); 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) 40 return std::count_if(methods.cbegin(), methods.cend(), [&context](grammar::attributes::function_def const& func)
41 { 41 {
42 return !blacklist::is_function_blacklisted(func, context) && !func.is_static; 42 return !blacklist::is_function_blacklisted(func, context) && !func.is_static;
@@ -230,7 +230,7 @@ struct klass
230 .generate(sink, cls.parts, concrete_cxt)) return false; 230 .generate(sink, cls.parts, concrete_cxt)) return false;
231 231
232 // Concrete function definitions 232 // Concrete function definitions
233 auto implemented_methods = helpers::get_all_implementable_methods(cls); 233 auto implemented_methods = helpers::get_all_implementable_methods(cls, concrete_cxt);
234 if(!as_generator(*(function_definition)) 234 if(!as_generator(*(function_definition))
235 .generate(sink, implemented_methods, concrete_cxt)) return false; 235 .generate(sink, implemented_methods, concrete_cxt)) return false;
236 236
@@ -302,7 +302,7 @@ struct klass
302 .generate(sink, cls.parts, inherit_cxt)) return false; 302 .generate(sink, cls.parts, inherit_cxt)) return false;
303 303
304 // Inherit function definitions 304 // Inherit function definitions
305 auto implemented_methods = helpers::get_all_implementable_methods(cls); 305 auto implemented_methods = helpers::get_all_implementable_methods(cls, inherit_cxt);
306 if(!as_generator(*(function_definition(true))) 306 if(!as_generator(*(function_definition(true)))
307 .generate(sink, implemented_methods, inherit_cxt)) return false; 307 .generate(sink, implemented_methods, inherit_cxt)) return false;
308 308
@@ -354,7 +354,7 @@ struct klass
354 context); 354 context);
355 auto native_inherit_name = name_helpers::klass_native_inherit_name(cls); 355 auto native_inherit_name = name_helpers::klass_native_inherit_name(cls);
356 auto inherit_name = name_helpers::klass_inherit_name(cls); 356 auto inherit_name = name_helpers::klass_inherit_name(cls);
357 auto implementable_methods = helpers::get_all_implementable_methods(cls); 357 auto implementable_methods = helpers::get_all_implementable_methods(cls, context);
358 bool root = !helpers::has_regular_ancestor(cls); 358 bool root = !helpers::has_regular_ancestor(cls);
359 auto const& indent = current_indentation(inative_cxt); 359 auto const& indent = current_indentation(inative_cxt);
360 360