| // WARNING: This file is machine generated by fidlgen. |
| |
| #include <placement_of_attributes.test.json.llcpp.h> |
| |
| #include <memory> |
| |
| namespace llcpp { |
| |
| namespace example { |
| |
| namespace { |
| |
| [[maybe_unused]] constexpr uint64_t kExampleProtocol_Method_Ordinal = |
| 1965996700874037518lu; |
| extern "C" const fidl_type_t example_ExampleProtocolMethodRequestTable; |
| extern "C" const fidl_type_t example_ExampleProtocolMethodResponseTable; |
| |
| } // namespace |
| ExampleProtocol::ResultOf::Method::Method(zx_handle_t _client, |
| ::llcpp::exampleusing::Empty& arg) { |
| MethodOwnedRequest _request(0, arg); |
| _request.GetFidlMessage().Write(_client); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| ExampleProtocol::UnownedResultOf::Method::Method( |
| zx_handle_t _client, uint8_t* _request_bytes, |
| uint32_t _request_byte_capacity, ::llcpp::exampleusing::Empty& arg) { |
| MethodUnownedRequest _request(_request_bytes, _request_byte_capacity, 0, arg); |
| _request.GetFidlMessage().Write(_client); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| |
| ::fidl::Result ExampleProtocol::ClientImpl::Method( |
| ::llcpp::exampleusing::Empty arg) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| auto _res = ResultOf::Method(_binding->handle(), arg); |
| return ::fidl::Result(_res.status(), _res.error()); |
| } |
| return ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| |
| ::fidl::Result ExampleProtocol::ClientImpl::Method( |
| ::fidl::BytePart _request_buffer, ::llcpp::exampleusing::Empty arg) { |
| if (auto _binding = ::fidl::internal::ClientBase::GetBinding()) { |
| auto _res = |
| UnownedResultOf::Method(_binding->handle(), _request_buffer.data(), |
| _request_buffer.capacity(), arg); |
| return ::fidl::Result(_res.status(), _res.error()); |
| } |
| return ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| |
| std::optional<::fidl::UnbindInfo> ExampleProtocol::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 ExampleProtocolDispatchMethod(void* interface, void* bytes, |
| ::fidl::Transaction* txn) { |
| auto message = reinterpret_cast<ExampleProtocol::MethodRequest*>(bytes); |
| reinterpret_cast<ExampleProtocol::Interface*>(interface)->Method( |
| std::move(message->arg), |
| ExampleProtocol::Interface::MethodCompleter::Sync(txn)); |
| } |
| |
| } // namespace methods |
| |
| namespace entries { |
| |
| ::fidl::internal::MethodEntry ExampleProtocol[] = { |
| {kExampleProtocol_Method_Ordinal, ExampleProtocol::MethodRequest::Type, |
| methods::ExampleProtocolDispatchMethod}, |
| }; |
| |
| } // namespace entries |
| |
| bool ExampleProtocol::TryDispatch(Interface* impl, fidl_msg_t* msg, |
| ::fidl::Transaction* txn) { |
| return ::fidl::internal::TryDispatch( |
| impl, msg, txn, entries::ExampleProtocol, |
| entries::ExampleProtocol + sizeof(entries::ExampleProtocol) / |
| sizeof(::fidl::internal::MethodEntry)); |
| } |
| |
| bool ExampleProtocol::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; |
| } |
| |
| void ExampleProtocol::MethodRequest::_InitHeader(zx_txid_t _txid) { |
| fidl_init_txn_header(&_hdr, _txid, kExampleProtocol_Method_Ordinal); |
| } |
| auto ::llcpp::example::ExampleXUnion::which() const -> Tag { |
| ZX_ASSERT(!has_invalid_tag()); |
| switch (ordinal_) { |
| case Ordinal::kVariant: |
| return static_cast<Tag>(ordinal_); |
| default: |
| return Tag::kUnknown; |
| } |
| } |
| |
| void ::llcpp::example::ExampleXUnion::SizeAndOffsetAssertionHelper() { |
| static_assert(sizeof(ExampleXUnion) == sizeof(fidl_xunion_t)); |
| static_assert(offsetof(ExampleXUnion, ordinal_) == |
| offsetof(fidl_xunion_t, tag)); |
| static_assert(offsetof(ExampleXUnion, envelope_) == |
| offsetof(fidl_xunion_t, envelope)); |
| } |
| |
| void ::llcpp::example::ExampleUnion::SizeAndOffsetAssertionHelper() { |
| static_assert(sizeof(ExampleUnion) == sizeof(fidl_xunion_t)); |
| static_assert(offsetof(ExampleUnion, ordinal_) == |
| offsetof(fidl_xunion_t, tag)); |
| static_assert(offsetof(ExampleUnion, envelope_) == |
| offsetof(fidl_xunion_t, envelope)); |
| } |
| |
| } // namespace example |
| } // namespace llcpp |