blob: 6ba188264db9d5fce5cd6f3ac23b36de234d5354 [file] [log] [blame]
// 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>
#endif // __Fuchsia__
#include <zircon/fidl.h>
namespace llcpp {
namespace fidl {
namespace test {
namespace inheritancewithrecursivedecl {
class Parent;
class Child;
extern "C" const fidl_type_t
fidl_test_inheritancewithrecursivedecl_ParentFirstRequestTable;
extern "C" const fidl_type_t
fidl_test_inheritancewithrecursivedecl_ParentFirstResponseTable;
class Parent final {
Parent() = delete;
public:
struct FirstRequest final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
::zx::channel request;
explicit FirstRequest(zx_txid_t _txid, ::zx::channel& request)
: request(std::move(request)) {
_InitHeader(_txid);
}
explicit FirstRequest(zx_txid_t _txid) { _InitHeader(_txid); }
static constexpr const fidl_type_t* Type =
&fidl_test_inheritancewithrecursivedecl_ParentFirstRequestTable;
static constexpr uint32_t MaxNumHandles = 1;
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;
void _CloseHandles();
class UnownedEncodedMessage final {
public:
UnownedEncodedMessage(uint8_t* _bytes, uint32_t _byte_size,
zx_txid_t _txid, ::zx::channel& request)
: message_(_bytes, _byte_size, sizeof(FirstRequest), handles_,
std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) {
FIDL_ALIGNDECL FirstRequest _request(_txid, request);
message_.LinearizeAndEncode<FirstRequest>(&_request);
}
UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size,
FirstRequest* request)
: message_(bytes, byte_size, sizeof(FirstRequest), handles_,
std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) {
message_.LinearizeAndEncode<FirstRequest>(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:
FirstRequest& Message() {
return *reinterpret_cast<FirstRequest*>(message_.bytes());
}
zx_handle_disposition_t
handles_[std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)];
::fidl::OutgoingMessage message_;
};
class OwnedEncodedMessage final {
public:
explicit OwnedEncodedMessage(zx_txid_t _txid, ::zx::channel& request)
: message_(bytes_, sizeof(bytes_), _txid, request) {}
explicit OwnedEncodedMessage(FirstRequest* 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<FirstRequest>();
}
DecodedMessage(fidl_incoming_msg_t* msg)
: ::fidl::internal::IncomingMessage(msg) {
Decode<FirstRequest>();
}
DecodedMessage(const DecodedMessage&) = delete;
DecodedMessage(DecodedMessage&&) = delete;
DecodedMessage* operator=(const DecodedMessage&) = delete;
DecodedMessage* operator=(DecodedMessage&&) = delete;
~DecodedMessage() {
if (ok() && (PrimaryObject() != nullptr)) {
PrimaryObject()->_CloseHandles();
}
}
FirstRequest* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<FirstRequest*>(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<FirstRequest>();
}
}
};
private:
void _InitHeader(zx_txid_t _txid);
};
// Collection of return types of FIDL calls in this protocol.
class ResultOf final {
ResultOf() = delete;
public:
class First final : public ::fidl::Result {
public:
explicit First(zx_handle_t _client, ::zx::channel& request);
explicit First(const ::fidl::Result& result) : ::fidl::Result(result) {}
First(First&&) = delete;
First(const First&) = delete;
First* operator=(First&&) = delete;
First* operator=(const First&) = delete;
~First() = default;
private:
};
};
// 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 First final : public ::fidl::Result {
public:
explicit First(zx_handle_t _client, uint8_t* _request_bytes,
uint32_t _request_byte_capacity, ::zx::channel& request);
explicit First(const ::fidl::Result& result) : ::fidl::Result(result) {}
First(First&&) = delete;
First(const First&) = delete;
First* operator=(First&&) = delete;
First* operator=(const First&) = delete;
~First() = default;
};
};
// Methods to make a sync FIDL call directly on an unowned channel, avoiding
// setting up a client.
class Call final {
Call() = delete;
public:
// Allocates 24 bytes of message buffer on the stack. No heap allocation
// necessary.
static ResultOf::First First(::zx::unowned_channel _client_end,
::zx::channel request) {
return ResultOf::First(_client_end->get(), request);
}
// Caller provides the backing storage for FIDL message via request and
// response buffers.
static UnownedResultOf::First First(::zx::unowned_channel _client_end,
::fidl::BufferSpan _request_buffer,
::zx::channel request) {
return UnownedResultOf::First(_client_end->get(), _request_buffer.data,
_request_buffer.capacity, request);
}
};
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 24 bytes of message buffer on the stack. No heap allocation
// necessary.
ResultOf::First First(::zx::channel request) {
return ResultOf::First(this->channel().get(), request);
}
// Caller provides the backing storage for FIDL message via request and
// response buffers.
UnownedResultOf::First First(::fidl::BufferSpan _request_buffer,
::zx::channel request) {
return UnownedResultOf::First(this->channel().get(), _request_buffer.data,
_request_buffer.capacity, request);
}
private:
::zx::channel channel_;
};
struct AsyncEventHandlers;
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 = Parent;
using FirstCompleter = ::fidl::Completer<>;
virtual void First(::zx::channel request,
FirstCompleter::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_inheritancewithrecursivedecl_ChildFirstRequestTable;
extern "C" const fidl_type_t
fidl_test_inheritancewithrecursivedecl_ChildFirstResponseTable;
extern "C" const fidl_type_t
fidl_test_inheritancewithrecursivedecl_ChildSecondRequestTable;
extern "C" const fidl_type_t
fidl_test_inheritancewithrecursivedecl_ChildSecondResponseTable;
class Child final {
Child() = delete;
public:
struct FirstRequest final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
::zx::channel request;
explicit FirstRequest(zx_txid_t _txid, ::zx::channel& request)
: request(std::move(request)) {
_InitHeader(_txid);
}
explicit FirstRequest(zx_txid_t _txid) { _InitHeader(_txid); }
static constexpr const fidl_type_t* Type =
&fidl_test_inheritancewithrecursivedecl_ChildFirstRequestTable;
static constexpr uint32_t MaxNumHandles = 1;
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;
void _CloseHandles();
class UnownedEncodedMessage final {
public:
UnownedEncodedMessage(uint8_t* _bytes, uint32_t _byte_size,
zx_txid_t _txid, ::zx::channel& request)
: message_(_bytes, _byte_size, sizeof(FirstRequest), handles_,
std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) {
FIDL_ALIGNDECL FirstRequest _request(_txid, request);
message_.LinearizeAndEncode<FirstRequest>(&_request);
}
UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size,
FirstRequest* request)
: message_(bytes, byte_size, sizeof(FirstRequest), handles_,
std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) {
message_.LinearizeAndEncode<FirstRequest>(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:
FirstRequest& Message() {
return *reinterpret_cast<FirstRequest*>(message_.bytes());
}
zx_handle_disposition_t
handles_[std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)];
::fidl::OutgoingMessage message_;
};
class OwnedEncodedMessage final {
public:
explicit OwnedEncodedMessage(zx_txid_t _txid, ::zx::channel& request)
: message_(bytes_, sizeof(bytes_), _txid, request) {}
explicit OwnedEncodedMessage(FirstRequest* 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<FirstRequest>();
}
DecodedMessage(fidl_incoming_msg_t* msg)
: ::fidl::internal::IncomingMessage(msg) {
Decode<FirstRequest>();
}
DecodedMessage(const DecodedMessage&) = delete;
DecodedMessage(DecodedMessage&&) = delete;
DecodedMessage* operator=(const DecodedMessage&) = delete;
DecodedMessage* operator=(DecodedMessage&&) = delete;
~DecodedMessage() {
if (ok() && (PrimaryObject() != nullptr)) {
PrimaryObject()->_CloseHandles();
}
}
FirstRequest* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<FirstRequest*>(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<FirstRequest>();
}
}
};
private:
void _InitHeader(zx_txid_t _txid);
};
struct SecondRequest final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
::zx::channel request;
explicit SecondRequest(zx_txid_t _txid, ::zx::channel& request)
: request(std::move(request)) {
_InitHeader(_txid);
}
explicit SecondRequest(zx_txid_t _txid) { _InitHeader(_txid); }
static constexpr const fidl_type_t* Type =
&fidl_test_inheritancewithrecursivedecl_ChildSecondRequestTable;
static constexpr uint32_t MaxNumHandles = 1;
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;
void _CloseHandles();
class UnownedEncodedMessage final {
public:
UnownedEncodedMessage(uint8_t* _bytes, uint32_t _byte_size,
zx_txid_t _txid, ::zx::channel& request)
: message_(_bytes, _byte_size, sizeof(SecondRequest), handles_,
std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) {
FIDL_ALIGNDECL SecondRequest _request(_txid, request);
message_.LinearizeAndEncode<SecondRequest>(&_request);
}
UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size,
SecondRequest* request)
: message_(bytes, byte_size, sizeof(SecondRequest), handles_,
std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) {
message_.LinearizeAndEncode<SecondRequest>(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:
SecondRequest& Message() {
return *reinterpret_cast<SecondRequest*>(message_.bytes());
}
zx_handle_disposition_t
handles_[std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)];
::fidl::OutgoingMessage message_;
};
class OwnedEncodedMessage final {
public:
explicit OwnedEncodedMessage(zx_txid_t _txid, ::zx::channel& request)
: message_(bytes_, sizeof(bytes_), _txid, request) {}
explicit OwnedEncodedMessage(SecondRequest* 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<SecondRequest>();
}
DecodedMessage(fidl_incoming_msg_t* msg)
: ::fidl::internal::IncomingMessage(msg) {
Decode<SecondRequest>();
}
DecodedMessage(const DecodedMessage&) = delete;
DecodedMessage(DecodedMessage&&) = delete;
DecodedMessage* operator=(const DecodedMessage&) = delete;
DecodedMessage* operator=(DecodedMessage&&) = delete;
~DecodedMessage() {
if (ok() && (PrimaryObject() != nullptr)) {
PrimaryObject()->_CloseHandles();
}
}
SecondRequest* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<SecondRequest*>(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<SecondRequest>();
}
}
};
private:
void _InitHeader(zx_txid_t _txid);
};
// Collection of return types of FIDL calls in this protocol.
class ResultOf final {
ResultOf() = delete;
public:
class First final : public ::fidl::Result {
public:
explicit First(zx_handle_t _client, ::zx::channel& request);
explicit First(const ::fidl::Result& result) : ::fidl::Result(result) {}
First(First&&) = delete;
First(const First&) = delete;
First* operator=(First&&) = delete;
First* operator=(const First&) = delete;
~First() = default;
private:
};
class Second final : public ::fidl::Result {
public:
explicit Second(zx_handle_t _client, ::zx::channel& request);
explicit Second(const ::fidl::Result& result) : ::fidl::Result(result) {}
Second(Second&&) = delete;
Second(const Second&) = delete;
Second* operator=(Second&&) = delete;
Second* operator=(const Second&) = delete;
~Second() = default;
private:
};
};
// 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 First final : public ::fidl::Result {
public:
explicit First(zx_handle_t _client, uint8_t* _request_bytes,
uint32_t _request_byte_capacity, ::zx::channel& request);
explicit First(const ::fidl::Result& result) : ::fidl::Result(result) {}
First(First&&) = delete;
First(const First&) = delete;
First* operator=(First&&) = delete;
First* operator=(const First&) = delete;
~First() = default;
};
class Second final : public ::fidl::Result {
public:
explicit Second(zx_handle_t _client, uint8_t* _request_bytes,
uint32_t _request_byte_capacity, ::zx::channel& request);
explicit Second(const ::fidl::Result& result) : ::fidl::Result(result) {}
Second(Second&&) = delete;
Second(const Second&) = delete;
Second* operator=(Second&&) = delete;
Second* operator=(const Second&) = delete;
~Second() = default;
};
};
// Methods to make a sync FIDL call directly on an unowned channel, avoiding
// setting up a client.
class Call final {
Call() = delete;
public:
// Allocates 24 bytes of message buffer on the stack. No heap allocation
// necessary.
static ResultOf::First First(::zx::unowned_channel _client_end,
::zx::channel request) {
return ResultOf::First(_client_end->get(), request);
}
// Caller provides the backing storage for FIDL message via request and
// response buffers.
static UnownedResultOf::First First(::zx::unowned_channel _client_end,
::fidl::BufferSpan _request_buffer,
::zx::channel request) {
return UnownedResultOf::First(_client_end->get(), _request_buffer.data,
_request_buffer.capacity, request);
}
// Allocates 24 bytes of message buffer on the stack. No heap allocation
// necessary.
static ResultOf::Second Second(::zx::unowned_channel _client_end,
::zx::channel request) {
return ResultOf::Second(_client_end->get(), request);
}
// Caller provides the backing storage for FIDL message via request and
// response buffers.
static UnownedResultOf::Second Second(::zx::unowned_channel _client_end,
::fidl::BufferSpan _request_buffer,
::zx::channel request) {
return UnownedResultOf::Second(_client_end->get(), _request_buffer.data,
_request_buffer.capacity, request);
}
};
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 24 bytes of message buffer on the stack. No heap allocation
// necessary.
ResultOf::First First(::zx::channel request) {
return ResultOf::First(this->channel().get(), request);
}
// Caller provides the backing storage for FIDL message via request and
// response buffers.
UnownedResultOf::First First(::fidl::BufferSpan _request_buffer,
::zx::channel request) {
return UnownedResultOf::First(this->channel().get(), _request_buffer.data,
_request_buffer.capacity, request);
}
// Allocates 24 bytes of message buffer on the stack. No heap allocation
// necessary.
ResultOf::Second Second(::zx::channel request) {
return ResultOf::Second(this->channel().get(), request);
}
// Caller provides the backing storage for FIDL message via request and
// response buffers.
UnownedResultOf::Second Second(::fidl::BufferSpan _request_buffer,
::zx::channel request) {
return UnownedResultOf::Second(this->channel().get(),
_request_buffer.data,
_request_buffer.capacity, request);
}
private:
::zx::channel channel_;
};
struct AsyncEventHandlers;
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 = Child;
using FirstCompleter = ::fidl::Completer<>;
virtual void First(::zx::channel request,
FirstCompleter::Sync& _completer) = 0;
using SecondCompleter = ::fidl::Completer<>;
virtual void Second(::zx::channel request,
SecondCompleter::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;
};
} // namespace inheritancewithrecursivedecl
} // namespace test
} // namespace fidl
} // namespace llcpp
namespace fidl {
template <>
struct IsFidlType<
::llcpp::fidl::test::inheritancewithrecursivedecl::Parent::FirstRequest>
: public std::true_type {};
template <>
struct IsFidlMessage<
::llcpp::fidl::test::inheritancewithrecursivedecl::Parent::FirstRequest>
: public std::true_type {};
static_assert(sizeof(::llcpp::fidl::test::inheritancewithrecursivedecl::Parent::
FirstRequest) ==
::llcpp::fidl::test::inheritancewithrecursivedecl::Parent::
FirstRequest::PrimarySize);
static_assert(
offsetof(
::llcpp::fidl::test::inheritancewithrecursivedecl::Parent::FirstRequest,
request) == 16);
template <>
struct IsFidlType<
::llcpp::fidl::test::inheritancewithrecursivedecl::Child::FirstRequest>
: public std::true_type {};
template <>
struct IsFidlMessage<
::llcpp::fidl::test::inheritancewithrecursivedecl::Child::FirstRequest>
: public std::true_type {};
static_assert(sizeof(::llcpp::fidl::test::inheritancewithrecursivedecl::Child::
FirstRequest) ==
::llcpp::fidl::test::inheritancewithrecursivedecl::Child::
FirstRequest::PrimarySize);
static_assert(
offsetof(
::llcpp::fidl::test::inheritancewithrecursivedecl::Child::FirstRequest,
request) == 16);
template <>
struct IsFidlType<
::llcpp::fidl::test::inheritancewithrecursivedecl::Child::SecondRequest>
: public std::true_type {};
template <>
struct IsFidlMessage<
::llcpp::fidl::test::inheritancewithrecursivedecl::Child::SecondRequest>
: public std::true_type {};
static_assert(sizeof(::llcpp::fidl::test::inheritancewithrecursivedecl::Child::
SecondRequest) ==
::llcpp::fidl::test::inheritancewithrecursivedecl::Child::
SecondRequest::PrimarySize);
static_assert(
offsetof(
::llcpp::fidl::test::inheritancewithrecursivedecl::Child::SecondRequest,
request) == 16);
} // namespace fidl
namespace llcpp {
namespace fidl {
namespace test {
namespace inheritancewithrecursivedecl {
struct Parent::AsyncEventHandlers {};
class Parent::ClientImpl final : private ::fidl::internal::ClientBase {
public:
// Allocates 24 bytes of message buffer on the stack. No heap allocation
// necessary.
::fidl::Result First(::zx::channel request);
// Caller provides the backing storage for FIDL message via request and
// response buffers.
::fidl::Result First(::fidl::BufferSpan _request_buffer,
::zx::channel request);
private:
friend class ::fidl::Client<Parent>;
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 Parent protocol, and can send events in that protocol.
class Parent::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 Parent::WeakEventSender {
public:
private:
friend class ::fidl::ServerBindingRef<Parent>;
explicit WeakEventSender(
std::weak_ptr<::fidl::internal::AsyncServerBinding<Parent>> binding)
: binding_(std::move(binding)) {}
std::weak_ptr<::fidl::internal::AsyncServerBinding<Parent>> binding_;
};
struct Child::AsyncEventHandlers {};
class Child::ClientImpl final : private ::fidl::internal::ClientBase {
public:
// Allocates 24 bytes of message buffer on the stack. No heap allocation
// necessary.
::fidl::Result First(::zx::channel request);
// Caller provides the backing storage for FIDL message via request and
// response buffers.
::fidl::Result First(::fidl::BufferSpan _request_buffer,
::zx::channel request);
// Allocates 24 bytes of message buffer on the stack. No heap allocation
// necessary.
::fidl::Result Second(::zx::channel request);
// Caller provides the backing storage for FIDL message via request and
// response buffers.
::fidl::Result Second(::fidl::BufferSpan _request_buffer,
::zx::channel request);
private:
friend class ::fidl::Client<Child>;
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 Child protocol, and can send events in that protocol.
class Child::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 Child::WeakEventSender {
public:
private:
friend class ::fidl::ServerBindingRef<Child>;
explicit WeakEventSender(
std::weak_ptr<::fidl::internal::AsyncServerBinding<Child>> binding)
: binding_(std::move(binding)) {}
std::weak_ptr<::fidl::internal::AsyncServerBinding<Child>> binding_;
};
} // namespace inheritancewithrecursivedecl
} // namespace test
} // namespace fidl
} // namespace llcpp