| // WARNING: This file is machine generated by fidlgen. |
| |
| #include <fidl/test/doccomments/llcpp/fidl.h> |
| |
| #include <memory> |
| |
| void ::fidl_test_doccomments::wire::StrictUnion:: |
| SizeAndOffsetAssertionHelper() { |
| static_assert(sizeof(StrictUnion) == sizeof(fidl_xunion_t)); |
| static_assert(offsetof(StrictUnion, ordinal_) == |
| offsetof(fidl_xunion_t, tag)); |
| static_assert(offsetof(StrictUnion, envelope_) == |
| offsetof(fidl_xunion_t, envelope)); |
| } |
| |
| namespace fidl_test_doccomments { |
| [[maybe_unused]] constexpr uint64_t kInterface_Method_Ordinal = |
| 6649887292072346213lu; |
| |
| extern "C" const fidl_type_t fidl_test_doccomments_InterfaceMethodRequestTable; |
| |
| extern "C" const fidl_type_t fidl_test_doccomments_InterfaceMethodResponseTable; |
| |
| [[maybe_unused]] constexpr uint64_t kInterface_OnEvent_Ordinal = |
| 3999525675942213370lu; |
| |
| extern "C" const fidl_type_t fidl_test_doccomments_InterfaceOnEventRequestTable; |
| |
| extern "C" const fidl_type_t fidl_test_doccomments_InterfaceOnEventEventTable; |
| #ifdef __Fuchsia__ |
| } // namespace fidl_test_doccomments |
| ::fidl::WireResult<::fidl_test_doccomments::Interface::Method>::WireResult( |
| ::fidl::UnownedClientEnd<::fidl_test_doccomments::Interface> _client) { |
| ::fidl::OwnedEncodedMessage< |
| ::fidl::WireRequest<::fidl_test_doccomments::Interface::Method>> |
| _request(zx_txid_t(0)); |
| _request.GetOutgoingMessage().Write(_client); |
| status_ = _request.status(); |
| error_ = _request.error(); |
| } |
| namespace fidl_test_doccomments { |
| #endif // __Fuchsia__ |
| |
| } // namespace fidl_test_doccomments |
| #ifdef __Fuchsia__ |
| ::fidl::Result |
| fidl::internal::WireClientImpl<::fidl_test_doccomments::Interface>::Method() { |
| if (auto _channel = ::fidl::internal::ClientBase::GetChannel()) { |
| auto _res = ::fidl::WireResult<::fidl_test_doccomments::Interface::Method>( |
| ::fidl::UnownedClientEnd<::fidl_test_doccomments::Interface>( |
| _channel->handle())); |
| return ::fidl::Result(_res.status(), _res.error()); |
| } |
| return ::fidl::Result(ZX_ERR_CANCELED, ::fidl::kErrorChannelUnbound); |
| } |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| std::optional<::fidl::UnbindInfo> fidl::internal::WireClientImpl< |
| ::fidl_test_doccomments::Interface>::DispatchEvent(fidl_incoming_msg_t* |
| msg) { |
| if (event_handler_ != nullptr) { |
| fidl_message_header_t* hdr = |
| reinterpret_cast<fidl_message_header_t*>(msg->bytes); |
| switch (hdr->ordinal) { |
| case ::fidl_test_doccomments::kInterface_OnEvent_Ordinal: { |
| const char* error_message; |
| zx_status_t status = fidl_decode_etc( |
| ::fidl::WireResponse< |
| ::fidl_test_doccomments::Interface::OnEvent>::Type, |
| msg->bytes, msg->num_bytes, msg->handles, msg->num_handles, |
| &error_message); |
| if (status != ZX_OK) { |
| return ::fidl::UnbindInfo{::fidl::UnbindInfo::kDecodeError, status}; |
| } |
| event_handler_->OnEvent( |
| reinterpret_cast<::fidl::WireResponse< |
| ::fidl_test_doccomments::Interface::OnEvent>*>(msg->bytes)); |
| return std::nullopt; |
| } |
| default: |
| break; |
| } |
| } |
| FidlHandleInfoCloseMany(msg->handles, msg->num_handles); |
| return ::fidl::UnbindInfo{::fidl::UnbindInfo::kUnexpectedMessage, |
| ZX_ERR_NOT_SUPPORTED}; |
| } |
| #endif // __Fuchsia__ |
| |
| ::fidl::Result |
| fidl::WireSyncEventHandler<::fidl_test_doccomments::Interface>::HandleOneEvent( |
| ::fidl::UnownedClientEnd<::fidl_test_doccomments::Interface> client_end) { |
| zx_status_t status = client_end.channel()->wait_one( |
| ZX_CHANNEL_READABLE | ZX_CHANNEL_PEER_CLOSED, ::zx::time::infinite(), |
| nullptr); |
| if (status != ZX_OK) { |
| return ::fidl::Result(status, ::fidl::kErrorWaitOneFailed); |
| } |
| constexpr uint32_t kHandleAllocSize = ([]() constexpr { |
| uint32_t x = 0; |
| if (::fidl::WireResponse< |
| ::fidl_test_doccomments::Interface::OnEvent>::MaxNumHandles >= x) { |
| x = ::fidl::WireResponse< |
| ::fidl_test_doccomments::Interface::OnEvent>::MaxNumHandles; |
| } |
| if (x > ZX_CHANNEL_MAX_MSG_HANDLES) { |
| x = ZX_CHANNEL_MAX_MSG_HANDLES; |
| } |
| return x; |
| })(); |
| ::fidl::internal::InlineMessageBuffer<16> read_storage; |
| uint8_t* read_bytes = read_storage.data(); |
| zx_handle_info_t read_handles[kHandleAllocSize]; |
| uint32_t actual_bytes; |
| uint32_t actual_handles; |
| status = client_end.channel()->read_etc( |
| ZX_CHANNEL_READ_MAY_DISCARD, read_bytes, read_handles, |
| read_storage.size(), kHandleAllocSize, &actual_bytes, &actual_handles); |
| if (status == ZX_ERR_BUFFER_TOO_SMALL) { |
| // Message size is unexpectedly larger than calculated. |
| // This can only be due to a newer version of the protocol defining a new |
| // event, whose size exceeds the maximum of known events in the current |
| // protocol. |
| return ::fidl::Result(Unknown(), nullptr); |
| } |
| if (status != ZX_OK) { |
| return ::fidl::Result(status, ::fidl::kErrorReadFailed); |
| } |
| if (actual_bytes < sizeof(fidl_message_header_t)) { |
| FidlHandleInfoCloseMany(read_handles, actual_handles); |
| return ::fidl::Result(ZX_ERR_INVALID_ARGS, ::fidl::kErrorInvalidHeader); |
| } |
| fidl_message_header_t* hdr = |
| reinterpret_cast<fidl_message_header_t*>(read_bytes); |
| status = fidl_validate_txn_header(hdr); |
| if (status != ZX_OK) { |
| FidlHandleInfoCloseMany(read_handles, actual_handles); |
| return ::fidl::Result(status, ::fidl::kErrorInvalidHeader); |
| } |
| switch (hdr->ordinal) { |
| case ::fidl_test_doccomments::kInterface_OnEvent_Ordinal: { |
| const char* error_message; |
| zx_status_t status = fidl_decode_etc( |
| ::fidl::WireResponse< |
| ::fidl_test_doccomments::Interface::OnEvent>::Type, |
| read_bytes, actual_bytes, read_handles, actual_handles, |
| &error_message); |
| if (status != ZX_OK) { |
| return ::fidl::Result(status, error_message); |
| } |
| OnEvent(reinterpret_cast<::fidl::WireResponse< |
| ::fidl_test_doccomments::Interface::OnEvent>*>(read_bytes)); |
| return ::fidl::Result(ZX_OK, nullptr); |
| } |
| default: { |
| FidlHandleInfoCloseMany(read_handles, actual_handles); |
| return ::fidl::Result(Unknown(), nullptr); |
| } |
| } |
| } |
| |
| #ifdef __Fuchsia__ |
| |
| ::fidl::DispatchResult |
| fidl::internal::WireDispatcher<::fidl_test_doccomments::Interface>::TryDispatch( |
| ::fidl::WireInterface<::fidl_test_doccomments::Interface>* impl, |
| fidl_incoming_msg_t* msg, ::fidl::Transaction* txn) { |
| static const ::fidl::internal::MethodEntry entries[] = { |
| { |
| ::fidl_test_doccomments::kInterface_Method_Ordinal, |
| ::fidl::WireRequest<::fidl_test_doccomments::Interface::Method>::Type, |
| [](void* interface, void* bytes, ::fidl::Transaction* txn) { |
| ::fidl::WireInterface<::fidl_test_doccomments::Interface>:: |
| MethodCompleter::Sync completer(txn); |
| reinterpret_cast< |
| ::fidl::WireInterface<::fidl_test_doccomments::Interface>*>( |
| interface) |
| ->Method(completer); |
| }, |
| }, |
| }; |
| return ::fidl::internal::TryDispatch( |
| impl, msg, txn, entries, |
| entries + sizeof(entries) / sizeof(::fidl::internal::MethodEntry)); |
| } |
| |
| ::fidl::DispatchResult |
| fidl::internal::WireDispatcher<::fidl_test_doccomments::Interface>::Dispatch( |
| ::fidl::WireInterface<::fidl_test_doccomments::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 |
| fidl::WireInterface<::fidl_test_doccomments::Interface>::dispatch_message( |
| fidl_incoming_msg_t* msg, ::fidl::Transaction* txn) { |
| return ::fidl::internal::WireDispatcher< |
| ::fidl_test_doccomments::Interface>::Dispatch(this, msg, txn); |
| } |
| #endif // __Fuchsia__ |
| |
| void ::fidl::WireRequest< |
| ::fidl_test_doccomments::Interface::Method>::_InitHeader(zx_txid_t _txid) { |
| fidl_init_txn_header(&_hdr, _txid, |
| ::fidl_test_doccomments::kInterface_Method_Ordinal); |
| } |
| |
| void ::fidl::WireResponse< |
| ::fidl_test_doccomments::Interface::OnEvent>::_InitHeader() { |
| fidl_init_txn_header(&_hdr, 0, |
| ::fidl_test_doccomments::kInterface_OnEvent_Ordinal); |
| } |
| |
| #ifdef __Fuchsia__ |
| |
| zx_status_t fidl::WireEventSender<::fidl_test_doccomments::Interface>::OnEvent() |
| const { |
| ::fidl::OwnedEncodedMessage< |
| ::fidl::WireResponse<::fidl_test_doccomments::Interface::OnEvent>> |
| _response{}; |
| _response.Write(server_end_); |
| return _response.status(); |
| } |
| |
| #endif // __Fuchsia__ |
| |
| auto ::fidl_test_doccomments::wire::FlexibleUnion::which() const |
| -> ::fidl_test_doccomments::wire::FlexibleUnion::Tag { |
| ZX_ASSERT(!has_invalid_tag()); |
| switch (ordinal_) { |
| case ::fidl_test_doccomments::wire::FlexibleUnion::Ordinal::kField: |
| return static_cast<::fidl_test_doccomments::wire::FlexibleUnion::Tag>( |
| ordinal_); |
| default: |
| return ::fidl_test_doccomments::wire::FlexibleUnion::Tag::kUnknown; |
| } |
| } |
| |
| void ::fidl_test_doccomments::wire::FlexibleUnion:: |
| SizeAndOffsetAssertionHelper() { |
| static_assert(sizeof(FlexibleUnion) == sizeof(fidl_xunion_t)); |
| static_assert(offsetof(FlexibleUnion, ordinal_) == |
| offsetof(fidl_xunion_t, tag)); |
| static_assert(offsetof(FlexibleUnion, envelope_) == |
| offsetof(fidl_xunion_t, envelope)); |
| } |