X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FParseHelpers.dox;h=2ff88af1ddb457f56d0decd4b5871497d0991c13;hb=5443435c4c2b6e4386c5334b5b8358273f2bae93;hp=c0c79810d271e6bb2a561cccf61c1ce8be160955;hpb=734c0be097d831c8b6e1e797bae08262fc9b4dfe;p=senf.git 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)); }