|  | // 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/linearized_and_encoded.h> | 
|  | #include <lib/fidl/llcpp/memory.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 <variant> | 
|  | #ifdef __Fuchsia__ | 
|  | #include <lib/fidl/llcpp/client.h> | 
|  | #include <lib/fidl/llcpp/connect_service.h> | 
|  | #include <lib/fidl/llcpp/message.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; | 
|  | static constexpr bool IsResource = false; | 
|  |  | 
|  | 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; | 
|  | static constexpr bool IsResource = false; | 
|  |  | 
|  | ::fidl::VectorView<int32_t> val = {}; | 
|  | }; | 
|  |  | 
|  | 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; | 
|  | static constexpr bool IsResource = false; | 
|  |  | 
|  | ::llcpp::fidl::test::nullable::SimpleUnion val = {}; | 
|  | }; | 
|  |  | 
|  | 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; | 
|  | static constexpr bool IsResource = false; | 
|  |  | 
|  | ::fidl::tracking_ptr<::llcpp::fidl::test::nullable::Int32Wrapper> val = {}; | 
|  | }; | 
|  |  | 
|  | 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; | 
|  | static constexpr bool IsResource = false; | 
|  |  | 
|  | ::fidl::StringView val = {}; | 
|  | }; | 
|  |  | 
|  | 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; | 
|  | static constexpr bool IsResource = true; | 
|  |  | 
|  | ::zx::channel val = {}; | 
|  | }; | 
|  |  | 
|  | 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; | 
|  | static constexpr bool IsResource = true; | 
|  |  | 
|  | ::zx::channel val = {}; | 
|  | }; | 
|  |  | 
|  | 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; | 
|  | static constexpr bool IsResource = true; | 
|  |  | 
|  | ::zx::vmo val = {}; | 
|  | }; | 
|  |  | 
|  | 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 bool IsResource = false; | 
|  | static constexpr ::fidl::internal::TransactionalMessageKind MessageKind = | 
|  | ::fidl::internal::TransactionalMessageKind::kResponse; | 
|  |  | 
|  | 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 bool IsResource = false; | 
|  | static constexpr ::fidl::internal::TransactionalMessageKind MessageKind = | 
|  | ::fidl::internal::TransactionalMessageKind::kRequest; | 
|  | using ResponseType = AddResponse; | 
|  |  | 
|  | 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); | 
|  | 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_; | 
|  | }; | 
|  | }; | 
|  |  | 
|  | class AddUnownedResponse final { | 
|  | public: | 
|  | AddUnownedResponse(uint8_t* _bytes, uint32_t _byte_size, int32_t sum) | 
|  | : message_(_bytes, _byte_size, sizeof(AddResponse), nullptr, 0, 0) { | 
|  | // Destructors can't be called because it will lead to handle double close | 
|  | // (here and in fidl::Encode). | 
|  | FIDL_ALIGNDECL uint8_t _response_buffer[sizeof(AddResponse)]; | 
|  | auto& _response = *new (_response_buffer) AddResponse(sum); | 
|  | message_.LinearizeAndEncode(AddResponse::Type, &_response); | 
|  | } | 
|  |  | 
|  | zx_status_t status() const { return message_.status(); } | 
|  | bool ok() const { return message_.status() == ZX_OK; } | 
|  | const char* error() const { return message_.error(); } | 
|  | bool linearized() const { return message_.linearized(); } | 
|  | bool encoded() const { return message_.encoded(); } | 
|  |  | 
|  | ::fidl::internal::FidlMessage& GetFidlMessage() { return message_; } | 
|  |  | 
|  | void Write(zx_handle_t client) { message_.Write(client); } | 
|  |  | 
|  | private: | 
|  | AddResponse& Message() { | 
|  | return *reinterpret_cast<AddResponse*>(message_.bytes().data()); | 
|  | } | 
|  | ::fidl::internal::FidlMessage message_; | 
|  | }; | 
|  |  | 
|  | class AddOwnedResponse final { | 
|  | public: | 
|  | explicit AddOwnedResponse(int32_t sum) | 
|  | : message_(bytes_, sizeof(bytes_), sum) {} | 
|  |  | 
|  | zx_status_t status() const { return message_.status(); } | 
|  | bool ok() const { return message_.ok(); } | 
|  | const char* error() const { return message_.error(); } | 
|  | bool linearized() const { return message_.linearized(); } | 
|  | bool encoded() const { return message_.encoded(); } | 
|  |  | 
|  | ::fidl::internal::FidlMessage& GetFidlMessage() { | 
|  | return message_.GetFidlMessage(); | 
|  | } | 
|  |  | 
|  | void Write(zx_handle_t client) { message_.Write(client); } | 
|  |  | 
|  | private: | 
|  | FIDL_ALIGNDECL | 
|  | uint8_t bytes_[AddResponse::PrimarySize + AddResponse::MaxOutOfLine]; | 
|  | AddUnownedResponse message_; | 
|  | }; | 
|  |  | 
|  | class AddUnownedRequest final { | 
|  | public: | 
|  | AddUnownedRequest(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) { | 
|  | // Destructors can't be called because it will lead to handle double close | 
|  | // (here and in fidl::Encode). | 
|  | FIDL_ALIGNDECL uint8_t _request_buffer[sizeof(AddRequest)]; | 
|  | auto& _request = *new (_request_buffer) AddRequest(_txid, a, b); | 
|  | message_.LinearizeAndEncode(AddRequest::Type, &_request); | 
|  | } | 
|  |  | 
|  | zx_status_t status() const { return message_.status(); } | 
|  | bool ok() const { return message_.status() == ZX_OK; } | 
|  | const char* error() const { return message_.error(); } | 
|  | bool linearized() const { return message_.linearized(); } | 
|  | bool encoded() const { return message_.encoded(); } | 
|  |  | 
|  | ::fidl::internal::FidlMessage& GetFidlMessage() { return message_; } | 
|  |  | 
|  | void Write(zx_handle_t client) { message_.Write(client); } | 
|  |  | 
|  | private: | 
|  | AddRequest& Message() { | 
|  | return *reinterpret_cast<AddRequest*>(message_.bytes().data()); | 
|  | } | 
|  | ::fidl::internal::FidlMessage message_; | 
|  | }; | 
|  |  | 
|  | class AddOwnedRequest final { | 
|  | public: | 
|  | explicit AddOwnedRequest(zx_txid_t _txid, int32_t a, int32_t b) | 
|  | : message_(bytes_, sizeof(bytes_), _txid, a, b) {} | 
|  |  | 
|  | zx_status_t status() const { return message_.status(); } | 
|  | bool ok() const { return message_.ok(); } | 
|  | const char* error() const { return message_.error(); } | 
|  | bool linearized() const { return message_.linearized(); } | 
|  | bool encoded() const { return message_.encoded(); } | 
|  |  | 
|  | ::fidl::internal::FidlMessage& GetFidlMessage() { | 
|  | return message_.GetFidlMessage(); | 
|  | } | 
|  |  | 
|  | void Write(zx_handle_t client) { message_.Write(client); } | 
|  |  | 
|  | private: | 
|  | FIDL_ALIGNDECL | 
|  | uint8_t bytes_[AddRequest::PrimarySize + AddRequest::MaxOutOfLine]; | 
|  | AddUnownedRequest message_; | 
|  | }; | 
|  |  | 
|  | // 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::BytePart _request_buffer, int32_t a, | 
|  | int32_t b, | 
|  | ::fidl::BytePart _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::BytePart _request_buffer, int32_t a, | 
|  | int32_t b, ::fidl::BytePart _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: | 
|  | Interface() = default; | 
|  | virtual ~Interface() = default; | 
|  | using _Outer = SimpleProtocol; | 
|  | using _Base = ::fidl::CompleterBase; | 
|  |  | 
|  | class AddCompleterBase : public _Base { | 
|  | 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::BytePart _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; | 
|  | }; | 
|  |  | 
|  | // 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 bool TryDispatch(Interface* impl, fidl_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 bool Dispatch(Interface* impl, fidl_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 bool TypeErasedDispatch(void* impl, fidl_msg_t* msg, | 
|  | ::fidl::Transaction* txn) { | 
|  | return Dispatch(static_cast<Interface*>(impl), msg, txn); | 
|  | } | 
|  |  | 
|  | class EventSender; | 
|  | }; | 
|  |  | 
|  | 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; | 
|  | static constexpr bool IsResource = false; | 
|  |  | 
|  | int32_t val = {}; | 
|  | }; | 
|  |  | 
|  | }  // 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); | 
|  |  | 
|  | 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); | 
|  |  | 
|  | 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); | 
|  |  | 
|  | 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); | 
|  |  | 
|  | 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(int32_t sum)> _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::BytePart _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::BytePart _request_buffer, int32_t a, | 
|  | int32_t b, ::fidl::BytePart _response_buffer); | 
|  |  | 
|  | private: | 
|  | friend class ::fidl::Client<SimpleProtocol>; | 
|  |  | 
|  | ClientImpl(::zx::channel client_end, async_dispatcher_t* dispatcher, | 
|  | ::fidl::internal::TypeErasedOnUnboundFn on_unbound, | 
|  | AsyncEventHandlers handlers) | 
|  | : ::fidl::internal::ClientBase(std::move(client_end), dispatcher, | 
|  | std::move(on_unbound)), | 
|  | handlers_(std::move(handlers)) {} | 
|  |  | 
|  | std::optional<::fidl::UnbindInfo> DispatchEvent(fidl_msg_t* msg) override; | 
|  |  | 
|  | AsyncEventHandlers handlers_; | 
|  | }; | 
|  |  | 
|  | class SimpleProtocol::EventSender { | 
|  | public: | 
|  | private: | 
|  | friend class ::fidl::ServerBindingRef<SimpleProtocol>; | 
|  |  | 
|  | explicit EventSender(std::weak_ptr<::fidl::internal::AsyncBinding> binding) | 
|  | : binding_(std::move(binding)) {} | 
|  |  | 
|  | std::weak_ptr<::fidl::internal::AsyncBinding> binding_; | 
|  | }; | 
|  |  | 
|  | }  // namespace nullable | 
|  | }  // namespace test | 
|  | }  // namespace fidl | 
|  | }  // namespace llcpp |