blob: 612b2e5dbfebb64f721a6154c78ab3d4d3c7090e [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/object_view.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/stdcompat/optional.h>
#include <algorithm>
#include <cstddef>
#include <variant>
#ifdef __Fuchsia__
#include <lib/fidl/llcpp/client.h>
#include <lib/fidl/llcpp/client_end.h>
#include <lib/fidl/llcpp/connect_service.h>
#include <lib/fidl/llcpp/result.h>
#include <lib/fidl/llcpp/server.h>
#include <lib/fidl/llcpp/server_end.h>
#include <lib/fidl/llcpp/service_handler_interface.h>
#include <lib/fidl/llcpp/sync_call.h>
#include <lib/fidl/llcpp/transaction.h>
#include <lib/fidl/txn_header.h>
#include <lib/zx/bti.h>
#include <lib/zx/channel.h>
#include <lib/zx/clock.h>
#include <lib/zx/debuglog.h>
#include <lib/zx/event.h>
#include <lib/zx/eventpair.h>
#include <lib/zx/exception.h>
#include <lib/zx/fifo.h>
#include <lib/zx/guest.h>
#include <lib/zx/handle.h>
#include <lib/zx/interrupt.h>
#include <lib/zx/iommu.h>
#include <lib/zx/job.h>
#include <lib/zx/pager.h>
#include <lib/zx/pcidevice.h>
#include <lib/zx/pmt.h>
#include <lib/zx/port.h>
#include <lib/zx/process.h>
#include <lib/zx/profile.h>
#include <lib/zx/resource.h>
#include <lib/zx/socket.h>
#include <lib/zx/suspendtoken.h>
#include <lib/zx/thread.h>
#include <lib/zx/timer.h>
#include <lib/zx/vcpu.h>
#include <lib/zx/vmar.h>
#include <lib/zx/vmo.h>
#endif // __Fuchsia__
#include <zircon/fidl.h>
#include <zx/llcpp/fidl.h>
namespace llcpp {
namespace fidl {
namespace test {
namespace handles {
namespace wire {
enum class obj_type : uint32_t {
NONE = 0u,
PROCESS = 1u,
THREAD = 2u,
VMO = 3u,
CHANNEL = 4u,
EVENT = 5u,
PORT = 6u,
INTERRUPT = 9u,
PCI_DEVICE = 11u,
LOG = 12u,
SOCKET = 14u,
RESOURCE = 15u,
EVENTPAIR = 16u,
JOB = 17u,
VMAR = 18u,
FIFO = 19u,
GUEST = 20u,
VCPU = 21u,
TIMER = 22u,
IOMMU = 23u,
BTI = 24u,
PROFILE = 25u,
PMT = 26u,
SUSPEND_TOKEN = 27u,
PAGER = 28u,
EXCEPTION = 29u,
CLOCK = 30u,
STREAM = 31u,
MSI_ALLOCATION = 32u,
MSI_INTERRUPT = 33u,
};
} // namespace wire
using obj_type = ::llcpp::fidl::test::handles::wire::obj_type;
namespace wire {
struct Handles;
} // namespace wire
using Handles = ::llcpp::fidl::test::handles::wire::Handles;
class SomeProtocol;
namespace wire {
#ifdef __Fuchsia__
extern "C" const fidl_type_t fidl_test_handles_HandlesTable;
struct Handles {
static constexpr const fidl_type_t* Type = &fidl_test_handles_HandlesTable;
static constexpr uint32_t MaxNumHandles = 33;
static constexpr uint32_t PrimarySize = 132;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0;
static constexpr bool HasPointer = false;
::zx::handle plain_handle = {};
::zx::bti bti_handle = {};
::zx::channel channel_handle = {};
::zx::clock clock_handle = {};
::zx::debuglog debuglog_handle = {};
::zx::event event_handle = {};
::zx::eventpair eventpair_handle = {};
::zx::exception exception_handle = {};
::zx::fifo fifo_handle = {};
::zx::guest guest_handle = {};
::zx::interrupt interrupt_handle = {};
::zx::iommu iommu_handle = {};
::zx::job job_handle = {};
::zx::pager pager_handle = {};
::zx::pcidevice pcidevice_handle = {};
::zx::pmt pmt_handle = {};
::zx::port port_handle = {};
::zx::process process_handle = {};
::zx::profile profile_handle = {};
::zx::resource resource_handle = {};
::zx::socket socket_handle = {};
::zx::suspendtoken suspendtoken_handle = {};
::zx::thread thread_handle = {};
::zx::timer timer_handle = {};
::zx::vcpu vcpu_handle = {};
::zx::vmar vmar_handle = {};
::zx::vmo vmo_handle = {};
::zx::vmo rights_handle = {};
::zx::handle aliased_plain_handle_field = {};
::zx::vmo aliased_subtype_handle_field = {};
::zx::vmo aliased_rights_handle_field = {};
::fidl::ClientEnd<::llcpp::fidl::test::handles::SomeProtocol> some_protocol =
{};
::fidl::ServerEnd<::llcpp::fidl::test::handles::SomeProtocol>
request_some_protocol = {};
void _CloseHandles();
private:
class UnownedEncodedByteMessage final {
public:
UnownedEncodedByteMessage(uint8_t* bytes, uint32_t byte_size,
Handles* value)
: message_(bytes, byte_size, sizeof(Handles), handles_,
std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles), 0) {
message_.Encode<Handles>(value);
}
UnownedEncodedByteMessage(const UnownedEncodedByteMessage&) = delete;
UnownedEncodedByteMessage(UnownedEncodedByteMessage&&) = delete;
UnownedEncodedByteMessage* operator=(const UnownedEncodedByteMessage&) =
delete;
UnownedEncodedByteMessage* operator=(UnownedEncodedByteMessage&&) = 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::OutgoingByteMessage& GetOutgoingMessage() { return message_; }
private:
zx_handle_disposition_t
handles_[std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)];
::fidl::OutgoingByteMessage message_;
};
class UnownedEncodedIovecMessage final {
public:
UnownedEncodedIovecMessage(zx_channel_iovec_t* iovecs, uint32_t iovec_size,
fidl_iovec_substitution_t* substitutions,
uint32_t substitutions_size, Handles* value)
: message_(::fidl::OutgoingIovecMessage::constructor_args{
.iovecs = iovecs,
.iovecs_actual = 0,
.iovecs_capacity = iovec_size,
.substitutions = substitutions,
.substitutions_actual = 0,
.substitutions_capacity = substitutions_size,
.handles = handles_,
.handle_actual = 0,
.handle_capacity =
std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles),
}) {
message_.Encode<Handles>(value);
}
UnownedEncodedIovecMessage(const UnownedEncodedIovecMessage&) = delete;
UnownedEncodedIovecMessage(UnownedEncodedIovecMessage&&) = delete;
UnownedEncodedIovecMessage* operator=(const UnownedEncodedIovecMessage&) =
delete;
UnownedEncodedIovecMessage* operator=(UnownedEncodedIovecMessage&&) =
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::OutgoingIovecMessage& GetOutgoingMessage() { return message_; }
private:
zx_handle_disposition_t
handles_[std::min(ZX_CHANNEL_MAX_MSG_HANDLES, MaxNumHandles)];
::fidl::OutgoingIovecMessage message_;
};
class OwnedEncodedByteMessage final {
public:
explicit OwnedEncodedByteMessage(Handles* value)
: message_(bytes_, sizeof(bytes_), value) {}
OwnedEncodedByteMessage(const OwnedEncodedByteMessage&) = delete;
OwnedEncodedByteMessage(OwnedEncodedByteMessage&&) = delete;
OwnedEncodedByteMessage* operator=(const OwnedEncodedByteMessage&) = delete;
OwnedEncodedByteMessage* operator=(OwnedEncodedByteMessage&&) = 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::OutgoingByteMessage& GetOutgoingMessage() {
return message_.GetOutgoingMessage();
}
private:
FIDL_ALIGNDECL
uint8_t bytes_[FIDL_ALIGN(PrimarySize + MaxOutOfLine)];
UnownedEncodedByteMessage message_;
};
class OwnedEncodedIovecMessage final {
public:
explicit OwnedEncodedIovecMessage(Handles* value)
: message_(iovecs_, ::fidl::internal::kIovecBufferSize, substitutions_,
::fidl::internal::kIovecBufferSize, value) {}
OwnedEncodedIovecMessage(const OwnedEncodedIovecMessage&) = delete;
OwnedEncodedIovecMessage(OwnedEncodedIovecMessage&&) = delete;
OwnedEncodedIovecMessage* operator=(const OwnedEncodedIovecMessage&) =
delete;
OwnedEncodedIovecMessage* operator=(OwnedEncodedIovecMessage&&) = 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::OutgoingIovecMessage& GetOutgoingMessage() {
return message_.GetOutgoingMessage();
}
private:
zx_channel_iovec_t iovecs_[::fidl::internal::kIovecBufferSize];
fidl_iovec_substitution_t
substitutions_[::fidl::internal::kIovecBufferSize];
UnownedEncodedIovecMessage message_;
};
public:
friend ::fidl::internal::EncodedMessageTypes<Handles>;
using OwnedEncodedMessage = OwnedEncodedByteMessage;
using UnownedEncodedMessage = UnownedEncodedByteMessage;
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 Handles>();
}
DecodedMessage(fidl_incoming_msg_t* msg)
: ::fidl::internal::IncomingMessage(msg) {
Decode<struct Handles>();
}
DecodedMessage(const DecodedMessage&) = delete;
DecodedMessage(DecodedMessage&&) = delete;
DecodedMessage* operator=(const DecodedMessage&) = delete;
DecodedMessage* operator=(DecodedMessage&&) = delete;
~DecodedMessage() {
if (ok() && (PrimaryObject() != nullptr)) {
PrimaryObject()->_CloseHandles();
}
}
struct Handles* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<struct Handles*>(bytes());
}
// Release the ownership of the decoded message. That means that the handles
// won't be closed When the object is destroyed. After calling this method,
// the DecodedMessage object should not be used anymore.
void ReleasePrimaryObject() { ResetBytes(); }
};
};
#endif // __Fuchsia__
} // namespace wire
class SomeProtocol final {
SomeProtocol() = delete;
public:
class EventHandlerInterface {
public:
EventHandlerInterface() = default;
virtual ~EventHandlerInterface() = default;
};
#ifdef __Fuchsia__
// Collection of return types of FIDL calls in this protocol.
class ResultOf final {
ResultOf() = delete;
public:
};
// 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:
};
// Methods to make a sync FIDL call directly on an unowned channel or a
// const reference to a
// |fidl::ClientEnd<::llcpp::fidl::test::handles::SomeProtocol>|, avoiding
// setting up a client.
class Call final {
Call() = delete;
public:
};
class SyncClient final {
public:
SyncClient() = default;
explicit SyncClient(::fidl::ClientEnd<SomeProtocol> client_end)
: client_end_(std::move(client_end)) {}
~SyncClient() = default;
SyncClient(SyncClient&&) = default;
SyncClient& operator=(SyncClient&&) = default;
const ::fidl::ClientEnd<SomeProtocol>& client_end() const {
return client_end_;
}
::fidl::ClientEnd<SomeProtocol>& client_end() { return client_end_; }
const ::zx::channel& channel() const { return client_end_.channel(); }
::zx::channel* mutable_channel() { return &client_end_.channel(); }
private:
::fidl::ClientEnd<SomeProtocol> client_end_;
};
#ifdef __Fuchsia__
class AsyncEventHandler;
class ClientImpl;
#endif
// Pure-virtual interface to be implemented by a server.
// This interface uses typed channels (i.e. |fidl::ClientEnd<SomeProtocol>|
// and |fidl::ServerEnd<SomeProtocol>|).
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 = SomeProtocol;
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);
}
#endif
class EventSender;
class WeakEventSender;
};
} // namespace handles
} // namespace test
} // namespace fidl
} // namespace llcpp
namespace fidl {
template <>
struct IsFidlType<::llcpp::fidl::test::handles::wire::obj_type>
: public std::true_type {};
#ifdef __Fuchsia__
template <>
struct IsFidlType<::llcpp::fidl::test::handles::wire::Handles>
: public std::true_type {};
template <>
struct IsStruct<::llcpp::fidl::test::handles::wire::Handles>
: public std::true_type {};
static_assert(
std::is_standard_layout_v<::llcpp::fidl::test::handles::wire::Handles>);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
plain_handle) == 0);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
bti_handle) == 4);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
channel_handle) == 8);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
clock_handle) == 12);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
debuglog_handle) == 16);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
event_handle) == 20);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
eventpair_handle) == 24);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
exception_handle) == 28);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
fifo_handle) == 32);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
guest_handle) == 36);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
interrupt_handle) == 40);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
iommu_handle) == 44);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
job_handle) == 48);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
pager_handle) == 52);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
pcidevice_handle) == 56);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
pmt_handle) == 60);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
port_handle) == 64);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
process_handle) == 68);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
profile_handle) == 72);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
resource_handle) == 76);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
socket_handle) == 80);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
suspendtoken_handle) == 84);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
thread_handle) == 88);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
timer_handle) == 92);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
vcpu_handle) == 96);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
vmar_handle) == 100);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
vmo_handle) == 104);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
rights_handle) == 108);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
aliased_plain_handle_field) == 112);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
aliased_subtype_handle_field) == 116);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
aliased_rights_handle_field) == 120);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
some_protocol) == 124);
static_assert(offsetof(::llcpp::fidl::test::handles::wire::Handles,
request_some_protocol) == 128);
static_assert(sizeof(::llcpp::fidl::test::handles::wire::Handles) ==
::llcpp::fidl::test::handles::wire::Handles::PrimarySize);
#endif // __Fuchsia__
} // namespace fidl
namespace llcpp {
namespace fidl {
namespace test {
namespace handles {
namespace wire {} // namespace wire
#ifdef __Fuchsia__
class SomeProtocol::AsyncEventHandler
: public SomeProtocol::EventHandlerInterface {
public:
AsyncEventHandler() = default;
virtual void Unbound(::fidl::UnbindInfo info) {}
};
class SomeProtocol::ClientImpl final : private ::fidl::internal::ClientBase {
public:
AsyncEventHandler* event_handler() const { return event_handler_.get(); }
private:
friend class ::fidl::Client<SomeProtocol>;
friend class ::fidl::internal::ControlBlock<SomeProtocol>;
explicit ClientImpl(std::shared_ptr<AsyncEventHandler> event_handler)
: event_handler_(std::move(event_handler)) {}
std::optional<::fidl::UnbindInfo> DispatchEvent(
fidl_incoming_msg_t* msg) override;
std::shared_ptr<AsyncEventHandler> event_handler_;
};
#endif
#ifdef __Fuchsia__
// |EventSender| owns a server endpoint of a channel speaking
// the SomeProtocol protocol, and can send events in that protocol.
class SomeProtocol::EventSender {
public:
// Constructs an event sender with an invalid channel.
EventSender() = default;
explicit EventSender(
::fidl::ServerEnd<::llcpp::fidl::test::handles::SomeProtocol> server_end)
: server_end_(std::move(server_end)) {}
// The underlying server channel endpoint, which may be replaced at run-time.
const ::fidl::ServerEnd<SomeProtocol>& server_end() const {
return server_end_;
}
::fidl::ServerEnd<SomeProtocol>& server_end() { return server_end_; }
const ::zx::channel& channel() const { return server_end_.channel(); }
::zx::channel& channel() { return server_end_.channel(); }
// Whether the underlying channel is valid.
bool is_valid() const { return server_end_.is_valid(); }
private:
::fidl::ServerEnd<SomeProtocol> server_end_;
};
class SomeProtocol::WeakEventSender {
public:
private:
friend class ::fidl::ServerBindingRef<SomeProtocol>;
explicit WeakEventSender(
std::weak_ptr<::fidl::internal::AsyncServerBinding<SomeProtocol>> binding)
: binding_(std::move(binding)) {}
std::weak_ptr<::fidl::internal::AsyncServerBinding<SomeProtocol>> binding_;
};
#endif
} // namespace handles
} // namespace test
} // namespace fidl
} // namespace llcpp