blob: 26885b94cc1fa42a653dd52c95bacdd4a3d70be9 [file] [log] [blame]
// mojo/public/interfaces/bindings/tests/sample_import.mojom-shared.h 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.
#ifndef MOJO_PUBLIC_INTERFACES_BINDINGS_TESTS_SAMPLE_IMPORT_MOJOM_SHARED_H_
#define MOJO_PUBLIC_INTERFACES_BINDINGS_TESTS_SAMPLE_IMPORT_MOJOM_SHARED_H_
#include <stdint.h>
#include <functional>
#include <iosfwd>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/array_data_view.h"
#include "mojo/public/cpp/bindings/enum_traits.h"
#include "mojo/public/cpp/bindings/interface_data_view.h"
#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/map_data_view.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"
#include "mojo/public/interfaces/bindings/tests/sample_import.mojom-shared-internal.h"
#include "mojo/public/cpp/bindings/lib/interface_serialization.h"
#include "mojo/public/cpp/system/data_pipe.h"
#ifdef KYTHE_IS_RUNNING
#pragma kythe_inline_metadata "Metadata comment"
#endif
namespace imported {
class PointDataView;
class PointOrShapeDataView;
} // imported
namespace mojo {
namespace internal {
template <>
struct MojomTypeTraits<::imported::PointDataView> {
using Data = ::imported::internal::Point_Data;
using DataAsArrayElement = Pointer<Data>;
static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};
template <>
struct MojomTypeTraits<::imported::PointOrShapeDataView> {
using Data = ::imported::internal::PointOrShape_Data;
using DataAsArrayElement = Data;
static constexpr MojomTypeCategory category = MojomTypeCategory::kUnion;
};
} // namespace internal
} // namespace mojo
namespace imported {
// @generated_from: imported.Shape
enum class Shape : int32_t {
// @generated_from: imported.Shape.RECTANGLE
RECTANGLE = 1,
// @generated_from: imported.Shape.CIRCLE
CIRCLE = 2,
// @generated_from: imported.Shape.TRIANGLE
TRIANGLE = 3,
// @generated_from: imported.Shape.LAST
LAST = 3,
kMinValue = 1,
kMaxValue = 3,
};
std::ostream& operator<<(std::ostream& os, Shape value);
inline bool IsKnownEnumValue(Shape value) {
return internal::Shape_Data::IsKnownValue(
static_cast<int32_t>(value));
}
// @generated_from: imported.AnotherShape
enum class AnotherShape : int32_t {
// @generated_from: imported.AnotherShape.RECTANGLE
RECTANGLE = 10,
// @generated_from: imported.AnotherShape.CIRCLE
CIRCLE = 11,
// @generated_from: imported.AnotherShape.TRIANGLE
TRIANGLE = 12,
kMinValue = 10,
kMaxValue = 12,
};
std::ostream& operator<<(std::ostream& os, AnotherShape value);
inline bool IsKnownEnumValue(AnotherShape value) {
return internal::AnotherShape_Data::IsKnownValue(
static_cast<int32_t>(value));
}
// @generated_from: imported.YetAnotherShape
enum class YetAnotherShape : int32_t {
// @generated_from: imported.YetAnotherShape.RECTANGLE
RECTANGLE = 20,
// @generated_from: imported.YetAnotherShape.CIRCLE
CIRCLE = 21,
// @generated_from: imported.YetAnotherShape.TRIANGLE
TRIANGLE = 22,
kMinValue = 20,
kMaxValue = 22,
};
std::ostream& operator<<(std::ostream& os, YetAnotherShape value);
inline bool IsKnownEnumValue(YetAnotherShape value) {
return internal::YetAnotherShape_Data::IsKnownValue(
static_cast<int32_t>(value));
}
// Interface base classes. They are used for type safety check.
class ImportedInterfaceInterfaceBase {};
using ImportedInterfacePtrDataView =
mojo::InterfacePtrDataView<ImportedInterfaceInterfaceBase>;
using ImportedInterfaceRequestDataView =
mojo::InterfaceRequestDataView<ImportedInterfaceInterfaceBase>;
using ImportedInterfaceAssociatedPtrInfoDataView =
mojo::AssociatedInterfacePtrInfoDataView<ImportedInterfaceInterfaceBase>;
using ImportedInterfaceAssociatedRequestDataView =
mojo::AssociatedInterfaceRequestDataView<ImportedInterfaceInterfaceBase>;
class PointDataView {
public:
PointDataView() = default;
PointDataView(
internal::Point_Data* data,
mojo::Message* message)
: data_(data) {}
bool is_null() const { return !data_; }
int32_t x() const {
return data_->x;
}
int32_t y() const {
return data_->y;
}
private:
internal::Point_Data* data_ = nullptr;
};
class PointOrShapeDataView {
public:
using Tag = internal::PointOrShape_Data::PointOrShape_Tag;
PointOrShapeDataView() = default;
PointOrShapeDataView(
internal::PointOrShape_Data* data,
mojo::Message* message)
: data_(data), message_(message) {}
bool is_null() const {
// For inlined unions, |data_| is always non-null. In that case we need to
// check |data_->is_null()|.
return !data_ || data_->is_null();
}
Tag tag() const { return data_->tag; }
bool is_point() const { return data_->tag == Tag::kPoint; }
inline void GetPointDataView(
PointDataView* output) const;
template <typename UserType>
[[nodiscard]] bool ReadPoint(UserType* output) const {
CHECK(is_point());
return mojo::internal::Deserialize<::imported::PointDataView>(
data_->data.f_point.Get(), output, message_);
}
bool is_shape() const { return data_->tag == Tag::kShape; }
template <typename UserType>
[[nodiscard]] bool ReadShape(UserType* output) const {
CHECK(is_shape());
return mojo::internal::Deserialize<::imported::Shape>(
data_->data.f_shape, output);
}
Shape shape() const {
CHECK(is_shape());
// TODO(dcheng): This seems incorrect, as it bypasses enum traits.
return ::mojo::internal::ToKnownEnumValueHelper(
static_cast<::imported::Shape>(data_->data.f_shape));
}
private:
internal::PointOrShape_Data* data_ = nullptr;
mojo::Message* message_ = nullptr;
};
} // imported
namespace std {
template <>
struct hash<::imported::Shape>
: public mojo::internal::EnumHashImpl<::imported::Shape> {};
template <>
struct hash<::imported::AnotherShape>
: public mojo::internal::EnumHashImpl<::imported::AnotherShape> {};
template <>
struct hash<::imported::YetAnotherShape>
: public mojo::internal::EnumHashImpl<::imported::YetAnotherShape> {};
} // namespace std
namespace mojo {
namespace internal {
template <typename MaybeConstUserType>
struct Serializer<::imported::Shape, MaybeConstUserType> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Traits = EnumTraits<::imported::Shape, UserType>;
static void Serialize(UserType input, int32_t* output) {
*output = static_cast<int32_t>(Traits::ToMojom(input));
}
static bool Deserialize(int32_t input, UserType* output) {
return Traits::FromMojom(::mojo::internal::ToKnownEnumValueHelper(
static_cast<::imported::Shape>(input)), output);
}
};
} // namespace internal
namespace internal {
template <typename MaybeConstUserType>
struct Serializer<::imported::AnotherShape, MaybeConstUserType> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Traits = EnumTraits<::imported::AnotherShape, UserType>;
static void Serialize(UserType input, int32_t* output) {
*output = static_cast<int32_t>(Traits::ToMojom(input));
}
static bool Deserialize(int32_t input, UserType* output) {
return Traits::FromMojom(::mojo::internal::ToKnownEnumValueHelper(
static_cast<::imported::AnotherShape>(input)), output);
}
};
} // namespace internal
namespace internal {
template <typename MaybeConstUserType>
struct Serializer<::imported::YetAnotherShape, MaybeConstUserType> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Traits = EnumTraits<::imported::YetAnotherShape, UserType>;
static void Serialize(UserType input, int32_t* output) {
*output = static_cast<int32_t>(Traits::ToMojom(input));
}
static bool Deserialize(int32_t input, UserType* output) {
return Traits::FromMojom(::mojo::internal::ToKnownEnumValueHelper(
static_cast<::imported::YetAnotherShape>(input)), output);
}
};
} // namespace internal
namespace internal {
template <typename MaybeConstUserType>
struct Serializer<::imported::PointDataView, MaybeConstUserType> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Traits = StructTraits<::imported::PointDataView, UserType>;
static void Serialize(
MaybeConstUserType& input,
mojo::internal::MessageFragment<::imported::internal::Point_Data>& fragment) {
if (CallIsNullIfExists<Traits>(input))
return;
fragment.Allocate();
fragment->x = Traits::x(input);
fragment->y = Traits::y(input);
}
static bool Deserialize(::imported::internal::Point_Data* input,
UserType* output,
Message* message) {
if (!input)
return CallSetToNullIfExists<Traits>(output);
::imported::PointDataView data_view(input, message);
return Traits::Read(data_view, output);
}
};
} // namespace internal
namespace internal {
template <typename MaybeConstUserType>
struct Serializer<::imported::PointOrShapeDataView, MaybeConstUserType> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Traits = UnionTraits<::imported::PointOrShapeDataView, UserType>;
static void Serialize(MaybeConstUserType& input,
MessageFragment<::imported::internal::PointOrShape_Data>& fragment,
bool inlined) {
if (CallIsNullIfExists<Traits>(input)) {
if (inlined)
fragment->set_null();
return;
}
if (!inlined)
fragment.Allocate();
// TODO(azani): Handle unknown and objects.
// Set the not-null flag.
fragment->size = kUnionDataSize;
fragment->tag = Traits::GetTag(input);
switch (fragment->tag) {
case ::imported::PointOrShapeDataView::Tag::kPoint: {
decltype(Traits::point(input))
in_point = Traits::point(input);
mojo::internal::MessageFragment<
typename decltype(fragment->data.f_point)::BaseType>
value_fragment(fragment.message());
mojo::internal::Serialize<::imported::PointDataView>(
in_point, value_fragment);
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
value_fragment.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null point in PointOrShape union");
fragment->data.f_point.Set(
value_fragment.is_null() ? nullptr : value_fragment.data());
break;
}
case ::imported::PointOrShapeDataView::Tag::kShape: {
decltype(Traits::shape(input))
in_shape = Traits::shape(input);
mojo::internal::Serialize<::imported::Shape>(
in_shape, &fragment->data.f_shape);
break;
}
}
}
static bool Deserialize(::imported::internal::PointOrShape_Data* input,
UserType* output,
Message* message) {
if (!input || input->is_null())
return CallSetToNullIfExists<Traits>(output);
::imported::PointOrShapeDataView data_view(input, message);
return Traits::Read(data_view, output);
}
};
} // namespace internal
} // namespace mojo
namespace imported {
inline void PointOrShapeDataView::GetPointDataView(
PointDataView* output) const {
CHECK(is_point());
*output = PointDataView(data_->data.f_point.Get(), message_);
}
} // imported
// Declare TraceFormatTraits for enums, which should be defined in ::perfetto
// namespace.
namespace perfetto {
template <>
struct TraceFormatTraits<::imported::Shape> {
static void WriteIntoTrace(perfetto::TracedValue context, ::imported::Shape value);
};
} // namespace perfetto
namespace perfetto {
template <>
struct TraceFormatTraits<::imported::AnotherShape> {
static void WriteIntoTrace(perfetto::TracedValue context, ::imported::AnotherShape value);
};
} // namespace perfetto
namespace perfetto {
template <>
struct TraceFormatTraits<::imported::YetAnotherShape> {
static void WriteIntoTrace(perfetto::TracedValue context, ::imported::YetAnotherShape value);
};
} // namespace perfetto
#endif // MOJO_PUBLIC_INTERFACES_BINDINGS_TESTS_SAMPLE_IMPORT_MOJOM_SHARED_H_
/* Metadata comment
eyJ0eXBlIjogImt5dGhlMCIsICJtZXRhIjogW3sidHlwZSI6ICJhbmNob3JfZGVmaW5lcyIsICJi
ZWdpbiI6IDIwMDcsICJlbmQiOiAyMDEyLCAidm5hbWUiOiB7Imxhbmd1YWdlIjogIm1vam9tIiwg
ImNvcnB1cyI6ICJjaHJvbWl1bS5nb29nbGVzb3VyY2UuY29tL2NvZGVzZWFyY2gvY2hyb21pdW0v
c3JjLy9tYWluIiwgInNpZ25hdHVyZSI6ICJpbXBvcnRlZC5TaGFwZSJ9LCAiZWRnZSI6ICIlL2t5
dGhlL2VkZ2UvZ2VuZXJhdGVzIn0sIHsidHlwZSI6ICJhbmNob3JfZGVmaW5lcyIsICJiZWdpbiI6
IDIwNzUsICJlbmQiOiAyMDg0LCAidm5hbWUiOiB7Imxhbmd1YWdlIjogIm1vam9tIiwgImNvcnB1
cyI6ICJjaHJvbWl1bS5nb29nbGVzb3VyY2UuY29tL2NvZGVzZWFyY2gvY2hyb21pdW0vc3JjLy9t
YWluIiwgInNpZ25hdHVyZSI6ICJpbXBvcnRlZC5TaGFwZS5SRUNUQU5HTEUifSwgImVkZ2UiOiAi
JS9reXRoZS9lZGdlL2dlbmVyYXRlcyJ9LCB7InR5cGUiOiAiYW5jaG9yX2RlZmluZXMiLCAiYmVn
aW4iOiAyMTM3LCAiZW5kIjogMjE0MywgInZuYW1lIjogeyJsYW5ndWFnZSI6ICJtb2pvbSIsICJj
b3JwdXMiOiAiY2hyb21pdW0uZ29vZ2xlc291cmNlLmNvbS9jb2Rlc2VhcmNoL2Nocm9taXVtL3Ny
Yy8vbWFpbiIsICJzaWduYXR1c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