|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75262 - branches/quickbook-dev/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-11-02 04:47:33
Author: danieljames
Date: 2011-11-02 04:47:31 EDT (Wed, 02 Nov 2011)
New Revision: 75262
URL: http://svn.boost.org/trac/boost/changeset/75262
Log:
Quickbook: Represent callouts in value tree.
Text files modified:
branches/quickbook-dev/tools/quickbook/src/actions.cpp | 34 +++++++++++++++++++++++++---------
branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp | 9 +++++++--
branches/quickbook-dev/tools/quickbook/src/template_stack.cpp | 15 +++++++++++++++
branches/quickbook-dev/tools/quickbook/src/template_stack.hpp | 15 ++-------------
branches/quickbook-dev/tools/quickbook/src/template_tags.hpp | 1 +
branches/quickbook-dev/tools/quickbook/src/values.cpp | 4 ++++
6 files changed, 54 insertions(+), 24 deletions(-)
Modified: branches/quickbook-dev/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions.cpp 2011-11-02 04:47:31 EDT (Wed, 02 Nov 2011)
@@ -1260,7 +1260,10 @@
template_symbol const* symbol,
string_iterator first)
{
- assert(symbol->content.get_tag() == template_tags::block);
+ value_consumer values = symbol->content;
+ value content = values.consume(template_tags::block);
+ value callouts = values.consume();
+ values.finish();
std::vector<std::string> callout_ids;
std::vector<value> args;
@@ -1281,15 +1284,21 @@
callout_ids.push_back(callout_id2);
}
- call_template(actions, symbol, args, first);
+ // Create a fake symbol for call_template
+ template_symbol t(
+ symbol->identifier,
+ symbol->params,
+ content,
+ symbol->parent);
+ call_template(actions, &t, args, first);
std::string block;
- if(!symbol->callouts.empty())
+ if(!callouts.empty())
{
block += "<calloutlist>";
int i = 0;
- BOOST_FOREACH(value c, symbol->callouts)
+ BOOST_FOREACH(value c, callouts)
{
std::string callout_id1 = callout_ids[i++];
std::string callout_id2 = callout_ids[i++];
@@ -1376,9 +1385,11 @@
///////////////////////////////////
// Initialise the arguments
-
- if (!symbol->callouts.check())
+
+ switch(symbol->content.get_tag())
{
+ case template_tags::block:
+ case template_tags::phrase:
// Break the arguments for a template
break_arguments(args, symbol->params, actions.current_file->path);
@@ -1398,9 +1409,10 @@
}
call_template(actions, symbol, args, first);
- }
- else
- {
+ break;
+
+ case template_tags::snippet:
+
if (!args.empty())
{
detail::outerr(actions.current_file, first)
@@ -1412,6 +1424,10 @@
}
call_code_snippet(actions, symbol, first);
+ break;
+
+ default:
+ assert(0);
}
}
Modified: branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp 2011-11-02 04:47:31 EDT (Wed, 02 Nov 2011)
@@ -461,8 +461,13 @@
}
// TODO: Save position in start_snippet
- template_symbol symbol(snippet->id, params, qbk_value(body, qbk_version_n, template_tags::block));
- symbol.callouts = callouts;
+
+ value_builder content;
+ content.set_tag(template_tags::snippet);
+ content.insert(qbk_value(body, qbk_version_n, template_tags::block));
+ content.insert(callouts);
+
+ template_symbol symbol(snippet->id, params, content.release());
storage.push_back(symbol);
// Merge the snippet into its parent
Modified: branches/quickbook-dev/tools/quickbook/src/template_stack.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/template_stack.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/template_stack.cpp 2011-11-02 04:47:31 EDT (Wed, 02 Nov 2011)
@@ -16,6 +16,21 @@
namespace quickbook
{
+ template_symbol::template_symbol(
+ std::string const& identifier,
+ std::vector<std::string> const& params,
+ value const& content,
+ template_scope const* parent)
+ : identifier(identifier)
+ , params(params)
+ , content(content)
+ , parent(parent)
+ {
+ assert(content.get_tag() == template_tags::block ||
+ content.get_tag() == template_tags::phrase ||
+ content.get_tag() == template_tags::snippet);
+ }
+
template_stack::template_stack()
: scope(template_stack::parser(*this))
, scopes()
Modified: branches/quickbook-dev/tools/quickbook/src/template_stack.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/template_stack.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/template_stack.hpp 2011-11-02 04:47:31 EDT (Wed, 02 Nov 2011)
@@ -31,20 +31,11 @@
struct template_symbol
{
- template_symbol(
+ template_symbol(
std::string const& identifier,
std::vector<std::string> const& params,
value const& content,
- template_scope const* parent = 0)
- : identifier(identifier)
- , params(params)
- , content(content)
- , parent(parent)
- , callouts()
- {
- assert(content.get_tag() == template_tags::block ||
- content.get_tag() == template_tags::phrase);
- }
+ template_scope const* parent = 0);
std::string identifier;
std::vector<std::string> params;
@@ -54,8 +45,6 @@
// TODO: I should probably call this something like lexical_parent
// or static_parent for clarity.
template_scope const* parent;
-
- value callouts;
};
typedef boost::spirit::classic::symbols<template_symbol> template_symbols;
Modified: branches/quickbook-dev/tools/quickbook/src/template_tags.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/template_tags.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/template_tags.hpp 2011-11-02 04:47:31 EDT (Wed, 02 Nov 2011)
@@ -19,6 +19,7 @@
(identifier)
(block)
(phrase)
+ (snippet)
)
}
Modified: branches/quickbook-dev/tools/quickbook/src/values.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/values.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/values.cpp 2011-11-02 04:47:31 EDT (Wed, 02 Nov 2011)
@@ -877,6 +877,10 @@
list_tag = value::default_tag;
}
+ void value_builder::set_tag(value::tag_type tag) {
+ list_tag = tag;
+ }
+
void value_builder::insert(value const& item) {
current.append(item.value_);
}
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