Skip to content

Commit

Permalink
utils: ipc: Allow the skipHeader attribute on enums
Browse files Browse the repository at this point in the history
Currently, enums that are passed between pipeline handlers and their IPA
must be defined in a mojom file. However, there is a use case for
enum/flags to be defined in a C++ header, such that the enum can be used
in a component other than the pipeline handler and its IPA.

To support this, add support for the skipHeader attribute for enums.
Like structs, it is only allowed in core.mojom.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  • Loading branch information
Rahi374 committed Oct 18, 2022
1 parent 3b54b56 commit 4e9ed14
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions include/libcamera/ipa/core.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ module libcamera;
* - structs
*
* Attributes:
* - skipHeader - structs only, and only in core.mojom
* - Do not generate a C++ definition for the structure
* - skipHeader - allowed only for structs and enums in core.mojom
* - Do not generate a C++ definition for the structure or enum
* - Any type used in a mojom interface definition must have a corresponding
* definition in a mojom file for the code generator to accept it, except
* for types solely used as map/array members for which a definition is not
Expand Down Expand Up @@ -52,6 +52,8 @@ module libcamera;
* then the type definition in the core.mojom file should have the
* [skipHeader] attribute only
* - A (de)serializer will be generated for the type
* - enums that are defined in a libcamera C++ header also fall in this
* category
* - If a type definition has [skipHeader], then the header where the type is
* defined must be included in ipa_interface.h
* - Types that are solely used as array/map members do not require a mojom
Expand Down
4 changes: 2 additions & 2 deletions include/libcamera/ipa/ipa_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
namespace libcamera {

/*
* Structs that are defined in core.mojom and have the skipHeader tag must be
* #included here.
* Structs and enums that are defined in core.mojom that have the skipHeader
* tag must be #included here.
*/

class IPAInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace libcamera {
static const {{const.kind|name}} {{const.mojom_name}} = {{const.value}};
{% endfor %}

{% for enum in enums %}
{% for enum in enums_gen_header %}
{{funcs.define_enum(enum)}}
{% endfor %}

Expand Down
2 changes: 1 addition & 1 deletion utils/ipc/generators/mojom_libcamera_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def _GetJinjaExports(self):
def _GetJinjaExportsForCore(self):
return {
'consts': self.module.constants,
'enums': self.module.enums,
'enums_gen_header': [x for x in self.module.enums if x.attributes is None or 'skipHeader' not in x.attributes],
'has_array': len([x for x in self.module.kinds.keys() if x[0] == 'a']) > 0,
'has_map': len([x for x in self.module.kinds.keys() if x[0] == 'm']) > 0,
'structs_gen_header': [x for x in self.module.structs if x.attributes is None or 'skipHeader' not in x.attributes],
Expand Down

0 comments on commit 4e9ed14

Please sign in to comment.