mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-19 03:55:49 +00:00
Support uint32_t serialization for size_t (which is either uint32_t or uint64_t on known systems)
This commit is contained in:
parent
2ff823f2eb
commit
545838f7eb
@ -12,7 +12,8 @@ namespace {
|
||||
bool gTestOutputMode = false;
|
||||
} // namespace
|
||||
|
||||
// uint8_t
|
||||
//// Elementary types
|
||||
|
||||
void Reflect(Reader& visitor, uint8_t& value) {
|
||||
value = (uint8_t)visitor.GetInt();
|
||||
}
|
||||
@ -20,7 +21,6 @@ void Reflect(Writer& visitor, uint8_t& value) {
|
||||
visitor.Int(value);
|
||||
}
|
||||
|
||||
// int16_t
|
||||
void Reflect(Reader& visitor, int16_t& value) {
|
||||
value = (int16_t)visitor.GetInt();
|
||||
}
|
||||
@ -28,7 +28,6 @@ void Reflect(Writer& visitor, int16_t& value) {
|
||||
visitor.Int(value);
|
||||
}
|
||||
|
||||
// int32_t
|
||||
void Reflect(Reader& visitor, int32_t& value) {
|
||||
value = visitor.GetInt();
|
||||
}
|
||||
@ -36,7 +35,13 @@ void Reflect(Writer& visitor, int32_t& value) {
|
||||
visitor.Int(value);
|
||||
}
|
||||
|
||||
// int64_t
|
||||
void Reflect(Reader& visitor, uint32_t& value) {
|
||||
value = visitor.GetUint32();
|
||||
}
|
||||
void Reflect(Writer& visitor, uint32_t& value) {
|
||||
visitor.Uint32(value);
|
||||
}
|
||||
|
||||
void Reflect(Reader& visitor, int64_t& value) {
|
||||
value = visitor.GetInt64();
|
||||
}
|
||||
@ -44,7 +49,6 @@ void Reflect(Writer& visitor, int64_t& value) {
|
||||
visitor.Int64(value);
|
||||
}
|
||||
|
||||
// uint64_t
|
||||
void Reflect(Reader& visitor, uint64_t& value) {
|
||||
value = visitor.GetUint64();
|
||||
}
|
||||
@ -52,7 +56,6 @@ void Reflect(Writer& visitor, uint64_t& value) {
|
||||
visitor.Uint64(value);
|
||||
}
|
||||
|
||||
// double
|
||||
void Reflect(Reader& visitor, double& value) {
|
||||
value = visitor.GetDouble();
|
||||
}
|
||||
@ -60,7 +63,6 @@ void Reflect(Writer& visitor, double& value) {
|
||||
visitor.Double(value);
|
||||
}
|
||||
|
||||
// bool
|
||||
void Reflect(Reader& visitor, bool& value) {
|
||||
value = visitor.GetBool();
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ class Reader {
|
||||
virtual void GetNull() = 0;
|
||||
virtual bool GetBool() = 0;
|
||||
virtual int GetInt() = 0;
|
||||
virtual uint32_t GetUint32() = 0;
|
||||
virtual int64_t GetInt64() = 0;
|
||||
virtual uint64_t GetUint64() = 0;
|
||||
virtual double GetDouble() = 0;
|
||||
@ -50,6 +51,7 @@ class Writer {
|
||||
virtual void Null() = 0;
|
||||
virtual void Bool(bool x) = 0;
|
||||
virtual void Int(int x) = 0;
|
||||
virtual void Uint32(uint32_t x) = 0;
|
||||
virtual void Int64(int64_t x) = 0;
|
||||
virtual void Uint64(uint64_t x) = 0;
|
||||
virtual void Double(double x) = 0;
|
||||
@ -153,6 +155,9 @@ void Reflect(Writer& visitor, int16_t& value);
|
||||
void Reflect(Reader& visitor, int32_t& value);
|
||||
void Reflect(Writer& visitor, int32_t& value);
|
||||
|
||||
void Reflect(Reader& visitor, uint32_t& value);
|
||||
void Reflect(Writer& visitor, uint32_t& value);
|
||||
|
||||
void Reflect(Reader& visitor, int64_t& value);
|
||||
void Reflect(Writer& visitor, int64_t& value);
|
||||
|
||||
|
@ -23,6 +23,7 @@ class JsonReader : public Reader {
|
||||
void GetNull() override {}
|
||||
bool GetBool() override { return m_->GetBool(); }
|
||||
int GetInt() override { return m_->GetInt(); }
|
||||
uint32_t GetUint32() override { return uint32_t(m_->GetUint64()); }
|
||||
int64_t GetInt64() override { return m_->GetInt64(); }
|
||||
uint64_t GetUint64() override { return m_->GetUint64(); }
|
||||
double GetDouble() override { return m_->GetDouble(); }
|
||||
@ -64,6 +65,7 @@ class JsonWriter : public Writer {
|
||||
void Null() override { m_->Null(); }
|
||||
void Bool(bool x) override { m_->Bool(x); }
|
||||
void Int(int x) override { m_->Int(x); }
|
||||
void Uint32(uint32_t x) override { m_->Uint64(x); }
|
||||
void Int64(int64_t x) override { m_->Int64(x); }
|
||||
void Uint64(uint64_t x) override { m_->Uint64(x); }
|
||||
void Double(double x) override { m_->Double(x); }
|
||||
|
@ -33,6 +33,7 @@ class MessagePackReader : public Reader {
|
||||
void GetNull() override { pk_->next(oh_); }
|
||||
bool GetBool() override { return Get<bool>(); }
|
||||
int GetInt() override { return Get<int>(); }
|
||||
uint32_t GetUint32() override { return Get<uint32_t>(); }
|
||||
int64_t GetInt64() override { return Get<int64_t>(); }
|
||||
uint64_t GetUint64() override { return Get<uint64_t>(); }
|
||||
double GetDouble() override { return Get<double>(); }
|
||||
@ -64,6 +65,7 @@ class MessagePackWriter : public Writer {
|
||||
void Null() override { m_->pack_nil(); }
|
||||
void Bool(bool x) override { m_->pack(x); }
|
||||
void Int(int x) override { m_->pack(x); }
|
||||
void Uint32(uint32_t x) override { m_->pack(x); }
|
||||
void Int64(int64_t x) override { m_->pack(x); }
|
||||
void Uint64(uint64_t x) override { m_->pack(x); }
|
||||
void Double(double x) override { m_->pack(x); }
|
||||
|
Loading…
Reference in New Issue
Block a user