|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64327 - in sandbox/SOC/2010/bit_masks: . boost/integer/bitfield_tuple boost/integer/detail/bft lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-07-25 10:51:11
Author: bbartman
Date: 2010-07-25 10:51:09 EDT (Sun, 25 Jul 2010)
New Revision: 64327
URL: http://svn.boost.org/trac/boost/changeset/64327
Log:
working on creating a custom policy for bitfield_tuple so that users can supply their own masks and policy for retrieval and storage
Added:
sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/mask_shift_indicators.hpp (contents, props changed)
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple/custom.hpp | 14 ++++++++------
sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/arg_parse_impl.hpp | 25 +++++++++++++++----------
sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/custom_packing_policy.hpp | 37 +++++++++++++++++++++++++++++++++++++
sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/pointer_packing_policy.hpp | 9 ++-------
sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/custom_member_test.cpp | 31 ++++++++++++++++++++++++++++++-
sandbox/SOC/2010/bit_masks/notes.txt | 4 ++++
6 files changed, 96 insertions(+), 24 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple/custom.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple/custom.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple/custom.hpp 2010-07-25 10:51:09 EDT (Sun, 25 Jul 2010)
@@ -8,21 +8,23 @@
#define BOOST_CUSTOM_FIELD_HPP
#include <cstddef>
-
-
-namespace boost {
-namespace bitfields {
+namespace boost { namespace bitfields {
/** The custom name means that the type being passed in is going to use
* custom packing and unpacking measures to store and retrieve its data.
- * The policy type will be documented else where so as to show how it works
+ * The policy type will be documented else where, as to show how it works
* and what it can/should be used for.
*/
template <
typename ReturnType,
typename Name,
typename Mask,
- typename Policy
+ template <
+ typename,
+ typename,
+ typename,
+ typename
+ > class Policy
>
struct custom;
Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/arg_parse_impl.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/arg_parse_impl.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/arg_parse_impl.hpp 2010-07-25 10:51:09 EDT (Sun, 25 Jul 2010)
@@ -306,7 +306,7 @@
template < typename ReturnType,
typename Name,
typename Mask,
- typename Policy,
+ template<typename,typename,typename,typename> class Policy,
typename StoragePolicy,
typename FieldVector,
typename Offset
@@ -339,10 +339,10 @@
front_storage_space,
back_storage_space
>::type
- >::type size_of_storage;
+ >::type size_of_value_mask;
- typedef typename mpl::plus< Offset, size_of_storage>::type offset;
+ typedef typename mpl::plus< Offset, size_of_value_mask>::type offset;
typedef bitfields::custom< ReturnType, Name, Mask, Policy > param;
@@ -350,12 +350,17 @@
typedef typename mpl::push_back<
FieldVector,
bitfield_element<
- ReturnType*,
+ ReturnType,
Name,
Offset,
- size_of_storage,
+ size_of_value_mask,
Mask,
- Policy
+ Policy<
+ Mask,
+ ReturnType,
+ Offset,
+ size_of_value_mask
+ >
>
>::type field_vector;
@@ -406,10 +411,10 @@
front_storage_space,
back_storage_space
>::type
- >::type size_of_storage;
+ >::type size_of_value_mask;
- typedef typename mpl::plus< Offset, size_of_storage>::type offset;
+ typedef typename mpl::plus< Offset, size_of_value_mask>::type offset;
typedef bitfields::pointer< ReturnType, Name, Mask > param;
@@ -420,13 +425,13 @@
ReturnType*,
Name,
Offset,
- size_of_storage,
+ size_of_value_mask,
Mask,
pointer_packing_policy<
Mask,
ReturnType*,
Offset,
- size_of_storage
+ size_of_value_mask
>
>
>::type field_vector;
Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/custom_packing_policy.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/custom_packing_policy.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/custom_packing_policy.hpp 2010-07-25 10:51:09 EDT (Sun, 25 Jul 2010)
@@ -0,0 +1,37 @@
+// Copyright 2010 Brian Bartman.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_BITFIELD_TUPLE_CUSTOM_PACKING_POLICY_HPP
+#define BOOST_BITFIELD_TUPLE_CUSTOM_PACKING_POLICY_HPP
+#include <cstddef>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/make_unsigned.hpp>
+#include <boost/integer/detail/bft/mask_shift_indicators.hpp>
+
+namespace boost { namespace detial {
+
+
+template <
+ typename Mask,
+ typename ValueType,
+ typename Offset,
+ typename Width
+>
+struct custom_packing_policy {
+ typedef Mask mask;
+ typedef ValueType value_type;
+
+ template <typename StorageType>
+ struct apply {
+ typedef StorageType storage_type;
+ static value_type get(storage_type storage);
+ static storage_type set(storage_type storage, value_type ptr);
+ };
+};
+
+}} // end boost::detail
+
+#endif
Added: sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/mask_shift_indicators.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/mask_shift_indicators.hpp 2010-07-25 10:51:09 EDT (Sun, 25 Jul 2010)
@@ -0,0 +1,18 @@
+// Copyright 2010 Brian Bartman.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_BITFIELD_TUPLE_MASK_SHIFT_INDICATORS_HPP
+#define BOOST_BITFIELD_TUPLE_MASK_SHIFT_INDICATORS_HPP
+#include <cstddef>
+
+namespace boost { namespace detail { namespace bit_shift {
+
+template <std::size_t Shift> struct right;
+template <std::size_t Shift> struct left;
+struct none;
+
+}}} // end boost::detail::bit_shift
+
+#endif
Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/pointer_packing_policy.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/pointer_packing_policy.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/pointer_packing_policy.hpp 2010-07-25 10:51:09 EDT (Sun, 25 Jul 2010)
@@ -9,14 +9,9 @@
#include <cstddef>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/make_unsigned.hpp>
+#include <boost/integer/detail/bft/mask_shift_indicators.hpp>
-namespace boost { namespace detail { namespace bit_shift {
-
-template <std::size_t Shift> struct right;
-template <std::size_t Shift> struct left;
-struct none;
-
-} // end bit_shift
+namespace boost { namespace detail {
// detial's relating to the set and get functions.
namespace policy_detail {
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/custom_member_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/custom_member_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/custom_member_test.cpp 2010-07-25 10:51:09 EDT (Sun, 25 Jul 2010)
@@ -10,9 +10,38 @@
using namespace boost;
using namespace boost::bitfields;
-struct cust;
+template <
+ typename Mask,
+ typename ValueType,
+ typename Offset,
+ typename Width
+>
+struct custom_packing_policy {
+ typedef Mask mask;
+ typedef ValueType value_type;
+
+ template <typename StorageType>
+ struct apply {
+ typedef StorageType storage_type;
+ static value_type get(storage_type storage);
+ static storage_type set(storage_type storage, value_type ptr);
+ };
+};
+struct cust;
int main() {
+ {
+ typedef bitfield_tuple<
+ custom<
+ unsigned int,
+ cust,
+ bits_mask<unsigned int, 3, 20>,
+ custom_packing_policy
+ >
+ > custom_t1;
+
+ custom_t1 t1;
+ }
return 0;
}
Modified: sandbox/SOC/2010/bit_masks/notes.txt
==============================================================================
--- sandbox/SOC/2010/bit_masks/notes.txt (original)
+++ sandbox/SOC/2010/bit_masks/notes.txt 2010-07-25 10:51:09 EDT (Sun, 25 Jul 2010)
@@ -41,6 +41,7 @@
14) bitfield_tuple.hpp
+15) Remove old pointer plus bits stuff
Test file review
@@ -148,7 +149,10 @@
a) remove test from name.
b) Change to using the <boost/detail/lightweight_test.hpp> framework.
+20) fails_on_64_bit.cpp
+ a) Move the contents into boost_endian_integration_test.cpp
+21) Remove the ppb_testing folder.
TO BE ADDED TO TESTS SECTION
Test which need to be created as a result of modifications or additions!
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk