$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r70958 - in branches/quickbook-dev/tools/quickbook: src test/include
From: dnljms_at_[hidden]
Date: 2011-04-03 15:18:14
Author: danieljames
Date: 2011-04-03 15:18:12 EDT (Sun, 03 Apr 2011)
New Revision: 70958
URL: http://svn.boost.org/trac/boost/changeset/70958
Log:
Quickbook: Scope templates in `include` in 1.6
Added:
   branches/quickbook-dev/tools/quickbook/test/include/templates-1.5.gold   (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/templates-1.5.quickbook   (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/templates-1.6.gold   (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/templates-1.6.quickbook   (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/templates-inc1.quickbook   (contents, props changed)
Text files modified: 
   branches/quickbook-dev/tools/quickbook/src/actions.cpp         |    15 +++++----------                         
   branches/quickbook-dev/tools/quickbook/src/actions_class.cpp   |    14 ++++++++------                          
   branches/quickbook-dev/tools/quickbook/src/actions_class.hpp   |    12 ++++++++++--                            
   branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2 |     2 ++                                      
   4 files changed, 25 insertions(+), 18 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-04-03 15:18:12 EDT (Sun, 03 Apr 2011)
@@ -1749,18 +1749,13 @@
     {
         assert(load_type == block_tags::include ||
             load_type == block_tags::import);
-
-        if (load_type == block_tags::import)
-        {
-            detail::outerr(actions.filename)
-                << "Quickbook import not implemented yet.\n";
-            ++actions.error_count;
-            return;
-        }
     
         {
-            file_state state(actions);
-        
+            file_state state(actions,
+                load_type == block_tags::import ? file_state::scope_none :
+                qbk_version_n >= 106u ? file_state::scope_all :
+                file_state::scope_macros);
+
             actions.filename = paths.filename;
             actions.filename_relative = paths.filename_relative;
 
Modified: branches/quickbook-dev/tools/quickbook/src/actions_class.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions_class.cpp	(original)
+++ branches/quickbook-dev/tools/quickbook/src/actions_class.cpp	2011-04-03 15:18:12 EDT (Sun, 03 Apr 2011)
@@ -94,14 +94,17 @@
         return *grammar_;
     }
 
-    file_state::file_state(actions& a)
+    file_state::file_state(actions& a, scope_flags scope)
         : a(a)
+        , scope(scope)
         , doc_id(a.doc_id)
         , filename(a.filename)
         , filename_relative(a.filename_relative)
-        , macro(a.macro)
         , source_mode(a.source_mode)
+        , macro()
     {
+        if (scope & scope_macros) macro = a.macro;
+        if (scope & scope_templates) a.templates.push();
         a.values.builder.save();
     }
 
@@ -111,12 +114,13 @@
         boost::swap(a.doc_id, doc_id);
         boost::swap(a.filename, filename);
         boost::swap(a.filename_relative, filename_relative);
-        a.macro = macro;
         boost::swap(a.source_mode, source_mode);
+        if (scope & scope_templates) a.templates.pop();
+        if (scope & scope_macros) a.macro = macro;
     }
     
     template_state::template_state(actions& a)
-        : file_state(a)
+        : file_state(a, file_state::scope_all)
         , section_level(a.section_level)
         , min_section_level(a.min_section_level)
         , section_id(a.section_id)
@@ -124,12 +128,10 @@
     {
         a.out.push();
         a.phrase.push();
-        a.templates.push();
     }
 
     template_state::~template_state()
     {
-        a.templates.pop();
         a.phrase.pop();
         a.out.pop();
         boost::swap(a.section_level, section_level);
Modified: branches/quickbook-dev/tools/quickbook/src/actions_class.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions_class.hpp	(original)
+++ branches/quickbook-dev/tools/quickbook/src/actions_class.hpp	2011-04-03 15:18:12 EDT (Sun, 03 Apr 2011)
@@ -114,15 +114,23 @@
 
     struct file_state
     {
-        explicit file_state(actions&);
+        enum scope_flags {
+            scope_none = 0,
+            scope_macros = 1,
+            scope_templates = 2,
+            scope_all = 3
+        };
+    
+        explicit file_state(actions&, scope_flags);
         ~file_state();
         
         quickbook::actions& a;
+        scope_flags scope;
         std::string doc_id;
         fs::path filename;
         fs::path filename_relative;
-        string_symbols macro;
         std::string source_mode;
+        string_symbols macro;
     private:
         file_state(file_state const&);
         file_state& operator=(file_state const&);
Modified: branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2	(original)
+++ branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2	2011-04-03 15:18:12 EDT (Sun, 03 Apr 2011)
@@ -20,6 +20,8 @@
     [ quickbook-test doc-title1a-1.5 ]
     [ quickbook-test section ]
     [ quickbook-test section-unclosed ]
+    [ quickbook-test templates-1.5 ]
+    [ quickbook-test templates-1.6 ]
     [ quickbook-error-test section-fail1 ]
     [ quickbook-error-test section-fail2 ]
     ;
Added: branches/quickbook-dev/tools/quickbook/test/include/templates-1.5.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/templates-1.5.gold	2011-04-03 15:18:12 EDT (Sun, 03 Apr 2011)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="templates_1_5" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+  <title>Templates 1.5</title>
+  <para>
+    Inline:templates-inc1.quickbook
+  </para>
+  <para>
+    Foo:templates-1.5.quickbook
+  </para>
+</article>
Added: branches/quickbook-dev/tools/quickbook/test/include/templates-1.5.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/templates-1.5.quickbook	2011-04-03 15:18:12 EDT (Sun, 03 Apr 2011)
@@ -0,0 +1,7 @@
+[article Templates 1.5
+[quickbook 1.5]
+]
+
+[include templates-inc1.quickbook]
+
+[foo]
\ No newline at end of file
Added: branches/quickbook-dev/tools/quickbook/test/include/templates-1.6.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/templates-1.6.gold	2011-04-03 15:18:12 EDT (Sun, 03 Apr 2011)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="templates_1_6" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+  <title>Templates 1.6</title>
+  <para>
+    Inline:templates-inc1.quickbook
+  </para>
+  <para>
+    [foo]
+  </para>
+</article>
Added: branches/quickbook-dev/tools/quickbook/test/include/templates-1.6.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/templates-1.6.quickbook	2011-04-03 15:18:12 EDT (Sun, 03 Apr 2011)
@@ -0,0 +1,7 @@
+[article Templates 1.6
+[quickbook 1.6]
+]
+
+[include templates-inc1.quickbook]
+
+[foo]
Added: branches/quickbook-dev/tools/quickbook/test/include/templates-inc1.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/templates-inc1.quickbook	2011-04-03 15:18:12 EDT (Sun, 03 Apr 2011)
@@ -0,0 +1,4 @@
+Inline:__FILENAME__
+
+[template foo Foo:__FILENAME__]
+