| // WARNING: This file is machine generated by fidlgen. |
| |
| #include <fidl/test/foreigntypeinresponseusedthroughcompose/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 foreigntypeinresponseusedthroughcompose { |
| namespace _internal { |
| extern "C" const fidl_type_t |
| fidl_test_foreigntypeinresponseusedthroughcompose_TopGetFooRequestTable; |
| |
| extern "C" const fidl_type_t |
| fidl_test_foreigntypeinresponseusedthroughcompose_TopGetFooResponseTable; |
| |
| } // namespace _internal |
| Top::~Top() = default; |
| |
| const fidl_type_t* ::fidl::test::foreigntypeinresponseusedthroughcompose:: |
| Top_RequestDecoder::GetType(uint64_t ordinal, bool* out_needs_response) { |
| switch (ordinal) { |
| case ::fidl::test::foreigntypeinresponseusedthroughcompose::internal:: |
| kTop_GetFoo_Ordinal: |
| *out_needs_response = true; |
| return &::fidl::test::foreigntypeinresponseusedthroughcompose::_internal:: |
| fidl_test_foreigntypeinresponseusedthroughcompose_TopGetFooRequestTable; |
| default: |
| *out_needs_response = false; |
| return nullptr; |
| } |
| } |
| |
| const fidl_type_t* Top_ResponseDecoder::GetType(uint64_t ordinal) { |
| switch (ordinal) { |
| case ::fidl::test::foreigntypeinresponseusedthroughcompose::internal:: |
| kTop_GetFoo_Ordinal: |
| return &::fidl::test::foreigntypeinresponseusedthroughcompose::_internal:: |
| fidl_test_foreigntypeinresponseusedthroughcompose_TopGetFooResponseTable; |
| default: |
| return nullptr; |
| } |
| } |
| |
| Top_EventSender::~Top_EventSender() = default; |
| |
| Top_Sync::~Top_Sync() = default; |
| |
| Top_Proxy::Top_Proxy(::fidl::internal::ProxyController* controller) |
| : controller_(controller) { |
| (void)controller_; |
| } |
| |
| Top_Proxy::~Top_Proxy() = default; |
| |
| zx_status_t Top_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> |
| Top_GetFoo_ResponseHandler(Top::GetFooCallback&& callback) { |
| ZX_DEBUG_ASSERT_MSG(callback, "Callback must not be empty for Top::GetFoo\n"); |
| return ::std::make_unique<::fidl::internal::SingleUseMessageHandler>( |
| [callback_ = |
| std::move(callback)](::fidl::HLCPPIncomingMessage&& message) { |
| ::fidl::Decoder decoder(std::move(message)); |
| callback_(::fidl::DecodeAs<::bottom::Foo>(&decoder, 16)); |
| return ZX_OK; |
| }, |
| &::fidl::test::foreigntypeinresponseusedthroughcompose::_internal:: |
| fidl_test_foreigntypeinresponseusedthroughcompose_TopGetFooResponseTable); |
| } |
| |
| } // namespace |
| void Top_Proxy::GetFoo(GetFooCallback callback) { |
| ::fidl::Encoder _encoder( |
| ::fidl::test::foreigntypeinresponseusedthroughcompose::internal:: |
| kTop_GetFoo_Ordinal); |
| controller_->Send( |
| &::fidl::test::foreigntypeinresponseusedthroughcompose::_internal:: |
| fidl_test_foreigntypeinresponseusedthroughcompose_TopGetFooRequestTable, |
| ::fidl::test::foreigntypeinresponseusedthroughcompose:: |
| Top_RequestEncoder::GetFoo(&_encoder), |
| Top_GetFoo_ResponseHandler(std::move(callback))); |
| } |
| |
| Top_Stub::Top_Stub( |
| ::fidl::test::foreigntypeinresponseusedthroughcompose::Top_Stub::Top_clazz* |
| impl) |
| : impl_(impl) { |
| (void)impl_; |
| } |
| |
| Top_Stub::~Top_Stub() = default; |
| |
| namespace { |
| |
| class Top_GetFoo_Responder final { |
| public: |
| Top_GetFoo_Responder(::fidl::internal::PendingResponse response) |
| : response_(std::move(response)) {} |
| |
| void operator()(::bottom::Foo foo) { |
| ::fidl::Encoder _encoder( |
| ::fidl::test::foreigntypeinresponseusedthroughcompose::internal:: |
| kTop_GetFoo_Ordinal); |
| response_.Send( |
| &::fidl::test::foreigntypeinresponseusedthroughcompose::_internal:: |
| fidl_test_foreigntypeinresponseusedthroughcompose_TopGetFooResponseTable, |
| ::fidl::test::foreigntypeinresponseusedthroughcompose:: |
| Top_ResponseEncoder::GetFoo(&_encoder, &foo)); |
| } |
| |
| private: |
| ::fidl::internal::PendingResponse response_; |
| }; |
| |
| } // namespace |
| |
| zx_status_t Top_Stub::Dispatch_(::fidl::HLCPPIncomingMessage message, |
| ::fidl::internal::PendingResponse response) { |
| bool needs_response; |
| const fidl_type_t* request_type = |
| ::fidl::test::foreigntypeinresponseusedthroughcompose:: |
| Top_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::foreigntypeinresponseusedthroughcompose::internal:: |
| kTop_GetFoo_Ordinal: { |
| impl_->GetFoo(Top_GetFoo_Responder(std::move(response))); |
| break; |
| } |
| default: { |
| status = ZX_ERR_NOT_SUPPORTED; |
| break; |
| } |
| } |
| return status; |
| } |
| |
| Top_SyncProxy::Top_SyncProxy(::zx::channel channel) |
| : proxy_(::std::move(channel)) {} |
| |
| Top_SyncProxy::~Top_SyncProxy() = default; |
| |
| zx_status_t Top_SyncProxy::GetFoo(::bottom::Foo* out_foo) { |
| ::fidl::Encoder _encoder( |
| ::fidl::test::foreigntypeinresponseusedthroughcompose::internal:: |
| kTop_GetFoo_Ordinal); |
| ::fidl::IncomingMessageBuffer buffer_; |
| ::fidl::HLCPPIncomingMessage response_ = buffer_.CreateEmptyIncomingMessage(); |
| zx_status_t status_ = proxy_.Call( |
| &::fidl::test::foreigntypeinresponseusedthroughcompose::_internal:: |
| fidl_test_foreigntypeinresponseusedthroughcompose_TopGetFooRequestTable, |
| &::fidl::test::foreigntypeinresponseusedthroughcompose::_internal:: |
| fidl_test_foreigntypeinresponseusedthroughcompose_TopGetFooResponseTable, |
| ::fidl::test::foreigntypeinresponseusedthroughcompose:: |
| Top_RequestEncoder::GetFoo(&_encoder), |
| &response_); |
| if (status_ != ZX_OK) return status_; |
| ::fidl::Decoder decoder_(std::move(response_)); |
| *out_foo = ::fidl::DecodeAs<::bottom::Foo>(&decoder_, 16); |
| return ZX_OK; |
| } |
| } // namespace foreigntypeinresponseusedthroughcompose |
| } // namespace test |
| } // namespace fidl |
| #endif // __Fuchsia__ |