csharp: Tag exported API items.
authorLauro Moura <lauromoura@expertisesolutions.com.br>
Thu, 11 Jul 2019 18:50:33 +0000 (15:50 -0300)
committerTaehyub Kim <taehyub.kim@samsung.com>
Wed, 17 Jul 2019 07:18:04 +0000 (16:18 +0900)
Summary:
Attributes to be used by the API export tool. For end users, no changes
in the public API (except for a new attribute in generated classes).

Also simplifies constructor forwarding by not needing to pass the type
of the first "generated" class to compare.

Currently only automatically generated items are tagged.

Depends: D9259

Reviewers: vitor.sousa, felipealmeida

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9270

src/bin/eolian_mono/eolian/mono/enum_definition.hh
src/bin/eolian_mono/eolian/mono/events.hh
src/bin/eolian_mono/eolian/mono/function_pointer.hh
src/bin/eolian_mono/eolian/mono/klass.hh
src/bin/eolian_mono/eolian/mono/struct_definition.hh
src/bindings/mono/eo_mono/EoWrapper.cs
src/bindings/mono/eo_mono/iwrapper.cs

index 9224639..4dae3cc 100644 (file)
@@ -25,6 +25,7 @@ struct enum_definition_generator
 
      if(!as_generator
         (
+         "[Efl.Eo.BindingEntity]\n"
          "public enum " << string << "\n{\n"
          )
         .generate(sink, name_helpers::typedecl_managed_name(enum_), context))
index c1a4503..d5d57c4 100644 (file)
@@ -250,6 +250,7 @@ struct event_argument_wrapper_generator
       return as_generator("///<summary>Event argument wrapper for event <see cref=\""
                           << join_namespaces(evt.klass.namespaces, '.', managed_namespace)
                           << klass_interface_name(evt.klass) << "." << evt_name << "\"/>.</summary>\n"
+                          << "[Efl.Eo.BindingEntity]\n"
                           << "public class " << name_helpers::managed_event_args_short_name(evt) << " : EventArgs {\n"
                           << scope_tab << "///<summary>Actual event payload.</summary>\n"
                           << scope_tab << "public " << type << " arg { get; set; }\n"
index f724d80..721368f 100644 (file)
@@ -44,6 +44,7 @@ struct function_pointer {
 
       // C# visible delegate
       if (!as_generator(documentation
+                  << "[Efl.Eo.BindingEntity]\n"
                   << "public delegate " << type << " " << string
                   << "(" << (parameter % ", ") << ");\n")
               .generate(sink, std::make_tuple(f, f.return_type, f_name, f.parameters), funcptr_ctx))
index 99dac21..a98866e 100644 (file)
@@ -106,6 +106,9 @@ struct klass
           .generate(sink, attributes::unused, iface_cxt))
          return false;
 
+       if(!as_generator("[Efl.Eo.BindingEntity]\n").generate(sink, attributes::unused, iface_cxt))
+         return false;
+
        if(!as_generator
         (
          "public " /*<< class_type*/ "interface" /*<<*/ " " << string << " : "
@@ -279,6 +282,7 @@ struct klass
             (
              documentation
              << "[" << name_helpers::klass_full_native_inherit_name(cls) << "]\n"
+             << "[Efl.Eo.BindingEntity]\n"
              << "public " << class_type << " " << name_helpers::klass_concrete_name(cls) << " : "
              << (klass_full_concrete_or_interface_name % ",") // classes
              << (root ? "Efl.Eo.EoWrapper" : "") // ... or root
@@ -502,7 +506,7 @@ struct klass
                      // For constructors with arguments, the parent is also required, as optional parameters can't come before non-optional paramenters.
                      << scope_tab << "public " << inherit_name << "(Efl.Object parent" << ((constructors.size() > 0) ? "" : "= null") << "\n"
                      << scope_tab << scope_tab << scope_tab << *(", " << constructor_param ) << ") : "
-                             << "base(" << name_helpers::klass_get_name(cls) <<  "(), typeof(" << inherit_name << "), parent)\n"
+                             << "base(" << name_helpers::klass_get_name(cls) <<  "(), parent)\n"
                      << scope_tab << "{\n"
                      << (*(scope_tab << scope_tab << constructor_invocation << "\n"))
                      << scope_tab << scope_tab << "FinishInstantiation();\n"
@@ -542,9 +546,8 @@ struct klass
                  scope_tab << "/// <summary>Initializes a new instance of the <see cref=\"" << inherit_name << "\"/> class.\n"
                  << scope_tab << "/// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>\n"
                  << scope_tab << "/// <param name=\"baseKlass\">The pointer to the base native Eo class.</param>\n"
-                 << scope_tab << "/// <param name=\"managedType\">The managed type of the public constructor that originated this call.</param>\n"
                  << scope_tab << "/// <param name=\"parent\">The Efl.Object parent of this instance.</param>\n"
-                 << scope_tab << "protected " << inherit_name << "(IntPtr baseKlass, System.Type managedType, Efl.Object parent) : base(baseKlass, managedType, parent)\n"
+                 << scope_tab << "protected " << inherit_name << "(IntPtr baseKlass, Efl.Object parent) : base(baseKlass, parent)\n"
                  << scope_tab << "{\n"
                  << scope_tab << "}\n\n"
               ).generate(sink, attributes::unused, context);
index 851b9c4..c949783 100644 (file)
@@ -396,6 +396,7 @@ struct struct_definition_generator
      if(!as_generator
         (
             indent << "[StructLayout(LayoutKind.Sequential)]\n"
+         << indent << "[Efl.Eo.BindingEntity]\n"
          << indent << "public struct " << string << "\n"
          << indent << "{\n"
          )
index 03edea0..c2ee5e2 100644 (file)
@@ -67,15 +67,14 @@ public abstract class EoWrapper : IWrapper, IDisposable
     /// Internal usage: Constructor to actually call the native library constructors. C# subclasses
     /// must use the public constructor only.</summary>
     /// <param name="baseKlass">The pointer to the base native Eo class.</param>
-    /// <param name="managedType">The managed type of the public constructor that originated this call.</param>
     /// <param name="parent">The Efl.Object parent of this instance.</param>
     /// <param name="file">Name of the file from where the constructor is called.</param>
     /// <param name="line">Number of the line from where the constructor is called.</param>
-    protected EoWrapper(IntPtr baseKlass, System.Type managedType, Efl.Object parent,
+    protected EoWrapper(IntPtr baseKlass, Efl.Object parent,
                         [CallerFilePath] string file = null,
                         [CallerLineNumber] int line = 0)
     {
-        generated = ((object)this).GetType() == managedType;
+        generated = Efl.Eo.BindingEntity.IsBindingEntity(((object)this).GetType());
         IntPtr actual_klass = baseKlass;
         if (!generated)
         {
index 833ae78..09c82a7 100644 (file)
@@ -775,6 +775,22 @@ public class PrivateNativeClass : NativeClass
     }
 }
 
+[System.AttributeUsage(System.AttributeTargets.Class |
+                       System.AttributeTargets.Interface |
+                       System.AttributeTargets.Enum |
+                       System.AttributeTargets.Delegate |
+                       System.AttributeTargets.Struct,
+                       AllowMultiple = false,
+                       Inherited = false)
+]
+public class BindingEntity: System.Attribute
+{
+    public static bool IsBindingEntity(System.Type t)
+    {
+        return Attribute.GetCustomAttribute(t, typeof(BindingEntity), false) != null;
+    }
+}
+
 public interface IWrapper
 {
     /// <summary>Pointer to internal Eo instance.</summary>