Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ nunavut_out
.hypothesis

.ropeproject

#clangd
.cache
8 changes: 8 additions & 0 deletions src/nunavut/lang/cpp/templates/ServiceType.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@ struct {{service_name}}
struct _traits_
{
_traits_() = delete;
{%- if T.has_fixed_port_id %}
static constexpr bool HasFixedPortID = true;
static constexpr {{ typename_unsigned_port }} FixedPortId = {{ T.fixed_port_id }}U;
{%- else %}
static constexpr bool HasFixedPortID = false;
{%- endif %}

static constexpr bool IsServiceType = true;
static constexpr bool IsService = true;
static constexpr bool IsRequest = false;
static constexpr bool IsResponse = false;

static constexpr const char* FullNameAndVersion() { return "{{ T }}"; }
};
};

Expand Down
6 changes: 6 additions & 0 deletions verification/cpp/suite/test_constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const bool regulated::basics::Service::Response_0_1::_traits_::IsResponse;
const bool regulated::basics::Service::Response_0_1::_traits_::IsServiceType;
const bool regulated::basics::Service_0_1::_traits_::IsService;
const bool regulated::basics::Service_0_1::_traits_::IsServiceType;
const bool regulated::basics::Service_0_1::_traits_::HasFixedPortID;
const std::uint16_t regulated::basics::Service_0_1::_traits_::FixedPortId;

const std::size_t regulated::basics::Struct__0_1::_traits_::ArrayCapacity::i10_4;
const std::size_t regulated::basics::Struct__0_1::_traits_::ArrayCapacity::f16_le2;
Expand Down Expand Up @@ -101,6 +103,10 @@ TEST(ConstantTests, Service)
// Type parameters.
EXPECT_TRUE(regulated::basics::Service_0_1::_traits_::IsService);
EXPECT_TRUE(regulated::basics::Service_0_1::_traits_::IsServiceType);
EXPECT_TRUE(regulated::basics::Service_0_1::_traits_::HasFixedPortID);
EXPECT_THAT(regulated::basics::Service_0_1::_traits_::FixedPortId, 300);
EXPECT_THAT(regulated::basics::Service_0_1::_traits_::FullNameAndVersion(),
StrEq("regulated.basics.Service.0.1"));

EXPECT_FALSE(regulated::basics::Service::Request_0_1::_traits_::IsService);
EXPECT_TRUE(regulated::basics::Service::Request_0_1::_traits_::IsServiceType);
Expand Down
4 changes: 4 additions & 0 deletions verification/cpp/suite/test_serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ static_assert(
regulated::basics::Service_0_1::_traits_::IsServiceType,
"Service is a service type");

static_assert(
regulated::basics::Service_0_1::_traits_::HasFixedPortID,
"Service has a fixed port ID");

static_assert(
not regulated::basics::Service_0_1::Request::_traits_::IsService,
"Request is not a service");
Expand Down
Loading