From 8d5161bf33528459447ee1ca02006ec0252db196 Mon Sep 17 00:00:00 2001 From: eschnett Date: Wed, 15 May 2013 23:08:47 +0000 Subject: Move all of Piraha into cctki_piraha namespace Change namespace "piraha" to "cctki_piraha", as per Cactus naming standard. Move smart_ptr into this namespace as well. git-svn-id: http://svn.cactuscode.org/flesh/trunk@5012 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/piraha/AutoGrammar.cc | 2 +- src/piraha/Boundary.cc | 2 +- src/piraha/Bracket.cc | 4 ++-- src/piraha/Call.cc | 2 +- src/piraha/Dot.cc | 2 +- src/piraha/End.cc | 2 +- src/piraha/Generic.cc | 2 +- src/piraha/Grammar.cc | 6 +++--- src/piraha/Group.cc | 2 +- src/piraha/ILiteral.cc | 2 +- src/piraha/Literal.cc | 2 +- src/piraha/Lookup.cc | 2 +- src/piraha/Matcher.cc | 2 +- src/piraha/Multi.cc | 2 +- src/piraha/NegLookAhead.cc | 2 +- src/piraha/Or.cc | 2 +- src/piraha/Piraha.hpp | 2 +- src/piraha/ReParse.cc | 2 +- src/piraha/Seq.cc | 2 +- src/piraha/Start.cc | 2 +- src/piraha/smart_ptr.cc | 4 ++++ src/piraha/smart_ptr.hpp | 8 ++++++++ 22 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/piraha/AutoGrammar.cc b/src/piraha/AutoGrammar.cc index 26789e28..e4ef5eed 100644 --- a/src/piraha/AutoGrammar.cc +++ b/src/piraha/AutoGrammar.cc @@ -1,6 +1,6 @@ #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; smart_ptr AutoGrammar::reparserGenerator() { smart_ptr g = new Grammar(); diff --git a/src/piraha/Boundary.cc b/src/piraha/Boundary.cc index 6c34335b..8a25524d 100644 --- a/src/piraha/Boundary.cc +++ b/src/piraha/Boundary.cc @@ -1,6 +1,6 @@ #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; bool is_c_ident(char c) { return ('a' <= c && c <= 'z') diff --git a/src/piraha/Bracket.cc b/src/piraha/Bracket.cc index d16d75da..47c3cc04 100644 --- a/src/piraha/Bracket.cc +++ b/src/piraha/Bracket.cc @@ -1,7 +1,7 @@ #include "Piraha.hpp" #include -using namespace piraha; +using namespace cctki_piraha; typedef vector >::iterator range_iter; @@ -95,7 +95,7 @@ bool Bracket::match(Matcher *m) { } } -void piraha::insertc(std::ostream& o,char c) { +void cctki_piraha::insertc(std::ostream& o,char c) { if(c == '-') { o << "\\-"; } else if(c == '\n') { diff --git a/src/piraha/Call.cc b/src/piraha/Call.cc index 5c3b5757..9cccb426 100644 --- a/src/piraha/Call.cc +++ b/src/piraha/Call.cc @@ -12,7 +12,7 @@ #include #include -namespace piraha { +namespace cctki_piraha { #define VAR(X) " " #X "=" << X diff --git a/src/piraha/Dot.cc b/src/piraha/Dot.cc index 8f1b0396..b06cd319 100644 --- a/src/piraha/Dot.cc +++ b/src/piraha/Dot.cc @@ -1,6 +1,6 @@ #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; bool Dot::match(Matcher *m) { if(m->pos - m->input_size >= 0) diff --git a/src/piraha/End.cc b/src/piraha/End.cc index 2c76dceb..52d85913 100644 --- a/src/piraha/End.cc +++ b/src/piraha/End.cc @@ -1,6 +1,6 @@ #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; bool End::match(Matcher *m) { return m->pos == (int)m->input_size; diff --git a/src/piraha/Generic.cc b/src/piraha/Generic.cc index f60696ee..21012a85 100644 --- a/src/piraha/Generic.cc +++ b/src/piraha/Generic.cc @@ -2,7 +2,7 @@ #include #include -using namespace piraha; +using namespace cctki_piraha; void read_file(const char *file,std::string& buf) { std::ifstream in; diff --git a/src/piraha/Grammar.cc b/src/piraha/Grammar.cc index 5a516358..66aca571 100644 --- a/src/piraha/Grammar.cc +++ b/src/piraha/Grammar.cc @@ -1,6 +1,6 @@ #include "Piraha.hpp" -namespace piraha { +namespace cctki_piraha { extern smart_ptr compile(smart_ptr g,bool ignCase,smart_ptr gram); @@ -8,7 +8,7 @@ smart_ptr pegGrammar = AutoGrammar::reparserGenerator(); void compile(smart_ptr thisg,std::string name,smart_ptr g) { thisg->default_rule = name; - smart_ptr p = piraha::compile(g,false,thisg); + smart_ptr p = cctki_piraha::compile(g,false,thisg); thisg->patterns.put(name,p); } void compile(smart_ptr thisg,std::string name,std::string pattern) { @@ -16,7 +16,7 @@ void compile(smart_ptr thisg,std::string name,std::string pattern) { smart_ptr m = new Matcher(pegGrammar,"pattern",pattern.c_str()); smart_ptr g = m.dup(); if(m->matches()) { - smart_ptr p = piraha::compile(g,false,thisg); + smart_ptr p = cctki_piraha::compile(g,false,thisg); thisg->patterns.put(name,p); } else { std::cout << "Could not compile(" << name << "," << pattern << ")" << std::endl; diff --git a/src/piraha/Group.cc b/src/piraha/Group.cc index 95079800..11e1ac61 100644 --- a/src/piraha/Group.cc +++ b/src/piraha/Group.cc @@ -1,6 +1,6 @@ #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; void Group::dump(std::ostream& o) { dump(-1,o,0); diff --git a/src/piraha/ILiteral.cc b/src/piraha/ILiteral.cc index a01c48fd..b7816145 100644 --- a/src/piraha/ILiteral.cc +++ b/src/piraha/ILiteral.cc @@ -1,6 +1,6 @@ #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; ILiteral::ILiteral(char b) : lc(lc_(b)), uc(uc_(b)) {} diff --git a/src/piraha/Literal.cc b/src/piraha/Literal.cc index 62678266..a8022ff8 100644 --- a/src/piraha/Literal.cc +++ b/src/piraha/Literal.cc @@ -1,6 +1,6 @@ #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; bool Literal::match(Matcher *m) { if(m->pos - m->input_size >= 0) { diff --git a/src/piraha/Lookup.cc b/src/piraha/Lookup.cc index 3b442864..a1cc457c 100644 --- a/src/piraha/Lookup.cc +++ b/src/piraha/Lookup.cc @@ -1,6 +1,6 @@ #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; Lookup::Lookup(std::string name_,smart_ptr g) : gram(g), name(name_), capture(true) { if(name[0] == '-') { diff --git a/src/piraha/Matcher.cc b/src/piraha/Matcher.cc index dd189042..9a37a06b 100644 --- a/src/piraha/Matcher.cc +++ b/src/piraha/Matcher.cc @@ -1,7 +1,7 @@ #include #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; Matcher::Matcher(smart_ptr g_,const char *pat_,const char *input_,int input_size_) : Group(pat_,input_), diff --git a/src/piraha/Multi.cc b/src/piraha/Multi.cc index ff03f7d9..ae795645 100644 --- a/src/piraha/Multi.cc +++ b/src/piraha/Multi.cc @@ -1,7 +1,7 @@ #include #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; bool Multi::match(Matcher *m) { vector > chSave; diff --git a/src/piraha/NegLookAhead.cc b/src/piraha/NegLookAhead.cc index a70e5539..43385ee9 100644 --- a/src/piraha/NegLookAhead.cc +++ b/src/piraha/NegLookAhead.cc @@ -1,6 +1,6 @@ #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; bool NegLookAhead::match(Matcher *m) { int pos = m->pos; diff --git a/src/piraha/Or.cc b/src/piraha/Or.cc index c5caec00..d9633e3e 100644 --- a/src/piraha/Or.cc +++ b/src/piraha/Or.cc @@ -2,7 +2,7 @@ #include #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; Or::Or(Pattern *p,...) : patterns() { va_list ap; diff --git a/src/piraha/Piraha.hpp b/src/piraha/Piraha.hpp index b8af3b7a..004a3ba0 100644 --- a/src/piraha/Piraha.hpp +++ b/src/piraha/Piraha.hpp @@ -7,7 +7,7 @@ #include #include -namespace piraha { +namespace cctki_piraha { const int max_int = 10000; diff --git a/src/piraha/ReParse.cc b/src/piraha/ReParse.cc index 295b0b29..60b83db5 100644 --- a/src/piraha/ReParse.cc +++ b/src/piraha/ReParse.cc @@ -2,7 +2,7 @@ #include #include -namespace piraha { +namespace cctki_piraha { char getChar(smart_ptr gr) { if(gr->groupCount()==1) { diff --git a/src/piraha/Seq.cc b/src/piraha/Seq.cc index c0b697bc..80be5ace 100644 --- a/src/piraha/Seq.cc +++ b/src/piraha/Seq.cc @@ -2,7 +2,7 @@ #include #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; Seq::Seq(Pattern *p,...) { va_list ap; diff --git a/src/piraha/Start.cc b/src/piraha/Start.cc index 52e3cf40..bcb72ef9 100644 --- a/src/piraha/Start.cc +++ b/src/piraha/Start.cc @@ -1,6 +1,6 @@ #include "Piraha.hpp" -using namespace piraha; +using namespace cctki_piraha; bool Start::match(Matcher *m) { return m->pos == 0; diff --git a/src/piraha/smart_ptr.cc b/src/piraha/smart_ptr.cc index b2e5a826..112e0f62 100644 --- a/src/piraha/smart_ptr.cc +++ b/src/piraha/smart_ptr.cc @@ -1,3 +1,7 @@ #include "smart_ptr.hpp" +namespace cctki_piraha { + std::set *ptrs = new std::set(); + +} diff --git a/src/piraha/smart_ptr.hpp b/src/piraha/smart_ptr.hpp index 58555562..b8784b55 100644 --- a/src/piraha/smart_ptr.hpp +++ b/src/piraha/smart_ptr.hpp @@ -8,6 +8,8 @@ #define NULL ((void*)0) #endif +namespace cctki_piraha { + extern std::set *ptrs; // TODO: This code is disabled because it leads to segfaults during @@ -19,11 +21,15 @@ extern std::set *ptrs; inline void add(std::set& v,void *t) { if(t == NULL) return; + // TODO: Don't separate finding and inserting; do it in one go to + // save a lookup. assert(v.find(t) == v.end()); v.insert(t); } inline void remove(std::set& v,void* t) { + // TODO: Don't separate finding and erasing; do it in one go + // to save a lookup. std::set::iterator it = v.find(t); assert(it != v.end()); v.erase(it); @@ -163,4 +169,6 @@ class smart_ptr { template friend class smart_ptr; }; + +} #endif -- cgit v1.2.3