[rtems-central commit] content: Add get_value_unspecified_type()

Sebastian Huber sebh at rtems.org
Tue May 9 13:45:26 UTC 2023


Module:    rtems-central
Branch:    master
Commit:    f31ca5f9b0299211c2f21b1e814654c7b2749838
Changeset: http://git.rtems.org/rtems-central/commit/?id=f31ca5f9b0299211c2f21b1e814654c7b2749838

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri May  5 14:41:18 2023 +0200

content: Add get_value_unspecified_type()

---

 rtemsspec/content.py                                  |  5 +++++
 rtemsspec/interface.py                                | 11 ++++++++++-
 rtemsspec/interfacedoc.py                             |  6 +++++-
 rtemsspec/tests/spec-interface/func.yml               |  1 +
 rtemsspec/tests/spec-interface/unspecified-struct.yml | 10 ++++++++++
 rtemsspec/tests/test_interface.py                     |  1 +
 rtemsspec/tests/test_interfacedoc.py                  |  2 +-
 rtemsspec/validation.py                               |  7 ++++++-
 8 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/rtemsspec/content.py b/rtemsspec/content.py
index 12ea4e9a..8ecf401a 100644
--- a/rtemsspec/content.py
+++ b/rtemsspec/content.py
@@ -1084,6 +1084,11 @@ def get_value_compound(ctx: ItemGetValueContext) -> Any:
     return ctx.item['name']
 
 
+def get_value_unspecified_type(ctx: ItemGetValueContext) -> Any:
+    """ Gets a value as a compound (unspecified struct or union). """
+    return f"{ctx.item['interface-type'][12:]} {ctx.item['name']}"
+
+
 class ExpressionMapper:
     """ Maps symbols and operations to form a C expression. """
 
diff --git a/rtemsspec/interface.py b/rtemsspec/interface.py
index d14dff92..85a6781a 100644
--- a/rtemsspec/interface.py
+++ b/rtemsspec/interface.py
@@ -37,7 +37,8 @@ from rtemsspec.content import CContent, CInclude, enabled_by_to_exp, \
     get_value_double_colon, get_value_doxygen_function, \
     get_value_doxygen_group, get_value_doxygen_ref, \
     get_value_forward_declaration, get_value_hash, get_value_header_file, \
-    get_value_params, get_value_plural, to_camel_case
+    get_value_params, get_value_plural, get_value_unspecified_type, \
+    to_camel_case
 from rtemsspec.items import Item, ItemCache, ItemGetValueMap, ItemMapper
 
 ItemMap = Dict[str, Item]
@@ -64,6 +65,14 @@ class _InterfaceMapper(ItemMapper):
         self._code_or_doc = "doc"
         self.add_get_value("interface/struct/code:/name", get_value_compound)
         self.add_get_value("interface/union/code:/name", get_value_compound)
+        self.add_get_value("interface/unspecified-struct/code:/name",
+                           get_value_unspecified_type)
+        self.add_get_value("interface/unspecified-struct/doc:/name",
+                           get_value_unspecified_type)
+        self.add_get_value("interface/unspecified-union/code:/name",
+                           get_value_unspecified_type)
+        self.add_get_value("interface/unspecified-union/doc:/name",
+                           get_value_unspecified_type)
         self.add_get_value("glossary/term/doc:/plural", get_value_plural)
         self.add_get_value("interface/forward-declaration/code:/name",
                            get_value_forward_declaration)
diff --git a/rtemsspec/interfacedoc.py b/rtemsspec/interfacedoc.py
index 9474d353..c7b03fff 100644
--- a/rtemsspec/interfacedoc.py
+++ b/rtemsspec/interfacedoc.py
@@ -31,7 +31,7 @@ import os
 from typing import Any, Dict, List, Tuple
 
 from rtemsspec.content import CContent, get_value_compound, \
-    get_value_forward_declaration
+    get_value_forward_declaration, get_value_unspecified_type
 from rtemsspec.sphinxcontent import get_label, get_reference, sanitize_name, \
     SphinxContent, SphinxInterfaceMapper
 from rtemsspec.items import Item, ItemCache, ItemGetValueContext, ItemMapper
@@ -56,6 +56,10 @@ class _CodeMapper(ItemMapper):
         self.add_get_value("interface/struct:/name", get_value_compound)
         self.add_get_value("interface/union:/name", get_value_compound)
         self.add_get_value("interface/macro:/params/name", _get_code_param)
+        self.add_get_value("interface/unspecified-struct:/name",
+                           get_value_unspecified_type)
+        self.add_get_value("interface/unspecified-unione:/name",
+                           get_value_unspecified_type)
 
 
 def _generate_introduction(target: str, group: Item, group_uids: List[str],
diff --git a/rtemsspec/tests/spec-interface/func.yml b/rtemsspec/tests/spec-interface/func.yml
index e02a2d90..c60a9302 100644
--- a/rtemsspec/tests/spec-interface/func.yml
+++ b/rtemsspec/tests/spec-interface/func.yml
@@ -19,6 +19,7 @@ description: |
   ${td:/name}, ${enum:/name}, ${define:/name}, ${macro:/name}, ${var:/name},
   ${enumerator-0:/name}, ${s:/name}, ${option:/name}, ${option:/type},
   ${ga:/name}, and ${gf:/name}.  Second parameter is ${.:/params[1]/name}.
+  Mention ${unspecified-struct:/name}.
 
   .. code-block:
 
diff --git a/rtemsspec/tests/spec-interface/unspecified-struct.yml b/rtemsspec/tests/spec-interface/unspecified-struct.yml
new file mode 100644
index 00000000..85dd6d68
--- /dev/null
+++ b/rtemsspec/tests/spec-interface/unspecified-struct.yml
@@ -0,0 +1,10 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2023 embedded brains GmbH & Co. KG
+enabled-by: true
+index-entries: []
+interface-type: unspecified-struct
+links: []
+name: US
+references: []
+type: interface
diff --git a/rtemsspec/tests/test_interface.py b/rtemsspec/tests/test_interface.py
index 40ad5f72..bdd9fbfa 100644
--- a/rtemsspec/tests/test_interface.py
+++ b/rtemsspec/tests/test_interface.py
@@ -219,6 +219,7 @@ struct Struct;
  * Function description.  References to xs, VeryLongFunction(), ::Integer,
  * #Enum, #DEFINE, VERY_LONG_MACRO(), #Variable, ::ENUMERATOR_0, Struct, @ref
  * a, interface, @ref GroupA, and @ref GroupF.  Second parameter is ``Param1``.
+ * Mention struct US.
  *
  * @code
  * these two lines
diff --git a/rtemsspec/tests/test_interfacedoc.py b/rtemsspec/tests/test_interfacedoc.py
index e9d78bad..42c1a9c8 100644
--- a/rtemsspec/tests/test_interfacedoc.py
+++ b/rtemsspec/tests/test_interfacedoc.py
@@ -466,7 +466,7 @@ Function description.  References to :term:`xs <x>`,
 :ref:`InterfaceVeryLongFunction`, :c:type:`Integer`, :c:type:`Enum`,
 :c:macro:`DEFINE`, :ref:`InterfaceVERYLONGMACRO`, Variable,
 :c:macro:`ENUMERATOR_0`, ``struct Struct``, :ref:`a`, interface, :ref:`GroupA`,
-and Group F.  Second parameter is ``Param1``.
+and Group F.  Second parameter is ``Param1``. Mention :c:type:`US`.
 
 .. code-block:
 
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index 729c25a1..ce7602be 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -34,7 +34,8 @@ from typing import Any, Dict, List, Optional, Tuple
 
 from rtemsspec.content import CContent, CInclude, enabled_by_to_exp, \
     ExpressionMapper, GenericContent, get_integer_type, get_value_params, \
-    get_value_plural, get_value_doxygen_group, get_value_doxygen_function
+    get_value_plural, get_value_doxygen_group, get_value_doxygen_function, \
+    get_value_unspecified_type
 from rtemsspec.items import create_unique_link, Item, ItemCache, \
     ItemGetValueContext, ItemMapper
 from rtemsspec.transitionmap import TransitionMap
@@ -74,6 +75,10 @@ class _Mapper(ItemMapper):
         self.add_get_value("interface/macro:/params/name", get_value_params)
         self.add_get_value("interface/unspecified-function:/name",
                            get_value_doxygen_function)
+        self.add_get_value("interface/unspecified-struct:/name",
+                           get_value_unspecified_type)
+        self.add_get_value("interface/unspecified-unione:/name",
+                           get_value_unspecified_type)
         self.add_get_value("memory-benchmark:/test-suite-name",
                            _get_test_suite_name)
         self.add_get_value(



More information about the vc mailing list