From 7fd28e23ebb516a46e87d7a0bd6eab91bab98089 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 3 Dec 2011 03:14:25 +0100 Subject: [PATCH] cleanup configflags to use uint instead of char using char for those flag template parameters was never a good idea. It won't save us any space and makes debugging harder --- src/lib/meta/configflags.hpp | 44 ++++++++++++------------- src/proc/engine/nodeoperation.hpp | 6 ++-- tests/lib/meta/config-flags-test.cpp | 2 +- tests/lib/meta/typelist-diagnostics.hpp | 27 +++++++-------- 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/lib/meta/configflags.hpp b/src/lib/meta/configflags.hpp index 4e71bfd9e..b80dae229 100644 --- a/src/lib/meta/configflags.hpp +++ b/src/lib/meta/configflags.hpp @@ -58,15 +58,15 @@ namespace meta{ const size_t CONFIG_FLAGS_MAX = 5; - template struct Flag { typedef Flag ID; }; + template struct Flag { typedef Flag ID; }; template<> struct Flag<0> { typedef NullType ID; }; - template< char f1=0 - , char f2=0 - , char f3=0 - , char f4=0 - , char f5=0 + template< uint f1=0 + , uint f2=0 + , uint f3=0 + , uint f4=0 + , uint f5=0 > struct Flags { @@ -81,11 +81,11 @@ namespace meta{ }; - template< char f1=0 - , char f2=0 - , char f3=0 - , char f4=0 - , char f5=0 + template< uint f1=0 + , uint f2=0 + , uint f3=0 + , uint f4=0 + , uint f5=0 > struct Config ///< distinct type representing a configuration { @@ -95,15 +95,15 @@ namespace meta{ - template + template struct ConfigSetFlag; ///< set (prepend) the Flag to the given config - template< char Fl - , char f1 - , char f2 - , char f3 - , char f4 - , char IGN + template< uint Fl + , uint f1 + , uint f2 + , uint f3 + , uint f4 + , uint IGN > struct ConfigSetFlag > { @@ -119,7 +119,7 @@ namespace meta{ typedef CONF Config; typedef Config Type; }; - template + template struct BuildConfigFromFlags< Node,FLAGS>, CONF> { typedef typename ConfigSetFlag< Fl @@ -134,8 +134,8 @@ namespace meta{ namespace { - /** helper comparing enum values and chars (flags) */ - template + /** helper comparing enum values and flags */ + template struct maxC { enum{ VAL = ii < jj? jj : ii }; @@ -157,7 +157,7 @@ namespace meta{ template struct FlagInfo; - template + template struct FlagInfo, FLAGS> > { enum{ BITS = maxC< ff, FlagInfo::BITS> ::VAL diff --git a/src/proc/engine/nodeoperation.hpp b/src/proc/engine/nodeoperation.hpp index a715353bf..7e48b5763 100644 --- a/src/proc/engine/nodeoperation.hpp +++ b/src/proc/engine/nodeoperation.hpp @@ -282,7 +282,7 @@ namespace config { ///////////////////////////: but BufferProvider selection is going to be solved differently anyway, see Ticket #249 template struct SelectBuffProvider { typedef AllocBufferFromParent Type; }; - template + template struct SelectBuffProvider< Config > { typedef AllocBufferFromCache Type; }; @@ -290,7 +290,7 @@ namespace config { struct Strategy ; - template + template struct Strategy< Config > : QueryCache< AllocBufferTable< @@ -302,7 +302,7 @@ namespace config { OperationBase > > > > > > > { }; - template + template struct Strategy< Config > : AllocBufferTable< PullInput< diff --git a/tests/lib/meta/config-flags-test.cpp b/tests/lib/meta/config-flags-test.cpp index 87649556f..9319a4e39 100644 --- a/tests/lib/meta/config-flags-test.cpp +++ b/tests/lib/meta/config-flags-test.cpp @@ -102,7 +102,7 @@ namespace test { template<> struct Maybe : Indeed { enum{ CODE = 10 }; }; template<> struct Maybe : Indeed { enum{ CODE = 30 }; }; - template + template struct Maybe > { typedef Yes_t is_defined; diff --git a/tests/lib/meta/typelist-diagnostics.hpp b/tests/lib/meta/typelist-diagnostics.hpp index 721498c45..d55a84fe2 100644 --- a/tests/lib/meta/typelist-diagnostics.hpp +++ b/tests/lib/meta/typelist-diagnostics.hpp @@ -22,6 +22,7 @@ /** @file typelist-diagnostics.hpp + ** Support for writing metaprogramming unit-tests dealing with typelists and flags. ** a Printer template usable for debugging the structure of a typelist built ** upon some simple debugging-style types. Examples being a Num template, ** or the Flag type. A Printer type generated from this template provides @@ -58,9 +59,9 @@ namespace meta { /** dummy interface / baseclass for diagnostics */ struct Numz { - char o_; - Numz (char x =0) : o_(x) { } - operator char () const { return o_; } + uint o_; + Numz (uint x =0) : o_(x) { } + operator uint () const { return o_; } }; @@ -72,18 +73,18 @@ namespace meta { { enum{ VAL=I }; - Num (char x = char(I)) : Numz(x) { } + Num (uint x = uint(I)) : Numz(x) { } }; /* some forwards used by config-flags-test.cpp */ - template struct Flag; - template< char f1 - , char f2 - , char f3 - , char f4 - , char f5 + template struct Flag; + template< uint f1 + , uint f2 + , uint f3 + , uint f4 + , uint f5 > struct Config; @@ -97,7 +98,7 @@ namespace meta { - namespace test { //< unit tests covering typelist manipulating templates + namespace test { // unit tests covering typelist manipulating templates namespace { // hidden internals for diagnostics.... using boost::format; @@ -129,7 +130,7 @@ namespace meta { static string print () { return str( fmt % uint(Num::VAL) % BASE::print()); } }; - template + template struct Printer, BASE> ///< display the presence of a Flag in the typelist : BASE { @@ -168,7 +169,7 @@ namespace meta { } }; - template + template struct Printer, BASE> : BASE {