Packets: Clean up ParseHelpers implementation
g0dil [Tue, 16 Oct 2007 09:03:38 +0000 (09:03 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@463 270642c3-0616-0410-b53a-bc976706d245

Packets/MPEGDVBBundle/DatagramSection.hh
Packets/PacketParser.hh
Packets/ParseHelpers.hh
Packets/ParseHelpers.ih
Packets/parse_fixed_setup.hh
Packets/parse_setup.hh

index 4ca4110..9873b03 100644 (file)
@@ -54,7 +54,7 @@ namespace senf {
         SENF_PARSE_FIELD( mac_addr_2, Parse_UInt8 );
         SENF_PARSE_FIELD( mac_addr_1, Parse_UInt8 );
 
-        SENF_PARSER_FINALIZE_INHERITED(Parse_DatagramSection, Parse_DSMCCSection);
+        SENF_PARSER_FINALIZE(Parse_DatagramSection);
 
         typedef Parse_UIntField < 2,  4 > Parse_payload_scrmbl_ctrl;
         typedef Parse_UIntField < 4,  6 > Parse_addr_scrmbl_ctrl;
index b3e2996..3585280 100644 (file)
@@ -241,6 +241,7 @@ namespace senf {
         typedef detail::packet::difference_type difference_type; ///< Signed integral type
         typedef detail::packet::byte byte; ///< Unsigned 8bit value, the raw value type
         typedef PacketData * state_type; ///< Type of the 'state' parameter
+        typedef PacketParserBase parser_base_type; ///< Base type of the next parser
 
         ///////////////////////////////////////////////////////////////////////////
         ///\name Structors and default members
index 905aaf6..9fc6cc0 100644 (file)
     \ingroup packetparser
  */
 
-#define SENF_FIXED_PARSER() SENF_ABSOLUTE_INCLUDE_PATH(Packets/parse_fixed_setup.hh)
-#define SENF_PARSER()       SENF_ABSOLUTE_INCLUDE_PATH(Packets/parse_setup.hh)
-
-#define SENF_FIXED_PARSER_INITIALIZE()                                                            \
-    private:                                                                                      \
-        SENF_MPL_SLOT_DEF_ZERO(index);                                                            \
-        SENF_MPL_SLOT_DEF_ZERO(offset);                                                           \
-        SENF_MPL_SLOT_DEF_ZERO(bit);                                                              \
-        SENF_MPL_SLOT_DEF_ZERO(bitfield_size);                                                    \
-        void init_chain(senf::mpl::rv<0>*) {}                                                     \
-    public:
-
-#define SENF_PARSER_INITIALIZE()                                                                  \
-    private:                                                                                      \
-        SENF_MPL_SLOT_DEF_ZERO(index);                                                            \
-        SENF_MPL_SLOT_DEF_ZERO(init_bytes);                                                       \
-        SENF_MPL_SLOT_DEF_ZERO(bit);                                                              \
-        SENF_MPL_SLOT_DEF_ZERO(bitfield_size);                                                    \
-        void init_chain(senf::mpl::rv<0>*) {}                                                     \
-        size_type field_offset_(senf::mpl::rv<0>*) const { return 0; }                            \
-    public:
-
-#define SENF_PARSER_FIELD(name, type)              SENF_PARSER_FIELD_I(name, type, var, rw)
-#define SENF_PARSER_FIELD_RO(name, type)           SENF_PARSER_FIELD_I(name, type, var, ro)
-#define SENF_PARSER_CUSTOM_FIELD(name, type, size) SENF_PARSER_CUSTOM_FIELD_I(name, type, size, var)
-
-#define SENF_PARSER_FIXED_FIELD(name, type)              SENF_PARSER_FIELD_I(name, type, fix, rw)
-#define SENF_PARSER_FIXED_FIELD_RO(name, type)           SENF_PARSER_FIELD_I(name, type, fix, ro)
-#define SENF_PARSER_FIXED_CUSTOM_FIELD(name, type, size) SENF_PARSER_CUSTOM_FIELD_I(name, type, size, fix)
-
-#define SENF_PARSER_FIELD_AFTER(name, type, prev)              SENF_PARSER_FIELD_I_AFTER(name, type, prev, var, rw)
-#define SENF_PARSER_FIELD_RO_AFTER(name, type, prev)           SENF_PARSER_FIELD_I_AFTER(name, type, prev, var, ro)
-#define SENF_PARSER_CUSTOM_FIELD_AFTER(name, type, size, prev) SENF_PARSER_CUSTOM_FIELD_I_AFTER(name, type, size, prev, var)
-
-#define SENF_PARSER_FIXED_FIELD_AFTER(name, type, prev)              SENF_PARSER_FIELD_I_AFTER(name, type, prev, fix, rw)
-#define SENF_PARSER_FIXED_FIELD_RO_AFTER(name, type, prev)           SENF_PARSER_FIELD_I_AFTER(name, type, prev, fix, ro)
-#define SENF_PARSER_FIXED_CUSTOM_FIELD_AFTER(name, type, size, prev) SENF_PARSER_CUSTOM_FIELD_I_AFTER(name, type, size, prev, fix)
-
-#define SENF_PARSER_BITFIELD(name, bits, type)    SENF_PARSER_BITFIELD_I(name, bits, type, var, rw)
-#define SENF_PARSER_BITFIELD_RO(name, bits, type) SENF_PARSER_BITFIELD_I(name, bits, type, var, ro)
-
-#define SENF_PARSER_FIXED_BITFIELD(name, bits, type)    SENF_PARSER_BITFIELD_I(name, bits, type, fix, rw)
-#define SENF_PARSER_FIXED_BITFIELD_RO(name, bits, type) SENF_PARSER_BITFIELD_I(name, bits, type, fix, ro)
-
-#define SENF_PARSER_INIT()                                                                        \
-     void init(int)
-
-#define SENF_PARSER_FINALIZE_GENERIC(name, base)                                                  \
-         void defaultInit() {                                                                     \
-             init_chain(static_cast<senf::mpl::rv<SENF_MPL_SLOT_GET(index)>*>(0));                \
-         }                                                                                        \
-         name(data_iterator i, state_type s) : base(i,s) {}                                       \
-    private:                                                                                      \
-         template <class T> void init(T) { defaultInit(); }                                       \
-    public:                                                                                       \
-         void init() { init(0); }
-
-#define SENF_PARSER_FINALIZE_INHERITED_DYNAMIC(name, base)                                        \
-    SENF_PARSER_FINALIZE_GENERIC(name, base)                                                      \
-    size_type bytes() const {                                                                     \
-        return field_offset_(static_cast<senf::mpl::rv<SENF_MPL_SLOT_GET(index)>*>(0));           \
-    }                                                                                             \
-    static size_type const init_bytes = SENF_MPL_SLOT_GET(init_bytes)
-
-#define SENF_PARSER_FINALIZE_INHERITED_FIXED(name, base)                                          \
-    SENF_PARSER_FINALIZE_GENERIC(name, base)                                                      \
-    static size_type const fixed_bytes = SENF_MPL_SLOT_GET(offset);
-
-#define SENF_PARSER_FINALIZE_FIXED(name)                                                          \
-    SENF_PARSER_FINALIZE_INHERITED_FIXED(name, senf::PacketParserBase)
-
-#define SENF_PARSER_FINALIZE_DYNAMIC(name)                                                        \
-    SENF_PARSER_FINALIZE_INHERITED_DYNAMIC(name, senf::PacketParserBase)
+#define SENF_FIXED_PARSER()     SENF_ABSOLUTE_INCLUDE_PATH(Packets/parse_fixed_setup.hh)
+#define SENF_PARSER()           SENF_ABSOLUTE_INCLUDE_PATH(Packets/parse_setup.hh)
+
+#define SENF_PARSER_INHERIT     BOOST_PP_CAT( SENF_PARSER_INHERIT_     , SENF_PARSER_TYPE )
+
+#define SENF_PARSE_FIELD        BOOST_PP_CAT( SENF_PARSE_FIELD_        , SENF_PARSER_TYPE )
+#define SENF_PARSE_FIELD_RO     BOOST_PP_CAT( SENF_PARSE_FIELD_RO_     , SENF_PARSER_TYPE )
+#define SENF_PARSE_CUSTOM_FIELD BOOST_PP_CAT( SENF_PARSE_CUSTOM_FIELD_ , SENF_PARSER_TYPE )
+#define SENF_PARSE_BITFIELD     BOOST_PP_CAT( SENF_PARSE_BITFIELD_     , SENF_PARSER_TYPE )
+#define SENF_PARSE_BITFIELD_RO  BOOST_PP_CAT( SENF_PARSE_BITFIELD_RO_  , SENF_PARSER_TYPE )
+
+#define SENF_PARSER_FINALIZE    BOOST_PP_CAT( SENF_PARSER_FINALIZE_    , SENF_PARSER_TYPE )
+
+#define SENF_PARSER_SKIP        BOOST_PP_CAT( SENF_PARSER_SKIP_        , SENF_PARSER_TYPE )
+#define SENF_PARSER_GOTO        BOOST_PP_CAT( SENF_PARSER_GOTO_        , SENF_PARSER_TYPE )
+#define SENF_PARSER_GOTO_OFFSET BOOST_PP_CAT( SENF_PARSER_GOTO_OFFSET_ , SENF_PARSER_TYPE )
+#define SENF_PARSER_LABEL       BOOST_PP_CAT( SENF_PARSER_LABEL_       , SENF_PARSER_TYPE )
+
+#define SENF_PARSER_INIT()      void init(int)
 
 ///////////////////////////////hh.e////////////////////////////////////////
 #endif
index bebd898..8b76054 100644 (file)
 #
 # // Custom includes
 # include <boost/preprocessor/cat.hpp>
-# include <boost/preprocessor/facilities/expand.hpp>
 # include "../Utils/mpl.hh"
 #
 # ////////////////////////////////ih.p///////////////////////////////////////
 #
+# ///////////////////////////////////////////////////////////////////////////
+# // SENF_PARSER_INITIALIZE
+#
+# define SENF_PARSER_INITIALIZE  BOOST_PP_CAT( SENF_PARSER_INITIALIZE_ , SENF_PARSER_TYPE )
+#
+# define SENF_PARSER_INITIALIZE_fix()                                                             \
+    private:                                                                                      \
+        SENF_MPL_SLOT_DEF_ZERO(index);                                                            \
+        SENF_MPL_SLOT_DEF_ZERO(offset);                                                           \
+        SENF_MPL_SLOT_DEF_ZERO(bit);                                                              \
+        SENF_MPL_SLOT_DEF_ZERO(bitfield_size);                                                    \
+        void init_chain(senf::mpl::rv<0>*) {}                                                     \
+    public:
+#
+# define SENF_PARSER_INITIALIZE_var()                                                             \
+    private:                                                                                      \
+        SENF_MPL_SLOT_DEF_ZERO(index);                                                            \
+        SENF_MPL_SLOT_DEF_ZERO(init_bytes);                                                       \
+        SENF_MPL_SLOT_DEF_ZERO(bit);                                                              \
+        SENF_MPL_SLOT_DEF_ZERO(bitfield_size);                                                    \
+        void init_chain(senf::mpl::rv<0>*) {}                                                     \
+        size_type field_offset_(senf::mpl::rv<0>*) const { return 0; }                            \
+    public:
+#
+# ///////////////////////////////////////////////////////////////////////////
+# // SENF_PARSER_INHERIT_*
+#
+# define SENF_PARSER_INHERIT_var(name)                                                            \
+        typedef name parser_base_type;                                                            \
+    private:                                                                                      \
+        SENF_MPL_SLOT_SET(index, 1);                                                              \
+        SENF_MPL_SLOT_SET(init_bytes, senf::init_bytes<name>::value);                             \
+        size_type field_offset_(senf::mpl::rv<1>*) const {                                        \
+            return senf::bytes( *static_cast<name*>(this) );                                      \
+        }                                                                                         \
+        void init_chain(senf::mpl::rv<inherit_index_>*) {                                         \
+            name::init();                                                                         \
+        }                                                                                         \
+    public:
+#
+# define SENF_PARSER_INHERIT_fix(name)                                                            \
+        typedef name parser_base_type;                                                            \
+    private:                                                                                      \
+        SENF_MPL_SLOT_SET(offset, name::fixed_bytes);                                             \
+        SENF_MPL_SLOT_SET(index, 1);                                                              \
+        void init_chain(senf::mpl::rv<1>*) {                                                      \
+            name::init();                                                                         \
+        }                                                                                         \
+    public:
+#
+# ///////////////////////////////////////////////////////////////////////////
+# // SENF_PARSE_FIELD_*
+#
+# define SENF_PARSE_FIELD_var(name, type)    SENF_PARSER_FIELD_I(name, type, var, rw)
+# define SENF_PARSE_FIELD_RO_var(name, type) SENF_PARSER_FIELD_I(name, type, var, ro)
+#
+# define SENF_PARSE_FIELD_fix(name, type)    SENF_PARSER_FIELD_I(name, type, fix, rw)
+# define SENF_PARSE_FIELD_RO_fix(name, type) SENF_PARSER_FIELD_I(name, type, fix, ro)
+#
+# define SENF_PARSER_FIELD_I(name, type, ofstype, rwtype)                                         \
+        SENF_PARSER_I_BITFIELD_RESET()                                                            \
+        SENF_PARSER_I_FIELD_INTRO(name, type)                                                     \
+        BOOST_PP_CAT(SENF_PARSER_I_FIELD_INIT_, rwtype) (name, type)                              \
+        BOOST_PP_CAT(SENF_PARSER_I_FIELD_OFS_, ofstype) (name, type)                              \
+        BOOST_PP_CAT(SENF_PARSER_I_ADVANCE_OFS_, ofstype) (                                       \
+            name, type,                                                                           \
+            BOOST_PP_CAT(SENF_PARSER_I_SIZE_, ofstype) (name, type),                              \
+            BOOST_PP_CAT(SENF_PARSER_I_INITBYTES_, ofstype) (name, type) )                        \
+        BOOST_PP_CAT(SENF_PARSER_I_FIELD_VAL_, rwtype) (name, type, ofstype)
+#
+# ////////////////////////////////////////
+# // SENF_PARSER_I_FIELD_INTRO
+#
 # define SENF_PARSER_I_FIELD_INTRO(name, type)                                                    \
         typedef type BOOST_PP_CAT(name, _t);                                                      \
         static size_type const BOOST_PP_CAT(name,_index) = SENF_MPL_SLOT_GET(index)+1;            \
         SENF_MPL_SLOT_SET(index, BOOST_PP_CAT(name,_index));                                      \
     public:
 #
+# ////////////////////////////////////////
+# // SENF_PARSER_I_FIELD_INIT_*
+#
 # define SENF_PARSER_I_FIELD_INIT_rw(name, type)                                                  \
     private:                                                                                      \
         void init_chain(senf::mpl::rv<BOOST_PP_CAT(name,_index)>*) {                              \
         }                                                                                         \
     public:
 #
+# define SENF_PARSER_I_FIELD_OFS_var(name, type)                                                  \
+        size_type BOOST_PP_CAT(name,_offset)() const {                                            \
+            return field_offset_(static_cast<senf::mpl::rv<BOOST_PP_CAT(name,_index)-1>*>(0));    \
+        }
+#
+# ////////////////////////////////////////
+# // SENF_PARSER_I_FIELD_OFS_*
+#
+# define SENF_PARSER_I_FIELD_OFS_fix(name, type)                                                  \
+        static size_type const BOOST_PP_CAT(name, _offset) = SENF_MPL_SLOT_GET(offset);
+#
+# define SENF_PARSER_FINALIZE_GENERIC(name)                                                       \
+         void defaultInit() {                                                                     \
+             init_chain(static_cast<senf::mpl::rv<SENF_MPL_SLOT_GET(index)>*>(0));                \
+         }                                                                                        \
+         name(data_iterator i, state_type s) : parser_base_type(i,s) {}                           \
+    private:                                                                                      \
+         template <class T> void init(T) { defaultInit(); }                                       \
+    public:                                                                                       \
+         void init() { init(0); }
+#
+# ////////////////////////////////////////
+# // SENF_PARSER_I_ADVANCE_OFS_*
+#
 # define SENF_PARSER_I_SIZE_var(name, type) senf::bytes(name())
 # define SENF_PARSER_I_INITBYTES_var(name, type) senf::init_bytes<type>::value
 #
+# define SENF_PARSER_I_SIZE_fix(name, type) type::fixed_bytes
+# define SENF_PARSER_I_INITBYTES_fix(name, type) void
+#
 # define SENF_PARSER_I_ADVANCE_OFS_var(name, type, size, isize)                                   \
-    private:                                                                                      \
         size_type BOOST_PP_CAT(name, _next_offset)() const {                                      \
             return BOOST_PP_CAT(name,_offset)() + size;                                           \
         }                                                                                         \
+        static size_type const BOOST_PP_CAT(name, _init_bytes) = SENF_MPL_SLOT_GET(init_bytes);   \
+        static size_type const BOOST_PP_CAT(name, _next_init_bytes) =                             \
+            BOOST_PP_CAT(name, _init_bytes) + isize;                                              \
+    private:                                                                                      \
         size_type field_offset_(senf::mpl::rv<BOOST_PP_CAT(name,_index)>*) const {                \
             return BOOST_PP_CAT(name, _next_offset)();                                            \
         }                                                                                         \
-        SENF_MPL_SLOT_SET(init_bytes, SENF_MPL_SLOT_GET(init_bytes) + isize);                     \
+        SENF_MPL_SLOT_SET(init_bytes, BOOST_PP_CAT(name,_next_init_bytes));                       \
     public:
 #
-# define SENF_PARSER_I_FIELD_OFS_var(name, type)                                                  \
-        size_type BOOST_PP_CAT(name,_offset)() const {                                            \
-            return field_offset_(static_cast<senf::mpl::rv<BOOST_PP_CAT(name,_index)-1>*>(0));    \
-        }
-#
-# define SENF_PARSER_I_FIELD_OFS_AFTER_var(name, type, prev)                                      \
-        size_type BOOST_PP_CAT(name,_offset)() const {                                            \
-            return BOOST_PP_CAT(prev,_next_offset)();                                             \
-        }
-#
-# define SENF_PARSER_I_SIZE_fix(name, type) type::fixed_bytes
-# define SENF_PARSER_I_INITBYTES_fix(name, type) void
-#
 # define SENF_PARSER_I_ADVANCE_OFS_fix(name, type, size, isize)                                   \
-    private:                                                                                      \
         static size_type const BOOST_PP_CAT(name, _next_offset) =                                 \
             BOOST_PP_CAT(name, _offset) + size;                                                   \
+    private:                                                                                      \
         SENF_MPL_SLOT_SET(offset, BOOST_PP_CAT(name, _next_offset));                              \
     public:
 #
-# define SENF_PARSER_I_FIELD_OFS_fix(name, type)                                                  \
-        static size_type const BOOST_PP_CAT(name, _offset) = SENF_MPL_SLOT_GET(offset);
-#
-# define SENF_PARSER_I_FIELD_OFS_AFTER_fix(name, type, prev)                                      \
-        static size_type const BOOST_PP_CAT(name, _offset) = BOOST_PP_CAT(prev, _next_offset);
+# ////////////////////////////////////////
+# // SENF_PARSER_I_FIELD_VAL_*
 #
 # define SENF_PARSER_I_MAYBECALL_var() ()
 # define SENF_PARSER_I_MAYBECALL_fix()
                     .value()                                                                      \
         }
 #
-# define SENF_PARSER_FIELD_I(name, type, ofstype, rwtype)                                         \
-        SENF_PARSER_I_BITFIELD_RESET()                                                            \
-        SENF_PARSER_I_FIELD_INTRO(name, type)                                                     \
-        BOOST_PP_CAT(SENF_PARSER_I_FIELD_INIT_, rwtype) (name, type)                              \
-        BOOST_PP_CAT(SENF_PARSER_I_FIELD_OFS_, ofstype) (name, type)                              \
-        BOOST_PP_CAT(SENF_PARSER_I_ADVANCE_OFS_, ofstype) (                                       \
-            name, type,                                                                           \
-            BOOST_PP_CAT(SENF_PARSER_I_SIZE_, ofstype) (name, type),                              \
-            BOOST_PP_CAT(SENF_PARSER_I_INITBYTES_, ofstype) (name, type) )                        \
-        BOOST_PP_CAT(SENF_PARSER_I_FIELD_VAL_, rwtype) (name, type, ofstype)
+# ///////////////////////////////////////////////////////////////////////////
+# // SENF_PARSE_CUSTOM_FIELD_*
 #
-# define SENF_PARSER_FIELD_I_AFTER(name, type, prev, ofstype, rwtype)                             \
-        SENF_PARSER_I_BITFIELD_RESET()                                                            \
-        SENF_PARSER_I_FIELD_INTRO(name, type)                                                     \
-        BOOST_PP_CAT(SENF_PARSER_I_FIELD_INIT_, rwtype) (name, type)                              \
-        BOOST_PP_CAT(SENF_PARSER_I_FIELD_OFS_AFTER_, ofstype) (name, type, prev);                 \
-        BOOST_PP_CAT(SENF_PARSER_I_ADVANCE_OFS_, ofstype) (                                       \
-            name, type,                                                                           \
-            BOOST_PP_CAT(SENF_PARSER_I_SIZE_, ofstype) (name, type),                              \
-            BOOST_PP_CAT(SENF_PARSER_I_INITBYTES_, ofstype) (name, type) )                        \
-        BOOST_PP_CAT(SENF_PARSER_I_FIELD_VAL_, rwtype) (name, type, ofstype)
+# define SENF_PARSE_CUSTOM_FIELD_var(name, type, size, isize)                                     \
+      SENF_PARSER_CUSTOM_FIELD_I(name, type, size, isize, var)
+# define SENF_PARSE_CUSTOM_FIELD_fix(name, type, size)                                            \
+      SENF_PARSER_CUSTOM_FIELD_I(name, type, size, size, fix)
 #
 # define SENF_PARSER_CUSTOM_FIELD_I(name, type, size, isize, ofstype)                             \
         SENF_PARSER_I_BITFIELD_RESET()                                                            \
         BOOST_PP_CAT(SENF_PARSER_I_ADVANCE_OFS_, ofstype) (name, type, size, isize)               \
         BOOST_PP_CAT(name, _t) name() const
 #
-# define SENF_PARSER_CUSTOM_FIELD_I_AFTER(name, type, size, isize, prev, ofstype)                 \
-        SENF_PARSER_I_BITFIELD_RESET()                                                            \
-        SENF_PARSER_I_FIELD_INTRO(name, type)                                                     \
-        SENF_PARSER_I_FIELD_INIT_ro(name, type)                                                   \
-        BOOST_PP_CAT(SENF_PARSER_I_FIELD_OFS_AFTER, ofstype) (name, type, prev)                   \
-        BOOST_PP_CAT(SENF_PARSER_I_ADVANCE_OFS_, ofstype) (name, type, size)                      \
-        BOOST_PP_CAT(name, _t) name() const
+# ///////////////////////////////////////////////////////////////////////////
+# // SENF_PARSE_BITFIELD_*
 #
-# define SENF_PARSER_I_BITFIELD_RESET()                                                           \
-        SENF_MPL_SLOT_SET(bit, 0);                                                                \
-        SENF_MPL_SLOT_SET(bitfield_size, 0);
+# define SENF_PARSE_BITFIELD_var(name, bits, type)                                                \
+      SENF_PARSER_BITFIELD_I(name, bits, type, var, rw)
+# define SENF_PARSE_BITFIELD_RO_var(name, bits, type)                                             \
+      SENF_PARSER_BITFIELD_I(name, bits, type, var, ro)
+#
+# define SENF_PARSE_BITFIELD_fix(name, bits, type)                                                \
+      SENF_PARSER_BITFIELD_I(name, bits, type, fix, rw)
+# define SENF_PARSE_BITFIELD_RO_fix(name, bits, type)                                             \
+      SENF_PARSER_BITFIELD_I(name, bits, type, fix, ro)
+#
+# ////////////////////////////////////////
+# // SENF_PARSER_BITFIELD_I
+#
+# define SENF_PARSER_BITFIELD_TYPE_signed(start, bits)   senf::Parse_IntField<start, start+bits>
+# define SENF_PARSER_BITFIELD_TYPE_unsigned(start, bits) senf::Parse_UIntField<start, start+bits>
+# define SENF_PARSER_BITFIELD_TYPE_bool(start, bits)     senf::Parse_Flag<start>
 #
 # define SENF_PARSER_BITFIELD_I(name, bits, type, ofstype, rwtype)                                \
         static size_type const BOOST_PP_CAT(name, _bit) = SENF_MPL_SLOT_GET(bit);                 \
     public:                                                                                       \
         SENF_PARSER_BITFIELD_II( name, bits, BOOST_PP_CAT(name, _bit_t), ofstype, rwtype)
 #
-# define SENF_PARSER_BITFIELD_TYPE_signed(start, bits)   senf::Parse_IntField<start, start+bits>
-# define SENF_PARSER_BITFIELD_TYPE_unsigned(start, bits) senf::Parse_UIntField<start, start+bits>
-# define SENF_PARSER_BITFIELD_TYPE_bool(start, bits)     senf::Parse_Flag<start>
-#
 # define SENF_PARSER_BITFIELD_II(name, bits, type, ofstype, rwtype)                               \
          SENF_PARSER_I_FIELD_INTRO(name, type)                                                    \
          SENF_PARSER_I_FIELD_INIT_ro(name, type)                                                  \
     public:                                                                                       \
          BOOST_PP_CAT(SENF_PARSER_I_FIELD_VAL_, rwtype) (name, type, ofstype)
 #
+# ////////////////////////////////////////
+# // SENF_PARSER_I_BITFIELD_OFS_*
+#
 # define SENF_PARSER_I_BITFIELD_OFS_var(name, type)                                               \
         size_type BOOST_PP_CAT(name,_offset)() const {                                            \
             return field_offset_(static_cast<senf::mpl::rv<BOOST_PP_CAT(name,_index)-1>*>(0))     \
         static size_type const BOOST_PP_CAT(name, _offset) = SENF_MPL_SLOT_GET(offset)            \
             - SENF_MPL_SLOT_GET(bitfield_size);
 #
-# define SENF_PARSER_INHERIT_I(name)                                                              \
-    private:                                                                                      \
-        SENF_MPL_SLOT_SET(index, 1);                                                              \
-        SENF_MPL_SLOT_SET(init_bytes, senf::init_bytes<name>::value);                             \
-        size_type field_offset_(senf::mpl::rv<1>*) const {                                        \
-            return senf::bytes( *static_cast<name*>(this) );                                      \
-        }                                                                                         \
-        void init_chain(senf::mpl::rv<inherit_index_>*) {                                         \
-            name::init();                                                                         \
-        }                                                                                         \
-    public:
+# ////////////////////////////////////////
+# // SENF_PARSER_I_BITFIELD_RESET
 #
-# define SENF_PARSER_FIXED_INHERIT_I(name)                                                        \
-    private:                                                                                      \
-        SENF_MPL_SLOT_SET(offset, name::fixed_bytes);                                             \
-        SENF_MPL_SLOT_SET(index, 1);                                                              \
-        void init_chain(senf::mpl::rv<1>*) {                                                      \
-            name::init();                                                                         \
-        }                                                                                         \
-    public:
+# define SENF_PARSER_I_BITFIELD_RESET()                                                           \
+        SENF_MPL_SLOT_SET(bit, 0);                                                                \
+        SENF_MPL_SLOT_SET(bitfield_size, 0);
+#
+# ///////////////////////////////////////////////////////////////////////////
+# // SENF_PARSER_FINALIZE_*
+#
+# define SENF_PARSER_FINALIZE_var(name)                                                           \
+    SENF_PARSER_FINALIZE_GENERIC(name)                                                            \
+    size_type bytes() const {                                                                     \
+        return field_offset_(static_cast<senf::mpl::rv<SENF_MPL_SLOT_GET(index)>*>(0));           \
+    }                                                                                             \
+    static size_type const init_bytes = SENF_MPL_SLOT_GET(init_bytes)
+#
+# define SENF_PARSER_FINALIZE_fix(name)                                                           \
+    SENF_PARSER_FINALIZE_GENERIC(name)                                                            \
+    static size_type const fixed_bytes = SENF_MPL_SLOT_GET(offset);
+#
+# define SENF_PARSER_SKIP_var
+# define SENF_PARSER_SKIP_fix
+#
+# define SENF_PARSER_GOTO_var
+# define SENF_PARSER_GOTO_fix
+#
+# define SENF_PARSER_GOTO_OFFSET_var
+# define SENF_PARSER_GOTO_OFFSET_fix
 #
+# define SENF_PARSER_LABEL_var
+# define SENF_PARSER_LABEL_fix
 #
 # ////////////////////////////////ih.e///////////////////////////////////////
 # endif
index a714b9d..68b38f5 100644 (file)
 /** \file
     \brief parse_fixed_setup public header */
 
-#ifdef SENF_PARSER_SETUP_INCLUDED
-#  undef SENF_PARSE_FIELD
-#  undef SENF_PARSE_FIELD_RO
-#  undef SENF_PARSE_FIELD_AFTER
-#  undef SENF_PARSE_FIELD_AFTER_RO
-#  undef SENF_PARSE_CUSTOM_FIELD
-#  undef SENF_PARSE_CUSTOM_FIELD_AFTER
-#  undef SENF_PARSE_BITFIELD
-#  undef SENF_PARSE_BITFIELD_RO
-#  undef SENF_PARSER_INHERIT
-#  undef SENF_PARSER_FINALIZE
-#  undef SENF_PARSER_FINALIZE_INHERITED
-#  undef SENF_PARSER_SETUP_INCLUDED
+#ifdef SENF_PARSER_TYPE
+#  undef SENF_PARSER_TYPE
 #endif
 
-#define SENF_PARSE_FIELD              SENF_PARSER_FIXED_FIELD
-#define SENF_PARSE_FIELD_RO           SENF_PARSER_FIXED_FIELD_RO
-#define SENF_PARSE_FIELD_AFTER        SENF_PARSER_FIXED_FIELD_AFTER
-#define SENF_PARSE_FIELD_AFTER_RO     SENF_PARSER_FIXED_FIELD_AFTER_RO
-#define SENF_PARSE_CUSTOM_FIELD       SENF_PARSER_FIXED_CUSTOM_FIELD
-#define SENF_PARSE_CUSTOM_FIELD_AFTER SENF_PARSER_FIXED_CUSTOM_FIELD_AFTER
-#define SENF_PARSE_BITFIELD           SENF_PARSER_FIXED_BITFIELD
-#define SENF_PARSE_BITFIELD_RO        SENF_PARSER_FIXED_BITFIELD_RO
+#define SENF_PARSER_TYPE fix
 
-#define SENF_PARSER_INHERIT           SENF_PARSER_FIXED_INHERIT_I
-#define SENF_PARSER_FINALIZE          SENF_PARSER_FINALIZE_FIXED
-#define SENF_PARSER_FINALIZE_INHERITED SENF_PARSER_FINALIZE_INHERITED_FIXED
-
-#define SENF_PARSER_SETUP_INCLUDED 1
-
-SENF_FIXED_PARSER_INITIALIZE()
+SENF_PARSER_INITIALIZE()
 
 \f
 // Local Variables:
index b097271..8154485 100644 (file)
 /** \file
     \brief parse_setup public header */
 
-#ifdef SENF_PARSER_SETUP_INCLUDED
-#  undef SENF_PARSE_FIELD
-#  undef SENF_PARSE_FIELD_RO
-#  undef SENF_PARSE_FIELD_AFTER
-#  undef SENF_PARSE_FIELD_AFTER_RO
-#  undef SENF_PARSE_CUSTOM_FIELD
-#  undef SENF_PARSE_CUSTOM_FIELD_AFTER
-#  undef SENF_PARSE_BITFIELD
-#  undef SENF_PARSE_BITFIELD_RO
-#  undef SENF_PARSER_INHERIT
-#  undef SENF_PARSER_FINALIZE
-#  undef SENF_PARSER_FINALIZE_INHERITED
-#  undef SENF_PARSER_SETUP_INCLUDED
+#ifdef SENF_PARSER_TYPE
+#  undef SENF_PARSER_TYPE
 #endif
 
-#define SENF_PARSE_FIELD              SENF_PARSER_FIELD
-#define SENF_PARSE_FIELD_RO           SENF_PARSER_FIELD_RO
-#define SENF_PARSE_FIELD_AFTER        SENF_PARSER_FIELD_AFTER
-#define SENF_PARSE_FIELD_AFTER_RO     SENF_PARSER_FIELD_AFTER_RO
-#define SENF_PARSE_CUSTOM_FIELD       SENF_PARSER_CUSTOM_FIELD
-#define SENF_PARSE_CUSTOM_FIELD_AFTER SENF_PARSER_CUSTOM_FIELD_AFTER
-#define SENF_PARSE_BITFIELD           SENF_PARSER_BITFIELD
-#define SENF_PARSE_BITFIELD_RO        SENF_PARSER_BITFIELD_RO
-
-#define SENF_PARSER_INHERIT           SENF_PARSER_INHERIT_I
-#define SENF_PARSER_FINALIZE          SENF_PARSER_FINALIZE_DYNAMIC
-#define SENF_PARSER_FINALIZE_INHERITED SENF_PARSER_FINALIZE_INHERITED_DYNAMIC
-
-#define SENF_PARSER_SETUP_INCLUDED 1
+#define SENF_PARSER_TYPE var
 
 SENF_PARSER_INITIALIZE()