|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64622 - in sandbox/SOC/2010/bit_masks: boost/integer/detail/bitfield_vector lib/integer/test/bitfield_vector_testing
From: bbartmanboost_at_[hidden]
Date: 2010-08-05 14:51:50
Author: bbartman
Date: 2010-08-05 14:51:47 EDT (Thu, 05 Aug 2010)
New Revision: 64622
URL: http://svn.boost.org/trac/boost/changeset/64622
Log:
worked on getting my bitfield_vector's member implementation working
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp | 91 ++++++++++++---------------------------
sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp | 5 -
2 files changed, 30 insertions(+), 66 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp 2010-08-05 14:51:47 EDT (Thu, 05 Aug 2010)
@@ -182,7 +182,7 @@
ret.mask_size = mask_size;
ret.mask = new storage_t[mask_size];
ret.last_left_shift = 0;
-
+ std::memset(ret.mask, 0, mask_size);
storage_ptr_t mask_ptr = ret.mask;
// calculate bit_count for for statement
@@ -257,89 +257,53 @@
/** Copy Constructor. */
proxy_reference_type(_self const& x)
- :_ptr(x._ptr), _offset(x._offset)
+ :_ptr(x._ptr),
+ _offset(x._offset),
+ _mask(make_field_mask<Width>(_offset))
{ }
/** pointer, offset constructor. */
proxy_reference_type(storage_type* ptr, offset_type offset)
- :_ptr(ptr), _offset(offset)
+ :_ptr(ptr),
+ _offset(offset),
+ _mask(make_field_mask<Width>(_offset))
{ }
+
+ ~proxy_reference_type() {
+ delete _mask.mask;
+ }
//@}
/** Copy assignment. */
_self& operator=(_self const& x) {
+ storage_ptr_t mask_ptr = _mask.mask;
_ptr = x._ptr;
_offset = x._offset;
+ _mask = make_field_mask<Width>(_offset);
+ delete mask_ptr;
return *this;
}
/** Implicit Conversion Operator*/
operator value_type() const {
value_type ret = 0;
- storage_type* byte_ptr = _ptr;
- // std::size_t remaining_bits = width;
- storage_type mask = 0;
-
- // constructing mask inside of char array.
- // TODO: Make this correctly deduced! as of right it is the largest
- // possible size.
- storage_type mask_array[9];
- std::memset(mask_array, 0,9);
-
-
- // this is so that the loop will work correctly the first time through.
- storage_type* mask_ptr = mask_array;
- --mask_ptr;
- mask = 0x80;
- mask >>= _offset;
- std::size_t bit_copy_ammount = _offset + width;
- std::size_t trailing_zeros = 8 - _offset;
- std::size_t mask_byte_count = 0;
- std::cout << "Pre-Mask creation Stats" << std::endl;
- std::cout << "trailing_zero's value: " << trailing_zeros << std::endl;
- std::cout << "bit_copy_ammount: " << bit_copy_ammount << std::endl;
- std::cout << "mask_byte_count: " << mask_byte_count << std::endl;
- for(std::size_t bit_index = _offset;bit_index <= bit_copy_ammount; ++bit_index){
- if( (bit_index%8) == 0) {
- ++mask_byte_count;
- trailing_zeros = 8;
- mask >>= 1;
- *mask_ptr |= mask;
- ++mask_ptr;
- mask = 0x80;
- continue;
- }
- --trailing_zeros;
- *mask_ptr |= mask;
- mask >>= 1;
- }
- std::cout << "Post-Mask creation Stats" << std::endl;
- std::cout << "trailing_zero's value: " << trailing_zeros << std::endl;
- std::cout << "bit_copy_ammount: " << bit_copy_ammount << std::endl;
- std::cout << "mask_byte_count: " << mask_byte_count << std::endl;
+ storage_ptr_t mask_ptr = _mask.mask;
+ storage_ptr_t end_mask_ptr = _mask.mask + _mask.mask_size - 1 ;
+ storage_ptr_t data_ptr = _ptr;
- // mask_ptr = mask_array;
- // storage_type* mask_array_end = (mask_array) + 9;
-
- for(std::size_t i =0; i < 9; ++i) {
- std::cout << std::hex << std::size_t(mask_array[i]) << "|";
+ if(_mask.mask_size == 1) {
+ return value_type(*data_ptr & *mask_ptr) >> (8-(_offset + width));
}
- std::cout << std::endl;
-
- for( std::size_t mask_index = 0;
- mask_index < mask_byte_count;
- ++mask_index)
- {
- if(!(mask_array[mask_index] & 0x1) ) {
- ret <<= 8 - ((_offset + width)%8);
- return ret + (mask_array[mask_index] >> trailing_zeros);
- }
+ for(;mask_ptr < end_mask_ptr;++mask_ptr) {
ret <<= 8;
- ret += *byte_ptr & mask_array[mask_index];
- ++byte_ptr;
- }
- return ret;
+ ret += *data_ptr & *mask_ptr;
+ ++data_ptr;
+ }
+ ret <<= _mask.last_left_shift;
+ ++data_ptr;
+ ++mask_ptr;
+ return ret += *data_ptr & *mask_ptr;
}
/** value_type storage assignement operator.*/
@@ -356,6 +320,7 @@
/** Member variables. */
storage_type* _ptr;
offset_type _offset;
+ mask_array_info _mask;
};
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp 2010-08-05 14:51:47 EDT (Thu, 05 Aug 2010)
@@ -203,7 +203,7 @@
delete manager_ptr.mask;
}
- /*
+
// encoding and decoding tests.
{
typedef unsigned char storage_type;
@@ -234,11 +234,10 @@
std::cout << "second use of t2" << std::endl;
std::cout << "Value returned by t2: "<< std::hex << t2 << std::endl;
std::cout << "third use of t2" << std::endl;
- BOOST_TEST(t2 == 6);
+ BOOST_TEST(t2 == 7);
}
-*/
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