| // WARNING: This file is machine generated by fidlgen. |
| |
| #pragma once |
| |
| #include <lib/fidl/internal.h> |
| #include <lib/fidl/llcpp/array.h> |
| #include <lib/fidl/llcpp/coding.h> |
| #include <lib/fidl/llcpp/envelope.h> |
| #include <lib/fidl/llcpp/errors.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/vector_view.h> |
| #include <lib/fit/function.h> |
| #include <lib/stdcompat/optional.h> |
| |
| #include <algorithm> |
| #include <cstddef> |
| #include <variant> |
| #ifdef __Fuchsia__ |
| #include <lib/fidl/llcpp/client.h> |
| #include <lib/fidl/llcpp/client_end.h> |
| #include <lib/fidl/llcpp/connect_service.h> |
| #include <lib/fidl/llcpp/result.h> |
| #include <lib/fidl/llcpp/server.h> |
| #include <lib/fidl/llcpp/server_end.h> |
| #include <lib/fidl/llcpp/service_handler_interface.h> |
| #include <lib/fidl/llcpp/sync_call.h> |
| #include <lib/fidl/llcpp/transaction.h> |
| #include <lib/fidl/llcpp/wire_messaging.h> |
| #include <lib/fidl/txn_header.h> |
| #include <lib/zx/vmo.h> |
| |
| #endif // __Fuchsia__ |
| #include <zircon/fidl.h> |
| |
| namespace fidl_test_handlesintypes { |
| namespace wire { |
| |
| enum class obj_type : uint32_t { |
| |
| NONE = 0u, |
| |
| VMO = 3u, |
| }; |
| |
| class UnionWithHandle; |
| |
| class TableWithHandle; |
| |
| struct HandlesInTypes; |
| |
| #ifdef __Fuchsia__ |
| |
| extern "C" const fidl_type_t fidl_test_handlesintypes_UnionWithHandleTable; |
| |
| class UnionWithHandle { |
| public: |
| UnionWithHandle() |
| : ordinal_(::fidl_test_handlesintypes::wire::UnionWithHandle::Ordinal:: |
| Invalid), |
| envelope_{} {} |
| |
| UnionWithHandle(const UnionWithHandle&) = default; |
| UnionWithHandle& operator=(const UnionWithHandle&) = default; |
| UnionWithHandle(UnionWithHandle&&) = default; |
| UnionWithHandle& operator=(UnionWithHandle&&) = default; |
| |
| 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_ == |
| ::fidl_test_handlesintypes::wire::UnionWithHandle::Ordinal::Invalid; |
| } |
| |
| bool is_h() const { |
| return ordinal_ == |
| ::fidl_test_handlesintypes::wire::UnionWithHandle::Ordinal::kH; |
| } |
| |
| static UnionWithHandle WithH(::fidl::ObjectView<::zx::vmo> val) { |
| UnionWithHandle result; |
| result.set_h(val); |
| return result; |
| } |
| |
| template <typename... Args> |
| static UnionWithHandle WithH(::fidl::AnyAllocator& allocator, |
| Args&&... args) { |
| UnionWithHandle result; |
| result.set_h( |
| ::fidl::ObjectView<::zx::vmo>(allocator, std::forward<Args>(args)...)); |
| return result; |
| } |
| |
| void set_h(::fidl::ObjectView<::zx::vmo> elem) { |
| ordinal_ = ::fidl_test_handlesintypes::wire::UnionWithHandle::Ordinal::kH; |
| envelope_.data = |
| ::fidl::ObjectView<void>::FromExternal(static_cast<void*>(elem.get())); |
| } |
| |
| template <typename... Args> |
| void set_h(::fidl::AnyAllocator& allocator, Args&&... args) { |
| ordinal_ = ::fidl_test_handlesintypes::wire::UnionWithHandle::Ordinal::kH; |
| set_h( |
| ::fidl::ObjectView<::zx::vmo>(allocator, std::forward<Args>(args)...)); |
| } |
| |
| ::zx::vmo& mutable_h() { |
| ZX_ASSERT(ordinal_ == |
| ::fidl_test_handlesintypes::wire::UnionWithHandle::Ordinal::kH); |
| return *static_cast<::zx::vmo*>(envelope_.data.get()); |
| } |
| const ::zx::vmo& h() const { |
| ZX_ASSERT(ordinal_ == |
| ::fidl_test_handlesintypes::wire::UnionWithHandle::Ordinal::kH); |
| return *static_cast<::zx::vmo*>(envelope_.data.get()); |
| } |
| ::fidl_test_handlesintypes::wire::UnionWithHandle::Tag which() const; |
| |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_handlesintypes_UnionWithHandleTable; |
| static constexpr uint32_t MaxNumHandles = 1; |
| static constexpr uint32_t PrimarySize = 24; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 8; |
| static constexpr bool HasPointer = true; |
| |
| void _CloseHandles(); |
| |
| private: |
| enum class Ordinal : fidl_xunion_tag_t { |
| Invalid = 0, |
| kH = 1, // 0x1 |
| }; |
| |
| static void SizeAndOffsetAssertionHelper(); |
| ::fidl_test_handlesintypes::wire::UnionWithHandle::Ordinal ordinal_; |
| FIDL_ALIGNDECL |
| ::fidl::Envelope<void> envelope_; |
| }; |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| |
| extern "C" const fidl_type_t fidl_test_handlesintypes_TableWithHandleTable; |
| |
| class TableWithHandle final { |
| public: |
| // Returns whether no field is set. |
| bool IsEmpty() const { return max_ordinal_ == 0; } |
| |
| class Frame; |
| |
| const ::zx::vmo& h() const { |
| ZX_ASSERT(has_h()); |
| return *frame_ptr_->h_.data; |
| } |
| ::zx::vmo& h() { |
| ZX_ASSERT(has_h()); |
| return *frame_ptr_->h_.data; |
| } |
| bool has_h() const { |
| return max_ordinal_ >= 1 && frame_ptr_->h_.data != nullptr; |
| } |
| TableWithHandle& set_h(::fidl::ObjectView<::zx::vmo> elem) { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->h_.data = elem; |
| max_ordinal_ = std::max(max_ordinal_, static_cast<uint64_t>(1)); |
| return *this; |
| } |
| TableWithHandle& set_h(std::nullptr_t) { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->h_.data = nullptr; |
| return *this; |
| } |
| template <typename... Args> |
| TableWithHandle& set_h(::fidl::AnyAllocator& allocator, Args&&... args) { |
| ZX_DEBUG_ASSERT(frame_ptr_ != nullptr); |
| frame_ptr_->h_.data = |
| ::fidl::ObjectView<::zx::vmo>(allocator, std::forward<Args>(args)...); |
| max_ordinal_ = std::max(max_ordinal_, static_cast<uint64_t>(1)); |
| return *this; |
| } |
| |
| TableWithHandle() = default; |
| explicit TableWithHandle(::fidl::AnyAllocator& allocator) |
| : frame_ptr_(::fidl::ObjectView<Frame>(allocator)) {} |
| // This constructor allows a user controlled allocation (not using a |
| // FidlAllocator). 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<Frame>&& frame) |
| : frame_ptr_(std::move(frame)) {} |
| ~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; |
| |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_handlesintypes_TableWithHandleTable; |
| static constexpr uint32_t MaxNumHandles = 1; |
| static constexpr uint32_t PrimarySize = 16; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 24; |
| static constexpr bool HasPointer = true; |
| |
| void Allocate(::fidl::AnyAllocator& allocator) { |
| max_ordinal_ = 0; |
| frame_ptr_ = ::fidl::ObjectView<Frame>(allocator); |
| } |
| void Init(::fidl::ObjectView<Frame>&& frame_ptr) { |
| max_ordinal_ = 0; |
| frame_ptr_ = std::move(frame_ptr); |
| } |
| |
| void _CloseHandles(); |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| TableWithHandle* value) |
| : message_(bytes, byte_size, sizeof(TableWithHandle), handles_, |
| std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) { |
| message_.Encode<TableWithHandle>(value); |
| } |
| UnownedEncodedMessage(const UnownedEncodedMessage&) = delete; |
| UnownedEncodedMessage(UnownedEncodedMessage&&) = delete; |
| UnownedEncodedMessage* operator=(const UnownedEncodedMessage&) = delete; |
| UnownedEncodedMessage* operator=(UnownedEncodedMessage&&) = delete; |
| |
| zx_status_t status() const { return message_.status(); } |
| const char* status_string() const { return message_.status_string(); } |
| bool ok() const { return message_.status() == ZX_OK; } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; } |
| |
| private: |
| zx_handle_disposition_t |
| handles_[std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)]; |
| ::fidl::OutgoingMessage message_; |
| }; |
| |
| class OwnedEncodedMessage final { |
| public: |
| explicit OwnedEncodedMessage(TableWithHandle* value) |
| : message_(bytes_.data(), bytes_.size(), value) {} |
| OwnedEncodedMessage(const OwnedEncodedMessage&) = delete; |
| OwnedEncodedMessage(OwnedEncodedMessage&&) = delete; |
| OwnedEncodedMessage* operator=(const OwnedEncodedMessage&) = delete; |
| OwnedEncodedMessage* operator=(OwnedEncodedMessage&&) = delete; |
| |
| zx_status_t status() const { return message_.status(); } |
| const char* status_string() const { return message_.status_string(); } |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| ::fidl::internal::InlineMessageBuffer<40> bytes_; |
| UnownedEncodedMessage message_; |
| }; |
| |
| class DecodedMessage final : public ::fidl::internal::IncomingMessage { |
| public: |
| DecodedMessage(uint8_t* bytes, uint32_t byte_actual, |
| zx_handle_info_t* handles = nullptr, |
| uint32_t handle_actual = 0) |
| : ::fidl::internal::IncomingMessage(bytes, byte_actual, handles, |
| handle_actual) { |
| Decode<TableWithHandle>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<TableWithHandle>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| ~DecodedMessage() { |
| if (ok() && (PrimaryObject() != nullptr)) { |
| PrimaryObject()->_CloseHandles(); |
| } |
| } |
| |
| TableWithHandle* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<TableWithHandle*>(bytes()); |
| } |
| |
| // Release the ownership of the decoded message. That means that the handles |
| // won't be closed When the object is destroyed. After calling this method, |
| // the DecodedMessage object should not be used anymore. |
| void ReleasePrimaryObject() { ResetBytes(); } |
| }; |
| |
| // Frames are managed automatically by the FidlAllocator class. |
| // The only direct usage is when performance is key and a frame needs to be |
| // allocated outside a FidlAllocator. Once created, a frame can only be used |
| // for one single table. |
| class Frame final { |
| public: |
| Frame() = default; |
| // In its intended usage, Frame 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. |
| Frame(const Frame&) = delete; |
| Frame& operator=(const Frame&) = delete; |
| |
| private: |
| Frame(Frame&&) noexcept = default; |
| Frame& operator=(Frame&&) noexcept = default; |
| ::fidl::Envelope<::zx::vmo> h_; |
| |
| friend class TableWithHandle; |
| }; |
| |
| private: |
| uint64_t max_ordinal_ = 0; |
| ::fidl::ObjectView<Frame> frame_ptr_; |
| }; |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| |
| extern "C" const fidl_type_t fidl_test_handlesintypes_HandlesInTypesTable; |
| |
| struct HandlesInTypes { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_handlesintypes_HandlesInTypesTable; |
| static constexpr uint32_t MaxNumHandles = 4294967295; |
| static constexpr uint32_t PrimarySize = 104; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 4294967295; |
| static constexpr bool HasPointer = true; |
| |
| ::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 = |
| {}; |
| |
| ::fidl_test_handlesintypes::wire::TableWithHandle table_with_handle = {}; |
| |
| ::fidl_test_handlesintypes::wire::UnionWithHandle union_with_handle = {}; |
| |
| void _CloseHandles(); |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| HandlesInTypes* value) |
| : message_(bytes, byte_size, sizeof(HandlesInTypes), handles_, |
| std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) { |
| message_.Encode<HandlesInTypes>(value); |
| } |
| UnownedEncodedMessage(const UnownedEncodedMessage&) = delete; |
| UnownedEncodedMessage(UnownedEncodedMessage&&) = delete; |
| UnownedEncodedMessage* operator=(const UnownedEncodedMessage&) = delete; |
| UnownedEncodedMessage* operator=(UnownedEncodedMessage&&) = delete; |
| |
| zx_status_t status() const { return message_.status(); } |
| const char* status_string() const { return message_.status_string(); } |
| bool ok() const { return message_.status() == ZX_OK; } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; } |
| |
| private: |
| zx_handle_disposition_t |
| handles_[std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)]; |
| ::fidl::OutgoingMessage message_; |
| }; |
| |
| class OwnedEncodedMessage final { |
| public: |
| explicit OwnedEncodedMessage(HandlesInTypes* value) |
| : message_(bytes_.data(), bytes_.size(), value) {} |
| OwnedEncodedMessage(const OwnedEncodedMessage&) = delete; |
| OwnedEncodedMessage(OwnedEncodedMessage&&) = delete; |
| OwnedEncodedMessage* operator=(const OwnedEncodedMessage&) = delete; |
| OwnedEncodedMessage* operator=(OwnedEncodedMessage&&) = delete; |
| |
| zx_status_t status() const { return message_.status(); } |
| const char* status_string() const { return message_.status_string(); } |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| ::fidl::internal::BoxedMessageBuffer<ZX_CHANNEL_MAX_MSG_BYTES> bytes_; |
| UnownedEncodedMessage message_; |
| }; |
| |
| class DecodedMessage final : public ::fidl::internal::IncomingMessage { |
| public: |
| DecodedMessage(uint8_t* bytes, uint32_t byte_actual, |
| zx_handle_info_t* handles = nullptr, |
| uint32_t handle_actual = 0) |
| : ::fidl::internal::IncomingMessage(bytes, byte_actual, handles, |
| handle_actual) { |
| Decode<struct HandlesInTypes>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct HandlesInTypes>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| ~DecodedMessage() { |
| if (ok() && (PrimaryObject() != nullptr)) { |
| PrimaryObject()->_CloseHandles(); |
| } |
| } |
| |
| struct HandlesInTypes* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct HandlesInTypes*>(bytes()); |
| } |
| |
| // Release the ownership of the decoded message. That means that the handles |
| // won't be closed When the object is destroyed. After calling this method, |
| // the DecodedMessage object should not be used anymore. |
| void ReleasePrimaryObject() { ResetBytes(); } |
| }; |
| }; |
| #endif // __Fuchsia__ |
| |
| } // namespace wire |
| } // namespace fidl_test_handlesintypes |
| namespace fidl { |
| |
| template <> |
| struct IsFidlType<::fidl_test_handlesintypes::wire::obj_type> |
| : public std::true_type {}; |
| |
| #ifdef __Fuchsia__ |
| |
| template <> |
| struct IsFidlType<::fidl_test_handlesintypes::wire::UnionWithHandle> |
| : public std::true_type {}; |
| template <> |
| struct IsUnion<::fidl_test_handlesintypes::wire::UnionWithHandle> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::fidl_test_handlesintypes::wire::UnionWithHandle>); |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| |
| template <> |
| struct IsFidlType<::fidl_test_handlesintypes::wire::TableWithHandle> |
| : public std::true_type {}; |
| template <> |
| struct IsTable<::fidl_test_handlesintypes::wire::TableWithHandle> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::fidl_test_handlesintypes::wire::TableWithHandle>); |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| |
| template <> |
| struct IsFidlType<::fidl_test_handlesintypes::wire::HandlesInTypes> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::fidl_test_handlesintypes::wire::HandlesInTypes> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::fidl_test_handlesintypes::wire::HandlesInTypes>); |
| static_assert(offsetof(::fidl_test_handlesintypes::wire::HandlesInTypes, |
| normal_handle) == 0); |
| static_assert(offsetof(::fidl_test_handlesintypes::wire::HandlesInTypes, |
| handle_in_vec) == 8); |
| static_assert(offsetof(::fidl_test_handlesintypes::wire::HandlesInTypes, |
| handle_in_array) == 24); |
| static_assert(offsetof(::fidl_test_handlesintypes::wire::HandlesInTypes, |
| handle_in_mixed_vec_array) == 48); |
| static_assert(offsetof(::fidl_test_handlesintypes::wire::HandlesInTypes, |
| table_with_handle) == 64); |
| static_assert(offsetof(::fidl_test_handlesintypes::wire::HandlesInTypes, |
| union_with_handle) == 80); |
| static_assert(sizeof(::fidl_test_handlesintypes::wire::HandlesInTypes) == |
| ::fidl_test_handlesintypes::wire::HandlesInTypes::PrimarySize); |
| #endif // __Fuchsia__ |
| |
| } // namespace fidl |