summaryrefslogtreecommitdiff
path: root/utils/ipc/generators/mojom_libcamera_generator.py
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2021-04-23 19:26:17 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2021-04-27 17:34:58 +0900
commit078fbff8f41fbf5ab9d8389e63aa5d0dbbc1d5f5 (patch)
treeb42da512ddc5f99ea1a9958108cadacc1c17c387 /utils/ipc/generators/mojom_libcamera_generator.py
parent17e8f6f71c0a03bd011675f83e93912317527885 (diff)
utils: ipc: Use the proper namespace for mojom structs
Structs defined in mojom previously used the namespace of the mojom file that was being used as the source. This is obviously not the correct namespace for structs that are defined in core.mojom. Fix the jinja function for getting the element type including namespace, and use it. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'utils/ipc/generators/mojom_libcamera_generator.py')
-rw-r--r--utils/ipc/generators/mojom_libcamera_generator.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/utils/ipc/generators/mojom_libcamera_generator.py b/utils/ipc/generators/mojom_libcamera_generator.py
index db9e28a6..effdfed6 100644
--- a/utils/ipc/generators/mojom_libcamera_generator.py
+++ b/utils/ipc/generators/mojom_libcamera_generator.py
@@ -258,12 +258,12 @@ def GetNameForElement(element):
return element.mojom_name
# vectors
if (mojom.IsArrayKind(element)):
- elem_name = GetNameForElement(element.kind)
+ elem_name = GetFullNameForElement(element.kind)
return f'std::vector<{elem_name}>'
# maps
if (mojom.IsMapKind(element)):
- key_name = GetNameForElement(element.key_kind)
- value_name = GetNameForElement(element.value_kind)
+ key_name = GetFullNameForElement(element.key_kind)
+ value_name = GetFullNameForElement(element.value_kind)
return f'std::map<{key_name}, {value_name}>'
# struct fields and function parameters
if isinstance(element, (mojom.Field, mojom.Method, mojom.Parameter)):
@@ -296,8 +296,16 @@ def GetNameForElement(element):
raise Exception('Unsupported element: %s' % element)
raise Exception('Unexpected element: %s' % element)
-def GetFullNameForElement(element, namespace_str):
+def GetFullNameForElement(element):
name = GetNameForElement(element)
+ namespace_str = ''
+ if mojom.IsStructKind(element):
+ namespace_str = element.module.mojom_namespace.replace('.', '::')
+ elif (hasattr(element, 'kind') and
+ (mojom.IsStructKind(element.kind) or
+ mojom.IsEnumKind(element.kind))):
+ namespace_str = element.kind.module.mojom_namespace.replace('.', '::')
+
if namespace_str == '':
return name
return f'{namespace_str}::{name}'