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:
Kamil Domanski
2014-08-20 22:44:38 +02:00
parent 5d96b4ae01
commit 84881f8c47
13 changed files with 269 additions and 269 deletions

View File

@@ -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); \
}