-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose FullNameAndVersion()
from a DSDL type.
#352
Conversation
…hirokov/cpp_type_name # Conflicts: # src/nunavut/_version.py
FullNameAndVersion()
from a DSDL type.
{% endif -%} | ||
{%- assert composite_type.extent % 8 == 0 %} | ||
{% endif %} | ||
static constexpr const char* FullNameAndVersion() { return "{{ composite_type }}"; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I can't make it as simple as it could be in c++17:
static constexpr char FullNameAndVersion[] = "{{ composite_type }}";
- linker error @ c++14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can by adding constexpr char {{composite_type|short_reference_name}}::FullNameAndVersion[];
after the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sonar will catch ODR issue with such approach.
@@ -0,0 +1,117 @@ | |||
/* | |||
* Copyright (c) 2024 OpenCyphal Development Team. | |||
* Authors: Sergei Shirokov <sergei.shirokov@zubax.com> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inspired by corresponding "C" test, namely verification/c/suite/test_constant.c
Quality Gate passedIssues Measures |
Le(regulated::basics::Struct__0_1::_traits_::SerializationBufferSizeBytes * 8U)); | ||
EXPECT_TRUE(regulated::basics::Struct__0_1::CONSTANT_TRUTH); | ||
|
||
// TODO: Uncomment when some form of "ARRAY_CAPACITY" is generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate issue and PR but probably I will add generation of a new <DSDL Type>::_traits_::ArrayCapacity
struct (similar to existing struct TypeOf
), where there will be listed static constexpr std::size_t
constants for each field which has variable array type. Static array fields don't require such information (b/c std::array<>
already has .size()
method), but maybe just for consistency I will list them as well.
And I'm not planning to expose analog of ARRAY_IS_VARIABLE_LENGTH_
boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thirtytwobits Do you agree with my future plan about above "ARRAY_CAPACITY" topic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CETL's variable_length_array already provides max_size for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it does, but under c++17 and above we use std::vector
(with PMR allocator of course)
{% endif -%} | ||
{%- assert composite_type.extent % 8 == 0 %} | ||
{% endif %} | ||
static constexpr const char* FullNameAndVersion() { return "{{ composite_type }}"; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can by adding constexpr char {{composite_type|short_reference_name}}::FullNameAndVersion[];
after the class.
Le(regulated::basics::Struct__0_1::_traits_::SerializationBufferSizeBytes * 8U)); | ||
EXPECT_TRUE(regulated::basics::Struct__0_1::CONSTANT_TRUTH); | ||
|
||
// TODO: Uncomment when some form of "ARRAY_CAPACITY" is generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CETL's variable_length_array already provides max_size for this?
Needed for libcyphal's subscriber implementation (see issue # 380)
support/serialization.hpp
should#include <cassert>
#348 - added#include <cassert>
fornunavut/support/serialization.hpp
file generation