| // WARNING: This file is machine generated by fidlgen. |
| |
| #pragma once |
| |
| #include <lib/fidl/llcpp/array.h> |
| #include <lib/fidl/llcpp/envelope.h> |
| #include <lib/fidl/llcpp/message.h> |
| #include <lib/fidl/llcpp/message_storage.h> |
| #include <lib/fidl/llcpp/object_view.h> |
| #include <lib/fidl/llcpp/string_view.h> |
| #include <lib/fidl/llcpp/traits.h> |
| #include <lib/fidl/llcpp/wire_types.h> |
| #include <lib/stdcompat/optional.h> |
| |
| #include <cinttypes> |
| #ifdef __Fuchsia__ |
| #include <lib/zx/channel.h> |
| |
| #endif // __Fuchsia__ |
| |
| #include <fidl/test.exampleusing/cpp/wire_types.h> |
| #include <fidl/test.placementofattributes/cpp/common_types.h> |
| #include <fidl/test.placementofattributes/cpp/markers.h> |
| |
| namespace test_placementofattributes { |
| |
| namespace wire { |
| using ExampleBits = ::test_placementofattributes::ExampleBits; |
| |
| using ExampleEnum = ::test_placementofattributes::ExampleEnum; |
| |
| struct ExampleStruct; |
| |
| struct ExampleProtocolMethodRequest; |
| |
| class ExampleTable; |
| |
| class ExampleXUnion; |
| |
| class ExampleUnion; |
| |
| extern "C" const fidl_type_t test_placementofattributes_ExampleStructTable; |
| |
| struct ExampleStruct { |
| uint32_t member = {}; |
| }; |
| |
| extern "C" const fidl_type_t test_placementofattributes_ExampleProtocolMethodRequestTable; |
| |
| struct ExampleProtocolMethodRequest { |
| ::test_exampleusing::wire::Empty arg = {}; |
| }; |
| |
| } // namespace wire |
| } // namespace test_placementofattributes |
| template <> |
| class ::fidl::WireTableBuilder<::test_placementofattributes::wire::ExampleTable>; |
| template <> |
| class ::fidl::WireTableExternalBuilder<::test_placementofattributes::wire::ExampleTable>; |
| |
| template <> |
| struct ::fidl::WireTableFrame<::test_placementofattributes::wire::ExampleTable> final { |
| public: |
| WireTableFrame() = default; |
| // In its intended usage, WireTableFrame will be referenced by an ObjectView. |
| // If the ObjectView is assigned before a move or copy, then it will reference |
| // the old invalid object. Because this is unsafe, copies are disallowed and |
| // moves are only allowed by friend classes that operate safely. |
| WireTableFrame(const WireTableFrame&) = delete; |
| WireTableFrame& operator=(const WireTableFrame&) = delete; |
| |
| private: |
| WireTableFrame(WireTableFrame&&) noexcept = default; |
| WireTableFrame& operator=(WireTableFrame&&) noexcept = default; |
| |
| bool HasUnknownData() const; |
| ::fidl::Envelope<uint32_t> member_; |
| |
| friend class ::test_placementofattributes::wire::ExampleTable; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_placementofattributes::wire::ExampleTable, ::fidl::WireTableBuilder<::test_placementofattributes::wire::ExampleTable>>; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_placementofattributes::wire::ExampleTable, ::fidl::WireTableExternalBuilder<::test_placementofattributes::wire::ExampleTable>>; |
| }; |
| |
| namespace test_placementofattributes { |
| namespace wire { |
| extern "C" const fidl_type_t test_placementofattributes_ExampleTableTable; |
| |
| class ExampleTable { |
| public: |
| ExampleTable() = default; |
| ExampleTable(const ExampleTable& other) noexcept = default; |
| ExampleTable& operator=(const ExampleTable& other) noexcept = default; |
| ExampleTable(ExampleTable&& other) noexcept = default; |
| ExampleTable& operator=(ExampleTable&& other) noexcept = default; |
| |
| ~ExampleTable() = default; |
| |
| // Returns whether no field is set. |
| bool IsEmpty() const { return max_ordinal_ == 0; } |
| |
| // Returns whether the table references unknown fields. |
| bool HasUnknownData() const; |
| |
| // Return a builder that by defaults allocates of an arena. |
| static ::fidl::WireTableBuilder<::test_placementofattributes::wire::ExampleTable> Builder(::fidl::AnyArena& arena); |
| |
| // Return a builder that relies on explicitly allocating |fidl::ObjectView|s. |
| static ::fidl::WireTableExternalBuilder<::test_placementofattributes::wire::ExampleTable> ExternalBuilder(::fidl::ObjectView<::fidl::WireTableFrame<::test_placementofattributes::wire::ExampleTable>> frame); |
| |
| const uint32_t& member() const { |
| ZX_ASSERT(has_member()); |
| return frame_ptr_->member_.get_data(); |
| } |
| uint32_t& member() { |
| ZX_ASSERT(has_member()); |
| return frame_ptr_->member_.get_data(); |
| } |
| bool has_member() const { |
| return max_ordinal_ >= 1 && frame_ptr_->member_.has_data(); |
| } |
| #if defined(FIDL_WIRE_ALLOW_DEPRECATED_MUTABLE_TABLES) || false |
| public: |
| #else // !defined(FIDL_WIRE_ALLOW_DEPRECATED_MUTABLE_TABLES) |
| private: |
| #endif // FIDL_WIRE_ALLOW_DEPRECATED_MUTABLE_TABLES |
| |
| ExampleTable& set_member(uint32_t elem) { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->member_.set_data(std::move(elem)); |
| max_ordinal_ = std::max(max_ordinal_, static_cast<uint64_t>(1)); |
| return *this; |
| } |
| |
| ExampleTable& clear_member() { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->member_.clear_data(); |
| return *this; |
| } |
| |
| explicit ExampleTable(::fidl::AnyArena& allocator) |
| : frame_ptr_(::fidl::ObjectView<::fidl::WireTableFrame<::test_placementofattributes::wire::ExampleTable>>(allocator)) {} |
| // This constructor allows a user controlled allocation (not using a Arena). |
| // It should only be used when performance is key. |
| // As soon as the frame is given to the table, it must not be used directly or for another table. |
| explicit ExampleTable(::fidl::ObjectView<::fidl::WireTableFrame<::test_placementofattributes::wire::ExampleTable>>&& frame) |
| : frame_ptr_(std::move(frame)) {} |
| |
| void Allocate(::fidl::AnyArena& allocator) { |
| max_ordinal_ = 0; |
| frame_ptr_ = ::fidl::ObjectView<::fidl::WireTableFrame<::test_placementofattributes::wire::ExampleTable>>(allocator); |
| } |
| void Init(::fidl::ObjectView<::fidl::WireTableFrame<::test_placementofattributes::wire::ExampleTable>>&& frame_ptr) { |
| max_ordinal_ = 0; |
| frame_ptr_ = std::move(frame_ptr); |
| } |
| |
| private: |
| friend ::fidl::internal::WireTableBaseBuilder<::test_placementofattributes::wire::ExampleTable, ::fidl::WireTableBuilder<::test_placementofattributes::wire::ExampleTable>>; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_placementofattributes::wire::ExampleTable, ::fidl::WireTableExternalBuilder<::test_placementofattributes::wire::ExampleTable>>; |
| |
| uint64_t max_ordinal_ = 0; |
| ::fidl::ObjectView<::fidl::WireTableFrame<::test_placementofattributes::wire::ExampleTable>> frame_ptr_; |
| }; |
| } // namespace wire |
| } // namespace test_placementofattributes |
| template <typename BuilderImpl> |
| class ::fidl::internal::WireTableBaseBuilder<::test_placementofattributes::wire::ExampleTable, BuilderImpl> { |
| public: |
| // Build and return the table. The builder should not be used after this. |
| ::test_placementofattributes::wire::ExampleTable Build() { |
| ZX_DEBUG_ASSERT(table_.frame_ptr_ != nullptr); |
| ::test_placementofattributes::wire::ExampleTable t = std::move(table_); |
| // Poison this builder to prevent accidental reuse. |
| table_.frame_ptr_ = nullptr; |
| return t; |
| } |
| |
| BuilderImpl& member(uint32_t elem) { |
| ZX_DEBUG_ASSERT(table_.frame_ptr_ != nullptr); |
| table_.frame_ptr_->member_.set_data(std::move(elem)); |
| table_.max_ordinal_ = std::max(table_.max_ordinal_, static_cast<uint64_t>(1)); |
| return *static_cast<BuilderImpl*>(this); |
| } |
| |
| protected: |
| WireTableBaseBuilder(::fidl::ObjectView<::fidl::WireTableFrame<::test_placementofattributes::wire::ExampleTable>>&& frame) |
| : table_(std::move(frame)) {} |
| |
| private: |
| ::test_placementofattributes::wire::ExampleTable table_; |
| }; |
| |
| template <> |
| class ::fidl::WireTableBuilder<::test_placementofattributes::wire::ExampleTable> final : public ::fidl::internal::WireTableBaseBuilder<::test_placementofattributes::wire::ExampleTable, ::fidl::WireTableBuilder<::test_placementofattributes::wire::ExampleTable>> { |
| using Base = ::fidl::internal::WireTableBaseBuilder<::test_placementofattributes::wire::ExampleTable, ::fidl::WireTableBuilder<::test_placementofattributes::wire::ExampleTable>>; |
| |
| public: |
| private: |
| friend class ::test_placementofattributes::wire::ExampleTable; |
| WireTableBuilder(::fidl::AnyArena& arena) |
| : Base(::fidl::ObjectView<::fidl::WireTableFrame<::test_placementofattributes::wire::ExampleTable>>(arena)), |
| arena_(arena) {} |
| |
| [[maybe_unused]] std::reference_wrapper<::fidl::AnyArena> arena_; |
| }; |
| |
| template <> |
| class ::fidl::WireTableExternalBuilder<::test_placementofattributes::wire::ExampleTable> final : public ::fidl::internal::WireTableBaseBuilder<::test_placementofattributes::wire::ExampleTable, ::fidl::WireTableExternalBuilder<::test_placementofattributes::wire::ExampleTable>> { |
| using Base = ::fidl::internal::WireTableBaseBuilder<::test_placementofattributes::wire::ExampleTable, ::fidl::WireTableExternalBuilder<::test_placementofattributes::wire::ExampleTable>>; |
| |
| private: |
| friend class ::test_placementofattributes::wire::ExampleTable; |
| using Base::Base; |
| WireTableExternalBuilder(::fidl::WireTableFrame<::test_placementofattributes::wire::ExampleTable>* frame) |
| : Base(::fidl::ObjectView<::fidl::WireTableFrame<::test_placementofattributes::wire::ExampleTable>>::FromExternal(frame)) {} |
| }; |
| namespace test_placementofattributes { |
| namespace wire { |
| inline ::fidl::WireTableBuilder<::test_placementofattributes::wire::ExampleTable> ExampleTable::Builder(::fidl::AnyArena& arena) { |
| return ::fidl::WireTableBuilder<::test_placementofattributes::wire::ExampleTable>(arena); |
| } |
| inline ::fidl::WireTableExternalBuilder<::test_placementofattributes::wire::ExampleTable> ExampleTable::ExternalBuilder(::fidl::ObjectView<::fidl::WireTableFrame<::test_placementofattributes::wire::ExampleTable>> frame) { |
| return ::fidl::WireTableExternalBuilder<::test_placementofattributes::wire::ExampleTable>(std::move(frame)); |
| } |
| |
| extern "C" const fidl_type_t test_placementofattributes_ExampleXUnionTable; |
| |
| class ExampleXUnion { |
| public: |
| ExampleXUnion() : ordinal_(::test_placementofattributes::wire::ExampleXUnion::Ordinal::Invalid), envelope_{} {} |
| |
| ExampleXUnion(const ExampleXUnion&) = default; |
| ExampleXUnion& operator=(const ExampleXUnion&) = default; |
| ExampleXUnion(ExampleXUnion&&) = default; |
| ExampleXUnion& operator=(ExampleXUnion&&) = default; |
| |
| enum class Tag : fidl_xunion_tag_t { |
| kVariant = 1, // 0x1 |
| kUnknown = ::std::numeric_limits<::fidl_union_tag_t>::max(), |
| }; |
| |
| bool has_invalid_tag() const { return ordinal_ == ::test_placementofattributes::wire::ExampleXUnion::Ordinal::Invalid; } |
| |
| bool is_variant() const { return ordinal_ == ::test_placementofattributes::wire::ExampleXUnion::Ordinal::kVariant; } |
| |
| static ExampleXUnion WithVariant(uint32_t val) { |
| ExampleXUnion result; |
| result.ordinal_ = ::test_placementofattributes::wire::ExampleXUnion::Ordinal::kVariant; |
| result.envelope_.As<uint32_t>().set_data(std::move(val)); |
| return result; |
| } |
| |
| uint32_t& variant() { |
| ZX_ASSERT(ordinal_ == ::test_placementofattributes::wire::ExampleXUnion::Ordinal::kVariant); |
| return envelope_.As<uint32_t>().get_data(); |
| } |
| const uint32_t& variant() const { |
| ZX_ASSERT(ordinal_ == ::test_placementofattributes::wire::ExampleXUnion::Ordinal::kVariant); |
| return envelope_.As<uint32_t>().get_data(); |
| } |
| ::test_placementofattributes::wire::ExampleXUnion::Tag Which() const; |
| |
| private: |
| enum class Ordinal : fidl_xunion_tag_t { |
| Invalid = 0, |
| kVariant = 1, // 0x1 |
| }; |
| |
| static void SizeAndOffsetAssertionHelper(); |
| ::test_placementofattributes::wire::ExampleXUnion::Ordinal ordinal_; |
| FIDL_ALIGNDECL |
| ::fidl::UntypedEnvelope envelope_; |
| }; |
| |
| extern "C" const fidl_type_t test_placementofattributes_ExampleUnionTable; |
| |
| class ExampleUnion { |
| public: |
| ExampleUnion() : ordinal_(::test_placementofattributes::wire::ExampleUnion::Ordinal::Invalid), envelope_{} {} |
| |
| ExampleUnion(const ExampleUnion&) = default; |
| ExampleUnion& operator=(const ExampleUnion&) = default; |
| ExampleUnion(ExampleUnion&&) = default; |
| ExampleUnion& operator=(ExampleUnion&&) = default; |
| |
| enum class Tag : fidl_xunion_tag_t { |
| kVariant = 1, // 0x1 |
| }; |
| |
| bool has_invalid_tag() const { return ordinal_ == ::test_placementofattributes::wire::ExampleUnion::Ordinal::Invalid; } |
| |
| bool is_variant() const { return ordinal_ == ::test_placementofattributes::wire::ExampleUnion::Ordinal::kVariant; } |
| |
| static ExampleUnion WithVariant(uint32_t val) { |
| ExampleUnion result; |
| result.ordinal_ = ::test_placementofattributes::wire::ExampleUnion::Ordinal::kVariant; |
| result.envelope_.As<uint32_t>().set_data(std::move(val)); |
| return result; |
| } |
| |
| uint32_t& variant() { |
| ZX_ASSERT(ordinal_ == ::test_placementofattributes::wire::ExampleUnion::Ordinal::kVariant); |
| return envelope_.As<uint32_t>().get_data(); |
| } |
| const uint32_t& variant() const { |
| ZX_ASSERT(ordinal_ == ::test_placementofattributes::wire::ExampleUnion::Ordinal::kVariant); |
| return envelope_.As<uint32_t>().get_data(); |
| } |
| ::test_placementofattributes::wire::ExampleUnion::Tag Which() const { |
| ZX_ASSERT(!has_invalid_tag()); |
| return static_cast<::test_placementofattributes::wire::ExampleUnion::Tag>(ordinal_); |
| } |
| |
| private: |
| enum class Ordinal : fidl_xunion_tag_t { |
| Invalid = 0, |
| kVariant = 1, // 0x1 |
| }; |
| |
| static void SizeAndOffsetAssertionHelper(); |
| ::test_placementofattributes::wire::ExampleUnion::Ordinal ordinal_; |
| FIDL_ALIGNDECL |
| ::fidl::UntypedEnvelope envelope_; |
| }; |
| |
| constexpr uint32_t kExampleConst = 0u; |
| |
| } // namespace wire |
| } // namespace test_placementofattributes |
| namespace fidl { |
| |
| template <bool IsRecursive> |
| struct internal::WireCodingTraits<::test_placementofattributes::wire::ExampleBits, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> { |
| static constexpr size_t inline_size = sizeof(uint32_t); |
| static constexpr bool is_memcpy_compatible = false; |
| |
| static void Encode(internal::WireEncoder* encoder, ::test_placementofattributes::wire::ExampleBits* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| if (unlikely(static_cast<uint32_t>(*value) & ~1ull)) { |
| encoder->SetError(::fidl::internal::kCodingErrorUnknownBitSetInBitsValue); |
| } |
| *position.As<::test_placementofattributes::wire::ExampleBits>() = *value; |
| } |
| static void Decode(internal::WireDecoder* decoder, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| ::test_placementofattributes::wire::ExampleBits value = *position.As<::test_placementofattributes::wire::ExampleBits>(); |
| if (unlikely(static_cast<uint32_t>(value) & ~1ull)) { |
| decoder->SetError(::fidl::internal::kCodingErrorUnknownBitSetInBitsValue); |
| } |
| } |
| }; |
| |
| template <bool IsRecursive> |
| struct internal::WireCodingTraits<::test_placementofattributes::wire::ExampleEnum, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> { |
| static constexpr size_t inline_size = sizeof(uint32_t); |
| static constexpr bool is_memcpy_compatible = false; |
| |
| static void Encode(internal::WireEncoder* encoder, ::test_placementofattributes::wire::ExampleEnum* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| switch (*value) { |
| case ::test_placementofattributes::wire::ExampleEnum::kMember: |
| break; |
| default: |
| encoder->SetError(::fidl::internal::kCodingErrorUnknownEnumValue); |
| return; |
| } |
| *position.As<::test_placementofattributes::wire::ExampleEnum>() = *value; |
| } |
| static void Decode(internal::WireDecoder* decoder, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| [[maybe_unused]] ::test_placementofattributes::wire::ExampleEnum value = *position.As<::test_placementofattributes::wire::ExampleEnum>(); |
| switch (value) { |
| case ::test_placementofattributes::wire::ExampleEnum::kMember: |
| break; |
| default: |
| decoder->SetError(::fidl::internal::kCodingErrorUnknownEnumValue); |
| return; |
| } |
| } |
| }; |
| |
| // TODO(fxbug.dev/95833) Remove this. |
| template <> |
| struct DeprecatedCTypeTraits<::test_placementofattributes::wire::ExampleStruct> { |
| static constexpr const fidl_type_t* kType = &::test_placementofattributes::wire::test_placementofattributes_ExampleStructTable; |
| }; |
| |
| template <> |
| struct TypeTraits<::test_placementofattributes::wire::ExampleStruct> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 0; |
| static constexpr uint32_t kPrimarySize = 4; |
| static constexpr uint32_t kPrimarySizeV1 = 4; |
| [[maybe_unused]] static constexpr uint32_t kMaxOutOfLine = 0; |
| static constexpr uint32_t kMaxOutOfLineV1 = 0; |
| static constexpr bool kHasEnvelope = false; |
| static constexpr bool kHasPointer = false; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_placementofattributes::wire::ExampleStruct> : public std::true_type {}; |
| template <> |
| struct IsStruct<::test_placementofattributes::wire::ExampleStruct> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_placementofattributes::wire::ExampleStruct>); |
| static_assert(offsetof(::test_placementofattributes::wire::ExampleStruct, member) == 0); |
| static_assert(sizeof(::test_placementofattributes::wire::ExampleStruct) == TypeTraits<::test_placementofattributes::wire::ExampleStruct>::kPrimarySize); |
| |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_placementofattributes::wire::ExampleStruct, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> { |
| static constexpr size_t inline_size = 4; |
| static constexpr auto kMembers = std::make_tuple(::fidl::internal::WireStructMemberCodingInfo<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>()); |
| static constexpr bool kHasPadding = false; |
| using Base = WireStructCodingTraitsBase<::test_placementofattributes::wire::ExampleStruct, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive>; |
| static constexpr bool is_memcpy_compatible = Base::is_memcpy_compatible; |
| |
| static void Encode( |
| internal::WireEncoder* encoder, ::test_placementofattributes::wire::ExampleStruct* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| if constexpr (is_memcpy_compatible) { |
| memcpy(position.As<void>(), value, sizeof(::test_placementofattributes::wire::ExampleStruct)); |
| } else { |
| internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::Encode(encoder, &value->member, position + 0, recursion_depth); |
| } |
| } |
| static void Decode( |
| internal::WireDecoder* decoder, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| if constexpr (!Base::are_members_memcpy_compatible) { |
| internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::Decode( |
| decoder, position + 0, recursion_depth); |
| } |
| } |
| }; |
| |
| // TODO(fxbug.dev/95833) Remove this. |
| template <> |
| struct DeprecatedCTypeTraits<::test_placementofattributes::wire::ExampleProtocolMethodRequest> { |
| static constexpr const fidl_type_t* kType = &::test_placementofattributes::wire::test_placementofattributes_ExampleProtocolMethodRequestTable; |
| }; |
| |
| template <> |
| struct TypeTraits<::test_placementofattributes::wire::ExampleProtocolMethodRequest> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 0; |
| static constexpr uint32_t kPrimarySize = 1; |
| static constexpr uint32_t kPrimarySizeV1 = 1; |
| [[maybe_unused]] static constexpr uint32_t kMaxOutOfLine = 0; |
| static constexpr uint32_t kMaxOutOfLineV1 = 0; |
| static constexpr bool kHasEnvelope = false; |
| static constexpr bool kHasPointer = false; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_placementofattributes::wire::ExampleProtocolMethodRequest> : public std::true_type {}; |
| template <> |
| struct IsStruct<::test_placementofattributes::wire::ExampleProtocolMethodRequest> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_placementofattributes::wire::ExampleProtocolMethodRequest>); |
| static_assert(offsetof(::test_placementofattributes::wire::ExampleProtocolMethodRequest, arg) == 0); |
| static_assert(sizeof(::test_placementofattributes::wire::ExampleProtocolMethodRequest) == TypeTraits<::test_placementofattributes::wire::ExampleProtocolMethodRequest>::kPrimarySize); |
| |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_placementofattributes::wire::ExampleProtocolMethodRequest, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> { |
| static constexpr size_t inline_size = 1; |
| static constexpr auto kMembers = std::make_tuple(::fidl::internal::WireStructMemberCodingInfo<::test_exampleusing::wire::Empty, fidl::internal::WireCodingConstraintEmpty, IsRecursive>()); |
| static constexpr bool kHasPadding = false; |
| using Base = WireStructCodingTraitsBase<::test_placementofattributes::wire::ExampleProtocolMethodRequest, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive>; |
| static constexpr bool is_memcpy_compatible = Base::is_memcpy_compatible; |
| |
| static void Encode( |
| internal::WireEncoder* encoder, ::test_placementofattributes::wire::ExampleProtocolMethodRequest* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| if constexpr (is_memcpy_compatible) { |
| memcpy(position.As<void>(), value, sizeof(::test_placementofattributes::wire::ExampleProtocolMethodRequest)); |
| } else { |
| internal::WireCodingTraits<::test_exampleusing::wire::Empty, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::Encode(encoder, &value->arg, position + 0, recursion_depth); |
| } |
| } |
| static void Decode( |
| internal::WireDecoder* decoder, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| if constexpr (!Base::are_members_memcpy_compatible) { |
| internal::WireCodingTraits<::test_exampleusing::wire::Empty, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::Decode( |
| decoder, position + 0, recursion_depth); |
| } |
| } |
| }; |
| |
| template <> |
| struct TypeTraits<::test_placementofattributes::wire::ExampleTable> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 2; |
| static constexpr uint32_t kPrimarySize = 16; |
| static constexpr uint32_t kPrimarySizeV1 = 16; |
| [[maybe_unused]] static constexpr uint32_t kMaxOutOfLine = 8; |
| static constexpr uint32_t kMaxOutOfLineV1 = 24; |
| static constexpr bool kHasEnvelope = true; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_placementofattributes::wire::ExampleTable> : public std::true_type {}; |
| template <> |
| struct IsTable<::test_placementofattributes::wire::ExampleTable> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_placementofattributes::wire::ExampleTable>); |
| |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_placementofattributes::wire::ExampleTable, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> |
| : ::fidl::internal::WireTableCodingTraitsBase<IsRecursive> { |
| using Base = ::fidl::internal::WireTableCodingTraitsBase<IsRecursive>; |
| static constexpr size_t inline_size = 16; |
| static constexpr bool is_memcpy_compatible = false; |
| |
| static void Encode(internal::WireEncoder* encoder, ::test_placementofattributes::wire::ExampleTable* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| RecursionDepth<IsRecursive> inner_depth = recursion_depth.Add(encoder, 2); |
| if (!inner_depth.IsValid()) { |
| return; |
| } |
| |
| ::fidl::internal::WirePosition vector_position; |
| if (Base::PreworkResult::kEarlyExit == |
| Base::PrepareForBodyEncode(encoder, value, position, &vector_position)) { |
| return; |
| } |
| |
| fidl_vector_t* vec = reinterpret_cast<fidl_vector_t*>(value); |
| fidl_envelope_v2_t* envelopes = static_cast<fidl_envelope_v2_t*>(vec->data); |
| for (size_t i = 0; i < vec->count; i++) { |
| size_t inline_size = 0; |
| switch (i) { |
| case 0: |
| inline_size = ::fidl::internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::inline_size; |
| break; |
| } |
| ::fidl::internal::EncodeFn<IsRecursive> encode_fn = nullptr; |
| switch (i) { |
| case 0: |
| encode_fn = ::fidl::internal::MakeEncodeFn<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>(); |
| break; |
| } |
| WirePosition envelope_position = vector_position + i * sizeof(fidl_envelope_v2_t); |
| WireEncodeEnvelope(inline_size, encode_fn, encoder, &envelopes[i], envelope_position, inner_depth); |
| } |
| } |
| static void Decode(internal::WireDecoder* decoder, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| RecursionDepth<IsRecursive> inner_depth = recursion_depth.Add(decoder, 2); |
| if (!inner_depth.IsValid()) { |
| return; |
| } |
| |
| ::fidl::internal::WirePosition vector_position; |
| if (Base::PreworkResult::kEarlyExit == Base::DecodePrework(decoder, position, &vector_position)) { |
| return; |
| } |
| |
| fidl_vector_t* vec = position.As<fidl_vector_t>(); |
| for (size_t i = 0; i < vec->count; i++) { |
| size_t inline_size = 0; |
| switch (i) { |
| case 0: |
| inline_size = ::fidl::internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::inline_size; |
| break; |
| } |
| DecodeFn<IsRecursive> decode_fn = nullptr; |
| switch (i) { |
| case 0: |
| decode_fn = ::fidl::internal::MakeDecodeFn<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>(); |
| break; |
| } |
| ::fidl::internal::WireDecodeOptionalEnvelope(inline_size, decode_fn, decoder, vector_position + i * sizeof(fidl_envelope_v2_t), inner_depth); |
| } |
| } |
| }; |
| |
| template <> |
| struct TypeTraits<::test_placementofattributes::wire::ExampleXUnion> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 1; |
| static constexpr uint32_t kPrimarySize = 16; |
| static constexpr uint32_t kPrimarySizeV1 = 24; |
| [[maybe_unused]] static constexpr uint32_t kMaxOutOfLine = 0; |
| static constexpr uint32_t kMaxOutOfLineV1 = 8; |
| static constexpr bool kHasEnvelope = true; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_placementofattributes::wire::ExampleXUnion> : public std::true_type {}; |
| template <> |
| struct IsUnion<::test_placementofattributes::wire::ExampleXUnion> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_placementofattributes::wire::ExampleXUnion>); |
| |
| template <typename Constraint, bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_placementofattributes::wire::ExampleXUnion, Constraint, IsRecursive> { |
| static constexpr size_t inline_size = 16; |
| static constexpr bool is_memcpy_compatible = false; |
| |
| static void Encode(internal::WireEncoder* encoder, ::test_placementofattributes::wire::ExampleXUnion* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| fidl_xunion_v2_t* u = reinterpret_cast<fidl_xunion_v2_t*>(value); |
| |
| if (unlikely(u->tag == 0)) { |
| if constexpr (Constraint::is_optional) { |
| *position.As<fidl_xunion_v2_t>() = {}; |
| return; |
| } |
| encoder->SetError(kCodingErrorInvalidUnionTag); |
| return; |
| } |
| |
| RecursionDepth<IsRecursive> inner_depth = recursion_depth.Add(encoder, 1); |
| if (!inner_depth.IsValid()) { |
| return; |
| } |
| |
| *position.As<fidl_xunion_tag_t>() = u->tag; |
| |
| size_t inline_size; |
| switch (u->tag) { |
| case 1: // ::test_placementofattributes::wire::ExampleXUnion::Tag::kVariant |
| inline_size = ::fidl::internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::inline_size; |
| break; |
| default: |
| inline_size = 0; |
| break; |
| } |
| ::fidl::internal::EncodeFn<IsRecursive> encode_fn; |
| switch (u->tag) { |
| case 1: // ::test_placementofattributes::wire::ExampleXUnion::Tag::kVariant |
| encode_fn = ::fidl::internal::MakeEncodeFn<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>(); |
| break; |
| default: |
| encode_fn = nullptr; |
| break; |
| } |
| WireEncodeEnvelope(inline_size, encode_fn, encoder, &u->envelope, position + sizeof(fidl_xunion_tag_t), inner_depth); |
| } |
| |
| static void Decode(internal::WireDecoder* decoder, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| ::test_placementofattributes::wire::ExampleXUnion::Tag tag = *position.As<::test_placementofattributes::wire::ExampleXUnion::Tag>(); |
| if (unlikely(static_cast<uint64_t>(tag) == 0)) { |
| if constexpr (!Constraint::is_optional) { |
| decoder->SetError(kCodingErrorInvalidUnionTag); |
| return; |
| } |
| static_assert(sizeof(fidl_envelope_v2_t) == sizeof(uint64_t)); |
| if (*(position + sizeof(fidl_xunion_tag_t)).As<uint64_t>() != 0) { |
| decoder->SetError(kCodingErrorZeroTagButNonZeroEnvelope); |
| } |
| return; |
| } |
| |
| RecursionDepth<IsRecursive> inner_depth = recursion_depth.Add(decoder, 1); |
| if (!inner_depth.IsValid()) { |
| return; |
| } |
| |
| size_t inline_size; |
| switch (tag) { |
| case ::test_placementofattributes::wire::ExampleXUnion::Tag::kVariant: |
| inline_size = ::fidl::internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::inline_size; |
| break; |
| default: |
| inline_size = 0; |
| break; |
| } |
| DecodeFn<IsRecursive> decode_fn; |
| switch (tag) { |
| case ::test_placementofattributes::wire::ExampleXUnion::Tag::kVariant: |
| decode_fn = ::fidl::internal::MakeDecodeFn<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>(); |
| break; |
| default: |
| decode_fn = nullptr; |
| break; |
| } |
| ::fidl::internal::WireDecodeFlexibleEnvelope(inline_size, decode_fn, decoder, position + sizeof(fidl_xunion_tag_t), inner_depth); |
| } |
| }; |
| |
| // Top-level union. |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_placementofattributes::wire::ExampleXUnion, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> |
| : public ::fidl::internal::WireCodingTraits<::test_placementofattributes::wire::ExampleXUnion, ::fidl::internal::WireCodingConstraintUnion<false>, IsRecursive> {}; |
| |
| template <> |
| struct TypeTraits<::test_placementofattributes::wire::ExampleUnion> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 1; |
| static constexpr uint32_t kPrimarySize = 16; |
| static constexpr uint32_t kPrimarySizeV1 = 24; |
| [[maybe_unused]] static constexpr uint32_t kMaxOutOfLine = 0; |
| static constexpr uint32_t kMaxOutOfLineV1 = 8; |
| static constexpr bool kHasEnvelope = true; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_placementofattributes::wire::ExampleUnion> : public std::true_type {}; |
| template <> |
| struct IsUnion<::test_placementofattributes::wire::ExampleUnion> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_placementofattributes::wire::ExampleUnion>); |
| |
| template <typename Constraint, bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_placementofattributes::wire::ExampleUnion, Constraint, IsRecursive> { |
| static constexpr size_t inline_size = 16; |
| static constexpr bool is_memcpy_compatible = false; |
| |
| static void Encode(internal::WireEncoder* encoder, ::test_placementofattributes::wire::ExampleUnion* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| fidl_xunion_v2_t* u = reinterpret_cast<fidl_xunion_v2_t*>(value); |
| |
| if (unlikely(u->tag == 0)) { |
| if constexpr (Constraint::is_optional) { |
| *position.As<fidl_xunion_v2_t>() = {}; |
| return; |
| } |
| encoder->SetError(kCodingErrorInvalidUnionTag); |
| return; |
| } |
| |
| RecursionDepth<IsRecursive> inner_depth = recursion_depth.Add(encoder, 1); |
| if (!inner_depth.IsValid()) { |
| return; |
| } |
| |
| *position.As<fidl_xunion_tag_t>() = u->tag; |
| |
| size_t inline_size; |
| switch (u->tag) { |
| case 1: // ::test_placementofattributes::wire::ExampleUnion::Tag::kVariant |
| inline_size = ::fidl::internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::inline_size; |
| break; |
| default: |
| inline_size = 0; |
| break; |
| } |
| ::fidl::internal::EncodeFn<IsRecursive> encode_fn; |
| switch (u->tag) { |
| case 1: // ::test_placementofattributes::wire::ExampleUnion::Tag::kVariant |
| encode_fn = ::fidl::internal::MakeEncodeFn<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>(); |
| break; |
| default: |
| encode_fn = nullptr; |
| break; |
| } |
| WireEncodeEnvelope(inline_size, encode_fn, encoder, &u->envelope, position + sizeof(fidl_xunion_tag_t), inner_depth); |
| } |
| |
| static void Decode(internal::WireDecoder* decoder, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| ::test_placementofattributes::wire::ExampleUnion::Tag tag = *position.As<::test_placementofattributes::wire::ExampleUnion::Tag>(); |
| if (unlikely(static_cast<uint64_t>(tag) == 0)) { |
| if constexpr (!Constraint::is_optional) { |
| decoder->SetError(kCodingErrorInvalidUnionTag); |
| return; |
| } |
| static_assert(sizeof(fidl_envelope_v2_t) == sizeof(uint64_t)); |
| if (*(position + sizeof(fidl_xunion_tag_t)).As<uint64_t>() != 0) { |
| decoder->SetError(kCodingErrorZeroTagButNonZeroEnvelope); |
| } |
| return; |
| } |
| |
| RecursionDepth<IsRecursive> inner_depth = recursion_depth.Add(decoder, 1); |
| if (!inner_depth.IsValid()) { |
| return; |
| } |
| |
| size_t inline_size; |
| switch (tag) { |
| case ::test_placementofattributes::wire::ExampleUnion::Tag::kVariant: |
| inline_size = ::fidl::internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::inline_size; |
| break; |
| default: |
| inline_size = 0; |
| break; |
| } |
| DecodeFn<IsRecursive> decode_fn; |
| switch (tag) { |
| case ::test_placementofattributes::wire::ExampleUnion::Tag::kVariant: |
| decode_fn = ::fidl::internal::MakeDecodeFn<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>(); |
| break; |
| default: |
| decode_fn = nullptr; |
| break; |
| } |
| ::fidl::internal::WireDecodeStrictEnvelope(inline_size, decode_fn, decoder, position + sizeof(fidl_xunion_tag_t), inner_depth); |
| } |
| }; |
| |
| // Top-level union. |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_placementofattributes::wire::ExampleUnion, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> |
| : public ::fidl::internal::WireCodingTraits<::test_placementofattributes::wire::ExampleUnion, ::fidl::internal::WireCodingConstraintUnion<false>, IsRecursive> {}; |
| |
| } // namespace fidl |