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
This commit is contained in:
Lauro Moura 2019-07-11 15:50:33 -03:00 committed by Vitor Sousa
parent 89399672b7
commit a19bb21edf
7 changed files with 28 additions and 6 deletions

View 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))

View 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"

View 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))

View 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);

View 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"
)

View 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)
{

View 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>