| // WARNING: This file is machine generated by fidlgen. |
| |
| #include <protocol_request.test.json.llcpp.h> |
| |
| #include <memory> |
| |
| namespace llcpp { |
| |
| namespace test { |
| namespace name { |
| |
| namespace { |
| |
| [[maybe_unused]] constexpr uint64_t kParent_GetChild_Ordinal = |
| 6332745893922832518lu; |
| extern "C" const fidl_type_t test_name_ParentGetChildRequestTable; |
| extern "C" const fidl_type_t test_name_ParentGetChildResponseTable; |
| [[maybe_unused]] constexpr uint64_t kParent_GetChildRequest_Ordinal = |
| 26635226975931008lu; |
| extern "C" const fidl_type_t test_name_ParentGetChildRequestRequestTable; |
| extern "C" const fidl_type_t test_name_ParentGetChildRequestResponseTable; |
| [[maybe_unused]] constexpr uint64_t kParent_TakeChild_Ordinal = |
| 7680932945371199613lu; |
| extern "C" const fidl_type_t test_name_ParentTakeChildRequestTable; |
| extern "C" const fidl_type_t test_name_ParentTakeChildResponseTable; |
| [[maybe_unused]] constexpr uint64_t kParent_TakeChildRequest_Ordinal = |
| 7803173423056840247lu; |
| extern "C" const fidl_type_t test_name_ParentTakeChildRequestRequestTable; |
| extern "C" const fidl_type_t test_name_ParentTakeChildRequestResponseTable; |
| |
| } // namespace |
| Parent::ResultOf::GetChild::GetChild(zx_handle_t _client) { |
| GetChildOwnedRequest _request(0); |
| _request.GetFidlMessage().Call( |
| GetChildResponse::Type, _client, bytes_, |
| GetChildResponse::PrimarySize + GetChildResponse::MaxOutOfLine); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| Parent::UnownedResultOf::GetChild::GetChild(zx_handle_t _client, |
| uint8_t* _response_bytes, |
| uint32_t _response_byte_capacity) |
| : bytes_(_response_bytes) { |
| GetChildOwnedRequest _request(0); |
| _request.GetFidlMessage().Call(GetChildResponse::Type, _client, |
| _response_bytes, _response_byte_capacity); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| Parent::ResultOf::GetChildRequest::GetChildRequest(zx_handle_t _client) { |
| GetChildRequestOwnedRequest _request(0); |
| _request.GetFidlMessage().Call(GetChildRequestResponse::Type, _client, bytes_, |
| GetChildRequestResponse::PrimarySize + |
| GetChildRequestResponse::MaxOutOfLine); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| Parent::UnownedResultOf::GetChildRequest::GetChildRequest( |
| zx_handle_t _client, uint8_t* _response_bytes, |
| uint32_t _response_byte_capacity) |
| : bytes_(_response_bytes) { |
| GetChildRequestOwnedRequest _request(0); |
| _request.GetFidlMessage().Call(GetChildRequestResponse::Type, _client, |
| _response_bytes, _response_byte_capacity); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| Parent::ResultOf::TakeChild::TakeChild(zx_handle_t _client, ::zx::channel& c) { |
| TakeChildOwnedRequest _request(0, c); |
| _request.GetFidlMessage().Write(_client); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| Parent::UnownedResultOf::TakeChild::TakeChild(zx_handle_t _client, |
| uint8_t* _request_bytes, |
| uint32_t _request_byte_capacity, |
| ::zx::channel& c) { |
| TakeChildUnownedRequest _request(_request_bytes, _request_byte_capacity, 0, |
| c); |
| _request.GetFidlMessage().Write(_client); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| Parent::ResultOf::TakeChildRequest::TakeChildRequest(zx_handle_t _client, |
| ::zx::channel& r) { |
| TakeChildRequestOwnedRequest _request(0, r); |
| _request.GetFidlMessage().Write(_client); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| Parent::UnownedResultOf::TakeChildRequest::TakeChildRequest( |
| zx_handle_t _client, uint8_t* _request_bytes, |
| uint32_t _request_byte_capacity, ::zx::channel& r) { |
| TakeChildRequestUnownedRequest _request(_request_bytes, |
| _request_byte_capacity, 0, r); |
| _request.GetFidlMessage().Write(_client); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| Parent::ResultOf::GetChild Parent::ClientImpl::GetChild_Sync() { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| return ResultOf::GetChild(_binding->handle()); |
| } |
| return Parent::ResultOf::GetChild( |
| ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound)); |
| } |
| |
| Parent::UnownedResultOf::GetChild Parent::ClientImpl::GetChild_Sync( |
| ::fidl::BytePart _response_buffer) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| return UnownedResultOf::GetChild(_binding->handle(), |
| _response_buffer.data(), |
| _response_buffer.capacity()); |
| } |
| return Parent::UnownedResultOf::GetChild( |
| ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound)); |
| } |
| |
| Parent::GetChildResponseContext::GetChildResponseContext() |
| : ::fidl::internal::ResponseContext(GetChildResponse::Type, |
| kParent_GetChild_Ordinal) {} |
| |
| void Parent::GetChildResponseContext::OnReply(uint8_t* reply) { |
| OnReply(reinterpret_cast<GetChildResponse*>(reply)); |
| } |
| |
| ::fidl::Result Parent::ClientImpl::GetChild( |
| ::fit::callback<void(::zx::channel c)> _cb) { |
| class ResponseContext final : public GetChildResponseContext { |
| public: |
| ResponseContext(::fit::callback<void(::zx::channel c)> cb) |
| : cb_(std::move(cb)) {} |
| |
| void OnReply(GetChildResponse* message) override { |
| cb_(std::move(message->c)); |
| |
| fidl_close_handles(type(), message, nullptr); |
| |
| delete this; |
| } |
| |
| void OnError() override { delete this; } |
| |
| private: |
| ::fit::callback<void(::zx::channel c)> cb_; |
| }; |
| |
| auto* _context = new ResponseContext(std::move(_cb)); |
| ::fidl::internal::ClientBase::PrepareAsyncTxn(_context); |
| GetChildOwnedRequest _request(_context->Txid()); |
| return _request.GetFidlMessage().Write(this, _context); |
| } |
| |
| ::fidl::Result Parent::ClientImpl::GetChild(GetChildResponseContext* _context) { |
| ::fidl::internal::ClientBase::PrepareAsyncTxn(_context); |
| |
| GetChildOwnedRequest _request(_context->Txid()); |
| return _request.GetFidlMessage().Write(this, _context); |
| } |
| |
| Parent::ResultOf::GetChildRequest Parent::ClientImpl::GetChildRequest_Sync() { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| return ResultOf::GetChildRequest(_binding->handle()); |
| } |
| return Parent::ResultOf::GetChildRequest( |
| ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound)); |
| } |
| |
| Parent::UnownedResultOf::GetChildRequest |
| Parent::ClientImpl::GetChildRequest_Sync(::fidl::BytePart _response_buffer) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| return UnownedResultOf::GetChildRequest(_binding->handle(), |
| _response_buffer.data(), |
| _response_buffer.capacity()); |
| } |
| return Parent::UnownedResultOf::GetChildRequest( |
| ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound)); |
| } |
| |
| Parent::GetChildRequestResponseContext::GetChildRequestResponseContext() |
| : ::fidl::internal::ResponseContext(GetChildRequestResponse::Type, |
| kParent_GetChildRequest_Ordinal) {} |
| |
| void Parent::GetChildRequestResponseContext::OnReply(uint8_t* reply) { |
| OnReply(reinterpret_cast<GetChildRequestResponse*>(reply)); |
| } |
| |
| ::fidl::Result Parent::ClientImpl::GetChildRequest( |
| ::fit::callback<void(::zx::channel r)> _cb) { |
| class ResponseContext final : public GetChildRequestResponseContext { |
| public: |
| ResponseContext(::fit::callback<void(::zx::channel r)> cb) |
| : cb_(std::move(cb)) {} |
| |
| void OnReply(GetChildRequestResponse* message) override { |
| cb_(std::move(message->r)); |
| |
| fidl_close_handles(type(), message, nullptr); |
| |
| delete this; |
| } |
| |
| void OnError() override { delete this; } |
| |
| private: |
| ::fit::callback<void(::zx::channel r)> cb_; |
| }; |
| |
| auto* _context = new ResponseContext(std::move(_cb)); |
| ::fidl::internal::ClientBase::PrepareAsyncTxn(_context); |
| GetChildRequestOwnedRequest _request(_context->Txid()); |
| return _request.GetFidlMessage().Write(this, _context); |
| } |
| |
| ::fidl::Result Parent::ClientImpl::GetChildRequest( |
| GetChildRequestResponseContext* _context) { |
| ::fidl::internal::ClientBase::PrepareAsyncTxn(_context); |
| |
| GetChildRequestOwnedRequest _request(_context->Txid()); |
| return _request.GetFidlMessage().Write(this, _context); |
| } |
| |
| ::fidl::Result Parent::ClientImpl::TakeChild(::zx::channel c) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| auto _res = ResultOf::TakeChild(_binding->handle(), c); |
| return ::fidl::Result(_res.status(), _res.error()); |
| } |
| return ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| |
| ::fidl::Result Parent::ClientImpl::TakeChild(::fidl::BytePart _request_buffer, |
| ::zx::channel c) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| auto _res = |
| UnownedResultOf::TakeChild(_binding->handle(), _request_buffer.data(), |
| _request_buffer.capacity(), c); |
| return ::fidl::Result(_res.status(), _res.error()); |
| } |
| return ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| |
| ::fidl::Result Parent::ClientImpl::TakeChildRequest(::zx::channel r) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| auto _res = ResultOf::TakeChildRequest(_binding->handle(), r); |
| return ::fidl::Result(_res.status(), _res.error()); |
| } |
| return ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| |
| ::fidl::Result Parent::ClientImpl::TakeChildRequest( |
| ::fidl::BytePart _request_buffer, ::zx::channel r) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| auto _res = UnownedResultOf::TakeChildRequest( |
| _binding->handle(), _request_buffer.data(), _request_buffer.capacity(), |
| r); |
| return ::fidl::Result(_res.status(), _res.error()); |
| } |
| return ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| |
| std::optional<::fidl::UnbindInfo> Parent::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 ParentDispatchGetChild(void* interface, void* bytes, |
| ::fidl::Transaction* txn) { |
| reinterpret_cast<Parent::Interface*>(interface)->GetChild( |
| Parent::Interface::GetChildCompleter::Sync(txn)); |
| } |
| |
| void ParentDispatchGetChildRequest(void* interface, void* bytes, |
| ::fidl::Transaction* txn) { |
| reinterpret_cast<Parent::Interface*>(interface)->GetChildRequest( |
| Parent::Interface::GetChildRequestCompleter::Sync(txn)); |
| } |
| |
| void ParentDispatchTakeChild(void* interface, void* bytes, |
| ::fidl::Transaction* txn) { |
| auto message = reinterpret_cast<Parent::TakeChildRequest*>(bytes); |
| reinterpret_cast<Parent::Interface*>(interface)->TakeChild( |
| std::move(message->c), Parent::Interface::TakeChildCompleter::Sync(txn)); |
| } |
| |
| void ParentDispatchTakeChildRequest(void* interface, void* bytes, |
| ::fidl::Transaction* txn) { |
| auto message = reinterpret_cast<Parent::TakeChildRequestRequest*>(bytes); |
| reinterpret_cast<Parent::Interface*>(interface)->TakeChildRequest( |
| std::move(message->r), |
| Parent::Interface::TakeChildRequestCompleter::Sync(txn)); |
| } |
| |
| } // namespace methods |
| |
| namespace entries { |
| |
| ::fidl::internal::MethodEntry Parent[] = { |
| {kParent_GetChild_Ordinal, Parent::GetChildRequest::Type, |
| methods::ParentDispatchGetChild}, |
| {kParent_GetChildRequest_Ordinal, Parent::GetChildRequestRequest::Type, |
| methods::ParentDispatchGetChildRequest}, |
| {kParent_TakeChild_Ordinal, Parent::TakeChildRequest::Type, |
| methods::ParentDispatchTakeChild}, |
| {kParent_TakeChildRequest_Ordinal, Parent::TakeChildRequestRequest::Type, |
| methods::ParentDispatchTakeChildRequest}, |
| }; |
| |
| } // namespace entries |
| |
| bool Parent::TryDispatch(Interface* impl, fidl_msg_t* msg, |
| ::fidl::Transaction* txn) { |
| return ::fidl::internal::TryDispatch( |
| impl, msg, txn, entries::Parent, |
| entries::Parent + |
| sizeof(entries::Parent) / sizeof(::fidl::internal::MethodEntry)); |
| } |
| |
| bool Parent::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 Parent::Interface::GetChildCompleterBase::Reply( |
| ::zx::channel c) { |
| GetChildOwnedResponse _response{c}; |
| return CompleterBase::SendReply(_response.GetFidlMessage()); |
| } |
| |
| ::fidl::Result Parent::Interface::GetChildCompleterBase::Reply( |
| ::fidl::BytePart _buffer, ::zx::channel c) { |
| GetChildUnownedResponse _response(_buffer.data(), _buffer.capacity(), c); |
| return CompleterBase::SendReply(_response.GetFidlMessage()); |
| } |
| |
| ::fidl::Result Parent::Interface::GetChildRequestCompleterBase::Reply( |
| ::zx::channel r) { |
| GetChildRequestOwnedResponse _response{r}; |
| return CompleterBase::SendReply(_response.GetFidlMessage()); |
| } |
| |
| ::fidl::Result Parent::Interface::GetChildRequestCompleterBase::Reply( |
| ::fidl::BytePart _buffer, ::zx::channel r) { |
| GetChildRequestUnownedResponse _response(_buffer.data(), _buffer.capacity(), |
| r); |
| return CompleterBase::SendReply(_response.GetFidlMessage()); |
| } |
| |
| void Parent::GetChildRequest::_InitHeader(zx_txid_t _txid) { |
| fidl_init_txn_header(&_hdr, _txid, kParent_GetChild_Ordinal); |
| } |
| |
| void Parent::GetChildResponse::_InitHeader() { |
| fidl_init_txn_header(&_hdr, 0, kParent_GetChild_Ordinal); |
| } |
| |
| void Parent::GetChildRequestRequest::_InitHeader(zx_txid_t _txid) { |
| fidl_init_txn_header(&_hdr, _txid, kParent_GetChildRequest_Ordinal); |
| } |
| |
| void Parent::GetChildRequestResponse::_InitHeader() { |
| fidl_init_txn_header(&_hdr, 0, kParent_GetChildRequest_Ordinal); |
| } |
| |
| void Parent::TakeChildRequest::_InitHeader(zx_txid_t _txid) { |
| fidl_init_txn_header(&_hdr, _txid, kParent_TakeChild_Ordinal); |
| } |
| |
| void Parent::TakeChildRequestRequest::_InitHeader(zx_txid_t _txid) { |
| fidl_init_txn_header(&_hdr, _txid, kParent_TakeChildRequest_Ordinal); |
| } |
| |
| namespace {} // namespace |
| |
| std::optional<::fidl::UnbindInfo> Child::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 {} // namespace methods |
| |
| namespace entries { |
| |
| ::fidl::internal::MethodEntry Child[] = {}; |
| |
| } // namespace entries |
| |
| bool Child::TryDispatch(Interface* impl, fidl_msg_t* msg, |
| ::fidl::Transaction* txn) { |
| return false; |
| } |
| |
| bool Child::Dispatch(Interface* impl, fidl_msg_t* msg, |
| ::fidl::Transaction* txn) { |
| zx_handle_close_many(msg->handles, msg->num_handles); |
| txn->InternalError( |
| {::fidl::UnbindInfo::kUnexpectedMessage, ZX_ERR_NOT_SUPPORTED}); |
| return false; |
| } |
| |
| } // namespace name |
| } // namespace test |
| } // namespace llcpp |