| // 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 <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/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> |
| #endif // __Fuchsia__ |
| #include <bottom/llcpp/fidl.h> |
| #include <middle/llcpp/fidl.h> |
| #include <zircon/fidl.h> |
| |
| namespace llcpp { |
| |
| namespace top { |
| |
| class Top; |
| |
| extern "C" const fidl_type_t top_TopGetFooRequestTable; |
| extern "C" const fidl_type_t top_TopGetFooResponseTable; |
| |
| class Top final { |
| Top() = delete; |
| |
| public: |
| struct GetFooResponse final { |
| FIDL_ALIGNDECL |
| fidl_message_header_t _hdr; |
| ::llcpp::bottom::Foo foo; |
| explicit GetFooResponse(::llcpp::bottom::Foo& foo) : foo(std::move(foo)) { |
| _InitHeader(); |
| } |
| GetFooResponse() { _InitHeader(); } |
| |
| static constexpr const fidl_type_t* Type = &top_TopGetFooResponseTable; |
| 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; |
| |
| class UnownedOutgoingMessage final { |
| public: |
| UnownedOutgoingMessage(uint8_t* _bytes, uint32_t _byte_size, |
| ::llcpp::bottom::Foo& foo) |
| : message_(_bytes, _byte_size, sizeof(GetFooResponse), 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(GetFooResponse)]; |
| auto& _response = *new (_response_buffer) GetFooResponse(foo); |
| message_.LinearizeAndEncode<GetFooResponse>(&_response); |
| } |
| |
| zx_status_t status() const { return message_.status(); } |
| 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: |
| GetFooResponse& Message() { |
| return *reinterpret_cast<GetFooResponse*>(message_.bytes()); |
| } |
| ::fidl::OutgoingMessage message_; |
| }; |
| |
| class OwnedOutgoingMessage final { |
| public: |
| explicit OwnedOutgoingMessage(::llcpp::bottom::Foo& foo) |
| : message_(bytes_, sizeof(bytes_), foo) {} |
| |
| zx_status_t status() const { return message_.status(); } |
| 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_[GetFooResponse::PrimarySize + GetFooResponse::MaxOutOfLine]; |
| UnownedOutgoingMessage message_; |
| }; |
| |
| private: |
| void _InitHeader(); |
| }; |
| struct GetFooRequest final { |
| FIDL_ALIGNDECL |
| fidl_message_header_t _hdr; |
| explicit GetFooRequest(zx_txid_t _txid) { _InitHeader(_txid); } |
| |
| static constexpr const fidl_type_t* Type = |
| &::fidl::_llcpp_coding_AnyZeroArgMessageTable; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 16; |
| static constexpr uint32_t MaxOutOfLine = 0; |
| static constexpr uint32_t AltPrimarySize = 16; |
| 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 = GetFooResponse; |
| |
| class UnownedOutgoingMessage final { |
| public: |
| UnownedOutgoingMessage(uint8_t* _bytes, uint32_t _byte_size, |
| zx_txid_t _txid) |
| : message_(_bytes, _byte_size, sizeof(GetFooRequest), 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(GetFooRequest)]; |
| auto& _request = *new (_request_buffer) GetFooRequest(_txid); |
| message_.LinearizeAndEncode<GetFooRequest>(&_request); |
| } |
| |
| zx_status_t status() const { return message_.status(); } |
| 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: |
| GetFooRequest& Message() { |
| return *reinterpret_cast<GetFooRequest*>(message_.bytes()); |
| } |
| ::fidl::OutgoingMessage message_; |
| }; |
| |
| class OwnedOutgoingMessage final { |
| public: |
| explicit OwnedOutgoingMessage(zx_txid_t _txid) |
| : message_(bytes_, sizeof(bytes_), _txid) {} |
| |
| zx_status_t status() const { return message_.status(); } |
| 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_[GetFooRequest::PrimarySize + GetFooRequest::MaxOutOfLine]; |
| UnownedOutgoingMessage message_; |
| }; |
| |
| private: |
| void _InitHeader(zx_txid_t _txid); |
| }; |
| |
| // Collection of return types of FIDL calls in this protocol. |
| class ResultOf final { |
| ResultOf() = delete; |
| |
| public: |
| class GetFoo final : public ::fidl::Result { |
| public: |
| explicit GetFoo(zx_handle_t _client); |
| GetFoo(zx_handle_t _client, zx_time_t _deadline); |
| explicit GetFoo(const ::fidl::Result& result) : ::fidl::Result(result) {} |
| GetFoo(GetFoo&&) = delete; |
| GetFoo(const GetFoo&) = delete; |
| GetFoo* operator=(GetFoo&&) = delete; |
| GetFoo* operator=(const GetFoo&) = delete; |
| ~GetFoo() = default; |
| |
| GetFooResponse* Unwrap() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<GetFooResponse*>(bytes_); |
| } |
| const GetFooResponse* Unwrap() const { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<const GetFooResponse*>(bytes_); |
| } |
| |
| GetFooResponse& value() { return *Unwrap(); } |
| const GetFooResponse& value() const { return *Unwrap(); } |
| |
| GetFooResponse* operator->() { return &value(); } |
| const GetFooResponse* operator->() const { return &value(); } |
| |
| GetFooResponse& operator*() { return value(); } |
| const GetFooResponse& operator*() const { return value(); } |
| |
| private: |
| FIDL_ALIGNDECL |
| uint8_t |
| bytes_[GetFooResponse::PrimarySize + GetFooResponse::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 GetFoo final : public ::fidl::Result { |
| public: |
| explicit GetFoo(zx_handle_t _client, uint8_t* _response_bytes, |
| uint32_t _response_byte_capacity); |
| explicit GetFoo(const ::fidl::Result& result) : ::fidl::Result(result) {} |
| GetFoo(GetFoo&&) = delete; |
| GetFoo(const GetFoo&) = delete; |
| GetFoo* operator=(GetFoo&&) = delete; |
| GetFoo* operator=(const GetFoo&) = delete; |
| ~GetFoo() = default; |
| |
| GetFooResponse* Unwrap() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<GetFooResponse*>(bytes_); |
| } |
| const GetFooResponse* Unwrap() const { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<const GetFooResponse*>(bytes_); |
| } |
| |
| GetFooResponse& value() { return *Unwrap(); } |
| const GetFooResponse& value() const { return *Unwrap(); } |
| |
| GetFooResponse* operator->() { return &value(); } |
| const GetFooResponse* operator->() const { return &value(); } |
| |
| GetFooResponse& operator*() { return value(); } |
| const GetFooResponse& 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 40 bytes of message buffer on the stack. No heap allocation |
| // necessary. |
| static ResultOf::GetFoo GetFoo(::zx::unowned_channel _client_end) { |
| return ResultOf::GetFoo(_client_end->get()); |
| } |
| |
| // Caller provides the backing storage for FIDL message via request and |
| // response buffers. |
| static UnownedResultOf::GetFoo GetFoo(::zx::unowned_channel _client_end, |
| ::fidl::BytePart _response_buffer) { |
| return UnownedResultOf::GetFoo(_client_end->get(), |
| _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 40 bytes of message buffer on the stack. No heap allocation |
| // necessary. |
| ResultOf::GetFoo GetFoo() { |
| return ResultOf::GetFoo(this->channel().get()); |
| } |
| |
| // Caller provides the backing storage for FIDL message via request and |
| // response buffers. |
| UnownedResultOf::GetFoo GetFoo(::fidl::BytePart _response_buffer) { |
| return UnownedResultOf::GetFoo(this->channel().get(), |
| _response_buffer.data(), |
| _response_buffer.capacity()); |
| } |
| |
| private: |
| ::zx::channel channel_; |
| }; |
| |
| struct AsyncEventHandlers; |
| class GetFooResponseContext; |
| class ClientImpl; |
| |
| // Pure-virtual interface to be implemented by a server. |
| class Interface { |
| public: |
| Interface() = default; |
| virtual ~Interface() = default; |
| |
| // The marker protocol type within which this |Interface| class is defined. |
| using _EnclosingProtocol = Top; |
| |
| class GetFooCompleterBase : 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(::llcpp::bottom::Foo foo); |
| ::fidl::Result Reply(::fidl::BytePart _buffer, ::llcpp::bottom::Foo foo); |
| |
| protected: |
| using ::fidl::CompleterBase::CompleterBase; |
| }; |
| |
| using GetFooCompleter = ::fidl::Completer<GetFooCompleterBase>; |
| |
| virtual void GetFoo(GetFooCompleter::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 ::fidl::DispatchResult 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 ::fidl::DispatchResult 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 ::fidl::DispatchResult TypeErasedDispatch(void* impl, fidl_msg_t* msg, |
| ::fidl::Transaction* txn) { |
| return Dispatch(static_cast<Interface*>(impl), msg, txn); |
| } |
| |
| class EventSender; |
| }; |
| |
| } // namespace top |
| } // namespace llcpp |
| |
| namespace fidl { |
| |
| template <> |
| struct IsFidlType<::llcpp::top::Top::GetFooRequest> : public std::true_type {}; |
| template <> |
| struct IsFidlMessage<::llcpp::top::Top::GetFooRequest> : public std::true_type { |
| }; |
| static_assert(sizeof(::llcpp::top::Top::GetFooRequest) == |
| ::llcpp::top::Top::GetFooRequest::PrimarySize); |
| |
| template <> |
| struct IsFidlType<::llcpp::top::Top::GetFooResponse> : public std::true_type {}; |
| template <> |
| struct IsFidlMessage<::llcpp::top::Top::GetFooResponse> |
| : public std::true_type {}; |
| static_assert(sizeof(::llcpp::top::Top::GetFooResponse) == |
| ::llcpp::top::Top::GetFooResponse::PrimarySize); |
| static_assert(offsetof(::llcpp::top::Top::GetFooResponse, foo) == 16); |
| |
| } // namespace fidl |
| |
| namespace llcpp { |
| |
| namespace top { |
| |
| struct Top::AsyncEventHandlers {}; |
| |
| class Top::GetFooResponseContext : public ::fidl::internal::ResponseContext { |
| public: |
| GetFooResponseContext(); |
| |
| virtual void OnReply(Top::GetFooResponse* message) = 0; |
| |
| private: |
| void OnReply(uint8_t* reply) override; |
| }; |
| |
| class Top::ClientImpl final : private ::fidl::internal::ClientBase { |
| public: |
| // Asynchronous variant of |Top.GetFoo()|. Allocates 16 bytes of request |
| // buffer on the stack. The callback is stored on the heap. |
| ::fidl::Result GetFoo(::fit::callback<void(::llcpp::bottom::Foo foo)> _cb); |
| // Asynchronous variant of |Top.GetFoo()|. 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 GetFoo(GetFooResponseContext* _context); |
| // Synchronous variant of |Top.GetFoo()|. Allocates 40 bytes of message buffer |
| // on the stack. No heap allocation necessary. |
| ResultOf::GetFoo GetFoo_Sync(); |
| |
| // Synchronous variant of |Top.GetFoo()|. Caller provides the backing storage |
| // for FIDL message via request and response buffers. |
| UnownedResultOf::GetFoo GetFoo_Sync(::fidl::BytePart _response_buffer); |
| |
| private: |
| friend class ::fidl::Client<Top>; |
| |
| explicit ClientImpl(AsyncEventHandlers handlers) |
| : handlers_(std::move(handlers)) {} |
| |
| std::optional<::fidl::UnbindInfo> DispatchEvent(fidl_msg_t* msg) override; |
| |
| AsyncEventHandlers handlers_; |
| }; |
| |
| class Top::EventSender { |
| public: |
| private: |
| friend class ::fidl::ServerBindingRef<Top>; |
| |
| explicit EventSender( |
| std::weak_ptr<::fidl::internal::AsyncServerBinding> binding) |
| : binding_(std::move(binding)) {} |
| |
| std::weak_ptr<::fidl::internal::AsyncServerBinding> binding_; |
| }; |
| |
| } // namespace top |
| } // namespace llcpp |