From 11211c78548018027978835f30709ca11bf35dc1 Mon Sep 17 00:00:00 2001
From: Adam Radziszewski <adam.radziszewski@pwr.wroc.pl>
Date: Wed, 4 Jan 2012 13:26:56 +0100
Subject: [PATCH] SWIG clean-up: mv shared_ptr & vector %template declarations
 to the class being wrapped

---
 swig/functionaloperator.i   |  2 +-
 swig/functionalopsequence.i | 17 +++++++++++------
 swig/lexicon.i              |  5 +++--
 swig/lexicons.i             |  6 ++++--
 swig/matchrule.i            |  6 ++++++
 swig/matchrulesequence.i    |  4 +---
 swig/operator.i             | 22 +++++++++++-----------
 swig/sentencecontext.i      |  4 ++--
 swig/tagrule.i              |  3 +++
 swig/tagrulesequence.i      |  2 +-
 swig/wcclfile.i             |  7 -------
 swig/wcclfileopsections.i   | 15 +++++++--------
 12 files changed, 50 insertions(+), 43 deletions(-)

diff --git a/swig/functionaloperator.i b/swig/functionaloperator.i
index 7058cc7..ae3565f 100644
--- a/swig/functionaloperator.i
+++ b/swig/functionaloperator.i
@@ -15,7 +15,7 @@
 %include <libcorpus2/boost_shared_ptr.i>
 
 %template(FunctionalOperatorPtr) boost::shared_ptr<Wccl::FunctionalOperator>;
-
+%template(ConstFunctionalOperatorPtr) boost::shared_ptr<const Wccl::FunctionalOperator>;
 
 namespace Wccl {
   class FunctionalOperator : public ParsedExpression {
diff --git a/swig/functionalopsequence.i b/swig/functionalopsequence.i
index a476ff8..49d6a8f 100644
--- a/swig/functionalopsequence.i
+++ b/swig/functionalopsequence.i
@@ -18,12 +18,10 @@
 
 %nodefaultctor Wccl::FunctionalOpSequence;
 
-%template(fun_op_ptr_t) boost::shared_ptr<FunctionalOperator>;
-%template(fun_op_ptr_c_t) boost::shared_ptr<const FunctionalOperator>;
-%template(name_op_pair_t) std::pair<std::string, boost::shared_ptr<FunctionalOperator> > ;
-%template(name_op_pair_c_t) std::pair<std::string, boost::shared_ptr<const FunctionalOperator> >;
-%template(name_op_v_t) std::vector<std::pair<std::string, boost::shared_ptr<FunctionalOperator> > >;
-%template(name_op_v_c_t) std::vector<std::pair<std::string, boost::shared_ptr<const FunctionalOperator> > >;
+%template(name_op_pair_t) std::pair<std::string, boost::shared_ptr<Wccl::FunctionalOperator> > ;
+%template(name_op_pair_c_t) std::pair<std::string, boost::shared_ptr<const Wccl::FunctionalOperator> >;
+%template(name_op_v_t) std::vector<std::pair<std::string, boost::shared_ptr<Wccl::FunctionalOperator> > >;
+%template(name_op_v_c_t) std::vector<std::pair<std::string, boost::shared_ptr<const Wccl::FunctionalOperator> > >;
 
 namespace Wccl {
   class FunctionalOpSequence : public Expression {
@@ -198,6 +196,13 @@ namespace Wccl {
   }; // OpSequence
 }
 
+%template(UntypedOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::UntypedOpSequence> >;
+%template(BoolOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::Bool> > >;
+%template(StrSetOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::StrSet> > >;
+%template(TSetOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::TSet> > >;
+%template(PositionOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::Position> > >;
+%template(MatchOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::Match> > >;
+
 using namespace boost;
 using namespace Wccl;
 using namespace std;
diff --git a/swig/lexicon.i b/swig/lexicon.i
index b9004e4..d32a41f 100644
--- a/swig/lexicon.i
+++ b/swig/lexicon.i
@@ -18,6 +18,9 @@
 
 %nodefaultctor Wccl::Lexicon;
 
+%template(LexiconPtr) boost::shared_ptr<Wccl::Lexicon>;
+%template(ConstLexiconPtr) boost::shared_ptr<const Wccl::Lexicon>;
+
 namespace Wccl {
   class Lexicon {
   public:
@@ -61,8 +64,6 @@ namespace Wccl {
     const map_t& map() const;
   };
 
-  %template(LexiconPtr) boost::shared_ptr<Wccl::Lexicon>;
-  %template(ConstLexiconPtr) boost::shared_ptr<const Wccl::Lexicon>;
 }
 
 using namespace boost;
diff --git a/swig/lexicons.i b/swig/lexicons.i
index 69a0456..0c19e08 100644
--- a/swig/lexicons.i
+++ b/swig/lexicons.i
@@ -13,6 +13,9 @@
 
 %rename(map_t) boost::unordered_map<std::string, boost::shared_ptr<Lexicon> >;
 
+%template(LexiconsPtr) boost::shared_ptr<Wccl::Lexicons>;
+%template(ConstLexiconsPtr) boost::shared_ptr<const Wccl::Lexicons>;
+
 namespace Wccl {
   class Lexicons {
   public:
@@ -42,8 +45,7 @@ namespace Wccl {
     const map_t& get_lexicons() const;
   };
 
-  %template(LexiconsPtr) boost::shared_ptr<Wccl::Lexicons>;
-  %template(ConstLexiconsPtr) boost::shared_ptr<const Wccl::Lexicons>;
+
 }
 
 using namespace boost;
diff --git a/swig/matchrule.i b/swig/matchrule.i
index 52165c9..7d61a7d 100644
--- a/swig/matchrule.i
+++ b/swig/matchrule.i
@@ -11,8 +11,14 @@
 %include "libcorpus2/annotatedsentence.i"
 
 %include "std_string.i"
+%include "std_vector.i"
 %include <libcorpus2/boost_shared_ptr.i>
 
+%template(MatchRulePtr) boost::shared_ptr<Wccl::Matching::MatchRule>;
+%template(ConstMatchRulePtr) boost::shared_ptr<const Wccl::Matching::MatchRule>;
+
+%template(MatchRuleVector) std::vector<Wccl::Matching::MatchRule>;
+
 namespace Wccl {
 namespace Matching {
   class MatchRule : public ParsedExpression {
diff --git a/swig/matchrulesequence.i b/swig/matchrulesequence.i
index d45853b..e6f7d6b 100644
--- a/swig/matchrulesequence.i
+++ b/swig/matchrulesequence.i
@@ -15,11 +15,9 @@
 %include "std_vector.i"
 %include <libcorpus2/boost_shared_ptr.i>
 
-%template(MatchRuleVector) std::vector<Wccl::Matching::MatchRule>;
-%template(MatchRulePtr) boost::shared_ptr<Wccl::Matching::MatchRule>;
 %template(ConstMatchRuleSequencePtr) boost::shared_ptr<const Wccl::Matching::MatchRuleSequence>;
 %template(MatchRuleSequencePtr) boost::shared_ptr<Wccl::Matching::MatchRuleSequence>;
-%template(ConstMatchRulePtr) boost::shared_ptr<const Wccl::Matching::MatchRule>;
+
 
 namespace Wccl {
 namespace Matching {
diff --git a/swig/operator.i b/swig/operator.i
index fa7c5c9..0d8e36e 100644
--- a/swig/operator.i
+++ b/swig/operator.i
@@ -40,8 +40,8 @@ namespace Wccl {
     boost::shared_ptr<const Value> base_apply(const SentenceContext& sc);
     
     /* --------------------------------------------------------------------- */
-    Operator clone() const;
-    Operator clone_clean() const;
+    // Operator clone() const;
+    // Operator clone_clean() const;
     
     /* --------------------------------------------------------------------- */
     boost::shared_ptr<Operator<T> > clone_ptr() const;
@@ -54,17 +54,17 @@ namespace Wccl {
     Operator* clone_internal() const;
     std::ostream& write_to(std::ostream& ostream) const;
   };
+}
 
-  %template (BoolOperator) Operator<Bool>;
-  %template (TSetOperator) Operator<TSet>;
-  %template (StrSetOperator) Operator<StrSet>;
-  %template (PositionOperator) Operator<Position>;
+%template (BoolOperator) Wccl::Operator<Wccl::Bool>;
+%template (TSetOperator) Wccl::Operator<Wccl::TSet>;
+%template (StrSetOperator) Wccl::Operator<Wccl::StrSet>;
+%template (PositionOperator) Wccl::Operator<Wccl::Position>;
 
-  %template (BoolOperatorPtr) boost::shared_ptr<Operator<Bool> >;
-  %template (TSetOperatorPtr) boost::shared_ptr<Operator<TSet> >;
-  %template (StrSetOperatorPtr) boost::shared_ptr<Operator<StrSet> >;
-  %template (PositionOperatorPtr) boost::shared_ptr<Operator<Position> >;
-}
+%template (BoolOperatorPtr) boost::shared_ptr<Wccl::Operator<Wccl::Bool> >;
+%template (TSetOperatorPtr) boost::shared_ptr<Wccl::Operator<Wccl::TSet> >;
+%template (StrSetOperatorPtr) boost::shared_ptr<Wccl::Operator<Wccl::StrSet> >;
+%template (PositionOperatorPtr) boost::shared_ptr<Wccl::Operator<Wccl::Position> >;
 
 using namespace boost;
 using namespace std;
diff --git a/swig/sentencecontext.i b/swig/sentencecontext.i
index 10fa25f..bddbe01 100644
--- a/swig/sentencecontext.i
+++ b/swig/sentencecontext.i
@@ -17,6 +17,8 @@
 
 // %feature("notabstract") Wccl::SentenceContext;
 
+%template(SentenceContextPtr) boost::shared_ptr<Wccl::SentenceContext>;
+
 namespace Wccl {
   class SentenceContext {
   public:
@@ -61,8 +63,6 @@ namespace Wccl {
   };
 }
 
-%template(SentenceContextSharedPtr) boost::shared_ptr<Wccl::SentenceContext>;
-
 using namespace boost;
 using namespace std;
 using namespace Wccl;
diff --git a/swig/tagrule.i b/swig/tagrule.i
index b8029fc..ec132af 100644
--- a/swig/tagrule.i
+++ b/swig/tagrule.i
@@ -15,10 +15,13 @@
 %include "libcorpus2/tagset.i"
 
 %include "std_string.i"
+%include "std_vector.i"
 %include <libcorpus2/boost_shared_ptr.i>
 
 %template(TagRulePtr) boost::shared_ptr<Wccl::TagRule>;
 
+%template(TagRuleVector) std::vector<Wccl::TagRule>;
+
 namespace Wccl {
   class TagRule : public ParsedExpression {
   public:
diff --git a/swig/tagrulesequence.i b/swig/tagrulesequence.i
index 31b0bfd..1736018 100644
--- a/swig/tagrulesequence.i
+++ b/swig/tagrulesequence.i
@@ -15,7 +15,7 @@
 %include "std_vector.i"
 %include <libcorpus2/boost_shared_ptr.i>
 
-%template(StdVectorTagRule) std::vector<TagRule>;
+
 %template(TagRuleSequencPtr) boost::shared_ptr<Wccl::TagRuleSequence>;
 %template(ConstTagRuleSequencPtr) boost::shared_ptr<const Wccl::TagRuleSequence>;
 
diff --git a/swig/wcclfile.i b/swig/wcclfile.i
index f7821d6..9e24237 100644
--- a/swig/wcclfile.i
+++ b/swig/wcclfile.i
@@ -25,13 +25,6 @@
 %include "std_vector.i"
 %include <libcorpus2/boost_shared_ptr.i>
 
-%template(UntypedOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::UntypedOpSequence> >;
-%template(BoolOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::Bool> > >;
-%template(StrSetOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::StrSet> > >;
-%template(TSetOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::TSet> > >;
-%template(PositionOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::Position> > >;
-%template(MatchOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::Match> > >;
-
 %nodefaultctor Wccl::WcclFile;
 
 %template(WcclFilePtr) boost::shared_ptr<Wccl::WcclFile>;
diff --git a/swig/wcclfileopsections.i b/swig/wcclfileopsections.i
index 8b22240..f8d08da 100644
--- a/swig/wcclfileopsections.i
+++ b/swig/wcclfileopsections.i
@@ -73,16 +73,15 @@ namespace Wccl {
     void append(const ptr_t& section);
     /* --------------------------------------------------------------------- */
   };
+}
 
-  %template(UntypedOpSequenceWcclFileOpSections) WcclFileOpSections<UntypedOpSequence>;
-  %template(StrSetOpSequence) WcclFileOpSections<OpSequence<StrSet> >;
-  %template(TSetOpSequence) WcclFileOpSections<OpSequence<TSet> >;
-  %template(BoolOpSequence) WcclFileOpSections<OpSequence<Bool> >;
-  %template(PositionOpSequence) WcclFileOpSections<OpSequence<Position> >;
-  %template(MatchOpSequence) WcclFileOpSections<OpSequence<Match> >;
+%template(UntypedOpSections) Wccl::WcclFileOpSections<Wccl::UntypedOpSequence>;
+%template(StrSetOpSections) Wccl::WcclFileOpSections<Wccl::OpSequence<Wccl::StrSet> >;
+%template(TSetOpSections) Wccl::WcclFileOpSections<Wccl::OpSequence<Wccl::TSet> >;
+%template(BoolOpSections) Wccl::WcclFileOpSections<Wccl::OpSequence<Wccl::Bool> >;
+%template(PositionOpSections) Wccl::WcclFileOpSections<Wccl::OpSequence<Wccl::Position> >;
+%template(MatchOpSections) Wccl::WcclFileOpSections<Wccl::OpSequence<Wccl::Match> >;
 
-  %template(OpSequenceStrSet) Wccl::WcclFileOpSections<Wccl::OpSequence<Wccl::StrSet> >;
-}
 
 using namespace std;
 using namespace Wccl;
-- 
GitLab