Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63712 - in sandbox/SOC/2010/bit_masks: boost/bitfield boost/integer lib/integer/test lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-07-06 19:08:32


Author: bbartman
Date: 2010-07-06 19:08:31 EDT (Tue, 06 Jul 2010)
New Revision: 63712
URL: http://svn.boost.org/trac/boost/changeset/63712

Log:
completed work on the basic pointer plus bits and discovered that endianness types are going to be a problem.
Added:
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/boost_endian_integration_test.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/bitfield/bitfield.hpp | 48 ++++++++++++++++++++++++++++++++++++++++
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp | 2
   sandbox/SOC/2010/bit_masks/boost/integer/pointer_plus_bits.hpp | 3 ++
   sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 | 2 +
   4 files changed, 54 insertions(+), 1 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/bitfield/bitfield.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/bitfield/bitfield.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/bitfield/bitfield.hpp 2010-07-06 19:08:31 EDT (Tue, 06 Jul 2010)
@@ -225,9 +225,21 @@
         static const std::size_t STS = 8*sizeof(storage_type);
         static const std::size_t LASTD = STS-LAST-1;
         static const std::size_t WIDTH = LAST - FIRST + 1; //!< Width in bits of the bitfield
+
+ static const storage_type VAL_MASK;
+ static const storage_type FIELD_MASK;
+ static const storage_type SIGN_MASK;
+
+/*
+ static const storage_type VAL_MASK = storage_type((1 << WIDTH) - 1); //!< Mask applied against assigned values
+ static const storage_type FIELD_MASK = storage_type(VAL_MASK << LASTD); //!< Mask of the field's bit positions
+ static const storage_type SIGN_MASK = storage_type(~VAL_MASK); //!< Sign mask applied against assigned
+*/
+/*
         static const storage_type VAL_MASK = (1 << WIDTH) - 1; //!< Mask applied against assigned values
         static const storage_type FIELD_MASK = (VAL_MASK << LASTD); //!< Mask of the field's bit positions
         static const storage_type SIGN_MASK = ~VAL_MASK; //!< Sign mask applied against assigned values
+*/
         static const value_type MIN_VAL = std::numeric_limits<value_type>::is_signed?value_type((1<<(WIDTH-1))-1):0; //!< min value that can be represented with the bitfield
         static const value_type MAX_VAL = std::numeric_limits<value_type>::is_signed?value_type(1<<(WIDTH-1)):(1<<(WIDTH))-1; //!< max value that can be represented with the bitfield
 
@@ -346,6 +358,42 @@
         r.set(v);
         return is;
     }
+
+template <
+ typename STORAGE_TYPE,
+ std::size_t F,
+ std::size_t L,
+ typename VALUE_TYPE,
+ typename REFERENCE_TYPE
+>
+bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::storage_type bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::VAL_MASK =
+ bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::storage_type(
+ (1 << bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::WIDTH) - 1);
+/*
+template <
+ typename STORAGE_TYPE,
+ std::size_t F,
+ std::size_t L,
+ typename VALUE_TYPE,
+ typename REFERENCE_TYPE
+>
+bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::storage_type bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::FIELD_MASK =
+ typename bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::storage_type(
+ bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::VAL_MASK
+ <<
+ bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::LASTD
+ );
+
+template <
+ typename STORAGE_TYPE,
+ std::size_t F,
+ std::size_t L,
+ typename VALUE_TYPE,
+ typename REFERENCE_TYPE
+>
+bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::storage_type bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::SIGN_MASK =
+ typename bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::storage_type(~bitfield<STORAGE_TYPE,F,L,VALUE_TYPE,REFERENCE_TYPE>::VAL_MASK);
+*/
 }}
 #endif
 

Modified: sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp 2010-07-06 19:08:31 EDT (Tue, 06 Jul 2010)
@@ -106,7 +106,7 @@
      * This sets the initial value of the internal data to x.
      * Also functions as the default constructor.
      */
- explicit bitfield_tuple(storage_type x = 0)
+ explicit bitfield_tuple(storage_type x = storage_type())
         :_data(x)
     { }
 

Modified: sandbox/SOC/2010/bit_masks/boost/integer/pointer_plus_bits.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/pointer_plus_bits.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/pointer_plus_bits.hpp 2010-07-06 19:08:31 EDT (Tue, 06 Jul 2010)
@@ -192,6 +192,9 @@
     struct bit_reference {
         explicit bit_reference(pointer& x);
         bit_reference(bit_reference<Index> const& x);
+ operator bool() const;
+ bit_reference<Index> const& operator=(bool rhs);
+
     private:
         bit_reference();
         pointer& _ref;

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 2010-07-06 19:08:31 EDT (Tue, 06 Jul 2010)
@@ -50,7 +50,9 @@
             :
             <toolset>gcc:<cxxflags>-Wno-long-long <toolset>darwin:<cxxflags>-Wno-long-long ]
         [ run bft_testing/make_bft_testing.cpp ]
+ #[ run bft_testing/boost_endian_integration_test.cpp ]
         [ run ppb_testing/pointer_plus_bits_test.cpp ]
 
+
     ;
 

Added: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/boost_endian_integration_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/boost_endian_integration_test.cpp 2010-07-06 19:08:31 EDT (Tue, 06 Jul 2010)
@@ -0,0 +1,39 @@
+// 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)
+
+
+#include <boost/integer/endian.hpp>
+#include <boost/integer/bitfield_tuple.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+
+
+
+struct red;
+struct green;
+struct blue;
+using namespace boost;
+using namespace boost::integer;
+
+typedef bitfield_tuple<
+ storage< big32_t >,
+ member<unsigned char, red, 5>,
+ member<unsigned char, green, 6>,
+ member<unsigned char, blue, 5>
+> rgb565_t;
+
+int main() {
+ {
+ // integer::bitfield<
+ }
+ #if 1
+ rgb565_t rgb565;
+ rgb565.get<red>() = 3;
+ BOOST_TEST(rgb565.get<red>() == 3);
+ rgb565.get<0>() = 4;
+ BOOST_TEST(rgb565.get<0>() == 4);
+ #endif
+ return boost::report_errors();
+}


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