vitorsousa pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=a19bb21edf75256e8dfe043d591d05bbf23a29a3
commit a19bb21edf75256e8dfe043d591d05bbf23a29a3 Author: Lauro Moura <[email protected]> Date: Thu Jul 11 15:50:33 2019 -0300 csharp: Tag exported API items. 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 | 1 + src/bin/eolian_mono/eolian/mono/events.hh | 1 + src/bin/eolian_mono/eolian/mono/function_pointer.hh | 1 + src/bin/eolian_mono/eolian/mono/klass.hh | 9 ++++++--- src/bin/eolian_mono/eolian/mono/struct_definition.hh | 1 + src/bindings/mono/eo_mono/EoWrapper.cs | 5 ++--- src/bindings/mono/eo_mono/iwrapper.cs | 16 ++++++++++++++++ 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/bin/eolian_mono/eolian/mono/enum_definition.hh b/src/bin/eolian_mono/eolian/mono/enum_definition.hh index 922463936e..4dae3cc7aa 100644 --- a/src/bin/eolian_mono/eolian/mono/enum_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/enum_definition.hh @@ -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)) diff --git a/src/bin/eolian_mono/eolian/mono/events.hh b/src/bin/eolian_mono/eolian/mono/events.hh index c1a45033f9..d5d57c4498 100644 --- a/src/bin/eolian_mono/eolian/mono/events.hh +++ b/src/bin/eolian_mono/eolian/mono/events.hh @@ -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" diff --git a/src/bin/eolian_mono/eolian/mono/function_pointer.hh b/src/bin/eolian_mono/eolian/mono/function_pointer.hh index f724d8029e..721368f115 100644 --- a/src/bin/eolian_mono/eolian/mono/function_pointer.hh +++ b/src/bin/eolian_mono/eolian/mono/function_pointer.hh @@ -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)) diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh index 99dac21123..a98866e34a 100644 --- a/src/bin/eolian_mono/eolian/mono/klass.hh +++ b/src/bin/eolian_mono/eolian/mono/klass.hh @@ -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); diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh index 851b9c4025..c949783945 100644 --- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh @@ -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" ) diff --git a/src/bindings/mono/eo_mono/EoWrapper.cs b/src/bindings/mono/eo_mono/EoWrapper.cs index 03edea018c..c2ee5e2a31 100644 --- a/src/bindings/mono/eo_mono/EoWrapper.cs +++ b/src/bindings/mono/eo_mono/EoWrapper.cs @@ -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) { diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs index 833ae78302..09c82a7e81 100644 --- a/src/bindings/mono/eo_mono/iwrapper.cs +++ b/src/bindings/mono/eo_mono/iwrapper.cs @@ -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> --
