|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70561 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-03-26 07:11:37
Author: danieljames
Date: 2011-03-26 07:11:36 EDT (Sat, 26 Mar 2011)
New Revision: 70561
URL: http://svn.boost.org/trac/boost/changeset/70561
Log:
Quickbook: Rename `rule_store` to `cleanup`.
Added:
trunk/tools/quickbook/src/cleanup.hpp (contents, props changed)
- copied, changed from r70559, /trunk/tools/quickbook/src/rule_store.hpp
Removed:
trunk/tools/quickbook/src/rule_store.hpp
Text files modified:
trunk/tools/quickbook/src/block_element_grammar.cpp | 3 +
trunk/tools/quickbook/src/cleanup.hpp | 48 +++++++++++----------------------------
trunk/tools/quickbook/src/doc_info_grammar.cpp | 3 +
trunk/tools/quickbook/src/grammar.cpp | 2
trunk/tools/quickbook/src/grammar_impl.hpp | 4 +-
trunk/tools/quickbook/src/main_grammar.cpp | 3 +
trunk/tools/quickbook/src/phrase_element_grammar.cpp | 3 +
7 files changed, 25 insertions(+), 41 deletions(-)
Modified: trunk/tools/quickbook/src/block_element_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/block_element_grammar.cpp (original)
+++ trunk/tools/quickbook/src/block_element_grammar.cpp 2011-03-26 07:11:36 EDT (Sat, 26 Mar 2011)
@@ -39,7 +39,8 @@
void quickbook_grammar::impl::init_block_elements()
{
- block_element_grammar_local& local = store_.create();
+ block_element_grammar_local& local = cleanup_.add(
+ new block_element_grammar_local);
local.element_id =
!( ':'
Copied: trunk/tools/quickbook/src/cleanup.hpp (from r70559, /trunk/tools/quickbook/src/rule_store.hpp)
==============================================================================
--- /trunk/tools/quickbook/src/rule_store.hpp (original)
+++ trunk/tools/quickbook/src/cleanup.hpp 2011-03-26 07:11:36 EDT (Sat, 26 Mar 2011)
@@ -6,13 +6,13 @@
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
-// This header defines a class which can will manage quickbook rules for a
-// grammar class so that it doesn't have to declare every rule it'll use.
-//
-// TODO: Noncopyable, but some sort of reference counting scheme would work.
+// This header defines a class which can will store pointers and deleters
+// to a number of objects and delete them on exit. Basically stick an
+// object in here, and you can use pointers and references to the object
+// for the cleanup object's lifespan.
-#if !defined(BOOST_SPIRIT_QUICKBOOK_RULE_STORE_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_RULE_STORE_HPP
+#if !defined(BOOST_SPIRIT_QUICKBOOK_CLEANUP_HPP)
+#define BOOST_SPIRIT_QUICKBOOK_CLEANUP_HPP
#include <deque>
#include <cassert>
@@ -50,44 +50,24 @@
};
}
- struct rule_store
+ struct cleanup
{
- struct instantiate
- {
- rule_store& s;
- instantiate(rule_store& s) : s(s) {}
-
- template <typename T>
- operator T&() {
- std::auto_ptr<T> obj(new T());
- T& ref = *obj;
- s.store_.push_back(detail::scoped_void());
- s.store_.back().store(obj.release(), &detail::delete_impl<T>);
- return ref;
- }
- };
-
- rule_store() {}
-
- instantiate create() {
- instantiate i(*this);
- return i;
- }
-
+ cleanup() {}
+
template <typename T>
T& add(T* new_)
{
std::auto_ptr<T> obj(new_);
- store_.push_back(detail::scoped_void());
- store_.back().store(obj.release(), &detail::delete_impl<T>);
+ cleanup_list_.push_back(detail::scoped_void());
+ cleanup_list_.back().store(obj.release(), &detail::delete_impl<T>);
return *new_;
}
- std::deque<detail::scoped_void> store_;
+ std::deque<detail::scoped_void> cleanup_list_;
private:
- rule_store& operator=(rule_store const&);
- rule_store(rule_store const&);
+ cleanup& operator=(cleanup const&);
+ cleanup(cleanup const&);
};
}
Modified: trunk/tools/quickbook/src/doc_info_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/doc_info_grammar.cpp (original)
+++ trunk/tools/quickbook/src/doc_info_grammar.cpp 2011-03-26 07:11:36 EDT (Sat, 26 Mar 2011)
@@ -89,7 +89,8 @@
void quickbook_grammar::impl::init_doc_info()
{
- doc_info_grammar_local& local = store_.create();
+ doc_info_grammar_local& local = cleanup_.add(
+ new doc_info_grammar_local);
typedef cl::uint_parser<int, 10, 1, 2> uint2_t;
Modified: trunk/tools/quickbook/src/grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/grammar.cpp (original)
+++ trunk/tools/quickbook/src/grammar.cpp 2011-03-26 07:11:36 EDT (Sat, 26 Mar 2011)
@@ -30,7 +30,7 @@
quickbook_grammar::impl::impl(quickbook::actions& a)
: actions(a)
- , store_()
+ , cleanup_()
{
init_main();
init_block_elements();
Modified: trunk/tools/quickbook/src/grammar_impl.hpp
==============================================================================
--- trunk/tools/quickbook/src/grammar_impl.hpp (original)
+++ trunk/tools/quickbook/src/grammar_impl.hpp 2011-03-26 07:11:36 EDT (Sat, 26 Mar 2011)
@@ -12,7 +12,7 @@
#define BOOST_SPIRIT_QUICKBOOK_GRAMMARS_IMPL_HPP
#include "grammar.hpp"
-#include "rule_store.hpp"
+#include "cleanup.hpp"
#include "values.hpp"
#include <boost/spirit/include/classic_symbols.hpp>
@@ -56,7 +56,7 @@
struct quickbook_grammar::impl
{
quickbook::actions& actions;
- rule_store store_;
+ cleanup cleanup_;
// Main Grammar
cl::rule<scanner> block_start;
Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp (original)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2011-03-26 07:11:36 EDT (Sat, 26 Mar 2011)
@@ -130,7 +130,8 @@
void quickbook_grammar::impl::init_main()
{
- main_grammar_local& local = store_.add(new main_grammar_local(actions));
+ main_grammar_local& local = cleanup_.add(
+ new main_grammar_local(actions));
block_skip_initial_spaces =
*(cl::blank_p | comment) >> block_start
Modified: trunk/tools/quickbook/src/phrase_element_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/phrase_element_grammar.cpp (original)
+++ trunk/tools/quickbook/src/phrase_element_grammar.cpp 2011-03-26 07:11:36 EDT (Sat, 26 Mar 2011)
@@ -32,7 +32,8 @@
void quickbook_grammar::impl::init_phrase_elements()
{
- phrase_element_grammar_local& local = store_.create();
+ phrase_element_grammar_local& local = cleanup_.add(
+ new phrase_element_grammar_local);
elements.add
("?", element_info(element_info::phrase, &local.cond_phrase))
Deleted: trunk/tools/quickbook/src/rule_store.hpp
==============================================================================
--- trunk/tools/quickbook/src/rule_store.hpp 2011-03-26 07:11:36 EDT (Sat, 26 Mar 2011)
+++ (empty file)
@@ -1,94 +0,0 @@
-/*=============================================================================
- Copyright (c) 2010 Daniel James
-
- 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)
-=============================================================================*/
-
-// This header defines a class which can will manage quickbook rules for a
-// grammar class so that it doesn't have to declare every rule it'll use.
-//
-// TODO: Noncopyable, but some sort of reference counting scheme would work.
-
-#if !defined(BOOST_SPIRIT_QUICKBOOK_RULE_STORE_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_RULE_STORE_HPP
-
-#include <deque>
-#include <cassert>
-#include <utility>
-
-namespace quickbook
-{
- namespace detail
- {
- template <typename T>
- void delete_impl(void* ptr) {
- delete static_cast<T*>(ptr);
- }
-
- struct scoped_void
- {
- void* ptr_;
- void (*del_)(void*);
-
- scoped_void() : ptr_(0), del_(0) {}
- scoped_void(scoped_void const& src) : ptr_(0), del_(0) {
- ignore_variable(&src);
- assert(!src.ptr_);
- }
- ~scoped_void() {
- if(ptr_) del_(ptr_);
- }
-
- void store(void* ptr, void (*del)(void* x)) {
- ptr = ptr_;
- del = del_;
- }
- private:
- scoped_void& operator=(scoped_void const&);
- };
- }
-
- struct rule_store
- {
- struct instantiate
- {
- rule_store& s;
- instantiate(rule_store& s) : s(s) {}
-
- template <typename T>
- operator T&() {
- std::auto_ptr<T> obj(new T());
- T& ref = *obj;
- s.store_.push_back(detail::scoped_void());
- s.store_.back().store(obj.release(), &detail::delete_impl<T>);
- return ref;
- }
- };
-
- rule_store() {}
-
- instantiate create() {
- instantiate i(*this);
- return i;
- }
-
- template <typename T>
- T& add(T* new_)
- {
- std::auto_ptr<T> obj(new_);
- store_.push_back(detail::scoped_void());
- store_.back().store(obj.release(), &detail::delete_impl<T>);
-
- return *new_;
- }
-
- std::deque<detail::scoped_void> store_;
- private:
- rule_store& operator=(rule_store const&);
- rule_store(rule_store const&);
- };
-}
-
-#endif
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