blob: 41d650beb6addfde1056c06f596adacdaf0cf811 [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
#include <service.test.json.llcpp.h>
#include <memory>
namespace llcpp {
namespace test {
namespace name {
namespace {
[[maybe_unused]] constexpr uint64_t kSecondProtocol_MethodOnSecond_Ordinal =
0xd09c00f00000000lu;
[[maybe_unused]] constexpr uint64_t kSecondProtocol_MethodOnSecond_GenOrdinal =
0x5785f9c1f2aece21lu;
extern "C" const fidl_type_t
v1_test_name_SecondProtocolMethodOnSecondRequestTable;
extern "C" const fidl_type_t
v1_test_name_SecondProtocolMethodOnSecondResponseTable;
} // namespace
SecondProtocol::ResultOf::MethodOnSecond_Impl::MethodOnSecond_Impl(
::zx::unowned_channel _client_end) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<
MethodOnSecondRequest, ::fidl::MessageDirection::kSending>();
::fidl::internal::AlignedBuffer<_kWriteAllocSize> _write_bytes_inlined;
auto& _write_bytes_array = _write_bytes_inlined;
uint8_t* _write_bytes = _write_bytes_array.view().data();
memset(_write_bytes, 0, MethodOnSecondRequest::PrimarySize);
::fidl::BytePart _request_bytes(_write_bytes, _kWriteAllocSize,
sizeof(MethodOnSecondRequest));
::fidl::DecodedMessage<MethodOnSecondRequest> _decoded_request(
std::move(_request_bytes));
Super::operator=(
SecondProtocol::InPlace::MethodOnSecond(std::move(_client_end)));
}
SecondProtocol::ResultOf::MethodOnSecond
SecondProtocol::SyncClient::MethodOnSecond() {
return ResultOf::MethodOnSecond(::zx::unowned_channel(this->channel_));
}
SecondProtocol::ResultOf::MethodOnSecond SecondProtocol::Call::MethodOnSecond(
::zx::unowned_channel _client_end) {
return ResultOf::MethodOnSecond(std::move(_client_end));
}
::fidl::internal::StatusAndError SecondProtocol::InPlace::MethodOnSecond(
::zx::unowned_channel _client_end) {
constexpr uint32_t _write_num_bytes = sizeof(MethodOnSecondRequest);
::fidl::internal::AlignedBuffer<_write_num_bytes> _write_bytes;
::fidl::BytePart _request_buffer = _write_bytes.view();
_request_buffer.set_actual(_write_num_bytes);
::fidl::DecodedMessage<MethodOnSecondRequest> params(
std::move(_request_buffer));
SecondProtocol::SetTransactionHeaderFor::MethodOnSecondRequest(params);
auto _encode_request_result = ::fidl::Encode(std::move(params));
if (_encode_request_result.status != ZX_OK) {
return ::fidl::internal::StatusAndError::FromFailure(
std::move(_encode_request_result));
}
zx_status_t _write_status = ::fidl::Write(
std::move(_client_end), std::move(_encode_request_result.message));
if (_write_status != ZX_OK) {
return ::fidl::internal::StatusAndError(
_write_status, ::fidl::internal::kErrorWriteFailed);
} else {
return ::fidl::internal::StatusAndError(ZX_OK, nullptr);
}
}
bool SecondProtocol::TryDispatch(Interface* impl, fidl_msg_t* msg,
::fidl::Transaction* txn) {
if (msg->num_bytes < sizeof(fidl_message_header_t)) {
zx_handle_close_many(msg->handles, msg->num_handles);
txn->Close(ZX_ERR_INVALID_ARGS);
return true;
}
fidl_message_header_t* hdr =
reinterpret_cast<fidl_message_header_t*>(msg->bytes);
zx_status_t status = fidl_validate_txn_header(hdr);
if (status != ZX_OK) {
txn->Close(status);
return true;
}
switch (hdr->ordinal) {
case kSecondProtocol_MethodOnSecond_Ordinal:
case kSecondProtocol_MethodOnSecond_GenOrdinal: {
auto result = ::fidl::DecodeAs<MethodOnSecondRequest>(msg);
if (result.status != ZX_OK) {
txn->Close(ZX_ERR_INVALID_ARGS);
return true;
}
impl->MethodOnSecond(Interface::MethodOnSecondCompleter::Sync(txn));
return true;
}
default: {
return false;
}
}
}
bool SecondProtocol::Dispatch(Interface* impl, fidl_msg_t* msg,
::fidl::Transaction* txn) {
bool found = TryDispatch(impl, msg, txn);
if (!found) {
zx_handle_close_many(msg->handles, msg->num_handles);
txn->Close(ZX_ERR_NOT_SUPPORTED);
}
return found;
}
void SecondProtocol::SetTransactionHeaderFor::MethodOnSecondRequest(
const ::fidl::DecodedMessage<SecondProtocol::MethodOnSecondRequest>& _msg) {
fidl_init_txn_header(&_msg.message()->_hdr, 0,
kSecondProtocol_MethodOnSecond_GenOrdinal);
_msg.message()->_hdr.flags[0] |= FIDL_TXN_HEADER_UNION_FROM_XUNION_FLAG;
}
namespace {
[[maybe_unused]] constexpr uint64_t kFirstProtocol_MethodOnFirst_Ordinal =
0x2838a83100000000lu;
[[maybe_unused]] constexpr uint64_t kFirstProtocol_MethodOnFirst_GenOrdinal =
0x580cbd0d43ccbe3blu;
extern "C" const fidl_type_t
v1_test_name_FirstProtocolMethodOnFirstRequestTable;
extern "C" const fidl_type_t
v1_test_name_FirstProtocolMethodOnFirstResponseTable;
} // namespace
FirstProtocol::ResultOf::MethodOnFirst_Impl::MethodOnFirst_Impl(
::zx::unowned_channel _client_end) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<
MethodOnFirstRequest, ::fidl::MessageDirection::kSending>();
::fidl::internal::AlignedBuffer<_kWriteAllocSize> _write_bytes_inlined;
auto& _write_bytes_array = _write_bytes_inlined;
uint8_t* _write_bytes = _write_bytes_array.view().data();
memset(_write_bytes, 0, MethodOnFirstRequest::PrimarySize);
::fidl::BytePart _request_bytes(_write_bytes, _kWriteAllocSize,
sizeof(MethodOnFirstRequest));
::fidl::DecodedMessage<MethodOnFirstRequest> _decoded_request(
std::move(_request_bytes));
Super::operator=(
FirstProtocol::InPlace::MethodOnFirst(std::move(_client_end)));
}
FirstProtocol::ResultOf::MethodOnFirst
FirstProtocol::SyncClient::MethodOnFirst() {
return ResultOf::MethodOnFirst(::zx::unowned_channel(this->channel_));
}
FirstProtocol::ResultOf::MethodOnFirst FirstProtocol::Call::MethodOnFirst(
::zx::unowned_channel _client_end) {
return ResultOf::MethodOnFirst(std::move(_client_end));
}
::fidl::internal::StatusAndError FirstProtocol::InPlace::MethodOnFirst(
::zx::unowned_channel _client_end) {
constexpr uint32_t _write_num_bytes = sizeof(MethodOnFirstRequest);
::fidl::internal::AlignedBuffer<_write_num_bytes> _write_bytes;
::fidl::BytePart _request_buffer = _write_bytes.view();
_request_buffer.set_actual(_write_num_bytes);
::fidl::DecodedMessage<MethodOnFirstRequest> params(
std::move(_request_buffer));
FirstProtocol::SetTransactionHeaderFor::MethodOnFirstRequest(params);
auto _encode_request_result = ::fidl::Encode(std::move(params));
if (_encode_request_result.status != ZX_OK) {
return ::fidl::internal::StatusAndError::FromFailure(
std::move(_encode_request_result));
}
zx_status_t _write_status = ::fidl::Write(
std::move(_client_end), std::move(_encode_request_result.message));
if (_write_status != ZX_OK) {
return ::fidl::internal::StatusAndError(
_write_status, ::fidl::internal::kErrorWriteFailed);
} else {
return ::fidl::internal::StatusAndError(ZX_OK, nullptr);
}
}
bool FirstProtocol::TryDispatch(Interface* impl, fidl_msg_t* msg,
::fidl::Transaction* txn) {
if (msg->num_bytes < sizeof(fidl_message_header_t)) {
zx_handle_close_many(msg->handles, msg->num_handles);
txn->Close(ZX_ERR_INVALID_ARGS);
return true;
}
fidl_message_header_t* hdr =
reinterpret_cast<fidl_message_header_t*>(msg->bytes);
zx_status_t status = fidl_validate_txn_header(hdr);
if (status != ZX_OK) {
txn->Close(status);
return true;
}
switch (hdr->ordinal) {
case kFirstProtocol_MethodOnFirst_Ordinal:
case kFirstProtocol_MethodOnFirst_GenOrdinal: {
auto result = ::fidl::DecodeAs<MethodOnFirstRequest>(msg);
if (result.status != ZX_OK) {
txn->Close(ZX_ERR_INVALID_ARGS);
return true;
}
impl->MethodOnFirst(Interface::MethodOnFirstCompleter::Sync(txn));
return true;
}
default: {
return false;
}
}
}
bool FirstProtocol::Dispatch(Interface* impl, fidl_msg_t* msg,
::fidl::Transaction* txn) {
bool found = TryDispatch(impl, msg, txn);
if (!found) {
zx_handle_close_many(msg->handles, msg->num_handles);
txn->Close(ZX_ERR_NOT_SUPPORTED);
}
return found;
}
void FirstProtocol::SetTransactionHeaderFor::MethodOnFirstRequest(
const ::fidl::DecodedMessage<FirstProtocol::MethodOnFirstRequest>& _msg) {
fidl_init_txn_header(&_msg.message()->_hdr, 0,
kFirstProtocol_MethodOnFirst_GenOrdinal);
_msg.message()->_hdr.flags[0] |= FIDL_TXN_HEADER_UNION_FROM_XUNION_FLAG;
}
} // namespace name
} // namespace test
} // namespace llcpp