From: g0dil Date: Wed, 11 Jun 2008 14:55:45 +0000 (+0000) Subject: Utils/Exception: Fix small (non-backtrace :-) ) problem when running test under final=1 X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=96bb4084fc4493a7a2686d02a895bce1160d61d6;p=senf.git Utils/Exception: Fix small (non-backtrace :-) ) problem when running test under final=1 Utils/mpl.hh: Add SENF_MPL_SLOT_NOEXPAND support Packets/ParseHelpers.doc: Add documentation about pretty-printing preprocessed code git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@877 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Packets/ParseHelpers.dox b/Packets/ParseHelpers.dox index c0c7981..2ff88af 100644 --- a/Packets/ParseHelpers.dox +++ b/Packets/ParseHelpers.dox @@ -21,10 +21,25 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \page parsermacro_expand_example Example macro-expansion of packet parser helper macros - + + Debugging the packet parser makros is somwhat difficult since the makro expansion will place + everything in a single line. To help pin down problems, I use + +
+    $ g++ -DSENF_MPL_SLOT_NOEXPAND -o .ii -E -DSENF_DEBUG -Iinclude .cc
+    $ sed -i -e 's/}/}\\n/g' -e '/^#.*$/d' .ii
+    $ astyle --style=linux -b .ii
+    
+ + I normally just cut-and-paste the \c g++ command from a normal build and add + -DSENF_MPL_SLOT_NOEXPAND. \c astyle is found at http://astyle.sourceforge.net/. If + needed, I then reissue this file (the precessed \.ii file) back to the compiler using the + original commandline (just replacing the \c .cc with \c .ii) to get error messages with + meaningful line numbers. + The following packet parser definition (taken from VariantParser.test.cc) has been subject to - macro-expansion (and a lot of reformatting) to show the inner workings of the packet parser - macros: + macro-expansion (and a lot of manual reformatting) to show the inner workings of the packet + parser macros: \code struct TestParser : public senf::PacketParserBase { @@ -92,7 +107,7 @@ } public: - size_type type_offset () const + size_type type_offset() const { return field_offset_(static_cast *>(0)) - SENF_MPL_SLOT_GET(bitfield_size); @@ -114,13 +129,13 @@ static size_type const type_group = SENF_MPL_SLOT_GET(group) + 0; SENF_MPL_SLOT_SET(group, type_group); SENF_MPL_SLOT_SET(bitfield_size, type_t::fixed_bytes); - type_t type_ () const + type_t type_() const { return parse (type_offset ()); } public: - type_t::value_type type () const + type_t::value_type type() const { return type_(); } @@ -198,7 +213,7 @@ return parse(content__offset()); } template < class T > - T content__dispatch (boost::false_type) const + T content__dispatch(boost::false_type) const { return parse(type(), content__offset()); } @@ -208,7 +223,7 @@ return content__dispatch( boost::integral_constant()); } - content__t content_ () const + content__t content_() const { return content__ (); } @@ -236,7 +251,7 @@ // ///////////////////////////////////////////////////////////////////////// // SENF_PARSER_FINALIZE(TestParser); - void defaultInit () const + void defaultInit() const { init_chain(static_cast *>(0)); } diff --git a/Utils/Exception.test.cc b/Utils/Exception.test.cc index 7706bcd..58a2f2b 100644 --- a/Utils/Exception.test.cc +++ b/Utils/Exception.test.cc @@ -58,7 +58,9 @@ BOOST_AUTO_UNIT_TEST(wrapException) } } catch (std::exception const & ex) { +#ifdef SENF_DEBUG BOOST_CHECK( std::string(ex.what()).find("-- \n") != std::string::npos ); +#endif BOOST_CHECK( std::string(ex.what()).find("special exception") != std::string::npos ); throw; } diff --git a/Utils/mpl.hh b/Utils/mpl.hh index 5f17c68..f33ca7e 100644 --- a/Utils/mpl.hh +++ b/Utils/mpl.hh @@ -156,6 +156,8 @@ namespace mpl { */ template struct take_class {}; +#ifndef SENF_MPL_SLOT_NOEXPAND + /** \brief Define MPL slot The slot macros \ref SENF_MPL_SLOT_DEF(), \ref SENF_MPL_SLOT_SET() and \ref @@ -220,6 +222,8 @@ namespace mpl { # define SENF_MPL_SLOT_GET(name) \ SENF_MPL_SLOT_I_GET(name) +#endif + }} ///////////////////////////////hh.e////////////////////////////////////////