| // 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/vmo.h> |
| |
| #endif // __Fuchsia__ |
| |
| #include <fidl/test.handlesintypes/cpp/common_types.h> |
| #include <fidl/test.handlesintypes/cpp/markers.h> |
| |
| namespace test_handlesintypes { |
| |
| namespace wire { |
| using ObjType = ::test_handlesintypes::ObjType; |
| |
| struct HandlesInTypes; |
| |
| class TableWithHandle; |
| |
| class UnionWithHandle; |
| |
| #ifdef __Fuchsia__ |
| |
| } // namespace wire |
| } // namespace test_handlesintypes |
| template <> |
| class ::fidl::WireTableBuilder<::test_handlesintypes::wire::TableWithHandle>; |
| template <> |
| class ::fidl::WireTableExternalBuilder<::test_handlesintypes::wire::TableWithHandle>; |
| |
| template <> |
| struct ::fidl::WireTableFrame<::test_handlesintypes::wire::TableWithHandle> 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<::zx::vmo> h_; |
| |
| friend class ::test_handlesintypes::wire::TableWithHandle; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_handlesintypes::wire::TableWithHandle, ::fidl::WireTableBuilder<::test_handlesintypes::wire::TableWithHandle>>; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_handlesintypes::wire::TableWithHandle, ::fidl::WireTableExternalBuilder<::test_handlesintypes::wire::TableWithHandle>>; |
| }; |
| |
| namespace test_handlesintypes { |
| namespace wire { |
| extern "C" const fidl_type_t test_handlesintypes_TableWithHandleTable; |
| |
| class TableWithHandle { |
| public: |
| TableWithHandle() = default; |
| TableWithHandle(const TableWithHandle& other) noexcept = default; |
| TableWithHandle& operator=(const TableWithHandle& other) noexcept = default; |
| TableWithHandle(TableWithHandle&& other) noexcept = default; |
| TableWithHandle& operator=(TableWithHandle&& other) noexcept = default; |
| |
| ~TableWithHandle() = default; |
| |
| // Returns whether no field is set. |
| bool IsEmpty() const { return max_ordinal_ == 0; } |
| |
| // Returns whether the table references unknown fields. |
| bool HasUnknownData() const; |
| void _CloseHandles(); |
| |
| // Return a builder that by defaults allocates of an arena. |
| static ::fidl::WireTableBuilder<::test_handlesintypes::wire::TableWithHandle> Builder(::fidl::AnyArena& arena); |
| |
| // Return a builder that relies on explicitly allocating |fidl::ObjectView|s. |
| static ::fidl::WireTableExternalBuilder<::test_handlesintypes::wire::TableWithHandle> ExternalBuilder(::fidl::ObjectView<::fidl::WireTableFrame<::test_handlesintypes::wire::TableWithHandle>> frame); |
| |
| const ::zx::vmo& h() const { |
| ZX_ASSERT(has_h()); |
| return frame_ptr_->h_.get_data(); |
| } |
| ::zx::vmo& h() { |
| ZX_ASSERT(has_h()); |
| return frame_ptr_->h_.get_data(); |
| } |
| bool has_h() const { |
| return max_ordinal_ >= 1 && frame_ptr_->h_.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 |
| |
| TableWithHandle& set_h(::zx::vmo elem) { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->h_.set_data(std::move(elem)); |
| max_ordinal_ = std::max(max_ordinal_, static_cast<uint64_t>(1)); |
| return *this; |
| } |
| |
| TableWithHandle& clear_h() { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->h_.clear_data(); |
| return *this; |
| } |
| |
| explicit TableWithHandle(::fidl::AnyArena& allocator) |
| : frame_ptr_(::fidl::ObjectView<::fidl::WireTableFrame<::test_handlesintypes::wire::TableWithHandle>>(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 TableWithHandle(::fidl::ObjectView<::fidl::WireTableFrame<::test_handlesintypes::wire::TableWithHandle>>&& frame) |
| : frame_ptr_(std::move(frame)) {} |
| |
| void Allocate(::fidl::AnyArena& allocator) { |
| max_ordinal_ = 0; |
| frame_ptr_ = ::fidl::ObjectView<::fidl::WireTableFrame<::test_handlesintypes::wire::TableWithHandle>>(allocator); |
| } |
| void Init(::fidl::ObjectView<::fidl::WireTableFrame<::test_handlesintypes::wire::TableWithHandle>>&& frame_ptr) { |
| max_ordinal_ = 0; |
| frame_ptr_ = std::move(frame_ptr); |
| } |
| |
| private: |
| friend ::fidl::internal::WireTableBaseBuilder<::test_handlesintypes::wire::TableWithHandle, ::fidl::WireTableBuilder<::test_handlesintypes::wire::TableWithHandle>>; |
| friend ::fidl::internal::WireTableBaseBuilder<::test_handlesintypes::wire::TableWithHandle, ::fidl::WireTableExternalBuilder<::test_handlesintypes::wire::TableWithHandle>>; |
| |
| uint64_t max_ordinal_ = 0; |
| ::fidl::ObjectView<::fidl::WireTableFrame<::test_handlesintypes::wire::TableWithHandle>> frame_ptr_; |
| }; |
| } // namespace wire |
| } // namespace test_handlesintypes |
| template <typename BuilderImpl> |
| class ::fidl::internal::WireTableBaseBuilder<::test_handlesintypes::wire::TableWithHandle, BuilderImpl> { |
| public: |
| // Build and return the table. The builder should not be used after this. |
| ::test_handlesintypes::wire::TableWithHandle Build() { |
| ZX_DEBUG_ASSERT(table_.frame_ptr_ != nullptr); |
| ::test_handlesintypes::wire::TableWithHandle t = std::move(table_); |
| // Poison this builder to prevent accidental reuse. |
| table_.frame_ptr_ = nullptr; |
| return t; |
| } |
| |
| BuilderImpl& h(::zx::vmo elem) { |
| ZX_DEBUG_ASSERT(table_.frame_ptr_ != nullptr); |
| table_.frame_ptr_->h_.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_handlesintypes::wire::TableWithHandle>>&& frame) |
| : table_(std::move(frame)) {} |
| |
| private: |
| ::test_handlesintypes::wire::TableWithHandle table_; |
| }; |
| |
| template <> |
| class ::fidl::WireTableBuilder<::test_handlesintypes::wire::TableWithHandle> final : public ::fidl::internal::WireTableBaseBuilder<::test_handlesintypes::wire::TableWithHandle, ::fidl::WireTableBuilder<::test_handlesintypes::wire::TableWithHandle>> { |
| using Base = ::fidl::internal::WireTableBaseBuilder<::test_handlesintypes::wire::TableWithHandle, ::fidl::WireTableBuilder<::test_handlesintypes::wire::TableWithHandle>>; |
| |
| public: |
| private: |
| friend class ::test_handlesintypes::wire::TableWithHandle; |
| WireTableBuilder(::fidl::AnyArena& arena) |
| : Base(::fidl::ObjectView<::fidl::WireTableFrame<::test_handlesintypes::wire::TableWithHandle>>(arena)), |
| arena_(arena) {} |
| |
| [[maybe_unused]] std::reference_wrapper<::fidl::AnyArena> arena_; |
| }; |
| |
| template <> |
| class ::fidl::WireTableExternalBuilder<::test_handlesintypes::wire::TableWithHandle> final : public ::fidl::internal::WireTableBaseBuilder<::test_handlesintypes::wire::TableWithHandle, ::fidl::WireTableExternalBuilder<::test_handlesintypes::wire::TableWithHandle>> { |
| using Base = ::fidl::internal::WireTableBaseBuilder<::test_handlesintypes::wire::TableWithHandle, ::fidl::WireTableExternalBuilder<::test_handlesintypes::wire::TableWithHandle>>; |
| |
| private: |
| friend class ::test_handlesintypes::wire::TableWithHandle; |
| using Base::Base; |
| WireTableExternalBuilder(::fidl::WireTableFrame<::test_handlesintypes::wire::TableWithHandle>* frame) |
| : Base(::fidl::ObjectView<::fidl::WireTableFrame<::test_handlesintypes::wire::TableWithHandle>>::FromExternal(frame)) {} |
| }; |
| namespace test_handlesintypes { |
| namespace wire { |
| inline ::fidl::WireTableBuilder<::test_handlesintypes::wire::TableWithHandle> TableWithHandle::Builder(::fidl::AnyArena& arena) { |
| return ::fidl::WireTableBuilder<::test_handlesintypes::wire::TableWithHandle>(arena); |
| } |
| inline ::fidl::WireTableExternalBuilder<::test_handlesintypes::wire::TableWithHandle> TableWithHandle::ExternalBuilder(::fidl::ObjectView<::fidl::WireTableFrame<::test_handlesintypes::wire::TableWithHandle>> frame) { |
| return ::fidl::WireTableExternalBuilder<::test_handlesintypes::wire::TableWithHandle>(std::move(frame)); |
| } |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| |
| extern "C" const fidl_type_t test_handlesintypes_UnionWithHandleTable; |
| |
| class UnionWithHandle { |
| public: |
| UnionWithHandle() : ordinal_(::test_handlesintypes::wire::UnionWithHandle::Ordinal::Invalid), envelope_{} {} |
| |
| ~UnionWithHandle(); |
| UnionWithHandle(UnionWithHandle&& other) { |
| _Move(std::move(other)); |
| } |
| UnionWithHandle& operator=(UnionWithHandle&& other) { |
| if (this != &other) { |
| _Move(std::move(other)); |
| } |
| return *this; |
| } |
| |
| enum class Tag : fidl_xunion_tag_t { |
| kH = 1, // 0x1 |
| kUnknown = ::std::numeric_limits<::fidl_union_tag_t>::max(), |
| }; |
| |
| bool has_invalid_tag() const { return ordinal_ == ::test_handlesintypes::wire::UnionWithHandle::Ordinal::Invalid; } |
| |
| bool is_h() const { return ordinal_ == ::test_handlesintypes::wire::UnionWithHandle::Ordinal::kH; } |
| |
| static UnionWithHandle WithH(::zx::vmo val) { |
| UnionWithHandle result; |
| result.ordinal_ = ::test_handlesintypes::wire::UnionWithHandle::Ordinal::kH; |
| result.envelope_.As<::zx::vmo>().set_data(std::move(val)); |
| return result; |
| } |
| |
| ::zx::vmo& h() { |
| ZX_ASSERT(ordinal_ == ::test_handlesintypes::wire::UnionWithHandle::Ordinal::kH); |
| return envelope_.As<::zx::vmo>().get_data(); |
| } |
| const ::zx::vmo& h() const { |
| ZX_ASSERT(ordinal_ == ::test_handlesintypes::wire::UnionWithHandle::Ordinal::kH); |
| return envelope_.As<::zx::vmo>().get_data(); |
| } |
| ::test_handlesintypes::wire::UnionWithHandle::Tag Which() const; |
| void _CloseHandles(); |
| |
| private: |
| enum class Ordinal : fidl_xunion_tag_t { |
| Invalid = 0, |
| kH = 1, // 0x1 |
| }; |
| void _Move(UnionWithHandle&& other); |
| |
| static void SizeAndOffsetAssertionHelper(); |
| ::test_handlesintypes::wire::UnionWithHandle::Ordinal ordinal_; |
| FIDL_ALIGNDECL |
| ::fidl::UntypedEnvelope envelope_; |
| }; |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| |
| extern "C" const fidl_type_t test_handlesintypes_HandlesInTypesTable; |
| |
| struct HandlesInTypes { |
| ::zx::vmo normal_handle = {}; |
| |
| ::fidl::VectorView<::zx::vmo> handle_in_vec = {}; |
| |
| ::fidl::Array<::zx::vmo, 5> handle_in_array = {}; |
| |
| ::fidl::VectorView<::fidl::Array<::zx::vmo, 5>> handle_in_mixed_vec_array = {}; |
| |
| ::test_handlesintypes::wire::TableWithHandle table_with_handle = {}; |
| |
| ::test_handlesintypes::wire::UnionWithHandle union_with_handle = {}; |
| |
| void _CloseHandles(); |
| }; |
| #endif // __Fuchsia__ |
| |
| } // namespace wire |
| } // namespace test_handlesintypes |
| namespace fidl { |
| |
| template <bool IsRecursive> |
| struct internal::WireCodingTraits<::test_handlesintypes::wire::ObjType, ::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_handlesintypes::wire::ObjType* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| switch (*value) { |
| case ::test_handlesintypes::wire::ObjType::kNone: |
| case ::test_handlesintypes::wire::ObjType::kVmo: |
| break; |
| default: |
| encoder->SetError(::fidl::internal::kCodingErrorUnknownEnumValue); |
| return; |
| } |
| *position.As<::test_handlesintypes::wire::ObjType>() = *value; |
| } |
| static void Decode(internal::WireDecoder* decoder, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| [[maybe_unused]] ::test_handlesintypes::wire::ObjType value = *position.As<::test_handlesintypes::wire::ObjType>(); |
| switch (value) { |
| case ::test_handlesintypes::wire::ObjType::kNone: |
| case ::test_handlesintypes::wire::ObjType::kVmo: |
| break; |
| default: |
| decoder->SetError(::fidl::internal::kCodingErrorUnknownEnumValue); |
| return; |
| } |
| } |
| }; |
| |
| #ifdef __Fuchsia__ |
| template <> |
| struct IsResource<::test_handlesintypes::wire::HandlesInTypes> : public std::true_type {}; |
| |
| // TODO(fxbug.dev/95833) Remove this. |
| template <> |
| struct DeprecatedCTypeTraits<::test_handlesintypes::wire::HandlesInTypes> { |
| static constexpr const fidl_type_t* kType = &::test_handlesintypes::wire::test_handlesintypes_HandlesInTypesTable; |
| }; |
| |
| template <> |
| struct TypeTraits<::test_handlesintypes::wire::HandlesInTypes> { |
| static constexpr uint32_t kMaxNumHandles = 4294967295; |
| static constexpr uint32_t kMaxDepth = 2; |
| static constexpr uint32_t kPrimarySize = 96; |
| static constexpr uint32_t kPrimarySizeV1 = 104; |
| [[maybe_unused]] static constexpr uint32_t kMaxOutOfLine = 4294967295; |
| static constexpr uint32_t kMaxOutOfLineV1 = 4294967295; |
| static constexpr bool kHasEnvelope = true; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_handlesintypes::wire::HandlesInTypes> : public std::true_type {}; |
| template <> |
| struct IsStruct<::test_handlesintypes::wire::HandlesInTypes> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_handlesintypes::wire::HandlesInTypes>); |
| static_assert(offsetof(::test_handlesintypes::wire::HandlesInTypes, normal_handle) == 0); |
| static_assert(offsetof(::test_handlesintypes::wire::HandlesInTypes, handle_in_vec) == 8); |
| static_assert(offsetof(::test_handlesintypes::wire::HandlesInTypes, handle_in_array) == 24); |
| static_assert(offsetof(::test_handlesintypes::wire::HandlesInTypes, handle_in_mixed_vec_array) == 48); |
| static_assert(offsetof(::test_handlesintypes::wire::HandlesInTypes, table_with_handle) == 64); |
| static_assert(offsetof(::test_handlesintypes::wire::HandlesInTypes, union_with_handle) == 80); |
| static_assert(sizeof(::test_handlesintypes::wire::HandlesInTypes) == TypeTraits<::test_handlesintypes::wire::HandlesInTypes>::kPrimarySize); |
| |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_handlesintypes::wire::HandlesInTypes, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> { |
| static constexpr size_t inline_size = 96; |
| static constexpr auto kMembers = std::make_tuple(::fidl::internal::WireStructMemberCodingInfo<::zx::vmo, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, IsRecursive>(), ::fidl::internal::WireStructMemberCodingInfo<::fidl::VectorView<::zx::vmo>, fidl::internal::WireCodingConstraintVector<fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, false>, IsRecursive>(), ::fidl::internal::WireStructMemberCodingInfo<::fidl::Array<::zx::vmo, 5>, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, IsRecursive>(), ::fidl::internal::WireStructMemberCodingInfo<::fidl::VectorView<::fidl::Array<::zx::vmo, 5>>, fidl::internal::WireCodingConstraintVector<fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, false>, IsRecursive>(), ::fidl::internal::WireStructMemberCodingInfo<::test_handlesintypes::wire::TableWithHandle, fidl::internal::WireCodingConstraintEmpty, IsRecursive>(), ::fidl::internal::WireStructMemberCodingInfo<::test_handlesintypes::wire::UnionWithHandle, fidl::internal::WireCodingConstraintUnion<false>, IsRecursive>()); |
| static constexpr bool kHasPadding = true; |
| using Base = WireStructCodingTraitsBase<::test_handlesintypes::wire::HandlesInTypes, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive>; |
| static constexpr bool is_memcpy_compatible = Base::is_memcpy_compatible; |
| |
| static void Encode( |
| internal::WireEncoder* encoder, ::test_handlesintypes::wire::HandlesInTypes* value, ::fidl::internal::WirePosition position, RecursionDepth<IsRecursive> recursion_depth) { |
| if constexpr (is_memcpy_compatible) { |
| memcpy(position.As<void>(), value, sizeof(::test_handlesintypes::wire::HandlesInTypes)); |
| } else { |
| internal::WireZeroPadding<uint64_t>(encoder, position + 0); |
| internal::WireZeroPadding<uint64_t>(encoder, position + 40); |
| internal::WireCodingTraits<::zx::vmo, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, IsRecursive>::Encode(encoder, &value->normal_handle, position + 0, recursion_depth); |
| internal::WireCodingTraits<::fidl::VectorView<::zx::vmo>, fidl::internal::WireCodingConstraintVector<fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, false>, IsRecursive>::Encode(encoder, &value->handle_in_vec, position + 8, recursion_depth); |
| internal::WireCodingTraits<::fidl::Array<::zx::vmo, 5>, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, IsRecursive>::Encode(encoder, &value->handle_in_array, position + 24, recursion_depth); |
| internal::WireCodingTraits<::fidl::VectorView<::fidl::Array<::zx::vmo, 5>>, fidl::internal::WireCodingConstraintVector<fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, false>, IsRecursive>::Encode(encoder, &value->handle_in_mixed_vec_array, position + 48, recursion_depth); |
| internal::WireCodingTraits<::test_handlesintypes::wire::TableWithHandle, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::Encode(encoder, &value->table_with_handle, position + 64, recursion_depth); |
| internal::WireCodingTraits<::test_handlesintypes::wire::UnionWithHandle, fidl::internal::WireCodingConstraintUnion<false>, IsRecursive>::Encode(encoder, &value->union_with_handle, position + 80, 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<::zx::vmo, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, IsRecursive>::Decode( |
| decoder, position + 0, recursion_depth); |
| internal::WireCodingTraits<::fidl::VectorView<::zx::vmo>, fidl::internal::WireCodingConstraintVector<fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, false>, IsRecursive>::Decode( |
| decoder, position + 8, recursion_depth); |
| internal::WireCodingTraits<::fidl::Array<::zx::vmo, 5>, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, IsRecursive>::Decode( |
| decoder, position + 24, recursion_depth); |
| internal::WireCodingTraits<::fidl::VectorView<::fidl::Array<::zx::vmo, 5>>, fidl::internal::WireCodingConstraintVector<fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, false>, IsRecursive>::Decode( |
| decoder, position + 48, recursion_depth); |
| internal::WireCodingTraits<::test_handlesintypes::wire::TableWithHandle, fidl::internal::WireCodingConstraintEmpty, IsRecursive>::Decode( |
| decoder, position + 64, recursion_depth); |
| internal::WireCodingTraits<::test_handlesintypes::wire::UnionWithHandle, fidl::internal::WireCodingConstraintUnion<false>, IsRecursive>::Decode( |
| decoder, position + 80, recursion_depth); |
| } |
| internal::WireCheckPadding<uint64_t>(decoder, position + 0, 0xffffffff00000000ull); |
| internal::WireCheckPadding<uint64_t>(decoder, position + 40, 0xffffffff00000000ull); |
| } |
| }; |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| template <> |
| struct IsResource<::test_handlesintypes::wire::TableWithHandle> : public std::true_type {}; |
| |
| template <> |
| struct TypeTraits<::test_handlesintypes::wire::TableWithHandle> { |
| static constexpr uint32_t kMaxNumHandles = 1; |
| 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_handlesintypes::wire::TableWithHandle> : public std::true_type {}; |
| template <> |
| struct IsTable<::test_handlesintypes::wire::TableWithHandle> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_handlesintypes::wire::TableWithHandle>); |
| |
| template <bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_handlesintypes::wire::TableWithHandle, ::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_handlesintypes::wire::TableWithHandle* 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<::zx::vmo, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, IsRecursive>::inline_size; |
| break; |
| } |
| ::fidl::internal::EncodeFn<IsRecursive> encode_fn = nullptr; |
| switch (i) { |
| case 0: |
| encode_fn = ::fidl::internal::MakeEncodeFn<::zx::vmo, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, 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<::zx::vmo, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, IsRecursive>::inline_size; |
| break; |
| } |
| DecodeFn<IsRecursive> decode_fn = nullptr; |
| switch (i) { |
| case 0: |
| decode_fn = ::fidl::internal::MakeDecodeFn<::zx::vmo, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, IsRecursive>(); |
| break; |
| } |
| ::fidl::internal::WireDecodeOptionalEnvelope(inline_size, decode_fn, decoder, vector_position + i * sizeof(fidl_envelope_v2_t), inner_depth); |
| } |
| } |
| }; |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| template <> |
| struct IsResource<::test_handlesintypes::wire::UnionWithHandle> : public std::true_type {}; |
| |
| template <> |
| struct TypeTraits<::test_handlesintypes::wire::UnionWithHandle> { |
| static constexpr uint32_t kMaxNumHandles = 1; |
| 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_handlesintypes::wire::UnionWithHandle> : public std::true_type {}; |
| template <> |
| struct IsUnion<::test_handlesintypes::wire::UnionWithHandle> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_handlesintypes::wire::UnionWithHandle>); |
| |
| template <typename Constraint, bool IsRecursive> |
| struct ::fidl::internal::WireCodingTraits<::test_handlesintypes::wire::UnionWithHandle, Constraint, IsRecursive> { |
| static constexpr size_t inline_size = 16; |
| static constexpr bool is_memcpy_compatible = false; |
| |
| static void Encode(internal::WireEncoder* encoder, ::test_handlesintypes::wire::UnionWithHandle* 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_handlesintypes::wire::UnionWithHandle::Tag::kH |
| inline_size = ::fidl::internal::WireCodingTraits<::zx::vmo, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, IsRecursive>::inline_size; |
| break; |
| default: |
| inline_size = 0; |
| break; |
| } |
| ::fidl::internal::EncodeFn<IsRecursive> encode_fn; |
| switch (u->tag) { |
| case 1: // ::test_handlesintypes::wire::UnionWithHandle::Tag::kH |
| encode_fn = ::fidl::internal::MakeEncodeFn<::zx::vmo, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, 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_handlesintypes::wire::UnionWithHandle::Tag tag = *position.As<::test_handlesintypes::wire::UnionWithHandle::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_handlesintypes::wire::UnionWithHandle::Tag::kH: |
| inline_size = ::fidl::internal::WireCodingTraits<::zx::vmo, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, IsRecursive>::inline_size; |
| break; |
| default: |
| inline_size = 0; |
| break; |
| } |
| DecodeFn<IsRecursive> decode_fn; |
| switch (tag) { |
| case ::test_handlesintypes::wire::UnionWithHandle::Tag::kH: |
| decode_fn = ::fidl::internal::MakeDecodeFn<::zx::vmo, fidl::internal::WireCodingConstraintHandle<ZX_OBJ_TYPE_VMO, 0x80000000, false>, 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_handlesintypes::wire::UnionWithHandle, ::fidl::internal::WireCodingConstraintEmpty, IsRecursive> |
| : public ::fidl::internal::WireCodingTraits<::test_handlesintypes::wire::UnionWithHandle, ::fidl::internal::WireCodingConstraintUnion<false>, IsRecursive> {}; |
| #endif // __Fuchsia__ |
| |
| } // namespace fidl |