summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-07-11 15:50:33 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-07-11 15:51:38 -0300
commita19bb21edf75256e8dfe043d591d05bbf23a29a3 (patch)
tree789cd6ca9f52637b1fd1889a15a58998c70c7cb3
parent89399672b7a90451071d03b9403d8c8b698d67e1 (diff)
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
-rw-r--r--src/bin/eolian_mono/eolian/mono/enum_definition.hh1
-rw-r--r--src/bin/eolian_mono/eolian/mono/events.hh1
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_pointer.hh1
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh9
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh1
-rw-r--r--src/bindings/mono/eo_mono/EoWrapper.cs5
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs16
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 9224639..4dae3cc 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
25 25
26 if(!as_generator 26 if(!as_generator
27 ( 27 (
28 "[Efl.Eo.BindingEntity]\n"
28 "public enum " << string << "\n{\n" 29 "public enum " << string << "\n{\n"
29 ) 30 )
30 .generate(sink, name_helpers::typedecl_managed_name(enum_), context)) 31 .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 c1a4503..d5d57c4 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
250 return as_generator("///<summary>Event argument wrapper for event <see cref=\"" 250 return as_generator("///<summary>Event argument wrapper for event <see cref=\""
251 << join_namespaces(evt.klass.namespaces, '.', managed_namespace) 251 << join_namespaces(evt.klass.namespaces, '.', managed_namespace)
252 << klass_interface_name(evt.klass) << "." << evt_name << "\"/>.</summary>\n" 252 << klass_interface_name(evt.klass) << "." << evt_name << "\"/>.</summary>\n"
253 << "[Efl.Eo.BindingEntity]\n"
253 << "public class " << name_helpers::managed_event_args_short_name(evt) << " : EventArgs {\n" 254 << "public class " << name_helpers::managed_event_args_short_name(evt) << " : EventArgs {\n"
254 << scope_tab << "///<summary>Actual event payload.</summary>\n" 255 << scope_tab << "///<summary>Actual event payload.</summary>\n"
255 << scope_tab << "public " << type << " arg { get; set; }\n" 256 << 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 f724d80..721368f 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 {
44 44
45 // C# visible delegate 45 // C# visible delegate
46 if (!as_generator(documentation 46 if (!as_generator(documentation
47 << "[Efl.Eo.BindingEntity]\n"
47 << "public delegate " << type << " " << string 48 << "public delegate " << type << " " << string
48 << "(" << (parameter % ", ") << ");\n") 49 << "(" << (parameter % ", ") << ");\n")
49 .generate(sink, std::make_tuple(f, f.return_type, f_name, f.parameters), funcptr_ctx)) 50 .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 99dac21..a98866e 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
106 .generate(sink, attributes::unused, iface_cxt)) 106 .generate(sink, attributes::unused, iface_cxt))
107 return false; 107 return false;
108 108
109 if(!as_generator("[Efl.Eo.BindingEntity]\n").generate(sink, attributes::unused, iface_cxt))
110 return false;
111
109 if(!as_generator 112 if(!as_generator
110 ( 113 (
111 "public " /*<< class_type*/ "interface" /*<<*/ " " << string << " : " 114 "public " /*<< class_type*/ "interface" /*<<*/ " " << string << " : "
@@ -279,6 +282,7 @@ struct klass
279 ( 282 (
280 documentation 283 documentation
281 << "[" << name_helpers::klass_full_native_inherit_name(cls) << "]\n" 284 << "[" << name_helpers::klass_full_native_inherit_name(cls) << "]\n"
285 << "[Efl.Eo.BindingEntity]\n"
282 << "public " << class_type << " " << name_helpers::klass_concrete_name(cls) << " : " 286 << "public " << class_type << " " << name_helpers::klass_concrete_name(cls) << " : "
283 << (klass_full_concrete_or_interface_name % ",") // classes 287 << (klass_full_concrete_or_interface_name % ",") // classes
284 << (root ? "Efl.Eo.EoWrapper" : "") // ... or root 288 << (root ? "Efl.Eo.EoWrapper" : "") // ... or root
@@ -502,7 +506,7 @@ struct klass
502 // For constructors with arguments, the parent is also required, as optional parameters can't come before non-optional paramenters. 506 // For constructors with arguments, the parent is also required, as optional parameters can't come before non-optional paramenters.
503 << scope_tab << "public " << inherit_name << "(Efl.Object parent" << ((constructors.size() > 0) ? "" : "= null") << "\n" 507 << scope_tab << "public " << inherit_name << "(Efl.Object parent" << ((constructors.size() > 0) ? "" : "= null") << "\n"
504 << scope_tab << scope_tab << scope_tab << *(", " << constructor_param ) << ") : " 508 << scope_tab << scope_tab << scope_tab << *(", " << constructor_param ) << ") : "
505 << "base(" << name_helpers::klass_get_name(cls) << "(), typeof(" << inherit_name << "), parent)\n" 509 << "base(" << name_helpers::klass_get_name(cls) << "(), parent)\n"
506 << scope_tab << "{\n" 510 << scope_tab << "{\n"
507 << (*(scope_tab << scope_tab << constructor_invocation << "\n")) 511 << (*(scope_tab << scope_tab << constructor_invocation << "\n"))
508 << scope_tab << scope_tab << "FinishInstantiation();\n" 512 << scope_tab << scope_tab << "FinishInstantiation();\n"
@@ -542,9 +546,8 @@ struct klass
542 scope_tab << "/// <summary>Initializes a new instance of the <see cref=\"" << inherit_name << "\"/> class.\n" 546 scope_tab << "/// <summary>Initializes a new instance of the <see cref=\"" << inherit_name << "\"/> class.\n"
543 << 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" 547 << 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"
544 << scope_tab << "/// <param name=\"baseKlass\">The pointer to the base native Eo class.</param>\n" 548 << scope_tab << "/// <param name=\"baseKlass\">The pointer to the base native Eo class.</param>\n"
545 << scope_tab << "/// <param name=\"managedType\">The managed type of the public constructor that originated this call.</param>\n"
546 << scope_tab << "/// <param name=\"parent\">The Efl.Object parent of this instance.</param>\n" 549 << scope_tab << "/// <param name=\"parent\">The Efl.Object parent of this instance.</param>\n"
547 << scope_tab << "protected " << inherit_name << "(IntPtr baseKlass, System.Type managedType, Efl.Object parent) : base(baseKlass, managedType, parent)\n" 550 << scope_tab << "protected " << inherit_name << "(IntPtr baseKlass, Efl.Object parent) : base(baseKlass, parent)\n"
548 << scope_tab << "{\n" 551 << scope_tab << "{\n"
549 << scope_tab << "}\n\n" 552 << scope_tab << "}\n\n"
550 ).generate(sink, attributes::unused, context); 553 ).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 851b9c4..c949783 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
396 if(!as_generator 396 if(!as_generator
397 ( 397 (
398 indent << "[StructLayout(LayoutKind.Sequential)]\n" 398 indent << "[StructLayout(LayoutKind.Sequential)]\n"
399 << indent << "[Efl.Eo.BindingEntity]\n"
399 << indent << "public struct " << string << "\n" 400 << indent << "public struct " << string << "\n"
400 << indent << "{\n" 401 << indent << "{\n"
401 ) 402 )
diff --git a/src/bindings/mono/eo_mono/EoWrapper.cs b/src/bindings/mono/eo_mono/EoWrapper.cs
index 03edea0..c2ee5e2 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
67 /// Internal usage: Constructor to actually call the native library constructors. C# subclasses 67 /// Internal usage: Constructor to actually call the native library constructors. C# subclasses
68 /// must use the public constructor only.</summary> 68 /// must use the public constructor only.</summary>
69 /// <param name="baseKlass">The pointer to the base native Eo class.</param> 69 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
70 /// <param name="managedType">The managed type of the public constructor that originated this call.</param>
71 /// <param name="parent">The Efl.Object parent of this instance.</param> 70 /// <param name="parent">The Efl.Object parent of this instance.</param>
72 /// <param name="file">Name of the file from where the constructor is called.</param> 71 /// <param name="file">Name of the file from where the constructor is called.</param>
73 /// <param name="line">Number of the line from where the constructor is called.</param> 72 /// <param name="line">Number of the line from where the constructor is called.</param>
74 protected EoWrapper(IntPtr baseKlass, System.Type managedType, Efl.Object parent, 73 protected EoWrapper(IntPtr baseKlass, Efl.Object parent,
75 [CallerFilePath] string file = null, 74 [CallerFilePath] string file = null,
76 [CallerLineNumber] int line = 0) 75 [CallerLineNumber] int line = 0)
77 { 76 {
78 generated = ((object)this).GetType() == managedType; 77 generated = Efl.Eo.BindingEntity.IsBindingEntity(((object)this).GetType());
79 IntPtr actual_klass = baseKlass; 78 IntPtr actual_klass = baseKlass;
80 if (!generated) 79 if (!generated)
81 { 80 {
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index 833ae78..09c82a7 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
775 } 775 }
776} 776}
777 777
778[System.AttributeUsage(System.AttributeTargets.Class |
779 System.AttributeTargets.Interface |
780 System.AttributeTargets.Enum |
781 System.AttributeTargets.Delegate |
782 System.AttributeTargets.Struct,
783 AllowMultiple = false,
784 Inherited = false)
785]
786public class BindingEntity: System.Attribute
787{
788 public static bool IsBindingEntity(System.Type t)
789 {
790 return Attribute.GetCustomAttribute(t, typeof(BindingEntity), false) != null;
791 }
792}
793
778public interface IWrapper 794public interface IWrapper
779{ 795{
780 /// <summary>Pointer to internal Eo instance.</summary> 796 /// <summary>Pointer to internal Eo instance.</summary>