| // 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__ |
| |
| #endif // __Fuchsia__ |
| |
| #include <fidl/test.arrays/cpp/common_types.h> |
| #include <fidl/test.arrays/cpp/markers.h> |
| |
| #pragma clang diagnostic push |
| #pragma clang diagnostic ignored "-Wshadow" |
| |
| namespace test_arrays { |
| |
| namespace wire { |
| |
| struct StructSmallArray; |
| |
| struct StructLargeArray; |
| |
| class TableSmallArray; |
| |
| class TableLargeArray; |
| |
| class UnionSmallArray; |
| |
| class UnionLargeArray; |
| |
| } // namespace wire |
| } // namespace test_arrays |
| |
| template <> |
| class ::fidl::WireTableBuilder<::test_arrays::wire::TableSmallArray>; |
| template <> |
| class ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableSmallArray>; |
| |
| template <> |
| struct ::fidl::WireTableFrame<::test_arrays::wire::TableSmallArray> 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<::fidl::Array<uint32_t, 2>> a_; |
| |
| friend class ::test_arrays::wire::TableSmallArray; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableSmallArray, ::fidl::WireTableBuilder<::test_arrays::wire::TableSmallArray>>; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableSmallArray, ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableSmallArray>>; |
| }; |
| |
| namespace test_arrays { |
| namespace wire { |
| |
| class TableSmallArray { |
| public: |
| TableSmallArray() = default; |
| TableSmallArray(const TableSmallArray& other) noexcept = default; |
| TableSmallArray& operator=(const TableSmallArray& other) noexcept = default; |
| TableSmallArray(TableSmallArray&& other) noexcept = default; |
| TableSmallArray& operator=(TableSmallArray&& other) noexcept = default; |
| |
| ~TableSmallArray() = 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_arrays::wire::TableSmallArray> Builder(::fidl::AnyArena& arena); |
| |
| // Return a builder that relies on explicitly allocating |fidl::ObjectView|s. |
| static ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableSmallArray> ExternalBuilder(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableSmallArray>> frame); |
| |
| [[nodiscard]] ::fidl::Array<uint32_t, 2>& a() const { |
| ZX_ASSERT(has_a()); |
| return frame_ptr_->a_.get_data(); |
| } |
| [[nodiscard]] bool has_a() const { |
| return max_ordinal_ >= 1 && frame_ptr_->a_.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 |
| |
| TableSmallArray& set_a(::fidl::ObjectView<::fidl::Array<uint32_t, 2>> elem) { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->a_.set_data(elem); |
| max_ordinal_ = std::max(max_ordinal_, static_cast<uint64_t>(1)); |
| return *this; |
| } |
| TableSmallArray& set_a(std::nullptr_t) { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->a_.set_data(nullptr); |
| return *this; |
| } |
| template <typename... Args> |
| TableSmallArray& set_a(::fidl::AnyArena& allocator, Args&&... args) { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->a_.set_data( |
| ::fidl::ObjectView<::fidl::Array<uint32_t, 2>>(allocator, std::forward<Args>(args)...)); |
| max_ordinal_ = std::max(max_ordinal_, static_cast<uint64_t>(1)); |
| return *this; |
| } |
| |
| TableSmallArray& clear_a() { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->a_.clear_data(); |
| max_ordinal_ = frame_ptr_->ComputeMaxOrdinal(); |
| return *this; |
| } |
| |
| explicit TableSmallArray(::fidl::AnyArena& allocator) |
| : frame_ptr_(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableSmallArray>>(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 TableSmallArray(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableSmallArray>>&& frame) |
| : frame_ptr_(std::move(frame)) {} |
| |
| void Allocate(::fidl::AnyArena& allocator) { |
| max_ordinal_ = 0; |
| frame_ptr_ = ::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableSmallArray>>(allocator); |
| } |
| void Init(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableSmallArray>>&& frame_ptr) { |
| max_ordinal_ = 0; |
| frame_ptr_ = std::move(frame_ptr); |
| } |
| |
| private: |
| friend ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableSmallArray, ::fidl::WireTableBuilder<::test_arrays::wire::TableSmallArray>>; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableSmallArray, ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableSmallArray>>; |
| |
| uint64_t max_ordinal_ = 0; |
| ::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableSmallArray>> frame_ptr_; |
| }; |
| } // namespace wire |
| } // namespace test_arrays |
| |
| template <typename BuilderImpl> |
| class ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableSmallArray, 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_arrays::wire::TableSmallArray Build() { |
| ZX_DEBUG_ASSERT(table_.frame_ptr_ != nullptr); |
| ::test_arrays::wire::TableSmallArray t = std::move(table_); |
| // Poison this builder to prevent accidental reuse. |
| table_.frame_ptr_ = nullptr; |
| return t; |
| } |
| [[nodiscard]] bool has_a() const { |
| return table_.has_a(); |
| } |
| |
| // Clears the a field. |
| // |
| // This method should be used sparingly, such as only during tests, as it has |
| // O(number_of_fields) complexity. |
| void clear_a() { |
| table_.clear_a(); |
| } |
| |
| // Getter for a. |
| // |
| |
| [[nodiscard]] ::fidl::Array<uint32_t, 2>& a() const { |
| return table_.a(); |
| } |
| |
| // Setter for a. |
| // |
| |
| BuilderImpl& a(Wrapper_Ignore_Me_<::fidl::ObjectView<::fidl::Array<uint32_t, 2>>> elem) { |
| ZX_DEBUG_ASSERT(table_.frame_ptr_ != nullptr); |
| ZX_DEBUG_ASSERT(elem.value.get() != nullptr); |
| table_.frame_ptr_->a_.set_data(elem.value); |
| 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_arrays::wire::TableSmallArray>>&& frame) |
| : table_(std::move(frame)) {} |
| |
| private: |
| ::test_arrays::wire::TableSmallArray table_; |
| }; |
| |
| template <> |
| class ::fidl::WireTableBuilder<::test_arrays::wire::TableSmallArray> final : public ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableSmallArray, ::fidl::WireTableBuilder<::test_arrays::wire::TableSmallArray>> { |
| using Base = ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableSmallArray, ::fidl::WireTableBuilder<::test_arrays::wire::TableSmallArray>>; |
| |
| public: |
| using Base::a; |
| |
| template < |
| typename First = ::fidl::Array<uint32_t, 2>, |
| typename... Args, |
| std::enable_if_t<!std::is_same_v<cpp20::remove_cvref_t<First>, fidl::ObjectView<::fidl::Array<uint32_t, 2>>>, int> = 0> |
| ::fidl::WireTableBuilder<::test_arrays::wire::TableSmallArray>& a(First&& first, Args&&... args_) { |
| fidl::ObjectView<::fidl::Array<uint32_t, 2>> view_(arena_.get(), std::forward<First>(first), std::forward<Args>(args_)...); |
| a(Base::Wrapper_Ignore_Me_<fidl::ObjectView<::fidl::Array<uint32_t, 2>>>(view_)); |
| return *this; |
| } |
| |
| private: |
| friend class ::test_arrays::wire::TableSmallArray; |
| WireTableBuilder(::fidl::AnyArena& arena) |
| : Base(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableSmallArray>>(arena)), |
| arena_(arena) {} |
| |
| [[maybe_unused]] std::reference_wrapper<::fidl::AnyArena> arena_; |
| }; |
| |
| template <> |
| class ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableSmallArray> final : public ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableSmallArray, ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableSmallArray>> { |
| using Base = ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableSmallArray, ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableSmallArray>>; |
| |
| private: |
| friend class ::test_arrays::wire::TableSmallArray; |
| using Base::Base; |
| WireTableExternalBuilder(::fidl::WireTableFrame<::test_arrays::wire::TableSmallArray>* frame) |
| : Base(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableSmallArray>>::FromExternal(frame)) {} |
| }; |
| namespace test_arrays { |
| namespace wire { |
| |
| inline ::fidl::WireTableBuilder<::test_arrays::wire::TableSmallArray> TableSmallArray::Builder(::fidl::AnyArena& arena) { |
| return ::fidl::WireTableBuilder<::test_arrays::wire::TableSmallArray>(arena); |
| } |
| inline ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableSmallArray> TableSmallArray::ExternalBuilder(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableSmallArray>> frame) { |
| return ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableSmallArray>(std::move(frame)); |
| } |
| |
| } // namespace wire |
| } // namespace test_arrays |
| |
| template <> |
| class ::fidl::WireTableBuilder<::test_arrays::wire::TableLargeArray>; |
| template <> |
| class ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableLargeArray>; |
| |
| template <> |
| struct ::fidl::WireTableFrame<::test_arrays::wire::TableLargeArray> 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<::fidl::Array<uint32_t, 100>> a_; |
| |
| friend class ::test_arrays::wire::TableLargeArray; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableLargeArray, ::fidl::WireTableBuilder<::test_arrays::wire::TableLargeArray>>; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableLargeArray, ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableLargeArray>>; |
| }; |
| |
| namespace test_arrays { |
| namespace wire { |
| |
| class TableLargeArray { |
| public: |
| TableLargeArray() = default; |
| TableLargeArray(const TableLargeArray& other) noexcept = default; |
| TableLargeArray& operator=(const TableLargeArray& other) noexcept = default; |
| TableLargeArray(TableLargeArray&& other) noexcept = default; |
| TableLargeArray& operator=(TableLargeArray&& other) noexcept = default; |
| |
| ~TableLargeArray() = 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_arrays::wire::TableLargeArray> Builder(::fidl::AnyArena& arena); |
| |
| // Return a builder that relies on explicitly allocating |fidl::ObjectView|s. |
| static ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableLargeArray> ExternalBuilder(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableLargeArray>> frame); |
| |
| [[nodiscard]] ::fidl::Array<uint32_t, 100>& a() const { |
| ZX_ASSERT(has_a()); |
| return frame_ptr_->a_.get_data(); |
| } |
| [[nodiscard]] bool has_a() const { |
| return max_ordinal_ >= 1 && frame_ptr_->a_.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 |
| |
| TableLargeArray& set_a(::fidl::ObjectView<::fidl::Array<uint32_t, 100>> elem) { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->a_.set_data(elem); |
| max_ordinal_ = std::max(max_ordinal_, static_cast<uint64_t>(1)); |
| return *this; |
| } |
| TableLargeArray& set_a(std::nullptr_t) { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->a_.set_data(nullptr); |
| return *this; |
| } |
| template <typename... Args> |
| TableLargeArray& set_a(::fidl::AnyArena& allocator, Args&&... args) { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->a_.set_data( |
| ::fidl::ObjectView<::fidl::Array<uint32_t, 100>>(allocator, std::forward<Args>(args)...)); |
| max_ordinal_ = std::max(max_ordinal_, static_cast<uint64_t>(1)); |
| return *this; |
| } |
| |
| TableLargeArray& clear_a() { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->a_.clear_data(); |
| max_ordinal_ = frame_ptr_->ComputeMaxOrdinal(); |
| return *this; |
| } |
| |
| explicit TableLargeArray(::fidl::AnyArena& allocator) |
| : frame_ptr_(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableLargeArray>>(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 TableLargeArray(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableLargeArray>>&& frame) |
| : frame_ptr_(std::move(frame)) {} |
| |
| void Allocate(::fidl::AnyArena& allocator) { |
| max_ordinal_ = 0; |
| frame_ptr_ = ::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableLargeArray>>(allocator); |
| } |
| void Init(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableLargeArray>>&& frame_ptr) { |
| max_ordinal_ = 0; |
| frame_ptr_ = std::move(frame_ptr); |
| } |
| |
| private: |
| friend ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableLargeArray, ::fidl::WireTableBuilder<::test_arrays::wire::TableLargeArray>>; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableLargeArray, ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableLargeArray>>; |
| |
| uint64_t max_ordinal_ = 0; |
| ::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableLargeArray>> frame_ptr_; |
| }; |
| } // namespace wire |
| } // namespace test_arrays |
| |
| template <typename BuilderImpl> |
| class ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableLargeArray, 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_arrays::wire::TableLargeArray Build() { |
| ZX_DEBUG_ASSERT(table_.frame_ptr_ != nullptr); |
| ::test_arrays::wire::TableLargeArray t = std::move(table_); |
| // Poison this builder to prevent accidental reuse. |
| table_.frame_ptr_ = nullptr; |
| return t; |
| } |
| [[nodiscard]] bool has_a() const { |
| return table_.has_a(); |
| } |
| |
| // Clears the a field. |
| // |
| // This method should be used sparingly, such as only during tests, as it has |
| // O(number_of_fields) complexity. |
| void clear_a() { |
| table_.clear_a(); |
| } |
| |
| // Getter for a. |
| // |
| |
| [[nodiscard]] ::fidl::Array<uint32_t, 100>& a() const { |
| return table_.a(); |
| } |
| |
| // Setter for a. |
| // |
| |
| BuilderImpl& a(Wrapper_Ignore_Me_<::fidl::ObjectView<::fidl::Array<uint32_t, 100>>> elem) { |
| ZX_DEBUG_ASSERT(table_.frame_ptr_ != nullptr); |
| ZX_DEBUG_ASSERT(elem.value.get() != nullptr); |
| table_.frame_ptr_->a_.set_data(elem.value); |
| 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_arrays::wire::TableLargeArray>>&& frame) |
| : table_(std::move(frame)) {} |
| |
| private: |
| ::test_arrays::wire::TableLargeArray table_; |
| }; |
| |
| template <> |
| class ::fidl::WireTableBuilder<::test_arrays::wire::TableLargeArray> final : public ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableLargeArray, ::fidl::WireTableBuilder<::test_arrays::wire::TableLargeArray>> { |
| using Base = ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableLargeArray, ::fidl::WireTableBuilder<::test_arrays::wire::TableLargeArray>>; |
| |
| public: |
| using Base::a; |
| |
| template < |
| typename First = ::fidl::Array<uint32_t, 100>, |
| typename... Args, |
| std::enable_if_t<!std::is_same_v<cpp20::remove_cvref_t<First>, fidl::ObjectView<::fidl::Array<uint32_t, 100>>>, int> = 0> |
| ::fidl::WireTableBuilder<::test_arrays::wire::TableLargeArray>& a(First&& first, Args&&... args_) { |
| fidl::ObjectView<::fidl::Array<uint32_t, 100>> view_(arena_.get(), std::forward<First>(first), std::forward<Args>(args_)...); |
| a(Base::Wrapper_Ignore_Me_<fidl::ObjectView<::fidl::Array<uint32_t, 100>>>(view_)); |
| return *this; |
| } |
| |
| private: |
| friend class ::test_arrays::wire::TableLargeArray; |
| WireTableBuilder(::fidl::AnyArena& arena) |
| : Base(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableLargeArray>>(arena)), |
| arena_(arena) {} |
| |
| [[maybe_unused]] std::reference_wrapper<::fidl::AnyArena> arena_; |
| }; |
| |
| template <> |
| class ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableLargeArray> final : public ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableLargeArray, ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableLargeArray>> { |
| using Base = ::fidl::internal::WireTableBaseBuilder<::test_arrays::wire::TableLargeArray, ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableLargeArray>>; |
| |
| private: |
| friend class ::test_arrays::wire::TableLargeArray; |
| using Base::Base; |
| WireTableExternalBuilder(::fidl::WireTableFrame<::test_arrays::wire::TableLargeArray>* frame) |
| : Base(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableLargeArray>>::FromExternal(frame)) {} |
| }; |
| namespace test_arrays { |
| namespace wire { |
| |
| inline ::fidl::WireTableBuilder<::test_arrays::wire::TableLargeArray> TableLargeArray::Builder(::fidl::AnyArena& arena) { |
| return ::fidl::WireTableBuilder<::test_arrays::wire::TableLargeArray>(arena); |
| } |
| inline ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableLargeArray> TableLargeArray::ExternalBuilder(::fidl::ObjectView<::fidl::WireTableFrame<::test_arrays::wire::TableLargeArray>> frame) { |
| return ::fidl::WireTableExternalBuilder<::test_arrays::wire::TableLargeArray>(std::move(frame)); |
| } |
| |
| class UnionSmallArray { |
| public: |
| UnionSmallArray() : ordinal_(::test_arrays::wire::UnionSmallArray::Ordinal::Invalid), envelope_{} {} |
| |
| UnionSmallArray(const UnionSmallArray&) = default; |
| UnionSmallArray& operator=(const UnionSmallArray&) = default; |
| UnionSmallArray(UnionSmallArray&&) = default; |
| UnionSmallArray& operator=(UnionSmallArray&&) = default; |
| |
| enum class Tag : fidl_xunion_tag_t { |
| kA = 1, // 0x1 |
| }; |
| |
| bool has_invalid_tag() const { return ordinal_ == ::test_arrays::wire::UnionSmallArray::Ordinal::Invalid; } |
| |
| bool is_a() const { return ordinal_ == ::test_arrays::wire::UnionSmallArray::Ordinal::kA; } |
| |
| static UnionSmallArray WithA(::fidl::ObjectView<::fidl::Array<uint32_t, 2>> val) { |
| UnionSmallArray result; |
| result.ordinal_ = ::test_arrays::wire::UnionSmallArray::Ordinal::kA; |
| result.envelope_.As<::fidl::Array<uint32_t, 2>>().set_data(std::move(val)); |
| return result; |
| } |
| |
| template <typename... Args> |
| static UnionSmallArray WithA(::fidl::AnyArena& allocator, Args&&... args) { |
| return WithA(::fidl::ObjectView<::fidl::Array<uint32_t, 2>>(allocator, |
| std::forward<Args>(args)...)); |
| } |
| |
| ::fidl::Array<uint32_t, 2>& a() { |
| ZX_ASSERT(ordinal_ == ::test_arrays::wire::UnionSmallArray::Ordinal::kA); |
| return envelope_.As<::fidl::Array<uint32_t, 2>>().get_data(); |
| } |
| const ::fidl::Array<uint32_t, 2>& a() const { |
| ZX_ASSERT(ordinal_ == ::test_arrays::wire::UnionSmallArray::Ordinal::kA); |
| return envelope_.As<::fidl::Array<uint32_t, 2>>().get_data(); |
| } |
| ::test_arrays::wire::UnionSmallArray::Tag Which() const { |
| ZX_ASSERT(!has_invalid_tag()); |
| return static_cast<::test_arrays::wire::UnionSmallArray::Tag>(ordinal_); |
| } |
| |
| private: |
| enum class Ordinal : fidl_xunion_tag_t { |
| Invalid = 0, |
| kA = 1, // 0x1 |
| }; |
| |
| static void SizeAndOffsetAssertionHelper(); |
| ::test_arrays::wire::UnionSmallArray::Ordinal ordinal_; |
| FIDL_ALIGNDECL |
| ::fidl::UntypedEnvelope envelope_; |
| }; |
| |
| class UnionLargeArray { |
| public: |
| UnionLargeArray() : ordinal_(::test_arrays::wire::UnionLargeArray::Ordinal::Invalid), envelope_{} {} |
| |
| UnionLargeArray(const UnionLargeArray&) = default; |
| UnionLargeArray& operator=(const UnionLargeArray&) = default; |
| UnionLargeArray(UnionLargeArray&&) = default; |
| UnionLargeArray& operator=(UnionLargeArray&&) = default; |
| |
| enum class Tag : fidl_xunion_tag_t { |
| kA = 1, // 0x1 |
| }; |
| |
| bool has_invalid_tag() const { return ordinal_ == ::test_arrays::wire::UnionLargeArray::Ordinal::Invalid; } |
| |
| bool is_a() const { return ordinal_ == ::test_arrays::wire::UnionLargeArray::Ordinal::kA; } |
| |
| static UnionLargeArray WithA(::fidl::ObjectView<::fidl::Array<uint32_t, 100>> val) { |
| UnionLargeArray result; |
| result.ordinal_ = ::test_arrays::wire::UnionLargeArray::Ordinal::kA; |
| result.envelope_.As<::fidl::Array<uint32_t, 100>>().set_data(std::move(val)); |
| return result; |
| } |
| |
| template <typename... Args> |
| static UnionLargeArray WithA(::fidl::AnyArena& allocator, Args&&... args) { |
| return WithA(::fidl::ObjectView<::fidl::Array<uint32_t, 100>>(allocator, |
| std::forward<Args>(args)...)); |
| } |
| |
| ::fidl::Array<uint32_t, 100>& a() { |
| ZX_ASSERT(ordinal_ == ::test_arrays::wire::UnionLargeArray::Ordinal::kA); |
| return envelope_.As<::fidl::Array<uint32_t, 100>>().get_data(); |
| } |
| const ::fidl::Array<uint32_t, 100>& a() const { |
| ZX_ASSERT(ordinal_ == ::test_arrays::wire::UnionLargeArray::Ordinal::kA); |
| return envelope_.As<::fidl::Array<uint32_t, 100>>().get_data(); |
| } |
| ::test_arrays::wire::UnionLargeArray::Tag Which() const { |
| ZX_ASSERT(!has_invalid_tag()); |
| return static_cast<::test_arrays::wire::UnionLargeArray::Tag>(ordinal_); |
| } |
| |
| private: |
| enum class Ordinal : fidl_xunion_tag_t { |
| Invalid = 0, |
| kA = 1, // 0x1 |
| }; |
| |
| static void SizeAndOffsetAssertionHelper(); |
| ::test_arrays::wire::UnionLargeArray::Ordinal ordinal_; |
| FIDL_ALIGNDECL |
| ::fidl::UntypedEnvelope envelope_; |
| }; |
| |
| struct StructSmallArray { |
| ::fidl::Array<uint32_t, 2> a = {}; |
| }; |
| |
| struct StructLargeArray { |
| ::fidl::Array<uint32_t, 100> a = {}; |
| }; |
| |
| } // namespace wire |
| } // namespace test_arrays |
| namespace fidl { |
| |
| template <> |
| struct TypeTraits<::test_arrays::wire::StructSmallArray> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 0; |
| static constexpr uint32_t kPrimarySize = 8; |
| [[maybe_unused]] |
| static constexpr uint32_t kMaxOutOfLine = 0; |
| static constexpr bool kHasFlexibleEnvelope = false; |
| static constexpr bool kHasPointer = false; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_arrays::wire::StructSmallArray> : public std::true_type {}; |
| template <> |
| struct IsWire<::test_arrays::wire::StructSmallArray> : public std::true_type {}; |
| template <> |
| struct IsStruct<::test_arrays::wire::StructSmallArray> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_arrays::wire::StructSmallArray>); |
| static_assert(offsetof(::test_arrays::wire::StructSmallArray, a) == 0); |
| static_assert(sizeof(::test_arrays::wire::StructSmallArray) == TypeTraits<::test_arrays::wire::StructSmallArray>::kPrimarySize); |
| |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_arrays::wire::StructSmallArray, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> { |
| static constexpr size_t kInlineSize = 8; |
| static constexpr auto kMembers = std::make_tuple(::fidl::internal::WireStructMemberCodingInfo<::fidl::Array<uint32_t, 2>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>()); |
| static constexpr bool kHasPadding = false; |
| using Base = WireStructCodingTraitsBase<::test_arrays::wire::StructSmallArray, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive>; |
| static constexpr bool kIsMemcpyCompatible = Base::kIsMemcpyCompatible; |
| |
| static void Encode( |
| internal::WireEncoder* encoder, ::test_arrays::wire::StructSmallArray* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| if constexpr (kIsMemcpyCompatible) { |
| memcpy(position.As<void>(), value, sizeof(::test_arrays::wire::StructSmallArray)); |
| } else { |
| internal::WireCodingTraits<::fidl::Array<uint32_t, 2>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::Encode(encoder, &value->a, 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<::fidl::Array<uint32_t, 2>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::Decode( |
| decoder, position + 0, recursion_depth); |
| } |
| } |
| }; |
| |
| template <> |
| struct TypeTraits<::test_arrays::wire::StructLargeArray> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 0; |
| static constexpr uint32_t kPrimarySize = 400; |
| [[maybe_unused]] |
| static constexpr uint32_t kMaxOutOfLine = 0; |
| static constexpr bool kHasFlexibleEnvelope = false; |
| static constexpr bool kHasPointer = false; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_arrays::wire::StructLargeArray> : public std::true_type {}; |
| template <> |
| struct IsWire<::test_arrays::wire::StructLargeArray> : public std::true_type {}; |
| template <> |
| struct IsStruct<::test_arrays::wire::StructLargeArray> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_arrays::wire::StructLargeArray>); |
| static_assert(offsetof(::test_arrays::wire::StructLargeArray, a) == 0); |
| static_assert(sizeof(::test_arrays::wire::StructLargeArray) == TypeTraits<::test_arrays::wire::StructLargeArray>::kPrimarySize); |
| |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_arrays::wire::StructLargeArray, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> { |
| static constexpr size_t kInlineSize = 400; |
| static constexpr auto kMembers = std::make_tuple(::fidl::internal::WireStructMemberCodingInfo<::fidl::Array<uint32_t, 100>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>()); |
| static constexpr bool kHasPadding = false; |
| using Base = WireStructCodingTraitsBase<::test_arrays::wire::StructLargeArray, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive>; |
| static constexpr bool kIsMemcpyCompatible = Base::kIsMemcpyCompatible; |
| |
| static void Encode( |
| internal::WireEncoder* encoder, ::test_arrays::wire::StructLargeArray* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| if constexpr (kIsMemcpyCompatible) { |
| memcpy(position.As<void>(), value, sizeof(::test_arrays::wire::StructLargeArray)); |
| } else { |
| internal::WireCodingTraits<::fidl::Array<uint32_t, 100>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::Encode(encoder, &value->a, 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<::fidl::Array<uint32_t, 100>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::Decode( |
| decoder, position + 0, recursion_depth); |
| } |
| } |
| }; |
| |
| template <> |
| struct TypeTraits<::test_arrays::wire::TableSmallArray> { |
| 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 = 16; |
| static constexpr bool kHasFlexibleEnvelope = true; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_arrays::wire::TableSmallArray> : public std::true_type {}; |
| template <> |
| struct IsWire<::test_arrays::wire::TableSmallArray> : public std::true_type {}; |
| template <> |
| struct IsTable<::test_arrays::wire::TableSmallArray> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_arrays::wire::TableSmallArray>); |
| |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_arrays::wire::TableSmallArray, ::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_arrays::wire::TableSmallArray* 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<::fidl::Array<uint32_t, 2>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::kInlineSize; |
| break; |
| } |
| ::fidl::internal::EncodeFn<IsRecursive> encode_fn = nullptr; |
| switch (i) { |
| case 0: |
| encode_fn = ::fidl::internal::MakeEncodeFn<::fidl::Array<uint32_t, 2>, 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<::fidl::Array<uint32_t, 2>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::kInlineSize; |
| break; |
| } |
| DecodeFn<IsRecursive> decode_fn = nullptr; |
| switch (i) { |
| case 0: |
| decode_fn = ::fidl::internal::MakeDecodeFn<::fidl::Array<uint32_t, 2>, 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_arrays::wire::TableLargeArray> { |
| 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 = 408; |
| static constexpr bool kHasFlexibleEnvelope = true; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_arrays::wire::TableLargeArray> : public std::true_type {}; |
| template <> |
| struct IsWire<::test_arrays::wire::TableLargeArray> : public std::true_type {}; |
| template <> |
| struct IsTable<::test_arrays::wire::TableLargeArray> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_arrays::wire::TableLargeArray>); |
| |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_arrays::wire::TableLargeArray, ::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_arrays::wire::TableLargeArray* 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<::fidl::Array<uint32_t, 100>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::kInlineSize; |
| break; |
| } |
| ::fidl::internal::EncodeFn<IsRecursive> encode_fn = nullptr; |
| switch (i) { |
| case 0: |
| encode_fn = ::fidl::internal::MakeEncodeFn<::fidl::Array<uint32_t, 100>, 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<::fidl::Array<uint32_t, 100>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::kInlineSize; |
| break; |
| } |
| DecodeFn<IsRecursive> decode_fn = nullptr; |
| switch (i) { |
| case 0: |
| decode_fn = ::fidl::internal::MakeDecodeFn<::fidl::Array<uint32_t, 100>, 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_arrays::wire::UnionSmallArray> { |
| 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 = 8; |
| static constexpr bool kHasFlexibleEnvelope = false; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_arrays::wire::UnionSmallArray> : public std::true_type {}; |
| template <> |
| struct IsWire<::test_arrays::wire::UnionSmallArray> : public std::true_type {}; |
| template <> |
| struct IsUnion<::test_arrays::wire::UnionSmallArray> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_arrays::wire::UnionSmallArray>); |
| |
| template <typename Constraint, bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_arrays::wire::UnionSmallArray, Constraint, IsRecursive> { |
| static constexpr size_t kInlineSize = 16; |
| static constexpr bool kIsMemcpyCompatible = false; |
| |
| static void Encode(internal::WireEncoder* encoder, ::test_arrays::wire::UnionSmallArray* 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_arrays::wire::UnionSmallArray::Tag::kA |
| encode_inline_size = ::fidl::internal::WireCodingTraits<::fidl::Array<uint32_t, 2>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::kInlineSize; |
| break; |
| default: |
| encode_inline_size = 0; |
| break; |
| } |
| ::fidl::internal::EncodeFn<IsRecursive> encode_fn; |
| switch (u->tag) { |
| case 1: // ::test_arrays::wire::UnionSmallArray::Tag::kA |
| encode_fn = ::fidl::internal::MakeEncodeFn<::fidl::Array<uint32_t, 2>, 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_arrays::wire::UnionSmallArray::Tag tag = *position.As<::test_arrays::wire::UnionSmallArray::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_arrays::wire::UnionSmallArray::Tag::kA: |
| decode_inline_size = ::fidl::internal::WireCodingTraits<::fidl::Array<uint32_t, 2>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::kInlineSize; |
| break; |
| default: |
| decode_inline_size = 0; |
| break; |
| } |
| DecodeFn<IsRecursive> decode_fn; |
| switch (tag) { |
| case ::test_arrays::wire::UnionSmallArray::Tag::kA: |
| decode_fn = ::fidl::internal::MakeDecodeFn<::fidl::Array<uint32_t, 2>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>(); |
| break; |
| default: |
| decode_fn = nullptr; |
| break; |
| } |
| ::fidl::internal::WireDecodeStrictEnvelope(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_arrays::wire::UnionSmallArray, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> |
| : public ::fidl::internal::WireCodingTraits<::test_arrays::wire::UnionSmallArray, ::fidl::internal::WireCodingConstraintUnion<false>, IsRecursive> {}; |
| |
| template <> |
| struct TypeTraits<::test_arrays::wire::UnionLargeArray> { |
| 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 = 400; |
| static constexpr bool kHasFlexibleEnvelope = false; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_arrays::wire::UnionLargeArray> : public std::true_type {}; |
| template <> |
| struct IsWire<::test_arrays::wire::UnionLargeArray> : public std::true_type {}; |
| template <> |
| struct IsUnion<::test_arrays::wire::UnionLargeArray> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_arrays::wire::UnionLargeArray>); |
| |
| template <typename Constraint, bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_arrays::wire::UnionLargeArray, Constraint, IsRecursive> { |
| static constexpr size_t kInlineSize = 16; |
| static constexpr bool kIsMemcpyCompatible = false; |
| |
| static void Encode(internal::WireEncoder* encoder, ::test_arrays::wire::UnionLargeArray* 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_arrays::wire::UnionLargeArray::Tag::kA |
| encode_inline_size = ::fidl::internal::WireCodingTraits<::fidl::Array<uint32_t, 100>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::kInlineSize; |
| break; |
| default: |
| encode_inline_size = 0; |
| break; |
| } |
| ::fidl::internal::EncodeFn<IsRecursive> encode_fn; |
| switch (u->tag) { |
| case 1: // ::test_arrays::wire::UnionLargeArray::Tag::kA |
| encode_fn = ::fidl::internal::MakeEncodeFn<::fidl::Array<uint32_t, 100>, 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_arrays::wire::UnionLargeArray::Tag tag = *position.As<::test_arrays::wire::UnionLargeArray::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_arrays::wire::UnionLargeArray::Tag::kA: |
| decode_inline_size = ::fidl::internal::WireCodingTraits<::fidl::Array<uint32_t, 100>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::kInlineSize; |
| break; |
| default: |
| decode_inline_size = 0; |
| break; |
| } |
| DecodeFn<IsRecursive> decode_fn; |
| switch (tag) { |
| case ::test_arrays::wire::UnionLargeArray::Tag::kA: |
| decode_fn = ::fidl::internal::MakeDecodeFn<::fidl::Array<uint32_t, 100>, fidl::internal::WireCodingConstraintEmpty, IsRecursive>(); |
| break; |
| default: |
| decode_fn = nullptr; |
| break; |
| } |
| ::fidl::internal::WireDecodeStrictEnvelope(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_arrays::wire::UnionLargeArray, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> |
| : public ::fidl::internal::WireCodingTraits<::test_arrays::wire::UnionLargeArray, ::fidl::internal::WireCodingConstraintUnion<false>, IsRecursive> {}; |
| |
| #pragma clang diagnostic pop |
| |
| } // namespace fidl |