summaryrefslogtreecommitdiff
path: root/rtemsspec/rtems.py
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2023-11-21 11:13:16 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-11-21 11:15:25 +0100
commitb0e8c33fe224459a6925cc27b35f0e843dd3fb78 (patch)
treecf4f6dd2442729aadaed95308fcb98965bb7c5c7 /rtemsspec/rtems.py
parent82d2dbe09683c898e1999e2314de6fac4ccad740 (diff)
rtems: Add gather_api_items()
Diffstat (limited to 'rtemsspec/rtems.py')
-rw-r--r--rtemsspec/rtems.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/rtemsspec/rtems.py b/rtemsspec/rtems.py
index df0af3f5..cd68f036 100644
--- a/rtemsspec/rtems.py
+++ b/rtemsspec/rtems.py
@@ -27,7 +27,7 @@
import base64
import hashlib
import itertools
-from typing import Any, List, Tuple, Union
+from typing import Any, Dict, List, Tuple, Union
from rtemsspec.items import create_unique_link, Item, ItemCache, Link
from rtemsspec.glossary import augment_glossary_terms
@@ -240,6 +240,44 @@ def validate(item: Item) -> None:
"interface-placement")
+_API_INTERFACES = [
+ "interface/appl-config-option/feature",
+ "interface/appl-config-option/feature-enable",
+ "interface/appl-config-option/initializer",
+ "interface/appl-config-option/integer",
+ "interface/function",
+ "interface/macro",
+ "interface/unspecified-function",
+ "interface/unspecified-macro",
+]
+
+_API_ROLES = [
+ "requirement-refinement",
+ "interface-ingroup",
+]
+
+
+def _gather_api_items(item: Item, items: Dict[str, List[Item]]) -> None:
+ if item.type in _API_INTERFACES and item["_pre_qualified"]:
+ parent = item.parent(_API_ROLES)
+ group = items.setdefault(parent.get("name", parent.spec), [])
+ group.append(item)
+ for child in item.children(_API_ROLES):
+ _gather_api_items(child, items)
+
+
+def gather_api_items(item_cache: ItemCache, items: Dict[str,
+ List[Item]]) -> None:
+ """
+ Gathers all API related items and groups them by the associated interface
+ group name.
+
+ If a group has no name, then the UID is used instead.
+ """
+ for group in item_cache["/req/api"].children("requirement-refinement"):
+ _gather_api_items(group, items)
+
+
def _is_proxy_link_enabled(link: Link) -> bool:
return link.item.is_enabled(link.item.cache.enabled)