| // WARNING: This file is machine generated by fidlgen. |
| |
| #include <fidl/test/protocols/cpp/natural_types.h> |
| |
| #include "lib/fidl/cpp/internal/natural_types_implementation.h" |
| |
| // |
| // Domain objects definitions (i.e. "natural types" in unified bindings) |
| // |
| namespace fidl { |
| namespace test { |
| namespace protocols { |
| |
| extern "C" const fidl_type_t |
| fidl_test_protocols_WithErrorSyntax_ResponseAsStruct_ResponseTable; |
| const fidl_type_t* WithErrorSyntax_ResponseAsStruct_Response::FidlType = |
| &fidl_test_protocols_WithErrorSyntax_ResponseAsStruct_ResponseTable; |
| |
| void WithErrorSyntax_ResponseAsStruct_Response::Encode( |
| ::fidl::Encoder* _encoder, size_t _offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| if (::fidl::IsMemcpyCompatible< |
| WithErrorSyntax_ResponseAsStruct_Response>::value) { |
| memcpy(_encoder->template GetPtr<WithErrorSyntax_ResponseAsStruct_Response>( |
| _offset), |
| this, sizeof(WithErrorSyntax_ResponseAsStruct_Response)); |
| } else { |
| ::fidl::Encode(_encoder, &a, _offset + 0); |
| ::fidl::Encode(_encoder, &b, _offset + 8); |
| ::fidl::Encode(_encoder, &c, _offset + 16); |
| } |
| } |
| |
| void WithErrorSyntax_ResponseAsStruct_Response::Decode( |
| ::fidl::Decoder* _decoder, |
| WithErrorSyntax_ResponseAsStruct_Response* _value, size_t _offset) { |
| if (::fidl::IsMemcpyCompatible< |
| WithErrorSyntax_ResponseAsStruct_Response>::value) { |
| memcpy(_value, |
| _decoder->template GetPtr<WithErrorSyntax_ResponseAsStruct_Response>( |
| _offset), |
| sizeof(WithErrorSyntax_ResponseAsStruct_Response)); |
| } else { |
| ::fidl::Decode(_decoder, &_value->a, _offset + 0); |
| ::fidl::Decode(_decoder, &_value->b, _offset + 8); |
| ::fidl::Decode(_decoder, &_value->c, _offset + 16); |
| } |
| } |
| |
| zx_status_t WithErrorSyntax_ResponseAsStruct_Response::Clone( |
| WithErrorSyntax_ResponseAsStruct_Response* _result) const { |
| zx_status_t _status = ::fidl::Clone(a, &_result->a); |
| if (_status != ZX_OK) return _status; |
| _status = ::fidl::Clone(b, &_result->b); |
| if (_status != ZX_OK) return _status; |
| _status = ::fidl::Clone(c, &_result->c); |
| if (_status != ZX_OK) return _status; |
| return ZX_OK; |
| } |
| |
| extern "C" const fidl_type_t |
| fidl_test_protocols_WithErrorSyntax_ResponseAsStruct_ResultTable; |
| const fidl_type_t* WithErrorSyntax_ResponseAsStruct_Result::FidlType = |
| &fidl_test_protocols_WithErrorSyntax_ResponseAsStruct_ResultTable; |
| |
| WithErrorSyntax_ResponseAsStruct_Result:: |
| WithErrorSyntax_ResponseAsStruct_Result() {} |
| |
| WithErrorSyntax_ResponseAsStruct_Result:: |
| ~WithErrorSyntax_ResponseAsStruct_Result() { |
| Destroy(); |
| } |
| |
| WithErrorSyntax_ResponseAsStruct_Result:: |
| WithErrorSyntax_ResponseAsStruct_Result( |
| WithErrorSyntax_ResponseAsStruct_Result&& other) |
| : tag_(other.tag_) { |
| switch (tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| kResponse: |
| new (&response_)::fidl::test::protocols:: |
| WithErrorSyntax_ResponseAsStruct_Response(); |
| response_ = std::move(other.response_); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| kErr: |
| err_ = std::move(other.err_); |
| break; |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| Invalid): |
| break; |
| } |
| } |
| |
| WithErrorSyntax_ResponseAsStruct_Result& |
| WithErrorSyntax_ResponseAsStruct_Result::operator=( |
| WithErrorSyntax_ResponseAsStruct_Result&& other) { |
| if (this != &other) { |
| Destroy(); |
| tag_ = other.tag_; |
| switch (tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result:: |
| Tag::kResponse: |
| new (&response_)::fidl::test::protocols:: |
| WithErrorSyntax_ResponseAsStruct_Response(); |
| response_ = std::move(other.response_); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result:: |
| Tag::kErr: |
| err_ = std::move(other.err_); |
| break; |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result:: |
| Tag::Invalid): |
| break; |
| } |
| } |
| return *this; |
| } |
| |
| WithErrorSyntax_ResponseAsStruct_Result |
| WithErrorSyntax_ResponseAsStruct_Result::WithResponse( |
| ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Response&& val) { |
| WithErrorSyntax_ResponseAsStruct_Result result; |
| result.set_response(std::move(val)); |
| return result; |
| } |
| WithErrorSyntax_ResponseAsStruct_Result |
| WithErrorSyntax_ResponseAsStruct_Result::WithErr(uint32_t&& val) { |
| WithErrorSyntax_ResponseAsStruct_Result result; |
| result.set_err(std::move(val)); |
| return result; |
| } |
| |
| void WithErrorSyntax_ResponseAsStruct_Result::Encode( |
| ::fidl::Encoder* encoder, size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| const size_t length_before = encoder->CurrentLength(); |
| const size_t handles_before = encoder->CurrentHandleCount(); |
| |
| size_t envelope_offset = 0; |
| |
| switch (Which()) { |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| kResponse: { |
| envelope_offset = |
| encoder->Alloc(::fidl::EncodingInlineSize< |
| ::fidl::test::protocols:: |
| WithErrorSyntax_ResponseAsStruct_Response, |
| ::fidl::Encoder>(encoder)); |
| ::fidl::Encode(encoder, &response_, envelope_offset); |
| break; |
| } |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| kErr: { |
| envelope_offset = encoder->Alloc( |
| ::fidl::EncodingInlineSize<uint32_t, ::fidl::Encoder>(encoder)); |
| ::fidl::Encode(encoder, &err_, envelope_offset); |
| break; |
| } |
| default: |
| break; |
| } |
| |
| fidl_xunion_t* xunion = encoder->GetPtr<fidl_xunion_t>(offset); |
| assert(xunion->envelope.presence == FIDL_ALLOC_ABSENT); |
| |
| if (envelope_offset) { |
| xunion->tag = tag_; |
| xunion->envelope.num_bytes = |
| static_cast<uint32_t>(encoder->CurrentLength() - length_before); |
| xunion->envelope.num_handles = |
| static_cast<uint32_t>(encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.presence = FIDL_ALLOC_PRESENT; |
| } |
| } |
| |
| void WithErrorSyntax_ResponseAsStruct_Result::Decode( |
| ::fidl::Decoder* decoder, WithErrorSyntax_ResponseAsStruct_Result* value, |
| size_t offset) { |
| fidl_xunion_t* xunion = decoder->GetPtr<fidl_xunion_t>(offset); |
| |
| if (!xunion->envelope.data) { |
| value->EnsureStorageInitialized(static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| Invalid)); |
| return; |
| } |
| |
| value->EnsureStorageInitialized(xunion->tag); |
| |
| const size_t envelope_offset = decoder->GetOffset(xunion->envelope.data); |
| |
| switch (value->tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| kResponse: |
| new (&value->response_)::fidl::test::protocols:: |
| WithErrorSyntax_ResponseAsStruct_Response(); |
| ::fidl::Decode(decoder, &value->response_, envelope_offset); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| kErr: |
| ::fidl::Decode(decoder, &value->err_, envelope_offset); |
| break; |
| default: |
| break; |
| } |
| } |
| |
| zx_status_t WithErrorSyntax_ResponseAsStruct_Result::Clone( |
| WithErrorSyntax_ResponseAsStruct_Result* result) const { |
| result->Destroy(); |
| result->tag_ = tag_; |
| switch (tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| Invalid: |
| return ZX_OK; |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| kResponse: |
| new (&result->response_)::fidl::test::protocols:: |
| WithErrorSyntax_ResponseAsStruct_Response(); |
| return ::fidl::Clone(response_, &result->response_); |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| kErr: |
| return ::fidl::Clone(err_, &result->err_); |
| default: |
| return ZX_OK; |
| } |
| } |
| |
| WithErrorSyntax_ResponseAsStruct_Result& |
| WithErrorSyntax_ResponseAsStruct_Result::set_response( |
| ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Response value) { |
| EnsureStorageInitialized( |
| ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| kResponse); |
| response_ = std::move(value); |
| return *this; |
| } |
| |
| WithErrorSyntax_ResponseAsStruct_Result& |
| WithErrorSyntax_ResponseAsStruct_Result::set_err(uint32_t value) { |
| EnsureStorageInitialized( |
| ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| kErr); |
| err_ = std::move(value); |
| return *this; |
| } |
| |
| void WithErrorSyntax_ResponseAsStruct_Result::Destroy() { |
| switch (tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| kResponse: |
| response_.~decltype(response_)(); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| kErr: |
| break; |
| |
| default: |
| break; |
| } |
| tag_ = static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result::Tag:: |
| Invalid); |
| } |
| |
| void WithErrorSyntax_ResponseAsStruct_Result::EnsureStorageInitialized( |
| ::fidl_xunion_tag_t tag) { |
| if (tag_ != tag) { |
| Destroy(); |
| tag_ = tag; |
| switch (tag_) { |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result:: |
| Tag::Invalid): |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result:: |
| Tag::kResponse: |
| new (&response_)::fidl::test::protocols:: |
| WithErrorSyntax_ResponseAsStruct_Response(); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ResponseAsStruct_Result:: |
| Tag::kErr: |
| new (&err_) uint32_t(); |
| break; |
| default: |
| break; |
| } |
| } |
| } |
| |
| extern "C" const fidl_type_t |
| fidl_test_protocols_WithErrorSyntax_ErrorAsPrimitive_ResponseTable; |
| const fidl_type_t* WithErrorSyntax_ErrorAsPrimitive_Response::FidlType = |
| &fidl_test_protocols_WithErrorSyntax_ErrorAsPrimitive_ResponseTable; |
| |
| void WithErrorSyntax_ErrorAsPrimitive_Response::Encode( |
| ::fidl::Encoder* _encoder, size_t _offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| if (::fidl::IsMemcpyCompatible< |
| WithErrorSyntax_ErrorAsPrimitive_Response>::value) { |
| memcpy(_encoder->template GetPtr<WithErrorSyntax_ErrorAsPrimitive_Response>( |
| _offset), |
| this, sizeof(WithErrorSyntax_ErrorAsPrimitive_Response)); |
| } else { |
| ::fidl::Encode(_encoder, &__reserved, _offset + 0); |
| } |
| } |
| |
| void WithErrorSyntax_ErrorAsPrimitive_Response::Decode( |
| ::fidl::Decoder* _decoder, |
| WithErrorSyntax_ErrorAsPrimitive_Response* _value, size_t _offset) { |
| if (::fidl::IsMemcpyCompatible< |
| WithErrorSyntax_ErrorAsPrimitive_Response>::value) { |
| memcpy(_value, |
| _decoder->template GetPtr<WithErrorSyntax_ErrorAsPrimitive_Response>( |
| _offset), |
| sizeof(WithErrorSyntax_ErrorAsPrimitive_Response)); |
| } else { |
| ::fidl::Decode(_decoder, &_value->__reserved, _offset + 0); |
| } |
| } |
| |
| zx_status_t WithErrorSyntax_ErrorAsPrimitive_Response::Clone( |
| WithErrorSyntax_ErrorAsPrimitive_Response* _result) const { |
| zx_status_t _status = ::fidl::Clone(__reserved, &_result->__reserved); |
| if (_status != ZX_OK) return _status; |
| return ZX_OK; |
| } |
| |
| extern "C" const fidl_type_t |
| fidl_test_protocols_WithErrorSyntax_ErrorAsPrimitive_ResultTable; |
| const fidl_type_t* WithErrorSyntax_ErrorAsPrimitive_Result::FidlType = |
| &fidl_test_protocols_WithErrorSyntax_ErrorAsPrimitive_ResultTable; |
| |
| WithErrorSyntax_ErrorAsPrimitive_Result:: |
| WithErrorSyntax_ErrorAsPrimitive_Result() {} |
| |
| WithErrorSyntax_ErrorAsPrimitive_Result:: |
| ~WithErrorSyntax_ErrorAsPrimitive_Result() { |
| Destroy(); |
| } |
| |
| WithErrorSyntax_ErrorAsPrimitive_Result:: |
| WithErrorSyntax_ErrorAsPrimitive_Result( |
| WithErrorSyntax_ErrorAsPrimitive_Result&& other) |
| : tag_(other.tag_) { |
| switch (tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| kResponse: |
| new (&response_)::fidl::test::protocols:: |
| WithErrorSyntax_ErrorAsPrimitive_Response(); |
| response_ = std::move(other.response_); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| kErr: |
| err_ = std::move(other.err_); |
| break; |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| Invalid): |
| break; |
| } |
| } |
| |
| WithErrorSyntax_ErrorAsPrimitive_Result& |
| WithErrorSyntax_ErrorAsPrimitive_Result::operator=( |
| WithErrorSyntax_ErrorAsPrimitive_Result&& other) { |
| if (this != &other) { |
| Destroy(); |
| tag_ = other.tag_; |
| switch (tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result:: |
| Tag::kResponse: |
| new (&response_)::fidl::test::protocols:: |
| WithErrorSyntax_ErrorAsPrimitive_Response(); |
| response_ = std::move(other.response_); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result:: |
| Tag::kErr: |
| err_ = std::move(other.err_); |
| break; |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result:: |
| Tag::Invalid): |
| break; |
| } |
| } |
| return *this; |
| } |
| |
| WithErrorSyntax_ErrorAsPrimitive_Result |
| WithErrorSyntax_ErrorAsPrimitive_Result::WithResponse( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Response&& val) { |
| WithErrorSyntax_ErrorAsPrimitive_Result result; |
| result.set_response(std::move(val)); |
| return result; |
| } |
| WithErrorSyntax_ErrorAsPrimitive_Result |
| WithErrorSyntax_ErrorAsPrimitive_Result::WithErr(uint32_t&& val) { |
| WithErrorSyntax_ErrorAsPrimitive_Result result; |
| result.set_err(std::move(val)); |
| return result; |
| } |
| |
| void WithErrorSyntax_ErrorAsPrimitive_Result::Encode( |
| ::fidl::Encoder* encoder, size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| const size_t length_before = encoder->CurrentLength(); |
| const size_t handles_before = encoder->CurrentHandleCount(); |
| |
| size_t envelope_offset = 0; |
| |
| switch (Which()) { |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| kResponse: { |
| envelope_offset = |
| encoder->Alloc(::fidl::EncodingInlineSize< |
| ::fidl::test::protocols:: |
| WithErrorSyntax_ErrorAsPrimitive_Response, |
| ::fidl::Encoder>(encoder)); |
| ::fidl::Encode(encoder, &response_, envelope_offset); |
| break; |
| } |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| kErr: { |
| envelope_offset = encoder->Alloc( |
| ::fidl::EncodingInlineSize<uint32_t, ::fidl::Encoder>(encoder)); |
| ::fidl::Encode(encoder, &err_, envelope_offset); |
| break; |
| } |
| default: |
| break; |
| } |
| |
| fidl_xunion_t* xunion = encoder->GetPtr<fidl_xunion_t>(offset); |
| assert(xunion->envelope.presence == FIDL_ALLOC_ABSENT); |
| |
| if (envelope_offset) { |
| xunion->tag = tag_; |
| xunion->envelope.num_bytes = |
| static_cast<uint32_t>(encoder->CurrentLength() - length_before); |
| xunion->envelope.num_handles = |
| static_cast<uint32_t>(encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.presence = FIDL_ALLOC_PRESENT; |
| } |
| } |
| |
| void WithErrorSyntax_ErrorAsPrimitive_Result::Decode( |
| ::fidl::Decoder* decoder, WithErrorSyntax_ErrorAsPrimitive_Result* value, |
| size_t offset) { |
| fidl_xunion_t* xunion = decoder->GetPtr<fidl_xunion_t>(offset); |
| |
| if (!xunion->envelope.data) { |
| value->EnsureStorageInitialized(static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| Invalid)); |
| return; |
| } |
| |
| value->EnsureStorageInitialized(xunion->tag); |
| |
| const size_t envelope_offset = decoder->GetOffset(xunion->envelope.data); |
| |
| switch (value->tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| kResponse: |
| new (&value->response_)::fidl::test::protocols:: |
| WithErrorSyntax_ErrorAsPrimitive_Response(); |
| ::fidl::Decode(decoder, &value->response_, envelope_offset); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| kErr: |
| ::fidl::Decode(decoder, &value->err_, envelope_offset); |
| break; |
| default: |
| break; |
| } |
| } |
| |
| zx_status_t WithErrorSyntax_ErrorAsPrimitive_Result::Clone( |
| WithErrorSyntax_ErrorAsPrimitive_Result* result) const { |
| result->Destroy(); |
| result->tag_ = tag_; |
| switch (tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| Invalid: |
| return ZX_OK; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| kResponse: |
| new (&result->response_)::fidl::test::protocols:: |
| WithErrorSyntax_ErrorAsPrimitive_Response(); |
| return ::fidl::Clone(response_, &result->response_); |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| kErr: |
| return ::fidl::Clone(err_, &result->err_); |
| default: |
| return ZX_OK; |
| } |
| } |
| |
| WithErrorSyntax_ErrorAsPrimitive_Result& |
| WithErrorSyntax_ErrorAsPrimitive_Result::set_response( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Response value) { |
| EnsureStorageInitialized( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| kResponse); |
| response_ = std::move(value); |
| return *this; |
| } |
| |
| WithErrorSyntax_ErrorAsPrimitive_Result& |
| WithErrorSyntax_ErrorAsPrimitive_Result::set_err(uint32_t value) { |
| EnsureStorageInitialized( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| kErr); |
| err_ = std::move(value); |
| return *this; |
| } |
| |
| void WithErrorSyntax_ErrorAsPrimitive_Result::Destroy() { |
| switch (tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| kResponse: |
| response_.~decltype(response_)(); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| kErr: |
| break; |
| |
| default: |
| break; |
| } |
| tag_ = static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result::Tag:: |
| Invalid); |
| } |
| |
| void WithErrorSyntax_ErrorAsPrimitive_Result::EnsureStorageInitialized( |
| ::fidl_xunion_tag_t tag) { |
| if (tag_ != tag) { |
| Destroy(); |
| tag_ = tag; |
| switch (tag_) { |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result:: |
| Tag::Invalid): |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result:: |
| Tag::kResponse: |
| new (&response_)::fidl::test::protocols:: |
| WithErrorSyntax_ErrorAsPrimitive_Response(); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsPrimitive_Result:: |
| Tag::kErr: |
| new (&err_) uint32_t(); |
| break; |
| default: |
| break; |
| } |
| } |
| } |
| |
| extern "C" const fidl_type_t |
| fidl_test_protocols_WithErrorSyntax_ErrorAsEnum_ResponseTable; |
| const fidl_type_t* WithErrorSyntax_ErrorAsEnum_Response::FidlType = |
| &fidl_test_protocols_WithErrorSyntax_ErrorAsEnum_ResponseTable; |
| |
| void WithErrorSyntax_ErrorAsEnum_Response::Encode( |
| ::fidl::Encoder* _encoder, size_t _offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| if (::fidl::IsMemcpyCompatible<WithErrorSyntax_ErrorAsEnum_Response>::value) { |
| memcpy(_encoder->template GetPtr<WithErrorSyntax_ErrorAsEnum_Response>( |
| _offset), |
| this, sizeof(WithErrorSyntax_ErrorAsEnum_Response)); |
| } else { |
| ::fidl::Encode(_encoder, &__reserved, _offset + 0); |
| } |
| } |
| |
| void WithErrorSyntax_ErrorAsEnum_Response::Decode( |
| ::fidl::Decoder* _decoder, WithErrorSyntax_ErrorAsEnum_Response* _value, |
| size_t _offset) { |
| if (::fidl::IsMemcpyCompatible<WithErrorSyntax_ErrorAsEnum_Response>::value) { |
| memcpy(_value, |
| _decoder->template GetPtr<WithErrorSyntax_ErrorAsEnum_Response>( |
| _offset), |
| sizeof(WithErrorSyntax_ErrorAsEnum_Response)); |
| } else { |
| ::fidl::Decode(_decoder, &_value->__reserved, _offset + 0); |
| } |
| } |
| |
| zx_status_t WithErrorSyntax_ErrorAsEnum_Response::Clone( |
| WithErrorSyntax_ErrorAsEnum_Response* _result) const { |
| zx_status_t _status = ::fidl::Clone(__reserved, &_result->__reserved); |
| if (_status != ZX_OK) return _status; |
| return ZX_OK; |
| } |
| |
| extern "C" const fidl_type_t |
| fidl_test_protocols_WithErrorSyntax_ErrorAsEnum_ResultTable; |
| const fidl_type_t* WithErrorSyntax_ErrorAsEnum_Result::FidlType = |
| &fidl_test_protocols_WithErrorSyntax_ErrorAsEnum_ResultTable; |
| |
| WithErrorSyntax_ErrorAsEnum_Result::WithErrorSyntax_ErrorAsEnum_Result() {} |
| |
| WithErrorSyntax_ErrorAsEnum_Result::~WithErrorSyntax_ErrorAsEnum_Result() { |
| Destroy(); |
| } |
| |
| WithErrorSyntax_ErrorAsEnum_Result::WithErrorSyntax_ErrorAsEnum_Result( |
| WithErrorSyntax_ErrorAsEnum_Result&& other) |
| : tag_(other.tag_) { |
| switch (tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| kResponse: |
| new (&response_)::fidl::test::protocols:: |
| WithErrorSyntax_ErrorAsEnum_Response(); |
| response_ = std::move(other.response_); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag::kErr: |
| new (&err_)::fidl::test::protocols::ErrorEnun(); |
| err_ = std::move(other.err_); |
| break; |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| Invalid): |
| break; |
| } |
| } |
| |
| WithErrorSyntax_ErrorAsEnum_Result& |
| WithErrorSyntax_ErrorAsEnum_Result::operator=( |
| WithErrorSyntax_ErrorAsEnum_Result&& other) { |
| if (this != &other) { |
| Destroy(); |
| tag_ = other.tag_; |
| switch (tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| kResponse: |
| new (&response_)::fidl::test::protocols:: |
| WithErrorSyntax_ErrorAsEnum_Response(); |
| response_ = std::move(other.response_); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| kErr: |
| new (&err_)::fidl::test::protocols::ErrorEnun(); |
| err_ = std::move(other.err_); |
| break; |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| Invalid): |
| break; |
| } |
| } |
| return *this; |
| } |
| |
| WithErrorSyntax_ErrorAsEnum_Result |
| WithErrorSyntax_ErrorAsEnum_Result::WithResponse( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Response&& val) { |
| WithErrorSyntax_ErrorAsEnum_Result result; |
| result.set_response(std::move(val)); |
| return result; |
| } |
| WithErrorSyntax_ErrorAsEnum_Result WithErrorSyntax_ErrorAsEnum_Result::WithErr( |
| ::fidl::test::protocols::ErrorEnun&& val) { |
| WithErrorSyntax_ErrorAsEnum_Result result; |
| result.set_err(std::move(val)); |
| return result; |
| } |
| |
| void WithErrorSyntax_ErrorAsEnum_Result::Encode( |
| ::fidl::Encoder* encoder, size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| const size_t length_before = encoder->CurrentLength(); |
| const size_t handles_before = encoder->CurrentHandleCount(); |
| |
| size_t envelope_offset = 0; |
| |
| switch (Which()) { |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| kResponse: { |
| envelope_offset = encoder->Alloc( |
| ::fidl::EncodingInlineSize< |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Response, |
| ::fidl::Encoder>(encoder)); |
| ::fidl::Encode(encoder, &response_, envelope_offset); |
| break; |
| } |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| kErr: { |
| envelope_offset = encoder->Alloc( |
| ::fidl::EncodingInlineSize<::fidl::test::protocols::ErrorEnun, |
| ::fidl::Encoder>(encoder)); |
| ::fidl::Encode(encoder, &err_, envelope_offset); |
| break; |
| } |
| default: |
| break; |
| } |
| |
| fidl_xunion_t* xunion = encoder->GetPtr<fidl_xunion_t>(offset); |
| assert(xunion->envelope.presence == FIDL_ALLOC_ABSENT); |
| |
| if (envelope_offset) { |
| xunion->tag = tag_; |
| xunion->envelope.num_bytes = |
| static_cast<uint32_t>(encoder->CurrentLength() - length_before); |
| xunion->envelope.num_handles = |
| static_cast<uint32_t>(encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.presence = FIDL_ALLOC_PRESENT; |
| } |
| } |
| |
| void WithErrorSyntax_ErrorAsEnum_Result::Decode( |
| ::fidl::Decoder* decoder, WithErrorSyntax_ErrorAsEnum_Result* value, |
| size_t offset) { |
| fidl_xunion_t* xunion = decoder->GetPtr<fidl_xunion_t>(offset); |
| |
| if (!xunion->envelope.data) { |
| value->EnsureStorageInitialized(static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| Invalid)); |
| return; |
| } |
| |
| value->EnsureStorageInitialized(xunion->tag); |
| |
| const size_t envelope_offset = decoder->GetOffset(xunion->envelope.data); |
| |
| switch (value->tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| kResponse: |
| new (&value->response_)::fidl::test::protocols:: |
| WithErrorSyntax_ErrorAsEnum_Response(); |
| ::fidl::Decode(decoder, &value->response_, envelope_offset); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag::kErr: |
| new (&value->err_)::fidl::test::protocols::ErrorEnun(); |
| ::fidl::Decode(decoder, &value->err_, envelope_offset); |
| break; |
| default: |
| break; |
| } |
| } |
| |
| zx_status_t WithErrorSyntax_ErrorAsEnum_Result::Clone( |
| WithErrorSyntax_ErrorAsEnum_Result* result) const { |
| result->Destroy(); |
| result->tag_ = tag_; |
| switch (tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| Invalid: |
| return ZX_OK; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| kResponse: |
| new (&result->response_)::fidl::test::protocols:: |
| WithErrorSyntax_ErrorAsEnum_Response(); |
| return ::fidl::Clone(response_, &result->response_); |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag::kErr: |
| new (&result->err_)::fidl::test::protocols::ErrorEnun(); |
| return ::fidl::Clone(err_, &result->err_); |
| default: |
| return ZX_OK; |
| } |
| } |
| |
| WithErrorSyntax_ErrorAsEnum_Result& |
| WithErrorSyntax_ErrorAsEnum_Result::set_response( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Response value) { |
| EnsureStorageInitialized( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| kResponse); |
| response_ = std::move(value); |
| return *this; |
| } |
| |
| WithErrorSyntax_ErrorAsEnum_Result& WithErrorSyntax_ErrorAsEnum_Result::set_err( |
| ::fidl::test::protocols::ErrorEnun value) { |
| EnsureStorageInitialized( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag::kErr); |
| err_ = std::move(value); |
| return *this; |
| } |
| |
| void WithErrorSyntax_ErrorAsEnum_Result::Destroy() { |
| switch (tag_) { |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| kResponse: |
| response_.~decltype(response_)(); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag::kErr: |
| err_.~decltype(err_)(); |
| break; |
| |
| default: |
| break; |
| } |
| tag_ = static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| Invalid); |
| } |
| |
| void WithErrorSyntax_ErrorAsEnum_Result::EnsureStorageInitialized( |
| ::fidl_xunion_tag_t tag) { |
| if (tag_ != tag) { |
| Destroy(); |
| tag_ = tag; |
| switch (tag_) { |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| Invalid): |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| kResponse: |
| new (&response_)::fidl::test::protocols:: |
| WithErrorSyntax_ErrorAsEnum_Response(); |
| break; |
| case ::fidl::test::protocols::WithErrorSyntax_ErrorAsEnum_Result::Tag:: |
| kErr: |
| new (&err_)::fidl::test::protocols::ErrorEnun(); |
| break; |
| default: |
| break; |
| } |
| } |
| } |
| |
| } // namespace protocols |
| } // namespace test |
| } // namespace fidl |