[rtems-central commit] content: Make align_declarations() public

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


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

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

content: Make align_declarations() public

---

 rtemsspec/content.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/rtemsspec/content.py b/rtemsspec/content.py
index 2b3c33e1..f804bbaf 100644
--- a/rtemsspec/content.py
+++ b/rtemsspec/content.py
@@ -576,12 +576,13 @@ def _get_align_pos(param: str) -> Tuple[int, int]:
     return match.start(1), match.start(1)
 
 
-def _align_params(params: List[str]) -> List[str]:
-    positions = list(map(_get_align_pos, params))
+def align_declarations(decls: List[str]) -> List[str]:
+    """ Aligns a list of C/C++ declarations. """
+    positions = list(map(_get_align_pos, decls))
     max_pos = max(positions)[1]
     return [
         param[:pos[0]] + (max_pos - pos[1]) * " " + param[pos[0]:]
-        for param, pos in zip(params, positions)
+        for param, pos in zip(decls, positions)
     ]
 
 
@@ -879,7 +880,7 @@ class CContent(Content):
         line = f"{ret}{space}{name}{param_line}{semicolon}"
         if len(self._indent) + len(line) > 79:
             if align:
-                params = _align_params(params)
+                params = align_declarations(params)
             self._function(ret, name, params, param_line, space, semicolon)
         else:
             self.add(line)



More information about the vc mailing list