| // WARNING: This file is machine generated by fidlgen. |
| |
| #include <inheritance.test.json.llcpp.h> |
| |
| #include <memory> |
| |
| namespace llcpp { |
| |
| namespace fidl { |
| namespace test { |
| namespace json { |
| |
| namespace { |
| |
| [[maybe_unused]] constexpr uint64_t ksuper_foo_Ordinal = 5722958650322615442lu; |
| extern "C" const fidl_type_t fidl_test_json_superfooRequestTable; |
| extern "C" const fidl_type_t fidl_test_json_superfooResponseTable; |
| |
| } // namespace |
| template <> |
| super::ResultOf::foo_Impl<super::fooResponse>::foo_Impl( |
| ::zx::unowned_channel _client_end, const ::fidl::StringView& s) { |
| fooRequest _request(0, s); |
| |
| auto _encoded = ::fidl::internal::LinearizedAndEncoded<fooRequest>(&_request); |
| auto& _encode_result = _encoded.result(); |
| if (_encode_result.status != ZX_OK) { |
| Super::SetFailure(std::move(_encode_result)); |
| return; |
| } |
| ::fidl::EncodedMessage<fooRequest> _encoded_request = |
| std::move(_encode_result.message); |
| Super::SetResult(super::InPlace::foo(std::move(_client_end), |
| std::move(_encoded_request), |
| Super::response_buffer())); |
| } |
| |
| super::ResultOf::foo super::SyncClient::foo(::fidl::StringView s) { |
| return ResultOf::foo(::zx::unowned_channel(this->channel_), s); |
| } |
| |
| super::ResultOf::foo super::Call::foo(::zx::unowned_channel _client_end, |
| ::fidl::StringView s) { |
| return ResultOf::foo(std::move(_client_end), s); |
| } |
| |
| template <> |
| super::UnownedResultOf::foo_Impl<super::fooResponse>::foo_Impl( |
| ::zx::unowned_channel _client_end, ::fidl::BytePart _request_buffer, |
| ::fidl::StringView s, ::fidl::BytePart _response_buffer) { |
| if (_request_buffer.capacity() < fooRequest::PrimarySize) { |
| Super::SetFailure(::fidl::DecodeResult<fooResponse>( |
| ZX_ERR_BUFFER_TOO_SMALL, ::fidl::kErrorRequestBufferTooSmall)); |
| return; |
| } |
| fooRequest _request(0, s); |
| auto _encode_result = ::fidl::LinearizeAndEncode<fooRequest>( |
| &_request, std::move(_request_buffer)); |
| if (_encode_result.status != ZX_OK) { |
| Super::SetFailure(std::move(_encode_result)); |
| return; |
| } |
| ::fidl::EncodedMessage<fooRequest> _encoded_request = |
| std::move(_encode_result.message); |
| Super::SetResult(super::InPlace::foo(std::move(_client_end), |
| std::move(_encoded_request), |
| std::move(_response_buffer))); |
| } |
| |
| super::UnownedResultOf::foo super::SyncClient::foo( |
| ::fidl::BytePart _request_buffer, ::fidl::StringView s, |
| ::fidl::BytePart _response_buffer) { |
| return UnownedResultOf::foo(::zx::unowned_channel(this->channel_), |
| std::move(_request_buffer), std::move(s), |
| std::move(_response_buffer)); |
| } |
| |
| super::UnownedResultOf::foo super::Call::foo( |
| ::zx::unowned_channel _client_end, ::fidl::BytePart _request_buffer, |
| ::fidl::StringView s, ::fidl::BytePart _response_buffer) { |
| return UnownedResultOf::foo(std::move(_client_end), |
| std::move(_request_buffer), std::move(s), |
| std::move(_response_buffer)); |
| } |
| |
| ::fidl::DecodeResult<super::fooResponse> super::InPlace::foo( |
| ::zx::unowned_channel _client_end, |
| ::fidl::DecodedMessage<fooRequest> params, |
| ::fidl::BytePart response_buffer) { |
| auto _encode_request_result = ::fidl::Encode(std::move(params)); |
| if (_encode_request_result.status != ZX_OK) { |
| return ::fidl::DecodeResult<super::fooResponse>::FromFailure( |
| std::move(_encode_request_result)); |
| } |
| return foo(std::move(_client_end), std::move(_encode_request_result.message), |
| std::move(response_buffer)); |
| } |
| |
| ::fidl::DecodeResult<super::fooResponse> super::InPlace::foo( |
| ::zx::unowned_channel _client_end, |
| ::fidl::EncodedMessage<fooRequest> params, |
| ::fidl::BytePart response_buffer) { |
| fooRequest* request = reinterpret_cast<fooRequest*>(params.bytes().data()); |
| fidl_init_txn_header(&request->_hdr, 0, ksuper_foo_Ordinal); |
| auto _call_result = ::fidl::Call<fooRequest, fooResponse>( |
| std::move(_client_end), std::move(params), std::move(response_buffer)); |
| if (_call_result.status != ZX_OK) { |
| return ::fidl::DecodeResult<super::fooResponse>::FromFailure( |
| std::move(_call_result)); |
| } |
| return ::fidl::Decode(std::move(_call_result.message)); |
| } |
| |
| super::ResultOf::foo super::ClientImpl::foo_Sync(::fidl::StringView s) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| return ResultOf::foo(_binding->channel(), s); |
| } |
| return ::fidl::StatusAndError(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| |
| super::UnownedResultOf::foo super::ClientImpl::foo_Sync( |
| ::fidl::BytePart _request_buffer, ::fidl::StringView s, |
| ::fidl::BytePart _response_buffer) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| return UnownedResultOf::foo(_binding->channel(), std::move(_request_buffer), |
| std::move(s), std::move(_response_buffer)); |
| } |
| return ::fidl::StatusAndError(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| |
| ::fidl::StatusAndError super::ClientImpl::foo( |
| ::fidl::StringView s, ::fit::callback<void(int64_t y)> _cb) { |
| class ManagedResponseContext : public fooResponseContext { |
| public: |
| ManagedResponseContext(::fit::callback<void(int64_t y)> cb) |
| : cb_(std::move(cb)) {} |
| |
| void OnReply(::fidl::DecodedMessage<fooResponse> msg) override { |
| auto message = msg.message(); |
| cb_(std::move(message->y)); |
| delete this; |
| } |
| |
| void OnError() override { delete this; } |
| |
| ::fit::callback<void(int64_t y)> cb_; |
| }; |
| constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize< |
| fooRequest, ::fidl::MessageDirection::kSending>(); |
| std::unique_ptr _write_bytes_boxed = |
| std::make_unique<::fidl::internal::AlignedBuffer<_kWriteAllocSize>>(); |
| auto& _write_bytes_array = *_write_bytes_boxed; |
| |
| auto* _context = new ManagedResponseContext(std::move(_cb)); |
| auto status_and_error = |
| foo(_write_bytes_array.view(), std::move(s), _context); |
| if (!status_and_error.ok()) { |
| delete _context; |
| } |
| return status_and_error; |
| } |
| |
| ::fidl::StatusAndError super::ClientImpl::foo(::fidl::BytePart _request_buffer, |
| ::fidl::StringView s, |
| fooResponseContext* _context) { |
| if (_request_buffer.capacity() < fooRequest::PrimarySize) { |
| return ::fidl::StatusAndError(ZX_ERR_BUFFER_TOO_SMALL, |
| ::fidl::kErrorRequestBufferTooSmall); |
| } |
| |
| ::fidl::internal::ClientBase::PrepareAsyncTxn(_context); |
| fooRequest _request(_context->Txid(), s); |
| auto _encode_request_result = ::fidl::LinearizeAndEncode<fooRequest>( |
| &_request, std::move(_request_buffer)); |
| if (_encode_request_result.status != ZX_OK) { |
| ::fidl::internal::ClientBase::ForgetAsyncTxn(_context); |
| return std::move(_encode_request_result); |
| } |
| |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| zx_status_t _write_status = ::fidl::Write( |
| _binding->channel(), std::move(_encode_request_result.message)); |
| if (_write_status != ZX_OK) { |
| ::fidl::internal::ClientBase::ForgetAsyncTxn(_context); |
| return ::fidl::StatusAndError(_write_status, ::fidl::kErrorWriteFailed); |
| } |
| return ::fidl::StatusAndError(ZX_OK, nullptr); |
| } |
| ::fidl::internal::ClientBase::ForgetAsyncTxn(_context); |
| return ::fidl::StatusAndError(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| |
| zx_status_t super::ClientImpl::Dispatch( |
| fidl_msg_t* msg, ::fidl::internal::ResponseContext* context) { |
| fidl_message_header_t* hdr = |
| reinterpret_cast<fidl_message_header_t*>(msg->bytes); |
| switch (hdr->ordinal) { |
| case ksuper_foo_Ordinal: { |
| auto result = ::fidl::DecodeAs<fooResponse>(msg); |
| if (result.status != ZX_OK) { |
| context->OnError(); |
| return result.status; |
| } |
| static_cast<fooResponseContext*>(context)->OnReply( |
| std::move(result.message)); |
| break; |
| } |
| case kFidlOrdinalEpitaph: |
| if (context) return ZX_ERR_INVALID_ARGS; |
| ::fidl::internal::ClientBase::Close( |
| reinterpret_cast<fidl_epitaph_t*>(hdr)->error); |
| break; |
| default: |
| zx_handle_close_many(msg->handles, msg->num_handles); |
| if (context) context->OnError(); |
| return ZX_ERR_NOT_SUPPORTED; |
| } |
| return ZX_OK; |
| } |
| |
| bool super::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 ksuper_foo_Ordinal: { |
| auto result = ::fidl::DecodeAs<fooRequest>(msg); |
| if (result.status != ZX_OK) { |
| txn->Close(ZX_ERR_INVALID_ARGS); |
| return true; |
| } |
| auto message = result.message.message(); |
| impl->foo(std::move(message->s), Interface::fooCompleter::Sync(txn)); |
| return true; |
| } |
| default: { |
| return false; |
| } |
| } |
| } |
| |
| bool super::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 super::Interface::fooCompleterBase::Reply(int64_t y) { |
| // Destructors can't be called because it will lead to handle double close |
| // (here and in fidl::Encode). |
| FIDL_ALIGNDECL uint8_t _response_buffer[sizeof(fooResponse)]; |
| auto& _response = *new (_response_buffer) fooResponse{y}; |
| |
| auto _encoded = |
| ::fidl::internal::LinearizedAndEncoded<fooResponse>(&_response); |
| auto& _encode_result = _encoded.result(); |
| if (_encode_result.status != ZX_OK) { |
| CompleterBase::Close(ZX_ERR_INTERNAL); |
| return; |
| } |
| CompleterBase::SendReply(std::move(_encode_result.message)); |
| } |
| |
| void super::Interface::fooCompleterBase::Reply(::fidl::BytePart _buffer, |
| int64_t y) { |
| if (_buffer.capacity() < fooResponse::PrimarySize) { |
| CompleterBase::Close(ZX_ERR_INTERNAL); |
| return; |
| } |
| new (_buffer.data()) fooResponse{y}; |
| _buffer.set_actual(sizeof(fooResponse)); |
| CompleterBase::SendReply( |
| ::fidl::DecodedMessage<fooResponse>(std::move(_buffer))); |
| } |
| |
| void super::Interface::fooCompleterBase::Reply( |
| ::fidl::DecodedMessage<fooResponse> params) { |
| ZX_DEBUG_ASSERT(params.message()->_hdr.magic_number == |
| kFidlWireFormatMagicNumberInitial); |
| ZX_DEBUG_ASSERT(params.message()->_hdr.ordinal == ksuper_foo_Ordinal); |
| CompleterBase::SendReply(std::move(params)); |
| } |
| |
| void super::fooRequest::_InitHeader(zx_txid_t _txid) { |
| fidl_init_txn_header(&_hdr, _txid, ksuper_foo_Ordinal); |
| } |
| |
| void super::fooResponse::_InitHeader() { |
| fidl_init_txn_header(&_hdr, 0, ksuper_foo_Ordinal); |
| } |
| |
| namespace { |
| |
| [[maybe_unused]] constexpr uint64_t ksub_foo_Ordinal = 5722958650322615442lu; |
| extern "C" const fidl_type_t fidl_test_json_subfooRequestTable; |
| extern "C" const fidl_type_t fidl_test_json_subfooResponseTable; |
| |
| } // namespace |
| template <> |
| sub::ResultOf::foo_Impl<sub::fooResponse>::foo_Impl( |
| ::zx::unowned_channel _client_end, const ::fidl::StringView& s) { |
| fooRequest _request(0, s); |
| |
| auto _encoded = ::fidl::internal::LinearizedAndEncoded<fooRequest>(&_request); |
| auto& _encode_result = _encoded.result(); |
| if (_encode_result.status != ZX_OK) { |
| Super::SetFailure(std::move(_encode_result)); |
| return; |
| } |
| ::fidl::EncodedMessage<fooRequest> _encoded_request = |
| std::move(_encode_result.message); |
| Super::SetResult(sub::InPlace::foo(std::move(_client_end), |
| std::move(_encoded_request), |
| Super::response_buffer())); |
| } |
| |
| sub::ResultOf::foo sub::SyncClient::foo(::fidl::StringView s) { |
| return ResultOf::foo(::zx::unowned_channel(this->channel_), s); |
| } |
| |
| sub::ResultOf::foo sub::Call::foo(::zx::unowned_channel _client_end, |
| ::fidl::StringView s) { |
| return ResultOf::foo(std::move(_client_end), s); |
| } |
| |
| template <> |
| sub::UnownedResultOf::foo_Impl<sub::fooResponse>::foo_Impl( |
| ::zx::unowned_channel _client_end, ::fidl::BytePart _request_buffer, |
| ::fidl::StringView s, ::fidl::BytePart _response_buffer) { |
| if (_request_buffer.capacity() < fooRequest::PrimarySize) { |
| Super::SetFailure(::fidl::DecodeResult<fooResponse>( |
| ZX_ERR_BUFFER_TOO_SMALL, ::fidl::kErrorRequestBufferTooSmall)); |
| return; |
| } |
| fooRequest _request(0, s); |
| auto _encode_result = ::fidl::LinearizeAndEncode<fooRequest>( |
| &_request, std::move(_request_buffer)); |
| if (_encode_result.status != ZX_OK) { |
| Super::SetFailure(std::move(_encode_result)); |
| return; |
| } |
| ::fidl::EncodedMessage<fooRequest> _encoded_request = |
| std::move(_encode_result.message); |
| Super::SetResult(sub::InPlace::foo(std::move(_client_end), |
| std::move(_encoded_request), |
| std::move(_response_buffer))); |
| } |
| |
| sub::UnownedResultOf::foo sub::SyncClient::foo( |
| ::fidl::BytePart _request_buffer, ::fidl::StringView s, |
| ::fidl::BytePart _response_buffer) { |
| return UnownedResultOf::foo(::zx::unowned_channel(this->channel_), |
| std::move(_request_buffer), std::move(s), |
| std::move(_response_buffer)); |
| } |
| |
| sub::UnownedResultOf::foo sub::Call::foo(::zx::unowned_channel _client_end, |
| ::fidl::BytePart _request_buffer, |
| ::fidl::StringView s, |
| ::fidl::BytePart _response_buffer) { |
| return UnownedResultOf::foo(std::move(_client_end), |
| std::move(_request_buffer), std::move(s), |
| std::move(_response_buffer)); |
| } |
| |
| ::fidl::DecodeResult<sub::fooResponse> sub::InPlace::foo( |
| ::zx::unowned_channel _client_end, |
| ::fidl::DecodedMessage<fooRequest> params, |
| ::fidl::BytePart response_buffer) { |
| auto _encode_request_result = ::fidl::Encode(std::move(params)); |
| if (_encode_request_result.status != ZX_OK) { |
| return ::fidl::DecodeResult<sub::fooResponse>::FromFailure( |
| std::move(_encode_request_result)); |
| } |
| return foo(std::move(_client_end), std::move(_encode_request_result.message), |
| std::move(response_buffer)); |
| } |
| |
| ::fidl::DecodeResult<sub::fooResponse> sub::InPlace::foo( |
| ::zx::unowned_channel _client_end, |
| ::fidl::EncodedMessage<fooRequest> params, |
| ::fidl::BytePart response_buffer) { |
| fooRequest* request = reinterpret_cast<fooRequest*>(params.bytes().data()); |
| fidl_init_txn_header(&request->_hdr, 0, ksub_foo_Ordinal); |
| auto _call_result = ::fidl::Call<fooRequest, fooResponse>( |
| std::move(_client_end), std::move(params), std::move(response_buffer)); |
| if (_call_result.status != ZX_OK) { |
| return ::fidl::DecodeResult<sub::fooResponse>::FromFailure( |
| std::move(_call_result)); |
| } |
| return ::fidl::Decode(std::move(_call_result.message)); |
| } |
| |
| sub::ResultOf::foo sub::ClientImpl::foo_Sync(::fidl::StringView s) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| return ResultOf::foo(_binding->channel(), s); |
| } |
| return ::fidl::StatusAndError(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| |
| sub::UnownedResultOf::foo sub::ClientImpl::foo_Sync( |
| ::fidl::BytePart _request_buffer, ::fidl::StringView s, |
| ::fidl::BytePart _response_buffer) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| return UnownedResultOf::foo(_binding->channel(), std::move(_request_buffer), |
| std::move(s), std::move(_response_buffer)); |
| } |
| return ::fidl::StatusAndError(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| |
| ::fidl::StatusAndError sub::ClientImpl::foo( |
| ::fidl::StringView s, ::fit::callback<void(int64_t y)> _cb) { |
| class ManagedResponseContext : public fooResponseContext { |
| public: |
| ManagedResponseContext(::fit::callback<void(int64_t y)> cb) |
| : cb_(std::move(cb)) {} |
| |
| void OnReply(::fidl::DecodedMessage<fooResponse> msg) override { |
| auto message = msg.message(); |
| cb_(std::move(message->y)); |
| delete this; |
| } |
| |
| void OnError() override { delete this; } |
| |
| ::fit::callback<void(int64_t y)> cb_; |
| }; |
| constexpr uint32_t _kWriteAllocSize = ::fidl::internal::ClampedMessageSize< |
| fooRequest, ::fidl::MessageDirection::kSending>(); |
| std::unique_ptr _write_bytes_boxed = |
| std::make_unique<::fidl::internal::AlignedBuffer<_kWriteAllocSize>>(); |
| auto& _write_bytes_array = *_write_bytes_boxed; |
| |
| auto* _context = new ManagedResponseContext(std::move(_cb)); |
| auto status_and_error = |
| foo(_write_bytes_array.view(), std::move(s), _context); |
| if (!status_and_error.ok()) { |
| delete _context; |
| } |
| return status_and_error; |
| } |
| |
| ::fidl::StatusAndError sub::ClientImpl::foo(::fidl::BytePart _request_buffer, |
| ::fidl::StringView s, |
| fooResponseContext* _context) { |
| if (_request_buffer.capacity() < fooRequest::PrimarySize) { |
| return ::fidl::StatusAndError(ZX_ERR_BUFFER_TOO_SMALL, |
| ::fidl::kErrorRequestBufferTooSmall); |
| } |
| |
| ::fidl::internal::ClientBase::PrepareAsyncTxn(_context); |
| fooRequest _request(_context->Txid(), s); |
| auto _encode_request_result = ::fidl::LinearizeAndEncode<fooRequest>( |
| &_request, std::move(_request_buffer)); |
| if (_encode_request_result.status != ZX_OK) { |
| ::fidl::internal::ClientBase::ForgetAsyncTxn(_context); |
| return std::move(_encode_request_result); |
| } |
| |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| zx_status_t _write_status = ::fidl::Write( |
| _binding->channel(), std::move(_encode_request_result.message)); |
| if (_write_status != ZX_OK) { |
| ::fidl::internal::ClientBase::ForgetAsyncTxn(_context); |
| return ::fidl::StatusAndError(_write_status, ::fidl::kErrorWriteFailed); |
| } |
| return ::fidl::StatusAndError(ZX_OK, nullptr); |
| } |
| ::fidl::internal::ClientBase::ForgetAsyncTxn(_context); |
| return ::fidl::StatusAndError(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| |
| zx_status_t sub::ClientImpl::Dispatch( |
| fidl_msg_t* msg, ::fidl::internal::ResponseContext* context) { |
| fidl_message_header_t* hdr = |
| reinterpret_cast<fidl_message_header_t*>(msg->bytes); |
| switch (hdr->ordinal) { |
| case ksub_foo_Ordinal: { |
| auto result = ::fidl::DecodeAs<fooResponse>(msg); |
| if (result.status != ZX_OK) { |
| context->OnError(); |
| return result.status; |
| } |
| static_cast<fooResponseContext*>(context)->OnReply( |
| std::move(result.message)); |
| break; |
| } |
| case kFidlOrdinalEpitaph: |
| if (context) return ZX_ERR_INVALID_ARGS; |
| ::fidl::internal::ClientBase::Close( |
| reinterpret_cast<fidl_epitaph_t*>(hdr)->error); |
| break; |
| default: |
| zx_handle_close_many(msg->handles, msg->num_handles); |
| if (context) context->OnError(); |
| return ZX_ERR_NOT_SUPPORTED; |
| } |
| return ZX_OK; |
| } |
| |
| bool sub::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 ksub_foo_Ordinal: { |
| auto result = ::fidl::DecodeAs<fooRequest>(msg); |
| if (result.status != ZX_OK) { |
| txn->Close(ZX_ERR_INVALID_ARGS); |
| return true; |
| } |
| auto message = result.message.message(); |
| impl->foo(std::move(message->s), Interface::fooCompleter::Sync(txn)); |
| return true; |
| } |
| default: { |
| return false; |
| } |
| } |
| } |
| |
| bool sub::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 sub::Interface::fooCompleterBase::Reply(int64_t y) { |
| // Destructors can't be called because it will lead to handle double close |
| // (here and in fidl::Encode). |
| FIDL_ALIGNDECL uint8_t _response_buffer[sizeof(fooResponse)]; |
| auto& _response = *new (_response_buffer) fooResponse{y}; |
| |
| auto _encoded = |
| ::fidl::internal::LinearizedAndEncoded<fooResponse>(&_response); |
| auto& _encode_result = _encoded.result(); |
| if (_encode_result.status != ZX_OK) { |
| CompleterBase::Close(ZX_ERR_INTERNAL); |
| return; |
| } |
| CompleterBase::SendReply(std::move(_encode_result.message)); |
| } |
| |
| void sub::Interface::fooCompleterBase::Reply(::fidl::BytePart _buffer, |
| int64_t y) { |
| if (_buffer.capacity() < fooResponse::PrimarySize) { |
| CompleterBase::Close(ZX_ERR_INTERNAL); |
| return; |
| } |
| new (_buffer.data()) fooResponse{y}; |
| _buffer.set_actual(sizeof(fooResponse)); |
| CompleterBase::SendReply( |
| ::fidl::DecodedMessage<fooResponse>(std::move(_buffer))); |
| } |
| |
| void sub::Interface::fooCompleterBase::Reply( |
| ::fidl::DecodedMessage<fooResponse> params) { |
| ZX_DEBUG_ASSERT(params.message()->_hdr.magic_number == |
| kFidlWireFormatMagicNumberInitial); |
| ZX_DEBUG_ASSERT(params.message()->_hdr.ordinal == ksub_foo_Ordinal); |
| CompleterBase::SendReply(std::move(params)); |
| } |
| |
| void sub::fooRequest::_InitHeader(zx_txid_t _txid) { |
| fidl_init_txn_header(&_hdr, _txid, ksub_foo_Ordinal); |
| } |
| |
| void sub::fooResponse::_InitHeader() { |
| fidl_init_txn_header(&_hdr, 0, ksub_foo_Ordinal); |
| } |
| |
| } // namespace json |
| } // namespace test |
| } // namespace fidl |
| } // namespace llcpp |