summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-01-17 21:43:57 +0900
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-01-17 21:45:49 +0900
commit586bc5207e63bd8f622f466749781e397fc5e921 (patch)
tree41cea82422433821ecd6a2ab55f15fbf20c7aec8 /src/bin/eolian_mono
parentadc2e674af528c01ca5bb11d56edc475bce5cc4d (diff)
efl-mono: Enable selecting to build @beta items
Summary: For autotools, use --enable-csharp-beta to enable the generation of beta methods and properties, for meson use -Dmono-beta=true. By default, no beta method or property is generated. Reviewers: woohyun, segfaultxavi, bu5hm4n, lauromoura Reviewed By: woohyun Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7637
Diffstat (limited to 'src/bin/eolian_mono')
-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.hh7
-rw-r--r--src/bin/eolian_mono/eolian_mono.cc13
8 files changed, 50 insertions, 13 deletions
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 1dc705a..5164311 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
48 { 48 {
49 if (f.is_static) 49 if (f.is_static)
50 return true; 50 return true;
51 if (blacklist::is_function_blacklisted(f.c_name)) 51 if (blacklist::is_function_blacklisted(f, context))
52 return true; 52 return true;
53 if (!f.return_type.original_type.visit(is_future{})) 53 if (!f.return_type.original_type.visit(is_future{}))
54 return true; 54 return true;
@@ -76,7 +76,7 @@ struct async_function_definition_generator
76 76
77 if(do_super && f.is_static) // Static methods goes only on Concrete classes. 77 if(do_super && f.is_static) // Static methods goes only on Concrete classes.
78 return true; 78 return true;
79 if(blacklist::is_function_blacklisted(f.c_name)) 79 if(blacklist::is_function_blacklisted(f, context))
80 return true; 80 return true;
81 if(!f.return_type.original_type.visit(is_future{})) 81 if(!f.return_type.original_type.visit(is_future{}))
82 return true; 82 return true;
diff --git a/src/bin/eolian_mono/eolian/mono/blacklist.hh b/src/bin/eolian_mono/eolian/mono/blacklist.hh
index fff61c7..c11437b 100644
--- a/src/bin/eolian_mono/eolian/mono/blacklist.hh
+++ b/src/bin/eolian_mono/eolian/mono/blacklist.hh
@@ -2,7 +2,9 @@
2#define EOLIAN_MONO_BLACKLIST_HH 2#define EOLIAN_MONO_BLACKLIST_HH
3 3
4#include "grammar/klass_def.hpp" 4#include "grammar/klass_def.hpp"
5#include "grammar/context.hpp"
5#include "name_helpers.hh" 6#include "name_helpers.hh"
7#include "generation_contexts.hh"
6 8
7namespace eolian_mono { 9namespace eolian_mono {
8 10
@@ -49,6 +51,19 @@ inline bool is_function_blacklisted(std::string const& c_name)
49 ; 51 ;
50} 52}
51 53
54template<typename Context>
55inline bool is_function_blacklisted(attributes::function_def const& func, Context context)
56{
57 auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
58 auto c_name = func.c_name;
59
60 if (func.is_beta && !options.want_beta)
61 return true;
62
63 return is_function_blacklisted(c_name);
64}
65
66
52// Blacklist structs that require some kind of manual binding. 67// Blacklist structs that require some kind of manual binding.
53inline bool is_struct_blacklisted(std::string const& full_name) 68inline bool is_struct_blacklisted(std::string const& full_name)
54{ 69{
@@ -85,9 +100,17 @@ inline bool is_property_blacklisted(std::string const& name)
85 || name == "Efl.Text.Text"; 100 || name == "Efl.Text.Text";
86} 101}
87 102
88inline bool is_property_blacklisted(attributes::property_def const& property) 103template<typename Context>
104inline bool is_property_blacklisted(attributes::property_def const& property, Context context)
89{ 105{
90 auto name = name_helpers::klass_full_concrete_or_interface_name(property.klass) + "." + name_helpers::property_managed_name(property); 106 auto name = name_helpers::klass_full_concrete_or_interface_name(property.klass) + "." + name_helpers::property_managed_name(property);
107
108 if (property.getter.is_engaged())
109 if (is_function_blacklisted(*property.getter, context))
110 return true;
111 if (property.setter.is_engaged())
112 if (is_function_blacklisted(*property.setter, context))
113 return true;
91 return is_property_blacklisted(name); 114 return is_property_blacklisted(name);
92} 115}
93 116
diff --git a/src/bin/eolian_mono/eolian/mono/function_declaration.hh b/src/bin/eolian_mono/eolian/mono/function_declaration.hh
index 8fdb826..baad0bb 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
20 template <typename OutputIterator, typename Context> 20 template <typename OutputIterator, typename Context>
21 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 21 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
22 { 22 {
23 if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) 23 if(blacklist::is_function_blacklisted(f, context) || f.is_static)
24 return true; 24 return true;
25 25
26 if(!as_generator(documentation).generate(sink, f, context)) 26 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 2d9e1b5..6917870 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
32 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 32 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
33 { 33 {
34 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_function_definition_generator: " << f.c_name << std::endl; 34 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_function_definition_generator: " << f.c_name << std::endl;
35 if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) // Only Concrete classes implement static methods. 35 if(blacklist::is_function_blacklisted(f, context) || f.is_static) // Only Concrete classes implement static methods.
36 return true; 36 return true;
37 else 37 else
38 { 38 {
@@ -138,7 +138,7 @@ struct function_definition_generator
138 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 138 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
139 { 139 {
140 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_definition_generator: " << f.c_name << std::endl; 140 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_definition_generator: " << f.c_name << std::endl;
141 if(blacklist::is_function_blacklisted(f.c_name)) 141 if(blacklist::is_function_blacklisted(f, context))
142 return true; 142 return true;
143 143
144 if(!as_generator 144 if(!as_generator
@@ -213,7 +213,7 @@ struct property_wrapper_definition_generator
213 template<typename OutputIterator, typename Context> 213 template<typename OutputIterator, typename Context>
214 bool generate(OutputIterator sink, attributes::property_def const& property, Context context) const 214 bool generate(OutputIterator sink, attributes::property_def const& property, Context context) const
215 { 215 {
216 if (blacklist::is_property_blacklisted(property)) 216 if (blacklist::is_property_blacklisted(property, context))
217 return true; 217 return true;
218 218
219 bool interface = context_find_tag<class_context>(context).current_wrapper_kind == class_context::interface; 219 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 78f2d71..90cbbc4 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
30 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 30 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
31 { 31 {
32 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_registration_generator: " << f.name << std::endl; 32 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_registration_generator: " << f.name << std::endl;
33 if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) // Static methods aren't overrideable 33 if(blacklist::is_function_blacklisted(f, context) || f.is_static) // Static methods aren't overrideable
34 return true; 34 return true;
35 else 35 else
36 { 36 {
diff --git a/src/bin/eolian_mono/eolian/mono/generation_contexts.hh b/src/bin/eolian_mono/eolian/mono/generation_contexts.hh
index ca1ca9e..9a1493a 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 {
45 const Eolian_State *state; 45 const Eolian_State *state;
46}; 46};
47 47
48struct options_context {
49 bool want_beta;
50};
51
48} 52}
49 53
50#endif 54#endif
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index c3d430e..6a2c818 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)
71} 71}
72 72
73/* Get the actual number of functions of a class, checking for blacklisted ones */ 73/* Get the actual number of functions of a class, checking for blacklisted ones */
74template<typename Context>
74static std::size_t 75static std::size_t
75get_implementable_function_count(grammar::attributes::klass_def const& cls) 76get_implementable_function_count(grammar::attributes::klass_def const& cls, Context context)
76{ 77{
77 auto methods = helpers::get_all_implementable_methods(cls); 78 auto methods = helpers::get_all_implementable_methods(cls);
78 return std::count_if(methods.cbegin(), methods.cend(), [](grammar::attributes::function_def const& func) 79 return std::count_if(methods.cbegin(), methods.cend(), [&context](grammar::attributes::function_def const& func)
79 { 80 {
80 return !blacklist::is_function_blacklisted(func.c_name) && !func.is_static; 81 return !blacklist::is_function_blacklisted(func, context) && !func.is_static;
81 }); 82 });
82} 83}
83 84
diff --git a/src/bin/eolian_mono/eolian_mono.cc b/src/bin/eolian_mono/eolian_mono.cc
index db88881..235f250 100644
--- a/src/bin/eolian_mono/eolian_mono.cc
+++ b/src/bin/eolian_mono/eolian_mono.cc
@@ -47,6 +47,7 @@ struct options_type
47 mutable Eolian_Unit const* unit; 47 mutable Eolian_Unit const* unit;
48 int v_major; 48 int v_major;
49 int v_minor; 49 int v_minor;
50 bool want_beta;
50 std::map<const std::string, std::string> references_map; 51 std::map<const std::string, std::string> references_map;
51}; 52};
52 53
@@ -144,7 +145,9 @@ run(options_type const& opts)
144 opts.references_map}, 145 opts.references_map},
145 efl::eolian::grammar::context_null()); 146 efl::eolian::grammar::context_null());
146 147
147 auto context = efl::eolian::grammar::context_add_tag(eolian_mono::eolian_state_context{opts.state}, lib_context); 148 auto options_context = efl::eolian::grammar::context_add_tag(eolian_mono::options_context{opts.want_beta}, lib_context);
149
150 auto context = efl::eolian::grammar::context_add_tag(eolian_mono::eolian_state_context{opts.state}, options_context);
148 151
149 EINA_ITERATOR_FOREACH(aliases, tp) 152 EINA_ITERATOR_FOREACH(aliases, tp)
150 { 153 {
@@ -273,6 +276,7 @@ _usage(const char *progname)
273 << " -n, --namespace <ns> Wrap generated code in a namespace. [Eg: efl::ecore::file]" << std::endl 276 << " -n, --namespace <ns> Wrap generated code in a namespace. [Eg: efl::ecore::file]" << std::endl
274 << " -r, --recurse Recurse input directories loading .eo files." << std::endl 277 << " -r, --recurse Recurse input directories loading .eo files." << std::endl
275 << " -v, --version Print the version." << std::endl 278 << " -v, --version Print the version." << std::endl
279 << " -b, --beta Enable @beta methods." << std::endl
276 << " -h, --help Print this help." << std::endl; 280 << " -h, --help Print this help." << std::endl;
277 exit(EXIT_FAILURE); 281 exit(EXIT_FAILURE);
278} 282}
@@ -302,9 +306,10 @@ opts_get(int argc, char **argv)
302 { "vmaj", required_argument, 0, 'M' }, 306 { "vmaj", required_argument, 0, 'M' },
303 { "vmin", required_argument, 0, 'm' }, 307 { "vmin", required_argument, 0, 'm' },
304 { "references", required_argument, 0, 'r'}, 308 { "references", required_argument, 0, 'r'},
309 { "beta", no_argument, 0, 'b'},
305 { 0, 0, 0, 0 } 310 { 0, 0, 0, 0 }
306 }; 311 };
307 const char* options = "I:D:o:c:M:m:ar:vh"; 312 const char* options = "I:D:o:c:M:m:ar:vhb";
308 313
309 int c, idx; 314 int c, idx;
310 while ( (c = getopt_long(argc, argv, options, long_options, &idx)) != -1) 315 while ( (c = getopt_long(argc, argv, options, long_options, &idx)) != -1)
@@ -356,6 +361,10 @@ opts_get(int argc, char **argv)
356 _print_version(); 361 _print_version();
357 if (argc == 2) exit(EXIT_SUCCESS); 362 if (argc == 2) exit(EXIT_SUCCESS);
358 } 363 }
364 else if (c == 'b')
365 {
366 opts.want_beta = true;
367 }
359 } 368 }
360 if (optind == argc-1) 369 if (optind == argc-1)
361 { 370 {