blob: 95495aa3bae09f4c42ce2959ecf8d32cdc6d6105 [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
// fidl_experiment = output_index_json
#include <test/time/cpp/fidl.h>
#include "lib/fidl/cpp/internal/implementation.h"
//
// Domain objects definitions
//
namespace test {
namespace time {
extern "C" const fidl_type_t test_time_AllInstantsTable;
const fidl_type_t* AllInstants::FidlType = &test_time_AllInstantsTable;
void AllInstants::Encode(::fidl::Encoder* _encoder, size_t _offset,
std::optional<::fidl::HandleInformation> maybe_handle_info) {
if (::fidl::IsMemcpyCompatible<AllInstants>::value) {
memcpy(_encoder->template GetPtr<AllInstants>(_offset), this, sizeof(AllInstants));
} else {
::fidl::Encode(_encoder, &monotonic, _offset + 0);
::fidl::Encode(_encoder, &boot, _offset + 8);
::fidl::Encode(_encoder, &monotonic_ticks, _offset + 16);
::fidl::Encode(_encoder, &boot_ticks, _offset + 24);
}
}
void AllInstants::Decode(::fidl::Decoder* _decoder, AllInstants* _value, size_t _offset) {
if (::fidl::IsMemcpyCompatible<AllInstants>::value) {
memcpy(_value, _decoder->template GetPtr<AllInstants>(_offset), sizeof(AllInstants));
} else {
::fidl::Decode(_decoder, &_value->monotonic, _offset + 0);
::fidl::Decode(_decoder, &_value->boot, _offset + 8);
::fidl::Decode(_decoder, &_value->monotonic_ticks, _offset + 16);
::fidl::Decode(_decoder, &_value->boot_ticks, _offset + 24);
}
}
zx_status_t AllInstants::Clone(AllInstants* _result) const {
zx_status_t _status = ::fidl::Clone(monotonic, &_result->monotonic);
if (_status != ZX_OK)
return _status;
_status = ::fidl::Clone(boot, &_result->boot);
if (_status != ZX_OK)
return _status;
_status = ::fidl::Clone(monotonic_ticks, &_result->monotonic_ticks);
if (_status != ZX_OK)
return _status;
_status = ::fidl::Clone(boot_ticks, &_result->boot_ticks);
if (_status != ZX_OK)
return _status;
return ZX_OK;
}
extern "C" const fidl_type_t test_time_ComplexInstantsTable;
const fidl_type_t* ComplexInstants::FidlType = &test_time_ComplexInstantsTable;
ComplexInstants::ComplexInstants() {}
ComplexInstants::ComplexInstants(ComplexInstants&& other) {
field_presence_ = other.field_presence_;
if (field_presence_.IsSet<0>()) {
Construct(&monotonic_value_.value, std::move(other.monotonic_value_.value));
}
if (field_presence_.IsSet<1>()) {
Construct(&boot_value_.value, std::move(other.boot_value_.value));
}
if (field_presence_.IsSet<2>()) {
Construct(&monotonic_ticks_value_.value, std::move(other.monotonic_ticks_value_.value));
}
if (field_presence_.IsSet<3>()) {
Construct(&boot_ticks_value_.value, std::move(other.boot_ticks_value_.value));
}
}
ComplexInstants::~ComplexInstants() {
if (field_presence_.IsSet<0>()) {
Destruct(&monotonic_value_.value);
}
if (field_presence_.IsSet<1>()) {
Destruct(&boot_value_.value);
}
if (field_presence_.IsSet<2>()) {
Destruct(&monotonic_ticks_value_.value);
}
if (field_presence_.IsSet<3>()) {
Destruct(&boot_ticks_value_.value);
}
}
ComplexInstants& ComplexInstants::operator=(ComplexInstants&& other) {
if (other.field_presence_.IsSet<0>()) {
if (field_presence_.IsSet<0>()) {
monotonic_value_.value = std::move(other.monotonic_value_.value);
} else {
field_presence_.Set<0>();
Construct(&monotonic_value_.value, std::move(other.monotonic_value_.value));
}
} else if (field_presence_.IsSet<0>()) {
field_presence_.Clear<0>();
Destruct(&monotonic_value_.value);
}
if (other.field_presence_.IsSet<1>()) {
if (field_presence_.IsSet<1>()) {
boot_value_.value = std::move(other.boot_value_.value);
} else {
field_presence_.Set<1>();
Construct(&boot_value_.value, std::move(other.boot_value_.value));
}
} else if (field_presence_.IsSet<1>()) {
field_presence_.Clear<1>();
Destruct(&boot_value_.value);
}
if (other.field_presence_.IsSet<2>()) {
if (field_presence_.IsSet<2>()) {
monotonic_ticks_value_.value = std::move(other.monotonic_ticks_value_.value);
} else {
field_presence_.Set<2>();
Construct(&monotonic_ticks_value_.value, std::move(other.monotonic_ticks_value_.value));
}
} else if (field_presence_.IsSet<2>()) {
field_presence_.Clear<2>();
Destruct(&monotonic_ticks_value_.value);
}
if (other.field_presence_.IsSet<3>()) {
if (field_presence_.IsSet<3>()) {
boot_ticks_value_.value = std::move(other.boot_ticks_value_.value);
} else {
field_presence_.Set<3>();
Construct(&boot_ticks_value_.value, std::move(other.boot_ticks_value_.value));
}
} else if (field_presence_.IsSet<3>()) {
field_presence_.Clear<3>();
Destruct(&boot_ticks_value_.value);
}
return *this;
}
bool ComplexInstants::IsEmpty() const {
return field_presence_.IsEmpty();
}
ComplexInstants& ComplexInstants::set_monotonic(::std::array<::fidl::basic_time<ZX_CLOCK_MONOTONIC>, 10> _value) {
if (!field_presence_.IsSet<0>()) {
field_presence_.Set<0>();
Construct(&monotonic_value_.value, std::move(_value));
} else {
monotonic_value_.value = std::move(_value);
}
return *this;
}
ComplexInstants& ComplexInstants::set_boot(::std::vector<::fidl::basic_time<ZX_CLOCK_BOOT>> _value) {
if (!field_presence_.IsSet<1>()) {
field_presence_.Set<1>();
Construct(&boot_value_.value, std::move(_value));
} else {
boot_value_.value = std::move(_value);
}
return *this;
}
ComplexInstants& ComplexInstants::set_monotonic_ticks(::std::array<::fidl::basic_ticks<ZX_CLOCK_MONOTONIC>, 10> _value) {
if (!field_presence_.IsSet<2>()) {
field_presence_.Set<2>();
Construct(&monotonic_ticks_value_.value, std::move(_value));
} else {
monotonic_ticks_value_.value = std::move(_value);
}
return *this;
}
ComplexInstants& ComplexInstants::set_boot_ticks(::std::array<::fidl::basic_ticks<ZX_CLOCK_BOOT>, 10> _value) {
if (!field_presence_.IsSet<3>()) {
field_presence_.Set<3>();
Construct(&boot_ticks_value_.value, std::move(_value));
} else {
boot_ticks_value_.value = std::move(_value);
}
return *this;
}
void ComplexInstants::Encode(::fidl::Encoder* _encoder, size_t _offset,
std::optional<::fidl::HandleInformation> maybe_handle_info) {
size_t max_ordinal = MaxOrdinal();
::fidl::EncodeVectorPointer(_encoder, max_ordinal, _offset);
if (max_ordinal == 0) return;
[[maybe_unused]] size_t base = _encoder->Alloc(max_ordinal * sizeof(fidl_envelope_t));
if (field_presence_.IsSet<0>()) {
const size_t length_before = _encoder->CurrentLength();
const size_t handles_before = _encoder->CurrentHandleCount();
size_t envelope_base = base + (1 - 1) * sizeof(fidl_envelope_t);
if (::fidl::EncodingInlineSize<::std::array<::fidl::basic_time<ZX_CLOCK_MONOTONIC>, 10>>(_encoder) <= FIDL_ENVELOPE_INLINING_SIZE_THRESHOLD) {
::fidl::Encode(_encoder, &monotonic_value_.value, envelope_base);
fidl_envelope_t* envelope = _encoder->GetPtr<fidl_envelope_t>(envelope_base);
envelope->num_handles = static_cast<uint16_t>(_encoder->CurrentHandleCount() - handles_before);
envelope->flags = FIDL_ENVELOPE_FLAGS_INLINING_MASK;
} else {
::fidl::Encode(
_encoder,
&monotonic_value_.value,
_encoder->Alloc(::fidl::EncodingInlineSize<::std::array<::fidl::basic_time<ZX_CLOCK_MONOTONIC>, 10>, ::fidl::Encoder>(_encoder)));
fidl_envelope_t* envelope = _encoder->GetPtr<fidl_envelope_t>(envelope_base);
envelope->num_bytes = static_cast<uint32_t>(_encoder->CurrentLength() - length_before);
envelope->num_handles = static_cast<uint16_t>(_encoder->CurrentHandleCount() - handles_before);
envelope->flags = 0;
}
}
if (field_presence_.IsSet<1>()) {
const size_t length_before = _encoder->CurrentLength();
const size_t handles_before = _encoder->CurrentHandleCount();
size_t envelope_base = base + (2 - 1) * sizeof(fidl_envelope_t);
if (::fidl::EncodingInlineSize<::std::vector<::fidl::basic_time<ZX_CLOCK_BOOT>>>(_encoder) <= FIDL_ENVELOPE_INLINING_SIZE_THRESHOLD) {
::fidl::Encode(_encoder, &boot_value_.value, envelope_base);
fidl_envelope_t* envelope = _encoder->GetPtr<fidl_envelope_t>(envelope_base);
envelope->num_handles = static_cast<uint16_t>(_encoder->CurrentHandleCount() - handles_before);
envelope->flags = FIDL_ENVELOPE_FLAGS_INLINING_MASK;
} else {
::fidl::Encode(
_encoder,
&boot_value_.value,
_encoder->Alloc(::fidl::EncodingInlineSize<::std::vector<::fidl::basic_time<ZX_CLOCK_BOOT>>, ::fidl::Encoder>(_encoder)));
fidl_envelope_t* envelope = _encoder->GetPtr<fidl_envelope_t>(envelope_base);
envelope->num_bytes = static_cast<uint32_t>(_encoder->CurrentLength() - length_before);
envelope->num_handles = static_cast<uint16_t>(_encoder->CurrentHandleCount() - handles_before);
envelope->flags = 0;
}
}
if (field_presence_.IsSet<2>()) {
const size_t length_before = _encoder->CurrentLength();
const size_t handles_before = _encoder->CurrentHandleCount();
size_t envelope_base = base + (3 - 1) * sizeof(fidl_envelope_t);
if (::fidl::EncodingInlineSize<::std::array<::fidl::basic_ticks<ZX_CLOCK_MONOTONIC>, 10>>(_encoder) <= FIDL_ENVELOPE_INLINING_SIZE_THRESHOLD) {
::fidl::Encode(_encoder, &monotonic_ticks_value_.value, envelope_base);
fidl_envelope_t* envelope = _encoder->GetPtr<fidl_envelope_t>(envelope_base);
envelope->num_handles = static_cast<uint16_t>(_encoder->CurrentHandleCount() - handles_before);
envelope->flags = FIDL_ENVELOPE_FLAGS_INLINING_MASK;
} else {
::fidl::Encode(
_encoder,
&monotonic_ticks_value_.value,
_encoder->Alloc(::fidl::EncodingInlineSize<::std::array<::fidl::basic_ticks<ZX_CLOCK_MONOTONIC>, 10>, ::fidl::Encoder>(_encoder)));
fidl_envelope_t* envelope = _encoder->GetPtr<fidl_envelope_t>(envelope_base);
envelope->num_bytes = static_cast<uint32_t>(_encoder->CurrentLength() - length_before);
envelope->num_handles = static_cast<uint16_t>(_encoder->CurrentHandleCount() - handles_before);
envelope->flags = 0;
}
}
if (field_presence_.IsSet<3>()) {
const size_t length_before = _encoder->CurrentLength();
const size_t handles_before = _encoder->CurrentHandleCount();
size_t envelope_base = base + (4 - 1) * sizeof(fidl_envelope_t);
if (::fidl::EncodingInlineSize<::std::array<::fidl::basic_ticks<ZX_CLOCK_BOOT>, 10>>(_encoder) <= FIDL_ENVELOPE_INLINING_SIZE_THRESHOLD) {
::fidl::Encode(_encoder, &boot_ticks_value_.value, envelope_base);
fidl_envelope_t* envelope = _encoder->GetPtr<fidl_envelope_t>(envelope_base);
envelope->num_handles = static_cast<uint16_t>(_encoder->CurrentHandleCount() - handles_before);
envelope->flags = FIDL_ENVELOPE_FLAGS_INLINING_MASK;
} else {
::fidl::Encode(
_encoder,
&boot_ticks_value_.value,
_encoder->Alloc(::fidl::EncodingInlineSize<::std::array<::fidl::basic_ticks<ZX_CLOCK_BOOT>, 10>, ::fidl::Encoder>(_encoder)));
fidl_envelope_t* envelope = _encoder->GetPtr<fidl_envelope_t>(envelope_base);
envelope->num_bytes = static_cast<uint32_t>(_encoder->CurrentLength() - length_before);
envelope->num_handles = static_cast<uint16_t>(_encoder->CurrentHandleCount() - handles_before);
envelope->flags = 0;
}
}
}
void ComplexInstants::Decode(::fidl::Decoder* _decoder, ComplexInstants* _value, size_t _offset) {
fidl_vector_t* encoded = _decoder->GetPtr<fidl_vector_t>(_offset);
[[maybe_unused]] size_t base;
[[maybe_unused]] size_t count;
if (!encoded->data) {
goto clear_all;
}
base = _decoder->GetOffset(encoded->data);
count = encoded->count;
if (count >= 1) {
size_t envelope_base = base + (1 - 1) * sizeof(fidl_envelope_t);
fidl_envelope_t* envelope = _decoder->GetPtr<fidl_envelope_t>(envelope_base);
if (*reinterpret_cast<const void* const*>(envelope) != nullptr) {
::fidl::Decode(_decoder, _value->mutable_monotonic(),
_decoder->EnvelopeValueOffset(envelope));
} else {
_value->clear_monotonic();
}
} else {
goto done_1;
}
if (count >= 2) {
size_t envelope_base = base + (2 - 1) * sizeof(fidl_envelope_t);
fidl_envelope_t* envelope = _decoder->GetPtr<fidl_envelope_t>(envelope_base);
if (*reinterpret_cast<const void* const*>(envelope) != nullptr) {
::fidl::Decode(_decoder, _value->mutable_boot(),
_decoder->EnvelopeValueOffset(envelope));
} else {
_value->clear_boot();
}
} else {
goto done_2;
}
if (count >= 3) {
size_t envelope_base = base + (3 - 1) * sizeof(fidl_envelope_t);
fidl_envelope_t* envelope = _decoder->GetPtr<fidl_envelope_t>(envelope_base);
if (*reinterpret_cast<const void* const*>(envelope) != nullptr) {
::fidl::Decode(_decoder, _value->mutable_monotonic_ticks(),
_decoder->EnvelopeValueOffset(envelope));
} else {
_value->clear_monotonic_ticks();
}
} else {
goto done_3;
}
if (count >= 4) {
size_t envelope_base = base + (4 - 1) * sizeof(fidl_envelope_t);
fidl_envelope_t* envelope = _decoder->GetPtr<fidl_envelope_t>(envelope_base);
if (*reinterpret_cast<const void* const*>(envelope) != nullptr) {
::fidl::Decode(_decoder, _value->mutable_boot_ticks(),
_decoder->EnvelopeValueOffset(envelope));
} else {
_value->clear_boot_ticks();
}
} else {
goto done_4;
}
return;
// Clear unset values.
clear_all:
done_1:
_value->clear_monotonic();
done_2:
_value->clear_boot();
done_3:
_value->clear_monotonic_ticks();
done_4:
_value->clear_boot_ticks();
return;
}
zx_status_t ComplexInstants::Clone(ComplexInstants* result) const {
if (field_presence_.IsSet<0>()) {
zx_status_t _status = ::fidl::Clone(monotonic_value_.value, result->mutable_monotonic());
if (_status != ZX_OK)
return _status;
} else {
result->clear_monotonic();
}
if (field_presence_.IsSet<1>()) {
zx_status_t _status = ::fidl::Clone(boot_value_.value, result->mutable_boot());
if (_status != ZX_OK)
return _status;
} else {
result->clear_boot();
}
if (field_presence_.IsSet<2>()) {
zx_status_t _status = ::fidl::Clone(monotonic_ticks_value_.value, result->mutable_monotonic_ticks());
if (_status != ZX_OK)
return _status;
} else {
result->clear_monotonic_ticks();
}
if (field_presence_.IsSet<3>()) {
zx_status_t _status = ::fidl::Clone(boot_ticks_value_.value, result->mutable_boot_ticks());
if (_status != ZX_OK)
return _status;
} else {
result->clear_boot_ticks();
}
return ZX_OK;
}
//
// Proxies and stubs definitions
//
} // namespace time
} // namespace test