blob: 17349d0245deff48bc133e21d4fa216a30cbef48 [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
#include <fuchsia/device/power/test/llcpp/fidl.h>
#include <memory>
namespace llcpp {
namespace fuchsia {
namespace device {
namespace power {
namespace test {
::llcpp::fuchsia::device::power::test::TestDevice_AddDeviceWithPowerArgs_Result::TestDevice_AddDeviceWithPowerArgs_Result() {
tag_ = Tag::Invalid;
}
::llcpp::fuchsia::device::power::test::TestDevice_AddDeviceWithPowerArgs_Result::~TestDevice_AddDeviceWithPowerArgs_Result() {
Destroy();
}
void ::llcpp::fuchsia::device::power::test::TestDevice_AddDeviceWithPowerArgs_Result::Destroy() {
switch (which()) {
case Tag::kResponse:
response_.~TestDevice_AddDeviceWithPowerArgs_Response();
break;
default:
break;
}
tag_ = Tag::Invalid;
}
void ::llcpp::fuchsia::device::power::test::TestDevice_AddDeviceWithPowerArgs_Result::MoveImpl_(TestDevice_AddDeviceWithPowerArgs_Result&& other) {
switch (other.which()) {
case Tag::kResponse:
mutable_response() = std::move(other.mutable_response());
break;
case Tag::kErr:
mutable_err() = std::move(other.mutable_err());
break;
default:
break;
}
other.Destroy();
}
void ::llcpp::fuchsia::device::power::test::TestDevice_AddDeviceWithPowerArgs_Result::SizeAndOffsetAssertionHelper() {
static_assert(offsetof(::llcpp::fuchsia::device::power::test::TestDevice_AddDeviceWithPowerArgs_Result, response_) == 4);
static_assert(offsetof(::llcpp::fuchsia::device::power::test::TestDevice_AddDeviceWithPowerArgs_Result, err_) == 4);
static_assert(sizeof(::llcpp::fuchsia::device::power::test::TestDevice_AddDeviceWithPowerArgs_Result) == ::llcpp::fuchsia::device::power::test::TestDevice_AddDeviceWithPowerArgs_Result::PrimarySize);
}
TestDevice_AddDeviceWithPowerArgs_Response& ::llcpp::fuchsia::device::power::test::TestDevice_AddDeviceWithPowerArgs_Result::mutable_response() {
if (which() != Tag::kResponse) {
Destroy();
new (&response_) TestDevice_AddDeviceWithPowerArgs_Response;
}
tag_ = Tag::kResponse;
return response_;
}
int32_t& ::llcpp::fuchsia::device::power::test::TestDevice_AddDeviceWithPowerArgs_Result::mutable_err() {
if (which() != Tag::kErr) {
Destroy();
new (&err_) int32_t;
}
tag_ = Tag::kErr;
return err_;
}
namespace {
[[maybe_unused]]
constexpr uint64_t kTestDevice_AddDeviceWithPowerArgs_GenOrdinal = 0x5d89a15400000000lu;
extern "C" const fidl_type_t fuchsia_device_power_test_TestDeviceAddDeviceWithPowerArgsRequestTable;
extern "C" const fidl_type_t fuchsia_device_power_test_TestDeviceAddDeviceWithPowerArgsResponseTable;
} // namespace
template <>
TestDevice::ResultOf::AddDeviceWithPowerArgs_Impl<TestDevice::AddDeviceWithPowerArgsResponse>::AddDeviceWithPowerArgs_Impl(zx::unowned_channel _client_end, ::fidl::VectorView<::llcpp::fuchsia::device::DevicePowerStateInfo> info) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<AddDeviceWithPowerArgsRequest, ::fidl::MessageDirection::kSending>();
std::unique_ptr _write_bytes_boxed = std::make_unique<::fidl::internal::AlignedBuffer<_kWriteAllocSize>>();
auto& _write_bytes_array = *_write_bytes_boxed;
AddDeviceWithPowerArgsRequest _request = {};
_request.info = std::move(info);
auto _linearize_result = ::fidl::Linearize(&_request, _write_bytes_array.view());
if (_linearize_result.status != ZX_OK) {
Super::SetFailure(std::move(_linearize_result));
return;
}
::fidl::DecodedMessage<AddDeviceWithPowerArgsRequest> _decoded_request = std::move(_linearize_result.message);
Super::SetResult(
TestDevice::InPlace::AddDeviceWithPowerArgs(std::move(_client_end), std::move(_decoded_request), Super::response_buffer()));
}
TestDevice::ResultOf::AddDeviceWithPowerArgs TestDevice::SyncClient::AddDeviceWithPowerArgs(::fidl::VectorView<::llcpp::fuchsia::device::DevicePowerStateInfo> info) {
return ResultOf::AddDeviceWithPowerArgs(zx::unowned_channel(this->channel_), std::move(info));
}
TestDevice::ResultOf::AddDeviceWithPowerArgs TestDevice::Call::AddDeviceWithPowerArgs(zx::unowned_channel _client_end, ::fidl::VectorView<::llcpp::fuchsia::device::DevicePowerStateInfo> info) {
return ResultOf::AddDeviceWithPowerArgs(std::move(_client_end), std::move(info));
}
template <>
TestDevice::UnownedResultOf::AddDeviceWithPowerArgs_Impl<TestDevice::AddDeviceWithPowerArgsResponse>::AddDeviceWithPowerArgs_Impl(zx::unowned_channel _client_end, ::fidl::BytePart _request_buffer, ::fidl::VectorView<::llcpp::fuchsia::device::DevicePowerStateInfo> info, ::fidl::BytePart _response_buffer) {
if (_request_buffer.capacity() < AddDeviceWithPowerArgsRequest::PrimarySize) {
Super::SetFailure(::fidl::DecodeResult<AddDeviceWithPowerArgsResponse>(ZX_ERR_BUFFER_TOO_SMALL, ::fidl::internal::kErrorRequestBufferTooSmall));
return;
}
AddDeviceWithPowerArgsRequest _request = {};
_request.info = std::move(info);
auto _linearize_result = ::fidl::Linearize(&_request, std::move(_request_buffer));
if (_linearize_result.status != ZX_OK) {
Super::SetFailure(std::move(_linearize_result));
return;
}
::fidl::DecodedMessage<AddDeviceWithPowerArgsRequest> _decoded_request = std::move(_linearize_result.message);
Super::SetResult(
TestDevice::InPlace::AddDeviceWithPowerArgs(std::move(_client_end), std::move(_decoded_request), std::move(_response_buffer)));
}
TestDevice::UnownedResultOf::AddDeviceWithPowerArgs TestDevice::SyncClient::AddDeviceWithPowerArgs(::fidl::BytePart _request_buffer, ::fidl::VectorView<::llcpp::fuchsia::device::DevicePowerStateInfo> info, ::fidl::BytePart _response_buffer) {
return UnownedResultOf::AddDeviceWithPowerArgs(zx::unowned_channel(this->channel_), std::move(_request_buffer), std::move(info), std::move(_response_buffer));
}
TestDevice::UnownedResultOf::AddDeviceWithPowerArgs TestDevice::Call::AddDeviceWithPowerArgs(zx::unowned_channel _client_end, ::fidl::BytePart _request_buffer, ::fidl::VectorView<::llcpp::fuchsia::device::DevicePowerStateInfo> info, ::fidl::BytePart _response_buffer) {
return UnownedResultOf::AddDeviceWithPowerArgs(std::move(_client_end), std::move(_request_buffer), std::move(info), std::move(_response_buffer));
}
::fidl::DecodeResult<TestDevice::AddDeviceWithPowerArgsResponse> TestDevice::InPlace::AddDeviceWithPowerArgs(zx::unowned_channel _client_end, ::fidl::DecodedMessage<AddDeviceWithPowerArgsRequest> params, ::fidl::BytePart response_buffer) {
params.message()->_hdr = {};
params.message()->_hdr.ordinal = kTestDevice_AddDeviceWithPowerArgs_GenOrdinal;
auto _encode_request_result = ::fidl::Encode(std::move(params));
if (_encode_request_result.status != ZX_OK) {
return ::fidl::DecodeResult<TestDevice::AddDeviceWithPowerArgsResponse>::FromFailure(
std::move(_encode_request_result));
}
auto _call_result = ::fidl::Call<AddDeviceWithPowerArgsRequest, AddDeviceWithPowerArgsResponse>(
std::move(_client_end), std::move(_encode_request_result.message), std::move(response_buffer));
if (_call_result.status != ZX_OK) {
return ::fidl::DecodeResult<TestDevice::AddDeviceWithPowerArgsResponse>::FromFailure(
std::move(_call_result));
}
return ::fidl::Decode(std::move(_call_result.message));
}
bool TestDevice::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);
switch (hdr->ordinal) {
case kTestDevice_AddDeviceWithPowerArgs_GenOrdinal:
{
auto result = ::fidl::DecodeAs<AddDeviceWithPowerArgsRequest>(msg);
if (result.status != ZX_OK) {
txn->Close(ZX_ERR_INVALID_ARGS);
return true;
}
auto message = result.message.message();
impl->AddDeviceWithPowerArgs(std::move(message->info),
Interface::AddDeviceWithPowerArgsCompleter::Sync(txn));
return true;
}
default: {
return false;
}
}
}
bool TestDevice::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 TestDevice::Interface::AddDeviceWithPowerArgsCompleterBase::Reply(TestDevice_AddDeviceWithPowerArgs_Result result) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<AddDeviceWithPowerArgsResponse, ::fidl::MessageDirection::kSending>();
FIDL_ALIGNDECL uint8_t _write_bytes[_kWriteAllocSize] = {};
auto& _response = *reinterpret_cast<AddDeviceWithPowerArgsResponse*>(_write_bytes);
_response._hdr.ordinal = kTestDevice_AddDeviceWithPowerArgs_GenOrdinal;
_response.result = std::move(result);
::fidl::BytePart _response_bytes(_write_bytes, _kWriteAllocSize, sizeof(AddDeviceWithPowerArgsResponse));
CompleterBase::SendReply(::fidl::DecodedMessage<AddDeviceWithPowerArgsResponse>(std::move(_response_bytes)));
}
void TestDevice::Interface::AddDeviceWithPowerArgsCompleterBase::Reply(::fidl::BytePart _buffer, TestDevice_AddDeviceWithPowerArgs_Result result) {
if (_buffer.capacity() < AddDeviceWithPowerArgsResponse::PrimarySize) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
auto& _response = *reinterpret_cast<AddDeviceWithPowerArgsResponse*>(_buffer.data());
_response._hdr.ordinal = kTestDevice_AddDeviceWithPowerArgs_GenOrdinal;
_response.result = std::move(result);
_buffer.set_actual(sizeof(AddDeviceWithPowerArgsResponse));
CompleterBase::SendReply(::fidl::DecodedMessage<AddDeviceWithPowerArgsResponse>(std::move(_buffer)));
}
void TestDevice::Interface::AddDeviceWithPowerArgsCompleterBase::Reply(::fidl::DecodedMessage<AddDeviceWithPowerArgsResponse> params) {
params.message()->_hdr = {};
params.message()->_hdr.ordinal = kTestDevice_AddDeviceWithPowerArgs_GenOrdinal;
CompleterBase::SendReply(std::move(params));
}
} // namespace test
} // namespace power
} // namespace device
} // namespace fuchsia
} // namespace llcpp