Commit 591304dc authored by James Cook's avatar James Cook Committed by Commit Bot

mojo: Convert enum MojomTypeCategory to kCamelCase style

This avoids collisions with Microsoft Windows headers that define
macros like INTERFACE and HANDLE.

Bug: none
Test: compiles
Change-Id: I9f27a6d3dfb945acd3a0f9a5d9b0710a589da909
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1738339
Auto-Submit: James Cook <jamescook@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#684503}
parent 62330e7f
......@@ -22,7 +22,7 @@ template <typename T>
class ArrayDataViewImpl<
T,
typename std::enable_if<
BelongsTo<T, MojomTypeCategory::POD>::value>::type> {
BelongsTo<T, MojomTypeCategory::kPOD>::value>::type> {
public:
using Data_ = typename MojomTypeTraits<ArrayDataView<T>>::Data;
......@@ -42,7 +42,7 @@ template <typename T>
class ArrayDataViewImpl<
T,
typename std::enable_if<
BelongsTo<T, MojomTypeCategory::BOOLEAN>::value>::type> {
BelongsTo<T, MojomTypeCategory::kBoolean>::value>::type> {
public:
using Data_ = typename MojomTypeTraits<ArrayDataView<T>>::Data;
......@@ -60,7 +60,7 @@ template <typename T>
class ArrayDataViewImpl<
T,
typename std::enable_if<
BelongsTo<T, MojomTypeCategory::ENUM>::value>::type> {
BelongsTo<T, MojomTypeCategory::kEnum>::value>::type> {
public:
static_assert(sizeof(T) == sizeof(int32_t), "Unexpected enum size");
......@@ -88,10 +88,10 @@ class ArrayDataViewImpl<
T,
typename std::enable_if<
BelongsTo<T,
MojomTypeCategory::ASSOCIATED_INTERFACE |
MojomTypeCategory::ASSOCIATED_INTERFACE_REQUEST |
MojomTypeCategory::INTERFACE |
MojomTypeCategory::INTERFACE_REQUEST>::value>::type> {
MojomTypeCategory::kAssociatedInterface |
MojomTypeCategory::kAssociatedInterfaceRequest |
MojomTypeCategory::kInterface |
MojomTypeCategory::kInterfaceRequest>::value>::type> {
public:
using Data_ = typename MojomTypeTraits<ArrayDataView<T>>::Data;
......@@ -115,7 +115,7 @@ template <typename T>
class ArrayDataViewImpl<
T,
typename std::enable_if<
BelongsTo<T, MojomTypeCategory::HANDLE>::value>::type> {
BelongsTo<T, MojomTypeCategory::kHandle>::value>::type> {
public:
using Data_ = typename MojomTypeTraits<ArrayDataView<T>>::Data;
......@@ -135,12 +135,13 @@ class ArrayDataViewImpl<
};
template <typename T>
class ArrayDataViewImpl<T,
typename std::enable_if<BelongsTo<
T,
MojomTypeCategory::ARRAY | MojomTypeCategory::MAP |
MojomTypeCategory::STRING |
MojomTypeCategory::STRUCT>::value>::type> {
class ArrayDataViewImpl<
T,
typename std::enable_if<
BelongsTo<T,
MojomTypeCategory::kArray | MojomTypeCategory::kMap |
MojomTypeCategory::kString |
MojomTypeCategory::kStruct>::value>::type> {
public:
using Data_ = typename MojomTypeTraits<ArrayDataView<T>>::Data;
......@@ -165,7 +166,7 @@ template <typename T>
class ArrayDataViewImpl<
T,
typename std::enable_if<
BelongsTo<T, MojomTypeCategory::UNION>::value>::type> {
BelongsTo<T, MojomTypeCategory::kUnion>::value>::type> {
public:
using Data_ = typename MojomTypeTraits<ArrayDataView<T>>::Data;
......
......@@ -106,7 +106,7 @@ struct ArraySerializer<
MaybeConstUserType,
UserTypeIterator,
typename std::enable_if<BelongsTo<typename MojomType::Element,
MojomTypeCategory::POD>::value>::type> {
MojomTypeCategory::kPOD>::value>::type> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Data = typename MojomTypeTraits<MojomType>::Data;
using DataElement = typename Data::Element;
......@@ -174,7 +174,7 @@ struct ArraySerializer<
MaybeConstUserType,
UserTypeIterator,
typename std::enable_if<BelongsTo<typename MojomType::Element,
MojomTypeCategory::ENUM>::value>::type> {
MojomTypeCategory::kEnum>::value>::type> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Data = typename MojomTypeTraits<MojomType>::Data;
using DataElement = typename Data::Element;
......@@ -224,7 +224,7 @@ struct ArraySerializer<MojomType,
UserTypeIterator,
typename std::enable_if<BelongsTo<
typename MojomType::Element,
MojomTypeCategory::BOOLEAN>::value>::type> {
MojomTypeCategory::kBoolean>::value>::type> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Traits = ArrayTraits<UserType>;
using Data = typename MojomTypeTraits<MojomType>::Data;
......@@ -268,12 +268,12 @@ struct ArraySerializer<
MojomType,
MaybeConstUserType,
UserTypeIterator,
typename std::enable_if<
BelongsTo<typename MojomType::Element,
MojomTypeCategory::ASSOCIATED_INTERFACE |
MojomTypeCategory::ASSOCIATED_INTERFACE_REQUEST |
MojomTypeCategory::HANDLE | MojomTypeCategory::INTERFACE |
MojomTypeCategory::INTERFACE_REQUEST>::value>::type> {
typename std::enable_if<BelongsTo<
typename MojomType::Element,
MojomTypeCategory::kAssociatedInterface |
MojomTypeCategory::kAssociatedInterfaceRequest |
MojomTypeCategory::kHandle | MojomTypeCategory::kInterface |
MojomTypeCategory::kInterfaceRequest>::value>::type> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Data = typename MojomTypeTraits<MojomType>::Data;
using Element = typename MojomType::Element;
......@@ -296,8 +296,8 @@ struct ArraySerializer<
static const ValidationError kError =
BelongsTo<Element,
MojomTypeCategory::ASSOCIATED_INTERFACE |
MojomTypeCategory::ASSOCIATED_INTERFACE_REQUEST>::value
MojomTypeCategory::kAssociatedInterface |
MojomTypeCategory::kAssociatedInterfaceRequest>::value
? VALIDATION_ERROR_UNEXPECTED_INVALID_INTERFACE_ID
: VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE;
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
......@@ -334,9 +334,9 @@ struct ArraySerializer<MojomType,
UserTypeIterator,
typename std::enable_if<BelongsTo<
typename MojomType::Element,
MojomTypeCategory::ARRAY | MojomTypeCategory::MAP |
MojomTypeCategory::STRING |
MojomTypeCategory::STRUCT>::value>::type> {
MojomTypeCategory::kArray | MojomTypeCategory::kMap |
MojomTypeCategory::kString |
MojomTypeCategory::kStruct>::value>::type> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Data = typename MojomTypeTraits<MojomType>::Data;
using Element = typename MojomType::Element;
......@@ -382,9 +382,9 @@ struct ArraySerializer<MojomType,
private:
template <typename T,
bool is_array_or_map = BelongsTo<T,
MojomTypeCategory::ARRAY |
MojomTypeCategory::MAP>::value>
bool is_array_or_map = BelongsTo<
T,
MojomTypeCategory::kArray | MojomTypeCategory::kMap>::value>
struct SerializeCaller {
template <typename InputElementType>
static void Run(InputElementType&& input,
......@@ -414,12 +414,12 @@ struct ArraySerializer<MojomType,
template <typename MojomType,
typename MaybeConstUserType,
typename UserTypeIterator>
struct ArraySerializer<
MojomType,
MaybeConstUserType,
UserTypeIterator,
typename std::enable_if<BelongsTo<typename MojomType::Element,
MojomTypeCategory::UNION>::value>::type> {
struct ArraySerializer<MojomType,
MaybeConstUserType,
UserTypeIterator,
typename std::enable_if<
BelongsTo<typename MojomType::Element,
MojomTypeCategory::kUnion>::value>::type> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Data = typename MojomTypeTraits<MojomType>::Data;
using Element = typename MojomType::Element;
......
......@@ -183,20 +183,20 @@ struct IsUnionDataType {
};
enum class MojomTypeCategory : uint32_t {
ARRAY = 1 << 0,
ASSOCIATED_INTERFACE = 1 << 1,
ASSOCIATED_INTERFACE_REQUEST = 1 << 2,
BOOLEAN = 1 << 3,
ENUM = 1 << 4,
HANDLE = 1 << 5,
INTERFACE = 1 << 6,
INTERFACE_REQUEST = 1 << 7,
MAP = 1 << 8,
kArray = 1 << 0,
kAssociatedInterface = 1 << 1,
kAssociatedInterfaceRequest = 1 << 2,
kBoolean = 1 << 3,
kEnum = 1 << 4,
kHandle = 1 << 5,
kInterface = 1 << 6,
kInterfaceRequest = 1 << 7,
kMap = 1 << 8,
// POD except boolean and enum.
POD = 1 << 9,
STRING = 1 << 10,
STRUCT = 1 << 11,
UNION = 1 << 12
kPOD = 1 << 9,
kString = 1 << 10,
kStruct = 1 << 11,
kUnion = 1 << 12
};
inline constexpr MojomTypeCategory operator&(MojomTypeCategory x,
......@@ -216,7 +216,7 @@ struct MojomTypeTraits {
using Data = T;
using DataAsArrayElement = Data;
static const MojomTypeCategory category = MojomTypeCategory::POD;
static const MojomTypeCategory category = MojomTypeCategory::kPOD;
};
template <typename T>
......@@ -224,7 +224,7 @@ struct MojomTypeTraits<ArrayDataView<T>, false> {
using Data = Array_Data<typename MojomTypeTraits<T>::DataAsArrayElement>;
using DataAsArrayElement = Pointer<Data>;
static const MojomTypeCategory category = MojomTypeCategory::ARRAY;
static const MojomTypeCategory category = MojomTypeCategory::kArray;
};
template <typename T>
......@@ -233,7 +233,7 @@ struct MojomTypeTraits<AssociatedInterfacePtrInfoDataView<T>, false> {
using DataAsArrayElement = Data;
static const MojomTypeCategory category =
MojomTypeCategory::ASSOCIATED_INTERFACE;
MojomTypeCategory::kAssociatedInterface;
};
template <typename T>
......@@ -242,7 +242,7 @@ struct MojomTypeTraits<AssociatedInterfaceRequestDataView<T>, false> {
using DataAsArrayElement = Data;
static const MojomTypeCategory category =
MojomTypeCategory::ASSOCIATED_INTERFACE_REQUEST;
MojomTypeCategory::kAssociatedInterfaceRequest;
};
template <>
......@@ -250,7 +250,7 @@ struct MojomTypeTraits<bool, false> {
using Data = bool;
using DataAsArrayElement = Data;
static const MojomTypeCategory category = MojomTypeCategory::BOOLEAN;
static const MojomTypeCategory category = MojomTypeCategory::kBoolean;
};
template <typename T>
......@@ -258,7 +258,7 @@ struct MojomTypeTraits<T, true> {
using Data = int32_t;
using DataAsArrayElement = Data;
static const MojomTypeCategory category = MojomTypeCategory::ENUM;
static const MojomTypeCategory category = MojomTypeCategory::kEnum;
};
template <typename T>
......@@ -266,7 +266,7 @@ struct MojomTypeTraits<ScopedHandleBase<T>, false> {
using Data = Handle_Data;
using DataAsArrayElement = Data;
static const MojomTypeCategory category = MojomTypeCategory::HANDLE;
static const MojomTypeCategory category = MojomTypeCategory::kHandle;
};
template <typename T>
......@@ -274,7 +274,7 @@ struct MojomTypeTraits<InterfacePtrDataView<T>, false> {
using Data = Interface_Data;
using DataAsArrayElement = Data;
static const MojomTypeCategory category = MojomTypeCategory::INTERFACE;
static const MojomTypeCategory category = MojomTypeCategory::kInterface;
};
template <typename T>
......@@ -283,7 +283,7 @@ struct MojomTypeTraits<InterfaceRequestDataView<T>, false> {
using DataAsArrayElement = Data;
static const MojomTypeCategory category =
MojomTypeCategory::INTERFACE_REQUEST;
MojomTypeCategory::kInterfaceRequest;
};
template <typename K, typename V>
......@@ -292,7 +292,7 @@ struct MojomTypeTraits<MapDataView<K, V>, false> {
typename MojomTypeTraits<V>::DataAsArrayElement>;
using DataAsArrayElement = Pointer<Data>;
static const MojomTypeCategory category = MojomTypeCategory::MAP;
static const MojomTypeCategory category = MojomTypeCategory::kMap;
};
template <>
......@@ -300,7 +300,7 @@ struct MojomTypeTraits<StringDataView, false> {
using Data = String_Data;
using DataAsArrayElement = Pointer<Data>;
static const MojomTypeCategory category = MojomTypeCategory::STRING;
static const MojomTypeCategory category = MojomTypeCategory::kString;
};
template <typename T, MojomTypeCategory categories>
......
......@@ -35,7 +35,7 @@ template <typename MojomType>
struct MojomSerializationImplTraits<
MojomType,
typename std::enable_if<
BelongsTo<MojomType, MojomTypeCategory::STRUCT>::value>::type> {
BelongsTo<MojomType, MojomTypeCategory::kStruct>::value>::type> {
template <typename MaybeConstUserType, typename WriterType>
static void Serialize(MaybeConstUserType& input,
Buffer* buffer,
......@@ -49,7 +49,7 @@ template <typename MojomType>
struct MojomSerializationImplTraits<
MojomType,
typename std::enable_if<
BelongsTo<MojomType, MojomTypeCategory::UNION>::value>::type> {
BelongsTo<MojomType, MojomTypeCategory::kUnion>::value>::type> {
template <typename MaybeConstUserType, typename WriterType>
static void Serialize(MaybeConstUserType& input,
Buffer* buffer,
......@@ -73,8 +73,8 @@ mojo::Message SerializeAsMessageImpl(UserType* input) {
template <typename MojomType, typename DataArrayType, typename UserType>
DataArrayType SerializeImpl(UserType* input) {
static_assert(BelongsTo<MojomType, MojomTypeCategory::STRUCT>::value ||
BelongsTo<MojomType, MojomTypeCategory::UNION>::value,
static_assert(BelongsTo<MojomType, MojomTypeCategory::kStruct>::value ||
BelongsTo<MojomType, MojomTypeCategory::kUnion>::value,
"Unexpected type.");
Message message = SerializeAsMessageImpl<MojomType>(input);
uint32_t size = message.payload_num_bytes();
......@@ -90,8 +90,8 @@ bool DeserializeImpl(const void* data,
std::vector<mojo::ScopedHandle> handles,
UserType* output,
bool (*validate_func)(const void*, ValidationContext*)) {
static_assert(BelongsTo<MojomType, MojomTypeCategory::STRUCT>::value ||
BelongsTo<MojomType, MojomTypeCategory::UNION>::value,
static_assert(BelongsTo<MojomType, MojomTypeCategory::kStruct>::value ||
BelongsTo<MojomType, MojomTypeCategory::kUnion>::value,
"Unexpected type.");
using DataType = typename MojomTypeTraits<MojomType>::Data;
......
......@@ -12,10 +12,10 @@ struct MojomTypeTraits<{{kind|get_qualified_name_for_kind}}DataView> {
using Data = {{kind|get_qualified_name_for_kind(internal=True)}};
{%- if kind|is_union_kind %}
using DataAsArrayElement = Data;
static constexpr MojomTypeCategory category = MojomTypeCategory::UNION;
static constexpr MojomTypeCategory category = MojomTypeCategory::kUnion;
{%- else %}
using DataAsArrayElement = Pointer<Data>;
static constexpr MojomTypeCategory category = MojomTypeCategory::STRUCT;
static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
{%- endif %}
};
{%- endmacro %}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment