| // WARNING: This file is machine generated by fidlgen. |
| |
| // fidl_experiment = output_index_json |
| |
| #pragma once |
| |
| #include <lib/fidl/cpp/wire/array.h> |
| #include <lib/fidl/cpp/wire/envelope.h> |
| #include <lib/fidl/cpp/wire/internal/framework_err.h> |
| #include <lib/fidl/cpp/wire/message.h> |
| #include <lib/fidl/cpp/wire/message_storage.h> |
| #include <lib/fidl/cpp/wire/object_view.h> |
| #include <lib/fidl/cpp/wire/string_view.h> |
| #include <lib/fidl/cpp/wire/traits.h> |
| #include <lib/fidl/cpp/wire/wire_types.h> |
| #include <lib/stdcompat/optional.h> |
| |
| #include <cinttypes> |
| #ifdef __Fuchsia__ |
| #include <lib/zx/channel.h> |
| |
| #endif // __Fuchsia__ |
| |
| #include <fidl/test.versions/cpp/common_types.h> |
| #include <fidl/test.versions/cpp/markers.h> |
| |
| #pragma clang diagnostic push |
| #pragma clang diagnostic ignored "-Wshadow" |
| |
| namespace test_versions { |
| |
| namespace wire { |
| using Bits = ::test_versions::Bits; |
| |
| using Enum = ::test_versions::Enum; |
| |
| struct Struct; |
| |
| class Table; |
| |
| class Union; |
| |
| using Alias = ::fidl::StringView; |
| |
| struct Struct { |
| uint32_t x = {}; |
| }; |
| |
| } // namespace wire |
| } // namespace test_versions |
| |
| template <> |
| class ::fidl::WireTableBuilder<::test_versions::wire::Table>; |
| template <> |
| class ::fidl::WireTableExternalBuilder<::test_versions::wire::Table>; |
| |
| template <> |
| struct ::fidl::WireTableFrame<::test_versions::wire::Table> 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; |
| uint64_t ComputeMaxOrdinal() const; |
| ::fidl::Envelope<uint32_t> x_; |
| |
| friend class ::test_versions::wire::Table; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_versions::wire::Table, ::fidl::WireTableBuilder<::test_versions::wire::Table>>; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_versions::wire::Table, ::fidl::WireTableExternalBuilder<::test_versions::wire::Table>>; |
| }; |
| |
| namespace test_versions { |
| namespace wire { |
| |
| class Table { |
| public: |
| Table() = default; |
| Table(const Table& other) noexcept = default; |
| Table& operator=(const Table& other) noexcept = default; |
| Table(Table&& other) noexcept = default; |
| Table& operator=(Table&& other) noexcept = default; |
| |
| ~Table() = 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_versions::wire::Table> Builder(::fidl::AnyArena& arena); |
| |
| // Return a builder that relies on explicitly allocating |fidl::ObjectView|s. |
| static ::fidl::WireTableExternalBuilder<::test_versions::wire::Table> ExternalBuilder(::fidl::ObjectView<::fidl::WireTableFrame<::test_versions::wire::Table>> frame); |
| |
| [[nodiscard]] uint32_t& x() const { |
| ZX_ASSERT(has_x()); |
| return frame_ptr_->x_.get_data(); |
| } |
| [[nodiscard]] bool has_x() const { |
| return max_ordinal_ >= 1 && frame_ptr_->x_.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 |
| |
| Table& set_x(uint32_t elem) { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->x_.set_data(std::move(elem)); |
| max_ordinal_ = std::max(max_ordinal_, static_cast<uint64_t>(1)); |
| return *this; |
| } |
| |
| Table& clear_x() { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->x_.clear_data(); |
| max_ordinal_ = frame_ptr_->ComputeMaxOrdinal(); |
| return *this; |
| } |
| |
| explicit Table(::fidl::AnyArena& allocator) |
| : frame_ptr_(::fidl::ObjectView<::fidl::WireTableFrame<::test_versions::wire::Table>>(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 Table(::fidl::ObjectView<::fidl::WireTableFrame<::test_versions::wire::Table>>&& frame) |
| : frame_ptr_(std::move(frame)) {} |
| |
| void Allocate(::fidl::AnyArena& allocator) { |
| max_ordinal_ = 0; |
| frame_ptr_ = ::fidl::ObjectView<::fidl::WireTableFrame<::test_versions::wire::Table>>(allocator); |
| } |
| void Init(::fidl::ObjectView<::fidl::WireTableFrame<::test_versions::wire::Table>>&& frame_ptr) { |
| max_ordinal_ = 0; |
| frame_ptr_ = std::move(frame_ptr); |
| } |
| |
| private: |
| friend ::fidl::internal::WireTableBaseBuilder<::test_versions::wire::Table, ::fidl::WireTableBuilder<::test_versions::wire::Table>>; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_versions::wire::Table, ::fidl::WireTableExternalBuilder<::test_versions::wire::Table>>; |
| |
| uint64_t max_ordinal_ = 0; |
| ::fidl::ObjectView<::fidl::WireTableFrame<::test_versions::wire::Table>> frame_ptr_; |
| }; |
| } // namespace wire |
| } // namespace test_versions |
| |
| template <typename BuilderImpl> |
| class ::fidl::internal::WireTableBaseBuilder<::test_versions::wire::Table, BuilderImpl> { |
| protected: |
| // |Wrapper_Ignore_Me_| wraps a |fidl::ObjectView<T>| and reduces its |
| // priority in overload resolution. When the user writes `{}` as the |
| // setter argument, that would default construct the field instead of |
| // constructing a NULL object view. |
| template <typename U> |
| struct Wrapper_Ignore_Me_ { |
| Wrapper_Ignore_Me_(U v) : value(v) {} |
| U value; |
| }; |
| |
| public: |
| // Build and return the table. The builder should not be used after this. |
| ::test_versions::wire::Table Build() { |
| ZX_DEBUG_ASSERT(table_.frame_ptr_ != nullptr); |
| ::test_versions::wire::Table t = std::move(table_); |
| // Poison this builder to prevent accidental reuse. |
| table_.frame_ptr_ = nullptr; |
| return t; |
| } |
| [[nodiscard]] bool has_x() const { |
| return table_.has_x(); |
| } |
| |
| // Clears the x field. |
| // |
| // This method should be used sparingly, such as only during tests, as it has |
| // O(number_of_fields) complexity. |
| void clear_x() { |
| table_.clear_x(); |
| } |
| |
| // Getter for x. |
| // |
| |
| [[nodiscard]] uint32_t& x() const { |
| return table_.x(); |
| } |
| |
| // Setter for x. |
| // |
| |
| BuilderImpl& x(uint32_t elem) { |
| ZX_DEBUG_ASSERT(table_.frame_ptr_ != nullptr); |
| table_.frame_ptr_->x_.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_versions::wire::Table>>&& frame) |
| : table_(std::move(frame)) {} |
| |
| private: |
| ::test_versions::wire::Table table_; |
| }; |
| |
| template <> |
| class ::fidl::WireTableBuilder<::test_versions::wire::Table> final : public ::fidl::internal::WireTableBaseBuilder<::test_versions::wire::Table, ::fidl::WireTableBuilder<::test_versions::wire::Table>> { |
| using Base = ::fidl::internal::WireTableBaseBuilder<::test_versions::wire::Table, ::fidl::WireTableBuilder<::test_versions::wire::Table>>; |
| |
| public: |
| private: |
| friend class ::test_versions::wire::Table; |
| WireTableBuilder(::fidl::AnyArena& arena) |
| : Base(::fidl::ObjectView<::fidl::WireTableFrame<::test_versions::wire::Table>>(arena)), |
| arena_(arena) {} |
| |
| [[maybe_unused]] std::reference_wrapper<::fidl::AnyArena> arena_; |
| }; |
| |
| template <> |
| class ::fidl::WireTableExternalBuilder<::test_versions::wire::Table> final : public ::fidl::internal::WireTableBaseBuilder<::test_versions::wire::Table, ::fidl::WireTableExternalBuilder<::test_versions::wire::Table>> { |
| using Base = ::fidl::internal::WireTableBaseBuilder<::test_versions::wire::Table, ::fidl::WireTableExternalBuilder<::test_versions::wire::Table>>; |
| |
| private: |
| friend class ::test_versions::wire::Table; |
| using Base::Base; |
| WireTableExternalBuilder(::fidl::WireTableFrame<::test_versions::wire::Table>* frame) |
| : Base(::fidl::ObjectView<::fidl::WireTableFrame<::test_versions::wire::Table>>::FromExternal(frame)) {} |
| }; |
| namespace test_versions { |
| namespace wire { |
| |
| inline ::fidl::WireTableBuilder<::test_versions::wire::Table> Table::Builder(::fidl::AnyArena& arena) { |
| return ::fidl::WireTableBuilder<::test_versions::wire::Table>(arena); |
| } |
| inline ::fidl::WireTableExternalBuilder<::test_versions::wire::Table> Table::ExternalBuilder(::fidl::ObjectView<::fidl::WireTableFrame<::test_versions::wire::Table>> frame) { |
| return ::fidl::WireTableExternalBuilder<::test_versions::wire::Table>(std::move(frame)); |
| } |
| |
| class Union { |
| public: |
| Union() : ordinal_(::test_versions::wire::Union::Ordinal::Invalid), envelope_{} {} |
| |
| Union(const Union&) = default; |
| Union& operator=(const Union&) = default; |
| Union(Union&&) = default; |
| Union& operator=(Union&&) = default; |
| |
| enum class Tag : fidl_xunion_tag_t { |
| kX = 1, // 0x1 |
| _do_not_handle_this__write_a_default_case_instead = ::std::numeric_limits<::fidl_union_tag_t>::max(), |
| }; |
| constexpr bool IsUnknown() const { |
| return Which() == ::test_versions::wire::Union::Tag::_do_not_handle_this__write_a_default_case_instead; |
| } |
| |
| bool has_invalid_tag() const { return ordinal_ == ::test_versions::wire::Union::Ordinal::Invalid; } |
| |
| bool is_x() const { return ordinal_ == ::test_versions::wire::Union::Ordinal::kX; } |
| |
| static Union WithX(uint32_t val) { |
| Union result; |
| result.ordinal_ = ::test_versions::wire::Union::Ordinal::kX; |
| result.envelope_.As<uint32_t>().set_data(std::move(val)); |
| return result; |
| } |
| |
| uint32_t& x() { |
| ZX_ASSERT(ordinal_ == ::test_versions::wire::Union::Ordinal::kX); |
| return envelope_.As<uint32_t>().get_data(); |
| } |
| const uint32_t& x() const { |
| ZX_ASSERT(ordinal_ == ::test_versions::wire::Union::Ordinal::kX); |
| return envelope_.As<uint32_t>().get_data(); |
| } |
| ::test_versions::wire::Union::Tag Which() const; |
| |
| private: |
| enum class Ordinal : fidl_xunion_tag_t { |
| Invalid = 0, |
| kX = 1, // 0x1 |
| }; |
| |
| static void SizeAndOffsetAssertionHelper(); |
| ::test_versions::wire::Union::Ordinal ordinal_; |
| FIDL_ALIGNDECL |
| ::fidl::UntypedEnvelope envelope_; |
| }; |
| |
| constexpr uint32_t kConst = 0u; |
| |
| constexpr bool kAddedAtHead = true; |
| |
| } // namespace wire |
| } // namespace test_versions |
| namespace fidl { |
| |
| template <bool IsRecursive> |
| struct internal::WireCodingTraits<::test_versions::wire::Bits, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> { |
| static constexpr size_t kInlineSize = sizeof(uint32_t); |
| static constexpr bool kIsMemcpyCompatible = true; |
| |
| static void Encode(internal::WireEncoder* encoder, ::test_versions::wire::Bits* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| *position.As<::test_versions::wire::Bits>() = *value; |
| } |
| static void Decode(internal::WireDecoder* decoder, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| } |
| }; |
| |
| template <bool IsRecursive> |
| struct internal::WireCodingTraits<::test_versions::wire::Enum, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> { |
| static constexpr size_t kInlineSize = sizeof(uint32_t); |
| static constexpr bool kIsMemcpyCompatible = true; |
| |
| static void Encode(internal::WireEncoder* encoder, ::test_versions::wire::Enum* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| *position.As<::test_versions::wire::Enum>() = *value; |
| } |
| static void Decode(internal::WireDecoder* decoder, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| } |
| }; |
| |
| template <> |
| struct TypeTraits<::test_versions::wire::Struct> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 0; |
| static constexpr uint32_t kPrimarySize = 4; |
| [[maybe_unused]] |
| static constexpr uint32_t kMaxOutOfLine = 0; |
| static constexpr bool kHasFlexibleEnvelope = false; |
| static constexpr bool kHasPointer = false; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_versions::wire::Struct> : public std::true_type {}; |
| template <> |
| struct IsWire<::test_versions::wire::Struct> : public std::true_type {}; |
| template <> |
| struct IsStruct<::test_versions::wire::Struct> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_versions::wire::Struct>); |
| static_assert(offsetof(::test_versions::wire::Struct, x) == 0); |
| static_assert(sizeof(::test_versions::wire::Struct) == TypeTraits<::test_versions::wire::Struct>::kPrimarySize); |
| |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_versions::wire::Struct, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> { |
| static constexpr size_t kInlineSize = 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_versions::wire::Struct, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive>; |
| static constexpr bool kIsMemcpyCompatible = Base::kIsMemcpyCompatible; |
| |
| static void Encode( |
| internal::WireEncoder* encoder, ::test_versions::wire::Struct* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| if constexpr (kIsMemcpyCompatible) { |
| memcpy(position.As<void>(), value, sizeof(::test_versions::wire::Struct)); |
| } else { |
| internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::Encode(encoder, &value->x, 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); |
| } |
| } |
| }; |
| |
| template <> |
| struct TypeTraits<::test_versions::wire::Table> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 2; |
| static constexpr uint32_t kPrimarySize = 16; |
| [[maybe_unused]] |
| static constexpr uint32_t kMaxOutOfLine = 8; |
| static constexpr bool kHasFlexibleEnvelope = true; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_versions::wire::Table> : public std::true_type {}; |
| template <> |
| struct IsWire<::test_versions::wire::Table> : public std::true_type {}; |
| template <> |
| struct IsTable<::test_versions::wire::Table> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_versions::wire::Table>); |
| |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_versions::wire::Table, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> |
| : ::fidl::internal::WireTableCodingTraitsBase<IsRecursive> { |
| using Base = ::fidl::internal::WireTableCodingTraitsBase<IsRecursive>; |
| static constexpr size_t kInlineSize = 16; |
| static constexpr bool kIsMemcpyCompatible = false; |
| |
| static void Encode(internal::WireEncoder* encoder, ::test_versions::wire::Table* 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_t* envelopes = static_cast<fidl_envelope_t*>(vec->data); |
| for (size_t i = 0; i < vec->count; i++) { |
| size_t encode_inline_size = 0; |
| switch (i) { |
| case 0: |
| encode_inline_size = ::fidl::internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::kInlineSize; |
| 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_t); |
| WireEncodeEnvelope(encode_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 decode_inline_size = 0; |
| switch (i) { |
| case 0: |
| decode_inline_size = ::fidl::internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::kInlineSize; |
| 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(decode_inline_size, decode_fn, decoder, vector_position + i * sizeof(fidl_envelope_t), inner_depth); |
| } |
| } |
| }; |
| |
| template <> |
| struct TypeTraits<::test_versions::wire::Union> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 1; |
| static constexpr uint32_t kPrimarySize = 16; |
| [[maybe_unused]] |
| static constexpr uint32_t kMaxOutOfLine = 0; |
| static constexpr bool kHasFlexibleEnvelope = true; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_versions::wire::Union> : public std::true_type {}; |
| template <> |
| struct IsWire<::test_versions::wire::Union> : public std::true_type {}; |
| template <> |
| struct IsUnion<::test_versions::wire::Union> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_versions::wire::Union>); |
| |
| template <typename Constraint, bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_versions::wire::Union, Constraint, IsRecursive> { |
| static constexpr size_t kInlineSize = 16; |
| static constexpr bool kIsMemcpyCompatible = false; |
| |
| static void Encode(internal::WireEncoder* encoder, ::test_versions::wire::Union* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| fidl_union_t* u = reinterpret_cast<fidl_union_t*>(value); |
| |
| if (unlikely(u->tag == 0)) { |
| if constexpr (Constraint::is_optional) { |
| *position.As<fidl_union_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 encode_inline_size; |
| switch (u->tag) { |
| case 1: // ::test_versions::wire::Union::Tag::kX |
| encode_inline_size = ::fidl::internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::kInlineSize; |
| break; |
| default: |
| encode_inline_size = 0; |
| break; |
| } |
| ::fidl::internal::EncodeFn<IsRecursive> encode_fn; |
| switch (u->tag) { |
| case 1: // ::test_versions::wire::Union::Tag::kX |
| encode_fn = ::fidl::internal::MakeEncodeFn<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>(); |
| break; |
| default: |
| encode_fn = nullptr; |
| break; |
| } |
| WireEncodeEnvelope(encode_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_versions::wire::Union::Tag tag = *position.As<::test_versions::wire::Union::Tag>(); |
| if (unlikely(static_cast<uint64_t>(tag) == 0)) { |
| if constexpr (!Constraint::is_optional) { |
| decoder->SetError(kCodingErrorInvalidUnionTag); |
| return; |
| } |
| static_assert(sizeof(fidl_envelope_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 decode_inline_size; |
| switch (tag) { |
| case ::test_versions::wire::Union::Tag::kX: |
| decode_inline_size = ::fidl::internal::WireCodingTraits<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::kInlineSize; |
| break; |
| default: |
| decode_inline_size = 0; |
| break; |
| } |
| DecodeFn<IsRecursive> decode_fn; |
| switch (tag) { |
| case ::test_versions::wire::Union::Tag::kX: |
| decode_fn = ::fidl::internal::MakeDecodeFn<uint32_t, fidl::internal::WireCodingConstraintEmpty, IsRecursive>(); |
| break; |
| default: |
| decode_fn = nullptr; |
| break; |
| } |
| ::fidl::internal::WireDecodeFlexibleEnvelope(decode_inline_size, decode_fn, decoder, position + sizeof(fidl_xunion_tag_t), inner_depth); |
| } |
| }; |
| |
| // Top-level union. |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_versions::wire::Union, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> |
| : public ::fidl::internal::WireCodingTraits<::test_versions::wire::Union, ::fidl::internal::WireCodingConstraintUnion<false>, IsRecursive> {}; |
| |
| #pragma clang diagnostic pop |
| |
| } // namespace fidl |