From 078fbff8f41fbf5ab9d8389e63aa5d0dbbc1d5f5 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Fri, 23 Apr 2021 19:26:17 +0900 Subject: 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 Reviewed-by: Laurent Pinchart --- utils/ipc/generators/mojom_libcamera_generator.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'utils/ipc/generators/mojom_libcamera_generator.py') 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}' -- cgit v1.2.1