| // 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/handle.h> |
| |
| #endif // __Fuchsia__ |
| #include <zircon/fidl.h> |
| #include <zx/llcpp/fidl.h> |
| |
| namespace fidl_test_encapsulatedstructs { |
| namespace wire { |
| struct NonInlineStructTestStruct; |
| |
| struct Int8Int32; |
| |
| struct Int16Int8; |
| |
| struct ArrayInt16Int8; |
| |
| struct StructPaddingTestStruct; |
| |
| struct TopLevelStruct; |
| |
| #ifdef __Fuchsia__ |
| |
| extern "C" const fidl_type_t |
| fidl_test_encapsulatedstructs_NonInlineStructTestStructTable; |
| |
| struct NonInlineStructTestStruct { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_encapsulatedstructs_NonInlineStructTestStructTable; |
| static constexpr uint32_t MaxNumHandles = 1; |
| static constexpr uint32_t PrimarySize = 16; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 8; |
| static constexpr bool HasPointer = true; |
| |
| ::fidl::ObjectView<::fidl_test_encapsulatedstructs::wire::Int16Int8> element = |
| {}; |
| |
| ::zx::handle h = {}; |
| |
| void _CloseHandles(); |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| NonInlineStructTestStruct* value) |
| : message_(bytes, byte_size, sizeof(NonInlineStructTestStruct), |
| handles_, |
| std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) { |
| message_.Encode<NonInlineStructTestStruct>(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(NonInlineStructTestStruct* 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<24> 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 NonInlineStructTestStruct>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct NonInlineStructTestStruct>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| ~DecodedMessage() { |
| if (ok() && (PrimaryObject() != nullptr)) { |
| PrimaryObject()->_CloseHandles(); |
| } |
| } |
| |
| struct NonInlineStructTestStruct* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct NonInlineStructTestStruct*>(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__ |
| |
| extern "C" const fidl_type_t fidl_test_encapsulatedstructs_Int8Int32Table; |
| |
| struct Int8Int32 { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_encapsulatedstructs_Int8Int32Table; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 8; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0; |
| static constexpr bool HasPointer = false; |
| |
| int8_t a = {}; |
| |
| int32_t b = {}; |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, Int8Int32* value) |
| : message_(bytes, byte_size, sizeof(Int8Int32), nullptr, 0, 0) { |
| message_.Encode<Int8Int32>(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(); } |
| #ifdef __Fuchsia__ |
| const char* status_string() const { return message_.status_string(); } |
| #endif // __Fuchsia__ |
| bool ok() const { return message_.status() == ZX_OK; } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; } |
| |
| private: |
| ::fidl::OutgoingMessage message_; |
| }; |
| |
| class OwnedEncodedMessage final { |
| public: |
| explicit OwnedEncodedMessage(Int8Int32* 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(); } |
| #ifdef __Fuchsia__ |
| const char* status_string() const { return message_.status_string(); } |
| #endif // __Fuchsia__ |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| ::fidl::internal::InlineMessageBuffer<8> 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 Int8Int32>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct Int8Int32>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| |
| struct Int8Int32* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct Int8Int32*>(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(); } |
| }; |
| }; |
| |
| extern "C" const fidl_type_t fidl_test_encapsulatedstructs_Int16Int8Table; |
| |
| struct Int16Int8 { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_encapsulatedstructs_Int16Int8Table; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 4; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0; |
| static constexpr bool HasPointer = false; |
| |
| int16_t a = {}; |
| |
| int8_t b = {}; |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, Int16Int8* value) |
| : message_(bytes, byte_size, sizeof(Int16Int8), nullptr, 0, 0) { |
| message_.Encode<Int16Int8>(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(); } |
| #ifdef __Fuchsia__ |
| const char* status_string() const { return message_.status_string(); } |
| #endif // __Fuchsia__ |
| bool ok() const { return message_.status() == ZX_OK; } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; } |
| |
| private: |
| ::fidl::OutgoingMessage message_; |
| }; |
| |
| class OwnedEncodedMessage final { |
| public: |
| explicit OwnedEncodedMessage(Int16Int8* 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(); } |
| #ifdef __Fuchsia__ |
| const char* status_string() const { return message_.status_string(); } |
| #endif // __Fuchsia__ |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| ::fidl::internal::InlineMessageBuffer<8> 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 Int16Int8>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct Int16Int8>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| |
| struct Int16Int8* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct Int16Int8*>(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(); } |
| }; |
| }; |
| |
| extern "C" const fidl_type_t fidl_test_encapsulatedstructs_ArrayInt16Int8Table; |
| |
| struct ArrayInt16Int8 { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_encapsulatedstructs_ArrayInt16Int8Table; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 12; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0; |
| static constexpr bool HasPointer = false; |
| |
| ::fidl::Array<::fidl_test_encapsulatedstructs::wire::Int16Int8, 3> arr = {}; |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| ArrayInt16Int8* value) |
| : message_(bytes, byte_size, sizeof(ArrayInt16Int8), nullptr, 0, 0) { |
| message_.Encode<ArrayInt16Int8>(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(); } |
| #ifdef __Fuchsia__ |
| const char* status_string() const { return message_.status_string(); } |
| #endif // __Fuchsia__ |
| bool ok() const { return message_.status() == ZX_OK; } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; } |
| |
| private: |
| ::fidl::OutgoingMessage message_; |
| }; |
| |
| class OwnedEncodedMessage final { |
| public: |
| explicit OwnedEncodedMessage(ArrayInt16Int8* 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(); } |
| #ifdef __Fuchsia__ |
| const char* status_string() const { return message_.status_string(); } |
| #endif // __Fuchsia__ |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| ::fidl::internal::InlineMessageBuffer<16> 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 ArrayInt16Int8>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct ArrayInt16Int8>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| |
| struct ArrayInt16Int8* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct ArrayInt16Int8*>(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(); } |
| }; |
| }; |
| |
| extern "C" const fidl_type_t |
| fidl_test_encapsulatedstructs_StructPaddingTestStructTable; |
| |
| struct StructPaddingTestStruct { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_encapsulatedstructs_StructPaddingTestStructTable; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 24; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0; |
| static constexpr bool HasPointer = false; |
| |
| ::fidl_test_encapsulatedstructs::wire::Int16Int8 trailing = {}; |
| |
| ::fidl_test_encapsulatedstructs::wire::Int8Int32 inner = {}; |
| |
| ::fidl_test_encapsulatedstructs::wire::ArrayInt16Int8 array = {}; |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| StructPaddingTestStruct* value) |
| : message_(bytes, byte_size, sizeof(StructPaddingTestStruct), nullptr, |
| 0, 0) { |
| message_.Encode<StructPaddingTestStruct>(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(); } |
| #ifdef __Fuchsia__ |
| const char* status_string() const { return message_.status_string(); } |
| #endif // __Fuchsia__ |
| bool ok() const { return message_.status() == ZX_OK; } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; } |
| |
| private: |
| ::fidl::OutgoingMessage message_; |
| }; |
| |
| class OwnedEncodedMessage final { |
| public: |
| explicit OwnedEncodedMessage(StructPaddingTestStruct* 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(); } |
| #ifdef __Fuchsia__ |
| const char* status_string() const { return message_.status_string(); } |
| #endif // __Fuchsia__ |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| ::fidl::internal::InlineMessageBuffer<24> 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 StructPaddingTestStruct>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct StructPaddingTestStruct>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| |
| struct StructPaddingTestStruct* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct StructPaddingTestStruct*>(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(); } |
| }; |
| }; |
| |
| #ifdef __Fuchsia__ |
| |
| extern "C" const fidl_type_t fidl_test_encapsulatedstructs_TopLevelStructTable; |
| |
| struct TopLevelStruct { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_encapsulatedstructs_TopLevelStructTable; |
| static constexpr uint32_t MaxNumHandles = 1; |
| static constexpr uint32_t PrimarySize = 40; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 8; |
| static constexpr bool HasPointer = true; |
| |
| ::fidl_test_encapsulatedstructs::wire::StructPaddingTestStruct a = {}; |
| |
| ::fidl_test_encapsulatedstructs::wire::NonInlineStructTestStruct b = {}; |
| |
| void _CloseHandles(); |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| TopLevelStruct* value) |
| : message_(bytes, byte_size, sizeof(TopLevelStruct), handles_, |
| std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) { |
| message_.Encode<TopLevelStruct>(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(TopLevelStruct* 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<48> 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 TopLevelStruct>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct TopLevelStruct>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| ~DecodedMessage() { |
| if (ok() && (PrimaryObject() != nullptr)) { |
| PrimaryObject()->_CloseHandles(); |
| } |
| } |
| |
| struct TopLevelStruct* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct TopLevelStruct*>(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_encapsulatedstructs |
| namespace fidl { |
| |
| #ifdef __Fuchsia__ |
| |
| template <> |
| struct IsFidlType< |
| ::fidl_test_encapsulatedstructs::wire::NonInlineStructTestStruct> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct< |
| ::fidl_test_encapsulatedstructs::wire::NonInlineStructTestStruct> |
| : public std::true_type {}; |
| static_assert( |
| std::is_standard_layout_v< |
| ::fidl_test_encapsulatedstructs::wire::NonInlineStructTestStruct>); |
| static_assert( |
| offsetof(::fidl_test_encapsulatedstructs::wire::NonInlineStructTestStruct, |
| element) == 0); |
| static_assert( |
| offsetof(::fidl_test_encapsulatedstructs::wire::NonInlineStructTestStruct, |
| h) == 8); |
| static_assert( |
| sizeof(::fidl_test_encapsulatedstructs::wire::NonInlineStructTestStruct) == |
| ::fidl_test_encapsulatedstructs::wire::NonInlineStructTestStruct:: |
| PrimarySize); |
| #endif // __Fuchsia__ |
| |
| template <> |
| struct IsFidlType<::fidl_test_encapsulatedstructs::wire::Int8Int32> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::fidl_test_encapsulatedstructs::wire::Int8Int32> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::fidl_test_encapsulatedstructs::wire::Int8Int32>); |
| static_assert(offsetof(::fidl_test_encapsulatedstructs::wire::Int8Int32, a) == |
| 0); |
| static_assert(offsetof(::fidl_test_encapsulatedstructs::wire::Int8Int32, b) == |
| 4); |
| static_assert(sizeof(::fidl_test_encapsulatedstructs::wire::Int8Int32) == |
| ::fidl_test_encapsulatedstructs::wire::Int8Int32::PrimarySize); |
| |
| template <> |
| struct IsFidlType<::fidl_test_encapsulatedstructs::wire::Int16Int8> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::fidl_test_encapsulatedstructs::wire::Int16Int8> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::fidl_test_encapsulatedstructs::wire::Int16Int8>); |
| static_assert(offsetof(::fidl_test_encapsulatedstructs::wire::Int16Int8, a) == |
| 0); |
| static_assert(offsetof(::fidl_test_encapsulatedstructs::wire::Int16Int8, b) == |
| 2); |
| static_assert(sizeof(::fidl_test_encapsulatedstructs::wire::Int16Int8) == |
| ::fidl_test_encapsulatedstructs::wire::Int16Int8::PrimarySize); |
| |
| template <> |
| struct IsFidlType<::fidl_test_encapsulatedstructs::wire::ArrayInt16Int8> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::fidl_test_encapsulatedstructs::wire::ArrayInt16Int8> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::fidl_test_encapsulatedstructs::wire::ArrayInt16Int8>); |
| static_assert(offsetof(::fidl_test_encapsulatedstructs::wire::ArrayInt16Int8, |
| arr) == 0); |
| static_assert( |
| sizeof(::fidl_test_encapsulatedstructs::wire::ArrayInt16Int8) == |
| ::fidl_test_encapsulatedstructs::wire::ArrayInt16Int8::PrimarySize); |
| |
| template <> |
| struct IsFidlType< |
| ::fidl_test_encapsulatedstructs::wire::StructPaddingTestStruct> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::fidl_test_encapsulatedstructs::wire::StructPaddingTestStruct> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::fidl_test_encapsulatedstructs::wire::StructPaddingTestStruct>); |
| static_assert( |
| offsetof(::fidl_test_encapsulatedstructs::wire::StructPaddingTestStruct, |
| trailing) == 0); |
| static_assert( |
| offsetof(::fidl_test_encapsulatedstructs::wire::StructPaddingTestStruct, |
| inner) == 4); |
| static_assert( |
| offsetof(::fidl_test_encapsulatedstructs::wire::StructPaddingTestStruct, |
| array) == 12); |
| static_assert( |
| sizeof(::fidl_test_encapsulatedstructs::wire::StructPaddingTestStruct) == |
| ::fidl_test_encapsulatedstructs::wire::StructPaddingTestStruct:: |
| PrimarySize); |
| |
| #ifdef __Fuchsia__ |
| |
| template <> |
| struct IsFidlType<::fidl_test_encapsulatedstructs::wire::TopLevelStruct> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::fidl_test_encapsulatedstructs::wire::TopLevelStruct> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::fidl_test_encapsulatedstructs::wire::TopLevelStruct>); |
| static_assert(offsetof(::fidl_test_encapsulatedstructs::wire::TopLevelStruct, |
| a) == 0); |
| static_assert(offsetof(::fidl_test_encapsulatedstructs::wire::TopLevelStruct, |
| b) == 24); |
| static_assert( |
| sizeof(::fidl_test_encapsulatedstructs::wire::TopLevelStruct) == |
| ::fidl_test_encapsulatedstructs::wire::TopLevelStruct::PrimarySize); |
| #endif // __Fuchsia__ |
| |
| } // namespace fidl |