Skip to content

Commit

Permalink
Add bool specialization for VariableLengthArray; fix AUTOSAR complian…
Browse files Browse the repository at this point in the history
…ce issues; fix GTest integration (OpenCyphal#284)

- Add bool specialization for VariableLengthArray; fix OpenCyphal#260 
- Fix OpenCyphal#281 
- Update Google Test to the latest version v1.13
- Fix incorrect handling of compilation flags in `Findgtest.cmake`
- Fix warnings revealed by the above fix

There is a fair amount of code duplication between the generic and
specialized versions of `VariableLengthArray`. It is possible to
eliminate some of it by extracting commonalities into a base class.
  • Loading branch information
pavel-kirienko authored Mar 3, 2023
1 parent b3b6939 commit b903b8e
Show file tree
Hide file tree
Showing 16 changed files with 1,157 additions and 188 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ In the list of targets that the :code:`cmake --build . --target help` command li
will be prefixed with :code:`test_` and the psedo-target that also executes the test will be prefixed with
:code:`run_test_`. You should avoid the :code:`_with_lcov` when you are manually building tests.

To obtain coverage information for the verification suite (not the Python code),
build the `cov_all` target and inspect the output under the `coverage` directory.

cmake build options
------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/nunavut/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.. autodata:: __version__
"""

__version__ = "2.0.2"
__version__ = "2.0.3"
__license__ = "MIT"
__author__ = "OpenCyphal"
__copyright__ = "Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Copyright (c) 2022 OpenCyphal."
Expand Down
6 changes: 1 addition & 5 deletions src/nunavut/jinja/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def __init__(
package_name_for_templates: typing.Optional[str] = None,
search_policy: ResourceSearchPolicy = ResourceSearchPolicy.FIND_ALL,
):

super().__init__(namespace, generate_namespace_types)

if templates_dir is not None and not isinstance(templates_dir, list):
Expand Down Expand Up @@ -668,7 +667,6 @@ def is_deprecated(instance: pydsdl.Any) -> bool:
# +-----------------------------------------------------------------------+

def __init__(self, namespace: nunavut.Namespace, **kwargs: typing.Any):

# set the search policy so we ignore the internal templates iff a filesystem
# path is provided to the generator.
super().__init__(namespace, search_policy=ResourceSearchPolicy.FIND_FIRST, **kwargs)
Expand All @@ -688,7 +686,7 @@ def generate_all(
*self.language_context.get_target_language().get_support_module(), is_dryrun, omit_serialization_support
)
provider = self.namespace.get_all_types if self.generate_namespace_types else self.namespace.get_all_datatypes
for (parsed_type, output_path) in provider():
for parsed_type, output_path in provider():
logger.info("Generating: %s", parsed_type)
generated.append(self._generate_type(parsed_type, output_path, is_dryrun, allow_overwrite))
return generated
Expand Down Expand Up @@ -785,7 +783,6 @@ class SupportGenerator(CodeGenerator):
"""

def __init__(self, namespace: nunavut.Namespace, **kwargs: typing.Any):

super().__init__(namespace, builtin_template_path="support", **kwargs)

target_language = self.language_context.get_target_language()
Expand Down Expand Up @@ -867,7 +864,6 @@ def _copy_header(
line_pps: typing.List["nunavut._postprocessors.LinePostProcessor"],
file_pps: typing.List["nunavut._postprocessors.FilePostProcessor"],
) -> pathlib.Path:

if not is_dryrun:
self._handle_overwrite(target, allow_overwrite)
target.parent.mkdir(parents=True, exist_ok=True)
Expand Down
2 changes: 0 additions & 2 deletions src/nunavut/jinja/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ def update_nunavut_globals(
is_dryrun: bool = False,
omit_serialization_support: bool = False,
) -> None:

nunavut_namespace = self.nunavut_global

setattr(
Expand Down Expand Up @@ -498,7 +497,6 @@ def _add_support_from_language_module_to_environment(
)

def _update_language_support(self, lctx: LanguageContext) -> None:

supported_languages = lctx.get_supported_languages()
target_language = lctx.get_target_language()
ln_globals = self.globals["ln"]
Expand Down
1 change: 0 additions & 1 deletion src/nunavut/jinja/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ def parse(self, parser: Parser) -> nodes.Node:
return result

def _use_query_common(self, uses_query_name: str, lineno: int, name: str, filename: str) -> bool:

target_language = self.environment.target_language

if uses_query_name is None:
Expand Down
1 change: 0 additions & 1 deletion src/nunavut/lang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ def _new_language_map(self, target_language: Language) -> typing.Dict[str, Langu
return languages

def _resolve_target_language(self, explicit_value: typing.Optional[str]) -> str:

if explicit_value is not None:
return explicit_value

Expand Down
2 changes: 0 additions & 2 deletions src/nunavut/lang/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ def _strop_by_keyword(self, token: str, token_type: str, dry_run: bool) -> str:
return stropped

def _strop_by_pattern(self, token: str, token_type: str, dry_run: bool) -> str:

stropped = token

reserved_pattern_rules = self._reserved_token_patterns_by_type[token_type]
Expand Down Expand Up @@ -439,7 +438,6 @@ def encode_character(self, c: str) -> str:

@functools.lru_cache(maxsize=1024)
def strop(self, token: str, token_type: str = "any") -> str: # noqa: C901

token_type_lower = token_type.lower()
if token_type_lower == "all":
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion src/nunavut/lang/cpp/support/serialization.j2
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public:
const uint8_t in = static_cast<uint8_t>(static_cast<uint8_t>(data_[src_off / 8U] >> src_mod) << dst_mod) & 0xFFU; // NOSONAR
// Intentional violation of MISRA: indexing on a pointer.
// This simplifies the implementation greatly and avoids pointer arithmetics.
const uint8_t a = dst.data_[dst_off / 8U] & (static_cast<uint8_t>((~mask) & 0xFFU)); // NOSONAR
const uint8_t a = dst.data_[dst_off / 8U] & (static_cast<uint8_t>(static_cast<uint8_t>(~mask) & 0xFFU)); // NOSONAR
const uint8_t b = in & mask;
// Intentional violation of MISRA: indexing on a pointer.
// This simplifies the implementation greatly and avoids pointer arithmetics.
Expand Down
Loading

0 comments on commit b903b8e

Please sign in to comment.