aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-01-06 00:28:30 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-01-06 00:37:34 -0300
commit032bcc57bc2104191a1dce8c1131eb18147fefb8 (patch)
treee6b9707c19bc32d7414f8d0713cf6aaa28a0215c
parentefl-mono: Replace init_cb with constructor parameters. (diff)
downloadefl-devs/lauromoura/csharp-beta.tar.gz
efl-mono: WIP Enable selecting to build @beta items.devs/lauromoura/csharp-beta
Still missing making meson call -b on eolian_mono if -Dmono-beta=true is passed to it and add a test to check with reflection if the method is generated or not (This may need passing this config info to the compiled code somehow).
-rw-r--r--meson_options.txt6
-rw-r--r--src/bin/eolian_mono/eolian/mono/async_function_definition.hh4
-rw-r--r--src/bin/eolian_mono/eolian/mono/blacklist.hh25
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_declaration.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh6
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_registration.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/generation_contexts.hh4
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh9
-rw-r--r--src/bin/eolian_mono/eolian_mono.cc11
9 files changed, 56 insertions, 13 deletions
diff --git a/meson_options.txt b/meson_options.txt
index e24f999ee4..d8bb595993 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -328,6 +328,12 @@ option('mono',
description: 'Flag for handling c# bindings'
)
+option('mono-beta',
+ type: 'boolean',
+ value: false,
+ description: 'Flag for enabling @beta Eo methods in the api'
+)
+
option('native-arch-optimization',
type: 'boolean',
value: true,
diff --git a/src/bin/eolian_mono/eolian/mono/async_function_definition.hh b/src/bin/eolian_mono/eolian/mono/async_function_definition.hh
index 1dc705ad3a..5164311ee7 100644
--- a/src/bin/eolian_mono/eolian/mono/async_function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/async_function_definition.hh
@@ -48,7 +48,7 @@ struct async_function_declaration_generator
{
if (f.is_static)
return true;
- if (blacklist::is_function_blacklisted(f.c_name))
+ if (blacklist::is_function_blacklisted(f, context))
return true;
if (!f.return_type.original_type.visit(is_future{}))
return true;
@@ -76,7 +76,7 @@ struct async_function_definition_generator
if(do_super && f.is_static) // Static methods goes only on Concrete classes.
return true;
- if(blacklist::is_function_blacklisted(f.c_name))
+ if(blacklist::is_function_blacklisted(f, context))
return true;
if(!f.return_type.original_type.visit(is_future{}))
return true;
diff --git a/src/bin/eolian_mono/eolian/mono/blacklist.hh b/src/bin/eolian_mono/eolian/mono/blacklist.hh
index 684b842c24..7b8b2e9797 100644
--- a/src/bin/eolian_mono/eolian/mono/blacklist.hh
+++ b/src/bin/eolian_mono/eolian/mono/blacklist.hh
@@ -2,7 +2,9 @@
#define EOLIAN_MONO_BLACKLIST_HH
#include "grammar/klass_def.hpp"
+#include "grammar/context.hpp"
#include "name_helpers.hh"
+#include "generation_contexts.hh"
namespace eolian_mono {
@@ -48,6 +50,19 @@ inline bool is_function_blacklisted(std::string const& c_name)
;
}
+template<typename Context>
+inline bool is_function_blacklisted(attributes::function_def const& func, Context context)
+{
+ auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
+ auto c_name = func.c_name;
+
+ if (func.is_beta && !options.want_beta)
+ return true;
+
+ return is_function_blacklisted(c_name);
+}
+
+
// Blacklist structs that require some kind of manual binding.
inline bool is_struct_blacklisted(std::string const& full_name)
{
@@ -84,9 +99,17 @@ inline bool is_property_blacklisted(std::string const& name)
|| name == "Efl.Text.Text";
}
-inline bool is_property_blacklisted(attributes::property_def const& property)
+template<typename Context>
+inline bool is_property_blacklisted(attributes::property_def const& property, Context context)
{
auto name = name_helpers::klass_full_concrete_or_interface_name(property.klass) + "." + name_helpers::property_managed_name(property);
+
+ if (property.getter.is_engaged())
+ if (is_function_blacklisted(*property.getter, context))
+ return true;
+ if (property.setter.is_engaged())
+ if (is_function_blacklisted(*property.setter, context))
+ return true;
return is_property_blacklisted(name);
}
diff --git a/src/bin/eolian_mono/eolian/mono/function_declaration.hh b/src/bin/eolian_mono/eolian/mono/function_declaration.hh
index 8fdb8269e8..baad0bb33d 100644
--- a/src/bin/eolian_mono/eolian/mono/function_declaration.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_declaration.hh
@@ -20,7 +20,7 @@ struct function_declaration_generator
template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
{
- if(blacklist::is_function_blacklisted(f.c_name) || f.is_static)
+ if(blacklist::is_function_blacklisted(f, context) || f.is_static)
return true;
if(!as_generator(documentation).generate(sink, f, context))
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index b0e2e5ea3c..779d312397 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -32,7 +32,7 @@ struct native_function_definition_generator
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
{
EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_function_definition_generator: " << f.c_name << std::endl;
- if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) // Only Concrete classes implement static methods.
+ if(blacklist::is_function_blacklisted(f, context) || f.is_static) // Only Concrete classes implement static methods.
return true;
else
{
@@ -134,7 +134,7 @@ struct function_definition_generator
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
{
EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_definition_generator: " << f.c_name << std::endl;
- if(blacklist::is_function_blacklisted(f.c_name))
+ if(blacklist::is_function_blacklisted(f, context))
return true;
if(!as_generator
@@ -209,7 +209,7 @@ struct property_wrapper_definition_generator
template<typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::property_def const& property, Context context) const
{
- if (blacklist::is_property_blacklisted(property))
+ if (blacklist::is_property_blacklisted(property, context))
return true;
bool interface = context_find_tag<class_context>(context).current_wrapper_kind == class_context::interface;
diff --git a/src/bin/eolian_mono/eolian/mono/function_registration.hh b/src/bin/eolian_mono/eolian/mono/function_registration.hh
index 0b8da4a05a..3fcd445477 100644
--- a/src/bin/eolian_mono/eolian/mono/function_registration.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_registration.hh
@@ -30,7 +30,7 @@ struct function_registration_generator
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
{
EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_registration_generator: " << f.name << std::endl;
- if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) // Static methods aren't overrideable
+ if(blacklist::is_function_blacklisted(f, context) || f.is_static) // Static methods aren't overrideable
return true;
else
{
diff --git a/src/bin/eolian_mono/eolian/mono/generation_contexts.hh b/src/bin/eolian_mono/eolian/mono/generation_contexts.hh
index ca1ca9e678..9a1493ab25 100644
--- a/src/bin/eolian_mono/eolian/mono/generation_contexts.hh
+++ b/src/bin/eolian_mono/eolian/mono/generation_contexts.hh
@@ -45,6 +45,10 @@ struct eolian_state_context {
const Eolian_State *state;
};
+struct options_context {
+ bool want_beta;
+};
+
}
#endif
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index dcc2767715..dbca44d092 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -71,13 +71,14 @@ static bool generate_equals_method(OutputIterator sink, Context const &context)
}
/* Get the actual number of functions of a class, checking for blacklisted ones */
+template<typename Context>
static std::size_t
-get_implementable_function_count(grammar::attributes::klass_def const& cls)
+get_implementable_function_count(grammar::attributes::klass_def const& cls, Context context)
{
auto methods = helpers::get_all_implementable_methods(cls);
- return std::count_if(methods.cbegin(), methods.cend(), [](grammar::attributes::function_def const& func)
+ return std::count_if(methods.cbegin(), methods.cend(), [&context](grammar::attributes::function_def const& func)
{
- return !blacklist::is_function_blacklisted(func.c_name) && !func.is_static;
+ return !blacklist::is_function_blacklisted(func, context) && !func.is_static;
});
}
@@ -345,7 +346,7 @@ struct klass
if(!as_generator("}\n").generate(sink, attributes::unused, inherit_cxt)) return false;
}
- std::size_t function_count = get_implementable_function_count(cls);
+ std::size_t function_count = get_implementable_function_count(cls, context);
int function_registration_index = 0;
auto index_generator = [&function_registration_index]
diff --git a/src/bin/eolian_mono/eolian_mono.cc b/src/bin/eolian_mono/eolian_mono.cc
index db888816a2..5ee6697a7c 100644
--- a/src/bin/eolian_mono/eolian_mono.cc
+++ b/src/bin/eolian_mono/eolian_mono.cc
@@ -47,6 +47,7 @@ struct options_type
mutable Eolian_Unit const* unit;
int v_major;
int v_minor;
+ bool want_beta;
std::map<const std::string, std::string> references_map;
};
@@ -144,7 +145,9 @@ run(options_type const& opts)
opts.references_map},
efl::eolian::grammar::context_null());
- auto context = efl::eolian::grammar::context_add_tag(eolian_mono::eolian_state_context{opts.state}, lib_context);
+ auto options_context = efl::eolian::grammar::context_add_tag(eolian_mono::options_context{opts.want_beta}, lib_context);
+
+ auto context = efl::eolian::grammar::context_add_tag(eolian_mono::eolian_state_context{opts.state}, options_context);
EINA_ITERATOR_FOREACH(aliases, tp)
{
@@ -273,6 +276,7 @@ _usage(const char *progname)
<< " -n, --namespace <ns> Wrap generated code in a namespace. [Eg: efl::ecore::file]" << std::endl
<< " -r, --recurse Recurse input directories loading .eo files." << std::endl
<< " -v, --version Print the version." << std::endl
+ << " -b, --beta Enable @beta methods." << std::endl
<< " -h, --help Print this help." << std::endl;
exit(EXIT_FAILURE);
}
@@ -302,6 +306,7 @@ opts_get(int argc, char **argv)
{ "vmaj", required_argument, 0, 'M' },
{ "vmin", required_argument, 0, 'm' },
{ "references", required_argument, 0, 'r'},
+ { "beta", no_argument, 0, 'b'},
{ 0, 0, 0, 0 }
};
const char* options = "I:D:o:c:M:m:ar:vh";
@@ -356,6 +361,10 @@ opts_get(int argc, char **argv)
_print_version();
if (argc == 2) exit(EXIT_SUCCESS);
}
+ else if (c == 'b')
+ {
+ opts.want_beta = true;
+ }
}
if (optind == argc-1)
{