mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 09:31:59 +00:00
msgpack seems to work
Specify cacheFormat: 1 (SerializeFormat::MessagePack) in initializationOptions to write to .mpack cache files.
This commit is contained in:
parent
a0a52e50a2
commit
286a0649c1
@ -154,7 +154,8 @@ inline bool operator!=(const IndexFuncRef& a, const IndexFuncRef& b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void Reflect(Reader& visitor, IndexFuncRef& value) {
|
inline void Reflect(Reader& visitor, IndexFuncRef& value) {
|
||||||
const char* str_value = visitor.GetCString();
|
std::string s = visitor.GetString();
|
||||||
|
const char* str_value = s.c_str();
|
||||||
if (str_value[0] == '~') {
|
if (str_value[0] == '~') {
|
||||||
value.is_implicit = true;
|
value.is_implicit = true;
|
||||||
++str_value;
|
++str_value;
|
||||||
|
@ -148,8 +148,10 @@ bool Range::operator<(const Range& that) const {
|
|||||||
void Reflect(Reader& visitor, Position& value) {
|
void Reflect(Reader& visitor, Position& value) {
|
||||||
if (!visitor.IsString())
|
if (!visitor.IsString())
|
||||||
value = Position();
|
value = Position();
|
||||||
else
|
else {
|
||||||
value = Position(visitor.GetCString());
|
std::string s = visitor.GetString();
|
||||||
|
value = Position(s.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void Reflect(Writer& visitor, Position& value) {
|
void Reflect(Writer& visitor, Position& value) {
|
||||||
std::string output = value.ToString();
|
std::string output = value.ToString();
|
||||||
@ -160,8 +162,10 @@ void Reflect(Writer& visitor, Position& value) {
|
|||||||
void Reflect(Reader& visitor, Range& value) {
|
void Reflect(Reader& visitor, Range& value) {
|
||||||
if (!visitor.IsString())
|
if (!visitor.IsString())
|
||||||
value = Range();
|
value = Range();
|
||||||
else
|
else {
|
||||||
value = Range(visitor.GetCString());
|
std::string s = visitor.GetString();
|
||||||
|
value = Range(s.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void Reflect(Writer& visitor, Range& value) {
|
void Reflect(Writer& visitor, Range& value) {
|
||||||
std::string output = value.ToString();
|
std::string output = value.ToString();
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "indexer.h"
|
#include "indexer.h"
|
||||||
|
|
||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool gTestOutputMode = false;
|
bool gTestOutputMode = false;
|
||||||
@ -252,7 +253,8 @@ std::unique_ptr<IndexFile> Deserialize(SerializeFormat format,
|
|||||||
Reflect(reader, *file);
|
Reflect(reader, *file);
|
||||||
if (file->version != expected_version)
|
if (file->version != expected_version)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} catch (msgpack::insufficient_bytes&) {
|
} catch (msgpack::unpack_error& ex) {
|
||||||
|
LOG_S(ERROR) << "msgpack::unpack_err for '" << path << "' " << ex.what();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -27,8 +27,7 @@ class Reader {
|
|||||||
virtual int GetInt() = 0;
|
virtual int GetInt() = 0;
|
||||||
virtual int64_t GetInt64() = 0;
|
virtual int64_t GetInt64() = 0;
|
||||||
virtual uint64_t GetUint64() = 0;
|
virtual uint64_t GetUint64() = 0;
|
||||||
virtual const char* GetCString() = 0;
|
virtual std::string GetString() = 0;
|
||||||
virtual std::string GetString() { return GetCString(); }
|
|
||||||
|
|
||||||
virtual bool HasMember(const char* x) = 0;
|
virtual bool HasMember(const char* x) = 0;
|
||||||
virtual std::unique_ptr<Reader> operator[](const char* x) = 0;
|
virtual std::unique_ptr<Reader> operator[](const char* x) = 0;
|
||||||
@ -163,8 +162,12 @@ void Reflect(Reader& visitor, optional<T>& value) {
|
|||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Reflect(Writer& visitor, optional<T>& value) {
|
void Reflect(Writer& visitor, optional<T>& value) {
|
||||||
|
// We omit optional fields for JsonWriter to reduce output.
|
||||||
|
// But don't omit them for other serialization formats.
|
||||||
if (value)
|
if (value)
|
||||||
Reflect(visitor, value.value());
|
Reflect(visitor, *value);
|
||||||
|
else if (visitor.Format() != SerializeFormat::Json)
|
||||||
|
visitor.Null();
|
||||||
}
|
}
|
||||||
|
|
||||||
// std::variant (Writer only)
|
// std::variant (Writer only)
|
||||||
@ -179,8 +182,6 @@ void Reflect(Writer& visitor, std::variant<T0, T1>& value) {
|
|||||||
// std::vector
|
// std::vector
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Reflect(Reader& visitor, std::vector<T>& values) {
|
void Reflect(Reader& visitor, std::vector<T>& values) {
|
||||||
if (!visitor.IsArray())
|
|
||||||
return;
|
|
||||||
visitor.IterArray([&](Reader& entry) {
|
visitor.IterArray([&](Reader& entry) {
|
||||||
T entry_value;
|
T entry_value;
|
||||||
Reflect(entry, entry_value);
|
Reflect(entry, entry_value);
|
||||||
@ -224,10 +225,10 @@ void ReflectMember(Writer& visitor, const char* name, std::vector<T>& values) {
|
|||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void ReflectMember(Writer& visitor, const char* name, optional<T>& value) {
|
void ReflectMember(Writer& visitor, const char* name, optional<T>& value) {
|
||||||
if (!value)
|
if (value || visitor.Format() != SerializeFormat::Json) {
|
||||||
return;
|
|
||||||
visitor.Key(name);
|
visitor.Key(name);
|
||||||
Reflect(visitor, value);
|
Reflect(visitor, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void ReflectMember(Writer& visitor, const char* name, std::string& value);
|
void ReflectMember(Writer& visitor, const char* name, std::string& value);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class JsonReader : public Reader {
|
|||||||
int GetInt() override { return m_->GetInt(); }
|
int GetInt() override { return m_->GetInt(); }
|
||||||
int64_t GetInt64() override { return m_->GetInt64(); }
|
int64_t GetInt64() override { return m_->GetInt64(); }
|
||||||
uint64_t GetUint64() override { return m_->GetUint64(); }
|
uint64_t GetUint64() override { return m_->GetUint64(); }
|
||||||
const char* GetCString() override { return m_->GetString(); }
|
std::string GetString() override { return m_->GetString(); }
|
||||||
|
|
||||||
bool HasMember(const char* x) override { return m_->HasMember(x); }
|
bool HasMember(const char* x) override { return m_->HasMember(x); }
|
||||||
std::unique_ptr<Reader> operator[](const char* x) override {
|
std::unique_ptr<Reader> operator[](const char* x) override {
|
||||||
|
@ -25,7 +25,7 @@ class MessagePackReader : public Reader {
|
|||||||
int GetInt() override { return o_.as<int>(); }
|
int GetInt() override { return o_.as<int>(); }
|
||||||
int64_t GetInt64() override { return o_.as<int64_t>(); }
|
int64_t GetInt64() override { return o_.as<int64_t>(); }
|
||||||
uint64_t GetUint64() override { return o_.as<uint64_t>(); }
|
uint64_t GetUint64() override { return o_.as<uint64_t>(); }
|
||||||
const char* GetCString() override { return o_.as<char*>(); }
|
std::string GetString() override { return o_.as<std::string>(); }
|
||||||
|
|
||||||
bool HasMember(const char* x) override { return true; }
|
bool HasMember(const char* x) override { return true; }
|
||||||
std::unique_ptr<Reader> operator[](const char* x) override {
|
std::unique_ptr<Reader> operator[](const char* x) override {
|
||||||
|
Loading…
Reference in New Issue
Block a user