From e9915fe25c68da1695ad1164b963e144c7f7c8c4 Mon Sep 17 00:00:00 2001 From: dellaert Date: Sun, 30 Nov 2014 23:26:07 +0100 Subject: [PATCH] Moved to headers --- wrap/ReturnType.h | 32 ++++++++++++++++ wrap/ReturnValue.h | 37 ++++++++++++++++++ wrap/tests/testReturnValue.cpp | 69 ---------------------------------- 3 files changed, 69 insertions(+), 69 deletions(-) diff --git a/wrap/ReturnType.h b/wrap/ReturnType.h index f9d8b318a..1c67a1d9a 100644 --- a/wrap/ReturnType.h +++ b/wrap/ReturnType.h @@ -62,4 +62,36 @@ private: }; +//****************************************************************************** +// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html +struct ReturnTypeGrammar: public classic::grammar { + + wrap::ReturnType& result_; ///< successful parse will be placed in here + + TypeGrammar type_g; + + /// Construct ReturnType grammar and specify where result is placed + ReturnTypeGrammar(wrap::ReturnType& result) : + result_(result), type_g(result_) { + } + + /// Definition of type grammar + template + struct definition { + + classic::rule type_p; + + definition(ReturnTypeGrammar const& self) { + using namespace classic; + type_p = self.type_g >> !ch_p('*')[assign_a(self.result_.isPtr, T)]; + } + + classic::rule const& start() const { + return type_p; + } + + }; +}; +// ReturnTypeGrammar + } // \namespace wrap diff --git a/wrap/ReturnValue.h b/wrap/ReturnValue.h index 7fab5faca..b23cbf681 100644 --- a/wrap/ReturnValue.h +++ b/wrap/ReturnValue.h @@ -77,4 +77,41 @@ struct ReturnValue { }; +//****************************************************************************** +// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html +struct ReturnValueGrammar: public classic::grammar { + + wrap::ReturnValue& result_; ///< successful parse will be placed in here + + ReturnTypeGrammar returnType1_g, returnType2_g; + + /// Construct type grammar and specify where result is placed + ReturnValueGrammar(wrap::ReturnValue& result) : + result_(result), returnType1_g(result.type1), returnType2_g(result.type2) { + } + + /// Definition of type grammar + template + struct definition { + + classic::rule pair_p, returnValue_p; + + definition(ReturnValueGrammar const& self) { + + using namespace classic; + + pair_p = (str_p("pair") >> '<' >> self.returnType1_g >> ',' + >> self.returnType2_g >> '>')[assign_a(self.result_.isPair, T)]; + + returnValue_p = pair_p | self.returnType1_g; + } + + classic::rule const& start() const { + return returnValue_p; + } + + }; +}; +// ReturnValueGrammar + } // \namespace wrap diff --git a/wrap/tests/testReturnValue.cpp b/wrap/tests/testReturnValue.cpp index 8b9774fe4..b604bf8f8 100644 --- a/wrap/tests/testReturnValue.cpp +++ b/wrap/tests/testReturnValue.cpp @@ -41,38 +41,6 @@ TEST( ReturnType, Constructor2 ) { EXPECT(actual.isPtr); } -//****************************************************************************** -// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html -struct ReturnTypeGrammar: public classic::grammar { - - wrap::ReturnType& result_; ///< successful parse will be placed in here - - TypeGrammar type_g; - - /// Construct ReturnType grammar and specify where result is placed - ReturnTypeGrammar(wrap::ReturnType& result) : - result_(result), type_g(result_) { - } - - /// Definition of type grammar - template - struct definition { - - classic::rule type_p; - - definition(ReturnTypeGrammar const& self) { - using namespace classic; - type_p = self.type_g >> !ch_p('*')[assign_a(self.result_.isPtr, T)]; - } - - classic::rule const& start() const { - return type_p; - } - - }; -}; -// ReturnTypeGrammar - //****************************************************************************** TEST( ReturnType, grammar ) { @@ -107,43 +75,6 @@ TEST( ReturnValue, Constructor ) { EXPECT(actual.isPair); } -//****************************************************************************** -// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html -struct ReturnValueGrammar: public classic::grammar { - - wrap::ReturnValue& result_; ///< successful parse will be placed in here - - ReturnTypeGrammar returnType1_g, returnType2_g; - - /// Construct type grammar and specify where result is placed - ReturnValueGrammar(wrap::ReturnValue& result) : - result_(result), returnType1_g(result.type1), returnType2_g(result.type2) { - } - - /// Definition of type grammar - template - struct definition { - - classic::rule pair_p, returnValue_p; - - definition(ReturnValueGrammar const& self) { - - using namespace classic; - - pair_p = (str_p("pair") >> '<' >> self.returnType1_g >> ',' - >> self.returnType2_g >> '>')[assign_a(self.result_.isPair, T)]; - - returnValue_p = pair_p | self.returnType1_g; - } - - classic::rule const& start() const { - return returnValue_p; - } - - }; -}; -// ReturnValueGrammar - //****************************************************************************** TEST( ReturnValue, grammar ) {