| // WARNING: This file is machine generated by fidlgen. |
| |
| #include <nullable.test.json.llcpp.h> |
| |
| #include <memory> |
| |
| 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 |
| SimpleProtocol::ResultOf::Add::Add(zx_handle_t _client, int32_t a, int32_t b) { |
| AddOwnedRequest _request(0, a, b); |
| _request.GetFidlMessage().Call( |
| AddResponse::Type, _client, bytes_, |
| AddResponse::PrimarySize + AddResponse::MaxOutOfLine); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| SimpleProtocol::UnownedResultOf::Add::Add(zx_handle_t _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) { |
| AddUnownedRequest _request(_request_bytes, _request_byte_capacity, 0, a, b); |
| _request.GetFidlMessage().Call(AddResponse::Type, _client, _response_bytes, |
| _response_byte_capacity); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| SimpleProtocol::ResultOf::Add SimpleProtocol::ClientImpl::Add_Sync(int32_t a, |
| int32_t b) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| return ResultOf::Add(_binding->handle(), a, b); |
| } |
| return SimpleProtocol::ResultOf::Add( |
| ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound)); |
| } |
| |
| SimpleProtocol::UnownedResultOf::Add SimpleProtocol::ClientImpl::Add_Sync( |
| ::fidl::BytePart _request_buffer, int32_t a, int32_t b, |
| ::fidl::BytePart _response_buffer) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| return UnownedResultOf::Add( |
| _binding->handle(), _request_buffer.data(), _request_buffer.capacity(), |
| a, b, _response_buffer.data(), _response_buffer.capacity()); |
| } |
| return SimpleProtocol::UnownedResultOf::Add( |
| ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound)); |
| } |
| |
| SimpleProtocol::AddResponseContext::AddResponseContext() |
| : ::fidl::internal::ResponseContext(AddResponse::Type, |
| kSimpleProtocol_Add_Ordinal) {} |
| |
| void 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(int32_t sum)> _cb) { |
| class ResponseContext final : public AddResponseContext { |
| public: |
| ResponseContext(::fit::callback<void(int32_t sum)> cb) |
| : cb_(std::move(cb)) {} |
| |
| void OnReply(AddResponse* message) override { |
| cb_(std::move(message->sum)); |
| |
| delete this; |
| } |
| |
| void OnError() override { delete this; } |
| |
| private: |
| ::fit::callback<void(int32_t sum)> cb_; |
| }; |
| |
| auto* _context = new ResponseContext(std::move(_cb)); |
| ::fidl::internal::ClientBase::PrepareAsyncTxn(_context); |
| AddOwnedRequest _request(_context->Txid(), a, b); |
| return _request.GetFidlMessage().Write(this, _context); |
| } |
| |
| ::fidl::Result SimpleProtocol::ClientImpl::Add(::fidl::BytePart _request_buffer, |
| int32_t a, int32_t b, |
| AddResponseContext* _context) { |
| ::fidl::internal::ClientBase::PrepareAsyncTxn(_context); |
| |
| AddUnownedRequest _request(_request_buffer.data(), _request_buffer.capacity(), |
| _context->Txid(), a, b); |
| return _request.GetFidlMessage().Write(this, _context); |
| } |
| |
| std::optional<::fidl::UnbindInfo> SimpleProtocol::ClientImpl::DispatchEvent( |
| fidl_msg_t* msg) { |
| fidl_message_header_t* hdr = |
| reinterpret_cast<fidl_message_header_t*>(msg->bytes); |
| switch (hdr->ordinal) { |
| default: |
| zx_handle_close_many(msg->handles, msg->num_handles); |
| return ::fidl::UnbindInfo{::fidl::UnbindInfo::kUnexpectedMessage, |
| ZX_ERR_NOT_SUPPORTED}; |
| } |
| return {}; |
| } |
| |
| namespace methods { |
| |
| void SimpleProtocolDispatchAdd(void* interface, void* bytes, |
| ::fidl::Transaction* txn) { |
| auto message = reinterpret_cast<SimpleProtocol::AddRequest*>(bytes); |
| reinterpret_cast<SimpleProtocol::Interface*>(interface)->Add( |
| std::move(message->a), std::move(message->b), |
| SimpleProtocol::Interface::AddCompleter::Sync(txn)); |
| } |
| |
| } // namespace methods |
| |
| namespace entries { |
| |
| ::fidl::internal::MethodEntry SimpleProtocol[] = { |
| {kSimpleProtocol_Add_Ordinal, SimpleProtocol::AddRequest::Type, |
| methods::SimpleProtocolDispatchAdd}, |
| }; |
| |
| } // namespace entries |
| |
| bool SimpleProtocol::TryDispatch(Interface* impl, fidl_msg_t* msg, |
| ::fidl::Transaction* txn) { |
| return ::fidl::internal::TryDispatch( |
| impl, msg, txn, entries::SimpleProtocol, |
| entries::SimpleProtocol + sizeof(entries::SimpleProtocol) / |
| sizeof(::fidl::internal::MethodEntry)); |
| } |
| |
| bool SimpleProtocol::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->InternalError( |
| {::fidl::UnbindInfo::kUnexpectedMessage, ZX_ERR_NOT_SUPPORTED}); |
| } |
| return found; |
| } |
| |
| ::fidl::Result SimpleProtocol::Interface::AddCompleterBase::Reply(int32_t sum) { |
| AddOwnedResponse _response{sum}; |
| return CompleterBase::SendReply(_response.GetFidlMessage()); |
| } |
| |
| ::fidl::Result SimpleProtocol::Interface::AddCompleterBase::Reply( |
| ::fidl::BytePart _buffer, int32_t sum) { |
| AddUnownedResponse _response(_buffer.data(), _buffer.capacity(), sum); |
| return CompleterBase::SendReply(_response.GetFidlMessage()); |
| } |
| |
| void SimpleProtocol::AddRequest::_InitHeader(zx_txid_t _txid) { |
| fidl_init_txn_header(&_hdr, _txid, kSimpleProtocol_Add_Ordinal); |
| } |
| |
| void SimpleProtocol::AddResponse::_InitHeader() { |
| fidl_init_txn_header(&_hdr, 0, kSimpleProtocol_Add_Ordinal); |
| } |
| |
| void ::llcpp::fidl::test::nullable::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 |