| // 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/buffer_allocator.h> |
| #include <lib/fidl/llcpp/buffer_then_heap_allocator.h> |
| #include <lib/fidl/llcpp/coding.h> |
| #include <lib/fidl/llcpp/envelope.h> |
| #include <lib/fidl/llcpp/errors.h> |
| #include <lib/fidl/llcpp/memory.h> |
| #include <lib/fidl/llcpp/message.h> |
| #include <lib/fidl/llcpp/message_storage.h> |
| #include <lib/fidl/llcpp/string_view.h> |
| #include <lib/fidl/llcpp/tracking_ptr.h> |
| #include <lib/fidl/llcpp/traits.h> |
| #include <lib/fidl/llcpp/vector_view.h> |
| #include <lib/fit/function.h> |
| #include <lib/fit/optional.h> |
| |
| #include <variant> |
| #ifdef __Fuchsia__ |
| #include <lib/fidl/llcpp/client.h> |
| #include <lib/fidl/llcpp/connect_service.h> |
| #include <lib/fidl/llcpp/result.h> |
| #include <lib/fidl/llcpp/server.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/txn_header.h> |
| #include <lib/zx/channel.h> |
| #include <lib/zx/vmo.h> |
| #endif // __Fuchsia__ |
| #include <zircon/fidl.h> |
| #include <zx/llcpp/fidl.h> |
| |
| namespace llcpp { |
| |
| namespace fidl { |
| namespace test { |
| namespace nullable { |
| |
| struct StructWithNullableVector; |
| struct StructWithNullableUnion; |
| struct StructWithNullableStruct; |
| struct StructWithNullableString; |
| struct StructWithNullableRequest; |
| struct StructWithNullableProtocol; |
| struct StructWithNullableHandle; |
| class SimpleProtocol; |
| class SimpleUnion; |
| struct Int32Wrapper; |
| |
| extern "C" const fidl_type_t fidl_test_nullable_SimpleUnionTable; |
| |
| class SimpleUnion { |
| public: |
| SimpleUnion() : ordinal_(Ordinal::Invalid), envelope_{} {} |
| |
| SimpleUnion(SimpleUnion&&) = default; |
| SimpleUnion& operator=(SimpleUnion&&) = default; |
| |
| ~SimpleUnion() { reset_ptr(nullptr); } |
| |
| enum class Tag : fidl_xunion_tag_t { |
| kA = 1, // 0x1 |
| kB = 2, // 0x2 |
| }; |
| |
| bool has_invalid_tag() const { return ordinal_ == Ordinal::Invalid; } |
| |
| bool is_a() const { return ordinal_ == Ordinal::kA; } |
| |
| static SimpleUnion WithA(::fidl::tracking_ptr<int32_t>&& val) { |
| SimpleUnion result; |
| result.set_a(std::move(val)); |
| return result; |
| } |
| |
| void set_a(::fidl::tracking_ptr<int32_t>&& elem) { |
| ordinal_ = Ordinal::kA; |
| reset_ptr(static_cast<::fidl::tracking_ptr<void>>(std::move(elem))); |
| } |
| |
| int32_t& mutable_a() { |
| ZX_ASSERT(ordinal_ == Ordinal::kA); |
| return *static_cast<int32_t*>(envelope_.data.get()); |
| } |
| const int32_t& a() const { |
| ZX_ASSERT(ordinal_ == Ordinal::kA); |
| return *static_cast<int32_t*>(envelope_.data.get()); |
| } |
| |
| bool is_b() const { return ordinal_ == Ordinal::kB; } |
| |
| static SimpleUnion WithB(::fidl::tracking_ptr<float>&& val) { |
| SimpleUnion result; |
| result.set_b(std::move(val)); |
| return result; |
| } |
| |
| void set_b(::fidl::tracking_ptr<float>&& elem) { |
| ordinal_ = Ordinal::kB; |
| reset_ptr(static_cast<::fidl::tracking_ptr<void>>(std::move(elem))); |
| } |
| |
| float& mutable_b() { |
| ZX_ASSERT(ordinal_ == Ordinal::kB); |
| return *static_cast<float*>(envelope_.data.get()); |
| } |
| const float& b() const { |
| ZX_ASSERT(ordinal_ == Ordinal::kB); |
| return *static_cast<float*>(envelope_.data.get()); |
| } |
| Tag which() const { |
| ZX_ASSERT(!has_invalid_tag()); |
| return static_cast<Tag>(ordinal_); |
| } |
| |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_nullable_SimpleUnionTable; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 24; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 8; |
| static constexpr bool HasPointer = true; |
| |
| private: |
| enum class Ordinal : fidl_xunion_tag_t { |
| Invalid = 0, |
| kA = 1, // 0x1 |
| kB = 2, // 0x2 |
| }; |
| |
| void reset_ptr(::fidl::tracking_ptr<void>&& new_ptr) { |
| // To clear the existing value, std::move it and let it go out of scope. |
| switch (static_cast<fidl_xunion_tag_t>(ordinal_)) { |
| case 1: { |
| ::fidl::tracking_ptr<int32_t> to_destroy = |
| static_cast<::fidl::tracking_ptr<int32_t>>( |
| std::move(envelope_.data)); |
| break; |
| } |
| case 2: { |
| ::fidl::tracking_ptr<float> to_destroy = |
| static_cast<::fidl::tracking_ptr<float>>(std::move(envelope_.data)); |
| break; |
| } |
| } |
| |
| envelope_.data = std::move(new_ptr); |
| } |
| |
| static void SizeAndOffsetAssertionHelper(); |
| Ordinal ordinal_; |
| FIDL_ALIGNDECL |
| ::fidl::Envelope<void> envelope_; |
| }; |
| |
| extern "C" const fidl_type_t fidl_test_nullable_StructWithNullableVectorTable; |
| |
| struct StructWithNullableVector { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_nullable_StructWithNullableVectorTable; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 16; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 4294967295; |
| static constexpr bool HasPointer = true; |
| |
| ::fidl::VectorView<int32_t> val = {}; |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| StructWithNullableVector* value) |
| : message_(bytes, byte_size, sizeof(StructWithNullableVector), nullptr, |
| 0, 0) { |
| message_.LinearizeAndEncode<StructWithNullableVector>(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 |
| 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(StructWithNullableVector* value) |
| : bytes_(std::make_unique< |
| ::fidl::internal::AlignedBuffer<ZX_CHANNEL_MAX_MSG_BYTES>>()), |
| message_(bytes_->data(), ZX_CHANNEL_MAX_MSG_BYTES, 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 |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| std::unique_ptr<::fidl::internal::AlignedBuffer<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 StructWithNullableVector>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct StructWithNullableVector>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| |
| struct StructWithNullableVector* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct StructWithNullableVector*>(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(); } |
| |
| // These methods should only be used for testing purpose. |
| // They create an DecodedMessage using the bytes of an outgoing message and |
| // copying the handles. |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| UnownedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| OwnedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| |
| private: |
| DecodedMessage(::fidl::OutgoingMessage& outgoing_message) { |
| Init(outgoing_message, nullptr, 0); |
| if (ok()) { |
| Decode<struct StructWithNullableVector>(); |
| } |
| } |
| }; |
| }; |
| |
| extern "C" const fidl_type_t fidl_test_nullable_StructWithNullableUnionTable; |
| |
| struct StructWithNullableUnion { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_nullable_StructWithNullableUnionTable; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 24; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 8; |
| static constexpr bool HasPointer = true; |
| |
| ::llcpp::fidl::test::nullable::SimpleUnion val = {}; |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| StructWithNullableUnion* value) |
| : message_(bytes, byte_size, sizeof(StructWithNullableUnion), nullptr, |
| 0, 0) { |
| message_.LinearizeAndEncode<StructWithNullableUnion>(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 |
| 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(StructWithNullableUnion* value) |
| : message_(bytes_, sizeof(bytes_), 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 |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| FIDL_ALIGNDECL |
| uint8_t bytes_[FIDL_ALIGN(PrimarySize + MaxOutOfLine)]; |
| 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 StructWithNullableUnion>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct StructWithNullableUnion>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| |
| struct StructWithNullableUnion* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct StructWithNullableUnion*>(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(); } |
| |
| // These methods should only be used for testing purpose. |
| // They create an DecodedMessage using the bytes of an outgoing message and |
| // copying the handles. |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| UnownedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| OwnedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| |
| private: |
| DecodedMessage(::fidl::OutgoingMessage& outgoing_message) { |
| Init(outgoing_message, nullptr, 0); |
| if (ok()) { |
| Decode<struct StructWithNullableUnion>(); |
| } |
| } |
| }; |
| }; |
| |
| extern "C" const fidl_type_t fidl_test_nullable_StructWithNullableStructTable; |
| |
| struct StructWithNullableStruct { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_nullable_StructWithNullableStructTable; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 8; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 8; |
| static constexpr bool HasPointer = true; |
| |
| ::fidl::tracking_ptr<::llcpp::fidl::test::nullable::Int32Wrapper> val = {}; |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| StructWithNullableStruct* value) |
| : message_(bytes, byte_size, sizeof(StructWithNullableStruct), nullptr, |
| 0, 0) { |
| message_.LinearizeAndEncode<StructWithNullableStruct>(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 |
| 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(StructWithNullableStruct* value) |
| : message_(bytes_, sizeof(bytes_), 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 |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| FIDL_ALIGNDECL |
| uint8_t bytes_[FIDL_ALIGN(PrimarySize + MaxOutOfLine)]; |
| 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 StructWithNullableStruct>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct StructWithNullableStruct>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| |
| struct StructWithNullableStruct* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct StructWithNullableStruct*>(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(); } |
| |
| // These methods should only be used for testing purpose. |
| // They create an DecodedMessage using the bytes of an outgoing message and |
| // copying the handles. |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| UnownedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| OwnedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| |
| private: |
| DecodedMessage(::fidl::OutgoingMessage& outgoing_message) { |
| Init(outgoing_message, nullptr, 0); |
| if (ok()) { |
| Decode<struct StructWithNullableStruct>(); |
| } |
| } |
| }; |
| }; |
| |
| extern "C" const fidl_type_t fidl_test_nullable_StructWithNullableStringTable; |
| |
| struct StructWithNullableString { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_nullable_StructWithNullableStringTable; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 16; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 4294967295; |
| static constexpr bool HasPointer = true; |
| |
| ::fidl::StringView val = {}; |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| StructWithNullableString* value) |
| : message_(bytes, byte_size, sizeof(StructWithNullableString), nullptr, |
| 0, 0) { |
| message_.LinearizeAndEncode<StructWithNullableString>(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 |
| 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(StructWithNullableString* value) |
| : bytes_(std::make_unique< |
| ::fidl::internal::AlignedBuffer<ZX_CHANNEL_MAX_MSG_BYTES>>()), |
| message_(bytes_->data(), ZX_CHANNEL_MAX_MSG_BYTES, 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 |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| std::unique_ptr<::fidl::internal::AlignedBuffer<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 StructWithNullableString>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct StructWithNullableString>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| |
| struct StructWithNullableString* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct StructWithNullableString*>(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(); } |
| |
| // These methods should only be used for testing purpose. |
| // They create an DecodedMessage using the bytes of an outgoing message and |
| // copying the handles. |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| UnownedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| OwnedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| |
| private: |
| DecodedMessage(::fidl::OutgoingMessage& outgoing_message) { |
| Init(outgoing_message, nullptr, 0); |
| if (ok()) { |
| Decode<struct StructWithNullableString>(); |
| } |
| } |
| }; |
| }; |
| |
| #ifdef __Fuchsia__ |
| extern "C" const fidl_type_t fidl_test_nullable_StructWithNullableRequestTable; |
| |
| struct StructWithNullableRequest { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_nullable_StructWithNullableRequestTable; |
| static constexpr uint32_t MaxNumHandles = 1; |
| static constexpr uint32_t PrimarySize = 4; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0; |
| static constexpr bool HasPointer = false; |
| |
| ::zx::channel val = {}; |
| |
| void _CloseHandles(); |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| StructWithNullableRequest* value) |
| : message_(bytes, byte_size, sizeof(StructWithNullableRequest), |
| handles_, |
| std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) { |
| message_.LinearizeAndEncode<StructWithNullableRequest>(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 |
| 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(StructWithNullableRequest* value) |
| : message_(bytes_, sizeof(bytes_), 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 |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| FIDL_ALIGNDECL |
| uint8_t bytes_[FIDL_ALIGN(PrimarySize + MaxOutOfLine)]; |
| 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 StructWithNullableRequest>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct StructWithNullableRequest>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| ~DecodedMessage() { |
| if (ok() && (PrimaryObject() != nullptr)) { |
| PrimaryObject()->_CloseHandles(); |
| } |
| } |
| |
| struct StructWithNullableRequest* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct StructWithNullableRequest*>(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(); } |
| |
| // These methods should only be used for testing purpose. |
| // They create an DecodedMessage using the bytes of an outgoing message and |
| // copying the handles. |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| UnownedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| OwnedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| |
| private: |
| DecodedMessage(::fidl::OutgoingMessage& outgoing_message) { |
| zx_handle_info_t |
| handles[std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)]; |
| Init(outgoing_message, handles, |
| std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)); |
| if (ok()) { |
| Decode<struct StructWithNullableRequest>(); |
| } |
| } |
| }; |
| }; |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| extern "C" const fidl_type_t fidl_test_nullable_StructWithNullableProtocolTable; |
| |
| struct StructWithNullableProtocol { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_nullable_StructWithNullableProtocolTable; |
| static constexpr uint32_t MaxNumHandles = 1; |
| static constexpr uint32_t PrimarySize = 4; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0; |
| static constexpr bool HasPointer = false; |
| |
| ::zx::channel val = {}; |
| |
| void _CloseHandles(); |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| StructWithNullableProtocol* value) |
| : message_(bytes, byte_size, sizeof(StructWithNullableProtocol), |
| handles_, |
| std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) { |
| message_.LinearizeAndEncode<StructWithNullableProtocol>(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 |
| 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(StructWithNullableProtocol* value) |
| : message_(bytes_, sizeof(bytes_), 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 |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| FIDL_ALIGNDECL |
| uint8_t bytes_[FIDL_ALIGN(PrimarySize + MaxOutOfLine)]; |
| 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 StructWithNullableProtocol>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct StructWithNullableProtocol>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| ~DecodedMessage() { |
| if (ok() && (PrimaryObject() != nullptr)) { |
| PrimaryObject()->_CloseHandles(); |
| } |
| } |
| |
| struct StructWithNullableProtocol* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct StructWithNullableProtocol*>(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(); } |
| |
| // These methods should only be used for testing purpose. |
| // They create an DecodedMessage using the bytes of an outgoing message and |
| // copying the handles. |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| UnownedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| OwnedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| |
| private: |
| DecodedMessage(::fidl::OutgoingMessage& outgoing_message) { |
| zx_handle_info_t |
| handles[std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)]; |
| Init(outgoing_message, handles, |
| std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)); |
| if (ok()) { |
| Decode<struct StructWithNullableProtocol>(); |
| } |
| } |
| }; |
| }; |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| extern "C" const fidl_type_t fidl_test_nullable_StructWithNullableHandleTable; |
| |
| struct StructWithNullableHandle { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_nullable_StructWithNullableHandleTable; |
| static constexpr uint32_t MaxNumHandles = 1; |
| static constexpr uint32_t PrimarySize = 4; |
| [[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0; |
| static constexpr bool HasPointer = false; |
| |
| ::zx::vmo val = {}; |
| |
| void _CloseHandles(); |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| StructWithNullableHandle* value) |
| : message_(bytes, byte_size, sizeof(StructWithNullableHandle), handles_, |
| std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) { |
| message_.LinearizeAndEncode<StructWithNullableHandle>(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 |
| 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(StructWithNullableHandle* value) |
| : message_(bytes_, sizeof(bytes_), 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 |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| FIDL_ALIGNDECL |
| uint8_t bytes_[FIDL_ALIGN(PrimarySize + MaxOutOfLine)]; |
| 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 StructWithNullableHandle>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct StructWithNullableHandle>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| ~DecodedMessage() { |
| if (ok() && (PrimaryObject() != nullptr)) { |
| PrimaryObject()->_CloseHandles(); |
| } |
| } |
| |
| struct StructWithNullableHandle* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct StructWithNullableHandle*>(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(); } |
| |
| // These methods should only be used for testing purpose. |
| // They create an DecodedMessage using the bytes of an outgoing message and |
| // copying the handles. |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| UnownedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| OwnedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| |
| private: |
| DecodedMessage(::fidl::OutgoingMessage& outgoing_message) { |
| zx_handle_info_t |
| handles[std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)]; |
| Init(outgoing_message, handles, |
| std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)); |
| if (ok()) { |
| Decode<struct StructWithNullableHandle>(); |
| } |
| } |
| }; |
| }; |
| #endif // __Fuchsia__ |
| |
| extern "C" const fidl_type_t fidl_test_nullable_SimpleProtocolAddRequestTable; |
| extern "C" const fidl_type_t fidl_test_nullable_SimpleProtocolAddResponseTable; |
| |
| class SimpleProtocol final { |
| SimpleProtocol() = delete; |
| |
| public: |
| struct AddResponse final { |
| FIDL_ALIGNDECL |
| fidl_message_header_t _hdr; |
| int32_t sum; |
| explicit AddResponse(int32_t sum) : sum(sum) { _InitHeader(); } |
| AddResponse() { _InitHeader(); } |
| |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_nullable_SimpleProtocolAddResponseTable; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 24; |
| static constexpr uint32_t MaxOutOfLine = 0; |
| static constexpr bool HasFlexibleEnvelope = false; |
| static constexpr bool HasPointer = false; |
| static constexpr ::fidl::internal::TransactionalMessageKind MessageKind = |
| ::fidl::internal::TransactionalMessageKind::kResponse; |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* _bytes, uint32_t _byte_size, int32_t sum) |
| : message_(_bytes, _byte_size, sizeof(AddResponse), nullptr, 0, 0) { |
| FIDL_ALIGNDECL AddResponse _response{sum}; |
| message_.LinearizeAndEncode<AddResponse>(&_response); |
| } |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| AddResponse* response) |
| : message_(bytes, byte_size, sizeof(AddResponse), nullptr, 0, 0) { |
| message_.LinearizeAndEncode<AddResponse>(response); |
| } |
| 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 |
| bool ok() const { return message_.status() == ZX_OK; } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; } |
| |
| void Write(zx_handle_t client) { message_.Write(client); } |
| |
| private: |
| AddResponse& Message() { |
| return *reinterpret_cast<AddResponse*>(message_.bytes()); |
| } |
| ::fidl::OutgoingMessage message_; |
| }; |
| |
| class OwnedEncodedMessage final { |
| public: |
| explicit OwnedEncodedMessage(int32_t sum) |
| : message_(bytes_, sizeof(bytes_), sum) {} |
| explicit OwnedEncodedMessage(AddResponse* response) |
| : message_(bytes_, sizeof(bytes_), response) {} |
| 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 |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| void Write(zx_handle_t client) { message_.Write(client); } |
| |
| private: |
| FIDL_ALIGNDECL |
| uint8_t bytes_[PrimarySize + MaxOutOfLine]; |
| 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<AddResponse>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<AddResponse>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| |
| AddResponse* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<AddResponse*>(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(); } |
| |
| // These methods should only be used for testing purpose. |
| // They create an DecodedMessage using the bytes of an outgoing message |
| // and copying the handles. |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| UnownedEncodedMessage* outgoing_message) { |
| return DecodedMessage(outgoing_message->GetOutgoingMessage()); |
| } |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| OwnedEncodedMessage* outgoing_message) { |
| return DecodedMessage(outgoing_message->GetOutgoingMessage()); |
| } |
| |
| private: |
| DecodedMessage(::fidl::OutgoingMessage& outgoing_message) { |
| Init(outgoing_message, nullptr, 0); |
| if (ok()) { |
| Decode<AddResponse>(); |
| } |
| } |
| }; |
| |
| private: |
| void _InitHeader(); |
| }; |
| struct AddRequest final { |
| FIDL_ALIGNDECL |
| fidl_message_header_t _hdr; |
| int32_t a; |
| int32_t b; |
| explicit AddRequest(zx_txid_t _txid, int32_t a, int32_t b) : a(a), b(b) { |
| _InitHeader(_txid); |
| } |
| explicit AddRequest(zx_txid_t _txid) { _InitHeader(_txid); } |
| |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_nullable_SimpleProtocolAddRequestTable; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 24; |
| static constexpr uint32_t MaxOutOfLine = 0; |
| static constexpr uint32_t AltPrimarySize = 24; |
| static constexpr uint32_t AltMaxOutOfLine = 0; |
| static constexpr bool HasFlexibleEnvelope = false; |
| static constexpr bool HasPointer = false; |
| static constexpr ::fidl::internal::TransactionalMessageKind MessageKind = |
| ::fidl::internal::TransactionalMessageKind::kRequest; |
| using ResponseType = AddResponse; |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* _bytes, uint32_t _byte_size, |
| zx_txid_t _txid, int32_t a, int32_t b) |
| : message_(_bytes, _byte_size, sizeof(AddRequest), nullptr, 0, 0) { |
| FIDL_ALIGNDECL AddRequest _request(_txid, a, b); |
| message_.LinearizeAndEncode<AddRequest>(&_request); |
| } |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| AddRequest* request) |
| : message_(bytes, byte_size, sizeof(AddRequest), nullptr, 0, 0) { |
| message_.LinearizeAndEncode<AddRequest>(request); |
| } |
| 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 |
| bool ok() const { return message_.status() == ZX_OK; } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; } |
| |
| void Write(zx_handle_t client) { message_.Write(client); } |
| |
| private: |
| AddRequest& Message() { |
| return *reinterpret_cast<AddRequest*>(message_.bytes()); |
| } |
| ::fidl::OutgoingMessage message_; |
| }; |
| |
| class OwnedEncodedMessage final { |
| public: |
| explicit OwnedEncodedMessage(zx_txid_t _txid, int32_t a, int32_t b) |
| : message_(bytes_, sizeof(bytes_), _txid, a, b) {} |
| explicit OwnedEncodedMessage(AddRequest* request) |
| : message_(bytes_, sizeof(bytes_), request) {} |
| 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 |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| void Write(zx_handle_t client) { message_.Write(client); } |
| |
| private: |
| FIDL_ALIGNDECL |
| uint8_t bytes_[PrimarySize + MaxOutOfLine]; |
| 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<AddRequest>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<AddRequest>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| |
| AddRequest* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<AddRequest*>(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(); } |
| |
| // These methods should only be used for testing purpose. |
| // They create an DecodedMessage using the bytes of an outgoing message |
| // and copying the handles. |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| UnownedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| OwnedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| |
| private: |
| DecodedMessage(::fidl::OutgoingMessage& outgoing_message) { |
| Init(outgoing_message, nullptr, 0); |
| if (ok()) { |
| Decode<AddRequest>(); |
| } |
| } |
| }; |
| |
| private: |
| void _InitHeader(zx_txid_t _txid); |
| }; |
| |
| // Collection of return types of FIDL calls in this protocol. |
| class ResultOf final { |
| ResultOf() = delete; |
| |
| public: |
| class Add final : public ::fidl::Result { |
| public: |
| explicit Add(zx_handle_t _client, int32_t a, int32_t b); |
| Add(zx_handle_t _client, int32_t a, int32_t b, zx_time_t _deadline); |
| explicit Add(const ::fidl::Result& result) : ::fidl::Result(result) {} |
| Add(Add&&) = delete; |
| Add(const Add&) = delete; |
| Add* operator=(Add&&) = delete; |
| Add* operator=(const Add&) = delete; |
| ~Add() = default; |
| |
| AddResponse* Unwrap() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<AddResponse*>(bytes_); |
| } |
| const AddResponse* Unwrap() const { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<const AddResponse*>(bytes_); |
| } |
| |
| AddResponse& value() { return *Unwrap(); } |
| const AddResponse& value() const { return *Unwrap(); } |
| |
| AddResponse* operator->() { return &value(); } |
| const AddResponse* operator->() const { return &value(); } |
| |
| AddResponse& operator*() { return value(); } |
| const AddResponse& operator*() const { return value(); } |
| |
| private: |
| FIDL_ALIGNDECL |
| uint8_t bytes_[AddResponse::PrimarySize + AddResponse::MaxOutOfLine]; |
| }; |
| }; |
| |
| // Collection of return types of FIDL calls in this protocol, |
| // when the caller-allocate flavor or in-place call is used. |
| class UnownedResultOf final { |
| UnownedResultOf() = delete; |
| |
| public: |
| class Add final : public ::fidl::Result { |
| public: |
| explicit Add(zx_handle_t _client, uint8_t* _request_bytes, |
| uint32_t _request_byte_capacity, int32_t a, int32_t b, |
| uint8_t* _response_bytes, uint32_t _response_byte_capacity); |
| explicit Add(const ::fidl::Result& result) : ::fidl::Result(result) {} |
| Add(Add&&) = delete; |
| Add(const Add&) = delete; |
| Add* operator=(Add&&) = delete; |
| Add* operator=(const Add&) = delete; |
| ~Add() = default; |
| |
| AddResponse* Unwrap() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<AddResponse*>(bytes_); |
| } |
| const AddResponse* Unwrap() const { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<const AddResponse*>(bytes_); |
| } |
| |
| AddResponse& value() { return *Unwrap(); } |
| const AddResponse& value() const { return *Unwrap(); } |
| |
| AddResponse* operator->() { return &value(); } |
| const AddResponse* operator->() const { return &value(); } |
| |
| AddResponse& operator*() { return value(); } |
| const AddResponse& operator*() const { return value(); } |
| |
| private: |
| uint8_t* bytes_; |
| }; |
| }; |
| |
| // Methods to make a sync FIDL call directly on an unowned channel, avoiding |
| // setting up a client. |
| class Call final { |
| Call() = delete; |
| |
| public: |
| // Allocates 48 bytes of message buffer on the stack. No heap allocation |
| // necessary. |
| static ResultOf::Add Add(::zx::unowned_channel _client_end, int32_t a, |
| int32_t b) { |
| return ResultOf::Add(_client_end->get(), a, b); |
| } |
| |
| // Caller provides the backing storage for FIDL message via request and |
| // response buffers. |
| static UnownedResultOf::Add Add(::zx::unowned_channel _client_end, |
| ::fidl::BufferSpan _request_buffer, |
| int32_t a, int32_t b, |
| ::fidl::BufferSpan _response_buffer) { |
| return UnownedResultOf::Add( |
| _client_end->get(), _request_buffer.data, _request_buffer.capacity, a, |
| b, _response_buffer.data, _response_buffer.capacity); |
| } |
| }; |
| |
| class SyncClient final { |
| public: |
| SyncClient() = default; |
| explicit SyncClient(::zx::channel channel) : channel_(std::move(channel)) {} |
| ~SyncClient() = default; |
| SyncClient(SyncClient&&) = default; |
| SyncClient& operator=(SyncClient&&) = default; |
| |
| const ::zx::channel& channel() const { return channel_; } |
| |
| ::zx::channel* mutable_channel() { return &channel_; } |
| |
| // Allocates 48 bytes of message buffer on the stack. No heap allocation |
| // necessary. |
| ResultOf::Add Add(int32_t a, int32_t b) { |
| return ResultOf::Add(this->channel().get(), a, b); |
| } |
| |
| // Caller provides the backing storage for FIDL message via request and |
| // response buffers. |
| UnownedResultOf::Add Add(::fidl::BufferSpan _request_buffer, int32_t a, |
| int32_t b, ::fidl::BufferSpan _response_buffer) { |
| return UnownedResultOf::Add( |
| this->channel().get(), _request_buffer.data, _request_buffer.capacity, |
| a, b, _response_buffer.data, _response_buffer.capacity); |
| } |
| |
| private: |
| ::zx::channel channel_; |
| }; |
| |
| struct AsyncEventHandlers; |
| class AddResponseContext; |
| class ClientImpl; |
| |
| // Pure-virtual interface to be implemented by a server. |
| class Interface : public ::fidl::internal::IncomingMessageDispatcher { |
| public: |
| Interface() = default; |
| virtual ~Interface() = default; |
| |
| // The marker protocol type within which this |Interface| class is defined. |
| using _EnclosingProtocol = SimpleProtocol; |
| |
| class AddCompleterBase : public ::fidl::CompleterBase { |
| public: |
| // In the following methods, the return value indicates internal errors |
| // during the reply, such as encoding or writing to the transport. Note |
| // that any error will automatically lead to the destruction of the |
| // binding, after which the |on_unbound| callback will be triggered with a |
| // detailed reason. |
| // |
| // See //zircon/system/ulib/fidl/include/lib/fidl/llcpp/server.h. |
| // |
| // Because the reply status is identical to the unbinding status, it can |
| // be safely ignored. |
| ::fidl::Result Reply(int32_t sum); |
| ::fidl::Result Reply(::fidl::BufferSpan _buffer, int32_t sum); |
| |
| protected: |
| using ::fidl::CompleterBase::CompleterBase; |
| }; |
| |
| using AddCompleter = ::fidl::Completer<AddCompleterBase>; |
| |
| virtual void Add(int32_t a, int32_t b, AddCompleter::Sync& _completer) = 0; |
| |
| private: |
| ::fidl::DispatchResult dispatch_message(fidl_incoming_msg_t* msg, |
| ::fidl::Transaction* txn) final; |
| }; |
| |
| // Attempts to dispatch the incoming message to a handler function in the |
| // server implementation. If there is no matching handler, it returns false, |
| // leaving the message and transaction intact. In all other cases, it consumes |
| // the message and returns true. It is possible to chain multiple TryDispatch |
| // functions in this manner. |
| static ::fidl::DispatchResult TryDispatch(Interface* impl, |
| fidl_incoming_msg_t* msg, |
| ::fidl::Transaction* txn); |
| |
| // Dispatches the incoming message to one of the handlers functions in the |
| // protocol. If there is no matching handler, it closes all the handles in |
| // |msg| and closes the channel with a |ZX_ERR_NOT_SUPPORTED| epitaph, before |
| // returning false. The message should then be discarded. |
| static ::fidl::DispatchResult Dispatch(Interface* impl, |
| fidl_incoming_msg_t* msg, |
| ::fidl::Transaction* txn); |
| |
| // Same as |Dispatch|, but takes a |void*| instead of |Interface*|. |
| // Only used with |fidl::BindServer| to reduce template expansion. |
| // Do not call this method manually. Use |Dispatch| instead. |
| static ::fidl::DispatchResult TypeErasedDispatch(void* impl, |
| fidl_incoming_msg_t* msg, |
| ::fidl::Transaction* txn) { |
| return Dispatch(static_cast<Interface*>(impl), msg, txn); |
| } |
| |
| class EventSender; |
| class WeakEventSender; |
| }; |
| |
| extern "C" const fidl_type_t fidl_test_nullable_Int32WrapperTable; |
| |
| struct Int32Wrapper { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_nullable_Int32WrapperTable; |
| 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; |
| |
| int32_t val = {}; |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, |
| Int32Wrapper* value) |
| : message_(bytes, byte_size, sizeof(Int32Wrapper), nullptr, 0, 0) { |
| message_.LinearizeAndEncode<Int32Wrapper>(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 |
| 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(Int32Wrapper* value) |
| : message_(bytes_, sizeof(bytes_), 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 |
| bool ok() const { return message_.ok(); } |
| const char* error() const { return message_.error(); } |
| |
| ::fidl::OutgoingMessage& GetOutgoingMessage() { |
| return message_.GetOutgoingMessage(); |
| } |
| |
| private: |
| FIDL_ALIGNDECL |
| uint8_t bytes_[FIDL_ALIGN(PrimarySize + MaxOutOfLine)]; |
| 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 Int32Wrapper>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct Int32Wrapper>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| |
| struct Int32Wrapper* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct Int32Wrapper*>(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(); } |
| |
| // These methods should only be used for testing purpose. |
| // They create an DecodedMessage using the bytes of an outgoing message and |
| // copying the handles. |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| UnownedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| OwnedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| |
| private: |
| DecodedMessage(::fidl::OutgoingMessage& outgoing_message) { |
| Init(outgoing_message, nullptr, 0); |
| if (ok()) { |
| Decode<struct Int32Wrapper>(); |
| } |
| } |
| }; |
| }; |
| |
| } // namespace nullable |
| } // namespace test |
| } // namespace fidl |
| } // namespace llcpp |
| |
| namespace fidl { |
| |
| template <> |
| struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableVector> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::llcpp::fidl::test::nullable::StructWithNullableVector> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::llcpp::fidl::test::nullable::StructWithNullableVector>); |
| static_assert(offsetof(::llcpp::fidl::test::nullable::StructWithNullableVector, |
| val) == 0); |
| static_assert( |
| sizeof(::llcpp::fidl::test::nullable::StructWithNullableVector) == |
| ::llcpp::fidl::test::nullable::StructWithNullableVector::PrimarySize); |
| |
| template <> |
| struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableUnion> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::llcpp::fidl::test::nullable::StructWithNullableUnion> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::llcpp::fidl::test::nullable::StructWithNullableUnion>); |
| static_assert(offsetof(::llcpp::fidl::test::nullable::StructWithNullableUnion, |
| val) == 0); |
| static_assert( |
| sizeof(::llcpp::fidl::test::nullable::StructWithNullableUnion) == |
| ::llcpp::fidl::test::nullable::StructWithNullableUnion::PrimarySize); |
| |
| template <> |
| struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableStruct> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::llcpp::fidl::test::nullable::StructWithNullableStruct> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::llcpp::fidl::test::nullable::StructWithNullableStruct>); |
| static_assert(offsetof(::llcpp::fidl::test::nullable::StructWithNullableStruct, |
| val) == 0); |
| static_assert( |
| sizeof(::llcpp::fidl::test::nullable::StructWithNullableStruct) == |
| ::llcpp::fidl::test::nullable::StructWithNullableStruct::PrimarySize); |
| |
| template <> |
| struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableString> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::llcpp::fidl::test::nullable::StructWithNullableString> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::llcpp::fidl::test::nullable::StructWithNullableString>); |
| static_assert(offsetof(::llcpp::fidl::test::nullable::StructWithNullableString, |
| val) == 0); |
| static_assert( |
| sizeof(::llcpp::fidl::test::nullable::StructWithNullableString) == |
| ::llcpp::fidl::test::nullable::StructWithNullableString::PrimarySize); |
| |
| #ifdef __Fuchsia__ |
| template <> |
| struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableRequest> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::llcpp::fidl::test::nullable::StructWithNullableRequest> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::llcpp::fidl::test::nullable::StructWithNullableRequest>); |
| static_assert(offsetof(::llcpp::fidl::test::nullable::StructWithNullableRequest, |
| val) == 0); |
| static_assert( |
| sizeof(::llcpp::fidl::test::nullable::StructWithNullableRequest) == |
| ::llcpp::fidl::test::nullable::StructWithNullableRequest::PrimarySize); |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| template <> |
| struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableProtocol> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::llcpp::fidl::test::nullable::StructWithNullableProtocol> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::llcpp::fidl::test::nullable::StructWithNullableProtocol>); |
| static_assert( |
| offsetof(::llcpp::fidl::test::nullable::StructWithNullableProtocol, val) == |
| 0); |
| static_assert( |
| sizeof(::llcpp::fidl::test::nullable::StructWithNullableProtocol) == |
| ::llcpp::fidl::test::nullable::StructWithNullableProtocol::PrimarySize); |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| template <> |
| struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableHandle> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::llcpp::fidl::test::nullable::StructWithNullableHandle> |
| : public std::true_type {}; |
| static_assert(std::is_standard_layout_v< |
| ::llcpp::fidl::test::nullable::StructWithNullableHandle>); |
| static_assert(offsetof(::llcpp::fidl::test::nullable::StructWithNullableHandle, |
| val) == 0); |
| static_assert( |
| sizeof(::llcpp::fidl::test::nullable::StructWithNullableHandle) == |
| ::llcpp::fidl::test::nullable::StructWithNullableHandle::PrimarySize); |
| #endif // __Fuchsia__ |
| |
| template <> |
| struct IsFidlType<::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest> |
| : public std::true_type {}; |
| template <> |
| struct IsFidlMessage<::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest> |
| : public std::true_type {}; |
| static_assert( |
| sizeof(::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest) == |
| ::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest::PrimarySize); |
| static_assert( |
| offsetof(::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest, a) == |
| 16); |
| static_assert( |
| offsetof(::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest, b) == |
| 20); |
| |
| template <> |
| struct IsFidlType<::llcpp::fidl::test::nullable::SimpleProtocol::AddResponse> |
| : public std::true_type {}; |
| template <> |
| struct IsFidlMessage<::llcpp::fidl::test::nullable::SimpleProtocol::AddResponse> |
| : public std::true_type {}; |
| static_assert( |
| sizeof(::llcpp::fidl::test::nullable::SimpleProtocol::AddResponse) == |
| ::llcpp::fidl::test::nullable::SimpleProtocol::AddResponse::PrimarySize); |
| static_assert( |
| offsetof(::llcpp::fidl::test::nullable::SimpleProtocol::AddResponse, sum) == |
| 16); |
| |
| template <> |
| struct IsFidlType<::llcpp::fidl::test::nullable::SimpleUnion> |
| : public std::true_type {}; |
| template <> |
| struct IsUnion<::llcpp::fidl::test::nullable::SimpleUnion> |
| : public std::true_type {}; |
| static_assert( |
| std::is_standard_layout_v<::llcpp::fidl::test::nullable::SimpleUnion>); |
| |
| template <> |
| struct IsFidlType<::llcpp::fidl::test::nullable::Int32Wrapper> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::llcpp::fidl::test::nullable::Int32Wrapper> |
| : public std::true_type {}; |
| static_assert( |
| std::is_standard_layout_v<::llcpp::fidl::test::nullable::Int32Wrapper>); |
| static_assert(offsetof(::llcpp::fidl::test::nullable::Int32Wrapper, val) == 0); |
| static_assert(sizeof(::llcpp::fidl::test::nullable::Int32Wrapper) == |
| ::llcpp::fidl::test::nullable::Int32Wrapper::PrimarySize); |
| |
| } // namespace fidl |
| |
| namespace llcpp { |
| |
| namespace fidl { |
| namespace test { |
| namespace nullable { |
| |
| struct SimpleProtocol::AsyncEventHandlers {}; |
| |
| class SimpleProtocol::AddResponseContext |
| : public ::fidl::internal::ResponseContext { |
| public: |
| AddResponseContext(); |
| |
| virtual void OnReply(SimpleProtocol::AddResponse* message) = 0; |
| |
| private: |
| void OnReply(uint8_t* reply) override; |
| }; |
| |
| class SimpleProtocol::ClientImpl final : private ::fidl::internal::ClientBase { |
| public: |
| // Asynchronous variant of |SimpleProtocol.Add()|. Allocates 24 bytes of |
| // request buffer on the stack. The callback is stored on the heap. |
| ::fidl::Result Add(int32_t a, int32_t b, |
| ::fit::callback<void(AddResponse* response)> _cb); |
| // Asynchronous variant of |SimpleProtocol.Add()|. Caller provides the backing |
| // storage for FIDL message via request buffer. Ownership of _context is given |
| // unsafely to the binding until OnError() or OnReply() are called on it. |
| ::fidl::Result Add(::fidl::BufferSpan _request_buffer, int32_t a, int32_t b, |
| AddResponseContext* _context); |
| // Synchronous variant of |SimpleProtocol.Add()|. Allocates 48 bytes of |
| // message buffer on the stack. No heap allocation necessary. |
| ResultOf::Add Add_Sync(int32_t a, int32_t b); |
| |
| // Synchronous variant of |SimpleProtocol.Add()|. Caller provides the backing |
| // storage for FIDL message via request and response buffers. |
| UnownedResultOf::Add Add_Sync(::fidl::BufferSpan _request_buffer, int32_t a, |
| int32_t b, ::fidl::BufferSpan _response_buffer); |
| |
| private: |
| friend class ::fidl::Client<SimpleProtocol>; |
| |
| explicit ClientImpl(AsyncEventHandlers handlers) |
| : handlers_(std::move(handlers)) {} |
| |
| std::optional<::fidl::UnbindInfo> DispatchEvent( |
| fidl_incoming_msg_t* msg) override; |
| |
| AsyncEventHandlers handlers_; |
| }; |
| |
| // |EventSender| owns a server endpoint of a channel speaking |
| // the SimpleProtocol protocol, and can send events in that protocol. |
| class SimpleProtocol::EventSender { |
| public: |
| // Constructs an event sender with an invalid channel. |
| EventSender() = default; |
| |
| // TODO(fxbug.dev/65212): EventSender should take a ::fidl::ServerEnd. |
| explicit EventSender(::zx::channel server_end) |
| : server_end_(std::move(server_end)) {} |
| |
| // The underlying server channel endpoint, which may be replaced at run-time. |
| const ::zx::channel& channel() const { return server_end_; } |
| ::zx::channel& channel() { return server_end_; } |
| |
| // Whether the underlying channel is valid. |
| bool is_valid() const { return server_end_.is_valid(); } |
| |
| private: |
| ::zx::channel server_end_; |
| }; |
| |
| class SimpleProtocol::WeakEventSender { |
| public: |
| private: |
| friend class ::fidl::ServerBindingRef<SimpleProtocol>; |
| |
| explicit WeakEventSender( |
| std::weak_ptr<::fidl::internal::AsyncServerBinding<SimpleProtocol>> |
| binding) |
| : binding_(std::move(binding)) {} |
| |
| std::weak_ptr<::fidl::internal::AsyncServerBinding<SimpleProtocol>> binding_; |
| }; |
| |
| } // namespace nullable |
| } // namespace test |
| } // namespace fidl |
| } // namespace llcpp |