csharp: Small style changes
authorLauro Moura <lauromoura@expertisesolutions.com.br>
Mon, 22 Apr 2019 21:15:19 +0000 (18:15 -0300)
committerYeongjong Lee <yj34.lee@samsung.com>
Wed, 24 Apr 2019 05:24:47 +0000 (14:24 +0900)
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

src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
src/bin/eolian_mono/eolian/mono/parameter.hh
src/bin/eolian_mono/eolian/mono/part_definition.hh
src/bin/eolian_mono/eolian/mono/struct_fields.hh

index 296b59c..632696d 100644 (file)
@@ -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))]";
           }},
         };
 
index acd0c5d..ca3c573 100644 (file)
@@ -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<attributes::regular_type_def>(&param.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;
   }
index 06cdf15..9c57587 100644 (file)
@@ -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);
index 42a20e1..163d1b9 100644 (file)
@@ -18,7 +18,7 @@ struct field_argument_default_generator
    template<typename OutputIterator, typename Context>
    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;