blob: d5786e571f91c8b2e796f248b1e7316588262dbd [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
#include <fidl/test/emptystruct/cpp/fidl.h>
#include "lib/fidl/cpp/internal/implementation.h"
//
// Domain objects definitions (i.e. "natural types" in unified bindings)
//
namespace fidl {
namespace test {
namespace emptystruct {
extern "C" const fidl_type_t fidl_test_emptystruct_EmptyTable;
const fidl_type_t* Empty::FidlType = &fidl_test_emptystruct_EmptyTable;
void Empty::Encode(
::fidl::Encoder* _encoder, size_t _offset,
cpp17::optional<::fidl::HandleInformation> maybe_handle_info) {
if (::fidl::IsMemcpyCompatible<Empty>::value) {
memcpy(_encoder->template GetPtr<Empty>(_offset), this, sizeof(Empty));
} else {
::fidl::Encode(_encoder, &__reserved, _offset + 0);
}
}
void Empty::Decode(::fidl::Decoder* _decoder, Empty* _value, size_t _offset) {
if (::fidl::IsMemcpyCompatible<Empty>::value) {
memcpy(_value, _decoder->template GetPtr<Empty>(_offset), sizeof(Empty));
} else {
::fidl::Decode(_decoder, &_value->__reserved, _offset + 0);
}
}
zx_status_t Empty::Clone(Empty* _result) const {
zx_status_t _status = ::fidl::Clone(__reserved, &_result->__reserved);
if (_status != ZX_OK) return _status;
return ZX_OK;
}
//
// Proxies and stubs definitions
//
#ifdef __Fuchsia__
namespace _internal {
extern "C" const fidl_type_t
fidl_test_emptystruct_EmptyProtocolSendRequestTable;
extern "C" const fidl_type_t
fidl_test_emptystruct_EmptyProtocolReceiveEventTable;
extern "C" const fidl_type_t
fidl_test_emptystruct_EmptyProtocolSendAndReceiveRequestTable;
extern "C" const fidl_type_t
fidl_test_emptystruct_EmptyProtocolSendAndReceiveResponseTable;
} // namespace _internal
EmptyProtocol::~EmptyProtocol() = default;
const fidl_type_t* ::fidl::test::emptystruct::EmptyProtocol_RequestDecoder::
GetType(uint64_t ordinal, bool* out_needs_response) {
switch (ordinal) {
case internal::kEmptyProtocol_Send_Ordinal:
*out_needs_response = false;
return &::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolSendRequestTable;
case internal::kEmptyProtocol_SendAndReceive_Ordinal:
*out_needs_response = true;
return &::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolSendAndReceiveRequestTable;
default:
*out_needs_response = false;
return nullptr;
}
}
const fidl_type_t* EmptyProtocol_ResponseDecoder::GetType(uint64_t ordinal) {
switch (ordinal) {
case internal::kEmptyProtocol_Receive_Ordinal:
return &::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolReceiveEventTable;
case internal::kEmptyProtocol_SendAndReceive_Ordinal:
return &::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolSendAndReceiveResponseTable;
default:
return nullptr;
}
}
EmptyProtocol_EventSender::~EmptyProtocol_EventSender() = default;
EmptyProtocol_Sync::~EmptyProtocol_Sync() = default;
EmptyProtocol_Proxy::EmptyProtocol_Proxy(
::fidl::internal::ProxyController* controller)
: controller_(controller) {
(void)controller_;
}
EmptyProtocol_Proxy::~EmptyProtocol_Proxy() = default;
zx_status_t EmptyProtocol_Proxy::Dispatch_(
::fidl::HLCPPIncomingMessage message) {
zx_status_t status = ZX_OK;
switch (message.ordinal()) {
case internal::kEmptyProtocol_Receive_Ordinal: {
if (!Receive) {
status = ZX_OK;
break;
}
const char* error_msg = nullptr;
status = message.Decode(
&::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolReceiveEventTable,
&error_msg);
if (status != ZX_OK) {
FIDL_REPORT_DECODING_ERROR(
message,
&::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolReceiveEventTable,
error_msg);
break;
}
::fidl::Decoder decoder(std::move(message));
Receive(::fidl::DecodeAs<::fidl::test::emptystruct::Empty>(&decoder, 16));
break;
}
default: {
status = ZX_ERR_NOT_SUPPORTED;
break;
}
}
return status;
}
void EmptyProtocol_Proxy::Send(::fidl::test::emptystruct::Empty e) {
::fidl::Encoder _encoder(internal::kEmptyProtocol_Send_Ordinal);
controller_->Send(
&::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolSendRequestTable,
::fidl::test::emptystruct::EmptyProtocol_RequestEncoder::Send(&_encoder,
&e),
nullptr);
}
namespace {
::std::unique_ptr<::fidl::internal::SingleUseMessageHandler>
EmptyProtocol_SendAndReceive_ResponseHandler(
EmptyProtocol::SendAndReceiveCallback&& callback) {
ZX_DEBUG_ASSERT_MSG(
callback,
"Callback must not be empty for EmptyProtocol::SendAndReceive\n");
return ::std::make_unique<::fidl::internal::SingleUseMessageHandler>(
[callback_ =
std::move(callback)](::fidl::HLCPPIncomingMessage&& message) {
::fidl::Decoder decoder(std::move(message));
callback_(
::fidl::DecodeAs<::fidl::test::emptystruct::Empty>(&decoder, 16));
return ZX_OK;
},
&::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolSendAndReceiveResponseTable);
}
} // namespace
void EmptyProtocol_Proxy::SendAndReceive(::fidl::test::emptystruct::Empty e,
SendAndReceiveCallback callback) {
::fidl::Encoder _encoder(internal::kEmptyProtocol_SendAndReceive_Ordinal);
controller_->Send(
&::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolSendAndReceiveRequestTable,
::fidl::test::emptystruct::EmptyProtocol_RequestEncoder::SendAndReceive(
&_encoder, &e),
EmptyProtocol_SendAndReceive_ResponseHandler(std::move(callback)));
}
EmptyProtocol_Stub::EmptyProtocol_Stub(EmptyProtocol_clazz* impl)
: impl_(impl) {
(void)impl_;
}
EmptyProtocol_Stub::~EmptyProtocol_Stub() = default;
namespace {
class EmptyProtocol_SendAndReceive_Responder final {
public:
EmptyProtocol_SendAndReceive_Responder(
::fidl::internal::PendingResponse response)
: response_(std::move(response)) {}
void operator()(::fidl::test::emptystruct::Empty e) {
::fidl::Encoder _encoder(internal::kEmptyProtocol_SendAndReceive_Ordinal);
response_.Send(
&::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolSendAndReceiveResponseTable,
::fidl::test::emptystruct::EmptyProtocol_ResponseEncoder::
SendAndReceive(&_encoder, &e));
}
private:
::fidl::internal::PendingResponse response_;
};
} // namespace
zx_status_t EmptyProtocol_Stub::Dispatch_(
::fidl::HLCPPIncomingMessage message,
::fidl::internal::PendingResponse response) {
bool needs_response;
const fidl_type_t* request_type =
::fidl::test::emptystruct::EmptyProtocol_RequestDecoder::GetType(
message.ordinal(), &needs_response);
if (request_type == nullptr) {
return ZX_ERR_NOT_SUPPORTED;
}
if (response.needs_response() != needs_response) {
if (needs_response) {
FIDL_REPORT_DECODING_ERROR(message, request_type,
"Message needing a response with no txid");
} else {
FIDL_REPORT_DECODING_ERROR(message, request_type,
"Message not needing a response with a txid");
}
return ZX_ERR_INVALID_ARGS;
}
const char* error_msg = nullptr;
zx_status_t status = message.Decode(request_type, &error_msg);
if (status != ZX_OK) {
FIDL_REPORT_DECODING_ERROR(message, request_type, error_msg);
return status;
}
uint64_t ordinal = message.ordinal();
switch (ordinal) {
case internal::kEmptyProtocol_Send_Ordinal: {
::fidl::Decoder decoder(std::move(message));
impl_->Send(
::fidl::DecodeAs<::fidl::test::emptystruct::Empty>(&decoder, 16));
break;
}
case internal::kEmptyProtocol_SendAndReceive_Ordinal: {
::fidl::Decoder decoder(std::move(message));
impl_->SendAndReceive(
::fidl::DecodeAs<::fidl::test::emptystruct::Empty>(&decoder, 16),
EmptyProtocol_SendAndReceive_Responder(std::move(response)));
break;
}
default: {
status = ZX_ERR_NOT_SUPPORTED;
break;
}
}
return status;
}
void EmptyProtocol_Stub::Receive(::fidl::test::emptystruct::Empty e) {
::fidl::Encoder _encoder(internal::kEmptyProtocol_Receive_Ordinal);
sender_()->Send(
&::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolReceiveEventTable,
::fidl::test::emptystruct::EmptyProtocol_ResponseEncoder::Receive(
&_encoder, &e));
}
EmptyProtocol_SyncProxy::EmptyProtocol_SyncProxy(::zx::channel channel)
: proxy_(::std::move(channel)) {}
EmptyProtocol_SyncProxy::~EmptyProtocol_SyncProxy() = default;
zx_status_t EmptyProtocol_SyncProxy::Send(::fidl::test::emptystruct::Empty e) {
::fidl::Encoder _encoder(internal::kEmptyProtocol_Send_Ordinal);
return proxy_.Send(
&::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolSendRequestTable,
::fidl::test::emptystruct::EmptyProtocol_RequestEncoder::Send(&_encoder,
&e));
}
zx_status_t EmptyProtocol_SyncProxy::SendAndReceive(
::fidl::test::emptystruct::Empty e,
::fidl::test::emptystruct::Empty* out_e) {
::fidl::Encoder _encoder(internal::kEmptyProtocol_SendAndReceive_Ordinal);
::fidl::IncomingMessageBuffer buffer_;
::fidl::HLCPPIncomingMessage response_ = buffer_.CreateEmptyIncomingMessage();
zx_status_t status_ = proxy_.Call(
&::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolSendAndReceiveRequestTable,
&::fidl::test::emptystruct::_internal::
fidl_test_emptystruct_EmptyProtocolSendAndReceiveResponseTable,
::fidl::test::emptystruct::EmptyProtocol_RequestEncoder::SendAndReceive(
&_encoder, &e),
&response_);
if (status_ != ZX_OK) return status_;
::fidl::Decoder decoder_(std::move(response_));
*out_e = ::fidl::DecodeAs<::fidl::test::emptystruct::Empty>(&decoder_, 16);
return ZX_OK;
}
#endif // __Fuchsia__
} // namespace emptystruct
} // namespace test
} // namespace fidl