forked from enlightenment/efl
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
This commit is contained in:
parent
15e5d29f88
commit
fa333608b7
|
@ -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<attributes::function_def> get_all_implementable_methods(attributes::klass_def const& cls)
|
||||
template<typename Context>
|
||||
std::vector<attributes::function_def> get_all_implementable_methods(attributes::klass_def const& cls, Context const& context)
|
||||
{
|
||||
bool want_beta = efl::eolian::grammar::context_find_tag<options_context>(context).want_beta;
|
||||
std::vector<attributes::function_def> 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<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::
|
|||
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;
|
||||
|
|
|
@ -36,7 +36,7 @@ template<typename Context>
|
|||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue