Compile time BitLenToByteLen computation; marshal type util tests

This commit is contained in:
Pavel Kirienko
2014-03-08 23:24:20 +04:00
parent fb329a2f0a
commit d9474388b0
4 changed files with 36 additions and 14 deletions
@@ -20,6 +20,10 @@ template <>
struct IntegerBitLen<0> { enum { Result = 0 }; };
template <unsigned long BitLen>
struct BitLenToByteLen { enum { Result = (BitLen + 7) / 8 }; };
template <typename T, typename Enable = void>
struct StorageType { typedef T Type; };
+2 -2
View File
@@ -12,6 +12,7 @@
#include <uavcan/internal/lazy_constructor.hpp>
#include <uavcan/internal/transport/transfer_sender.hpp>
#include <uavcan/internal/marshal/scalar_codec.hpp>
#include <uavcan/internal/marshal/types.hpp>
namespace uavcan
{
@@ -54,8 +55,7 @@ private:
IMarshalBuffer* getBuffer()
{
const int size = (DataType::MaxBitLen + 7) / 8;
return buffer_provider_.getBuffer(size);
return buffer_provider_.getBuffer(BitLenToByteLen<DataType::MaxBitLen>::Result);
}
int genericSend(const DataType& message, TransferType transfer_type, NodeID dst_node_id,