|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64045 - in sandbox/SOC/2010/bit_masks: boost/integer boost/integer/detail/bft boost/integer/detail/bft/ext lib/integer/test lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-07-15 09:12:04
Author: bbartman
Date: 2010-07-15 09:11:56 EDT (Thu, 15 Jul 2010)
New Revision: 64045
URL: http://svn.boost.org/trac/boost/changeset/64045
Log:
working on fix for different compilers for bitfield_tuple
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp | 4
sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/ext/bitfield_iterator.hpp | 4
sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/make_bitfield_tuple.hpp | 92 ++++++++++++
sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/boost_endian_integration_test.cpp | 290 ---------------------------------------
sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/make_bft_testing.cpp | 51 -------
sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/template_expansion_marco_test.cpp | 4
sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp | 31 ++-
7 files changed, 121 insertions(+), 355 deletions(-)
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-15 09:11:56 EDT (Thu, 15 Jul 2010)
@@ -27,7 +27,9 @@
#include <boost/integer/detail/bft/ext/bitfield_tuple_fusion_includes.hpp>
#include <boost/integer/detail/fusion_ext_includes.hpp>
#include <boost/integer/detail/bft/make_bitfield_tuple.hpp>
-#include <boost/integer/detail/bft/msvc_fixes/msvc_fix_includes.hpp>
+
+// TODO: re evaluate if this is needed or not.
+// #include <boost/integer/detail/bft/msvc_fixes/msvc_fix_includes.hpp>
namespace boost {
Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/ext/bitfield_iterator.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/ext/bitfield_iterator.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/ext/bitfield_iterator.hpp 2010-07-15 09:11:56 EDT (Thu, 15 Jul 2010)
@@ -36,6 +36,10 @@
detail::bft_category
>
{
+
+private:
+ bitfield_tuple_iterator& operator=(bitfield_tuple_iterator const&);
+public:
/** Constructor over a bitfield tuple. */
bitfield_tuple_iterator(BitfieldTuple& bft)
: _data(bft) { }
Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/make_bitfield_tuple.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/make_bitfield_tuple.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/make_bitfield_tuple.hpp 2010-07-15 09:11:56 EDT (Thu, 15 Jul 2010)
@@ -9,7 +9,97 @@
#include <boost/config.hpp>
#include <cstddef>
+namespace boost { namespace detail {
+
+/** Used to help generate psudo variadic template paramerer apperance.
+ * This make the typename T##N = mpl::void_ pattern.
+ */
+#define BOOST_MAKE_BFT_PARAM(z, n, data ) \
+ typename T ## n
+
+/** Makes the T0 through TN parameter list for the
+ * Generates pattern.
+ * typename T0, ... typename TN
+ */
+#define BOOST_MAKE_BFT_TEMPLATE_PARAMETERS(N) \
+ BOOST_PP_ENUM( N,\
+ BOOST_MAKE_BFT_PARAM, \
+ BOOST_BFT_NOTHING )
+
+
+/** Used for generating a single funciton parameter for the make_bitfield_tuple
+ * function template.
+ */
+#define BOOST_MAKE_BFT_FUNCTION_PARAM(z, n, data ) \
+ T ## n parameter ## n
+
+/** used for generating the parameters for a the make_bitfield_tuple
+ * funciton.
+ * Generates pattern
+ * T0 parameter0 , ... TN parametern
+ */
+#define BOOST_MAKE_BFT_FUNCTION_PARAMETERS(N) \
+ BOOST_PP_ENUM( N,\
+ BOOST_MAKE_BFT_FUNCTION_PARAM, \
+ BOOST_BFT_NOTHING )
+
+#define BOOST_MAKE_BFT_ASSIGN_FUNCTION_CALL(z,n,data)\
+ detail::assign_parameter_to_bft<n>(bft, parameter##n);
+
+#define BOOST_MAKE_BFT_GENERATE_ASSIGNMENT_CALLS( TO ) \
+ BOOST_PP_REPEAT_FROM_TO( \
+ 0,\
+ TO, \
+ BOOST_MAKE_BFT_ASSIGN_FUNCTION_CALL,\
+ BOOST_BFT_NOTHING )
+
+
+#define BOOST_MAKE_BFT_FUNCTION(z, N, data) \
+ template <typename BitfieldTuple, BOOST_MAKE_BFT_TEMPLATE_PARAMETERS(N)> \
+ BitfieldTuple make_bitfield_tuple(BOOST_MAKE_BFT_FUNCTION_PARAMETERS(N)){ \
+ BitfieldTuple bft; \
+ BOOST_MAKE_BFT_GENERATE_ASSIGNMENT_CALLS(N); \
+ return bft; \
+ }
+
+#define BOOST_MAKE_BFT_OVERLOADS() \
+ BOOST_PP_REPEAT_FROM_TO( \
+ 1,\
+ BOOST_BFT_PARAM_COUNT, \
+ BOOST_MAKE_BFT_FUNCTION,\
+ BOOST_BFT_NOTHING )
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable : 4244)
+#endif
+/** This is a function which is used to assign a value into a bitfield_tuple
+ * as well as remove the actual mpl::void_* from the parameter list through
+ * specialization.
+ */
+template <std::size_t Index, typename BitfieldTuple, typename ParameterType>
+inline void assign_parameter_to_bft(BitfieldTuple& bft, ParameterType value) {
+ bft.template get<Index>() = value;
+}
+template <std::size_t Index, typename BitfieldTuple>
+inline void assign_parameter_to_bft(BitfieldTuple&, mpl::void_*) { }
+
+template <std::size_t Index, typename BitfieldTuple>
+inline void assign_parameter_to_bft(BitfieldTuple&, void*) { }
+
+#if BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+} // end detail
+
+BOOST_MAKE_BFT_OVERLOADS()
+
+} // end boost::detail::msvc_fixes
+
+
+#if 0
namespace boost { namespace detail {
#ifdef BOOST_MSVC
@@ -191,5 +281,5 @@
#endif
} // end boost
-
+#endif
#endif
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/boost_endian_integration_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/boost_endian_integration_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/boost_endian_integration_test.cpp 2010-07-15 09:11:56 EDT (Thu, 15 Jul 2010)
@@ -3,293 +3,9 @@
// (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/endian_binary_stream.hpp>
-#include <boost/binary_stream.hpp>
-
-#include <boost/integer/bitfield_tuple.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-// used for working with the special conversion tools for creating
-// specific endianed storage.
-#include <boost/type_traits/is_convertible.hpp>
-
-#include <boost/mpl/bitwise.hpp>
-#include <boost/mpl/arithmetic.hpp>
-#include <climits>
-
-#include <boost/assert.hpp>
-#include <iostream>
-#include <typeinfo>
-#include <cstdio>
-
-struct red;
-struct green;
-struct blue;
-using namespace boost;
-using namespace boost::integer;
-using namespace boost::bitfields;
-using namespace std;
-
-// I have a little endian for my desktop.
-
-
-namespace boost { namespace bitfields { namespace endian {
-
-struct little_endian_tag {};
-struct big_endian_tag {};
-struct pdp_endian_tag {};
-
-
-struct native_tag
- :
-#ifdef BOOST_LITTLE_ENDIAN
- little_endian_tag
-#elif BOOST_BIG_ENDIAN
- big_endian_tag
-#elif BOOST_PDP_ENDIAN
- pdp_endian_tag
-#else
-#error "We are in Big trouble here as we have encountered an unknown endian macro" \
-" definition this may be a result of a change inside of <boost/detail/endain.hpp>" \
-" or your processor isn't registered in the <boost/detail/endian.hpp> header file."
-#endif
-{ };
-
-typedef
-#ifdef BOOST_LITTLE_ENDIAN
- little_endian_tag
-#elif BOOST_BIG_ENDIAN
- big_endian_tag
-#elif BOOST_PDP_ENDIAN
- pdp_endian_tag
-#else
-#error "We are in Big trouble here as we have encountered an unknown endian macro" \
-" definition this may be a result of a change inside of <boost/detail/endain.hpp>" \
-" or your processor isn't registered in the <boost/detail/endian.hpp> header file."
-#endif
-native;
-
-template <std::size_t Order>
-struct _byte_order_from_macro
- :integral_constant<std::size_t, Order>
-{ };
-
-// this is a typedef that defines the byte order statically instead of
-// via macro that way it can be reasoned about.
-typedef _byte_order_from_macro<BOOST_BYTE_ORDER> byte_order;
-
-typedef integral_constant <std::size_t, CHAR_BIT> char_bit;
-
-/** dumb stuff to remember about endianness
- * all single bytes stored left to right in bits ALWAYS 0 - 7
- * little endian is 1234
- * bit endian is 4321
- *
- * 1234
- * means that the 0 bit of the integer is first.
- *
- * 4321
- * means that 31st bit is first.
- *
- * little endian short -- to -- big endian short
- * 0x12 ---> 0x21
- *
- *
- *
- *
- *
- *
- */
-namespace detail {
-
-template <
- std::size_t ByteIndex,
- typename InIntegralC,
- typename OutIntegralC
->
-struct calculate_out_integral_c {
-
- // create mask for getting the next byte.
- typedef bits_mask<
- typename InIntegralC::value_type,
- ByteIndex * char_bit::value,
- char_bit::value
- > mask;
-
- // gettting next byte's value
- typedef typename mpl::bitand_<
- InIntegralC,
- mask
- >::type current_byte_value;
-
- // shift back to the starting point.
- typedef typename mpl::shift_right<
- current_byte_value,
- mpl::size_t<ByteIndex * char_bit::value>
- >::type right_shifted_byte;
-
- // shift to correct position.
- typedef typename mpl::shift_left<
- right_shifted_byte,
- mpl::size_t<
- ((sizeof(typename InIntegralC::value_type) - 1 - ByteIndex)
- *
- char_bit::value )>
- >::type positioned_byte;
-
- typedef typename mpl::bitor_<
- OutIntegralC,
- positioned_byte
- >::type type;
-};
-
-
-template <
- std::size_t ByteIndex,
- typename InIntegralC,
- typename OutIntegralC,
- bool Continue = true
->
-struct conversion_loop
- :conversion_loop<
- ByteIndex + 1, // increment ByteIndex so I move to the next byte.
- InIntegralC,
- typename calculate_out_integral_c<
- ByteIndex,
- InIntegralC,
- OutIntegralC
- >::type,
- // now evaluating the boolean condition for continuation of loop.
- (ByteIndex < (sizeof(typename InIntegralC::value_type)-1) )
- >
-{ };
-
-// this kills the loop.
-template <
- std::size_t ByteIndex,
- typename InIntegralC,
- typename OutIntegralC
->
-struct conversion_loop<ByteIndex,InIntegralC,OutIntegralC,false> {
- typedef OutIntegralC type;
-};
-
-
-// calls the loop that converts the endianness.
-template <typename IntegralConstType, typename EndiannessTag>
-struct convertion_helper {
- typedef typename conversion_loop<
- 0,
- IntegralConstType,
- integral_constant<
- typename IntegralConstType::value_type,
- 0
- >
- >::type type;
-};
-
-// trival case where native endianness is being used or something convertible to
-// the native_tag is being used.
-template <typename IntegralConstType>
-struct convertion_helper <IntegralConstType,native_tag> {
- typedef IntegralConstType type;
-};
-
-
-}
-
-/** Yes this will take an integral constant and change the encoded endianness
- * of it to be which ever you choose accept for PDP because I don't know
- * just how to deal with that one just yet.
- */
-template <typename IntegralConstantType, typename ConvertTo = native_tag >
-struct set_endianness {
- typedef typename mpl::if_<
- is_convertible<ConvertTo,native_tag>,
- native_tag,
- ConvertTo
- >::type endianness_tag;
- typedef typename detail::convertion_helper<
- IntegralConstantType,
- endianness_tag
- >::type type;
-};
-
-}}} // end boost::bitfields::endian
-
-using namespace boost::bitfields::endian;
-
-typedef bitfield_tuple<
- storage< big32_t >,
- member<unsigned char, red, 5>,
- member<unsigned char, green, 6>,
- member<unsigned char, blue, 5>
-> rgb565_t;
-typedef set_endianness<
- integral_constant<unsigned int, 0xDEADBEEF>,
- big_endian_tag
->::type converted_type;
-
-typedef integral_constant<unsigned int, 0xDEADBEEF> beefy;
-typedef integral_constant<unsigned int, 0> start_of_the_end;
+// TODO: add actual tests here for bitfield_tuple to make sure that it can handle
+// and store types with different endianness.
int main() {
- {
- // cout << typeid(native).name() << endl;
- // cout << byte_order() << endl;
- // typedef integer::bitfield<ubig32_t,0,3> a_bitfield;
- // cout << is_same<unative32_t,ulittle32_t>::value << endl;
- // cout << is_same<unative32_t,ubig32_t>::value << endl;
- // cout << typeid(converted_type).name() << endl;
- // cout << converted_type() << endl;
-
- printf("%0x\n",0xdeadbeef);
- printf("%0x\n", converted_type::value );
-
- typedef boost::bitfields::endian::detail::calculate_out_integral_c<
- 0,
- beefy,
- start_of_the_end
- >::type step_one;
- printf("Step 1: %0x\n", step_one::value );
-
- typedef boost::bitfields::endian::detail::calculate_out_integral_c<
- 1,
- beefy,
- step_one
- >::type step_two;
- printf("Step 2: %0x\n", step_two::value );
-
-
-
- typedef boost::bitfields::endian::detail::calculate_out_integral_c<
- 2,
- beefy,
- step_two
- >::type step_three;
- printf("Step 3: %0x\n", step_three::value );
-
-
- typedef boost::bitfields::endian::detail::calculate_out_integral_c<
- 3,
- beefy,
- step_three
- >::type step_four;
- printf("Step 4: %0x\n", step_four::value );
-
- // BOOST_TEST(false);
-
- }
- {
- #if 0
- 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();
+ return 0;
}
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/make_bft_testing.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/make_bft_testing.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/make_bft_testing.cpp 2010-07-15 09:11:56 EDT (Thu, 15 Jul 2010)
@@ -25,60 +25,9 @@
member<int, salmon, 16>,
flag<blue>
> test_tuple;
-#ifdef BOOST_MSVC
-
-
-#endif
int main() {
{
-#ifdef BOOST_MSVC
- using namespace ::boost::detail;
- // Checking to make sure that the indexs work correctly.
- BOOST_MPL_ASSERT(( get_create_parameter<test_tuple,0>::is_valid_index ));
- BOOST_MPL_ASSERT(( get_create_parameter<test_tuple,1>::is_valid_index ));
- BOOST_MPL_ASSERT(( get_create_parameter<test_tuple,2>::is_valid_index ));
- BOOST_MPL_ASSERT(( get_create_parameter<test_tuple,3>::is_valid_index ));
- BOOST_MPL_ASSERT_NOT(( get_create_parameter<test_tuple,4>::is_valid_index ));
- BOOST_MPL_ASSERT_NOT(( get_create_parameter<test_tuple,5>::is_valid_index ));
- BOOST_MPL_ASSERT_NOT(( get_create_parameter<test_tuple,6>::is_valid_index ));
- BOOST_MPL_ASSERT_NOT(( get_create_parameter<test_tuple,7>::is_valid_index ));
- BOOST_MPL_ASSERT_NOT(( get_create_parameter<test_tuple,8>::is_valid_index ));
- BOOST_MPL_ASSERT_NOT(( get_create_parameter<test_tuple,9>::is_valid_index ));
- BOOST_MPL_ASSERT_NOT(( get_create_parameter<test_tuple,10>::is_valid_index ));
- BOOST_MPL_ASSERT_NOT(( get_create_parameter<test_tuple,11>::is_valid_index ));
- BOOST_MPL_ASSERT_NOT(( get_create_parameter<test_tuple,12>::is_valid_index ));
- BOOST_MPL_ASSERT_NOT(( get_create_parameter<test_tuple,13>::is_valid_index ));
- BOOST_MPL_ASSERT_NOT(( get_create_parameter<test_tuple,14>::is_valid_index ));
- // BOOST_ASSERT((false));
- // checking to make sure that the if statement part of it works correctly.
-
-
- BOOST_MPL_ASSERT(( is_same<get_create_parameter<test_tuple,0>::type, char> ));
- BOOST_MPL_ASSERT(( is_same<get_create_parameter<test_tuple,1>::type, unsigned char> ));
- BOOST_MPL_ASSERT(( is_same<get_create_parameter<test_tuple,2>::type, int> ));
- BOOST_MPL_ASSERT(( is_same<get_create_parameter<test_tuple,3>::type, bool> ));
- BOOST_MPL_ASSERT(( is_same<get_create_parameter<test_tuple,4>::type, mpl::void_*> ));
-#endif
- }
- {
-#if 1
- using namespace ::boost::detail;
- BOOST_MPL_ASSERT((
- is_same<
- get_create_parameter<test_tuple,0>::type,
- char
- >
- ));
- BOOST_MPL_ASSERT((
- is_same<
- get_create_parameter<test_tuple,2>::type,
- int
- >
- ));
-#endif
- }
- {
test_tuple bft = make_bitfield_tuple<test_tuple>(1,2,4,true);
BOOST_ASSERT(( bft.get<red>() == 1 ));
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/template_expansion_marco_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/template_expansion_marco_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/template_expansion_marco_test.cpp 2010-07-15 09:11:56 EDT (Thu, 15 Jul 2010)
@@ -12,7 +12,7 @@
using namespace boost;
using namespace boost::bitfields;
-using namespace std;
+//~ using namespace std;
template <BOOST_MAKE_BFT_TEMPLATE_PARAMS()>
struct ham_bone {
@@ -21,7 +21,7 @@
int main() {
ham_bone<int,int,int,int,int,int,int,int,int,int> temp;
- cout << typeid( &temp ).name() << endl;
+ std::cout << typeid( &temp ).name() << std::endl;
return 0;
}
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/high_bit_mask_test.cpp 2010-07-15 09:11:56 EDT (Thu, 15 Jul 2010)
@@ -20,24 +20,17 @@
template <typename T>
void test_function() {
- using namespace std;
+ //~ using namespace std;
- cout << "Starting test. Test Type = " << typeid(T).name() << endl;
+ std::cout << "Starting test. Test Type = " << typeid(T).name() << std::endl;
// making sure that the value type is transfered correctly.
BOOST_TEST((is_same< typename high_bits_mask<T, 3>::value_type, T >::value));
-#ifdef BOOST_MSVC
-#pragma warning(push)
-#pragma warning(disable: 4127)
-#endif
+
if(!is_same<char,T>::value ) {
-#ifdef BOOST_MSVC
-#pragma warning(pop)
-#endif
- cout << "Mask Value: " << hex << boost::high_bits_mask<T,1>::value << endl;
- cout << "Test Value: " << hex << static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 1)) << endl;
+ std::cout << "Mask Value: " << std::hex << boost::high_bits_mask<T,1>::value << std::endl;
+ std::cout << "Test Value: " << std::hex << static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 1)) << std::endl;
}
-
BOOST_TEST(( boost::high_bits_mask<T,1>::value ==
static_cast<T>( ~(~(typename make_unsigned<T>::type(0)) >> 1)) ));
BOOST_TEST(( boost::high_bits_mask<T,2>::value ==
@@ -72,12 +65,24 @@
int main() {
-
+#ifdef BOOST_MSVC
+#pragma warning( push )
+#pragma warning( disable : 4307 ) // c4307 constant value overflow.
+#pragma warning( disable : 4309 ) // truncation of constant value.
+
+// Look into fixing this! I think i can actually fix this warning.
+#pragma warning( disable : 4305 ) // initializing truncation from const
+ // boost::mpl::size_t<N>::value_type to const
+ // arg.
+#endif
mpl::for_each< test_types >( type_tester() );
mpl::for_each< test_types_2 >( type_tester() );
mpl::for_each< test_types_3 >( type_tester() );
+#ifdef BOOST_MSVC
+#pragma warning( pop )
+#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