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 bc0bb6863a..3fddb03780 100644 --- a/src/bin/eolian_mono/eolian/mono/async_function_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/async_function_definition.hh @@ -36,6 +36,7 @@ #include "using_decl.hh" #include "generation_contexts.hh" #include "blacklist.hh" +#include "documentation.hh" namespace eolian_mono { @@ -71,8 +72,10 @@ struct async_function_declaration_generator if(f.scope != attributes::member_scope::scope_public) return true; + auto ref = documentation_generator::function_conversion (f, context); + if (!as_generator( - scope_tab(2) << "/// Async wrapper for .\n" + scope_tab(2) << "/// Async wrapper for .\n" ).generate(sink, attributes::unused, context)) return false; diff --git a/src/bin/eolian_mono/eolian/mono/documentation.hh b/src/bin/eolian_mono/eolian/mono/documentation.hh index d15f91437d..eac5e1a179 100644 --- a/src/bin/eolian_mono/eolian/mono/documentation.hh +++ b/src/bin/eolian_mono/eolian/mono/documentation.hh @@ -23,6 +23,7 @@ #include "name_helpers.hh" #include "generation_contexts.hh" #include "blacklist.hh" +#include "property_definition.hh" #include @@ -76,7 +77,8 @@ struct documentation_generator // The name_tail parameter is the last 4 chars of the original string, which // could be ".set" or ".get" and in this case they are ignored by Eolian. // We want them to know what the documentation intended to reference. - static std::string function_conversion(const ::Eolian_Object *klass, const ::Eolian_Function *function, std::string name_tail) + template + static std::string function_conversion(const ::Eolian_Object *klass, const ::Eolian_Function *function, std::string name_tail, Context const& context) { ::Eolian_Function_Type ftype = ::eolian_function_type_get(function); const char* eo_name = ::eolian_function_name_get(function); @@ -113,26 +115,65 @@ struct documentation_generator name += name_helpers::managed_method_name({function, ftype, NULL, eolian_object_unit_get(EOLIAN_OBJECT(function))}); break; case ::EOLIAN_PROP_SET: - name += ".Set"; - name += name_helpers::property_managed_name(klass_d, eo_name); - break; case ::EOLIAN_PROP_GET: - name += ".Get"; - name += name_helpers::property_managed_name(klass_d, eo_name); - break; case ::EOLIAN_PROPERTY: + { + efl::eina::optional getter_func; + efl::eina::optional setter_func; + auto unit = (const Eolian_Unit*) context_find_tag(context).state; + if (ftype == ::EOLIAN_PROPERTY || ftype == ::EOLIAN_PROP_GET) + getter_func = attributes::function_def{function, ::EOLIAN_PROP_GET, nullptr, unit}; + if (ftype == ::EOLIAN_PROPERTY || ftype == ::EOLIAN_PROP_SET) + setter_func = attributes::function_def{function, ::EOLIAN_PROP_SET, nullptr, unit}; + attributes::property_def property{function, getter_func, setter_func, unit}; + + std::string short_name = name_helpers::property_managed_name(klass_d, eo_name); + class_context::wrapper_kind klass_kind; + if (helpers::is_managed_interface(klass_d)) + klass_kind = class_context::interface; + else + klass_kind = class_context::inherit; + auto my_context = grammar::context_replace_tag(class_context{klass_kind}, context); + + if (name_tail == ".get") { - int getter_nkeys = property_num_keys(function, ::EOLIAN_PROP_GET); - int setter_nkeys = property_num_keys(function, ::EOLIAN_PROP_SET); - std::string short_name = name_helpers::property_managed_name(klass_d, eo_name); - bool blacklisted = blacklist::is_property_blacklisted(name + "." + short_name); - // EO properties with keys or blacklisted are not converted into C# properties. - // In these cases we refer to the getter method instead of the property. - if ((getter_nkeys > 0) || (setter_nkeys > 0) || (blacklisted)) name += ".Get" + short_name; - else if (name_tail == ".get") name += ".Get" + short_name; - else if (name_tail == ".set") name += ".Set" + short_name; - else name += "." + short_name; + if (property_generate_wrapper_getter (property, my_context)) + { + name += "." + short_name; + } + else + { + name += ".Get" + short_name; + } } + else if (name_tail == ".set") + { + if (property_generate_wrapper_setter (property, my_context)) + { + name += "." + short_name; + } + else + { + name += ".Set" + short_name; + } + } + else + { + switch (ftype) + { + case ::EOLIAN_PROPERTY: + case ::EOLIAN_PROP_GET: + if (property_generate_wrapper_getter (property, my_context)) + name += "." + short_name; + else + name += ".Get" + short_name; + break; + default: + name += ".Set" + short_name; + break; + } + } + } break; default: break; @@ -140,33 +181,89 @@ struct documentation_generator return name; } - static std::string function_conversion(attributes::function_def const& func) + template + static std::string function_conversion(attributes::function_def const& func, Context const& context) { // This function is called only from the constructor reference conversion, so it does not // need to check whether this function non-public in a interface returning an empty reference (yet). std::string name = name_helpers::klass_full_concrete_or_interface_name(func.klass); switch (func.type) { - // managed_method_name takes care of reordering the function name so the get/set goes first - // for properties - case attributes::function_type::method: - case attributes::function_type::prop_set: - case attributes::function_type::prop_get: - if (blacklist::is_function_blacklisted(func.c_name))return ""; - if (!name.empty()) name += "."; - name += name_helpers::managed_method_name(func); - break; - default: - // No need to deal with property as function_defs are converted to get/set when building a given klass_def. - break; + // managed_method_name takes care of reordering the function name so the get/set goes first + // for properties + case attributes::function_type::method: + if (blacklist::is_function_blacklisted(func.c_name))return ""; + if (!name.empty()) name += "."; + name += name_helpers::managed_method_name(func); + break; + case attributes::function_type::prop_set: + case attributes::function_type::prop_get: + case attributes::function_type::property: + { + auto unit = (const Eolian_Unit*) context_find_tag(context).state; + auto klass = get_klass(func.klass, unit); + attributes::klass_def klass_d(klass, unit); + + auto eo_name = func.name; + auto prop_name = eo_name; + if (prop_name.size () > 4 + && + ( prop_name.substr(prop_name.size() - 4) == "_set" + || prop_name.substr(prop_name.size() - 4) == "_get")) + { + prop_name = prop_name.substr(0, prop_name.size() - 4); + } + std::string short_name = name_helpers::property_managed_name(klass_d, prop_name); + assert (prop_name.size() <= 4 || + (prop_name.substr(prop_name.size() - 4) != "_set" + && prop_name.substr(prop_name.size() - 4) != "_get")); + assert (short_name.size() <= 3 || + (short_name.substr(short_name.size() - 3) != "Set" + && short_name.substr(short_name.size() - 3) != "Get")); + + // We need to replace the current class context with the context + // from the class that originated this property. + class_context::wrapper_kind klass_kind; + if (helpers::is_managed_interface(klass_d)) + klass_kind = class_context::interface; + else + klass_kind = class_context::inherit; + + auto my_context = grammar::context_replace_tag(class_context{klass_kind}, context); + + auto function = eolian_class_function_by_name_get (klass, prop_name.c_str(), EOLIAN_PROPERTY); + attributes::function_def getter_func{function, ::EOLIAN_PROP_GET, nullptr, unit}; + attributes::function_def setter_func{function, ::EOLIAN_PROP_SET, nullptr, unit}; + attributes::property_def prop{function, getter_func, setter_func, unit}; + + if (func.type == attributes::function_type::prop_get || func.type == attributes::function_type::property) + { + if (property_generate_wrapper_getter (prop, my_context)) + name += "." + short_name; + else + name += ".Get" + short_name; + } + else if (func.type == attributes::function_type::prop_set) + { + if (property_generate_wrapper_setter (prop, my_context)) + name += "." + short_name; + else + name += ".Set" + short_name; + } + } + break; + default: + // No need to deal with property as function_defs are converted to get/set when building a given klass_def. + break; } return name; } // Turns an Eolian reference like @Efl.Input.Pointer.tool into a tag + template static std::string ref_conversion(const ::Eolian_Doc_Token *token, const Eolian_State *state, std::string name_tail, - bool want_beta) + bool want_beta, Context const& context) { const Eolian_Object *data, *data2; ::Eolian_Object_Type type = @@ -195,7 +292,7 @@ struct documentation_generator is_beta = eolian_object_is_beta(data) || eolian_object_is_beta(data2); break; case ::EOLIAN_OBJECT_FUNCTION: - ref += function_conversion(data, (const ::Eolian_Function *)data2, name_tail); + ref += function_conversion(data, (const ::Eolian_Function *)data2, name_tail, context); is_beta = eolian_object_is_beta(data) || eolian_object_is_beta(data2); break; case ::EOLIAN_OBJECT_CONSTANT: @@ -226,8 +323,9 @@ struct documentation_generator return ref; } - // Turns EO documentation syntax into C# triple-slash XML comment syntax - static std::string syntax_conversion(std::string text, const Eolian_State *state, bool want_beta) + // Turns EO documentation syntax into C# triple-slash XML comment syntax + template + static std::string syntax_conversion(std::string text, const Eolian_State *state, bool want_beta, Context const& context) { std::string new_text, ref; ::Eolian_Doc_Token_Type previous_token_type = ::EOLIAN_DOC_TOKEN_UNKNOWN; @@ -266,7 +364,7 @@ struct documentation_generator new_text += token_text; break; case ::EOLIAN_DOC_TOKEN_REF: - ref = ref_conversion(&token, state, name_tail, want_beta); + ref = ref_conversion(&token, state, name_tail, want_beta, context); if (ref != "") { if (utils::ends_with(ref, BETA_REF_SUFFIX)) @@ -333,7 +431,7 @@ struct documentation_generator if (!as_generator(html_escaped_string).generate(std::back_inserter(new_text), text, context)) return false; auto options = context_find_tag(context); - new_text = syntax_conversion( new_text, context_find_tag(context).state, options.want_beta); + new_text = syntax_conversion( new_text, context_find_tag(context).state, options.want_beta, context); std::string tabs; as_generator(scope_tab(scope_size) << "/// ").generate (std::back_inserter(tabs), attributes::unused, context); @@ -698,7 +796,7 @@ struct documentation_generator for (auto &¶m : ctor.function.parameters) { - auto ref = function_conversion(func); + auto ref = function_conversion(func, context); if (!context_find_tag(context).want_beta && func.is_beta) { @@ -741,7 +839,7 @@ struct documentation_string_generator auto options = context_find_tag(context); auto state = context_find_tag(context).state; - if (!as_generator(string).generate(sink, documentation_generator::syntax_conversion(escaped, state, options.want_beta), context)) + if (!as_generator(string).generate(sink, documentation_generator::syntax_conversion(escaped, state, options.want_beta, context), context)) return false; return true; diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh index 3c30cdd3fe..6aeaadcedb 100644 --- a/src/bin/eolian_mono/eolian/mono/function_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh @@ -27,6 +27,7 @@ #include "grammar/alternative.hpp" #include "grammar/attribute_reorder.hpp" #include "grammar/counter.hpp" +#include "property_definition.hh" #include "logging.hh" #include "type.hh" #include "name_helpers.hh" @@ -44,6 +45,7 @@ namespace eolian_mono { struct native_function_definition_generator { attributes::klass_def const* klass; + std::vector properties; template bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const @@ -52,6 +54,24 @@ struct native_function_definition_generator if(blacklist::is_function_blacklisted(f, context)) return true; + auto it = std::find_if (properties.begin(), properties.end() + , [&] (attributes::property_def const& prop) + { + return (prop.getter && *prop.getter == f) + || (prop.setter && *prop.setter == f); + }); + if (it != properties.end()) + { + if (it->getter && *it->getter == f) + { + if (property_generate_wrapper_getter (*it, context)) + return true; + } + else + if (property_generate_wrapper_setter (*it, context)) + return true; + } + auto const& indent = current_indentation(context); // Delegate for the C# method we will export to EO as a method implementation. @@ -184,10 +204,6 @@ struct native_function_definition_generator struct function_definition_generator { - function_definition_generator(bool do_super = false) - : do_super(do_super) - {} - template bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const { @@ -197,6 +213,25 @@ struct function_definition_generator if(blacklist::is_function_blacklisted(f, context)) return true; + auto function_scope = eolian_mono::function_scope_get(f); + auto it = std::find_if (properties.begin(), properties.end() + , [&] (attributes::property_def const& prop) + { + return (prop.getter && *prop.getter == f) + || (prop.setter && *prop.setter == f); + }); + if (it != properties.end()) + { + if (it->getter && *it->getter == f) + { + if (property_generate_wrapper_getter (*it, context)) + function_scope = "internal "; + } + else + if (property_generate_wrapper_setter (*it, context)) + function_scope = "internal "; + } + // Do not generate static function for concrete class if (is_concrete && f.is_static) return true; @@ -219,7 +254,7 @@ struct function_definition_generator self = ""; if(!as_generator - (scope_tab(2) << eolian_mono::function_scope_get(f) << ((do_super && !f.is_static) ? "virtual " : "") << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ") + (scope_tab(2) << function_scope << ((do_super && !f.is_static) ? "virtual " : "") << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ") << ") {\n" << scope_tab(3) << eolian_mono::function_definition_preamble() << klass_full_native_inherit_name(f.klass) << "." << string << "_ptr.Value.Delegate(" @@ -235,24 +270,29 @@ struct function_definition_generator } bool do_super; + std::vector properties; }; struct function_definition_parameterized { - function_definition_generator operator()(bool do_super) const + function_definition_generator operator()(bool do_super, std::vector properties) const { - return {do_super}; + return {do_super, properties}; + } + function_definition_generator operator()(std::vector properties) const + { + return {false, properties}; } } const function_definition; -function_definition_generator as_generator(function_definition_parameterized) -{ - return {}; -} +// function_definition_generator as_generator(function_definition_parameterized) +// { +// return {}; +// } struct native_function_definition_parameterized { - native_function_definition_generator operator()(attributes::klass_def const& klass) const + native_function_definition_generator operator()(attributes::klass_def const& klass, std::vector properties) const { - return {&klass}; + return {&klass, properties}; } } const native_function_definition; @@ -356,27 +396,19 @@ struct property_wrapper_definition_generator // if (get_params > 0 || set_params > 1) // return true; - if (property.getter - && std::find_if (property.getter->parameters.begin() - , property.getter->parameters.end() - , [] (parameter_def const& p) - { - return p.direction != parameter_direction::out; - }) != property.getter->parameters.end()) + if (property.getter && !property.getter->keys.empty()) return true; - if (property.setter - && std::find_if (property.setter->parameters.begin() - , property.setter->parameters.end() - , [] (parameter_def const& p) - { - return p.direction != parameter_direction::in; - }) != property.setter->parameters.end()) + if (property.setter && !property.setter->keys.empty()) return true; - + if (property.getter && property.setter) { - if (get_params != 0 && property.setter->parameters.size() != property.getter->parameters.size()) - return true; + if (property.setter->values.size() != property.getter->values.size()) + { + if (!std::equal(property.setter->values.begin(), property.setter->values.end() + , property.getter->values.begin())) + return true; + } } std::vector parameters; @@ -481,9 +513,11 @@ struct property_wrapper_definition_generator if (property.getter.is_engaged() && is_interface) { if (is_get_public) + { if (!as_generator(scope_tab(2) << scope_tab << set_scope << "get;\n" ).generate(sink, attributes::unused, context)) return false; + } } else if (property.getter.is_engaged() && get_params == 0/*parameters.size() == 1 && property.getter.is_engaged()*/) { @@ -526,9 +560,11 @@ struct property_wrapper_definition_generator if (property.setter.is_engaged() && is_interface) { if (is_set_public) + { if (!as_generator(scope_tab(2) << scope_tab << set_scope << "set;\n" ).generate(sink, attributes::unused, context)) return false; + } } else if (parameters.size() == 1 && property.setter.is_engaged()) { diff --git a/src/bin/eolian_mono/eolian/mono/helpers.hh b/src/bin/eolian_mono/eolian/mono/helpers.hh index b34a985749..f704ef00af 100644 --- a/src/bin/eolian_mono/eolian/mono/helpers.hh +++ b/src/bin/eolian_mono/eolian/mono/helpers.hh @@ -248,6 +248,67 @@ std::vector get_all_implementable_methods(attributes:: return ret; } +/* + * Gets all properties that this class should implement (i.e. that come from an unimplemented interface/mixin and the class itself) + */ +template +std::vector get_all_implementable_properties(attributes::klass_def const& cls, Context const& context) +{ + bool want_beta = efl::eolian::grammar::context_find_tag(context).want_beta; + std::vector ret; + auto filter_beta = [&want_beta](attributes::property_def const& prop) { + if (!want_beta) + return prop.getter && !prop.setter ? !prop.getter->is_beta + : prop.getter && prop.setter ? !prop.getter->is_beta || !prop.setter->is_beta + : true + ; + else + return true; + }; + + std::copy_if(cls.properties.begin(), cls.properties.end(), std::back_inserter(ret), filter_beta); + + // Non implemented interfaces + std::set implemented_interfaces; + std::set interfaces; + std::function inherit_algo = + [&] (attributes::klass_name const &klass, bool is_implemented) + { + attributes::klass_def c(get_klass(klass, cls.unit), cls.unit); + for (auto&& inherit: c.immediate_inherits) + { + switch(inherit.type) + { + case attributes::class_type::mixin: + case attributes::class_type::interface_: + interfaces.insert(inherit); + if (is_implemented) + implemented_interfaces.insert(inherit); + inherit_algo(inherit, is_implemented); + break; + case attributes::class_type::abstract_: + case attributes::class_type::regular: + inherit_algo(inherit, true); + default: + break; + } + } + }; + + inherit_algo(attributes::get_klass_name(cls), false); + + for (auto&& inherit : implemented_interfaces) + interfaces.erase(inherit); + + for (auto&& inherit : interfaces) + { + attributes::klass_def klass(get_klass(inherit, cls.unit), cls.unit); + std::copy_if(klass.properties.cbegin(), klass.properties.cend(), std::back_inserter(ret), filter_beta); + } + + return ret; +} + template inline bool is_managed_interface(Klass const& klass) { @@ -284,6 +345,51 @@ std::vector get_all_registerable_methods(attributes::k return ret; } +bool is_function_registerable (attributes::function_def func, attributes::klass_def const& cls) +{ + if (cls == func.klass) + return true; + + if (is_managed_interface(func.klass) && func.is_static) + return true; + + if (!is_managed_interface(func.klass) || func.scope != attributes::member_scope::scope_public) + return true; + return false; +} + +// /* +// * Gets all methods that this class should register (i.e. that comes from it and non-public interface methods +// * that this class is the first one implementing) +// */ +// template +// std::vector get_all_registerable_properties(attributes::klass_def const& cls, Context const& context) +// { +// std::vector ret; + +// auto implementable_properties = get_all_implementable_properties(cls, context); + +// std::copy_if(implementable_properties.cbegin(), implementable_properties.cend(), std::back_inserter(ret) +// , [&cls](attributes::property_def const & property) { +// auto klass = property.getter ? property.getter->klass +// : property.setter->klass; + +// if (cls == klass) +// return true; + +// if (is_managed_interface(klass) && ((property.getter && property.getter->is_static) +// || (property.setter && property.setter->is_static))) +// return true; + +// if (!is_managed_interface(klass) || ((property.getter && property.getter->scope != attributes::member_scope::scope_public) +// || (property.setter && property.setter->scope != attributes::member_scope::scope_public))) +// return true; +// return false; +// }); + +// return ret; +// } + /* * Checks whether the given is unique going up the inheritance tree from leaf_klass */ diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh index da6fd6d45c..9a494ef4c2 100644 --- a/src/bin/eolian_mono/eolian/mono/klass.hh +++ b/src/bin/eolian_mono/eolian/mono/klass.hh @@ -29,6 +29,7 @@ #include "name_helpers.hh" #include "async_function_definition.hh" #include "function_definition.hh" +#include "property_definition.hh" #include "function_registration.hh" #include "function_declaration.hh" #include "documentation.hh" @@ -142,7 +143,27 @@ struct klass if(!as_generator("\n" << scope_tab << "{\n").generate(sink, attributes::unused, iface_cxt)) return false; - if(!as_generator(*(function_declaration)).generate(sink, cls.functions, iface_cxt)) + auto properties = cls.properties; + auto functions = cls.functions; + functions.erase (std::remove_if (functions.begin(), functions.end() + , [&] (attributes::function_def const& f) + { + auto it = std::find_if (properties.begin(), properties.end() + , [&f] (attributes::property_def const& prop) + { + return (prop.getter && *prop.getter == f) + || (prop.setter && *prop.setter == f); + }); + if (it != properties.end()) + { + if (it->getter && *it->getter == f) + return property_generate_wrapper_getter (*it, iface_cxt); + else if (it->setter && *it->setter == f) + return property_generate_wrapper_setter (*it, iface_cxt); + } + return false; + }), functions.end()); + if(!as_generator(*(function_declaration)).generate(sink, functions, iface_cxt)) return false; if(!as_generator(*(async_function_declaration)).generate(sink, cls.functions, iface_cxt)) @@ -158,7 +179,10 @@ struct klass ).generate(sink, p, iface_cxt)) return false; - if (!as_generator(*(property_wrapper_definition(cls))).generate(sink, cls.properties, iface_cxt)) + properties.erase(std::remove_if (properties.begin(), properties.end() + , [&] (attributes::property_def const& prop) + { return !property_generate_wrapper_getter (prop, iface_cxt); }), properties.end()); + if (!as_generator(*(property_wrapper_definition(cls))).generate(sink, properties, iface_cxt)) return false; // End of interface declaration @@ -246,7 +270,7 @@ struct klass // Inherit function definitions auto implemented_methods = helpers::get_all_implementable_methods(cls, inherit_cxt); - if(!as_generator(*(function_definition(true))) + if(!as_generator(*(function_definition(true, helpers::get_all_implementable_properties(cls, inherit_cxt)))) .generate(sink, implemented_methods, inherit_cxt)) return false; // Async wrappers @@ -337,6 +361,7 @@ struct klass 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_registerable_methods(cls, context); + auto implementable_properties = helpers::get_all_implementable_properties(cls, context); bool root = !helpers::has_regular_ancestor(cls); bool is_concrete = context_find_tag(context).current_wrapper_kind == class_context::concrete; auto const& indent = current_indentation(inative_cxt).inc(); @@ -376,11 +401,12 @@ struct klass return false; } - if(implementable_methods.size() >= 1) + if(!implementable_methods.empty()) { if(!as_generator( indent << scope_tab << "private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule(" - << context_find_tag(context).actual_library_name(cls.filename) << ");\n\n" + << context_find_tag(context).actual_library_name(cls.filename) << "); // " << implementable_methods.size() + << " " << implementable_properties.size() << "\n\n" ).generate(sink, attributes::unused, inative_cxt)) return false; } @@ -455,10 +481,17 @@ struct klass // Native method definitions if(!as_generator( indent << scope_tab << "#pragma warning disable CA1707, CS1591, SA1300, SA1600\n\n" - << *(native_function_definition(cls)) + << *(native_function_definition(cls, implementable_properties)) << indent << scope_tab << "#pragma warning restore CA1707, CS1591, SA1300, SA1600\n\n") .generate(sink, implementable_methods, change_indentation(indent.inc(), inative_cxt))) return false; + if(!as_generator( + indent << scope_tab << "#pragma warning disable CA1707, CS1591, SA1300, SA1600\n\n" + << *(native_property_function_definition(cls, cls)) + << indent << scope_tab << "#pragma warning restore CA1707, CS1591, SA1300, SA1600\n\n") + .generate(sink, implementable_properties + , change_indentation(indent.inc(), inative_cxt))) return false; + if(!as_generator(indent << "}\n").generate(sink, attributes::unused, inative_cxt)) return false; } return true; diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh index abd94641ef..59faa0d493 100644 --- a/src/bin/eolian_mono/eolian/mono/parameter.hh +++ b/src/bin/eolian_mono/eolian/mono/parameter.hh @@ -34,6 +34,7 @@ namespace eolian_mono { struct argument_generator; struct argument_invocation_generator; struct native_argument_invocation_generator; + struct native_tuple_argument_invocation_generator; struct native_convert_in_variable_generator; struct convert_in_variable_generator; struct native_convert_out_variable_generator; @@ -108,6 +109,16 @@ template <> struct attributes_needed< ::eolian_mono::native_argument_invocation_generator> : std::integral_constant {}; } +template <> +struct is_eager_generator< ::eolian_mono::native_tuple_argument_invocation_generator> : std::true_type {}; +template <> +struct is_generator< ::eolian_mono::native_tuple_argument_invocation_generator> : std::true_type {}; + +namespace type_traits { +template <> +struct attributes_needed< ::eolian_mono::native_tuple_argument_invocation_generator> : std::integral_constant {}; +} + template <> struct is_eager_generator< ::eolian_mono::native_convert_in_variable_generator> : std::true_type {}; template <> @@ -552,6 +563,28 @@ struct native_argument_invocation_generator } } const native_argument_invocation {}; +struct native_tuple_argument_invocation_generator +{ + template + bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const + { + std::string arg;// = direction_modifier(param); + + if (param_should_use_out_var(param, true)) + arg += out_variable_name(param.param_name); + else if (param_should_use_in_var(param, true)) + arg += in_variable_name(param.param_name); + else if (param.type.original_type.visit(is_fp_visitor{})) + { + arg += escape_keyword(param.param_name) + "_wrapper.ManagedCb"; + } + else // FIXME Wrap data and C function pointers into some kind of structure. + arg += escape_keyword(param.param_name); + + return as_generator(arg).generate(sink, attributes::unused, context); + } +} const native_tuple_argument_invocation {}; + // Generates the correct parameter name when invoking a function struct argument_invocation_generator { diff --git a/src/bin/eolian_mono/eolian/mono/property_definition.hh b/src/bin/eolian_mono/eolian/mono/property_definition.hh new file mode 100644 index 0000000000..df94fc36e8 --- /dev/null +++ b/src/bin/eolian_mono/eolian/mono/property_definition.hh @@ -0,0 +1,383 @@ +/* + * Copyright 2019 by its authors. See AUTHORS. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef EOLIAN_MONO_PROPERTY_DEFINITION_HH +#define EOLIAN_MONO_PROPERTY_DEFINITION_HH + +#include "grammar/generator.hpp" +#include "grammar/klass_def.hpp" + +#include "grammar/indentation.hpp" +#include "grammar/list.hpp" +#include "grammar/alternative.hpp" +#include "type.hh" +#include "parameter.hh" +#include "name_helpers.hh" +#include "using_decl.hh" +#include "blacklist.hh" + +#include + +namespace eolian_mono { + +struct compare_get_and_set_value_type +{ + inline bool operator () (attributes::parameter_def const& get, attributes::parameter_def const& set) const; + inline bool operator () (attributes::type_def const& get, attributes::type_def const& set) const; +}; + +struct compare_get_and_set_value_type_overload +{ + template + bool operator()(T const& /*left*/, U const& /*right*/) const + { + return false; + } + bool operator()(attributes::regular_type_def const& left, attributes::regular_type_def const& right) const + { + return left.base_type == right.base_type + && left.namespaces == right.namespaces; + } + bool operator()(attributes::complex_type_def const& left, attributes::complex_type_def const& right) const + { + return (*this)(left.outer, right.outer) + && std::equal (left.subtypes.begin(), left.subtypes.end(), right.subtypes.begin() + , compare_get_and_set_value_type{}); + } + bool operator()(attributes::klass_name const& left, attributes::klass_name const& right) const + { + return left.namespaces == right.namespaces + && left.eolian_name == right.eolian_name; + } + + typedef bool result_type; +}; + +inline bool compare_get_and_set_value_type::operator () (attributes::parameter_def const& get, attributes::parameter_def const& set) const +{ + return efl::eina::visit(compare_get_and_set_value_type_overload{}, get.type.original_type, set.type.original_type); +} +inline bool compare_get_and_set_value_type::operator () (attributes::type_def const& get, attributes::type_def const& set) const +{ + return efl::eina::visit(compare_get_and_set_value_type_overload{}, get.original_type, set.original_type); +} + +template +bool property_generate_wrapper_both_check(attributes::property_def const& property, Context const& context) +{ + if (blacklist::is_property_blacklisted(property, context)) + return false; + + bool is_interface = context_find_tag(context).current_wrapper_kind == class_context::interface; + bool is_static = (property.getter.is_engaged() && property.getter->is_static) + || (property.setter.is_engaged() && property.setter->is_static); + bool is_concrete = context_find_tag(context).current_wrapper_kind == class_context::concrete; + + if ((is_concrete || is_interface) && is_static) + return false; + + if (!property.getter) + return false; + + if (property.setter) + { + if (property.getter->values.size() == property.setter->values.size()) + { + if (!std::equal (property.getter->values.begin(), property.getter->values.end(), property.setter->values.begin() + , compare_get_and_set_value_type{})) + return false; + } + else + return false; + } + + return true; +} + +template +bool property_generate_wrapper_getter(attributes::property_def const& property, Context const& context) +{ + if (!property_generate_wrapper_both_check (property, context)) + return false; + + if (!property.getter->keys.empty()) + return false; + + if (property.getter->explicit_return_type != attributes::void_) + return false; + + assert (!!property.getter.is_engaged()); + + bool is_interface = context_find_tag(context).current_wrapper_kind == class_context::interface; + if (is_interface) + { + std::string get_scope = property.getter.is_engaged() ? eolian_mono::function_scope_get(*property.getter) : ""; + bool is_get_public = get_scope == "public "; + if (!is_get_public) + return false; + } + return true; +} + +template +bool property_generate_wrapper_setter (attributes::property_def const& property, Context const& context) +{ + if (!property_generate_wrapper_both_check (property, context)) + return false; + if (!property.setter) + return false; + + if (property.setter->explicit_return_type != attributes::void_) + return false; + + if (!property.setter->keys.empty()) + return false; + + bool is_interface = context_find_tag(context).current_wrapper_kind == class_context::interface; + if (property.setter.is_engaged() && is_interface) + { + std::string set_scope = property.setter.is_engaged() ? eolian_mono::function_scope_get(*property.setter) : ""; + bool is_set_public = set_scope == "public "; + if (!is_set_public) + return false; + } + + return true; +} + +struct native_property_function_definition_generator +{ + template + bool generate(OutputIterator sink, attributes::property_def const& property, Context const& context) const + { + EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_property_function_definition_generator: " << property.name << std::endl; + + if(blacklist::is_property_blacklisted(property, context)) + return true; + + auto const& indent = current_indentation(context); + + bool has_wrapper_getter = property_generate_wrapper_getter (property, context); + bool has_wrapper_setter = property_generate_wrapper_setter (property, context); + + auto gen = [&] (attributes::function_def const& f, bool is_set) + { + // Delegate for the C# method we will export to EO as a method implementation. + if(!as_generator + ( + indent << eolian_mono::marshall_annotation(true) << "\n" + << indent << "private delegate " + << eolian_mono::marshall_type(true) + << " " + << string + << "_delegate(" << (f.is_static ? "" : "System.IntPtr obj, System.IntPtr pd") + << ((!f.is_static && f.parameters.size() > 0) ? ", " : "") + << (grammar::attribute_reorder<-1, -1> + ( + (marshall_annotation << " " << marshall_parameter) + ) % ", ") + << ");\n\n") + .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context)) + return false; + + // API delegate is the wrapper for the Eo methods exported from C that we will use from C#. + if(!as_generator + ( + indent << eolian_mono::marshall_annotation(true) << "\n" + << indent << "internal delegate " + << eolian_mono::marshall_type(true) + << " " + << string << "_api_delegate(" << (f.is_static ? "" : "System.IntPtr obj") + << ((!f.is_static && f.parameters.size() > 0) ? ", " : "") + << (grammar::attribute_reorder<-1, -1> + ( + (marshall_annotation << " " << marshall_parameter) + ) % ", ") + << ");\n\n") + .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context)) + return false; + + // Delegate holder (so it can't be collected). + if(!as_generator + (indent << "internal static readonly Efl.Eo.FunctionWrapper<" << string << "_api_delegate> " << string << "_ptr = new Efl.Eo.FunctionWrapper<" + << string << "_api_delegate>(Module, \"" << string << "\");\n\n") + .generate(sink, std::make_tuple(f.c_name, f.c_name, f.c_name, f.c_name), context)) + return false; + + // We do not generate the wrapper to be called from C for non public interface member directly. + if (blacklist::is_non_public_interface_member(f, *implementing_klass)) + return true; + + // Do not generate static method in interface + if (((implementing_klass->type == attributes::class_type::interface_) || + (implementing_klass->type == attributes::class_type::mixin)) && f.is_static) + return true; + + // Actual method implementation to be called from C. + std::string return_type; + if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context)) + return false; + + std::string klass_cast_name; + if ((implementing_klass->type == attributes::class_type::interface_) || + ((implementing_klass->type == attributes::class_type::mixin) && !f.is_static)) + klass_cast_name = name_helpers::klass_interface_name(*implementing_klass); + else + klass_cast_name = name_helpers::klass_inherit_name(*implementing_klass); + + std::string self = "Efl.Eo.Globals.Super(obj, Efl.Eo.Globals.GetClass(obj))"; + + if (f.is_static) + self = ""; + + if(!as_generator + (indent << "[SuppressMessage(\"Microsoft.Reliability\", \"CA2000:DisposeObjectsBeforeLosingScope\", Justification = \"The instantiated objects can be stored in the called Managed API method.\")]\n" + << indent << "private static " + << eolian_mono::marshall_type(true) << " " + << string + << "(System.IntPtr obj, System.IntPtr pd" + << *(", " << marshall_parameter) + << ")\n" + << indent << "{\n" + << indent << scope_tab << "Eina.Log.Debug(\"function " << string << " was called\");\n" + << indent << scope_tab << "var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);\n" + << indent << scope_tab << "if (ws != null)\n" + << indent << scope_tab << "{\n" + << indent << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble() << "\n" + << indent << scope_tab << scope_tab << "try\n" + << indent << scope_tab << scope_tab << "{\n" + ) + .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters + , /***/f.c_name/***/ + , f + ), context)) + return false; + if (is_set/* && has_wrapper_setter*/) + { + if(!as_generator + ( + indent << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "") + << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).") << string + ) + .generate(sink, std::make_tuple(name_helpers::property_managed_name(property), f.parameters), context)) + return false; + + if(!f.keys.empty() && !as_generator(lit("[(") << (native_argument_invocation % ", ") << ")]").generate (sink, f.keys, context)) + return false; + + if(!as_generator + (" = (" + << (native_tuple_argument_invocation % ", ") << ");\n" + ) + .generate(sink, f.values, context)) + return false; + } + else if (!is_set/* && has_wrapper_getter*/) + { + if(!as_generator + ( + indent << scope_tab << scope_tab << scope_tab << "var ret = " + << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).") + << string + + ) + .generate(sink, std::make_tuple(name_helpers::property_managed_name(property)), context)) + return false; + + if(!f.keys.empty() && !as_generator(lit("[(") << (native_argument_invocation % ", ") << ")]").generate (sink, f.keys, context)) + return false; + + if (!as_generator(";\n").generate (sink, attributes::unused, context)) + return false; + + } + // else if (!as_generator + // (indent << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "") + // << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).") << string + // << "(" << (native_argument_invocation % ", ") << ");\n" + // ).generate(sink, std::make_tuple(name_helpers::managed_method_name(f), f.parameters), context)) + // return false; + + if(!as_generator + ( + indent << scope_tab << scope_tab << "}\n" + << indent << scope_tab << scope_tab << "catch (Exception e)\n" + << indent << scope_tab << scope_tab << "{\n" + << indent << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n" + << indent << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);\n" + << indent << scope_tab << scope_tab << "}\n\n" + << indent << eolian_mono::native_function_definition_epilogue(*implementing_klass) << "\n" + << indent << scope_tab << "}\n" + << indent << scope_tab << "else\n" + << indent << scope_tab << "{\n" + << indent << scope_tab << scope_tab << (return_type != "void" ? "return " : "") << string + << "_ptr.Value.Delegate(" << self << ((!f.is_static && f.parameters.size() > 0) ? ", " : "") << (argument % ", ") << ");\n" + << indent << scope_tab << "}\n" + << indent << "}\n\n" + ) + .generate(sink, std::make_tuple(f, f.c_name, f.parameters), context)) + return false; + + // Static functions do not need to be called from C + if (f.is_static) + return true; + + // This is the delegate that will be passed to Eo to be called from C. + if(!as_generator( + indent << "private static " << f.c_name << "_delegate " << f.c_name << "_static_delegate;\n\n" + ).generate(sink, attributes::unused, context)) + return false; + return true; + }; + + bool r = true; + if(r && property.getter && has_wrapper_getter + && helpers::is_function_registerable (*property.getter, *implementing_klass)) + r &= gen (*property.getter, false); + if(r && property.setter && has_wrapper_setter + && helpers::is_function_registerable (*property.setter, *implementing_klass)) + r &= gen (*property.setter, true); + return r; + } + + attributes::klass_def const* implementing_klass, *klass_from_property; +}; + +struct native_property_function_definition_parameterized +{ + native_property_function_definition_generator operator()(attributes::klass_def const& klass + , attributes::klass_def const& prop_from_klass) const + { + return {&klass, &prop_from_klass}; + } +} const native_property_function_definition; + +} + +namespace efl { namespace eolian { namespace grammar { + +template <> +struct is_eager_generator< ::eolian_mono::native_property_function_definition_generator> : std::true_type {}; +template <> +struct is_generator< ::eolian_mono::native_property_function_definition_generator> : std::true_type {}; + +namespace type_traits { + +template <> +struct attributes_needed< ::eolian_mono::native_property_function_definition_generator> : std::integral_constant {}; + +} } } } + +#endif diff --git a/src/bindings/cxx/eina_cxx/eina_variant.hh b/src/bindings/cxx/eina_cxx/eina_variant.hh index a337f2e211..112549020f 100644 --- a/src/bindings/cxx/eina_cxx/eina_variant.hh +++ b/src/bindings/cxx/eina_cxx/eina_variant.hh @@ -24,9 +24,21 @@ #include #include +#include namespace efl { namespace eina { +template +struct variant; + +template +struct variant_size : std::tuple_size>::type +{ +}; + +template +struct variant_as_tuple; + namespace _impl { template @@ -51,7 +63,57 @@ template struct find : find_impl<0u, T, U, Args...> {}; +template +struct visit_impl_meta_args +{ + typedef std::integral_constant current_type_index; + typedef std::integral_constant current_variant_index; + typedef TupleVariant variants; + // typedef typename std::tuple_element::type current_variant; + // typedef typename variant_as_tuple::type current_variant_types; + // typedef typename std::tuple_element::type current_type; + typedef TypesFound types_found; +}; + +template struct current_variant_types +{ + typedef typename std::tuple_element::type current_variant; + typedef typename variant_as_tuple::type type; +}; } + +// template +// struct call_n_visitor; + +// template +// struct call_n_visitor +// { + + /* + template + static typename F::result_type call(int type, void* buffer, F f) + { + if(type == N) + { + using std::tuple_element; + typedef typename tuple_element::type type; + type* o = static_cast(buffer); + return f(*o); + } + else + return call_visitor::call(type, buffer, f); + } + */ + +// template +// struct call_n_visitor +// { +// template +// static typename F::result_type call(int, void const*, F, Variants&&... variants) +// { +// std::abort(); +// } +// }; template struct call_visitor @@ -306,6 +368,11 @@ struct variant { return call_visitor<0u, sizeof...(Args), std::tuple>::call(type, static_cast(&buffer), f); } + + constexpr std::size_t index() const + { + return type; + } private: template @@ -332,6 +399,103 @@ private: * Member variable for holding the contained value. */ buffer_type buffer; + + template + friend struct variant_as_tuple; + + // template + // friend typename F::result_type visit_impl2 + // (std::false_type, std::false_type + // , _impl::visit_impl_meta_args, F&& f, TupleVariant&& variants, index_sequence); + + // template + // friend typename F::result_type visit_impl2 + // (std::true_type, std::false_type + // , _impl::visit_impl_meta_args, F&& f, TupleVariant&& variants, index_sequence); + // template + // friend typename F::result_type visit_impl2 + // (std::false_type, std::true_type + // , _impl::visit_impl_meta_args, F&& f, TupleVariant&& variants, index_sequence); + + // // template + // // friend typename F::result_type visit_impl2 + // // (std::true_type, std::false_type + // // , _impl::visit_impl_meta_args, F&& f, TupleVariant&& variants) + // // { + // // } + + // // template + // // friend typename F::result_type call + // // (std::true_type, int, F &&, Variants&&... variants) + // // { + // // std::abort(); + // // } + + // // template + // // friend typename F::result_type call (F&&f, Variant&& variant, Variants&&... variants) + // // { + // // return call (std::integral_constant::value)>{} + // // , variant.type, std::forward(f), std::forward(variant), std::forward(variants)...); + // // } + + // // template + // // friend typename F::result_type call (F&&f, Variant&& variant, Variants&&... variants) + // // { + // // return call (std::integral_constant::value)>{} + // // , variant.type, std::forward(f), std::forward(variant), std::forward(variants)...); + // // } + + // template + // friend typename F::result_type visit_impl (F&& f, Variants&&... variants); +}; + + +template +struct variant_as_tuple> +{ + typedef std::tuple type; +}; + +template +struct variant_as_tuple> +{ + typedef std::tuple type; +}; + +template +struct variant_as_tuple> +{ + typedef std::tuple type; +}; + +template +struct variant_as_tuple> +{ + typedef std::tuple type; +}; + +template +struct variant_as_tuple&> +{ + typedef std::tuple type; +}; + +template +struct variant_as_tuple&> +{ + typedef std::tuple type; +}; + +template +struct variant_as_tuple&> +{ + typedef std::tuple type; +}; + +template +struct variant_as_tuple&> +{ + typedef std::tuple type; }; template @@ -372,7 +536,80 @@ T const& get(variantconst& variant, typename std::enable_if<_impl::is_o else throw std::logic_error(""); } - + +template + typename F::result_type visit_impl2 + (std::false_type, std::true_type + , _impl::visit_impl_meta_args, F&& f, TupleVariant&& variants + , eina::index_sequence) + { + return f (eina::get::type>(std::get(variants))...); + } + + template + typename F::result_type visit_impl2 + (std::true_type, std::false_type + , _impl::visit_impl_meta_args, F&&, TupleVariant&&, eina::index_sequence) + { + std::abort(); + } + + + template + typename F::result_type visit_impl2 (std::false_type, std::false_type + , _impl::visit_impl_meta_args, F&& f, TupleVariant&& variants + , index_sequence) + { + using std::tuple_element; + typedef _impl::visit_impl_meta_args meta_args; + if(std::get(variants).index() == NT) + { + typedef typename _impl::current_variant_types::type variant_types; + typedef typename tuple_element::type type; + std::integral_constant::value == NV+1)> is_true {}; + return visit_impl2( std::false_type{} + , is_true + , _impl::visit_impl_meta_args<0u, NV+1, Tuple, typename _mpl::push_back::type>{} + , std::forward(f), std::forward(variants) + , make_index_sequence::value>{}); + } + else + { + typedef typename _impl::current_variant_types::type variant_types; + return visit_impl2 (std::integral_constant::value == NT+1)>{} + , std::false_type{} + , _impl::visit_impl_meta_args{}, std::forward(f), std::forward(variants) + , make_index_sequence::value>{}); + } + } + + template + typename F::result_type visit_impl_aux (std::false_type fals, std::false_type + , _impl::visit_impl_meta_args args, F&& f, TupleVariant&& variants) + { + return visit_impl2 (fals, fals, args, std::forward(f), std::forward(variants) + , make_index_sequence::value>{}); + } + + template + typename F::result_type visit_impl (F&& f, Variants&&... variants) + { + return visit_impl_aux + (std::false_type{} + , std::false_type{} + , _impl::visit_impl_meta_args + <0u, 0u + , std::tuple::type...>, std::tuple<>>{}, std::forward(f), std::forward_as_tuple(std::forward(variants)...)); + } + +template +auto visit (F&& function, Variants&& ... variants) -> typename F::result_type +{ + return visit_impl (std::forward(function), std::forward(variants)...); +} + } } #endif + diff --git a/src/bindings/mono/efl_mono/GenericModel.cs b/src/bindings/mono/efl_mono/GenericModel.cs index ae1b69cf3e..c23eeb64ab 100644 --- a/src/bindings/mono/efl_mono/GenericModel.cs +++ b/src/bindings/mono/efl_mono/GenericModel.cs @@ -33,20 +33,13 @@ public class GenericModel : Efl.Object, Efl.IModel /// The list of properties available in the wrapped model. public IEnumerable Properties { - get { return GetProperties(); } + get { return model.Properties; } } /// The number of children in the wrapped model. public uint ChildrenCount { - get { return GetChildrenCount(); } - } - - /// The list of properties available in the wrapped model. - /// The list of properties in the model. - public IEnumerable GetProperties() - { - return model.GetProperties(); + get { return model.ChildrenCount; } } /// Gets the value of the given property in the wrapped model. @@ -67,13 +60,6 @@ public class GenericModel : Efl.Object, Efl.IModel return model.SetProperty(property, value); } - /// Returns the number of children in the wrapped model. - /// The number of children. - public uint GetChildrenCount() - { - return model.GetChildrenCount(); - } - /// Returns an that will resolve when the property is ready to be read. /// The property of the model. /// An that resolves when the property is ready. @@ -169,10 +155,10 @@ public class GenericModel : Efl.Object, Efl.IModel /// Get children as specified by iterator. /// - /// Provided index have to be between 0 and . + /// Provided index have to be between 0 and . /// - /// This function might rely on as a fallback. - /// Indices of the requested children. + /// This function might rely on as a fallback.
Since EFL 1.23.
+ /// Indices of the requested children. /// Array of children public Eina.Future GetChildrenIndex(IEnumerable indices) { diff --git a/src/bindings/mono/eo_mono/EoWrapper.cs b/src/bindings/mono/eo_mono/EoWrapper.cs index db618232c4..e4ff8669e6 100644 --- a/src/bindings/mono/eo_mono/EoWrapper.cs +++ b/src/bindings/mono/eo_mono/EoWrapper.cs @@ -227,7 +227,7 @@ public abstract class EoWrapper : IWrapper, IDisposable public void Del() { // FIXME Implement this - ((Efl.Object)this).SetParent(null); + ((Efl.Object)this).Parent = null; Dispose(); } diff --git a/src/lib/eolian_cxx/grammar/context.hpp b/src/lib/eolian_cxx/grammar/context.hpp index 9e175a8ee5..e7bc014acb 100644 --- a/src/lib/eolian_cxx/grammar/context.hpp +++ b/src/lib/eolian_cxx/grammar/context.hpp @@ -40,28 +40,25 @@ context_add_tag(NewTag const& tag, context_null context) return context_cons{tag, context}; } -template -constexpr context_cons -context_replace_tag(Tag const& tag, context_cons const& context - , typename std::enable_if::value>::type* = nullptr) +template +constexpr context_cons +context_replace_tag(Tag const& tag, context_cons const& context) { return {tag, context.tail}; } -template -constexpr context_cons -context_replace_tag(Tag const& tag, context_cons const& context - , typename std::enable_if::value>::type* = nullptr) -{ - return {context.tag, context_replace_tag(tag, context.tail)}; -} - template -constexpr context_null +constexpr context_cons context_replace_tag(Tag const& tag, context_null const&) { - static_assert(std::is_same::value, "Tag type not available in this generation context"); - return tag; + return context_cons{tag, context_null{}}; +} + +template +constexpr context_cons(), std::declval()))> +context_replace_tag(Tag const& tag, context_cons const& context) +{ + return {context.tag, context_replace_tag(tag, context.tail)}; } template diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs index 162eac63ba..494dc8a62e 100644 --- a/src/tests/efl_mono/Eina.cs +++ b/src/tests/efl_mono/Eina.cs @@ -576,10 +576,10 @@ class TestEinaArray var a = new Eina.Array(); Test.Assert(a.Handle != IntPtr.Zero); var o = new Dummy.Numberwrapper(); - o.SetNumber(88); + o.Number = 88; Test.Assert(a.Push(o)); Test.Assert(a[0].NativeHandle == o.NativeHandle); - Test.Assert(a[0].GetNumber() == 88); + Test.Assert(a[0].Number == 88); o.Dispose(); a.Dispose(); } @@ -619,11 +619,11 @@ class TestEinaArray var a = new Eina.Array(); Test.Assert(a.Handle != IntPtr.Zero); var o = new Dummy.Numberwrapper(); - o.SetNumber(88); + o.Number = 88; Test.Assert(a.Push(o)); var p = a.Pop(); Test.Assert(p.NativeHandle == o.NativeHandle); - Test.Assert(p.GetNumber() == 88); + Test.Assert(p.Number == 88); Test.Assert(a.Count() == 0); o.Dispose(); a.Dispose(); @@ -674,25 +674,25 @@ class TestEinaArray Test.Assert(a.Handle != IntPtr.Zero); var o1 = new Dummy.Numberwrapper(); - o1.SetNumber(88); + o1.Number = 88; Test.Assert(a.Push(o1)); Test.Assert(a[0].NativeHandle == o1.NativeHandle); - Test.Assert(a[0].GetNumber() == 88); + Test.Assert(a[0].Number == 88); var o2 = new Dummy.Numberwrapper(); - o2.SetNumber(44); + o2.Number = 44; a.DataSet(0, o2); Test.Assert(a[0].NativeHandle == o2.NativeHandle); - Test.Assert(a[0].GetNumber() == 44); + Test.Assert(a[0].Number == 44); var o3 = new Dummy.Numberwrapper(); - o3.SetNumber(22); + o3.Number = 22; a[0] = o3; Test.Assert(a[0].NativeHandle == o3.NativeHandle); - Test.Assert(a[0].GetNumber() == 22); + Test.Assert(a[0].Number == 22); o3.Dispose(); o2.Dispose(); o1.Dispose(); @@ -758,24 +758,24 @@ class TestEinaArray Test.Assert(a.Count() == 0); var o1 = new Dummy.Numberwrapper(); - o1.SetNumber(88); + o1.Number = 88; Test.Assert(a.Push(o1)); Test.Assert(a[0].NativeHandle == o1.NativeHandle); - Test.Assert(a[0].GetNumber() == 88); + Test.Assert(a[0].Number == 88); Test.Assert(a.Count() == 1); var o2 = new Dummy.Numberwrapper(); - o2.SetNumber(44); + o2.Number = 44; Test.Assert(a.Push(o2)); Test.Assert(a[1].NativeHandle == o2.NativeHandle); - Test.Assert(a[1].GetNumber() == 44); + Test.Assert(a[1].Number == 44); Test.Assert(a.Count() == 2); var o3 = new Dummy.Numberwrapper(); - o3.SetNumber(22); + o3.Number = 22; Test.Assert(a.Push(o3)); Test.Assert(a[2].NativeHandle == o3.NativeHandle); - Test.Assert(a[2].GetNumber() == 22); + Test.Assert(a[2].Number == 22); Test.Assert(a.Count() == 3); o3.Dispose(); @@ -891,9 +891,9 @@ class TestEinaArray var a = new Dummy.Numberwrapper(); var b = new Dummy.Numberwrapper(); var c = new Dummy.Numberwrapper(); - a.SetNumber(88); - b.SetNumber(44); - c.SetNumber(22); + a.Number = 88; + b.Number = 44; + c.Number = 22; var cmp = new Dummy.Numberwrapper[]{a, b, c}; var arr = new Eina.Array(); @@ -905,7 +905,7 @@ class TestEinaArray int i = 0; foreach (Dummy.Numberwrapper e in arr) { - Test.AssertEquals(cmp[i].GetNumber(), e.GetNumber()); + Test.AssertEquals(cmp[i].Number, e.Number); Test.Assert(cmp[i].NativeHandle == e.NativeHandle); ++i; } @@ -1247,10 +1247,10 @@ class TestEinaInarray var a = new Eina.Inarray(); Test.Assert(a.Handle != IntPtr.Zero); var o = new Dummy.Numberwrapper(); - o.SetNumber(88); + o.Number = 88; Test.Assert(a.Push(o) == 0); Test.Assert(a[0].NativeHandle == o.NativeHandle); - Test.Assert(a[0].GetNumber() == 88); + Test.Assert(a[0].Number == 88); o.Dispose(); a.Dispose(); } @@ -1280,11 +1280,11 @@ class TestEinaInarray var a = new Eina.Inarray(); Test.Assert(a.Handle != IntPtr.Zero); var o = new Dummy.Numberwrapper(); - o.SetNumber(88); + o.Number = 88; Test.Assert(a.Push(o) >= 0); var p = a.Pop(); Test.Assert(p.NativeHandle == o.NativeHandle); - Test.Assert(p.GetNumber() == 88); + Test.Assert(p.Number == 88); Test.Assert(a.Count() == 0); o.Dispose(); a.Dispose(); @@ -1326,26 +1326,26 @@ class TestEinaInarray Test.Assert(a.Handle != IntPtr.Zero); var o1 = new Dummy.Numberwrapper(); - o1.SetNumber(88); + o1.Number = 88; Test.Assert(a.Push(o1) >= 0); Test.Assert(a[0].NativeHandle == o1.NativeHandle); - Test.Assert(a[0].GetNumber() == 88); + Test.Assert(a[0].Number == 88); var o2 = new Dummy.Numberwrapper(); - o2.SetNumber(44); + o2.Number = 44; a.ReplaceAt(0, o2); Test.Assert(a[0].NativeHandle == o2.NativeHandle); - Test.Assert(a[0].GetNumber() == 44); + Test.Assert(a[0].Number == 44); Test.Assert(a.Count() == 1); var o3 = new Dummy.Numberwrapper(); - o3.SetNumber(22); + o3.Number = 22; a[0] = o3; Test.Assert(a[0].NativeHandle == o3.NativeHandle); - Test.Assert(a[0].GetNumber() == 22); + Test.Assert(a[0].Number == 22); Test.Assert(a.Count() == 1); o3.Dispose(); @@ -1396,24 +1396,24 @@ class TestEinaInarray Test.Assert(a.Count() == 0); var o1 = new Dummy.Numberwrapper(); - o1.SetNumber(88); + o1.Number = 88; Test.Assert(a.Push(o1) == 0); Test.Assert(a[0].NativeHandle == o1.NativeHandle); - Test.Assert(a[0].GetNumber() == 88); + Test.Assert(a[0].Number == 88); Test.Assert(a.Count() == 1); var o2 = new Dummy.Numberwrapper(); - o2.SetNumber(44); + o2.Number = 44; Test.Assert(a.Push(o2) == 1); Test.Assert(a[1].NativeHandle == o2.NativeHandle); - Test.Assert(a[1].GetNumber() == 44); + Test.Assert(a[1].Number == 44); Test.Assert(a.Count() == 2); var o3 = new Dummy.Numberwrapper(); - o3.SetNumber(22); + o3.Number = 22; Test.Assert(a.Push(o3) == 2); Test.Assert(a[2].NativeHandle == o3.NativeHandle); - Test.Assert(a[2].GetNumber() == 22); + Test.Assert(a[2].Number == 22); Test.Assert(a.Count() == 3); o3.Dispose(); @@ -1495,9 +1495,9 @@ class TestEinaInarray var a = new Dummy.Numberwrapper(); var b = new Dummy.Numberwrapper(); var c = new Dummy.Numberwrapper(); - a.SetNumber(88); - b.SetNumber(44); - c.SetNumber(22); + a.Number = 88; + b.Number = 44; + c.Number = 22; var cmp = new Dummy.Numberwrapper[]{a, b, c}; var arr = new Eina.Inarray(); @@ -1509,7 +1509,7 @@ class TestEinaInarray int i = 0; foreach (Dummy.Numberwrapper e in arr) { - Test.AssertEquals(cmp[i].GetNumber(), e.GetNumber()); + Test.AssertEquals(cmp[i].Number, e.Number); Test.Assert(cmp[i].NativeHandle == e.NativeHandle); ++i; } @@ -1571,25 +1571,25 @@ class TestEinaList var lst = new Eina.List(); var o1 = new Dummy.Numberwrapper(); - o1.SetNumber(88); + o1.Number = 88; lst.Append(o1); Test.Assert(lst[0].NativeHandle == o1.NativeHandle); - Test.Assert(lst[0].GetNumber() == 88); + Test.Assert(lst[0].Number == 88); var o2 = new Dummy.Numberwrapper(); - o2.SetNumber(44); + o2.Number = 44; lst.DataSet(0, o2); Test.Assert(lst[0].NativeHandle == o2.NativeHandle); - Test.Assert(lst[0].GetNumber() == 44); + Test.Assert(lst[0].Number == 44); var o3 = new Dummy.Numberwrapper(); - o3.SetNumber(22); + o3.Number = 22; lst[0] = o3; Test.Assert(lst[0].NativeHandle == o3.NativeHandle); - Test.Assert(lst[0].GetNumber() == 22); + Test.Assert(lst[0].Number == 22); o3.Dispose(); o2.Dispose(); o1.Dispose(); @@ -1651,24 +1651,24 @@ class TestEinaList Test.Assert(lst.Count() == 0); var o1 = new Dummy.Numberwrapper(); - o1.SetNumber(88); + o1.Number = 88; lst.Append(o1); Test.Assert(lst[0].NativeHandle == o1.NativeHandle); - Test.Assert(lst[0].GetNumber() == 88); + Test.Assert(lst[0].Number == 88); Test.Assert(lst.Count() == 1); var o2 = new Dummy.Numberwrapper(); - o2.SetNumber(44); + o2.Number = 44; lst.Append(o2); Test.Assert(lst[1].NativeHandle == o2.NativeHandle); - Test.Assert(lst[1].GetNumber() == 44); + Test.Assert(lst[1].Number == 44); Test.Assert(lst.Count() == 2); var o3 = new Dummy.Numberwrapper(); - o3.SetNumber(22); + o3.Number = 22; lst.Append(o3); Test.Assert(lst[2].NativeHandle == o3.NativeHandle); - Test.Assert(lst[2].GetNumber() == 22); + Test.Assert(lst[2].Number == 22); Test.Assert(lst.Count() == 3); o3.Dispose(); o2.Dispose(); @@ -1779,24 +1779,24 @@ class TestEinaList Test.Assert(lst.Count() == 0); var o1 = new Dummy.Numberwrapper(); - o1.SetNumber(88); + o1.Number = 88; lst.Prepend(o1); Test.Assert(lst[0].NativeHandle == o1.NativeHandle); - Test.Assert(lst[0].GetNumber() == 88); + Test.Assert(lst[0].Number == 88); Test.Assert(lst.Count() == 1); var o2 = new Dummy.Numberwrapper(); - o2.SetNumber(44); + o2.Number = 44; lst.Prepend(o2); Test.Assert(lst[0].NativeHandle == o2.NativeHandle); - Test.Assert(lst[0].GetNumber() == 44); + Test.Assert(lst[0].Number == 44); Test.Assert(lst.Count() == 2); var o3 = new Dummy.Numberwrapper(); - o3.SetNumber(22); + o3.Number = 22; lst.Prepend(o3); Test.Assert(lst[0].NativeHandle == o3.NativeHandle); - Test.Assert(lst[0].GetNumber() == 22); + Test.Assert(lst[0].Number == 22); Test.Assert(lst.Count() == 3); o3.Dispose(); @@ -2025,9 +2025,9 @@ class TestEinaList var a = new Dummy.Numberwrapper(); var b = new Dummy.Numberwrapper(); var c = new Dummy.Numberwrapper(); - a.SetNumber(88); - b.SetNumber(44); - c.SetNumber(22); + a.Number = 88; + b.Number = 44; + c.Number = 22; var cmp = new Dummy.Numberwrapper[]{a, b, c}; var lst = new Eina.List(); @@ -2038,7 +2038,7 @@ class TestEinaList int i = 0; foreach (Dummy.Numberwrapper e in lst) { - Test.AssertEquals(cmp[i].GetNumber(), e.GetNumber()); + Test.AssertEquals(cmp[i].Number, e.Number); Test.Assert(cmp[i].NativeHandle == e.NativeHandle); ++i; } @@ -2366,25 +2366,25 @@ class TestEinaInlist var lst = new Eina.Inlist(); var o1 = new Dummy.Numberwrapper(); - o1.SetNumber(88); + o1.Number = 88; lst.Append(o1); Test.Assert(lst[0].NativeHandle == o1.NativeHandle); - Test.Assert(lst[0].GetNumber() == 88); + Test.Assert(lst[0].Number == 88); var o2 = new Dummy.Numberwrapper(); - o2.SetNumber(44); + o2.Number = 44; lst.DataSet(0, o2); Test.Assert(lst[0].NativeHandle == o2.NativeHandle); - Test.Assert(lst[0].GetNumber() == 44); + Test.Assert(lst[0].Number == 44); var o3 = new Dummy.Numberwrapper(); - o3.SetNumber(22); + o3.Number = 22; lst[0] = o3; Test.Assert(lst[0].NativeHandle == o3.NativeHandle); - Test.Assert(lst[0].GetNumber() == 22); + Test.Assert(lst[0].Number == 22); Test.Assert(lst.Count() == 1); o3.Dispose(); @@ -2432,24 +2432,24 @@ class TestEinaInlist Test.Assert(lst.Count() == 0); var o1 = new Dummy.Numberwrapper(); - o1.SetNumber(88); + o1.Number = 88; lst.Append(o1); Test.Assert(lst[0].NativeHandle == o1.NativeHandle); - Test.Assert(lst[0].GetNumber() == 88); + Test.Assert(lst[0].Number == 88); Test.Assert(lst.Count() == 1); var o2 = new Dummy.Numberwrapper(); - o2.SetNumber(44); + o2.Number = 44; lst.Append(o2); Test.Assert(lst[1].NativeHandle == o2.NativeHandle); - Test.Assert(lst[1].GetNumber() == 44); + Test.Assert(lst[1].Number == 44); Test.Assert(lst.Count() == 2); var o3 = new Dummy.Numberwrapper(); - o3.SetNumber(22); + o3.Number = 22; lst.Append(o3); Test.Assert(lst[2].NativeHandle == o3.NativeHandle); - Test.Assert(lst[2].GetNumber() == 22); + Test.Assert(lst[2].Number == 22); Test.Assert(lst.Count() == 3); o3.Dispose(); o2.Dispose(); @@ -2528,24 +2528,24 @@ class TestEinaInlist Test.Assert(lst.Count() == 0); var o1 = new Dummy.Numberwrapper(); - o1.SetNumber(88); + o1.Number = 88; lst.Prepend(o1); Test.Assert(lst[0].NativeHandle == o1.NativeHandle); - Test.Assert(lst[0].GetNumber() == 88); + Test.Assert(lst[0].Number == 88); Test.Assert(lst.Count() == 1); var o2 = new Dummy.Numberwrapper(); - o2.SetNumber(44); + o2.Number = 44; lst.Prepend(o2); Test.Assert(lst[0].NativeHandle == o2.NativeHandle); - Test.Assert(lst[0].GetNumber() == 44); + Test.Assert(lst[0].Number == 44); Test.Assert(lst.Count() == 2); var o3 = new Dummy.Numberwrapper(); - o3.SetNumber(22); + o3.Number = 22; lst.Prepend(o3); Test.Assert(lst[0].NativeHandle == o3.NativeHandle); - Test.Assert(lst[0].GetNumber() == 22); + Test.Assert(lst[0].Number == 22); Test.Assert(lst.Count() == 3); o3.Dispose(); o2.Dispose(); @@ -2590,9 +2590,9 @@ class TestEinaInlist var a = new Dummy.Numberwrapper(); var b = new Dummy.Numberwrapper(); var c = new Dummy.Numberwrapper(); - a.SetNumber(88); - b.SetNumber(44); - c.SetNumber(22); + a.Number = 88; + b.Number = 44; + c.Number = 22; var cmp = new Dummy.Numberwrapper[]{a, b, c}; var lst = new Eina.Inlist(); @@ -2603,7 +2603,7 @@ class TestEinaInlist int i = 0; foreach (Dummy.Numberwrapper e in lst) { - Test.AssertEquals(cmp[i].GetNumber(), e.GetNumber()); + Test.AssertEquals(cmp[i].Number, e.Number); Test.Assert(cmp[i].NativeHandle == e.NativeHandle); ++i; } @@ -2690,17 +2690,17 @@ class TestEinaHash hsh[a] = aa; Test.Assert(hsh[a].NativeHandle == aa.NativeHandle); - Test.Assert(hsh[a].GetNumber() == aa.GetNumber()); + Test.Assert(hsh[a].Number == aa.Number); Test.Assert(hsh.Count == 1); hsh[b] = bb; Test.Assert(hsh[b].NativeHandle == bb.NativeHandle); - Test.Assert(hsh[b].GetNumber() == bb.GetNumber()); + Test.Assert(hsh[b].Number == bb.Number); Test.Assert(hsh.Count == 2); hsh[c] = cc; Test.Assert(hsh[c].NativeHandle == cc.NativeHandle); - Test.Assert(hsh[c].GetNumber() == cc.GetNumber()); + Test.Assert(hsh[c].Number == cc.Number); Test.Assert(hsh.Count == 3); @@ -2810,17 +2810,17 @@ class TestEinaHash hsh[b] = bb; hsh[c] = cc; - dct[a.GetNumber()] = aa; - dct[b.GetNumber()] = bb; - dct[c.GetNumber()] = cc; + dct[a.Number] = aa; + dct[b.Number] = bb; + dct[c.Number] = cc; int count = 0; foreach (KeyValuePair kvp in hsh) { - Test.Assert(dct[kvp.Key.GetNumber()].NativeHandle == kvp.Value.NativeHandle); - Test.Assert(dct[kvp.Key.GetNumber()].GetNumber() == kvp.Value.GetNumber()); - dct.Remove(kvp.Key.GetNumber()); + Test.Assert(dct[kvp.Key.Number].NativeHandle == kvp.Value.NativeHandle); + Test.Assert(dct[kvp.Key.Number].Number == kvp.Value.Number); + dct.Remove(kvp.Key.Number); ++count; } @@ -3121,11 +3121,11 @@ class TestEinaHash Test.Assert(t.EinaHashObjIn(hsh, nwk1, nwv1, out nwk2, out nwv2)); Test.Assert(hsh.Own); Test.Assert(hsh[nwk1].NativeHandle == nwv1.NativeHandle); - Test.Assert(hsh[nwk1].GetNumber() == nwv1.GetNumber()); - Test.Assert(hsh[nwk1].GetNumber() == 222); + Test.Assert(hsh[nwk1].Number == nwv1.Number); + Test.Assert(hsh[nwk1].Number == 222); Test.Assert(hsh[nwk2].NativeHandle == nwv2.NativeHandle); - Test.Assert(hsh[nwk2].GetNumber() == nwv2.GetNumber()); - Test.Assert(hsh[nwk2].GetNumber() == 444); + Test.Assert(hsh[nwk2].Number == nwv2.Number); + Test.Assert(hsh[nwk2].Number == 444); nwk1.Dispose(); nwk2.Dispose(); nwv1.Dispose(); @@ -3147,11 +3147,11 @@ class TestEinaHash Test.Assert(t.EinaHashObjInOwn(hsh, nwk1, nwv1, out nwk2, out nwv2)); Test.Assert(!hsh.Own); Test.Assert(hsh[nwk1].NativeHandle == nwv1.NativeHandle); - Test.Assert(hsh[nwk1].GetNumber() == nwv1.GetNumber()); - Test.Assert(hsh[nwk1].GetNumber() == 222); + Test.Assert(hsh[nwk1].Number == nwv1.Number); + Test.Assert(hsh[nwk1].Number == 222); Test.Assert(hsh[nwk2].NativeHandle == nwv2.NativeHandle); - Test.Assert(hsh[nwk2].GetNumber() == nwv2.GetNumber()); - Test.Assert(hsh[nwk2].GetNumber() == 444); + Test.Assert(hsh[nwk2].Number == nwv2.Number); + Test.Assert(hsh[nwk2].Number == 444); hsh.Dispose(); Test.Assert(hsh.Handle == IntPtr.Zero); Test.Assert(t.CheckEinaHashObjInOwn(nwk1, nwv1, nwk2, nwv2)); @@ -3171,8 +3171,8 @@ class TestEinaHash Test.Assert(t.EinaHashObjOut(out hsh, out nwk1, out nwv1)); Test.Assert(!hsh.Own); Test.Assert(hsh[nwk1].NativeHandle == nwv1.NativeHandle); - Test.Assert(hsh[nwk1].GetNumber() == nwv1.GetNumber()); - Test.Assert(hsh[nwk1].GetNumber() == 222); + Test.Assert(hsh[nwk1].Number == nwv1.Number); + Test.Assert(hsh[nwk1].Number == 222); Dummy.Numberwrapper nwk2 = NW(44); Dummy.Numberwrapper nwv2 = NW(444); hsh[nwk2] = nwv2; @@ -3195,8 +3195,8 @@ class TestEinaHash Test.Assert(t.EinaHashObjOutOwn(out hsh, out nwk1, out nwv1)); Test.Assert(hsh.Own); Test.Assert(hsh[nwk1].NativeHandle == nwv1.NativeHandle); - Test.Assert(hsh[nwk1].GetNumber() == nwv1.GetNumber()); - Test.Assert(hsh[nwk1].GetNumber() == 222); + Test.Assert(hsh[nwk1].Number == nwv1.Number); + Test.Assert(hsh[nwk1].Number == 222); Dummy.Numberwrapper nwk2 = NW(44); Dummy.Numberwrapper nwv2 = NW(444); hsh[nwk2] = nwv2; @@ -3218,8 +3218,8 @@ class TestEinaHash var hsh = t.EinaHashObjReturn(out nwk1, out nwv1); Test.Assert(!hsh.Own); Test.Assert(hsh[nwk1].NativeHandle == nwv1.NativeHandle); - Test.Assert(hsh[nwk1].GetNumber() == nwv1.GetNumber()); - Test.Assert(hsh[nwk1].GetNumber() == 222); + Test.Assert(hsh[nwk1].Number == nwv1.Number); + Test.Assert(hsh[nwk1].Number == 222); Dummy.Numberwrapper nwk2 = NW(44); Dummy.Numberwrapper nwv2 = NW(444); hsh[nwk2] = nwv2; @@ -3241,8 +3241,8 @@ class TestEinaHash var hsh = t.EinaHashObjReturnOwn(out nwk1, out nwv1); Test.Assert(hsh.Own); Test.Assert(hsh[nwk1].NativeHandle == nwv1.NativeHandle); - Test.Assert(hsh[nwk1].GetNumber() == nwv1.GetNumber()); - Test.Assert(hsh[nwk1].GetNumber() == 222); + Test.Assert(hsh[nwk1].Number == nwv1.Number); + Test.Assert(hsh[nwk1].Number == 222); Dummy.Numberwrapper nwk2 = NW(44); Dummy.Numberwrapper nwv2 = NW(444); hsh[nwk2] = nwv2; @@ -3395,7 +3395,7 @@ class TestEinaIterator foreach (Dummy.Numberwrapper e in itr) { Test.Assert(e.NativeHandle == base_objs[idx].NativeHandle); - Test.Assert(e.GetNumber() == base_objs[idx].GetNumber()); + Test.Assert(e.Number == base_objs[idx].Number); ++idx; } Test.AssertEquals(idx, base_objs.Length); @@ -3561,7 +3561,7 @@ class TestEinaIterator foreach (Dummy.Numberwrapper e in itr) { Test.Assert(e.NativeHandle == base_objs[idx].NativeHandle); - Test.Assert(e.GetNumber() == base_objs[idx].GetNumber()); + Test.Assert(e.Number == base_objs[idx].Number); ++idx; } Test.AssertEquals(idx, base_objs.Length); @@ -3903,19 +3903,19 @@ class TestEinaIterator hsh[a] = aa; hsh[b] = bb; hsh[c] = cc; - dct[a.GetNumber()] = a; - dct[b.GetNumber()] = b; - dct[c.GetNumber()] = c; + dct[a.Number] = a; + dct[b.Number] = b; + dct[c.Number] = c; var itr = hsh.Keys(); int idx = 0; foreach (Dummy.Numberwrapper e in itr) { - Test.Assert(dct[e.GetNumber()] != null); - Test.Assert(dct[e.GetNumber()].NativeHandle == e.NativeHandle); - Test.Assert(dct[e.GetNumber()].GetNumber() == e.GetNumber()); - dct.Remove(e.GetNumber()); + Test.Assert(dct[e.Number] != null); + Test.Assert(dct[e.Number].NativeHandle == e.NativeHandle); + Test.Assert(dct[e.Number].Number == e.Number); + dct.Remove(e.Number); ++idx; } Test.AssertEquals(dct.Count, 0); @@ -3939,19 +3939,19 @@ class TestEinaIterator hsh[a] = aa; hsh[b] = bb; hsh[c] = cc; - dct[aa.GetNumber()] = aa; - dct[bb.GetNumber()] = bb; - dct[cc.GetNumber()] = cc; + dct[aa.Number] = aa; + dct[bb.Number] = bb; + dct[cc.Number] = cc; var itr = hsh.Values(); int idx = 0; foreach (Dummy.Numberwrapper e in itr) { - Test.Assert(dct[e.GetNumber()] != null); - Test.Assert(dct[e.GetNumber()].NativeHandle == e.NativeHandle); - Test.Assert(dct[e.GetNumber()].GetNumber() == e.GetNumber()); - dct.Remove(e.GetNumber()); + Test.Assert(dct[e.Number] != null); + Test.Assert(dct[e.Number].NativeHandle == e.NativeHandle); + Test.Assert(dct[e.Number].Number == e.Number); + dct.Remove(e.Number); ++idx; } Test.AssertEquals(dct.Count, 0); @@ -4392,7 +4392,7 @@ class TestEinaIterator int idx = 0; foreach (Dummy.Numberwrapper e in itr) { - Test.AssertEquals(e.GetNumber(), base_seq_obj[idx].GetNumber()); + Test.AssertEquals(e.Number, base_seq_obj[idx].Number); ++idx; } Test.AssertEquals(idx, base_seq_obj.Length); @@ -4413,7 +4413,7 @@ class TestEinaIterator int idx = 0; foreach (Dummy.Numberwrapper e in itr) { - Test.AssertEquals(e.GetNumber(), base_seq_obj[idx].GetNumber()); + Test.AssertEquals(e.Number, base_seq_obj[idx].Number); ++idx; } Test.AssertEquals(idx, base_seq_obj.Length); @@ -4432,7 +4432,7 @@ class TestEinaIterator int idx = 0; foreach (Dummy.Numberwrapper e in itr) { - Test.AssertEquals(e.GetNumber(), base_seq_obj[idx].GetNumber()); + Test.AssertEquals(e.Number, base_seq_obj[idx].Number); ++idx; } Test.AssertEquals(idx, base_seq_obj.Length); @@ -4452,7 +4452,7 @@ class TestEinaIterator int idx = 0; foreach (Dummy.Numberwrapper e in itr) { - Test.AssertEquals(e.GetNumber(), base_seq_obj[idx].GetNumber()); + Test.AssertEquals(e.Number, base_seq_obj[idx].Number); ++idx; } Test.AssertEquals(idx, base_seq_obj.Length); diff --git a/src/tests/efl_mono/EinaTestData.cs b/src/tests/efl_mono/EinaTestData.cs index 411e38d576..2fd46f214b 100644 --- a/src/tests/efl_mono/EinaTestData.cs +++ b/src/tests/efl_mono/EinaTestData.cs @@ -49,7 +49,7 @@ public static class BaseData public static Dummy.Numberwrapper NW(int n) { var nw = new Dummy.Numberwrapper(); - nw.SetNumber(n); + nw.Number = n; return nw; } @@ -58,9 +58,9 @@ public static class BaseData var a = new Dummy.Numberwrapper(); var b = new Dummy.Numberwrapper(); var c = new Dummy.Numberwrapper(); - a.SetNumber(0x0); - b.SetNumber(0x2A); - c.SetNumber(0x42); + a.Number = 0x0; + b.Number = 0x2A; + c.Number = 0x42; return new Dummy.Numberwrapper[]{a, b, c}; } @@ -69,9 +69,9 @@ public static class BaseData var a = new Dummy.Numberwrapper(); var b = new Dummy.Numberwrapper(); var c = new Dummy.Numberwrapper(); - a.SetNumber(42); - b.SetNumber(43); - c.SetNumber(33); + a.Number = 42; + b.Number = 43; + c.Number = 33; return new Dummy.Numberwrapper[]{a, b, c}; } @@ -83,12 +83,12 @@ public static class BaseData var d = new Dummy.Numberwrapper(); var e = new Dummy.Numberwrapper(); var f = new Dummy.Numberwrapper(); - a.SetNumber(0x0); - b.SetNumber(0x2A); - c.SetNumber(0x42); - d.SetNumber(42); - e.SetNumber(43); - f.SetNumber(33); + a.Number = 0x0; + b.Number = 0x2A; + c.Number = 0x42; + d.Number = 42; + e.Number = 43; + f.Number = 33; return new Dummy.Numberwrapper[]{a, b, c, d, e, f}; } @@ -102,8 +102,8 @@ public static class BaseData Test.Assert(a.Length == b.Length, "Different lenght", line, file, member); for (int i = 0; i < a.Length; ++i) { - int av = a[i].GetNumber(); - int bv = b[i].GetNumber(); + int av = a[i].Number; + int bv = b[i].Number; Test.Assert(av == bv, $"Different values for element [{i}]: {av} == {bv}", line, file, member); } } diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs index 8d00155e10..8c0c9ab994 100644 --- a/src/tests/efl_mono/Eo.cs +++ b/src/tests/efl_mono/Eo.cs @@ -149,8 +149,8 @@ class TestEoNames var obj = new Dummy.TestObject(); string name = "Dummy"; - obj.SetName(name); - Test.AssertEquals(name, obj.GetName()); + obj.Name = name; + Test.AssertEquals(name, obj.Name); obj.Dispose(); } } @@ -162,9 +162,9 @@ class TestEoParent var parent = new Dummy.TestObject(null); var child = new Dummy.TestObject(parent); - Test.AssertEquals(parent, child.GetParent()); + Test.AssertEquals(parent, child.Parent); - var parent_retrieved = child.GetParent() as Dummy.TestObject; + var parent_retrieved = child.Parent as Dummy.TestObject; Test.AssertEquals(parent, parent_retrieved); child.Dispose(); parent.Dispose(); @@ -175,9 +175,9 @@ class TestEoParent Dummy.Numberwrapper parent = new Dummy.Numberwrapper(null); var child = new Dummy.TestObject(parent); - Test.AssertEquals(parent, child.GetParent()); + Test.AssertEquals(parent, child.Parent); - Dummy.Numberwrapper parent_retrieved = child.GetParent() as Dummy.Numberwrapper; + Dummy.Numberwrapper parent_retrieved = child.Parent as Dummy.Numberwrapper; Test.AssertEquals(parent, parent_retrieved); child.Dispose(); parent.Dispose(); @@ -195,9 +195,9 @@ class TestEoParent var parent = new Derived(null); var child = new Derived(parent); - Test.AssertEquals(parent, child.GetParent()); + Test.AssertEquals(parent, child.Parent); - var parent_from_cast = child.GetParent() as Derived; + var parent_from_cast = child.Parent as Derived; Test.AssertEquals(parent, parent_from_cast); child.Dispose(); parent.Dispose(); @@ -209,15 +209,15 @@ class TestKlassMethods public static void basic_class_method() { int reference = 0xbeef; - Dummy.TestObject.SetKlassProp(reference); - Test.AssertEquals(reference, Dummy.TestObject.GetKlassProp()); + Dummy.TestObject.KlassProp = reference; + Test.AssertEquals(reference, Dummy.TestObject.KlassProp); } public static void inherited_class_method() { int reference = 0xdead; - Dummy.Child.SetKlassProp(reference); - Test.AssertEquals(reference, Dummy.Child.GetKlassProp()); + Dummy.Child.KlassProp = reference; + Test.AssertEquals(reference, Dummy.Child.KlassProp); } } @@ -559,7 +559,7 @@ class TestConstructors #else var obj = new Dummy.Child(null, a, b); #endif - Test.Assert(!obj.GetIfaceWasSet()); + Test.Assert(!obj.IfaceWasSet); obj.Dispose(); } } @@ -586,7 +586,7 @@ class TestProvider var obj = new Dummy.TestObject(); Dummy.Numberwrapper provider = obj.FindProvider(typeof(Dummy.Numberwrapper)) as Dummy.Numberwrapper; Test.AssertEquals(provider.GetType(), typeof(Dummy.Numberwrapper)); - Test.AssertEquals(provider.GetNumber(), 1999); + Test.AssertEquals(provider.Number, 1999); obj.Dispose(); } @@ -685,16 +685,16 @@ class TestProtectedInterfaceMembers { var type = typeof(Dummy.ITestIface); var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance); + var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); // Fully protected property Test.AssertNull(methods.SingleOrDefault(m => m.Name == "GetProtectedProp")); Test.AssertNull(methods.SingleOrDefault(m => m.Name == "SetProtectedProp")); // Partially protected property - Test.AssertNotNull(methods.SingleOrDefault(m => m.Name == "GetPublicGetterPrivateSetter")); + Test.AssertNotNull(properties.SingleOrDefault(m => m.Name == "PublicGetterPrivateSetter")); Test.AssertNull(methods.SingleOrDefault(m => m.Name == "SetPublicGetterPrivateSetter")); - var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); Test.AssertNull(properties.SingleOrDefault(m => m.Name == "ProtectedProp")); Test.AssertNotNull(properties.SingleOrDefault(m => m.Name == "PublicGetterPrivateSetter")); } @@ -703,15 +703,16 @@ class TestProtectedInterfaceMembers { var type = typeof(Dummy.TestObject); - // Fully protected property - var protected_methods = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Where(m => m.IsFamily); - Test.AssertNotNull(protected_methods.SingleOrDefault(m => m.Name == "GetProtectedProp")); - Test.AssertNotNull(protected_methods.SingleOrDefault(m => m.Name == "SetProtectedProp")); + // Fully internal property + var internal_methods = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Where(m => m.IsAssembly); + Test.AssertNotNull(internal_methods.SingleOrDefault(m => m.Name == "GetProtectedProp")); + Test.AssertNotNull(internal_methods.SingleOrDefault(m => m.Name == "SetProtectedProp")); // Partially protected property var public_methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance); - Test.AssertNotNull(public_methods.SingleOrDefault(m => m.Name == "GetPublicGetterPrivateSetter")); - Test.AssertNotNull(protected_methods.SingleOrDefault(m => m.Name == "SetPublicGetterPrivateSetter")); + Test.AssertNull(public_methods.SingleOrDefault(m => m.Name == "GetPublicGetterPrivateSetter")); + Test.AssertNotNull(internal_methods.SingleOrDefault(m => m.Name == "GetPublicGetterPrivateSetter")); + Test.AssertNotNull(internal_methods.SingleOrDefault(m => m.Name == "SetPublicGetterPrivateSetter")); var protected_properties = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance); var prop = protected_properties.SingleOrDefault(m => m.Name == "ProtectedProp"); diff --git a/src/tests/efl_mono/Events.cs b/src/tests/efl_mono/Events.cs index 20c4b4491d..635e005c12 100644 --- a/src/tests/efl_mono/Events.cs +++ b/src/tests/efl_mono/Events.cs @@ -30,7 +30,7 @@ class TestEoEvents Efl.Object obj = sender as Efl.Object; if (obj != null) { - obj.SetName("loop_called"); + obj.Name = "loop_called"; correct_sender = true; } @@ -44,18 +44,18 @@ class TestEoEvents public static void idle_event() { Efl.Loop loop = Efl.App.AppMain; - loop.SetName("loop"); + loop.Name = "loop"; TestEoEvents listener = new TestEoEvents(); listener.loop = loop; loop.IdleEvent += listener.callback; Test.Assert(!listener.called); Test.Assert(!listener.correct_sender); - Test.AssertEquals("loop", loop.GetName()); + Test.AssertEquals("loop", loop.Name); loop.Begin(); Test.Assert(listener.called); Test.Assert(listener.correct_sender); - Test.AssertEquals("loop_called", loop.GetName()); + Test.AssertEquals("loop_called", loop.Name); loop.IdleEvent -= listener.callback; } diff --git a/src/tests/efl_mono/Model.cs b/src/tests/efl_mono/Model.cs index 008f79291b..f566b91d04 100644 --- a/src/tests/efl_mono/Model.cs +++ b/src/tests/efl_mono/Model.cs @@ -42,7 +42,7 @@ public static class TestModel { var veggies = CreateModel(loop); var model = new Efl.GenericModel(veggies, loop); - Test.AssertEquals(3, (int)model.GetChildrenCount()); + Test.AssertEquals(3, (int)model.ChildrenCount); VeggieViewModel r2 = await model.GetAtAsync(1).ConfigureAwait(false); Test.AssertEquals(r2.Name, "Romaine Lettuce"); diff --git a/src/tests/efl_mono/Parts.cs b/src/tests/efl_mono/Parts.cs index e206681e1a..c5de896053 100644 --- a/src/tests/efl_mono/Parts.cs +++ b/src/tests/efl_mono/Parts.cs @@ -51,9 +51,9 @@ public static class TestParts var p1 = t.OnePart; var p2 = t.TwoPart; Test.Assert(p1 is Dummy.TestObject); - Test.AssertEquals("part_one", p1.GetName()); + Test.AssertEquals("part_one", p1.Name); Test.Assert(p2 is Dummy.TestObject); - Test.AssertEquals("part_two", p2.GetName()); + Test.AssertEquals("part_two", p2.Name); } } @@ -97,9 +97,9 @@ public static class TestNamedParts var p1 = obj.GetPart("one"); var p2 = obj.GetPart("two"); Test.Assert(p1 is Dummy.TestObject); - Test.AssertEquals("part_one", p1.GetName()); + Test.AssertEquals("part_one", p1.Name); Test.Assert(p2 is Dummy.TestObject); - Test.AssertEquals("part_two", p2.GetName()); + Test.AssertEquals("part_two", p2.Name); obj.Dispose(); } } diff --git a/src/tests/efl_mono/StructHelpers.cs b/src/tests/efl_mono/StructHelpers.cs index 495638458a..0ce836a332 100644 --- a/src/tests/efl_mono/StructHelpers.cs +++ b/src/tests/efl_mono/StructHelpers.cs @@ -165,7 +165,7 @@ internal class StructHelpers Marshal.WriteByte(Fslice.Mem, 125); var Fobj = new Dummy.Numberwrapper(); - Fobj.SetNumber(42); + Fobj.Number = 42; return new Dummy.StructComplex(farray: Farray, flist: Flist, fhash: Fhash, fiterator: Fiterator, fanyValue:Fany_value, fanyValueRef: Fany_value_ref, @@ -205,7 +205,7 @@ internal class StructHelpers Test.Assert(complex.Fslice.GetBytes()[0] == 125); Test.Assert(complex.Fobj != null); - Test.Assert(complex.Fobj.GetNumber() == 42); + Test.Assert(complex.Fobj.Number == 42); }