|
15 | 15 | #define ORC_RT_SPSALLOCACTION_H |
16 | 16 |
|
17 | 17 | #include "orc-rt/AllocAction.h" |
| 18 | +#include "orc-rt/SPSWrapperFunctionBuffer.h" |
18 | 19 | #include "orc-rt/SimplePackedSerialization.h" |
19 | 20 |
|
20 | 21 | namespace orc_rt { |
21 | 22 |
|
| 23 | +struct SPSAllocAction; |
| 24 | + |
| 25 | +template <> class SPSSerializationTraits<SPSAllocAction, AllocAction> { |
| 26 | +public: |
| 27 | + static size_t size(const AllocAction &AA) { |
| 28 | + return SPSArgList<SPSExecutorAddr, SPSWrapperFunctionBuffer>::size( |
| 29 | + ExecutorAddr::fromPtr(AA.Fn), AA.ArgData); |
| 30 | + } |
| 31 | + |
| 32 | + static bool serialize(SPSOutputBuffer &OB, const AllocAction &AA) { |
| 33 | + return SPSArgList<SPSExecutorAddr, SPSWrapperFunctionBuffer>::serialize( |
| 34 | + OB, ExecutorAddr::fromPtr(AA.Fn), AA.ArgData); |
| 35 | + } |
| 36 | + |
| 37 | + static bool deserialize(SPSInputBuffer &IB, AllocAction &AA) { |
| 38 | + ExecutorAddr Fn; |
| 39 | + WrapperFunctionBuffer ArgData; |
| 40 | + if (!SPSArgList<SPSExecutorAddr, SPSWrapperFunctionBuffer>::deserialize( |
| 41 | + IB, Fn, ArgData)) |
| 42 | + return false; |
| 43 | + AA.Fn = Fn.toPtr<AllocActionFn>(); |
| 44 | + AA.ArgData = std::move(ArgData); |
| 45 | + return true; |
| 46 | + } |
| 47 | +}; |
| 48 | + |
| 49 | +struct SPSAllocActionPair; |
| 50 | + |
| 51 | +template <> class SPSSerializationTraits<SPSAllocActionPair, AllocActionPair> { |
| 52 | +public: |
| 53 | + static size_t size(const AllocActionPair &AAP) { |
| 54 | + return SPSArgList<SPSAllocAction, SPSAllocAction>::size(AAP.Finalize, |
| 55 | + AAP.Dealloc); |
| 56 | + } |
| 57 | + |
| 58 | + static bool serialize(SPSOutputBuffer &OB, const AllocActionPair &AAP) { |
| 59 | + return SPSArgList<SPSAllocAction, SPSAllocAction>::serialize( |
| 60 | + OB, AAP.Finalize, AAP.Dealloc); |
| 61 | + } |
| 62 | + |
| 63 | + static bool deserialize(SPSInputBuffer &IB, AllocActionPair &AAP) { |
| 64 | + return SPSArgList<SPSAllocAction, SPSAllocAction>::deserialize( |
| 65 | + IB, AAP.Finalize, AAP.Dealloc); |
| 66 | + } |
| 67 | +}; |
| 68 | + |
22 | 69 | template <typename... SPSArgTs> struct AllocActionSPSDeserializer { |
23 | 70 | template <typename... ArgTs> |
24 | 71 | bool deserialize(const char *ArgData, size_t ArgSize, ArgTs &...Args) { |
|
0 commit comments