mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
rework overhauled serialization methods to non-static
Thanks to Pieter Wuille for most of the work on this commit. I did not fixup the overhaul commit, because a rebase conflicted with "remove fields of ser_streamplaceholder". I prefer not to risk making a mistake while resolving it.
This commit is contained in:
@@ -38,12 +38,12 @@ inline T& REF(const T& val)
|
||||
return const_cast<T&>(val);
|
||||
}
|
||||
|
||||
// Used to acquire a const pointer "this" and generate a const
|
||||
// serialization operation from a template
|
||||
// Used to acquire a non-const pointer "this" to generate bodies
|
||||
// of const serialization operations from a template
|
||||
template<typename T>
|
||||
inline T MAKE_CONST(T val)
|
||||
inline T* NCONST_PTR(const T* val)
|
||||
{
|
||||
return const_cast<const T>(val);
|
||||
return const_cast<T*>(val);
|
||||
}
|
||||
|
||||
/** Get begin pointer of vector (non-const version).
|
||||
@@ -97,15 +97,15 @@ enum
|
||||
#define IMPLEMENT_SERIALIZE \
|
||||
size_t GetSerializeSize(int nType, int nVersion) const { \
|
||||
ser_streamplaceholder s; \
|
||||
return SerializationOp(MAKE_CONST(this), s, CSerActionGetSerializeSize(), nType, nVersion); \
|
||||
return NCONST_PTR(this)->SerializationOp(s, CSerActionGetSerializeSize(), nType, nVersion); \
|
||||
} \
|
||||
template<typename Stream> \
|
||||
void Serialize(Stream& s, int nType, int nVersion) const { \
|
||||
SerializationOp(MAKE_CONST(this), s, CSerActionSerialize(), nType, nVersion); \
|
||||
NCONST_PTR(this)->SerializationOp(s, CSerActionSerialize(), nType, nVersion); \
|
||||
} \
|
||||
template<typename Stream> \
|
||||
void Unserialize(Stream& s, int nType, int nVersion) { \
|
||||
SerializationOp(this, s, CSerActionUnserialize(), nType, nVersion); \
|
||||
SerializationOp(s, CSerActionUnserialize(), nType, nVersion); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user