Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70529 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-03-24 17:25:51


Author: danieljames
Date: 2011-03-24 17:25:50 EDT (Thu, 24 Mar 2011)
New Revision: 70529
URL: http://svn.boost.org/trac/boost/changeset/70529

Log:
Quickbook: Use a different type for stored values.

And fix some bugs in the process.
Text files modified:
   trunk/tools/quickbook/src/actions.cpp | 2
   trunk/tools/quickbook/src/code_snippet.cpp | 2
   trunk/tools/quickbook/src/template_stack.cpp | 2
   trunk/tools/quickbook/src/template_stack.hpp | 4 +-
   trunk/tools/quickbook/src/values.cpp | 64 ++++++++++++++++++++++++++-------------
   trunk/tools/quickbook/src/values.hpp | 26 +++++++++++----
   6 files changed, 66 insertions(+), 34 deletions(-)

Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp (original)
+++ trunk/tools/quickbook/src/actions.cpp 2011-03-24 17:25:50 EDT (Thu, 24 Mar 2011)
@@ -999,7 +999,7 @@
                         body.filename);
     
                     body.content = qbk_value(begin, pos.first,
- body.content.get_tag()).store();
+ body.content.get_tag());
                     args.push_back(second);
                 }
             }

Modified: trunk/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- trunk/tools/quickbook/src/code_snippet.cpp (original)
+++ trunk/tools/quickbook/src/code_snippet.cpp 2011-03-24 17:25:50 EDT (Thu, 24 Mar 2011)
@@ -395,7 +395,7 @@
         if(!snippet_stack) return;
         code += "``[[callout" + boost::lexical_cast<std::string>(callout_id) + "]]``";
     
- snippet_stack->callouts.insert(qbk_value(first, last, template_tags::block).store());
+ snippet_stack->callouts.insert(qbk_value(first, last, template_tags::block));
         ++callout_id;
     }
 

Modified: trunk/tools/quickbook/src/template_stack.cpp
==============================================================================
--- trunk/tools/quickbook/src/template_stack.cpp (original)
+++ trunk/tools/quickbook/src/template_stack.cpp 2011-03-24 17:25:50 EDT (Thu, 24 Mar 2011)
@@ -20,7 +20,7 @@
             value const& content,
             fs::path const& filename
         )
- : content(content.store())
+ : content(content)
         , filename(filename)
     {
         assert(content.get_tag() == template_tags::block ||

Modified: trunk/tools/quickbook/src/template_stack.hpp
==============================================================================
--- trunk/tools/quickbook/src/template_stack.hpp (original)
+++ trunk/tools/quickbook/src/template_stack.hpp 2011-03-24 17:25:50 EDT (Thu, 24 Mar 2011)
@@ -31,7 +31,7 @@
         template_body(value const&, fs::path const&);
         bool is_block() const;
 
- value content;
+ stored_value content;
         fs::path filename;
     };
 
@@ -60,7 +60,7 @@
         // or static_parent for clarity.
         template_scope const* parent;
 
- value callouts;
+ stored_value callouts;
     };
 
     typedef boost::spirit::classic::symbols<template_symbol> template_symbols;

Modified: trunk/tools/quickbook/src/values.cpp
==============================================================================
--- trunk/tools/quickbook/src/values.cpp (original)
+++ trunk/tools/quickbook/src/values.cpp 2011-03-24 17:25:50 EDT (Thu, 24 Mar 2011)
@@ -145,21 +145,10 @@
             intrusive_ptr_add_ref(value_);
         }
     
- value_counted& value_counted::operator=(value_counted x)
- {
- swap(x);
- return *this;
- }
-
         value_counted::~value_counted()
         {
             intrusive_ptr_release(value_);
         }
-
- value value_counted::store() const
- {
- return value(value_->store());
- }
     }
     
     ////////////////////////////////////////////////////////////////////////////
@@ -175,7 +164,7 @@
     {
     }
 
- value::value(detail::value_ref x)
+ value::value(detail::value_base const& x)
         : detail::value_counted(x)
     {
     }
@@ -184,7 +173,37 @@
         : detail::value_counted(x)
     {
     }
-
+
+ value& value::operator=(value x)
+ {
+ swap(x);
+ return *this;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ // stored_value
+
+ stored_value::stored_value()
+ : detail::value_counted()
+ {
+ }
+
+ stored_value::stored_value(stored_value const& x)
+ : detail::value_counted(x)
+ {
+ }
+
+ stored_value::stored_value(detail::value_base const& x)
+ : detail::value_counted(x.store())
+ {
+ }
+
+ stored_value& stored_value::operator=(stored_value x)
+ {
+ swap(x);
+ return *this;
+ }
+
     ////////////////////////////////////////////////////////////////////////////
     // Iterator
 
@@ -720,15 +739,16 @@
 
             value_list_builder build;
 
- for(value_node* pos2 = head_;
- pos2 != &value_nil_impl::instance;
- pos2 = pos2->next_)
- {
- if(pos2 == pos)
- build.append(new_node.get());
- else
- build.append(pos2);
- }
+ value_node* pos2 = head_;
+
+ for(;pos2 != pos; pos2 = pos2->next_)
+ build.append(pos2);
+
+ build.append(new_node.get());
+ pos2 = pos2->next_;
+
+ for(;pos2 != &value_nil_impl::instance; pos2 = pos2->next_)
+ build.append(pos2->store());
 
             return new value_list_impl(build.get(), tag_);
         }

Modified: trunk/tools/quickbook/src/values.hpp
==============================================================================
--- trunk/tools/quickbook/src/values.hpp (original)
+++ trunk/tools/quickbook/src/values.hpp 2011-03-24 17:25:50 EDT (Thu, 24 Mar 2011)
@@ -23,6 +23,7 @@
 namespace quickbook
 {
     class value;
+ class stored_value;
     class value_builder;
     class value_error;
 
@@ -98,9 +99,8 @@
 
             ~value_base() {}
 
- public:
             void swap(value_base& x) { std::swap(value_, x.value_); }
-
+ public:
             bool check() const { return value_->check(); }
             bool empty() const { return value_->empty(); }
             bool is_list() const { return value_->is_list(); }
@@ -122,6 +122,8 @@
             int get_int() const
             { return value_->get_int(); }
 
+ value_node* store() const { return value_->store(); }
+
         protected:
             value_node* value_;
 
@@ -181,15 +183,13 @@
 
         class value_counted : public value_base
         {
- public:
+ value_counted& operator=(value_counted const&);
+ protected:
             value_counted();
             value_counted(value_counted const&);
             value_counted(value_base const&);
             value_counted(value_node*);
- value_counted& operator=(value_counted);
             ~value_counted();
-
- value store() const;
         };
 
         ////////////////////////////////////////////////////////////////////////
@@ -226,8 +226,20 @@
     public:
         value();
         value(value const&);
- value(detail::value_ref);
+ value(detail::value_base const&);
         explicit value(detail::value_node*);
+ value& operator=(value);
+ void swap(value& x) { detail::value_counted::swap(x); }
+ };
+
+ class stored_value : public detail::value_counted
+ {
+ public:
+ stored_value();
+ stored_value(stored_value const&);
+ stored_value(detail::value_base const&);
+ stored_value& operator=(stored_value);
+ void swap(stored_value& x) { detail::value_counted::swap(x); }
     };
 
     // Empty


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