Skip to content

Commit

Permalink
bugfix(ev-cli): support array type in subscription
Browse files Browse the repository at this point in the history
- the json array object has been casted to `nlohman::json::array` so
  far, instead of `std::vector<ItemType>` for subscription
- this commit introduces some code duplication, as it copies the
  handling from the `_gather_cmds` implementation -- this should be
  refactored
- NOTE: the array of enum handling has not been checked

Signed-off-by: aw <[email protected]>
  • Loading branch information
a-w50 committed Jun 13, 2024
1 parent d144f55 commit e1c4a5a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ev-dev-tools/src/ev_cli/templates/interface-Exports.hpp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ public:
{% elif 'enum_type' in var %}
auto native_value = {{ string_to_enum(var.enum_type) }}({{ var_to_cpp(var) }}(value));
listener(native_value);
{% elif 'array_type' in var %}
{% if 'array_type_contains_enum' in var %}
std::vector<{{ arg.array_type }}> typed_value;
for (auto& entry : value) {
typed_value.push_back({{ string_to_enum(var.array_type) }}(entry));
}
listener(typed_value);
{% else %}
listener(value);
{% endif %}
{% elif var.json_type != 'null' %}
listener({{ var_to_cpp(var) }}(value));
{% else %}
Expand Down

0 comments on commit e1c4a5a

Please sign in to comment.