felipealmeida pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=87c58a460a0f39477461ef93e6ce8b63f994c873
commit 87c58a460a0f39477461ef93e6ce8b63f994c873 Author: Lauro Moura <lauromo...@expertisesolutions.com.br> Date: Tue Apr 10 22:50:05 2018 -0300 efl_mono: Add namespace on helpers. Make it easier on finding where those functions are coming from. --- .../eolian_mono/eolian/mono/function_definition.hh | 2 +- src/bin/eolian_mono/eolian/mono/helpers.hh | 6 ++- src/bin/eolian_mono/eolian/mono/klass.hh | 4 +- .../eolian_mono/eolian/mono/marshall_type_impl.hh | 4 +- src/bin/eolian_mono/eolian/mono/parameter.hh | 48 +++++++++++----------- src/bin/eolian_mono/eolian/mono/part_definition.hh | 2 +- .../eolian_mono/eolian/mono/struct_definition.hh | 18 ++++---- src/bin/eolian_mono/eolian/mono/struct_fields.hh | 4 +- 8 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh index e030434687..4431ddc86e 100644 --- a/src/bin/eolian_mono/eolian/mono/function_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh @@ -165,7 +165,7 @@ struct function_definition_generator << ") {\n " << eolian_mono::function_definition_preamble() << string << "(" << (do_super ? "efl.eo.Globals.efl_super(" : "") - << (f.is_static ? klass_get_name(f.klass) + "()": "this.raw_handle") + << (f.is_static ? helpers::klass_get_name(f.klass) + "()": "this.raw_handle") << (do_super ? ", this.raw_klass)" : "") << *(", " << argument_invocation ) << ");\n" << eolian_mono::function_definition_epilogue() diff --git a/src/bin/eolian_mono/eolian/mono/helpers.hh b/src/bin/eolian_mono/eolian/mono/helpers.hh index 420efc6984..e0ec6945fa 100644 --- a/src/bin/eolian_mono/eolian/mono/helpers.hh +++ b/src/bin/eolian_mono/eolian/mono/helpers.hh @@ -12,6 +12,8 @@ namespace eolian_mono { +namespace helpers { + namespace attributes = efl::eolian::grammar::attributes; inline std::string type_full_name(attributes::regular_type_def const& type) @@ -140,6 +142,8 @@ inline std::string klass_get_name(attributes::klass_name const &clsname) return output.str(); } -} +} // namespace helpers + +} // namespace eolian_mono #endif diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh index bf3f27cdd5..a5f380932c 100644 --- a/src/bin/eolian_mono/eolian/mono/klass.hh +++ b/src/bin/eolian_mono/eolian/mono/klass.hh @@ -241,7 +241,9 @@ struct klass } for (auto &&p : cls.parts) - if (!as_generator( klass_name_to_csharp(p.klass) << " " << utils::capitalize(p.name) << "{ get;}\n").generate(sink, attributes::unused, iface_cxt)) + if (!as_generator( + helpers::klass_name_to_csharp(p.klass) << " " << utils::capitalize(p.name) << "{ get;}\n" + ).generate(sink, attributes::unused, iface_cxt)) return false; // End of interface declaration diff --git a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh index 18359471bc..1d9368e1f5 100644 --- a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh +++ b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh @@ -155,7 +155,7 @@ struct marshall_type_visitor_generate }} }; - if (regular.is_struct() && !is_struct_blacklisted(regular) && !(bool)(regular.base_qualifier & qualifier_info::is_own)) + if (regular.is_struct() && !helpers::is_struct_blacklisted(regular) && !(bool)(regular.base_qualifier & qualifier_info::is_own)) { if ((is_out || is_return) && is_ptr) return as_generator(" System.IntPtr").generate(sink, attributes::unused, *context); @@ -177,7 +177,7 @@ struct marshall_type_visitor_generate { return *b; } - else if (is_ptr && need_pointer_conversion(®ular)) + else if (is_ptr && helpers::need_pointer_conversion(®ular)) { regular_type_def r = regular; r.base_type = " System.IntPtr"; diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh index 615b06fb35..8ee330ee00 100644 --- a/src/bin/eolian_mono/eolian/mono/parameter.hh +++ b/src/bin/eolian_mono/eolian/mono/parameter.hh @@ -288,10 +288,10 @@ inline bool param_should_use_out_var(attributes::parameter_def const& param, boo return true; auto regular = efl::eina::get<attributes::regular_type_def>(¶m.type.original_type); - if (need_struct_conversion(regular)) + if (helpers::need_struct_conversion(regular)) return true; - if (param.type.is_ptr && need_pointer_conversion(regular)) + if (param.type.is_ptr && helpers::need_pointer_conversion(regular)) return true; return false; @@ -336,10 +336,10 @@ inline bool param_should_use_in_var(attributes::parameter_def const& param, bool return true; auto regular = efl::eina::get<attributes::regular_type_def>(¶m.type.original_type); - if (need_struct_conversion(regular)) + if (helpers::need_struct_conversion(regular)) return true; - if (param.type.is_ptr && need_pointer_conversion(regular)) + if (param.type.is_ptr && helpers::need_pointer_conversion(regular)) return true; return false; @@ -371,7 +371,7 @@ inline std::string direction_modifier(attributes::parameter_def const& param) else if (param.direction == attributes::parameter_direction::in && param.type.is_ptr) { auto regular = efl::eina::get<attributes::regular_type_def>(¶m.type.original_type); - if (need_struct_conversion(regular)) + if (helpers::need_struct_conversion(regular)) return " ref "; // Don't add ref on Marshal if it is ptr } return " "; @@ -382,7 +382,7 @@ std::string marshall_direction_modifier(attributes::parameter_def const& param) if (param.direction == attributes::parameter_direction::in && param.type.is_ptr) { auto regular = efl::eina::get<attributes::regular_type_def>(¶m.type.original_type); - if (need_struct_conversion(regular) && param.type.has_own) + if (helpers::need_struct_conversion(regular) && param.type.has_own) return " "; // Don't add ref on Marshal if it is ptr } return direction_modifier(param); @@ -545,13 +545,13 @@ struct native_convert_in_variable_generator return true; auto regular = efl::eina::get<attributes::regular_type_def>(¶m.type.original_type); - if (param.type.is_ptr && need_pointer_conversion(regular) && !need_struct_conversion(param, regular)) + if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(param, regular)) { return as_generator( "var " << string << " = eina.PrimitiveConversion.PointerToManaged<" << type << ">(" << escape_keyword(param.param_name) << ");\n" ).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context); } - else if (need_struct_conversion(regular)) + else if (helpers::need_struct_conversion(regular)) { return as_generator( "var " << string << " = " << type << "_StructConversion.ToExternal(" << escape_keyword(param.param_name) << ");\n" @@ -613,13 +613,13 @@ struct convert_in_variable_generator return true; auto regular = efl::eina::get<attributes::regular_type_def>(¶m.type.original_type); - if (param.type.is_ptr && need_pointer_conversion(regular) && !need_struct_conversion(param, regular)) + if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(param, regular)) { return as_generator( "var " << string << " = eina.PrimitiveConversion.ManagedToPointerAlloc(" << escape_keyword(param.param_name) << ");\n" ).generate(sink, in_variable_name(param.param_name), context); } - else if (need_struct_conversion(regular)) + else if (helpers::need_struct_conversion(regular)) { return as_generator( "var " << string << " = " << type << "_StructConversion.ToInternal(" << escape_keyword(param.param_name) << ");\n" @@ -708,13 +708,13 @@ struct convert_out_variable_generator return true; auto regular = efl::eina::get<attributes::regular_type_def>(¶m.type.original_type); - if (param.type.is_ptr && need_pointer_conversion(regular) && !need_struct_conversion(regular)) + if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular)) { return as_generator( "System.IntPtr " << string << " = System.IntPtr.Zero;\n" ).generate(sink, out_variable_name(param.param_name), context); } - else if (need_struct_conversion(regular)) + else if (helpers::need_struct_conversion(regular)) { return as_generator( "var " << string << " = new " << marshall_type << "();\n" @@ -781,13 +781,13 @@ struct native_convert_out_variable_generator return true; auto regular = efl::eina::get<attributes::regular_type_def>(¶m.type.original_type); - if (param.type.is_ptr && need_pointer_conversion(regular) && !need_struct_conversion(regular)) + if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular)) { return as_generator( type << " " << string << " = default(" << type << ");\n" ).generate(sink, std::make_tuple(param, out_variable_name(param.param_name), param), context); } - else if (need_struct_conversion(regular) + else if (helpers::need_struct_conversion(regular) || param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT) || param_is_acceptable(param, "Eina_Stringshare *", !WANT_OWN, WANT_OUT)) { @@ -868,7 +868,7 @@ struct convert_out_assign_generator return true; auto regular = efl::eina::get<attributes::regular_type_def>(¶m.type.original_type); - if (param.type.is_ptr && need_pointer_conversion(regular) && !need_struct_conversion_in_return(param.type, param.direction)) + if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion_in_return(param.type, param.direction)) { bool ret = as_generator( string << " = eina.PrimitiveConversion.PointerToManaged<" << type << ">(" << out_variable_name(param.param_name) << ");\n" @@ -880,7 +880,7 @@ struct convert_out_assign_generator return ret; } - else if (need_struct_conversion(regular)) + else if (helpers::need_struct_conversion(regular)) { return as_generator( string << " = " << type << "_StructConversion.ToExternal(" << out_variable_name(param.param_name) << ");\n" @@ -963,7 +963,7 @@ struct native_convert_in_ptr_assign_generator bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const { auto regular = efl::eina::get<attributes::regular_type_def>(¶m.type.original_type); - if (param_should_use_in_var(param, true) && param.type.is_ptr && !param.type.has_own && need_struct_conversion(regular)) + if (param_should_use_in_var(param, true) && param.type.is_ptr && !param.type.has_own && helpers::need_struct_conversion(regular)) { return as_generator( string << " = " << type << "_StructConversion.ToInternal(" << in_variable_name(param.param_name) << ");\n" @@ -980,7 +980,7 @@ struct convert_in_ptr_assign_generator bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const { auto regular = efl::eina::get<attributes::regular_type_def>(¶m.type.original_type); - if (param_should_use_in_var(param, true) && param.type.is_ptr && !param.type.has_own && need_struct_conversion(regular)) + if (param_should_use_in_var(param, true) && param.type.is_ptr && !param.type.has_own && helpers::need_struct_conversion(regular)) { return as_generator( string << " = " << type << "_StructConversion.ToExternal(" << in_variable_name(param.param_name) << ");\n" @@ -1010,7 +1010,7 @@ struct convert_return_generator bool generate(OutputIterator sink, attributes::type_def const& ret_type, Context const& context) const { auto regular = efl::eina::get<attributes::regular_type_def>(&ret_type.original_type); - if (ret_type.is_ptr && need_pointer_conversion(regular) && !need_struct_conversion_in_return(ret_type, attributes::parameter_direction::unknown)) + if (ret_type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion_in_return(ret_type, attributes::parameter_direction::unknown)) { return as_generator( "var __ret_tmp = eina.PrimitiveConversion.PointerToManaged<" << type << ">(_ret_var);\n" @@ -1018,7 +1018,7 @@ struct convert_return_generator << scope_tab << scope_tab << "return __ret_tmp;\n" ).generate(sink, ret_type, context); } - else if (need_struct_conversion(regular)) + else if (helpers::need_struct_conversion(regular)) { return as_generator( "return " << type << "_StructConversion.ToExternal(_ret_var);\n" @@ -1080,13 +1080,13 @@ struct native_convert_out_assign_generator return true; auto regular = efl::eina::get<attributes::regular_type_def>(¶m.type.original_type); - if (param.type.is_ptr && need_pointer_conversion(regular) && !need_struct_conversion_in_return(param.type, param.direction)) + if (param.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion_in_return(param.type, param.direction)) { return as_generator( string << " = eina.PrimitiveConversion.ManagedToPointerAlloc(" << string << ");\n" ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context); } - else if (need_struct_conversion(regular)) + else if (helpers::need_struct_conversion(regular)) { return as_generator( string << " = " << type << "_StructConversion.ToInternal(" << string << ");\n" @@ -1213,13 +1213,13 @@ struct native_convert_return_generator bool generate(OutputIterator sink, attributes::type_def const& ret_type, Context const& context) const { auto regular = efl::eina::get<attributes::regular_type_def>(&ret_type.original_type); - if (ret_type.is_ptr && need_pointer_conversion(regular) && !need_struct_conversion_in_return(ret_type, attributes::parameter_direction::unknown) ) + if (ret_type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion_in_return(ret_type, attributes::parameter_direction::unknown) ) { return as_generator( "return eina.PrimitiveConversion.ManagedToPointerAlloc(_ret_var);\n" ).generate(sink, attributes::unused, context); } - else if (need_struct_conversion(regular)) + else if (helpers::need_struct_conversion(regular)) { return as_generator( "return " << type << "_StructConversion.ToInternal(_ret_var);\n" diff --git a/src/bin/eolian_mono/eolian/mono/part_definition.hh b/src/bin/eolian_mono/eolian/mono/part_definition.hh index 83222c9ed4..3341f1e894 100644 --- a/src/bin/eolian_mono/eolian/mono/part_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/part_definition.hh @@ -17,7 +17,7 @@ struct part_definition_generator template <typename OutputIterator, typename Context> bool generate(OutputIterator sink, attributes::part_def const& part, Context const& context) const { - std::string part_klass_name = klass_name_to_csharp(part.klass); + std::string part_klass_name = helpers::klass_name_to_csharp(part.klass); return as_generator(scope_tab << documentation << scope_tab << "public " << part_klass_name << " " << utils::capitalize(part.name) << "\n" << scope_tab << "{\n" diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh index f772564440..bc3b730857 100644 --- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh @@ -51,7 +51,7 @@ struct struct_definition_generator documentation(1) << scope_tab(1) << "public " << type << " " << string << ";\n" ) - .generate(sink, std::make_tuple(field, field.type, to_field_name(field.name)), context)) + .generate(sink, std::make_tuple(field, field.type, helpers::to_field_name(field.name)), context)) return false; } @@ -104,7 +104,7 @@ struct struct_internal_definition_generator // iterate struct fields for (auto const& field : struct_.fields) { - auto field_name = to_field_name(field.name); + auto field_name = helpers::to_field_name(field.name); auto klass = efl::eina::get<attributes::klass_name>(&field.type.original_type); auto regular = efl::eina::get<attributes::regular_type_def>(&field.type.original_type); @@ -165,7 +165,7 @@ struct to_internal_field_convert_generator template <typename OutputIterator, typename Context> bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const { - auto field_name = to_field_name(field.name); + auto field_name = helpers::to_field_name(field.name); auto regular = efl::eina::get<attributes::regular_type_def>(&field.type.original_type); auto klass = efl::eina::get<attributes::klass_name>(&field.type.original_type); auto complex = efl::eina::get<attributes::complex_type_def>(&field.type.original_type); @@ -191,14 +191,14 @@ struct to_internal_field_convert_generator .generate(sink, std::make_tuple(field_name, field_name), context)) return false; } - else if (field.type.is_ptr && need_pointer_conversion(regular) && !need_struct_conversion(regular)) + else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular)) { if (!as_generator( scope_tab << scope_tab << "_internal_struct." << string << " = eina.PrimitiveConversion.ManagedToPointerAlloc(_external_struct." << string << ");\n") .generate(sink, std::make_tuple(field_name, field_name), context)) return false; } - else if (need_struct_conversion(regular)) + else if (helpers::need_struct_conversion(regular)) { if (!as_generator( scope_tab << scope_tab << "_internal_struct." << string << " = " << type << "_StructConversion.ToInternal(_external_struct." << string << ");\n") @@ -259,7 +259,7 @@ struct to_external_field_convert_generator template <typename OutputIterator, typename Context> bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const { - auto field_name = to_field_name(field.name); + auto field_name = helpers::to_field_name(field.name); auto regular = efl::eina::get<attributes::regular_type_def>(&field.type.original_type); auto klass = efl::eina::get<attributes::klass_name>(&field.type.original_type); auto complex = efl::eina::get<attributes::complex_type_def>(&field.type.original_type); @@ -301,14 +301,14 @@ struct to_external_field_convert_generator .generate(sink, std::make_tuple(field_name, field.type, field_name), context)) return false; } - else if (field.type.is_ptr && need_pointer_conversion(regular) && !need_struct_conversion(regular)) + else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular)) { if (!as_generator( scope_tab << scope_tab << "_external_struct." << string << " = eina.PrimitiveConversion.PointerToManaged<" << type << ">(_internal_struct." << string << ");\n") .generate(sink, std::make_tuple(field_name, field.type, field_name), context)) return false; } - else if (need_struct_conversion(regular)) + else if (helpers::need_struct_conversion(regular)) { if (!as_generator( scope_tab << scope_tab << "_external_struct." << string << " = " << type << "_StructConversion.ToExternal(_internal_struct." << string << ");\n") @@ -439,7 +439,7 @@ struct struct_entities_generator template <typename OutputIterator, typename Context> bool generate(OutputIterator sink, attributes::struct_def const& struct_, Context const& context) const { - if (is_struct_blacklisted(struct_)) + if (helpers::is_struct_blacklisted(struct_)) return true; std::vector<std::string> cpp_namespaces = escape_namespace(attributes::cpp_namespaces(struct_.namespaces)); diff --git a/src/bin/eolian_mono/eolian/mono/struct_fields.hh b/src/bin/eolian_mono/eolian/mono/struct_fields.hh index 0cd018b06f..c6d460d11a 100644 --- a/src/bin/eolian_mono/eolian/mono/struct_fields.hh +++ b/src/bin/eolian_mono/eolian/mono/struct_fields.hh @@ -20,7 +20,7 @@ struct field_argument_default_generator bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const { if (!as_generator(type << " " << string << "=default(" << type << ")") - .generate(sink, std::make_tuple(field.type, to_field_name(field.name), field.type), context)) + .generate(sink, std::make_tuple(field.type, helpers::to_field_name(field.name), field.type), context)) return false; return true; } @@ -32,7 +32,7 @@ struct field_argument_assignment_generator bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const { if (!as_generator("this." << string << " = " << string) - .generate(sink, std::make_tuple(to_field_name(field.name), to_field_name(field.name)), context)) + .generate(sink, std::make_tuple(helpers::to_field_name(field.name), helpers::to_field_name(field.name)), context)) return false; return true; } --