Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59563 - branches/quickbook-1.5-spirit2
From: daniel_james_at_[hidden]
Date: 2010-02-07 04:12:05


Author: danieljames
Date: 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
New Revision: 59563
URL: http://svn.boost.org/trac/boost/changeset/59563

Log:
Separate actions and state.
Added:
   branches/quickbook-1.5-spirit2/state.cpp (contents, props changed)
      - copied, changed from r59562, /branches/quickbook-1.5-spirit2/actions_class.cpp
   branches/quickbook-1.5-spirit2/state.hpp (contents, props changed)
      - copied, changed from r59562, /branches/quickbook-1.5-spirit2/actions_class.hpp
Removed:
   branches/quickbook-1.5-spirit2/actions_class.cpp
   branches/quickbook-1.5-spirit2/actions_class.hpp
Text files modified:
   branches/quickbook-1.5-spirit2/Jamfile.v2 | 2
   branches/quickbook-1.5-spirit2/actions.cpp | 15 ++
   branches/quickbook-1.5-spirit2/actions.hpp | 28 ++++
   branches/quickbook-1.5-spirit2/block.cpp | 4
   branches/quickbook-1.5-spirit2/block_actions.cpp | 94 ++++++++--------
   branches/quickbook-1.5-spirit2/block_list.cpp | 5
   branches/quickbook-1.5-spirit2/boostbook.cpp | 218 ++++++++++++++++++++--------------------
   branches/quickbook-1.5-spirit2/boostbook.hpp | 40 +++---
   branches/quickbook-1.5-spirit2/code_snippet.cpp | 2
   branches/quickbook-1.5-spirit2/doc_info.cpp | 5
   branches/quickbook-1.5-spirit2/doc_info_actions.cpp | 3
   branches/quickbook-1.5-spirit2/fwd.hpp | 2
   branches/quickbook-1.5-spirit2/phrase.cpp | 3
   branches/quickbook-1.5-spirit2/phrase_actions.cpp | 9
   branches/quickbook-1.5-spirit2/phrase_image.cpp | 5
   branches/quickbook-1.5-spirit2/process.cpp | 6
   branches/quickbook-1.5-spirit2/quickbook.cpp | 18 +-
   branches/quickbook-1.5-spirit2/state.cpp | 17 --
   branches/quickbook-1.5-spirit2/state.hpp | 20 --
   branches/quickbook-1.5-spirit2/syntax_highlight.cpp | 10 -
   branches/quickbook-1.5-spirit2/template.cpp | 48 ++++----
   21 files changed, 289 insertions(+), 265 deletions(-)

Modified: branches/quickbook-1.5-spirit2/Jamfile.v2
==============================================================================
--- branches/quickbook-1.5-spirit2/Jamfile.v2 (original)
+++ branches/quickbook-1.5-spirit2/Jamfile.v2 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -22,7 +22,7 @@
     process.cpp
     quickbook.cpp
     actions.cpp
- actions_class.cpp
+ state.cpp
     utils.cpp
     input_path.cpp
     post_process.cpp

Modified: branches/quickbook-1.5-spirit2/actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/actions.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -10,7 +10,7 @@
 =============================================================================*/
 
 #include "actions.hpp"
-#include "actions_class.hpp"
+#include "state.hpp"
 #include "doc_info.hpp"
 #include "utils.hpp"
 
@@ -22,6 +22,17 @@
     unsigned qbk_minor_version = 0;
     unsigned qbk_version_n = 0; // qbk_major_version * 100 + qbk_minor_version
 
+ actions::actions(state& state)
+ : state_(state)
+ , templates(state.templates)
+ , macro(state.macro)
+ , process(*this)
+ , phrase_push(state.phrase)
+ , phrase_pop(state.phrase)
+ , error(state.error_count)
+ , syntax_p(state.source_mode, *this)
+ {}
+
     namespace {
         std::string fully_qualified_id(std::string const& library_id,
             std::string const& qualified_section_id,
@@ -50,7 +61,7 @@
         detail::outwarn(pos.file,pos.line) << "Empty id.\n";
     }
 
- void phrase_push_action::operator()(unused_type, unused_type, unused_type) const
+ void phrase_push_action::operator()() const
     {
         phrase.push();
     }

Modified: branches/quickbook-1.5-spirit2/actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/actions.hpp (original)
+++ branches/quickbook-1.5-spirit2/actions.hpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -55,6 +55,8 @@
         boost::phoenix::function<quickbook_before_impl> qbk_before;
     }
 
+ // TODO: Define this elsewhere?
+
     struct macro {
         macro() {}
         explicit macro(char const* x) : raw_markup(x) {};
@@ -109,7 +111,11 @@
         phrase_push_action(collector& phrase)
             : phrase(phrase) {}
 
- void operator()(unused_type, unused_type, unused_type) const;
+ void operator()(unused_type, unused_type, unused_type) const {
+ return (*this)();
+ }
+
+ void operator()() const;
         
         collector& phrase;
     };
@@ -163,6 +169,26 @@
         
         quickbook::actions& actions;
     };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // actions
+ ///////////////////////////////////////////////////////////////////////////
+
+ struct actions
+ {
+ actions(state&);
+
+ state& state_;
+ template_stack& templates;
+ macro_symbols& macro;
+
+ process_action process;
+ phrase_push_action phrase_push;
+ phrase_pop_action phrase_pop;
+ error_action error;
+ element_id_warning_action element_id_warning;
+ syntax_highlight syntax_p;
+ };
 }
 
 #ifdef BOOST_MSVC

Deleted: branches/quickbook-1.5-spirit2/actions_class.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/actions_class.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
+++ (empty file)
@@ -1,101 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2005 Thomas Guest
- http://spirit.sourceforge.net/
-
- Use, modification and distribution is subject to the Boost Software
- License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-
-#include <boost/filesystem/operations.hpp>
-#include "actions_class.hpp"
-#include "quickbook.hpp"
-
-#if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310))
-#pragma warning(disable:4355)
-#endif
-
-namespace quickbook
-{
- namespace fs = boost::filesystem;
-
- actions::actions(char const* filein_, fs::path const& outdir_, string_stream& out_)
- // header info
- : doc_id()
- , doc_title()
-
- // main output stream
- , phrase(out_)
-
- // state
- , filename(fs::complete(fs::path(filein_, fs::native)))
- , outdir(outdir_)
- , macro()
- , section_level(0)
- , section_id()
- , qualified_section_id()
- , source_mode("c++")
-
- // temporary or global state
- , template_depth(0)
- , templates()
- , error_count(0)
-
- // actions
- , process(*this)
- , phrase_push(phrase)
- , phrase_pop(phrase)
- , error(error_count)
-
- , syntax_p(source_mode, *this)
- {
- // turn off __FILENAME__ macro on debug mode = true
- std::string filename_str = debug_mode ?
- std::string("NO_FILENAME_MACRO_GENERATED_IN_DEBUG_MODE") :
- filename.native_file_string();
-
- // add the predefined macros
- macro.add
- ("__DATE__", quickbook::macro(quickbook_get_date))
- ("__TIME__", quickbook::macro(quickbook_get_time))
- ("__FILENAME__", quickbook::macro(filename_str))
- ;
- }
-
- void actions::push()
- {
- state_stack.push(
- boost::make_tuple(
- filename
- , outdir
- , macro
- , section_level
- , section_id
- , qualified_section_id
- , source_mode
- )
- );
-
- phrase.push();
- templates.push();
- }
-
- void actions::pop()
- {
- boost::tie(
- filename
- , outdir
- , macro
- , section_level
- , section_id
- , qualified_section_id
- , source_mode
- ) = state_stack.top();
- state_stack.pop();
-
- phrase.pop();
- templates.pop();
- }
-}

Deleted: branches/quickbook-1.5-spirit2/actions_class.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/actions_class.hpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
+++ (empty file)
@@ -1,89 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- Use, modification and distribution is subject to the Boost Software
- License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_ACTIONS_CLASS_HPP)
-#define BOOST_SPIRIT_ACTIONS_CLASS_HPP
-
-#include <stack>
-#include <boost/tuple/tuple.hpp>
-#include <boost/filesystem/path.hpp>
-#include "fwd.hpp"
-#include "actions.hpp"
-#include "collector.hpp"
-#include "template.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
- namespace fs = boost::filesystem;
-
- struct actions
- {
- actions(char const* filein_, fs::path const& outdir, string_stream& out_);
-
- ///////////////////////////////////////////////////////////////////////////
- // State
- ///////////////////////////////////////////////////////////////////////////
-
- typedef std::vector<std::string> string_list;
- typedef std::pair<char, int> mark_type;
- static int const max_template_depth = 100;
-
- std::string doc_id;
- std::string doc_title;
-
- // main output stream
- collector phrase;
-
- // state
- fs::path filename;
- fs::path outdir;
- macro_symbols macro;
- int section_level;
- std::string section_id;
- std::string qualified_section_id;
- std::string source_mode;
-
- typedef boost::tuple<
- fs::path
- , fs::path
- , macro_symbols
- , int
- , std::string
- , std::string
- , std::string>
- state_tuple;
-
- std::stack<state_tuple> state_stack;
-
- // temporary or global state
- int template_depth;
- template_stack templates;
- int error_count;
-
- // push/pop the states and the streams
- void push();
- void pop();
-
- ///////////////////////////////////////////////////////////////////////////
- // actions
- ///////////////////////////////////////////////////////////////////////////
- process_action process;
- phrase_push_action phrase_push;
- phrase_pop_action phrase_pop;
- error_action error;
-
- syntax_highlight syntax_p;
-
- element_id_warning_action element_id_warning;
- };
-}
-
-#endif // BOOST_SPIRIT_ACTIONS_CLASS_HPP
-

Modified: branches/quickbook-1.5-spirit2/block.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block.cpp (original)
+++ branches/quickbook-1.5-spirit2/block.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -20,8 +20,8 @@
 #include <boost/fusion/include/adapt_struct.hpp>
 #include "grammars.hpp"
 #include "block.hpp"
-#include "utils.hpp"
-#include "actions_class.hpp"
+#include "template.hpp"
+#include "actions.hpp"
 #include "parse_utils.hpp"
 #include "code.hpp"
 

Modified: branches/quickbook-1.5-spirit2/block_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_actions.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -12,7 +12,8 @@
 #include <boost/assert.hpp>
 #include <boost/filesystem/convenience.hpp>
 #include "block_actions.hpp"
-#include "actions_class.hpp"
+#include "actions.hpp"
+#include "state.hpp"
 #include "quickbook.hpp"
 #include "grammars.hpp"
 #include "code_snippet_types.hpp"
@@ -45,30 +46,30 @@
     begin_section2 process(quickbook::actions& actions, begin_section const& x)
     {
         // TODO: This uses the generated title.
- actions.section_id = x.id ? *x.id :
+ actions.state_.section_id = x.id ? *x.id :
             detail::make_identifier(
                 x.content.raw_markup.begin(),
                 x.content.raw_markup.end());
 
- if (actions.section_level != 0) {
- actions.qualified_section_id += '.';
+ if (actions.state_.section_level != 0) {
+ actions.state_.qualified_section_id += '.';
         }
         else {
- BOOST_ASSERT(actions.qualified_section_id.empty());
+ BOOST_ASSERT(actions.state_.qualified_section_id.empty());
         }
 
- actions.qualified_section_id += actions.section_id;
- ++actions.section_level;
+ actions.state_.qualified_section_id += actions.state_.section_id;
+ ++actions.state_.section_level;
 
         begin_section2 r;
 
         if (qbk_version_n < 103) // version 1.2 and below
         {
- r.id = actions.doc_id + "." + actions.section_id;
+ r.id = actions.state_.doc_id + "." + actions.state_.section_id;
         }
         else // version 1.3 and above
         {
- r.linkend = r.id = actions.doc_id + "." + actions.qualified_section_id;
+ r.linkend = r.id = actions.state_.doc_id + "." + actions.state_.qualified_section_id;
         }
         
         r.content = x.content.content;
@@ -78,26 +79,26 @@
 
     end_section2 process(quickbook::actions& actions, end_section const& x)
     {
- --actions.section_level;
- if (actions.section_level < 0)
+ --actions.state_.section_level;
+ if (actions.state_.section_level < 0)
         {
             detail::outerr(x.position.file,x.position.line)
                 << "Mismatched [endsect] near column " << x.position.column << ".\n";
- ++actions.error_count;
+ ++actions.state_.error_count;
             
             // $$$ TODO: somehow fail parse else BOOST_ASSERT(std::string::npos != n)
             // $$$ below will assert.
         }
- if (actions.section_level == 0)
+ if (actions.state_.section_level == 0)
         {
- actions.qualified_section_id.clear();
+ actions.state_.qualified_section_id.clear();
         }
         else
         {
             std::string::size_type const n =
- actions.qualified_section_id.find_last_of('.');
+ actions.state_.qualified_section_id.find_last_of('.');
             BOOST_ASSERT(std::string::npos != n);
- actions.qualified_section_id.erase(n, std::string::npos);
+ actions.state_.qualified_section_id.erase(n, std::string::npos);
         }
         
         return end_section2();
@@ -112,7 +113,8 @@
         
         r.level = x.level;
         if(r.level < 0) {
- r.level = actions.section_level + 2;// section_level is zero-based. We need to use a
+ r.level = actions.state_.section_level + 2;
+ // section_level is zero-based. We need to use a
                                                 // one-based heading which is one greater
                                                 // than the current. Thus: section_level + 2.
             if (r.level > 6) // The max is h6, clip it if it goes
@@ -121,7 +123,7 @@
 
         if (!new_style) // version 1.2 and below
         {
- r.id = actions.section_id + "." +
+ r.id = actions.state_.section_id + "." +
                 detail::make_identifier(
                     x.content.raw_markup.begin(),
                     x.content.raw_markup.end());
@@ -129,7 +131,7 @@
         else // version 1.3 and above
         {
             r.linkend = r.id = fully_qualified_id(
- actions.doc_id, actions.qualified_section_id,
+ actions.state_.doc_id, actions.state_.qualified_section_id,
                 detail::make_identifier(
                     x.content.raw_markup.begin(),
                     x.content.raw_markup.end()));
@@ -143,7 +145,7 @@
 
     nothing process(quickbook::actions& actions, def_macro const& x)
     {
- actions.macro.add(
+ actions.state_.macro.add(
             x.macro_identifier.begin()
           , x.macro_identifier.end()
           , quickbook::macro(x.content));
@@ -152,10 +154,10 @@
 
     nothing process(quickbook::actions& actions, define_template const& x)
     {
- if(!actions.templates.add(x)) {
+ if(!actions.state_.templates.add(x)) {
             detail::outerr(x.position.file, x.position.line)
                 << "Template Redefinition: " << x.id << std::endl;
- ++actions.error_count;
+ ++actions.state_.error_count;
         }
         
         return nothing();
@@ -169,12 +171,12 @@
         
         if(qbk_version_n >= 105) {
             if(x.id) {
- r.id = fully_qualified_id(actions.doc_id,
- actions.qualified_section_id, *x.id);
+ r.id = fully_qualified_id(actions.state_.doc_id,
+ actions.state_.qualified_section_id, *x.id);
             }
             else if(r.title) {
- r.id = fully_qualified_id(actions.doc_id,
- actions.qualified_section_id,
+ r.id = fully_qualified_id(actions.state_.doc_id,
+ actions.state_.qualified_section_id,
                     detail::make_identifier(x.title.begin(), x.title.end()));
             }
         }
@@ -284,9 +286,9 @@
             fs::path path(x);
             if (!path.is_complete())
             {
- fs::path infile = fs::complete(actions.filename).normalize();
+ fs::path infile = fs::complete(actions.state_.filename).normalize();
                 path = (infile.branch_path() / path).normalize();
- fs::path outdir = fs::complete(actions.outdir).normalize();
+ fs::path outdir = fs::complete(actions.state_.outdir).normalize();
                 path = path_difference(outdir, path);
             }
             return path;
@@ -302,59 +304,59 @@
 
     nothing process(quickbook::actions& actions, include const& x)
     {
- fs::path filein = include_search(actions.filename.branch_path(), x.path);
+ fs::path filein = include_search(actions.state_.filename.branch_path(), x.path);
         std::string doc_id;
 
         // swap the filenames
- std::swap(actions.filename, filein);
+ std::swap(actions.state_.filename, filein);
 
         // save the doc info strings
- actions.doc_id.swap(doc_id);
+ actions.state_.doc_id.swap(doc_id);
 
         // scope the macros
- macro_symbols macro = actions.macro;
+ macro_symbols macro = actions.state_.macro;
         // scope the templates
- //~ template_symbols templates = actions.templates; $$$ fixme $$$
+ //~ template_symbols templates = actions.state_.templates; $$$ fixme $$$
 
         // if an id is specified in this include (as in [include:id foo.qbk])
         // then use it as the doc_id.
- if (x.id) actions.doc_id = *x.id;
+ if (x.id) actions.state_.doc_id = *x.id;
 
         // update the __FILENAME__ macro
- *actions.macro.find("__FILENAME__") =
- quickbook::macro(actions.filename.native_file_string());
+ *actions.state_.macro.find("__FILENAME__") =
+ quickbook::macro(actions.state_.filename.native_file_string());
 
         // parse the file
- quickbook::parse(actions.filename.native_file_string().c_str(), actions, true);
+ quickbook::parse(actions.state_.filename.native_file_string().c_str(), actions, true);
 
         // restore the values
- std::swap(actions.filename, filein);
+ std::swap(actions.state_.filename, filein);
 
- actions.doc_id.swap(doc_id);
+ actions.state_.doc_id.swap(doc_id);
 
         // restore the macros
- actions.macro = macro;
+ actions.state_.macro = macro;
         // restore the templates
- //~ actions.templates = templates; $$$ fixme $$$
+ //~ actions.state_.templates = templates; $$$ fixme $$$
         
         return nothing();
     }
 
     nothing process(quickbook::actions& actions, import const& x)
     {
- fs::path path = include_search(actions.filename.branch_path(), x.path);
+ fs::path path = include_search(actions.state_.filename.branch_path(), x.path);
         std::string ext = fs::extension(path);
         std::vector<define_template> storage;
- actions.error_count +=
- load_snippets(path.string(), storage, ext, actions.doc_id);
+ actions.state_.error_count +=
+ load_snippets(path.string(), storage, ext, actions.state_.doc_id);
 
         BOOST_FOREACH(define_template const& definition, storage)
         {
- if (!actions.templates.add(definition))
+ if (!actions.state_.templates.add(definition))
             {
                 detail::outerr(definition.position.file, definition.position.line)
                     << "Template Redefinition: " << definition.id << std::endl;
- ++actions.error_count;
+ ++actions.state_.error_count;
             }
         }
 

Modified: branches/quickbook-1.5-spirit2/block_list.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_list.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_list.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -10,7 +10,8 @@
 
 #include <stack>
 #include <boost/assert.hpp>
-#include "actions_class.hpp"
+#include "actions.hpp"
+#include "state.hpp"
 #include "gen_types.hpp"
 #include "utils.hpp"
 
@@ -82,7 +83,7 @@
                     << "Illegal change of list style near column " << pos.column << ".\n";
                 detail::outwarn(pos.file,pos.line)
                     << "Ignoring change of list style" << std::endl;
- ++actions.error_count;
+ ++actions.state_.error_count;
             }
         }
 

Modified: branches/quickbook-1.5-spirit2/boostbook.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/boostbook.cpp (original)
+++ branches/quickbook-1.5-spirit2/boostbook.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -3,18 +3,18 @@
 #include "fwd.hpp"
 #include "boostbook.hpp"
 #include "phrase.hpp"
-#include "actions_class.hpp"
+#include "state.hpp"
 
 namespace quickbook
 {
     struct output_action
     {
- output_action(quickbook::actions& actions) : actions(actions) {}
- quickbook::actions& actions;
+ output_action(quickbook::state& state) : state(state) {}
+ quickbook::state& state;
 
         template <typename T>
         void operator()(T const& x) const {
- output(actions, x);
+ output(state, x);
         }
     };
 
@@ -119,45 +119,45 @@
         } initialize_instance;
     }
 
- void output(quickbook::actions& actions, std::string const& x)
+ void output(quickbook::state& state, std::string const& x)
     {
- actions.phrase << x;
+ state.phrase << x;
     }
 
- void output(quickbook::actions& actions, char x)
+ void output(quickbook::state& state, char x)
     {
- actions.phrase << encode(x);
+ state.phrase << encode(x);
     }
 
- void output(quickbook::actions& actions, anchor const& x) {
- actions.phrase << "<anchor id=\"";
- actions.phrase << encode(x.id);
- actions.phrase << "\"/>\n";
+ void output(quickbook::state& state, anchor const& x) {
+ state.phrase << "<anchor id=\"";
+ state.phrase << encode(x.id);
+ state.phrase << "\"/>\n";
     }
 
- void output(quickbook::actions& actions, link const& x) {
+ void output(quickbook::state& state, link const& x) {
         boostbook_markup m = markup_map.at(x.type);
- actions.phrase << m.pre;
- actions.phrase << encode(x.destination);
- actions.phrase << "\">";
- actions.phrase << x.content;
- actions.phrase << m.post;
+ state.phrase << m.pre;
+ state.phrase << encode(x.destination);
+ state.phrase << "\">";
+ state.phrase << x.content;
+ state.phrase << m.post;
     }
 
- void output(quickbook::actions& actions, formatted const& x) {
+ void output(quickbook::state& state, formatted const& x) {
         boostbook_markup m = markup_map.at(x.type);
- actions.phrase << m.pre << x.content << m.post;
+ state.phrase << m.pre << x.content << m.post;
     }
 
- void output(quickbook::actions& actions, break_ const& x) {
+ void output(quickbook::state& state, break_ const& x) {
         boostbook_markup m = markup_map.at("break");
- actions.phrase << m.pre;
+ state.phrase << m.pre;
     }
 
- void output(quickbook::actions& actions, image2 const& x) {
- actions.phrase << "<inlinemediaobject>";
+ void output(quickbook::state& state, image2 const& x) {
+ state.phrase << "<inlinemediaobject>";
 
- actions.phrase << "<imageobject><imagedata";
+ state.phrase << "<imageobject><imagedata";
         
         for(image2::attribute_map::const_iterator
             attr_first = x.attributes.begin(), attr_last = x.attributes.end();
@@ -165,7 +165,7 @@
         {
             if(attr_first->first == "alt") continue;
         
- actions.phrase
+ state.phrase
                 << " "
                 << attr_first->first
                 << "=\""
@@ -173,35 +173,35 @@
                 << "\"";
         }
 
- actions.phrase << "></imagedata></imageobject>";
+ state.phrase << "></imagedata></imageobject>";
 
         image2::attribute_map::const_iterator it = x.attributes.find("alt");
         if(it != x.attributes.end()) {
             // Also add a textobject -- use the basename of the image file.
             // This will mean we get "alt" attributes of the HTML img.
- actions.phrase << "<textobject><phrase>";
- actions.phrase << encode(it->second);
- actions.phrase << "</phrase></textobject>";
+ state.phrase << "<textobject><phrase>";
+ state.phrase << encode(it->second);
+ state.phrase << "</phrase></textobject>";
         }
 
- actions.phrase << "</inlinemediaobject>";
+ state.phrase << "</inlinemediaobject>";
     }
 
- void output(quickbook::actions& actions, hr) {
- actions.phrase << markup_map.at("hr").pre;
+ void output(quickbook::state& state, hr) {
+ state.phrase << markup_map.at("hr").pre;
     }
 
- void output(quickbook::actions& actions, begin_section2 const& x) {
- actions.phrase << "\n<section id=\"" << x.id << "\">\n";
+ void output(quickbook::state& state, begin_section2 const& x) {
+ state.phrase << "\n<section id=\"" << x.id << "\">\n";
         if(x.linkend.empty()) {
- actions.phrase
+ state.phrase
                 << "<title>"
                 << x.content
                 << "</title>\n"
                 ;
         }
         else {
- actions.phrase
+ state.phrase
                 << "<title>"
                 << "<link linkend=\""
                 << x.linkend
@@ -213,169 +213,169 @@
         }
     }
 
- void output(quickbook::actions& actions, end_section2 const& x) {
- actions.phrase << "</section>";
+ void output(quickbook::state& state, end_section2 const& x) {
+ state.phrase << "</section>";
     }
 
- void output(quickbook::actions& actions, heading2 const& x) {
- actions.phrase
+ void output(quickbook::state& state, heading2 const& x) {
+ state.phrase
             << "<anchor id=\"" << x.id << "\"/>"
             << "<bridgehead renderas=\"sect" << x.level << "\">";
 
         if(x.linkend.empty()) {
- actions.phrase << x.content;
+ state.phrase << x.content;
         }
         else {
- actions.phrase
+ state.phrase
                 << "<link linkend=\"" << x.linkend << "\">"
                 << x.content << "</link>";
         }
 
- actions.phrase << "</bridgehead>";
+ state.phrase << "</bridgehead>";
     }
 
- void output(quickbook::actions& actions, variablelist const& x)
+ void output(quickbook::state& state, variablelist const& x)
     {
- actions.phrase << "<variablelist>\n";
+ state.phrase << "<variablelist>\n";
 
- actions.phrase << "<title>";
- actions.phrase << encode(x.title);
- actions.phrase << "</title>\n";
+ state.phrase << "<title>";
+ state.phrase << encode(x.title);
+ state.phrase << "</title>\n";
 
         boostbook_markup m = markup_map.at("varlistentry");
 
         for(std::vector<varlistentry>::const_iterator
             it = x.entries.begin(); it != x.entries.end(); ++it)
         {
- actions.phrase << m.pre;
- std::for_each(it->begin(), it->end(), output_action(actions));
- actions.phrase << m.post;
+ state.phrase << m.pre;
+ std::for_each(it->begin(), it->end(), output_action(state));
+ state.phrase << m.post;
         }
 
- actions.phrase << "</variablelist>\n";
+ state.phrase << "</variablelist>\n";
     }
 
- void output(quickbook::actions& actions, table2 const& x)
+ void output(quickbook::state& state, table2 const& x)
     {
         if (x.title)
         {
- actions.phrase << "<table frame=\"all\"";
+ state.phrase << "<table frame=\"all\"";
             if(x.id)
- actions.phrase << " id=\"" << *x.id << "\"";
- actions.phrase << ">\n";
- actions.phrase << "<title>";
- actions.phrase << encode(*x.title);
- actions.phrase << "</title>";
+ state.phrase << " id=\"" << *x.id << "\"";
+ state.phrase << ">\n";
+ state.phrase << "<title>";
+ state.phrase << encode(*x.title);
+ state.phrase << "</title>";
         }
         else
         {
- actions.phrase << "<informaltable frame=\"all\"";
+ state.phrase << "<informaltable frame=\"all\"";
             if(x.id)
- actions.phrase << " id=\"" << *x.id << "\"";
- actions.phrase << ">\n";
+ state.phrase << " id=\"" << *x.id << "\"";
+ state.phrase << ">\n";
         }
 
         // This is a bit odd for backwards compatability: the old version just
         // used the last count that was calculated.
- actions.phrase << "<tgroup cols=\"" << x.cols << "\">\n";
+ state.phrase << "<tgroup cols=\"" << x.cols << "\">\n";
 
         boostbook_markup m = markup_map.at("row");
 
         if (x.head)
         {
- actions.phrase << "<thead>";
- actions.phrase << m.pre;
- std::for_each(x.head->begin(), x.head->end(), actions.process);
- actions.phrase << m.post;
- actions.phrase << "</thead>\n";
+ state.phrase << "<thead>";
+ state.phrase << m.pre;
+ std::for_each(x.head->begin(), x.head->end(), output_action(state));
+ state.phrase << m.post;
+ state.phrase << "</thead>\n";
         }
 
- actions.phrase << "<tbody>\n";
+ state.phrase << "<tbody>\n";
 
         for(std::vector<table_row>::const_iterator
             it = x.rows.begin(); it != x.rows.end(); ++it)
         {
- actions.phrase << m.pre;
- std::for_each(it->begin(), it->end(), actions.process);
- actions.phrase << m.post;
+ state.phrase << m.pre;
+ std::for_each(it->begin(), it->end(), output_action(state));
+ state.phrase << m.post;
         }
 
- actions.phrase << "</tbody>\n" << "</tgroup>\n";
+ state.phrase << "</tbody>\n" << "</tgroup>\n";
 
         if (x.title)
         {
- actions.phrase << "</table>\n";
+ state.phrase << "</table>\n";
         }
         else
         {
- actions.phrase << "</informaltable>\n";
+ state.phrase << "</informaltable>\n";
         }
     }
 
- void output(quickbook::actions& actions, xinclude2 const& x)
+ void output(quickbook::state& state, xinclude2 const& x)
     {
- actions.phrase << "\n<xi:include href=\"" << x.path << "\" />\n";
+ state.phrase << "\n<xi:include href=\"" << x.path << "\" />\n";
     }
 
- void output(quickbook::actions& actions, list2 const& x)
+ void output(quickbook::state& state, list2 const& x)
     {
- actions.phrase << std::string(x.mark == '#' ? "<orderedlist>\n" : "<itemizedlist>\n");
+ state.phrase << std::string(x.mark == '#' ? "<orderedlist>\n" : "<itemizedlist>\n");
 
         for(std::vector<list_item2>::const_iterator
             it = x.items.begin(), end = x.items.end(); it != end; ++it)
         {
- actions.phrase << "<listitem>\n" << it->content;
- if(!it->sublist.items.empty()) output(actions, it->sublist);
- actions.phrase << std::string("\n</listitem>");
+ state.phrase << "<listitem>\n" << it->content;
+ if(!it->sublist.items.empty()) output(state, it->sublist);
+ state.phrase << std::string("\n</listitem>");
         }
 
- actions.phrase << std::string(x.mark == '#' ? "\n</orderedlist>" : "\n</itemizedlist>");
+ state.phrase << std::string(x.mark == '#' ? "\n</orderedlist>" : "\n</itemizedlist>");
     }
 
- void output(quickbook::actions& actions, code_token const& x)
+ void output(quickbook::state& state, code_token const& x)
     {
         std::string type = x.type;
         if(type == "space") {
- actions.phrase << x.text;
+ state.phrase << x.text;
         }
         else {
- actions.phrase
+ state.phrase
                 << "<phrase role=\"" << x.type << "\">"
                 << encode(x.text)
                 << "</phrase>";
         }
     }
 
- void output(quickbook::actions& actions, doc_info const& info)
+ void output(quickbook::state& state, doc_info const& info)
     {
         // if we're ignoring the document info, we're done.
         if (info.ignore) return;
 
- actions.phrase
+ state.phrase
             << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
             << "<!DOCTYPE library PUBLIC \"-//Boost//DTD BoostBook XML V1.0//EN\""
             << " \"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd\">";
 
         // Document tag
 
- actions.phrase
+ state.phrase
             << '<' << info.doc_type << " id=\"" << info.doc_id << "\"\n";
         
         if(info.doc_type == "library")
         {
- actions.phrase << " name=\"" << info.doc_title << "\"\n";
+ state.phrase << " name=\"" << info.doc_title << "\"\n";
         }
 
         if(!info.doc_dirname.empty())
         {
- actions.phrase << " dirname=\"" << info.doc_dirname << "\"\n";
+ state.phrase << " dirname=\"" << info.doc_dirname << "\"\n";
         }
 
- actions.phrase
+ state.phrase
             << "last-revision=\"" << info.doc_last_revision << "\""
             << " xmlns:xi=\"http://www.w3.org/2001/XInclude\"";
 
- actions.phrase << ">"; // end document tag.
+ state.phrase << ">"; // end document tag.
 
         // Title tag
 
@@ -389,35 +389,35 @@
         }
 
         // For 'library', the title comes after the info block.
- if(info.doc_type != "library") actions.phrase << title;
+ if(info.doc_type != "library") state.phrase << title;
 
         // Info tag
 
- actions.phrase << "<" << info.doc_type << "info>\n";
+ state.phrase << "<" << info.doc_type << "info>\n";
 
         if(!info.doc_authors.empty())
         {
- actions.phrase << "<authorgroup>\n";
+ state.phrase << "<authorgroup>\n";
             BOOST_FOREACH(doc_info::author const& author, info.doc_authors) {
- actions.phrase
+ state.phrase
                     << "<author>\n"
                     << "<firstname>" << author.first << "</firstname>\n"
                     << "<surname>" << author.second << "</surname>\n"
                     << "</author>\n";
             }
- actions.phrase << "</authorgroup>\n";
+ state.phrase << "</authorgroup>\n";
         }
 
         BOOST_FOREACH(doc_info::copyright_entry const& copyright,
             info.doc_copyrights)
         {
- actions.phrase << "<copyright>\n";
+ state.phrase << "<copyright>\n";
 
             BOOST_FOREACH(std::string const& year, copyright.first) {
- actions.phrase << "<year>" << year << "</year>\n";
+ state.phrase << "<year>" << year << "</year>\n";
             }
 
- actions.phrase
+ state.phrase
                 << "<holder>" << copyright.second << "</holder>\n"
                 << "</copyright>\n"
             ;
@@ -425,7 +425,7 @@
 
         if (!info.doc_license.empty())
         {
- actions.phrase
+ state.phrase
                 << "<legalnotice>\n"
                 << "<para>\n"
                 << info.doc_license
@@ -438,7 +438,7 @@
 
         if (!info.doc_purpose.empty())
         {
- actions.phrase
+ state.phrase
                 << "<" << info.doc_type << "purpose>\n"
                 << info.doc_purpose
                 << "</" << info.doc_type << "purpose>\n"
@@ -448,7 +448,7 @@
 
         if (!info.doc_category.empty())
         {
- actions.phrase
+ state.phrase
                 << "<" << info.doc_type << "category name=\"category:"
                 << info.doc_category
                 << "\"></" << info.doc_type << "category>\n"
@@ -456,20 +456,20 @@
             ;
         }
 
- actions.phrase
+ state.phrase
             << "</" << info.doc_type << "info>\n"
         ;
 
- if(info.doc_type == "library") actions.phrase << title;
+ if(info.doc_type == "library") state.phrase << title;
     }
 
- void output(quickbook::actions& actions, doc_info_post const& x)
+ void output(quickbook::state& state, doc_info_post const& x)
     {
         // if we're ignoring the document info, do nothing.
         if (x.info.ignore) return;
 
         // We've finished generating our output. Here's what we'll do
         // *after* everything else.
- actions.phrase << "</" << x.info.doc_type << ">";
+ state.phrase << "</" << x.info.doc_type << ">";
     }
 }

Modified: branches/quickbook-1.5-spirit2/boostbook.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/boostbook.hpp (original)
+++ branches/quickbook-1.5-spirit2/boostbook.hpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -25,33 +25,33 @@
 
     // Output function for boostbook, these should eventually become an
     // interface with implementations for boostbook and html.
- // They probably shouldn't use quickbook::actions, instead they
+ // They probably shouldn't use quickbook::state, instead they
     // should either take a stream/collector to write to, or return their
     // output by value.
 
- void output(quickbook::actions&, doc_info const&);
- void output(quickbook::actions&, doc_info_post const&);
+ void output(quickbook::state&, doc_info const&);
+ void output(quickbook::state&, doc_info_post const&);
 
     // Note: char is a plain quickbook character, string is an encoded
     // boostbook string. Oops.
- void output(quickbook::actions&, char);
- void output(quickbook::actions&, std::string const&);
- void output(quickbook::actions&, anchor const&);
- void output(quickbook::actions&, link const&);
- void output(quickbook::actions&, formatted const&);
- void output(quickbook::actions&, break_ const&);
- void output(quickbook::actions&, image2 const&);
-
- void output(quickbook::actions&, hr);
- void output(quickbook::actions&, begin_section2 const&);
- void output(quickbook::actions&, end_section2 const&);
- void output(quickbook::actions&, heading2 const&);
- void output(quickbook::actions&, variablelist const&);
- void output(quickbook::actions&, table2 const&);
- void output(quickbook::actions&, xinclude2 const&);
- void output(quickbook::actions&, list2 const&);
+ void output(quickbook::state&, char);
+ void output(quickbook::state&, std::string const&);
+ void output(quickbook::state&, anchor const&);
+ void output(quickbook::state&, link const&);
+ void output(quickbook::state&, formatted const&);
+ void output(quickbook::state&, break_ const&);
+ void output(quickbook::state&, image2 const&);
+
+ void output(quickbook::state&, hr);
+ void output(quickbook::state&, begin_section2 const&);
+ void output(quickbook::state&, end_section2 const&);
+ void output(quickbook::state&, heading2 const&);
+ void output(quickbook::state&, variablelist const&);
+ void output(quickbook::state&, table2 const&);
+ void output(quickbook::state&, xinclude2 const&);
+ void output(quickbook::state&, list2 const&);
 
- void output(quickbook::actions&, code_token const&);
+ void output(quickbook::state&, code_token const&);
 
     std::string encode(std::string const&);
     std::string encode(char);

Modified: branches/quickbook-1.5-spirit2/code_snippet.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_snippet.cpp (original)
+++ branches/quickbook-1.5-spirit2/code_snippet.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -16,9 +16,9 @@
 #include <iterator>
 #include <boost/lexical_cast.hpp>
 #include "utils.hpp"
-#include "actions_class.hpp"
 #include "grammars.hpp"
 #include "code_snippet_types.hpp"
+#include "template.hpp"
 
 namespace quickbook
 {

Modified: branches/quickbook-1.5-spirit2/doc_info.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info.cpp (original)
+++ branches/quickbook-1.5-spirit2/doc_info.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -10,7 +10,8 @@
 
 #include "doc_info.hpp"
 #include "grammars.hpp"
-#include "actions_class.hpp"
+#include "actions.hpp"
+#include "state.hpp"
 #include "parse_utils.hpp"
 #include <boost/spirit/include/qi_core.hpp>
 #include <boost/spirit/include/qi_uint.hpp>
@@ -112,7 +113,7 @@
                     | doc_last_revision [member_assign(&doc_info::doc_last_revision)]
                       // This has to be set in actions so that source code in phrases use the
                       // correct encoding.
- | doc_source_mode [ph::ref(actions.source_mode) = qi::_1]
+ | doc_source_mode [ph::ref(actions.state_.source_mode) = qi::_1]
                     )
>> space >> ']' >> +qi::eol
                 )

Modified: branches/quickbook-1.5-spirit2/doc_info_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/doc_info_actions.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -16,7 +16,8 @@
 #include "collector.hpp"
 #include "quickbook.hpp"
 #include "doc_info_actions.hpp"
-#include "actions_class.hpp"
+#include "actions.hpp"
+#include "state.hpp"
 #include "utils.hpp"
 
 namespace quickbook

Modified: branches/quickbook-1.5-spirit2/fwd.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/fwd.hpp (original)
+++ branches/quickbook-1.5-spirit2/fwd.hpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -16,9 +16,11 @@
 {
     struct nothing {};
 
+ struct template_stack;
     struct macro;
     struct doc_info;
 
+ struct state;
     struct actions;
     struct code_snippet_actions;
 

Modified: branches/quickbook-1.5-spirit2/phrase.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -21,7 +21,8 @@
 #include "code.hpp"
 #include "phrase.hpp"
 #include "grammars.hpp"
-#include "actions_class.hpp"
+#include "actions.hpp"
+#include "template.hpp"
 #include "parse_utils.hpp"
 
 BOOST_FUSION_ADAPT_STRUCT(

Modified: branches/quickbook-1.5-spirit2/phrase_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_actions.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -10,7 +10,8 @@
 
 #include <boost/assert.hpp>
 #include "phrase.hpp"
-#include "actions_class.hpp"
+#include "actions.hpp"
+#include "state.hpp"
 #include "utils.hpp"
 #include "code.hpp"
 #include "boostbook.hpp"
@@ -19,7 +20,7 @@
 namespace quickbook
 {
     nothing process(quickbook::actions& actions, source_mode const& s) {
- actions.source_mode = s.mode;
+ actions.state_.source_mode = s.mode;
         return nothing();
     }
 
@@ -97,12 +98,12 @@
 
         // TODO: I don't need to save this, do I?
         std::string save;
- actions.phrase.swap(save);
+ actions.state_.phrase.swap(save);
 
         // print the code with syntax coloring
         std::string str = actions.syntax_p(first_, last_);
 
- actions.phrase.swap(save);
+ actions.state_.phrase.swap(save);
         
         r.type = x.block ? "programlisting" : "code";
         r.content = str;

Modified: branches/quickbook-1.5-spirit2/phrase_image.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_image.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_image.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -12,7 +12,8 @@
 #include <boost/filesystem/fstream.hpp>
 #include "phrase.hpp"
 #include "gen_types.hpp"
-#include "actions_class.hpp"
+#include "actions.hpp"
+#include "state.hpp"
 #include "utils.hpp"
 
 namespace quickbook
@@ -41,7 +42,7 @@
                     << "Duplicate image attribute: "
                     << begin->first
                     << std::endl;
- ++actions.error_count;
+ ++actions.state_.error_count;
             }
         }
     

Modified: branches/quickbook-1.5-spirit2/process.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/process.cpp (original)
+++ branches/quickbook-1.5-spirit2/process.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -25,7 +25,7 @@
     template <typename T>
     void process_action::operator()(T const& x) const
     {
- output(actions, process(actions, x));
+ output(actions.state_, process(actions, x));
     }
 
     template <typename T>
@@ -34,11 +34,9 @@
         return x;
     }
 
- void output(quickbook::actions&, nothing) {
+ void output(quickbook::state&, nothing) {
     }
 
- void output(quickbook::actions&, std::string const&);
-
     template void process_action::operator()<formatted>(formatted const&) const;
     template void process_action::operator()<source_mode>(source_mode const&) const;
     template void process_action::operator()<macro>(macro const&) const;

Modified: branches/quickbook-1.5-spirit2/quickbook.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/quickbook.cpp (original)
+++ branches/quickbook-1.5-spirit2/quickbook.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -18,7 +18,8 @@
 #include <boost/ref.hpp>
 #include "fwd.hpp"
 #include "quickbook.hpp"
-#include "actions_class.hpp"
+#include "state.hpp"
+#include "actions.hpp"
 #include "grammars.hpp"
 #include "post_process.hpp"
 #include "utils.hpp"
@@ -56,7 +57,7 @@
         std::string storage;
         int err = detail::load(filein_, storage);
         if (err != 0) {
- ++actor.error_count;
+ ++actor.state_.error_count;
             return err;
         }
 
@@ -94,24 +95,25 @@
             file_position const pos = first.get_position();
             detail::outerr(pos.file,pos.line)
                 << "Syntax Error near column " << pos.column << ".\n";
- ++actor.error_count;
+ ++actor.state_.error_count;
         }
         
- if(actor.error_count)
+ if(actor.state_.error_count)
         {
             detail::outerr(filein_)
- << "Error count: " << actor.error_count << ".\n";
+ << "Error count: " << actor.state_.error_count << ".\n";
         }
 
- return actor.error_count ? 1 : 0;
+ return actor.state_.error_count ? 1 : 0;
     }
 
     static int
     parse(char const* filein_, fs::path const& outdir, string_stream& out, bool ignore_docinfo = false)
     {
- actions actor(filein_, outdir, out);
+ quickbook::state state(filein_, outdir, out);
+ actions actor(state);
         bool r = parse(filein_, actor);
- if (actor.section_level != 0)
+ if (actor.state_.section_level != 0)
             detail::outwarn(filein_)
                 << "Warning missing [endsect] detected at end of file."
                 << std::endl;

Copied: branches/quickbook-1.5-spirit2/state.cpp (from r59562, /branches/quickbook-1.5-spirit2/actions_class.cpp)
==============================================================================
--- /branches/quickbook-1.5-spirit2/actions_class.cpp (original)
+++ branches/quickbook-1.5-spirit2/state.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -10,7 +10,8 @@
 =============================================================================*/
 
 #include <boost/filesystem/operations.hpp>
-#include "actions_class.hpp"
+#include "actions.hpp"
+#include "state.hpp"
 #include "quickbook.hpp"
 
 #if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310))
@@ -21,7 +22,7 @@
 {
     namespace fs = boost::filesystem;
 
- actions::actions(char const* filein_, fs::path const& outdir_, string_stream& out_)
+ state::state(char const* filein_, fs::path const& outdir_, string_stream& out_)
     // header info
         : doc_id()
         , doc_title()
@@ -42,14 +43,6 @@
         , template_depth(0)
         , templates()
         , error_count(0)
-
- // actions
- , process(*this)
- , phrase_push(phrase)
- , phrase_pop(phrase)
- , error(error_count)
-
- , syntax_p(source_mode, *this)
     {
         // turn off __FILENAME__ macro on debug mode = true
         std::string filename_str = debug_mode ?
@@ -64,7 +57,7 @@
         ;
     }
 
- void actions::push()
+ void state::push()
     {
         state_stack.push(
             boost::make_tuple(
@@ -82,7 +75,7 @@
         templates.push();
     }
 
- void actions::pop()
+ void state::pop()
     {
         boost::tie(
             filename

Copied: branches/quickbook-1.5-spirit2/state.hpp (from r59562, /branches/quickbook-1.5-spirit2/actions_class.hpp)
==============================================================================
--- /branches/quickbook-1.5-spirit2/actions_class.hpp (original)
+++ branches/quickbook-1.5-spirit2/state.hpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -14,18 +14,18 @@
 #include <boost/tuple/tuple.hpp>
 #include <boost/filesystem/path.hpp>
 #include "fwd.hpp"
-#include "actions.hpp"
 #include "collector.hpp"
 #include "template.hpp"
+#include "actions.hpp"
 
 namespace quickbook
 {
     namespace qi = boost::spirit::qi;
     namespace fs = boost::filesystem;
 
- struct actions
+ struct state
     {
- actions(char const* filein_, fs::path const& outdir, string_stream& out_);
+ state(char const* filein_, fs::path const& outdir, string_stream& out_);
 
     ///////////////////////////////////////////////////////////////////////////
     // State
@@ -70,19 +70,7 @@
     // push/pop the states and the streams
         void push();
         void pop();
-
- ///////////////////////////////////////////////////////////////////////////
- // actions
- ///////////////////////////////////////////////////////////////////////////
- process_action process;
- phrase_push_action phrase_push;
- phrase_pop_action phrase_pop;
- error_action error;
-
- syntax_highlight syntax_p;
-
- element_id_warning_action element_id_warning;
- };
+ };
 }
 
 #endif // BOOST_SPIRIT_ACTIONS_CLASS_HPP

Modified: branches/quickbook-1.5-spirit2/syntax_highlight.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/syntax_highlight.cpp (original)
+++ branches/quickbook-1.5-spirit2/syntax_highlight.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -13,7 +13,7 @@
 #include <boost/spirit/include/qi_string.hpp>
 #include <boost/spirit/include/qi_directive.hpp>
 #include <boost/fusion/include/adapt_struct.hpp>
-#include "actions_class.hpp"
+#include "actions.hpp"
 #include "grammars.hpp"
 #include "phrase.hpp"
 #include "utils.hpp"
@@ -370,7 +370,7 @@
 
     std::string syntax_highlight::operator()(iterator first, iterator last) const
     {
- escape_actions.phrase.push();
+ escape_actions.phrase_push();
 
         // print the code with syntax coloring
         if (source_mode == "c++")
@@ -393,10 +393,6 @@
             BOOST_ASSERT(0);
         }
 
- std::string str;
- escape_actions.phrase.swap(str);
- escape_actions.phrase.pop();
-
- return str;
+ return escape_actions.phrase_pop();
     }
 }

Modified: branches/quickbook-1.5-spirit2/template.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/template.cpp (original)
+++ branches/quickbook-1.5-spirit2/template.cpp 2010-02-07 04:12:02 EST (Sun, 07 Feb 2010)
@@ -11,7 +11,7 @@
 #include "template.hpp"
 #include "phrase_actions.hpp"
 #include "grammars.hpp"
-#include "actions_class.hpp"
+#include "state.hpp"
 #include "utils.hpp"
 
 #ifdef BOOST_MSVC
@@ -268,13 +268,13 @@
             {
                 std::vector<std::string> empty_params;
 
- if (!actions.templates.add(
+ if (!actions.state_.templates.add(
                         define_template(*tpl, empty_params, *arg, pos),
                         &scope))
                 {
                     detail::outerr(pos.file,pos.line)
                         << "Duplicate Symbol Found" << std::endl;
- ++actions.error_count;
+ ++actions.state_.error_count;
                     return std::make_pair(false, tpl);
                 }
                 ++arg; ++tpl;
@@ -315,11 +315,11 @@
                 simple_phrase_grammar phrase_p(actions);
 
                 // do a phrase level parse
- iterator first(body.begin(), body.end(), actions.filename.native_file_string().c_str());
+ iterator first(body.begin(), body.end(), actions.state_.filename.native_file_string().c_str());
                 first.set_position(template_pos);
                 iterator last(body.end(), body.end());
                 r = boost::spirit::qi::parse(first, last, phrase_p) && first == last;
- actions.phrase.swap(result);
+ actions.state_.phrase.swap(result);
             }
             else
             {
@@ -331,11 +331,11 @@
                 body += "\n\n";
                 while (iter != body.end() && ((*iter == '\r') || (*iter == '\n')))
                     ++iter; // skip initial newlines
- iterator first(iter, body.end(), actions.filename.native_file_string().c_str());
+ iterator first(iter, body.end(), actions.state_.filename.native_file_string().c_str());
                 first.set_position(template_pos);
                 iterator last(body.end(), body.end());
                 r = boost::spirit::qi::parse(first, last, block_p) && first == last;
- actions.phrase.swap(result);
+ actions.state_.phrase.swap(result);
             }
             return r;
         }
@@ -343,13 +343,13 @@
 
     std::string process(quickbook::actions& actions, call_template const& x)
     {
- ++actions.template_depth;
- if (actions.template_depth > actions.max_template_depth)
+ ++actions.state_.template_depth;
+ if (actions.state_.template_depth > actions.state_.max_template_depth)
         {
             detail::outerr(x.position.file, x.position.line)
                 << "Infinite loop detected" << std::endl;
- --actions.template_depth;
- ++actions.error_count;
+ --actions.state_.template_depth;
+ ++actions.state_.error_count;
             return "";
         }
 
@@ -358,17 +358,17 @@
         //
         // Note that for quickbook 1.4- this value is just ignored when the
         // arguments are expanded.
- template_scope const& call_scope = actions.templates.top_scope();
+ template_scope const& call_scope = actions.state_.templates.top_scope();
 
         std::string result;
- actions.push(); // scope the actions' states
+ actions.state_.push(); // scope the actions' states
         {
             // Quickbook 1.4-: When expanding the tempalte continue to use the
             // current scope (the dynamic scope).
             // Quickbook 1.5+: Use the scope the template was defined in
             // (the static scope).
             if (qbk_version_n >= 105)
- actions.templates.set_parent_scope(*x.symbol->parent);
+ actions.state_.templates.set_parent_scope(*x.symbol->parent);
 
             std::vector<std::string> args = x.args;
     
@@ -376,9 +376,9 @@
             // Break the arguments
             if (!break_arguments(args, x.symbol->params, x.position))
             {
- actions.pop(); // restore the actions' states
- --actions.template_depth;
- ++actions.error_count;
+ actions.state_.pop(); // restore the actions' states
+ --actions.state_.template_depth;
+ ++actions.state_.error_count;
                 return "";
             }
 
@@ -392,8 +392,8 @@
 
             if (!get_arg_result)
             {
- actions.pop(); // restore the actions' states
- --actions.template_depth;
+ actions.state_.pop(); // restore the actions' states
+ --actions.state_.template_depth;
                 return "";
             }
 
@@ -409,15 +409,15 @@
                     << x.symbol->body
                     << "------------------end--------------------" << std::endl
                     << std::endl;
- actions.pop(); // restore the actions' states
- --actions.template_depth;
- ++actions.error_count;
+ actions.state_.pop(); // restore the actions' states
+ --actions.state_.template_depth;
+ ++actions.state_.error_count;
                 return "";
             }
         }
 
- actions.pop(); // restore the actions' states
- --actions.template_depth;
+ actions.state_.pop(); // restore the actions' states
+ --actions.state_.template_depth;
         
         return result;
     }


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