Skip to content

Commit

Permalink
#188: polymorphic: quick hack to split decl/def macros for ETI
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Mar 29, 2021
1 parent ec8965d commit 5f047d2
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/checkpoint/dispatch/vrt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,38 @@
return ::checkpoint::dispatch::vrt::objregistry::makeObjIdx<_CheckpointBaseType>(); \
}

#define checkpoint_virtual_serialize_root_decl() \
auto _CheckpointVSBaseTypeFn() -> decltype(auto) { return this; } \
virtual void _checkpointDynamicSerialize( \
void* s, \
::checkpoint::dispatch::vrt::TypeIdx ser_idx, \
::checkpoint::dispatch::vrt::TypeIdx expected_idx \
); \
virtual ::checkpoint::dispatch::vrt::TypeIdx _checkpointDynamicTypeIndex();

#define checkpoint_virtual_serialize_root_def(CLASS) \
void CLASS::_checkpointDynamicSerialize( \
void* s, \
::checkpoint::dispatch::vrt::TypeIdx ser_idx, \
::checkpoint::dispatch::vrt::TypeIdx expected_idx \
) { \
using _CheckpointBaseType = \
::checkpoint::dispatch::vrt::checkpoint_base_type_t<decltype(*this)>; \
::checkpoint::instantiateObjSerializer< \
_CheckpointBaseType, \
checkpoint_serializer_variadic_args() \
>(); \
::checkpoint::dispatch::vrt::assertTypeIdxMatch<_CheckpointBaseType>(expected_idx); \
auto dispatcher = \
::checkpoint::dispatch::vrt::serializer_registry::getObjIdx<_CheckpointBaseType>(ser_idx); \
dispatcher(s, *static_cast<_CheckpointBaseType*>(this)); \
} \
::checkpoint::dispatch::vrt::TypeIdx CLASS::_checkpointDynamicTypeIndex() { \
using _CheckpointBaseType = \
::checkpoint::dispatch::vrt::checkpoint_base_type_t<decltype(*this)>; \
return ::checkpoint::dispatch::vrt::objregistry::makeObjIdx<_CheckpointBaseType>(); \
}

#define checkpoint_virtual_serialize_base(BASE) checkpoint_virtual_serialize_root()

namespace checkpoint { namespace dispatch { namespace vrt {
Expand Down
43 changes: 43 additions & 0 deletions src/checkpoint/dispatch/vrt/derived.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,49 @@
return ::checkpoint::dispatch::vrt::objregistry::makeObjIdx<_CheckpointDerivedType>(); \
}

#define checkpoint_virtual_serialize_derived_decl() \
void _checkpointDynamicSerialize( \
void* s, \
::checkpoint::dispatch::vrt::TypeIdx base_ser_idx, \
::checkpoint::dispatch::vrt::TypeIdx expected_idx \
) override; \
::checkpoint::dispatch::vrt::TypeIdx _checkpointDynamicTypeIndex() override;

#define checkpoint_virtual_serialize_derived_from_def(CLASS, PARENT) \
void CLASS::_checkpointDynamicSerialize( \
void* s, \
::checkpoint::dispatch::vrt::TypeIdx base_ser_idx, \
::checkpoint::dispatch::vrt::TypeIdx expected_idx \
) { \
using _CheckpointDerivedType = \
::checkpoint::dispatch::vrt::checkpoint_derived_type_t<decltype(this)>; \
::checkpoint::instantiateObjSerializer< \
_CheckpointDerivedType, \
checkpoint_serializer_variadic_args() \
>(); \
debug_checkpoint( \
"%s: BEGIN: _checkpointDynamicSerialize: serializer_idx=%d {\n", \
typeid(_CheckpointDerivedType).name(), base_ser_idx \
); \
::checkpoint::dispatch::vrt::assertTypeIdxMatch<_CheckpointDerivedType>(expected_idx); \
auto base_idx = ::checkpoint::dispatch::vrt::objregistry::makeObjIdx<PARENT>(); \
PARENT::_checkpointDynamicSerialize(s, base_ser_idx, base_idx); \
auto dispatcher = \
::checkpoint::dispatch::vrt::serializer_registry::getBaseIdx<_CheckpointDerivedType>( \
base_ser_idx \
); \
dispatcher(s, *static_cast<_CheckpointDerivedType*>(this)); \
debug_checkpoint( \
"%s: END: _checkpointDynamicSerialize: serializer_idx=%d }\n", \
typeid(_CheckpointDerivedType).name(), base_ser_idx \
); \
} \
::checkpoint::dispatch::vrt::TypeIdx CLASS::_checkpointDynamicTypeIndex() { \
using _CheckpointDerivedType = \
::checkpoint::dispatch::vrt::checkpoint_derived_type_t<decltype(this)>; \
return ::checkpoint::dispatch::vrt::objregistry::makeObjIdx<_CheckpointDerivedType>(); \
}

#define checkpoint_virtual_serialize_derived(DERIVED, PARENT) checkpoint_virtual_serialize_derived_from(PARENT)

namespace checkpoint { namespace dispatch { namespace vrt {
Expand Down

0 comments on commit 5f047d2

Please sign in to comment.