From 4e6c585e5961ec4742cf08c1cfd01c1f40f05c2f Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 7 Jan 2018 16:06:01 -0800 Subject: [PATCH] Add mnemonic constants to ClangSymbolKind --- src/indexer.h | 16 ++++++++-------- src/serializer.cc | 11 +++++++++-- src/serializer.h | 3 +++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/indexer.h b/src/indexer.h index f7e3ab35..f7ec4e00 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -77,17 +77,17 @@ using IndexVarId = Id; struct IdCache; -// TODO Rename query.h:SymbolKind to another name; change int16_t to uint8_t +// TODO Rename query.h:SymbolKind to another name // clang/Index/IndexSymbol.h clang::index::SymbolKind -enum class ClangSymbolKind : int16_t { +enum class ClangSymbolKind : uint8_t { Unknown, - Module, + Module = 1, Namespace, NamespaceAlias, Macro, - Enum, + Enum = 5, Struct, Class, Protocol, @@ -95,23 +95,23 @@ enum class ClangSymbolKind : int16_t { Union, TypeAlias, - Function, + Function = 12, Variable, Field, EnumConstant, - InstanceMethod, + InstanceMethod = 16, ClassMethod, StaticMethod, InstanceProperty, ClassProperty, StaticProperty, - Constructor, + Constructor = 22, Destructor, ConversionFunction, - Parameter, + Parameter = 25, Using, }; MAKE_REFLECT_TYPE_PROXY(ClangSymbolKind, std::underlying_type::type); diff --git a/src/serializer.cc b/src/serializer.cc index cd7c31e6..b6dee5ea 100644 --- a/src/serializer.cc +++ b/src/serializer.cc @@ -20,10 +20,17 @@ std::string GetBaseName(const std::string& path) { } // namespace +// uint8_t +void Reflect(Reader& visitor, uint8_t& value) { + value = (uint8_t)visitor.GetInt(); +} +void Reflect(Writer& visitor, uint8_t& value) { + visitor.Int(value); +} + // int16_t void Reflect(Reader& visitor, int16_t& value) { - if (visitor.IsInt()) - value = (int16_t)visitor.GetInt(); + value = (int16_t)visitor.GetInt(); } void Reflect(Writer& visitor, int16_t& value) { visitor.Int(value); diff --git a/src/serializer.h b/src/serializer.h index b8543c60..0143cef6 100644 --- a/src/serializer.h +++ b/src/serializer.h @@ -131,6 +131,9 @@ void ReflectMemberEnd(TVisitor& visitor, T& value) { } */ +// uint8_t +void Reflect(Reader& visitor, uint8_t& value); +void Reflect(Writer& visitor, uint8_t& value); // int16_t void Reflect(Reader& visitor, int16_t& value); void Reflect(Writer& visitor, int16_t& value);