aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-06-04 18:12:49 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-06-04 18:12:49 +0000
commitf20624e954718a037c48818570a586f8ec8fde7e (patch)
tree6b4294e07333c2cad68c6f8bcd611808c3ea5955
parentc40a061cb2d7caee9693e39f7de3e3b85065c25e (diff)
downloadpaludis-f20624e954718a037c48818570a586f8ec8fde7e.tar.gz
paludis-f20624e954718a037c48818570a586f8ec8fde7e.tar.xz
Fix Gems tests.
-rw-r--r--paludis/repositories/gems/yaml.cc23
1 files changed, 20 insertions, 3 deletions
diff --git a/paludis/repositories/gems/yaml.cc b/paludis/repositories/gems/yaml.cc
index 82563b2..711d9ab 100644
--- a/paludis/repositories/gems/yaml.cc
+++ b/paludis/repositories/gems/yaml.cc
@@ -266,16 +266,35 @@ namespace paludis
template <>
struct Implementation<Document>
{
+ struct Register
+ {
+ Implementation<Document> * _imp;
+
+ Register(Implementation<Document> * imp) :
+ _imp(imp)
+ {
+ NodeManager::get_instance()->register_document(_imp->parser.get());
+ }
+
+ ~Register()
+ {
+ NodeManager::get_instance()->deregister_document(_imp->parser.get());
+ }
+ };
+
Node * top;
tr1::shared_ptr<SyckParser> parser;
tr1::shared_ptr<char> data;
unsigned data_length;
+ Register reg;
+
Implementation(const std::string & s) :
top(0),
parser(syck_new_parser(), call_unless_null(syck_free_parser)),
data(strdup(s.c_str()), call_unless_null(std::free)),
- data_length(s.length())
+ data_length(s.length()),
+ reg(this)
{
}
};
@@ -285,7 +304,6 @@ Document::Document(const std::string & s) :
PrivateImplementationPattern<Document>(new Implementation<Document>(s))
{
Context c("When parsing yaml document:");
- NodeManager::get_instance()->register_document(_imp->parser.get());
syck_parser_str(_imp->parser.get(), _imp->data.get(), _imp->data_length, 0);
syck_parser_handler(_imp->parser.get(), node_handler);
@@ -307,7 +325,6 @@ Document::Document(const std::string & s) :
Document::~Document()
{
- NodeManager::get_instance()->deregister_document(_imp->parser.get());
}
const Node *