| // WARNING: This file is machine generated by fidlgen. |
| |
| #include <fidl/test/protocolrequest/cpp/fidl.h> |
| |
| #include "lib/fidl/cpp/internal/implementation.h" |
| |
| // |
| // Domain objects definitions (i.e. "natural types" in unified bindings) |
| // |
| |
| // |
| // Proxies and stubs definitions |
| // |
| #ifdef __Fuchsia__ |
| |
| namespace fidl { |
| namespace test { |
| namespace protocolrequest { |
| namespace _internal { |
| extern "C" const fidl_type_t |
| fidl_test_protocolrequest_ParentGetChildRequestTable; |
| |
| extern "C" const fidl_type_t |
| fidl_test_protocolrequest_ParentGetChildResponseTable; |
| |
| extern "C" const fidl_type_t |
| fidl_test_protocolrequest_ParentGetChildRequestRequestTable; |
| |
| extern "C" const fidl_type_t |
| fidl_test_protocolrequest_ParentGetChildRequestResponseTable; |
| |
| extern "C" const fidl_type_t |
| fidl_test_protocolrequest_ParentTakeChildRequestTable; |
| |
| extern "C" const fidl_type_t |
| fidl_test_protocolrequest_ParentTakeChildRequestRequestTable; |
| |
| } // namespace _internal |
| Parent::~Parent() = default; |
| |
| const fidl_type_t* ::fidl::test::protocolrequest::Parent_RequestDecoder:: |
| GetType(uint64_t ordinal, bool* out_needs_response) { |
| switch (ordinal) { |
| case ::fidl::test::protocolrequest::internal::kParent_GetChild_Ordinal: |
| *out_needs_response = true; |
| return &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildRequestTable; |
| case ::fidl::test::protocolrequest::internal:: |
| kParent_GetChildRequest_Ordinal: |
| *out_needs_response = true; |
| return &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildRequestRequestTable; |
| case ::fidl::test::protocolrequest::internal::kParent_TakeChild_Ordinal: |
| *out_needs_response = false; |
| return &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentTakeChildRequestTable; |
| case ::fidl::test::protocolrequest::internal:: |
| kParent_TakeChildRequest_Ordinal: |
| *out_needs_response = false; |
| return &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentTakeChildRequestRequestTable; |
| default: |
| *out_needs_response = false; |
| return nullptr; |
| } |
| } |
| |
| const fidl_type_t* Parent_ResponseDecoder::GetType(uint64_t ordinal) { |
| switch (ordinal) { |
| case ::fidl::test::protocolrequest::internal::kParent_GetChild_Ordinal: |
| return &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildResponseTable; |
| case ::fidl::test::protocolrequest::internal:: |
| kParent_GetChildRequest_Ordinal: |
| return &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildRequestResponseTable; |
| default: |
| return nullptr; |
| } |
| } |
| |
| Parent_EventSender::~Parent_EventSender() = default; |
| |
| Parent_Sync::~Parent_Sync() = default; |
| |
| Parent_Proxy::Parent_Proxy(::fidl::internal::ProxyController* controller) |
| : controller_(controller) { |
| (void)controller_; |
| } |
| |
| Parent_Proxy::~Parent_Proxy() = default; |
| |
| zx_status_t Parent_Proxy::Dispatch_(::fidl::HLCPPIncomingMessage message) { |
| zx_status_t status = ZX_OK; |
| switch (message.ordinal()) { |
| default: { |
| status = ZX_ERR_NOT_SUPPORTED; |
| break; |
| } |
| } |
| return status; |
| } |
| |
| namespace { |
| |
| ::std::unique_ptr<::fidl::internal::SingleUseMessageHandler> |
| Parent_GetChild_ResponseHandler(Parent::GetChildCallback&& callback) { |
| ZX_DEBUG_ASSERT_MSG(callback, |
| "Callback must not be empty for Parent::GetChild\n"); |
| return ::std::make_unique<::fidl::internal::SingleUseMessageHandler>( |
| [callback_ = |
| std::move(callback)](::fidl::HLCPPIncomingMessage&& message) { |
| ::fidl::Decoder decoder(std::move(message)); |
| callback_( |
| ::fidl::DecodeAs< |
| ::fidl::InterfaceHandle<::fidl::test::protocolrequest::Child>>( |
| &decoder, 16)); |
| return ZX_OK; |
| }, |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildResponseTable); |
| } |
| |
| } // namespace |
| void Parent_Proxy::GetChild(GetChildCallback callback) { |
| ::fidl::Encoder _encoder( |
| ::fidl::test::protocolrequest::internal::kParent_GetChild_Ordinal); |
| controller_->Send( |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildRequestTable, |
| ::fidl::test::protocolrequest::Parent_RequestEncoder::GetChild(&_encoder), |
| Parent_GetChild_ResponseHandler(std::move(callback))); |
| } |
| namespace { |
| |
| ::std::unique_ptr<::fidl::internal::SingleUseMessageHandler> |
| Parent_GetChildRequest_ResponseHandler( |
| Parent::GetChildRequestCallback&& callback) { |
| ZX_DEBUG_ASSERT_MSG( |
| callback, "Callback must not be empty for Parent::GetChildRequest\n"); |
| return ::std::make_unique<::fidl::internal::SingleUseMessageHandler>( |
| [callback_ = |
| std::move(callback)](::fidl::HLCPPIncomingMessage&& message) { |
| ::fidl::Decoder decoder(std::move(message)); |
| callback_( |
| ::fidl::DecodeAs< |
| ::fidl::InterfaceRequest<::fidl::test::protocolrequest::Child>>( |
| &decoder, 16)); |
| return ZX_OK; |
| }, |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildRequestResponseTable); |
| } |
| |
| } // namespace |
| void Parent_Proxy::GetChildRequest(GetChildRequestCallback callback) { |
| ::fidl::Encoder _encoder( |
| ::fidl::test::protocolrequest::internal::kParent_GetChildRequest_Ordinal); |
| controller_->Send( |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildRequestRequestTable, |
| ::fidl::test::protocolrequest::Parent_RequestEncoder::GetChildRequest( |
| &_encoder), |
| Parent_GetChildRequest_ResponseHandler(std::move(callback))); |
| } |
| void Parent_Proxy::TakeChild( |
| ::fidl::InterfaceHandle<::fidl::test::protocolrequest::Child> c) { |
| ::fidl::Encoder _encoder( |
| ::fidl::test::protocolrequest::internal::kParent_TakeChild_Ordinal); |
| controller_->Send( |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentTakeChildRequestTable, |
| ::fidl::test::protocolrequest::Parent_RequestEncoder::TakeChild(&_encoder, |
| &c), |
| nullptr); |
| } |
| void Parent_Proxy::TakeChildRequest( |
| ::fidl::InterfaceRequest<::fidl::test::protocolrequest::Child> r) { |
| ::fidl::Encoder _encoder(::fidl::test::protocolrequest::internal:: |
| kParent_TakeChildRequest_Ordinal); |
| controller_->Send( |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentTakeChildRequestRequestTable, |
| ::fidl::test::protocolrequest::Parent_RequestEncoder::TakeChildRequest( |
| &_encoder, &r), |
| nullptr); |
| } |
| |
| Parent_Stub::Parent_Stub( |
| ::fidl::test::protocolrequest::Parent_Stub::Parent_clazz* impl) |
| : impl_(impl) { |
| (void)impl_; |
| } |
| |
| Parent_Stub::~Parent_Stub() = default; |
| |
| namespace { |
| |
| class Parent_GetChild_Responder final { |
| public: |
| Parent_GetChild_Responder(::fidl::internal::PendingResponse response) |
| : response_(std::move(response)) {} |
| |
| void operator()( |
| ::fidl::InterfaceHandle<::fidl::test::protocolrequest::Child> c) { |
| ::fidl::Encoder _encoder( |
| ::fidl::test::protocolrequest::internal::kParent_GetChild_Ordinal); |
| response_.Send( |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildResponseTable, |
| ::fidl::test::protocolrequest::Parent_ResponseEncoder::GetChild( |
| &_encoder, &c)); |
| } |
| |
| private: |
| ::fidl::internal::PendingResponse response_; |
| }; |
| |
| class Parent_GetChildRequest_Responder final { |
| public: |
| Parent_GetChildRequest_Responder(::fidl::internal::PendingResponse response) |
| : response_(std::move(response)) {} |
| |
| void operator()( |
| ::fidl::InterfaceRequest<::fidl::test::protocolrequest::Child> r) { |
| ::fidl::Encoder _encoder(::fidl::test::protocolrequest::internal:: |
| kParent_GetChildRequest_Ordinal); |
| response_.Send( |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildRequestResponseTable, |
| ::fidl::test::protocolrequest::Parent_ResponseEncoder::GetChildRequest( |
| &_encoder, &r)); |
| } |
| |
| private: |
| ::fidl::internal::PendingResponse response_; |
| }; |
| |
| } // namespace |
| |
| zx_status_t Parent_Stub::Dispatch_(::fidl::HLCPPIncomingMessage message, |
| ::fidl::internal::PendingResponse response) { |
| bool needs_response; |
| const fidl_type_t* request_type = |
| ::fidl::test::protocolrequest::Parent_RequestDecoder::GetType( |
| message.ordinal(), &needs_response); |
| if (request_type == nullptr) { |
| return ZX_ERR_NOT_SUPPORTED; |
| } |
| if (response.needs_response() != needs_response) { |
| if (needs_response) { |
| FIDL_REPORT_DECODING_ERROR(message, request_type, |
| "Message needing a response with no txid"); |
| } else { |
| FIDL_REPORT_DECODING_ERROR(message, request_type, |
| "Message not needing a response with a txid"); |
| } |
| return ZX_ERR_INVALID_ARGS; |
| } |
| const char* error_msg = nullptr; |
| zx_status_t status = message.Decode(request_type, &error_msg); |
| if (status != ZX_OK) { |
| FIDL_REPORT_DECODING_ERROR(message, request_type, error_msg); |
| return status; |
| } |
| uint64_t ordinal = message.ordinal(); |
| switch (ordinal) { |
| case ::fidl::test::protocolrequest::internal::kParent_GetChild_Ordinal: { |
| impl_->GetChild(Parent_GetChild_Responder(std::move(response))); |
| break; |
| } |
| case ::fidl::test::protocolrequest::internal:: |
| kParent_GetChildRequest_Ordinal: { |
| impl_->GetChildRequest( |
| Parent_GetChildRequest_Responder(std::move(response))); |
| break; |
| } |
| case ::fidl::test::protocolrequest::internal::kParent_TakeChild_Ordinal: { |
| ::fidl::Decoder decoder(std::move(message)); |
| impl_->TakeChild( |
| ::fidl::DecodeAs< |
| ::fidl::InterfaceHandle<::fidl::test::protocolrequest::Child>>( |
| &decoder, 16)); |
| break; |
| } |
| case ::fidl::test::protocolrequest::internal:: |
| kParent_TakeChildRequest_Ordinal: { |
| ::fidl::Decoder decoder(std::move(message)); |
| impl_->TakeChildRequest( |
| ::fidl::DecodeAs< |
| ::fidl::InterfaceRequest<::fidl::test::protocolrequest::Child>>( |
| &decoder, 16)); |
| break; |
| } |
| default: { |
| status = ZX_ERR_NOT_SUPPORTED; |
| break; |
| } |
| } |
| return status; |
| } |
| |
| Parent_SyncProxy::Parent_SyncProxy(::zx::channel channel) |
| : proxy_(::std::move(channel)) {} |
| |
| Parent_SyncProxy::~Parent_SyncProxy() = default; |
| |
| zx_status_t Parent_SyncProxy::GetChild( |
| ::fidl::InterfaceHandle<::fidl::test::protocolrequest::Child>* out_c) { |
| ::fidl::Encoder _encoder( |
| ::fidl::test::protocolrequest::internal::kParent_GetChild_Ordinal); |
| ::fidl::IncomingMessageBuffer buffer_; |
| ::fidl::HLCPPIncomingMessage response_ = buffer_.CreateEmptyIncomingMessage(); |
| zx_status_t status_ = proxy_.Call( |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildRequestTable, |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildResponseTable, |
| ::fidl::test::protocolrequest::Parent_RequestEncoder::GetChild(&_encoder), |
| &response_); |
| if (status_ != ZX_OK) return status_; |
| ::fidl::Decoder decoder_(std::move(response_)); |
| *out_c = ::fidl::DecodeAs< |
| ::fidl::InterfaceHandle<::fidl::test::protocolrequest::Child>>(&decoder_, |
| 16); |
| return ZX_OK; |
| } |
| |
| zx_status_t Parent_SyncProxy::GetChildRequest( |
| ::fidl::InterfaceRequest<::fidl::test::protocolrequest::Child>* out_r) { |
| ::fidl::Encoder _encoder( |
| ::fidl::test::protocolrequest::internal::kParent_GetChildRequest_Ordinal); |
| ::fidl::IncomingMessageBuffer buffer_; |
| ::fidl::HLCPPIncomingMessage response_ = buffer_.CreateEmptyIncomingMessage(); |
| zx_status_t status_ = proxy_.Call( |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildRequestRequestTable, |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentGetChildRequestResponseTable, |
| ::fidl::test::protocolrequest::Parent_RequestEncoder::GetChildRequest( |
| &_encoder), |
| &response_); |
| if (status_ != ZX_OK) return status_; |
| ::fidl::Decoder decoder_(std::move(response_)); |
| *out_r = ::fidl::DecodeAs< |
| ::fidl::InterfaceRequest<::fidl::test::protocolrequest::Child>>(&decoder_, |
| 16); |
| return ZX_OK; |
| } |
| |
| zx_status_t Parent_SyncProxy::TakeChild( |
| ::fidl::InterfaceHandle<::fidl::test::protocolrequest::Child> c) { |
| ::fidl::Encoder _encoder( |
| ::fidl::test::protocolrequest::internal::kParent_TakeChild_Ordinal); |
| return proxy_.Send( |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentTakeChildRequestTable, |
| ::fidl::test::protocolrequest::Parent_RequestEncoder::TakeChild(&_encoder, |
| &c)); |
| } |
| |
| zx_status_t Parent_SyncProxy::TakeChildRequest( |
| ::fidl::InterfaceRequest<::fidl::test::protocolrequest::Child> r) { |
| ::fidl::Encoder _encoder(::fidl::test::protocolrequest::internal:: |
| kParent_TakeChildRequest_Ordinal); |
| return proxy_.Send( |
| &::fidl::test::protocolrequest::_internal:: |
| fidl_test_protocolrequest_ParentTakeChildRequestRequestTable, |
| ::fidl::test::protocolrequest::Parent_RequestEncoder::TakeChildRequest( |
| &_encoder, &r)); |
| } |
| } // namespace protocolrequest |
| } // namespace test |
| } // namespace fidl |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| |
| namespace fidl { |
| namespace test { |
| namespace protocolrequest { |
| Child::~Child() = default; |
| |
| const fidl_type_t* ::fidl::test::protocolrequest::Child_RequestDecoder::GetType( |
| uint64_t ordinal, bool* out_needs_response) { |
| switch (ordinal) { |
| default: |
| *out_needs_response = false; |
| return nullptr; |
| } |
| } |
| |
| const fidl_type_t* Child_ResponseDecoder::GetType(uint64_t ordinal) { |
| switch (ordinal) { |
| default: |
| return nullptr; |
| } |
| } |
| |
| Child_EventSender::~Child_EventSender() = default; |
| |
| Child_Sync::~Child_Sync() = default; |
| |
| Child_Proxy::Child_Proxy(::fidl::internal::ProxyController* controller) |
| : controller_(controller) { |
| (void)controller_; |
| } |
| |
| Child_Proxy::~Child_Proxy() = default; |
| |
| zx_status_t Child_Proxy::Dispatch_(::fidl::HLCPPIncomingMessage message) { |
| zx_status_t status = ZX_OK; |
| switch (message.ordinal()) { |
| default: { |
| status = ZX_ERR_NOT_SUPPORTED; |
| break; |
| } |
| } |
| return status; |
| } |
| |
| Child_Stub::Child_Stub( |
| ::fidl::test::protocolrequest::Child_Stub::Child_clazz* impl) |
| : impl_(impl) { |
| (void)impl_; |
| } |
| |
| Child_Stub::~Child_Stub() = default; |
| |
| namespace {} // namespace |
| |
| zx_status_t Child_Stub::Dispatch_(::fidl::HLCPPIncomingMessage message, |
| ::fidl::internal::PendingResponse response) { |
| bool needs_response; |
| const fidl_type_t* request_type = |
| ::fidl::test::protocolrequest::Child_RequestDecoder::GetType( |
| message.ordinal(), &needs_response); |
| if (request_type == nullptr) { |
| return ZX_ERR_NOT_SUPPORTED; |
| } |
| if (response.needs_response() != needs_response) { |
| if (needs_response) { |
| FIDL_REPORT_DECODING_ERROR(message, request_type, |
| "Message needing a response with no txid"); |
| } else { |
| FIDL_REPORT_DECODING_ERROR(message, request_type, |
| "Message not needing a response with a txid"); |
| } |
| return ZX_ERR_INVALID_ARGS; |
| } |
| const char* error_msg = nullptr; |
| zx_status_t status = message.Decode(request_type, &error_msg); |
| if (status != ZX_OK) { |
| FIDL_REPORT_DECODING_ERROR(message, request_type, error_msg); |
| return status; |
| } |
| uint64_t ordinal = message.ordinal(); |
| switch (ordinal) { |
| default: { |
| status = ZX_ERR_NOT_SUPPORTED; |
| break; |
| } |
| } |
| return status; |
| } |
| |
| Child_SyncProxy::Child_SyncProxy(::zx::channel channel) |
| : proxy_(::std::move(channel)) {} |
| |
| Child_SyncProxy::~Child_SyncProxy() = default; |
| } // namespace protocolrequest |
| } // namespace test |
| } // namespace fidl |
| #endif // __Fuchsia__ |