From 11094aeaaf001241fb2d5bc8e74e23e8db944a2d Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Tue, 26 Nov 2019 11:13:47 -0300 Subject: [PATCH] csharp: Add more since tags to members Summary: - Class constructors and other members - Aliases fields ref T8359 Reviewers: felipealmeida, segfaultxavi, brunobelo, woohyun Reviewed By: felipealmeida Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8359 Differential Revision: https://phab.enlightenment.org/D10419 --- .../eolian/mono/alias_definition.hh | 12 +++++- .../eolian_mono/eolian/mono/documentation.hh | 18 ++++++++- src/bin/eolian_mono/eolian/mono/klass.hh | 40 +++++++++++++++---- src/lib/eolian_cxx/grammar/indentation.hpp | 11 +++++ 4 files changed, 71 insertions(+), 10 deletions(-) diff --git a/src/bin/eolian_mono/eolian/mono/alias_definition.hh b/src/bin/eolian_mono/eolian/mono/alias_definition.hh index 31d86fe10d..d7fda07cb5 100644 --- a/src/bin/eolian_mono/eolian/mono/alias_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/alias_definition.hh @@ -56,6 +56,10 @@ struct alias_definition_generator alias_type_doc = utils::replace_all(alias_type, "<", "<"); alias_type_doc = utils::replace_all(alias_type_doc, ">", ">"); + std::string alias_since; + if (!documentation_helpers::generate_since_tag_line(std::back_inserter(alias_since), alias.documentation, scope_tab, context)) + return false; + std::string const alias_name = utils::remove_all(alias.eolian_name, '_'); if (!as_generator( documentation @@ -63,7 +67,9 @@ struct alias_definition_generator << "{\n" << scope_tab << "private " << alias_type << " payload;\n\n" - << scope_tab << "/// Converts an instance of " << alias_type_doc << " to this struct.\n" + << scope_tab << "/// Converts an instance of " << alias_type_doc << " to this struct.\n" + << alias_since + << scope_tab << "/// \n" << scope_tab << "/// The value to be converted.\n" << scope_tab << "/// A struct with the given value.\n" << scope_tab << "public static implicit operator " << alias_name << "(" << alias_type << " value)\n" @@ -71,7 +77,9 @@ struct alias_definition_generator << scope_tab << scope_tab << "return new " << alias_name << "{payload=value};\n" << scope_tab << "}\n\n" - << scope_tab << "/// Converts an instance of this struct to " << alias_type_doc << ".\n" + << scope_tab << "/// Converts an instance of this struct to " << alias_type_doc << ".\n" + << alias_since + << scope_tab << "/// \n" << scope_tab << "/// The value to be converted packed in this struct.\n" << scope_tab << "/// The actual value the alias is wrapping.\n" << scope_tab << "public static implicit operator " << alias_type << "(" << alias_name << " value)\n" diff --git a/src/bin/eolian_mono/eolian/mono/documentation.hh b/src/bin/eolian_mono/eolian/mono/documentation.hh index b57dc4a6de..0a2179b167 100644 --- a/src/bin/eolian_mono/eolian/mono/documentation.hh +++ b/src/bin/eolian_mono/eolian/mono/documentation.hh @@ -649,8 +649,24 @@ struct documentation_string_generator } const documentation_string {}; -} // namespace eolian_mono +namespace documentation_helpers +{ +template +bool generate_since_tag_line(OutputIterator sink, attributes::documentation_def const& doc, Indent indentation, Context context) +{ + if (doc.since.empty()) + return true; + + return as_generator + ( + indentation << ("/// Since EFL " + doc.since + ".\n") + ).generate(sink, attributes::unused, context); +} + +} // documentation_helpers + +} // namespace eolian_mono namespace efl { namespace eolian { namespace grammar { diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh index 81d5956535..653acc78fc 100644 --- a/src/bin/eolian_mono/eolian/mono/klass.hh +++ b/src/bin/eolian_mono/eolian/mono/klass.hh @@ -410,6 +410,10 @@ struct klass auto implementable_methods = helpers::get_all_registerable_methods(cls, context); bool root = !helpers::has_regular_ancestor(cls); auto const& indent = current_indentation(inative_cxt); + std::string klass_since; + + if (!documentation_helpers::generate_since_tag_line(std::back_inserter(klass_since), cls.documentation, indent, context)) + return false; std::string base_name; if(!root) @@ -421,7 +425,10 @@ struct klass if(!as_generator ( indent << lit("/// Wrapper for native methods and virtual method delegates.\n") - << indent << "/// For internal use by generated code only.\n" + << indent << "/// For internal use by generated code only.\n" + << klass_since + << indent << "/// \n" + << indent << "[EditorBrowsable(EditorBrowsableState.Never)]\n" << indent << "internal new class " << native_inherit_name << " : " << (root ? "Efl.Eo.EoWrapper.NativeMethods" : base_name) << "\n" << indent << "{\n" ).generate(sink, attributes::unused, inative_cxt)) @@ -437,7 +444,9 @@ struct klass } if(!as_generator( - indent << scope_tab << "/// Gets the list of Eo operations to override.\n" + indent << scope_tab << "/// Gets the list of Eo operations to override.\n" + << klass_since + << indent << "/// \n" << indent << scope_tab << "/// The list of Eo operations to be overload.\n" << indent << scope_tab << "internal override System.Collections.Generic.List GetEoOps(System.Type type, bool includeInherited)\n" << indent << scope_tab << "{\n" @@ -485,9 +494,14 @@ struct klass ).generate(sink, attributes::unused, inative_cxt)) return false; + if (!klass_since.empty()) + klass_since = static_cast(scope_tab) + klass_since; + // Attribute getter of the native 'Efl_Class *' handle (for proper inheritance from additional explicit interfaces) if(!as_generator( - indent << scope_tab << "/// Returns the Eo class for the native methods of this class.\n" + indent << scope_tab << "/// Returns the Eo class for the native methods of this class.\n" + << klass_since + << indent << scope_tab << "/// \n" << indent << scope_tab << "/// The native class pointer.\n" << indent << scope_tab << "internal override IntPtr GetEflClass()\n" << indent << scope_tab << "{\n" @@ -558,9 +572,15 @@ struct klass return !blacklist::is_function_blacklisted(ctor.function, context); }); + std::string klass_since; + if (!documentation_helpers::generate_since_tag_line(std::back_inserter(klass_since), cls.documentation, scope_tab, context)) + return false; + // Public (API) constructors if (!as_generator( - scope_tab << "/// Initializes a new instance of the class.\n" + scope_tab << "/// Initializes a new instance of the class.\n" + << klass_since + << scope_tab << "/// \n" << scope_tab << "/// Parent instance.\n" << *(documentation) // For constructors with arguments, the parent is also required, as optional parameters can't come before non-optional paramenters. @@ -572,13 +592,17 @@ struct klass << scope_tab << scope_tab << "FinishInstantiation();\n" << scope_tab << "}\n\n" << scope_tab << "/// Subclasses should override this constructor if they are expected to be instantiated from native code.\n" - << scope_tab << "/// Do not call this constructor directly.\n" + << scope_tab << "/// Do not call this constructor directly.\n" + << klass_since + << scope_tab << "/// \n" << scope_tab << "/// Tag struct storing the native handle of the object being constructed.\n" << scope_tab << "protected " << inherit_name << "(ConstructingHandle ch) : base(ch)\n" << scope_tab << "{\n" << scope_tab << "}\n\n" << scope_tab << "/// Initializes a new instance of the class.\n" - << scope_tab << "/// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.\n" + << scope_tab << "/// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.\n" + << klass_since + << scope_tab << "/// \n" << scope_tab << "/// The native pointer to be wrapped.\n" << scope_tab << "internal " << inherit_name << "(Efl.Eo.WrappingHandle wh) : base(wh)\n" << scope_tab << "{\n" @@ -605,7 +629,9 @@ struct klass return as_generator( scope_tab << "/// Initializes a new instance of the 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.\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.\n" + << klass_since + << scope_tab << "/// \n" << scope_tab << "/// The pointer to the base native Eo class.\n" << scope_tab << "/// The Efl.Object parent of this instance.\n" << scope_tab << "protected " << inherit_name << "(IntPtr baseKlass, Efl.Object parent) : base(baseKlass, parent)\n" diff --git a/src/lib/eolian_cxx/grammar/indentation.hpp b/src/lib/eolian_cxx/grammar/indentation.hpp index b88a14d392..3bf5d07dbe 100644 --- a/src/lib/eolian_cxx/grammar/indentation.hpp +++ b/src/lib/eolian_cxx/grammar/indentation.hpp @@ -53,6 +53,11 @@ struct scope_tab_generator int n; int m; + + explicit operator std::string() const + { + return std::string(n * m, ' '); + } }; template <> @@ -71,6 +76,12 @@ struct scope_tab_terminal { return {1}; } + + explicit operator std::string() const + { + return static_cast(scope_tab_generator{1}); + } + } const scope_tab = {}; template <>