| // camera/mojo/camera_metadata.mojom-shared.cc is auto generated by mojom_bindings_generator.py, do not edit |
| |
| // Copyright 2016 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "camera/mojo/camera_metadata.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 "camera/mojo/camera_metadata.mojom-params-data.h" |
| namespace cros { |
| namespace mojom { |
| |
| NOINLINE static const char* EntryTypeToStringHelper(EntryType value) { |
| // Defined in a helper function to ensure that Clang generates a lookup table. |
| switch(value) { |
| case EntryType::TYPE_BYTE: |
| return "TYPE_BYTE"; |
| case EntryType::TYPE_INT32: |
| return "TYPE_INT32"; |
| case EntryType::TYPE_FLOAT: |
| return "TYPE_FLOAT"; |
| case EntryType::TYPE_INT64: |
| return "TYPE_INT64"; |
| case EntryType::TYPE_DOUBLE: |
| return "TYPE_DOUBLE"; |
| case EntryType::TYPE_RATIONAL: |
| return "TYPE_RATIONAL"; |
| case EntryType::NUM_TYPES: |
| return "NUM_TYPES"; |
| default: |
| return nullptr; |
| } |
| } |
| |
| std::string EntryTypeToString(EntryType value) { |
| const char *str = EntryTypeToStringHelper(value); |
| if (!str) { |
| return base::StringPrintf("Unknown EntryType value: %i", static_cast<int32_t>(value)); |
| } |
| return str; |
| } |
| |
| std::ostream& operator<<(std::ostream& os, EntryType value) { |
| return os << EntryTypeToString(value); |
| } |
| |
| namespace internal { |
| |
| |
| // static |
| bool CameraMetadataEntry_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 32, 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 CameraMetadataEntry_Data* object = |
| static_cast<const CameraMetadataEntry_Data*>(data); |
| |
| |
| if (!::cros::mojom::internal::CameraMetadataTag_Data |
| ::Validate(object->tag, validation_context)) |
| return false; |
| |
| |
| if (!::cros::mojom::internal::EntryType_Data |
| ::Validate(object->type, validation_context)) |
| return false; |
| |
| if (!mojo::internal::ValidatePointerNonNullable( |
| object->data, 5, validation_context)) { |
| return false; |
| } |
| constexpr const mojo::internal::ContainerValidateParams& data_validate_params = |
| mojo::internal::GetArrayValidator<0, false, nullptr>(); |
| if (!mojo::internal::ValidateContainer(object->data, validation_context, |
| &data_validate_params)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| CameraMetadataEntry_Data::CameraMetadataEntry_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| |
| // static |
| bool CameraMetadata_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 40, 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 CameraMetadata_Data* object = |
| static_cast<const CameraMetadata_Data*>(data); |
| |
| constexpr const mojo::internal::ContainerValidateParams& entries_validate_params = |
| mojo::internal::GetArrayValidator<0, false, nullptr>(); |
| if (!mojo::internal::ValidateContainer(object->entries, validation_context, |
| &entries_validate_params)) { |
| return false; |
| } |
| |
| return true; |
| } |
| |
| CameraMetadata_Data::CameraMetadata_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| } // namespace internal |
| } // namespace mojom |
| } // namespace cros |
| |
| namespace perfetto { |
| |
| // static |
| void TraceFormatTraits<::cros::mojom::EntryType>::WriteIntoTrace( |
| perfetto::TracedValue context, ::cros::mojom::EntryType value) { |
| return std::move(context).WriteString(::cros::mojom::EntryTypeToString(value)); |
| } |
| |
| } // namespace perfetto |