blob: 7d458b357ef2107de9fd923a7918929078ace745 [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_GetCurrentDevicePowerState_Result::TestDevice_GetCurrentDevicePowerState_Result() {
tag_ = Tag::Invalid;
}
::llcpp::fuchsia::device::power::test::TestDevice_GetCurrentDevicePowerState_Result::~TestDevice_GetCurrentDevicePowerState_Result() {
Destroy();
}
void ::llcpp::fuchsia::device::power::test::TestDevice_GetCurrentDevicePowerState_Result::Destroy() {
switch (which()) {
case Tag::kResponse:
response_.~TestDevice_GetCurrentDevicePowerState_Response();
break;
default:
break;
}
tag_ = Tag::Invalid;
}
void ::llcpp::fuchsia::device::power::test::TestDevice_GetCurrentDevicePowerState_Result::MoveImpl_(TestDevice_GetCurrentDevicePowerState_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_GetCurrentDevicePowerState_Result::SizeAndOffsetAssertionHelper() {
static_assert(offsetof(::llcpp::fuchsia::device::power::test::TestDevice_GetCurrentDevicePowerState_Result, response_) == 4);
static_assert(offsetof(::llcpp::fuchsia::device::power::test::TestDevice_GetCurrentDevicePowerState_Result, err_) == 4);
static_assert(sizeof(::llcpp::fuchsia::device::power::test::TestDevice_GetCurrentDevicePowerState_Result) == ::llcpp::fuchsia::device::power::test::TestDevice_GetCurrentDevicePowerState_Result::PrimarySize);
}
TestDevice_GetCurrentDevicePowerState_Response& ::llcpp::fuchsia::device::power::test::TestDevice_GetCurrentDevicePowerState_Result::mutable_response() {
if (which() != Tag::kResponse) {
Destroy();
new (&response_) TestDevice_GetCurrentDevicePowerState_Response;
}
tag_ = Tag::kResponse;
return response_;
}
int32_t& ::llcpp::fuchsia::device::power::test::TestDevice_GetCurrentDevicePowerState_Result::mutable_err() {
if (which() != Tag::kErr) {
Destroy();
new (&err_) int32_t;
}
tag_ = Tag::kErr;
return err_;
}
::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_Ordinal = 0x5d89a15400000000lu;
extern "C" const fidl_type_t fuchsia_device_power_test_TestDeviceAddDeviceWithPowerArgsRequestTable;
extern "C" const fidl_type_t fuchsia_device_power_test_TestDeviceAddDeviceWithPowerArgsResponseTable;
[[maybe_unused]]
constexpr uint64_t kTestDevice_GetCurrentDevicePowerState_Ordinal = 0x724b2ef700000000lu;
extern "C" const fidl_type_t fuchsia_device_power_test_TestDeviceGetCurrentDevicePowerStateResponseTable;
} // 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_Ordinal;
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));
}
template <>
TestDevice::ResultOf::GetCurrentDevicePowerState_Impl<TestDevice::GetCurrentDevicePowerStateResponse>::GetCurrentDevicePowerState_Impl(zx::unowned_channel _client_end) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<GetCurrentDevicePowerStateRequest, ::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, GetCurrentDevicePowerStateRequest::PrimarySize);
::fidl::BytePart _request_bytes(_write_bytes, _kWriteAllocSize, sizeof(GetCurrentDevicePowerStateRequest));
::fidl::DecodedMessage<GetCurrentDevicePowerStateRequest> _decoded_request(std::move(_request_bytes));
Super::SetResult(
TestDevice::InPlace::GetCurrentDevicePowerState(std::move(_client_end), Super::response_buffer()));
}
TestDevice::ResultOf::GetCurrentDevicePowerState TestDevice::SyncClient::GetCurrentDevicePowerState() {
return ResultOf::GetCurrentDevicePowerState(zx::unowned_channel(this->channel_));
}
TestDevice::ResultOf::GetCurrentDevicePowerState TestDevice::Call::GetCurrentDevicePowerState(zx::unowned_channel _client_end) {
return ResultOf::GetCurrentDevicePowerState(std::move(_client_end));
}
template <>
TestDevice::UnownedResultOf::GetCurrentDevicePowerState_Impl<TestDevice::GetCurrentDevicePowerStateResponse>::GetCurrentDevicePowerState_Impl(zx::unowned_channel _client_end, ::fidl::BytePart _response_buffer) {
FIDL_ALIGNDECL uint8_t _write_bytes[sizeof(GetCurrentDevicePowerStateRequest)] = {};
::fidl::BytePart _request_buffer(_write_bytes, sizeof(_write_bytes));
memset(_request_buffer.data(), 0, GetCurrentDevicePowerStateRequest::PrimarySize);
_request_buffer.set_actual(sizeof(GetCurrentDevicePowerStateRequest));
::fidl::DecodedMessage<GetCurrentDevicePowerStateRequest> _decoded_request(std::move(_request_buffer));
Super::SetResult(
TestDevice::InPlace::GetCurrentDevicePowerState(std::move(_client_end), std::move(_response_buffer)));
}
TestDevice::UnownedResultOf::GetCurrentDevicePowerState TestDevice::SyncClient::GetCurrentDevicePowerState(::fidl::BytePart _response_buffer) {
return UnownedResultOf::GetCurrentDevicePowerState(zx::unowned_channel(this->channel_), std::move(_response_buffer));
}
TestDevice::UnownedResultOf::GetCurrentDevicePowerState TestDevice::Call::GetCurrentDevicePowerState(zx::unowned_channel _client_end, ::fidl::BytePart _response_buffer) {
return UnownedResultOf::GetCurrentDevicePowerState(std::move(_client_end), std::move(_response_buffer));
}
::fidl::DecodeResult<TestDevice::GetCurrentDevicePowerStateResponse> TestDevice::InPlace::GetCurrentDevicePowerState(zx::unowned_channel _client_end, ::fidl::BytePart response_buffer) {
constexpr uint32_t _write_num_bytes = sizeof(GetCurrentDevicePowerStateRequest);
::fidl::internal::AlignedBuffer<_write_num_bytes> _write_bytes;
::fidl::BytePart _request_buffer = _write_bytes.view();
_request_buffer.set_actual(_write_num_bytes);
::fidl::DecodedMessage<GetCurrentDevicePowerStateRequest> params(std::move(_request_buffer));
params.message()->_hdr = {};
params.message()->_hdr.ordinal = kTestDevice_GetCurrentDevicePowerState_Ordinal;
auto _encode_request_result = ::fidl::Encode(std::move(params));
if (_encode_request_result.status != ZX_OK) {
return ::fidl::DecodeResult<TestDevice::GetCurrentDevicePowerStateResponse>::FromFailure(
std::move(_encode_request_result));
}
auto _call_result = ::fidl::Call<GetCurrentDevicePowerStateRequest, GetCurrentDevicePowerStateResponse>(
std::move(_client_end), std::move(_encode_request_result.message), std::move(response_buffer));
if (_call_result.status != ZX_OK) {
return ::fidl::DecodeResult<TestDevice::GetCurrentDevicePowerStateResponse>::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_Ordinal:
{
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;
}
case kTestDevice_GetCurrentDevicePowerState_Ordinal:
{
auto result = ::fidl::DecodeAs<GetCurrentDevicePowerStateRequest>(msg);
if (result.status != ZX_OK) {
txn->Close(ZX_ERR_INVALID_ARGS);
return true;
}
impl->GetCurrentDevicePowerState(
Interface::GetCurrentDevicePowerStateCompleter::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_Ordinal;
_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_Ordinal;
_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_Ordinal;
CompleterBase::SendReply(std::move(params));
}
void TestDevice::Interface::GetCurrentDevicePowerStateCompleterBase::Reply(TestDevice_GetCurrentDevicePowerState_Result result) {
constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize<GetCurrentDevicePowerStateResponse, ::fidl::MessageDirection::kSending>();
FIDL_ALIGNDECL uint8_t _write_bytes[_kWriteAllocSize] = {};
auto& _response = *reinterpret_cast<GetCurrentDevicePowerStateResponse*>(_write_bytes);
_response._hdr.ordinal = kTestDevice_GetCurrentDevicePowerState_Ordinal;
_response.result = std::move(result);
::fidl::BytePart _response_bytes(_write_bytes, _kWriteAllocSize, sizeof(GetCurrentDevicePowerStateResponse));
CompleterBase::SendReply(::fidl::DecodedMessage<GetCurrentDevicePowerStateResponse>(std::move(_response_bytes)));
}
void TestDevice::Interface::GetCurrentDevicePowerStateCompleterBase::Reply(::fidl::BytePart _buffer, TestDevice_GetCurrentDevicePowerState_Result result) {
if (_buffer.capacity() < GetCurrentDevicePowerStateResponse::PrimarySize) {
CompleterBase::Close(ZX_ERR_INTERNAL);
return;
}
auto& _response = *reinterpret_cast<GetCurrentDevicePowerStateResponse*>(_buffer.data());
_response._hdr.ordinal = kTestDevice_GetCurrentDevicePowerState_Ordinal;
_response.result = std::move(result);
_buffer.set_actual(sizeof(GetCurrentDevicePowerStateResponse));
CompleterBase::SendReply(::fidl::DecodedMessage<GetCurrentDevicePowerStateResponse>(std::move(_buffer)));
}
void TestDevice::Interface::GetCurrentDevicePowerStateCompleterBase::Reply(::fidl::DecodedMessage<GetCurrentDevicePowerStateResponse> params) {
params.message()->_hdr = {};
params.message()->_hdr.ordinal = kTestDevice_GetCurrentDevicePowerState_Ordinal;
CompleterBase::SendReply(std::move(params));
}
} // namespace test
} // namespace power
} // namespace device
} // namespace fuchsia
} // namespace llcpp