diff options
author | Lauro Moura <lauromoura@expertisesolutions.com.br> | 2019-03-11 15:46:12 -0300 |
---|---|---|
committer | Vitor Sousa <vitorsousa@expertisesolutions.com.br> | 2019-03-11 16:08:04 -0300 |
commit | f29ceef5002f7ab2a0f400adbed20299737bce20 (patch) | |
tree | 2324619326073a6a55f286723802553743feb3f9 /src/bin | |
parent | 2a003420f83134331c8b404df1905cba538cfad6 (diff) |
efl-csharp: Respect beta for classes and other stuff.
Summary:
In order to work around an issue with Efl.App, which is stable but
inherits from Efl.Core.Command_Line, @beta interfaces/mixins in the
inheritance chain are simply skipped.
Also changed the class used int test for inheritance from C#
Efl.Loop is stable but internally it uses a @beta class as argument to
its Register() method in the constructor. When instantiating a
user-defined C# subclass, the binding calls the C# override in the
NativeInherit class and the marshalling fails as no code is generated
for the beta class.
Also moved Efl.Part test to a beta class. Efl.Part is still beta.
Regarding parts, they are skipped if its class is @beta too.
Also rejected all elm_* files in elm public eo files. They should get
back in as they are converted to Efl.Ui.* api. An exception is
elm_interface_scrollable.eo, as efl_ui_panel depends on it.
Fixes T7730
Test Plan: Run tests
Reviewers: vitor.sousa, segfaultxavi, felipealmeida, cedric, bu5hm4n, zmike
Reviewed By: vitor.sousa
Subscribers: #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7730
Differential Revision: https://phab.enlightenment.org/D8268
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/eolian_mono/eolian/mono/blacklist.hh | 45 | ||||
-rw-r--r-- | src/bin/eolian_mono/eolian/mono/events.hh | 12 | ||||
-rw-r--r-- | src/bin/eolian_mono/eolian/mono/function_pointer.hh | 12 | ||||
-rw-r--r-- | src/bin/eolian_mono/eolian/mono/helpers.hh | 7 | ||||
-rw-r--r-- | src/bin/eolian_mono/eolian/mono/klass.hh | 17 | ||||
-rw-r--r-- | src/bin/eolian_mono/eolian/mono/part_definition.hh | 3 | ||||
-rw-r--r-- | src/bin/eolian_mono/eolian/mono/struct_definition.hh | 4 |
7 files changed, 86 insertions, 14 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/blacklist.hh b/src/bin/eolian_mono/eolian/mono/blacklist.hh index c11437b..2b9d8ad 100644 --- a/src/bin/eolian_mono/eolian/mono/blacklist.hh +++ b/src/bin/eolian_mono/eolian/mono/blacklist.hh | |||
@@ -67,6 +67,7 @@ inline bool is_function_blacklisted(attributes::function_def const& func, Contex | |||
67 | // Blacklist structs that require some kind of manual binding. | 67 | // Blacklist structs that require some kind of manual binding. |
68 | inline bool is_struct_blacklisted(std::string const& full_name) | 68 | inline bool is_struct_blacklisted(std::string const& full_name) |
69 | { | 69 | { |
70 | // For now, these manual structs are blacklisted regardless of beta status | ||
70 | return full_name == "Efl.Event_Description" | 71 | return full_name == "Efl.Event_Description" |
71 | || full_name == "Eina.Binbuf" | 72 | || full_name == "Eina.Binbuf" |
72 | || full_name == "Eina.Strbuf" | 73 | || full_name == "Eina.Strbuf" |
@@ -78,11 +79,28 @@ inline bool is_struct_blacklisted(std::string const& full_name) | |||
78 | || full_name == "Eina.Future"; | 79 | || full_name == "Eina.Future"; |
79 | } | 80 | } |
80 | 81 | ||
81 | inline bool is_struct_blacklisted(attributes::struct_def const& struct_) | 82 | template <typename Context> |
83 | inline bool is_struct_blacklisted(attributes::struct_def const& struct_, Context context) | ||
82 | { | 84 | { |
85 | auto options = efl::eolian::grammar::context_find_tag<options_context>(context); | ||
86 | if (struct_.is_beta && !options.want_beta) | ||
87 | return true; | ||
88 | |||
83 | return is_struct_blacklisted(name_helpers::struct_full_eolian_name(struct_)); | 89 | return is_struct_blacklisted(name_helpers::struct_full_eolian_name(struct_)); |
84 | } | 90 | } |
85 | 91 | ||
92 | // Struct as type_def is for places where the struct is used as a struct field or parameter/return. | ||
93 | template <typename Context> | ||
94 | inline bool is_struct_blacklisted(attributes::type_def const& struct_, Context context) | ||
95 | { | ||
96 | auto options = efl::eolian::grammar::context_find_tag<options_context>(context); | ||
97 | if (struct_.is_beta && !options.want_beta) | ||
98 | return true; | ||
99 | |||
100 | auto regular = efl::eina::get<attributes::regular_type_def>(struct_.original_type); | ||
101 | return is_struct_blacklisted(name_helpers::type_full_eolian_name(regular)); | ||
102 | } | ||
103 | |||
86 | inline bool is_struct_blacklisted(attributes::regular_type_def const& struct_) | 104 | inline bool is_struct_blacklisted(attributes::regular_type_def const& struct_) |
87 | { | 105 | { |
88 | return is_struct_blacklisted(name_helpers::type_full_eolian_name(struct_)); | 106 | return is_struct_blacklisted(name_helpers::type_full_eolian_name(struct_)); |
@@ -114,6 +132,31 @@ inline bool is_property_blacklisted(attributes::property_def const& property, Co | |||
114 | return is_property_blacklisted(name); | 132 | return is_property_blacklisted(name); |
115 | } | 133 | } |
116 | 134 | ||
135 | template<typename Context> | ||
136 | inline bool is_class_blacklisted(attributes::klass_def const& cls, Context context) | ||
137 | { | ||
138 | auto options = efl::eolian::grammar::context_find_tag<options_context>(context); | ||
139 | |||
140 | return cls.is_beta && !options.want_beta; | ||
141 | } | ||
142 | |||
143 | template<typename Context> | ||
144 | inline bool is_class_blacklisted(attributes::klass_name const& cls, Context context) | ||
145 | { | ||
146 | auto options = efl::eolian::grammar::context_find_tag<options_context>(context); | ||
147 | |||
148 | return cls.is_beta && !options.want_beta; | ||
149 | } | ||
150 | |||
151 | |||
152 | template<typename Context> | ||
153 | inline bool is_event_blacklisted(attributes::event_def const& evt, Context context) | ||
154 | { | ||
155 | auto options = efl::eolian::grammar::context_find_tag<options_context>(context); | ||
156 | |||
157 | return evt.beta && !options.want_beta; | ||
158 | } | ||
159 | |||
117 | } | 160 | } |
118 | 161 | ||
119 | } | 162 | } |
diff --git a/src/bin/eolian_mono/eolian/mono/events.hh b/src/bin/eolian_mono/eolian/mono/events.hh index 76e82bd..d8dc043 100644 --- a/src/bin/eolian_mono/eolian/mono/events.hh +++ b/src/bin/eolian_mono/eolian/mono/events.hh | |||
@@ -93,6 +93,9 @@ struct event_argument_wrapper_generator | |||
93 | if (!etype.is_engaged()) | 93 | if (!etype.is_engaged()) |
94 | return true; | 94 | return true; |
95 | 95 | ||
96 | if (blacklist::is_event_blacklisted(evt, context)) | ||
97 | return true; | ||
98 | |||
96 | std::string evt_name = name_helpers::managed_event_name(evt.name); | 99 | std::string evt_name = name_helpers::managed_event_name(evt.name); |
97 | 100 | ||
98 | return as_generator("///<summary>Event argument wrapper for event <see cref=\"" | 101 | return as_generator("///<summary>Event argument wrapper for event <see cref=\"" |
@@ -119,6 +122,9 @@ struct event_declaration_generator | |||
119 | std::string wrapper_args_type; | 122 | std::string wrapper_args_type; |
120 | std::string evt_name = name_helpers::managed_event_name(evt.name); | 123 | std::string evt_name = name_helpers::managed_event_name(evt.name); |
121 | 124 | ||
125 | if (blacklist::is_event_blacklisted(evt, context)) | ||
126 | return true; | ||
127 | |||
122 | if (evt.type.is_engaged()) | 128 | if (evt.type.is_engaged()) |
123 | wrapper_args_type = "<" + name_helpers::managed_event_args_name(evt) + ">"; | 129 | wrapper_args_type = "<" + name_helpers::managed_event_args_name(evt) + ">"; |
124 | 130 | ||
@@ -143,6 +149,9 @@ struct event_registration_generator | |||
143 | { | 149 | { |
144 | std::string wrapper_event_name; | 150 | std::string wrapper_event_name; |
145 | 151 | ||
152 | if (blacklist::is_event_blacklisted(evt, context)) | ||
153 | return true; | ||
154 | |||
146 | if (is_inherited_event && !helpers::is_unique_event(evt, leaf_klass)) | 155 | if (is_inherited_event && !helpers::is_unique_event(evt, leaf_klass)) |
147 | wrapper_event_name = name_helpers::translate_inherited_event_name(evt, klass); | 156 | wrapper_event_name = name_helpers::translate_inherited_event_name(evt, klass); |
148 | else | 157 | else |
@@ -172,6 +181,9 @@ struct event_definition_generator | |||
172 | template<typename OutputIterator, typename Context> | 181 | template<typename OutputIterator, typename Context> |
173 | bool generate(OutputIterator sink, attributes::event_def const& evt, Context context) const | 182 | bool generate(OutputIterator sink, attributes::event_def const& evt, Context context) const |
174 | { | 183 | { |
184 | if (blacklist::is_event_blacklisted(evt, context)) | ||
185 | return true; | ||
186 | |||
175 | std::string managed_evt_name = name_helpers::managed_event_name(evt.name); | 187 | std::string managed_evt_name = name_helpers::managed_event_name(evt.name); |
176 | 188 | ||
177 | bool is_unique = helpers::is_unique_event(evt, leaf_klass); | 189 | bool is_unique = helpers::is_unique_event(evt, leaf_klass); |
diff --git a/src/bin/eolian_mono/eolian/mono/function_pointer.hh b/src/bin/eolian_mono/eolian/mono/function_pointer.hh index a7e692b..f3918f1 100644 --- a/src/bin/eolian_mono/eolian/mono/function_pointer.hh +++ b/src/bin/eolian_mono/eolian/mono/function_pointer.hh | |||
@@ -9,15 +9,17 @@ | |||
9 | #include "function_helpers.hh" | 9 | #include "function_helpers.hh" |
10 | #include "documentation.hh" | 10 | #include "documentation.hh" |
11 | #include "generation_contexts.hh" | 11 | #include "generation_contexts.hh" |
12 | #include "blacklist.hh" | ||
12 | 13 | ||
13 | namespace eolian_mono { | 14 | namespace eolian_mono { |
14 | 15 | ||
15 | // Blacklist structs that require some kind of manual binding. | 16 | // Blacklist structs that require some kind of manual binding. |
16 | static bool is_function_ptr_blacklisted(attributes::function_def const& func) | 17 | template <typename Context> |
18 | static bool is_function_ptr_blacklisted(attributes::function_def const& func, Context context) | ||
17 | { | 19 | { |
18 | std::string name = name_helpers::function_ptr_full_eolian_name(func); | 20 | std::string name = name_helpers::function_ptr_full_eolian_name(func); |
19 | 21 | ||
20 | return false; | 22 | return blacklist::is_function_blacklisted(func, context); |
21 | } | 23 | } |
22 | 24 | ||
23 | struct function_pointer { | 25 | struct function_pointer { |
@@ -28,13 +30,13 @@ struct function_pointer { | |||
28 | // FIXME export Typedecl in eolian_cxx API | 30 | // FIXME export Typedecl in eolian_cxx API |
29 | auto funcptr_ctx = context_add_tag(class_context{class_context::function_ptr}, context); | 31 | auto funcptr_ctx = context_add_tag(class_context{class_context::function_ptr}, context); |
30 | 32 | ||
33 | if (is_function_ptr_blacklisted(f, context)) | ||
34 | return true; | ||
35 | |||
31 | std::string return_type; | 36 | std::string return_type; |
32 | if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context)) | 37 | if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context)) |
33 | return false; | 38 | return false; |
34 | 39 | ||
35 | if (is_function_ptr_blacklisted(f)) | ||
36 | return true; | ||
37 | |||
38 | if (!name_helpers::open_namespaces(sink, f.namespaces, funcptr_ctx)) | 40 | if (!name_helpers::open_namespaces(sink, f.namespaces, funcptr_ctx)) |
39 | return false; | 41 | return false; |
40 | 42 | ||
diff --git a/src/bin/eolian_mono/eolian/mono/helpers.hh b/src/bin/eolian_mono/eolian/mono/helpers.hh index 87a1e9d..a4bb169 100644 --- a/src/bin/eolian_mono/eolian/mono/helpers.hh +++ b/src/bin/eolian_mono/eolian/mono/helpers.hh | |||
@@ -102,8 +102,10 @@ std::set<attributes::klass_name, attributes::compare_klass_name_by_name> interfa | |||
102 | 102 | ||
103 | // Returns the set of interfaces implemented by this type that haven't been implemented | 103 | // Returns the set of interfaces implemented by this type that haven't been implemented |
104 | // by a regular parent class. | 104 | // by a regular parent class. |
105 | std::set<attributes::klass_name, attributes::compare_klass_name_by_name> non_implemented_interfaces(attributes::klass_def const& cls) | 105 | template<typename Context> |
106 | std::set<attributes::klass_name, attributes::compare_klass_name_by_name> non_implemented_interfaces(attributes::klass_def const& cls, Context context) | ||
106 | { | 107 | { |
108 | auto options = efl::eolian::grammar::context_find_tag<options_context>(context); | ||
107 | std::set<attributes::klass_name, attributes::compare_klass_name_by_name> implemented_interfaces; | 109 | std::set<attributes::klass_name, attributes::compare_klass_name_by_name> implemented_interfaces; |
108 | std::set<attributes::klass_name, attributes::compare_klass_name_by_name> interfaces; | 110 | std::set<attributes::klass_name, attributes::compare_klass_name_by_name> interfaces; |
109 | 111 | ||
@@ -114,6 +116,9 @@ std::set<attributes::klass_name, attributes::compare_klass_name_by_name> non_imp | |||
114 | attributes::klass_def c(get_klass(klass, cls.unit), cls.unit); | 116 | attributes::klass_def c(get_klass(klass, cls.unit), cls.unit); |
115 | for(auto&& inherit : c.immediate_inherits) | 117 | for(auto&& inherit : c.immediate_inherits) |
116 | { | 118 | { |
119 | if (inherit.is_beta && !options.want_beta) | ||
120 | continue; | ||
121 | |||
117 | switch(inherit.type) | 122 | switch(inherit.type) |
118 | { | 123 | { |
119 | case attributes::class_type::mixin: | 124 | case attributes::class_type::mixin: |
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh index 0689648..a9f270d 100644 --- a/src/bin/eolian_mono/eolian/mono/klass.hh +++ b/src/bin/eolian_mono/eolian/mono/klass.hh | |||
@@ -95,6 +95,13 @@ struct klass | |||
95 | bool generate(OutputIterator sink, attributes::klass_def const& cls, Context const& context) const | 95 | bool generate(OutputIterator sink, attributes::klass_def const& cls, Context const& context) const |
96 | { | 96 | { |
97 | EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "klass_generator: " << cls.eolian_name << std::endl; | 97 | EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "klass_generator: " << cls.eolian_name << std::endl; |
98 | |||
99 | if (blacklist::is_class_blacklisted(cls, context)) | ||
100 | { | ||
101 | EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "class " << cls.eolian_name << " is blacklisted. Skipping." << std::endl; | ||
102 | return true; | ||
103 | } | ||
104 | |||
98 | std::string suffix, class_type; | 105 | std::string suffix, class_type; |
99 | switch(cls.type) | 106 | switch(cls.type) |
100 | { | 107 | { |
@@ -183,7 +190,7 @@ struct klass | |||
183 | return false; | 190 | return false; |
184 | 191 | ||
185 | bool root = !helpers::has_regular_ancestor(cls); | 192 | bool root = !helpers::has_regular_ancestor(cls); |
186 | std::set<attributes::klass_name, attributes::compare_klass_name_by_name> inherit_interfaces = helpers::non_implemented_interfaces(cls); | 193 | std::set<attributes::klass_name, attributes::compare_klass_name_by_name> inherit_interfaces = helpers::non_implemented_interfaces(cls, context); |
187 | std::vector<attributes::klass_name> inherit_classes; | 194 | std::vector<attributes::klass_name> inherit_classes; |
188 | std::copy_if(cls.immediate_inherits.begin(), cls.immediate_inherits.end() | 195 | std::copy_if(cls.immediate_inherits.begin(), cls.immediate_inherits.end() |
189 | , std::back_inserter(inherit_classes) | 196 | , std::back_inserter(inherit_classes) |
@@ -268,7 +275,7 @@ struct klass | |||
268 | if (!as_generator(*(property_wrapper_definition)).generate(sink, cls.properties, concrete_cxt)) | 275 | if (!as_generator(*(property_wrapper_definition)).generate(sink, cls.properties, concrete_cxt)) |
269 | return false; | 276 | return false; |
270 | 277 | ||
271 | for (auto&& klass : helpers::non_implemented_interfaces(cls)) | 278 | for (auto&& klass : helpers::non_implemented_interfaces(cls, concrete_cxt)) |
272 | { | 279 | { |
273 | attributes::klass_def c(get_klass(klass, cls.unit), cls.unit); | 280 | attributes::klass_def c(get_klass(klass, cls.unit), cls.unit); |
274 | if (!as_generator(*(property_wrapper_definition)).generate(sink, c.properties, concrete_cxt)) | 281 | if (!as_generator(*(property_wrapper_definition)).generate(sink, c.properties, concrete_cxt)) |
@@ -340,7 +347,7 @@ struct klass | |||
340 | if (!as_generator(*(property_wrapper_definition)).generate(sink, cls.properties, inherit_cxt)) | 347 | if (!as_generator(*(property_wrapper_definition)).generate(sink, cls.properties, inherit_cxt)) |
341 | return false; | 348 | return false; |
342 | 349 | ||
343 | for (auto&& klass : helpers::non_implemented_interfaces(cls)) | 350 | for (auto&& klass : helpers::non_implemented_interfaces(cls, inherit_cxt)) |
344 | { | 351 | { |
345 | attributes::klass_def c(get_klass(klass, cls.unit), cls.unit); | 352 | attributes::klass_def c(get_klass(klass, cls.unit), cls.unit); |
346 | if (!as_generator(*(property_wrapper_definition)).generate(sink, c.properties, inherit_cxt)) | 353 | if (!as_generator(*(property_wrapper_definition)).generate(sink, c.properties, inherit_cxt)) |
@@ -644,7 +651,7 @@ struct klass | |||
644 | if (!as_generator(*(event_registration(cls, cls))).generate(sink, cls.events, context)) | 651 | if (!as_generator(*(event_registration(cls, cls))).generate(sink, cls.events, context)) |
645 | return false; | 652 | return false; |
646 | 653 | ||
647 | for (auto&& c : helpers::non_implemented_interfaces(cls)) | 654 | for (auto&& c : helpers::non_implemented_interfaces(cls, context)) |
648 | { | 655 | { |
649 | // Only non-regular types (which declare events through interfaces) need to register them. | 656 | // Only non-regular types (which declare events through interfaces) need to register them. |
650 | if (c.type == attributes::class_type::regular) | 657 | if (c.type == attributes::class_type::regular) |
@@ -742,7 +749,7 @@ struct klass | |||
742 | // Inherited events | 749 | // Inherited events |
743 | 750 | ||
744 | // For now, as mixins can inherit from regular classes, we can't filter out inherited events. | 751 | // For now, as mixins can inherit from regular classes, we can't filter out inherited events. |
745 | auto inherits = helpers::non_implemented_interfaces(cls); | 752 | auto inherits = helpers::non_implemented_interfaces(cls, context); |
746 | for (auto&& c : inherits) | 753 | for (auto&& c : inherits) |
747 | { | 754 | { |
748 | attributes::klass_def klass(get_klass(c, cls.unit), cls.unit); | 755 | attributes::klass_def klass(get_klass(c, cls.unit), cls.unit); |
diff --git a/src/bin/eolian_mono/eolian/mono/part_definition.hh b/src/bin/eolian_mono/eolian/mono/part_definition.hh index 47951f4..2a8d2e1 100644 --- a/src/bin/eolian_mono/eolian/mono/part_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/part_definition.hh | |||
@@ -18,6 +18,9 @@ struct part_definition_generator | |||
18 | template <typename OutputIterator, typename Context> | 18 | template <typename OutputIterator, typename Context> |
19 | bool generate(OutputIterator sink, attributes::part_def const& part, Context const& context) const | 19 | bool generate(OutputIterator sink, attributes::part_def const& part, Context const& context) const |
20 | { | 20 | { |
21 | if (blacklist::is_class_blacklisted(part.klass, context)) | ||
22 | return true; | ||
23 | |||
21 | auto part_klass_name = name_helpers::klass_full_concrete_or_interface_name(part.klass); | 24 | auto part_klass_name = name_helpers::klass_full_concrete_or_interface_name(part.klass); |
22 | return as_generator(scope_tab << documentation | 25 | return as_generator(scope_tab << documentation |
23 | << scope_tab << "public " << part_klass_name << " " << name_helpers::managed_part_name(part) << "\n" | 26 | << scope_tab << "public " << part_klass_name << " " << name_helpers::managed_part_name(part) << "\n" |
diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh index 17485d1..ba058d0 100644 --- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh | |||
@@ -196,6 +196,7 @@ struct to_internal_field_convert_generator | |||
196 | bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const | 196 | bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const |
197 | { | 197 | { |
198 | auto field_name = name_helpers::to_field_name(field.name); | 198 | auto field_name = name_helpers::to_field_name(field.name); |
199 | // FIXME Replace need_struct_conversion(regular) with need_struct_conversion(type) | ||
199 | auto regular = efl::eina::get<attributes::regular_type_def>(&field.type.original_type); | 200 | auto regular = efl::eina::get<attributes::regular_type_def>(&field.type.original_type); |
200 | auto klass = efl::eina::get<attributes::klass_name>(&field.type.original_type); | 201 | auto klass = efl::eina::get<attributes::klass_name>(&field.type.original_type); |
201 | auto complex = efl::eina::get<attributes::complex_type_def>(&field.type.original_type); | 202 | auto complex = efl::eina::get<attributes::complex_type_def>(&field.type.original_type); |
@@ -496,10 +497,9 @@ struct struct_entities_generator | |||
496 | template <typename OutputIterator, typename Context> | 497 | template <typename OutputIterator, typename Context> |
497 | bool generate(OutputIterator sink, attributes::struct_def const& struct_, Context const& context) const | 498 | bool generate(OutputIterator sink, attributes::struct_def const& struct_, Context const& context) const |
498 | { | 499 | { |
499 | if (blacklist::is_struct_blacklisted(struct_)) | 500 | if (blacklist::is_struct_blacklisted(struct_, context)) |
500 | return true; | 501 | return true; |
501 | 502 | ||
502 | |||
503 | if (!name_helpers::open_namespaces(sink, struct_.namespaces, context)) | 503 | if (!name_helpers::open_namespaces(sink, struct_.namespaces, context)) |
504 | return false; | 504 | return false; |
505 | 505 | ||