blob: 9e35b70627fad743c29104e5bd19b1b9b35ee209 [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
#pragma once
#include <fidl/test.consts/cpp/common_types.h>
#include <fidl/test.consts/cpp/markers.h>
#include <lib/fidl/cpp/natural_coding_traits.h>
#include <lib/fidl/cpp/natural_types.h>
#include <cinttypes>
#include <string>
#ifdef __Fuchsia__
#endif // __Fuchsia__
namespace test_consts {
constexpr zx_rights_t kZxRightsVal = ZX_RIGHT_READ;
constexpr zx_obj_type_t kZxObjVal = ZX_OBJ_TYPE_CHANNEL;
constexpr uint64_t kZxConst = ZX_CHANNEL_MAX_MSG_BYTES;
extern const char* kUsername;
constexpr uint32_t kPopulationUsa2018 = 330000000u;
constexpr int8_t kOffset = -33;
constexpr float kMinTemp = -273.15f;
constexpr uint64_t kFuchsia = 4054509061583223046u;
constexpr ::test_consts::EnumType kEnumVal = ::test_consts::EnumType::kValue;
constexpr ::test_consts::EnumType kEnumTrue = ::test_consts::EnumType::kTrue;
constexpr int32_t kEnumPrimitiveVal = ::test_consts::EnumType::kValue;
constexpr int32_t kEnumPrimitiveTrue = ::test_consts::EnumType::kTrue;
constexpr bool kEnabledFlag = true;
constexpr uint64_t kDiamond = 1746410393481133080u;
constexpr double kConversionFactor = 1.41421;
constexpr ::test_consts::BitsType kBitsVal = ::test_consts::BitsType::kValue;
constexpr ::test_consts::BitsType kBitsTrue = ::test_consts::BitsType::kTrue;
constexpr uint32_t kBitsPrimitiveVal = ::test_consts::BitsType::kValue;
constexpr uint32_t kBitsPrimitiveTrue = ::test_consts::BitsType::kTrue;
constexpr uint16_t kAnswerInBinary = 42u;
constexpr uint16_t kAnswer = 42u;
} // namespace test_consts
namespace fidl {
template <>
struct internal::NaturalCodingTraits<
::test_consts::BitsType, ::fidl::internal::NaturalCodingConstraintEmpty> {
static constexpr size_t inline_size_v2 = sizeof(uint32_t);
static constexpr bool is_memcpy_compatible = false;
static void Encode(internal::NaturalEncoder* encoder,
::test_consts::BitsType* value, size_t offset,
size_t recursion_depth) {
if (static_cast<uint32_t>(*value) & ~3ull) {
encoder->SetError(::fidl::internal::kCodingErrorUnknownBitSetInBitsValue);
}
*encoder->template GetPtr<::test_consts::BitsType>(offset) = *value;
}
static void Decode(internal::NaturalDecoder* decoder,
::test_consts::BitsType* value, size_t offset,
size_t recursion_depth) {
*value = *decoder->template GetPtr<::test_consts::BitsType>(offset);
if (static_cast<uint32_t>(*value) & ~3ull) {
decoder->SetError(::fidl::internal::kCodingErrorUnknownBitSetInBitsValue);
}
}
};
template <>
struct internal::NaturalCodingTraits<
::test_consts::EnumType, ::fidl::internal::NaturalCodingConstraintEmpty> {
static constexpr size_t inline_size_v2 = sizeof(int32_t);
static constexpr bool is_memcpy_compatible = false;
static void Encode(internal::NaturalEncoder* encoder,
::test_consts::EnumType* value, size_t offset,
size_t recursion_depth) {
switch (*value) {
case ::test_consts::EnumType::kValue:
case ::test_consts::EnumType::kTrue:
break;
default:
encoder->SetError(::fidl::internal::kCodingErrorUnknownEnumValue);
return;
}
*encoder->template GetPtr<::test_consts::EnumType>(offset) = *value;
}
static void Decode(internal::NaturalDecoder* decoder,
::test_consts::EnumType* value, size_t offset,
size_t recursion_depth) {
*value = *decoder->template GetPtr<::test_consts::EnumType>(offset);
switch (*value) {
case ::test_consts::EnumType::kValue:
case ::test_consts::EnumType::kTrue:
break;
default:
decoder->SetError(::fidl::internal::kCodingErrorUnknownEnumValue);
return;
}
}
};
} // namespace fidl