blob: e04484d34cdd0a131386ac593d7bfe8db8457a10 [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
#include <fidl/test/placementofattributes/llcpp/fidl.h>
#include <memory>
namespace llcpp {
namespace fidl {
namespace test {
namespace placementofattributes {
auto ::llcpp::fidl::test::placementofattributes::ExampleXUnion::which() const
-> Tag {
ZX_ASSERT(!has_invalid_tag());
switch (ordinal_) {
case Ordinal::kVariant:
return static_cast<Tag>(ordinal_);
default:
return Tag::kUnknown;
}
}
void ::llcpp::fidl::test::placementofattributes::ExampleXUnion::
SizeAndOffsetAssertionHelper() {
static_assert(sizeof(ExampleXUnion) == sizeof(fidl_xunion_t));
static_assert(offsetof(ExampleXUnion, ordinal_) ==
offsetof(fidl_xunion_t, tag));
static_assert(offsetof(ExampleXUnion, envelope_) ==
offsetof(fidl_xunion_t, envelope));
}
void ::llcpp::fidl::test::placementofattributes::ExampleUnion::
SizeAndOffsetAssertionHelper() {
static_assert(sizeof(ExampleUnion) == sizeof(fidl_xunion_t));
static_assert(offsetof(ExampleUnion, ordinal_) ==
offsetof(fidl_xunion_t, tag));
static_assert(offsetof(ExampleUnion, envelope_) ==
offsetof(fidl_xunion_t, envelope));
}
namespace {
[[maybe_unused]] constexpr uint64_t kExampleProtocol_Method_Ordinal =
2341079615635566980lu;
extern "C" const fidl_type_t
fidl_test_placementofattributes_ExampleProtocolMethodRequestTable;
extern "C" const fidl_type_t
fidl_test_placementofattributes_ExampleProtocolMethodResponseTable;
} // namespace
ExampleProtocol::ResultOf::Method::Method(zx_handle_t _client,
::llcpp::exampleusing::Empty& arg) {
MethodRequest::OwnedEncodedMessage _request(zx_txid_t(0), arg);
_request.GetOutgoingMessage().Write(_client);
status_ = _request.status();
error_ = _request.error();
}
ExampleProtocol::UnownedResultOf::Method::Method(
zx_handle_t _client, uint8_t* _request_bytes,
uint32_t _request_byte_capacity, ::llcpp::exampleusing::Empty& arg) {
MethodRequest::UnownedEncodedMessage _request(_request_bytes,
_request_byte_capacity, 0, arg);
_request.GetOutgoingMessage().Write(_client);
status_ = _request.status();
error_ = _request.error();
}
::fidl::Result ExampleProtocol::ClientImpl::Method(
::llcpp::exampleusing::Empty arg) {
if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) {
auto _res = ResultOf::Method(_channel->handle(), arg);
return ::fidl::Result(_res.status(), _res.error());
}
return ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound);
}
::fidl::Result ExampleProtocol::ClientImpl::Method(
::fidl::BufferSpan _request_buffer, ::llcpp::exampleusing::Empty arg) {
if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) {
auto _res =
UnownedResultOf::Method(_channel->handle(), _request_buffer.data,
_request_buffer.capacity, arg);
return ::fidl::Result(_res.status(), _res.error());
}
return ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound);
}
std::optional<::fidl::UnbindInfo> ExampleProtocol::ClientImpl::DispatchEvent(
fidl_incoming_msg_t* msg) {
fidl_message_header_t* hdr =
reinterpret_cast<fidl_message_header_t*>(msg->bytes);
switch (hdr->ordinal) {
default:
FidlHandleInfoCloseMany(msg->handles, msg->num_handles);
return ::fidl::UnbindInfo{::fidl::UnbindInfo::kUnexpectedMessage,
ZX_ERR_NOT_SUPPORTED};
}
return {};
}
namespace methods {
void ExampleProtocolDispatchMethod(void* interface, void* bytes,
::fidl::Transaction* txn) {
auto message = reinterpret_cast<ExampleProtocol::MethodRequest*>(bytes);
ExampleProtocol::Interface::MethodCompleter::Sync completer(txn);
reinterpret_cast<ExampleProtocol::Interface*>(interface)->Method(
std::move(message->arg), completer);
}
} // namespace methods
namespace entries {
::fidl::internal::MethodEntry ExampleProtocol[] = {
{kExampleProtocol_Method_Ordinal, ExampleProtocol::MethodRequest::Type,
methods::ExampleProtocolDispatchMethod},
};
} // namespace entries
::fidl::DispatchResult ExampleProtocol::TryDispatch(Interface* impl,
fidl_incoming_msg_t* msg,
::fidl::Transaction* txn) {
return ::fidl::internal::TryDispatch(
impl, msg, txn, entries::ExampleProtocol,
entries::ExampleProtocol + sizeof(entries::ExampleProtocol) /
sizeof(::fidl::internal::MethodEntry));
}
::fidl::DispatchResult ExampleProtocol::Dispatch(Interface* impl,
fidl_incoming_msg_t* msg,
::fidl::Transaction* txn) {
::fidl::DispatchResult dispatch_result = TryDispatch(impl, msg, txn);
if (dispatch_result == ::fidl::DispatchResult::kNotFound) {
FidlHandleInfoCloseMany(msg->handles, msg->num_handles);
txn->InternalError(
{::fidl::UnbindInfo::kUnexpectedMessage, ZX_ERR_NOT_SUPPORTED});
}
return dispatch_result;
}
::fidl::DispatchResult ExampleProtocol::Interface::dispatch_message(
fidl_incoming_msg_t* msg, ::fidl::Transaction* txn) {
return ExampleProtocol::Dispatch(this, msg, txn);
}
void ExampleProtocol::MethodRequest::_InitHeader(zx_txid_t _txid) {
fidl_init_txn_header(&_hdr, _txid, kExampleProtocol_Method_Ordinal);
}
} // namespace placementofattributes
} // namespace test
} // namespace fidl
} // namespace llcpp