| // WARNING: This file is machine generated by fidlgen. |
| |
| #include <fidl/test/nullable/llcpp/fidl.h> |
| |
| #include <memory> |
| |
| #ifdef __Fuchsia__ |
| void ::llcpp::fidl::test::nullable::wire::StructWithNullableRequest:: |
| _CloseHandles() { |
| val.reset(); |
| } |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| void ::llcpp::fidl::test::nullable::wire::StructWithNullableProtocol:: |
| _CloseHandles() { |
| val.reset(); |
| } |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| void ::llcpp::fidl::test::nullable::wire::StructWithNullableHandle:: |
| _CloseHandles() { |
| val.reset(); |
| } |
| #endif // __Fuchsia__ |
| |
| namespace llcpp { |
| namespace fidl { |
| namespace test { |
| namespace nullable { |
| namespace { |
| |
| [[maybe_unused]] constexpr uint64_t kSimpleProtocol_Add_Ordinal = |
| 1238508415331800925lu; |
| |
| extern "C" const fidl_type_t fidl_test_nullable_SimpleProtocolAddRequestTable; |
| |
| extern "C" const fidl_type_t fidl_test_nullable_SimpleProtocolAddResponseTable; |
| |
| } // namespace |
| #ifdef __Fuchsia__ |
| ::llcpp::fidl::test::nullable::SimpleProtocol::ResultOf::Add::Add( |
| ::fidl::UnownedClientEnd<::llcpp::fidl::test::nullable::SimpleProtocol> |
| _client, |
| int32_t a, int32_t b) { |
| ::fidl::internal::EncodedMessageTypes<AddRequest>::OwnedByte _request( |
| zx_txid_t(0), a, b); |
| _request.GetOutgoingMessage().Call<AddResponse>( |
| _client, bytes_, AddResponse::PrimarySize + AddResponse::MaxOutOfLine); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| ::llcpp::fidl::test::nullable::SimpleProtocol::ResultOf::Add::Add( |
| ::fidl::UnownedClientEnd<::llcpp::fidl::test::nullable::SimpleProtocol> |
| _client, |
| int32_t a, int32_t b, zx_time_t _deadline) { |
| ::fidl::internal::EncodedMessageTypes<AddRequest>::OwnedByte _request( |
| zx_txid_t(0), a, b); |
| _request.GetOutgoingMessage().Call<AddResponse>( |
| _client, bytes_, AddResponse::PrimarySize + AddResponse::MaxOutOfLine, |
| _deadline); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| #endif |
| |
| #ifdef __Fuchsia__ |
| ::llcpp::fidl::test::nullable::SimpleProtocol::UnownedResultOf::Add::Add( |
| ::fidl::UnownedClientEnd<::llcpp::fidl::test::nullable::SimpleProtocol> |
| _client, |
| uint8_t* _request_bytes, uint32_t _request_byte_capacity, int32_t a, |
| int32_t b, uint8_t* _response_bytes, uint32_t _response_byte_capacity) |
| : bytes_(_response_bytes) { |
| ::fidl::internal::EncodedMessageTypes<AddRequest>::UnownedByte _request( |
| _request_bytes, _request_byte_capacity, 0, a, b); |
| _request.GetOutgoingMessage().Call<AddResponse>(_client, _response_bytes, |
| _response_byte_capacity); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| #endif |
| |
| #ifdef __Fuchsia__ |
| ::llcpp::fidl::test::nullable::SimpleProtocol::ResultOf::Add |
| SimpleProtocol::ClientImpl::Add_Sync(int32_t a, int32_t b) { |
| if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) { |
| return ResultOf::Add( |
| ::fidl::UnownedClientEnd<::llcpp::fidl::test::nullable::SimpleProtocol>( |
| _channel->handle()), |
| a, b); |
| } |
| return ::llcpp::fidl::test::nullable::SimpleProtocol::ResultOf::Add( |
| ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound)); |
| } |
| #endif |
| |
| #ifdef __Fuchsia__ |
| ::llcpp::fidl::test::nullable::SimpleProtocol::UnownedResultOf::Add |
| SimpleProtocol::ClientImpl::Add_Sync(::fidl::BufferSpan _request_buffer, |
| int32_t a, int32_t b, |
| ::fidl::BufferSpan _response_buffer) { |
| if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) { |
| return UnownedResultOf::Add( |
| ::fidl::UnownedClientEnd<::llcpp::fidl::test::nullable::SimpleProtocol>( |
| _channel->handle()), |
| _request_buffer.data, _request_buffer.capacity, a, b, |
| _response_buffer.data, _response_buffer.capacity); |
| } |
| return ::llcpp::fidl::test::nullable::SimpleProtocol::UnownedResultOf::Add( |
| ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound)); |
| } |
| #endif |
| |
| #ifdef __Fuchsia__ |
| ::llcpp::fidl::test::nullable::SimpleProtocol::AddResponseContext:: |
| AddResponseContext() |
| : ::fidl::internal::ResponseContext(AddResponse::Type, |
| kSimpleProtocol_Add_Ordinal) {} |
| |
| void ::llcpp::fidl::test::nullable::SimpleProtocol::AddResponseContext::OnReply( |
| uint8_t* reply) { |
| OnReply(reinterpret_cast<AddResponse*>(reply)); |
| } |
| |
| ::fidl::Result SimpleProtocol::ClientImpl::Add( |
| int32_t a, int32_t b, ::fit::callback<void(AddResponse* response)> _cb) { |
| class ResponseContext final : public AddResponseContext { |
| public: |
| ResponseContext(::fit::callback<void(AddResponse* response)> cb) |
| : cb_(std::move(cb)) {} |
| |
| void OnReply(AddResponse* response) override { |
| cb_(response); |
| |
| delete this; |
| } |
| |
| void OnError() override { delete this; } |
| |
| private: |
| ::fit::callback<void(AddResponse* response)> cb_; |
| }; |
| |
| auto* _context = new ResponseContext(std::move(_cb)); |
| ::fidl::internal::ClientBase::PrepareAsyncTxn(_context); |
| AddRequest::OwnedEncodedMessage _request(_context->Txid(), a, b); |
| return _request.GetOutgoingMessage().Write(this, _context); |
| } |
| |
| ::fidl::Result SimpleProtocol::ClientImpl::Add( |
| ::fidl::BufferSpan _request_buffer, int32_t a, int32_t b, |
| AddResponseContext* _context) { |
| ::fidl::internal::ClientBase::PrepareAsyncTxn(_context); |
| |
| AddRequest::UnownedEncodedMessage _request( |
| _request_buffer.data, _request_buffer.capacity, _context->Txid(), a, b); |
| return _request.GetOutgoingMessage().Write(this, _context); |
| } |
| #endif |
| |
| #ifdef __Fuchsia__ |
| std::optional<::fidl::UnbindInfo> SimpleProtocol::ClientImpl::DispatchEvent( |
| fidl_incoming_msg_t* msg) { |
| FidlHandleInfoCloseMany(msg->handles, msg->num_handles); |
| return ::fidl::UnbindInfo{::fidl::UnbindInfo::kUnexpectedMessage, |
| ZX_ERR_NOT_SUPPORTED}; |
| } |
| #endif |
| |
| #ifdef __Fuchsia__ |
| namespace methods { |
| |
| void SimpleProtocolDispatchAdd(void* interface, void* bytes, |
| ::fidl::Transaction* txn) { |
| auto message = reinterpret_cast< |
| ::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest*>(bytes); |
| ::llcpp::fidl::test::nullable::SimpleProtocol::Interface::AddCompleter::Sync |
| completer(txn); |
| reinterpret_cast<::llcpp::fidl::test::nullable::SimpleProtocol::Interface*>( |
| interface) |
| ->Add(std::move(message->a), std::move(message->b), completer); |
| } |
| |
| } // namespace methods |
| |
| namespace entries { |
| |
| ::fidl::internal::MethodEntry SimpleProtocol[] = { |
| {kSimpleProtocol_Add_Ordinal, |
| ::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest::Type, |
| methods::SimpleProtocolDispatchAdd}, |
| }; |
| |
| } // namespace entries |
| |
| ::fidl::DispatchResult SimpleProtocol::TryDispatch(Interface* impl, |
| fidl_incoming_msg_t* msg, |
| ::fidl::Transaction* txn) { |
| return ::fidl::internal::TryDispatch( |
| impl, msg, txn, entries::SimpleProtocol, |
| entries::SimpleProtocol + sizeof(entries::SimpleProtocol) / |
| sizeof(::fidl::internal::MethodEntry)); |
| } |
| #endif |
| |
| #ifdef __Fuchsia__ |
| ::fidl::DispatchResult SimpleProtocol::Dispatch(Interface* impl, |
| fidl_incoming_msg_t* msg, |
| ::fidl::Transaction* txn) { |
| ::fidl::DispatchResult dispatch_result = TryDispatch(impl, msg, txn); |
| if (dispatch_result == ::fidl::DispatchResult::kNotFound) { |
| FidlHandleInfoCloseMany(msg->handles, msg->num_handles); |
| txn->InternalError( |
| {::fidl::UnbindInfo::kUnexpectedMessage, ZX_ERR_NOT_SUPPORTED}); |
| } |
| return dispatch_result; |
| } |
| |
| ::fidl::DispatchResult SimpleProtocol::Interface::dispatch_message( |
| fidl_incoming_msg_t* msg, ::fidl::Transaction* txn) { |
| return SimpleProtocol::Dispatch(this, msg, txn); |
| } |
| #endif |
| |
| #ifdef __Fuchsia__ |
| ::fidl::Result SimpleProtocol::Interface::AddCompleterBase::Reply(int32_t sum) { |
| ::fidl::internal::EncodedMessageTypes<AddResponse>::OwnedByte _response{sum}; |
| return CompleterBase::SendReply(&_response.GetOutgoingMessage()); |
| } |
| #endif |
| |
| #ifdef __Fuchsia__ |
| ::fidl::Result SimpleProtocol::Interface::AddCompleterBase::Reply( |
| ::fidl::BufferSpan _buffer, int32_t sum) { |
| AddResponse::UnownedEncodedMessage _response(_buffer.data, _buffer.capacity, |
| sum); |
| return CompleterBase::SendReply(&_response.GetOutgoingMessage()); |
| } |
| #endif |
| |
| void ::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest::_InitHeader( |
| zx_txid_t _txid) { |
| fidl_init_txn_header(&_hdr, _txid, kSimpleProtocol_Add_Ordinal); |
| } |
| |
| void ::llcpp::fidl::test::nullable::SimpleProtocol::AddResponse::_InitHeader() { |
| fidl_init_txn_header(&_hdr, 0, kSimpleProtocol_Add_Ordinal); |
| } |
| |
| #ifdef __Fuchsia__ |
| #endif |
| |
| void ::llcpp::fidl::test::nullable::wire::SimpleUnion:: |
| SizeAndOffsetAssertionHelper() { |
| static_assert(sizeof(SimpleUnion) == sizeof(fidl_xunion_t)); |
| static_assert(offsetof(SimpleUnion, ordinal_) == |
| offsetof(fidl_xunion_t, tag)); |
| static_assert(offsetof(SimpleUnion, envelope_) == |
| offsetof(fidl_xunion_t, envelope)); |
| } |
| } // namespace nullable |
| } // namespace test |
| } // namespace fidl |
| } // namespace llcpp |