blob: 90988725c7a1a53670d28bcc015d49ecfb97698e [file] [log] [blame]
// chromeos/services/machine_learning/public/mojom/tensor.mojom.cc is auto generated by mojom_bindings_generator.py, do not edit
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif
#include "chromeos/services/machine_learning/public/mojom/tensor.mojom.h"
#include <math.h>
#include <stdint.h>
#include <utility>
#include "base/debug/alias.h"
#include "base/hash/md5_constexpr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/typed_macros.h"
#include "mojo/public/cpp/bindings/lib/generated_code_util.h"
#include "mojo/public/cpp/bindings/lib/message_internal.h"
#include "mojo/public/cpp/bindings/lib/send_message_helper.h"
#include "mojo/public/cpp/bindings/lib/proxy_to_responder.h"
#include "mojo/public/cpp/bindings/lib/serialization_util.h"
#include "mojo/public/cpp/bindings/lib/unserialized_message_context.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"
#include "chromeos/services/machine_learning/public/mojom/tensor.mojom-params-data.h"
#include "chromeos/services/machine_learning/public/mojom/tensor.mojom-shared-message-ids.h"
#include "chromeos/services/machine_learning/public/mojom/tensor.mojom-import-headers.h"
#include "chromeos/services/machine_learning/public/mojom/tensor.mojom-test-utils.h"
#ifndef CHROMEOS_SERVICES_MACHINE_LEARNING_PUBLIC_MOJOM_TENSOR_MOJOM_JUMBO_H_
#define CHROMEOS_SERVICES_MACHINE_LEARNING_PUBLIC_MOJOM_TENSOR_MOJOM_JUMBO_H_
#endif
namespace chromeos {
namespace machine_learning {
namespace mojom {
StringList::StringList()
: value() {}
StringList::StringList(
std::vector<std::string> value_in)
: value(std::move(value_in)) {}
StringList::~StringList() = default;
void StringList::WriteIntoTrace(
perfetto::TracedValue traced_context) const {
[[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem(
"value"), this->value,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
"<value of type const std::vector<std::string>&>"
#else
"<value>"
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
);
}
bool StringList::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
return Data_::Validate(data, validation_context);
}
FloatList::FloatList()
: value() {}
FloatList::FloatList(
std::vector<double> value_in)
: value(std::move(value_in)) {}
FloatList::~FloatList() = default;
void FloatList::WriteIntoTrace(
perfetto::TracedValue traced_context) const {
[[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem(
"value"), this->value,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
"<value of type const std::vector<double>&>"
#else
"<value>"
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
);
}
bool FloatList::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
return Data_::Validate(data, validation_context);
}
Int64List::Int64List()
: value() {}
Int64List::Int64List(
std::vector<int64_t> value_in)
: value(std::move(value_in)) {}
Int64List::~Int64List() = default;
void Int64List::WriteIntoTrace(
perfetto::TracedValue traced_context) const {
[[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem(
"value"), this->value,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
"<value of type const std::vector<int64_t>&>"
#else
"<value>"
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
);
}
bool Int64List::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
return Data_::Validate(data, validation_context);
}
Tensor::Tensor()
: data(),
shape() {}
Tensor::Tensor(
ValueListPtr data_in,
Int64ListPtr shape_in)
: data(std::move(data_in)),
shape(std::move(shape_in)) {}
Tensor::~Tensor() = default;
void Tensor::WriteIntoTrace(
perfetto::TracedValue traced_context) const {
[[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem(
"data"), this->data,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
"<value of type ValueListPtr>"
#else
"<value>"
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
);
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem(
"shape"), this->shape,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
"<value of type Int64ListPtr>"
#else
"<value>"
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
);
}
bool Tensor::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
return Data_::Validate(data, validation_context);
}
ValueList::ValueList() : tag_(Tag::kStringList) {
data_.string_list = new StringListPtr;
}
ValueList::~ValueList() {
DestroyActive();
}
void ValueList::set_string_list(
StringListPtr string_list) {
if (tag_ == Tag::kStringList) {
*(data_.string_list) = std::move(string_list);
} else {
DestroyActive();
tag_ = Tag::kStringList;
data_.string_list = new StringListPtr(
std::move(string_list));
}
}
void ValueList::set_float_list(
FloatListPtr float_list) {
if (tag_ == Tag::kFloatList) {
*(data_.float_list) = std::move(float_list);
} else {
DestroyActive();
tag_ = Tag::kFloatList;
data_.float_list = new FloatListPtr(
std::move(float_list));
}
}
void ValueList::set_int64_list(
Int64ListPtr int64_list) {
if (tag_ == Tag::kInt64List) {
*(data_.int64_list) = std::move(int64_list);
} else {
DestroyActive();
tag_ = Tag::kInt64List;
data_.int64_list = new Int64ListPtr(
std::move(int64_list));
}
}
void ValueList::DestroyActive() {
switch (tag_) {
case Tag::kStringList:
delete data_.string_list;
break;
case Tag::kFloatList:
delete data_.float_list;
break;
case Tag::kInt64List:
delete data_.int64_list;
break;
}
}
bool ValueList::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
return Data_::Validate(data, validation_context, false);
}
} // namespace mojom
} // namespace machine_learning
} // namespace chromeos
namespace mojo {
// static
bool StructTraits<::chromeos::machine_learning::mojom::StringList::DataView, ::chromeos::machine_learning::mojom::StringListPtr>::Read(
::chromeos::machine_learning::mojom::StringList::DataView input,
::chromeos::machine_learning::mojom::StringListPtr* output) {
bool success = true;
::chromeos::machine_learning::mojom::StringListPtr result(::chromeos::machine_learning::mojom::StringList::New());
if (success && !input.ReadValue(&result->value))
success = false;
*output = std::move(result);
return success;
}
// static
bool StructTraits<::chromeos::machine_learning::mojom::FloatList::DataView, ::chromeos::machine_learning::mojom::FloatListPtr>::Read(
::chromeos::machine_learning::mojom::FloatList::DataView input,
::chromeos::machine_learning::mojom::FloatListPtr* output) {
bool success = true;
::chromeos::machine_learning::mojom::FloatListPtr result(::chromeos::machine_learning::mojom::FloatList::New());
if (success && !input.ReadValue(&result->value))
success = false;
*output = std::move(result);
return success;
}
// static
bool StructTraits<::chromeos::machine_learning::mojom::Int64List::DataView, ::chromeos::machine_learning::mojom::Int64ListPtr>::Read(
::chromeos::machine_learning::mojom::Int64List::DataView input,
::chromeos::machine_learning::mojom::Int64ListPtr* output) {
bool success = true;
::chromeos::machine_learning::mojom::Int64ListPtr result(::chromeos::machine_learning::mojom::Int64List::New());
if (success && !input.ReadValue(&result->value))
success = false;
*output = std::move(result);
return success;
}
// static
bool StructTraits<::chromeos::machine_learning::mojom::Tensor::DataView, ::chromeos::machine_learning::mojom::TensorPtr>::Read(
::chromeos::machine_learning::mojom::Tensor::DataView input,
::chromeos::machine_learning::mojom::TensorPtr* output) {
bool success = true;
::chromeos::machine_learning::mojom::TensorPtr result(::chromeos::machine_learning::mojom::Tensor::New());
if (success && !input.ReadData(&result->data))
success = false;
if (success && !input.ReadShape(&result->shape))
success = false;
*output = std::move(result);
return success;
}
// static
bool UnionTraits<::chromeos::machine_learning::mojom::ValueList::DataView, ::chromeos::machine_learning::mojom::ValueListPtr>::Read(
::chromeos::machine_learning::mojom::ValueList::DataView input,
::chromeos::machine_learning::mojom::ValueListPtr* output) {
using UnionType = ::chromeos::machine_learning::mojom::ValueList;
using Tag = UnionType::Tag;
switch (input.tag()) {
case Tag::kStringList: {
::chromeos::machine_learning::mojom::StringListPtr result_string_list;
if (!input.ReadStringList(&result_string_list))
return false;
*output = UnionType::NewStringList(
std::move(result_string_list));
break;
}
case Tag::kFloatList: {
::chromeos::machine_learning::mojom::FloatListPtr result_float_list;
if (!input.ReadFloatList(&result_float_list))
return false;
*output = UnionType::NewFloatList(
std::move(result_float_list));
break;
}
case Tag::kInt64List: {
::chromeos::machine_learning::mojom::Int64ListPtr result_int64_list;
if (!input.ReadInt64List(&result_int64_list))
return false;
*output = UnionType::NewInt64List(
std::move(result_int64_list));
break;
}
default:
return false;
}
return true;
}
} // namespace mojo
// Symbols declared in the -test-utils.h header are defined here instead of a
// separate .cc file to save compile time.
namespace chromeos {
namespace machine_learning {
namespace mojom {
} // namespace mojom
} // namespace machine_learning
} // namespace chromeos
#if defined(__clang__)
#pragma clang diagnostic pop
#endif