| // WARNING: This file is machine generated by fidlgen. |
| |
| #pragma once |
| |
| #include "lib/fidl/cpp/internal/header.h" |
| |
| // |
| // Domain objects declarations (i.e. "natural types" in unified bindings). |
| // |
| namespace fidl { |
| namespace test { |
| namespace error { |
| |
| class Example_foo_Response; |
| class Example_foo_Result; |
| #ifdef __Fuchsia__ |
| class Example; |
| using ExampleHandle = ::fidl::InterfaceHandle<Example>; |
| #endif // __Fuchsia__ |
| |
| class Example_foo_Response final { |
| public: |
| static const fidl_type_t* FidlType; |
| Example_foo_Response() = default; |
| explicit Example_foo_Response(int64_t v) : y(std::move(v)) {} |
| int64_t ResultValue_() { return std::move(y); } |
| explicit Example_foo_Response(std::tuple<int64_t> _value_tuple) { |
| std::tie(y) = std::move(_value_tuple); |
| } |
| operator std::tuple<int64_t>() && { return std::make_tuple(std::move(y)); } |
| |
| int64_t y{}; |
| |
| static inline ::std::unique_ptr<Example_foo_Response> New() { |
| return ::std::make_unique<Example_foo_Response>(); |
| } |
| |
| void Encode(::fidl::Encoder* _encoder, size_t _offset); |
| static void Decode(::fidl::Decoder* _decoder, Example_foo_Response* value, |
| size_t _offset); |
| zx_status_t Clone(Example_foo_Response* result) const; |
| }; |
| |
| inline zx_status_t Clone( |
| const ::fidl::test::error::Example_foo_Response& _value, |
| ::fidl::test::error::Example_foo_Response* _result) { |
| return _value.Clone(_result); |
| } |
| |
| using Example_foo_ResponsePtr = ::std::unique_ptr<Example_foo_Response>; |
| |
| class Example_foo_Result final { |
| public: |
| static const fidl_type_t* FidlType; |
| |
| Example_foo_Result(); |
| ~Example_foo_Result(); |
| |
| Example_foo_Result(Example_foo_Result&&); |
| Example_foo_Result& operator=(Example_foo_Result&&); |
| |
| static Example_foo_Result WithResponse( |
| ::fidl::test::error::Example_foo_Response&&); |
| static Example_foo_Result WithErr(uint32_t&&); |
| |
| enum __attribute__((enum_extensibility(closed))) Tag : fidl_xunion_tag_t { |
| |
| kResponse = 1, // 0x1 |
| kErr = 2, // 0x2 |
| Invalid = ::std::numeric_limits<::fidl_union_tag_t>::max(), |
| }; |
| |
| static inline ::std::unique_ptr<Example_foo_Result> New() { |
| return ::std::make_unique<Example_foo_Result>(); |
| } |
| |
| void Encode(::fidl::Encoder* encoder, size_t offset); |
| static void Decode(::fidl::Decoder* decoder, Example_foo_Result* value, |
| size_t offset); |
| zx_status_t Clone(Example_foo_Result* result) const; |
| |
| bool has_invalid_tag() const { return tag_ == Invalid; } |
| |
| bool is_response() const { return tag_ == Tag::kResponse; } |
| |
| ::fidl::test::error::Example_foo_Response& response() { |
| EnsureStorageInitialized(Tag::kResponse); |
| return response_; |
| } |
| |
| const ::fidl::test::error::Example_foo_Response& response() const { |
| ZX_ASSERT(is_response()); |
| return response_; |
| } |
| Example_foo_Result& set_response( |
| ::fidl::test::error::Example_foo_Response value); |
| |
| bool is_err() const { return tag_ == Tag::kErr; } |
| |
| uint32_t& err() { |
| EnsureStorageInitialized(Tag::kErr); |
| return err_; |
| } |
| |
| const uint32_t& err() const { |
| ZX_ASSERT(is_err()); |
| return err_; |
| } |
| Example_foo_Result& set_err(uint32_t value); |
| |
| Tag Which() const { return Tag(tag_); } |
| |
| // You probably want to use Which() method instead of Ordinal(). Use Ordinal() |
| // only when you need access to the raw integral ordinal value. |
| fidl_xunion_tag_t Ordinal() const { return tag_; } |
| |
| friend ::fidl::Equality<::fidl::test::error::Example_foo_Result>; |
| Example_foo_Result(fit::result<int64_t, uint32_t>&& result) { |
| ZX_ASSERT(!result.is_pending()); |
| if (result.is_ok()) { |
| set_response(Example_foo_Response{result.take_value()}); |
| } else { |
| set_err(std::move(result.take_error())); |
| } |
| } |
| Example_foo_Result(fit::ok_result<int64_t>&& result) |
| : Example_foo_Result(fit::result<int64_t, uint32_t>(std::move(result))) {} |
| Example_foo_Result(fit::error_result<uint32_t>&& result) |
| : Example_foo_Result(fit::result<int64_t, uint32_t>(std::move(result))) {} |
| operator fit::result<int64_t, uint32_t>() && { |
| if (is_err()) { |
| return fit::error(err()); |
| } |
| std::tuple<int64_t> value_tuple = std::move(response()); |
| return fit::ok(std::move(std::get<0>(value_tuple))); |
| } |
| |
| private: |
| void Destroy(); |
| void EnsureStorageInitialized(::fidl_xunion_tag_t tag); |
| |
| ::fidl_xunion_tag_t tag_ = static_cast<fidl_xunion_tag_t>(Tag::Invalid); |
| union { |
| ::fidl::test::error::Example_foo_Response response_; |
| uint32_t err_; |
| }; |
| }; |
| |
| inline zx_status_t Clone(const ::fidl::test::error::Example_foo_Result& value, |
| ::fidl::test::error::Example_foo_Result* result) { |
| return value.Clone(result); |
| } |
| |
| using Example_foo_ResultPtr = ::std::unique_ptr<Example_foo_Result>; |
| #ifdef __Fuchsia__ |
| |
| namespace _internal { |
| extern "C" const fidl_type_t fidl_test_error_ExamplefooRequestTable; |
| } |
| |
| class Example_RequestEncoder { |
| public: |
| static ::fidl::HLCPPOutgoingMessage foo(::fidl::Encoder* _encoder, |
| ::std::string* s) { |
| fidl_trace(WillHLCPPEncode); |
| _encoder->Alloc(32 - sizeof(fidl_message_header_t)); |
| ::fidl::Encode(_encoder, s, 16); |
| |
| fidl_trace(DidHLCPPEncode, |
| &_internal::fidl_test_error_ExamplefooRequestTable, |
| _encoder->GetPtr<const char>(0), _encoder->CurrentLength(), |
| _encoder->CurrentHandleCount()); |
| |
| return _encoder->GetMessage(); |
| } |
| }; |
| |
| namespace _internal { |
| extern "C" const fidl_type_t fidl_test_error_ExamplefooResponseTable; |
| } |
| |
| class Example_ResponseEncoder { |
| public: |
| static ::fidl::HLCPPOutgoingMessage foo( |
| ::fidl::Encoder* _encoder, |
| ::fidl::test::error::Example_foo_Result* result) { |
| fidl_trace(WillHLCPPEncode); |
| _encoder->Alloc(40 - sizeof(fidl_message_header_t)); |
| ::fidl::Encode(_encoder, result, 16); |
| |
| fidl_trace(DidHLCPPEncode, |
| &_internal::fidl_test_error_ExamplefooResponseTable, |
| _encoder->GetPtr<const char>(0), _encoder->CurrentLength(), |
| _encoder->CurrentHandleCount()); |
| return _encoder->GetMessage(); |
| } |
| }; |
| |
| #endif // __Fuchsia__ |
| } // namespace error |
| } // namespace test |
| } // namespace fidl |
| namespace fidl { |
| |
| template <> |
| struct CodingTraits<::fidl::test::error::Example_foo_Response> |
| : public EncodableCodingTraits<::fidl::test::error::Example_foo_Response, |
| 8> {}; |
| |
| template <> |
| struct IsMemcpyCompatible<::fidl::test::error::Example_foo_Response> |
| : public internal::BoolConstant< |
| !HasPadding<::fidl::test::error::Example_foo_Response>::value && |
| IsMemcpyCompatible<int64_t>::value> {}; |
| |
| inline zx_status_t Clone(const ::fidl::test::error::Example_foo_Response& value, |
| ::fidl::test::error::Example_foo_Response* result) { |
| return ::fidl::test::error::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::fidl::test::error::Example_foo_Response> { |
| bool operator()(const ::fidl::test::error::Example_foo_Response& _lhs, |
| const ::fidl::test::error::Example_foo_Response& _rhs) const { |
| if (!::fidl::Equals(_lhs.y, _rhs.y)) { |
| return false; |
| } |
| return true; |
| } |
| }; |
| template <> |
| struct IsFidlXUnion<::fidl::test::error::Example_foo_Result> |
| : public std::true_type {}; |
| |
| template <> |
| struct CodingTraits<::fidl::test::error::Example_foo_Result> |
| : public EncodableCodingTraits<::fidl::test::error::Example_foo_Result, |
| 24> {}; |
| |
| template <> |
| struct CodingTraits<std::unique_ptr<::fidl::test::error::Example_foo_Result>> { |
| static constexpr size_t inline_size_v1_no_ee = 24; |
| |
| static void Encode( |
| Encoder* encoder, |
| std::unique_ptr<::fidl::test::error::Example_foo_Result>* value, |
| size_t offset) { |
| auto&& p_xunion = *value; |
| if (p_xunion) { |
| p_xunion->Encode(encoder, offset); |
| } |
| } |
| |
| static void Decode( |
| Decoder* decoder, |
| std::unique_ptr<::fidl::test::error::Example_foo_Result>* value, |
| size_t offset) { |
| fidl_xunion_t* encoded = decoder->GetPtr<fidl_xunion_t>(offset); |
| if (encoded->tag == 0) { |
| value->reset(nullptr); |
| return; |
| } |
| |
| value->reset(new ::fidl::test::error::Example_foo_Result); |
| |
| ::fidl::test::error::Example_foo_Result::Decode(decoder, value->get(), |
| offset); |
| } |
| }; |
| |
| inline zx_status_t Clone(const ::fidl::test::error::Example_foo_Result& value, |
| ::fidl::test::error::Example_foo_Result* result) { |
| return ::fidl::test::error::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::fidl::test::error::Example_foo_Result> { |
| bool operator()(const ::fidl::test::error::Example_foo_Result& _lhs, |
| const ::fidl::test::error::Example_foo_Result& _rhs) const { |
| if (_lhs.Ordinal() != _rhs.Ordinal()) { |
| return false; |
| } |
| |
| switch (_lhs.Ordinal()) { |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::error::Example_foo_Result::Tag::Invalid): |
| return true; |
| case ::fidl::test::error::Example_foo_Result::Tag::kResponse: |
| return ::fidl::Equals(_lhs.response_, _rhs.response_); |
| case ::fidl::test::error::Example_foo_Result::Tag::kErr: |
| return ::fidl::Equals(_lhs.err_, _rhs.err_); |
| |
| default: |
| return false; |
| } |
| } |
| }; |
| } // namespace fidl |
| |
| // |
| // Proxies and stubs declarations |
| // |
| namespace fidl { |
| namespace test { |
| namespace error { |
| |
| #ifdef __Fuchsia__ |
| using ExamplePtr = ::fidl::InterfacePtr<Example>; |
| class Example_Proxy; |
| class Example_Stub; |
| class Example_EventSender; |
| class Example_Sync; |
| using ExampleSyncPtr = ::fidl::SynchronousInterfacePtr<Example>; |
| class Example_SyncProxy; |
| |
| namespace internal { |
| constexpr uint64_t kExample_foo_Ordinal = 0x57e41804562237aelu; |
| |
| } // namespace internal |
| #endif // __Fuchsia__ |
| #ifdef __Fuchsia__ |
| class Example { |
| public: |
| using Proxy_ = Example_Proxy; |
| using Stub_ = Example_Stub; |
| using EventSender_ = Example_EventSender; |
| using Sync_ = Example_Sync; |
| virtual ~Example(); |
| using fooCallback = |
| fit::function<void(::fidl::test::error::Example_foo_Result)>; |
| |
| virtual void foo(::std::string s, fooCallback callback) = 0; |
| }; |
| |
| class Example_RequestDecoder { |
| public: |
| Example_RequestDecoder() = default; |
| virtual ~Example_RequestDecoder() = default; |
| static const fidl_type_t* GetType(uint64_t ordinal, bool* out_needs_response); |
| virtual void foo(::std::string s) = 0; |
| }; |
| |
| class Example_ResponseDecoder { |
| public: |
| Example_ResponseDecoder() = default; |
| virtual ~Example_ResponseDecoder() = default; |
| static const fidl_type_t* GetType(uint64_t ordinal); |
| virtual void foo(::fidl::test::error::Example_foo_Result result) = 0; |
| }; |
| |
| class Example_EventSender { |
| public: |
| virtual ~Example_EventSender(); |
| }; |
| |
| class Example_Sync { |
| public: |
| using Proxy_ = Example_SyncProxy; |
| virtual ~Example_Sync(); |
| virtual zx_status_t foo( |
| ::std::string s, ::fidl::test::error::Example_foo_Result* out_result) = 0; |
| }; |
| |
| class Example_Proxy final : public ::fidl::internal::Proxy, public Example { |
| public: |
| explicit Example_Proxy(::fidl::internal::ProxyController* controller); |
| ~Example_Proxy() override; |
| |
| zx_status_t Dispatch_(::fidl::HLCPPIncomingMessage message) override; |
| void foo(::std::string s, fooCallback callback) override; |
| |
| private: |
| Example_Proxy(const Example_Proxy&) = delete; |
| Example_Proxy& operator=(const Example_Proxy&) = delete; |
| |
| ::fidl::internal::ProxyController* controller_; |
| }; |
| |
| class Example_Stub final : public ::fidl::internal::Stub, |
| public Example_EventSender { |
| public: |
| typedef class ::fidl::test::error::Example Example_clazz; |
| explicit Example_Stub(Example_clazz* impl); |
| ~Example_Stub() override; |
| |
| zx_status_t Dispatch_(::fidl::HLCPPIncomingMessage message, |
| ::fidl::internal::PendingResponse response) override; |
| |
| private: |
| Example_clazz* impl_; |
| }; |
| |
| class Example_SyncProxy : public Example_Sync { |
| public: |
| explicit Example_SyncProxy(::zx::channel channel); |
| ~Example_SyncProxy() override; |
| zx_status_t foo(::std::string s, |
| ::fidl::test::error::Example_foo_Result* out_result) override; |
| |
| private: |
| ::fidl::internal::SynchronousProxy proxy_; |
| friend class ::fidl::SynchronousInterfacePtr<Example>; |
| }; |
| |
| #endif // __Fuchsia__ |
| } // namespace error |
| } // namespace test |
| } // namespace fidl |