blob: 041f9ed0d3982f1f325186ad940522553946166b [file] [log] [blame]
// chromeos/services/machine_learning/public/mojom/graph_executor.mojom-shared.cc is auto generated by mojom_bindings_generator.py, do not edit
// Copyright 2016 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.
#include "chromeos/services/machine_learning/public/mojom/graph_executor.mojom-shared.h"
// Used to support stream output operator for enums.
// TODO(dcheng): Consider omitting this somehow if not needed.
#include <ostream>
#include <utility>
#include "base/strings/stringprintf.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/lib/validation_util.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"
#include "chromeos/services/machine_learning/public/mojom/graph_executor.mojom-params-data.h"
namespace chromeos {
namespace machine_learning {
namespace mojom {
static NOINLINE const char* ExecuteResultToStringHelper(ExecuteResult value) {
// Defined in a helper function to ensure that Clang generates a lookup table.
switch(value) {
case ExecuteResult::OK:
return "OK";
case ExecuteResult::INPUT_MISSING_ERROR:
return "INPUT_MISSING_ERROR";
case ExecuteResult::UNKNOWN_INPUT_ERROR:
return "UNKNOWN_INPUT_ERROR";
case ExecuteResult::INPUT_TYPE_ERROR:
return "INPUT_TYPE_ERROR";
case ExecuteResult::INPUT_SHAPE_ERROR:
return "INPUT_SHAPE_ERROR";
case ExecuteResult::INPUT_FORMAT_ERROR:
return "INPUT_FORMAT_ERROR";
case ExecuteResult::OUTPUT_MISSING_ERROR:
return "OUTPUT_MISSING_ERROR";
case ExecuteResult::UNKNOWN_OUTPUT_ERROR:
return "UNKNOWN_OUTPUT_ERROR";
case ExecuteResult::DUPLICATE_OUTPUT_ERROR:
return "DUPLICATE_OUTPUT_ERROR";
case ExecuteResult::EXECUTION_ERROR:
return "EXECUTION_ERROR";
default:
return nullptr;
}
}
std::string ExecuteResultToString(ExecuteResult value) {
const char *str = ExecuteResultToStringHelper(value);
if (!str) {
return base::StringPrintf("Unknown ExecuteResult value: %i", static_cast<int32_t>(value));
}
return str;
}
std::ostream& operator<<(std::ostream& os, ExecuteResult value) {
return os << ExecuteResultToString(value);
}
namespace internal {
// static
bool GraphExecutor_Execute_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
data, 24, validation_context)) {
return false;
}
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
[[maybe_unused]] const GraphExecutor_Execute_Params_Data* object =
static_cast<const GraphExecutor_Execute_Params_Data*>(data);
if (!mojo::internal::ValidatePointerNonNullable(
object->inputs, 1, validation_context)) {
return false;
}
const mojo::internal::ContainerValidateParams inputs_validate_params(
new mojo::internal::ContainerValidateParams(0, false, new mojo::internal::ContainerValidateParams(0, false, nullptr)), new mojo::internal::ContainerValidateParams(0, false, nullptr));
if (!mojo::internal::ValidateContainer(object->inputs, validation_context,
&inputs_validate_params)) {
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->output_names, 2, validation_context)) {
return false;
}
const mojo::internal::ContainerValidateParams output_names_validate_params(
0, false, new mojo::internal::ContainerValidateParams(0, false, nullptr));
if (!mojo::internal::ValidateContainer(object->output_names, validation_context,
&output_names_validate_params)) {
return false;
}
return true;
}
GraphExecutor_Execute_Params_Data::GraphExecutor_Execute_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool GraphExecutor_Execute_ResponseParams_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
data, 24, validation_context)) {
return false;
}
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
// the message comes from an older version.
[[maybe_unused]] const GraphExecutor_Execute_ResponseParams_Data* object =
static_cast<const GraphExecutor_Execute_ResponseParams_Data*>(data);
if (!::chromeos::machine_learning::mojom::internal::ExecuteResult_Data
::Validate(object->result, validation_context))
return false;
const mojo::internal::ContainerValidateParams outputs_validate_params(
0, false, nullptr);
if (!mojo::internal::ValidateContainer(object->outputs, validation_context,
&outputs_validate_params)) {
return false;
}
return true;
}
GraphExecutor_Execute_ResponseParams_Data::GraphExecutor_Execute_ResponseParams_Data()
: header_({sizeof(*this), 0}) {}
} // namespace internal
} // namespace mojom
} // namespace machine_learning
} // namespace chromeos
namespace perfetto {
// static
void TraceFormatTraits<::chromeos::machine_learning::mojom::ExecuteResult>::WriteIntoTrace(
perfetto::TracedValue context, ::chromeos::machine_learning::mojom::ExecuteResult value) {
return std::move(context).WriteString(::chromeos::machine_learning::mojom::ExecuteResultToString(value));
}
} // namespace perfetto