From 5cd99258238fb71a065fa84dbe50e1865dde68dc Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Mon, 22 Apr 2019 18:15:19 -0300 Subject: [PATCH] csharp: Small style changes Summary: - Marshal annotations - Parameters - Structs - Parts Depends on D8614 Reviewers: segfaultxavi, vitor.sousa Reviewed By: segfaultxavi, vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8622 --- .../eolian_mono/eolian/mono/marshall_annotation.hh | 44 +++++++++++----------- src/bin/eolian_mono/eolian/mono/parameter.hh | 17 +++++---- src/bin/eolian_mono/eolian/mono/part_definition.hh | 2 +- src/bin/eolian_mono/eolian/mono/struct_fields.hh | 2 +- 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh b/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh index 296b59c0..632696d 100644 --- a/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh +++ b/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh @@ -51,71 +51,71 @@ struct marshall_annotation_visitor_generate match const parameter_match_table[] = { // signed primitives - {"bool", nullptr, [&] { return " [MarshalAs(UnmanagedType.U1)]"; }}, + {"bool", nullptr, [&] { return "[MarshalAs(UnmanagedType.U1)]"; }}, {"string", true, [&] { - return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]"; + return "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]"; }}, {"string", false, [&] { - return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]"; + return "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]"; }}, {"mstring", true, [&] { - return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]"; + return "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]"; }}, {"mstring", false, [&] { - return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]"; + return "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]"; }}, {"stringshare", true, [&] { - return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]"; + return "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]"; }}, {"stringshare", false, [&] { - return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]"; + return "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]"; }}, {"any_value_ptr", true, [&] { - return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshalerOwn))]"; + return "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshalerOwn))]"; }}, {"any_value_ptr", false, [&] { - return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))]"; + return "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))]"; }}, {"strbuf", true, [&] { - return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]"; + return "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]"; }}, {"strbuf", false, [&] { - return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]"; + return "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]"; }}, }; match const return_match_table[] = { // signed primitives - {"bool", nullptr, [&] { return " [return: MarshalAs(UnmanagedType.U1)]"; }}, + {"bool", nullptr, [&] { return "[return: MarshalAs(UnmanagedType.U1)]"; }}, {"string", true, [&] { - return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]"; + return "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]"; }}, {"string", nullptr, [&] { - return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]"; + return "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]"; }}, {"mstring", true, [&] { - return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]"; + return "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]"; }}, {"mstring", false, [&] { - return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]"; + return "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]"; }}, {"stringshare", true, [&] { - return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]"; + return "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]"; }}, {"stringshare", false, [&] { - return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]"; + return "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]"; }}, {"any_value_ptr", true, [&] { - return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshalerOwn))]"; + return "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshalerOwn))]"; }}, {"any_value_ptr", false, [&] { - return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))]"; + return "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))]"; }}, {"strbuf", true, [&] { - return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]"; + return "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]"; }}, {"strbuf", false, [&] { - return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]"; + return "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]"; }}, }; diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh index acd0c5d..ca3c573 100644 --- a/src/bin/eolian_mono/eolian/mono/parameter.hh +++ b/src/bin/eolian_mono/eolian/mono/parameter.hh @@ -389,22 +389,22 @@ inline std::string direction_modifier(attributes::parameter_def const& param) { if (param.direction == attributes::parameter_direction::inout) { - return " ref "; + return "ref "; } else if (param.direction != attributes::parameter_direction::in) { if (param.type.c_type == "Eina_Slice" || param.type.c_type == "Eina_Rw_Slice") - return " ref "; + return "ref "; else - return " out "; + return "out "; } else if (param.direction == attributes::parameter_direction::in && param.type.is_ptr) { auto regular = efl::eina::get(¶m.type.original_type); if (helpers::need_struct_conversion(regular)) - return " ref "; // Don't add ref on Marshal if it is ptr + return "ref "; // Don't add ref on Marshal if it is ptr } - return " "; + return ""; } std::string marshall_direction_modifier(attributes::parameter_def const& param) @@ -1477,7 +1477,8 @@ struct constructor_invocation_generator if (!as_generator( "if (" << (efl::eolian::grammar::attribute_reorder<-1> - ("Efl.Eo.Globals.ParamHelperCheck(" << constructor_parameter_name(ctor) << ")") % "||") << ")\n" + ("Efl.Eo.Globals.ParamHelperCheck(" << constructor_parameter_name(ctor) << ")") % " || ") << ")\n" + << scope_tab << scope_tab << "{\n" << scope_tab << scope_tab << scope_tab << name_helpers::managed_method_name(ctor.function) << "(" ).generate(sink, params, context)) return false; @@ -1493,7 +1494,9 @@ struct constructor_invocation_generator return false; } - if (!as_generator(");").generate(sink, attributes::unused, context)) + if (!as_generator( + ");\n" + << scope_tab << scope_tab << "}\n").generate(sink, attributes::unused, context)) return false; return true; } diff --git a/src/bin/eolian_mono/eolian/mono/part_definition.hh b/src/bin/eolian_mono/eolian/mono/part_definition.hh index 06cdf15..9c57587 100644 --- a/src/bin/eolian_mono/eolian/mono/part_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/part_definition.hh @@ -27,7 +27,7 @@ struct part_definition_generator << scope_tab << "{\n" << scope_tab << scope_tab << "get\n" << scope_tab << scope_tab << "{\n" - << scope_tab << scope_tab << scope_tab << "return Efl.IPartNativeInherit.efl_part_get_ptr.Value.Delegate(NativeHandle, \"" << part.name << "\") as " << part_klass_name << ";\n" + << scope_tab << scope_tab << scope_tab << "return GetPart(\"" << part.name << "\") as " << part_klass_name << ";\n" << scope_tab << scope_tab << "}\n" << scope_tab << "}\n" ).generate(sink, part.documentation, context); diff --git a/src/bin/eolian_mono/eolian/mono/struct_fields.hh b/src/bin/eolian_mono/eolian/mono/struct_fields.hh index 42a20e1..163d1b9 100644 --- a/src/bin/eolian_mono/eolian/mono/struct_fields.hh +++ b/src/bin/eolian_mono/eolian/mono/struct_fields.hh @@ -18,7 +18,7 @@ struct field_argument_default_generator template bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const { - if (!as_generator(type << " " << string << "=default(" << type << ")") + if (!as_generator(type << " " << string << " = default(" << type << ")") .generate(sink, std::make_tuple(field.type, name_helpers::to_field_name(field.name), field.type), context)) return false; return true; -- 2.7.4