Thread: [Mockpp-commits] mockpp/mockpp gen_visitablemethod_N.pl,1.3,1.4
Brought to you by:
ewald-arnold
From: Ewald A. <ewa...@us...> - 2005-10-25 19:05:47
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31298/mockpp Modified Files: gen_visitablemethod_N.pl Log Message: basic file set Index: gen_visitablemethod_N.pl =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/gen_visitablemethod_N.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gen_visitablemethod_N.pl 24 Oct 2005 19:08:44 -0000 1.3 +++ gen_visitablemethod_N.pl 25 Oct 2005 19:05:29 -0000 1.4 @@ -13,16 +13,16 @@ $totalNumArgs = $ARGV[0]; if ($totalNumArgs < 5) { $totalNumArgs = 5; } - + for ($numArgs = 0; $numArgs <= $totalNumArgs; ++$numArgs) { open OUT, ">VisitableMockMethod" . $numArgs . ".h"; print "Creating VisitableMockMethod" . $numArgs . ".h\n"; -print OUT +print OUT "/** \@file \@brief Visitable Mock Method with $numArgs parameters. Generated with gen_visitablemethod_N.pl. - + \$I" . "d: VisitableMockMethod" . $numArgs . ".h,v 1.7 2005/10/19 20:53:09 ewald-arnold Exp \$ ***************************************************************************/ @@ -61,7 +61,7 @@ namespace mockpp { - + "; $templateParms = ""; @@ -72,20 +72,20 @@ } $templateParms .= "typename P$i"; } - if ($numArgs > 0) { + if ($numArgs > 0) { $templateParms_colon = ", " . $templateParms; } -# print OUT "// templateParms: $templateParms\n"; - +# print OUT "// templateParms: $templateParms\n"; + $templateArgs_colon = ""; $_ = $templateParms; s/typename //g; $templateArgs = $_; - if ($numArgs > 0) { + if ($numArgs > 0) { $templateArgs_colon = ", ". $templateArgs; } -# print OUT "// templateArgs: $templateArgs\n"; - +# print OUT "// templateArgs: $templateArgs\n"; + $parms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { @@ -94,7 +94,7 @@ $parms .= "const P$i &p$i"; } -# print OUT "// parms: $parms\n"; +# print OUT "// parms: $parms\n"; $holderParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { @@ -104,7 +104,7 @@ $holderParms .= "const ConstraintHolder<P$i> &p$i"; } -# print OUT "// holderParms: $holderParms\n"; +# print OUT "// holderParms: $holderParms\n"; $args = ""; for ($i = 1; $i <= $numArgs; ++$i) { @@ -114,8 +114,8 @@ $args .= "p$i"; } -# print OUT "// args: $args\n"; - +# print OUT "// args: $args\n"; + $boundArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { @@ -124,15 +124,15 @@ $boundArgs .= "args->a$i"; } -# print OUT "// boundArgs: $boundArgs\n"; +# print OUT "// boundArgs: $boundArgs\n"; $argsAsMembers = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argsAsMembers .= "P$i p$i;"; } -# print OUT "// argsAsMembers: $argsAsMembers\n"; - +# print OUT "// argsAsMembers: $argsAsMembers\n"; + $copyParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { @@ -141,7 +141,7 @@ $copyParms .= "P$i ia$i"; } -# print OUT "// copyParms: $copyParms\n"; +# print OUT "// copyParms: $copyParms\n"; $initArgs = ""; if ($numArgs > 0) { @@ -154,7 +154,7 @@ $initArgs .= "p$i(ip$i)"; } -# print OUT "// initArgs: $initArgs\n"; +# print OUT "// initArgs: $initArgs\n"; $argTypes = ""; for ($i = 1; $i <= $numArgs; ++$i) { @@ -163,8 +163,8 @@ # print OUT "// argTypes: $argTypes\n\n\n"; -print OUT -"/** Common stuf to set up visitable mock method expectations with " . $numArgs . " parameters. +print OUT +"/** Common stuff to set up visitable mock method expectations with " . $numArgs . " parameters. * \@ingroup grp_controller */ template <typename R" . $templateParms_colon . "> @@ -181,10 +181,10 @@ if ($numArgs > 0) { -print OUT " - , responseThrowables(this->getMethodName() + MOCKPP_PCHAR(\"/responseThrowables\") , this)"; +print OUT " + , responseThrowables(this->getMethodName() + MOCKPP_PCHAR(\"/responseThrowables\") , this)"; } - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " , parameter" . $p . "(this->getMethodName() + MOCKPP_PCHAR(\"/parameter" . $p . "\"), this)"; } @@ -193,16 +193,16 @@ } /** Set up expectations with constraints."; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } - + print OUT " */ void forward (" . $holderParms . ") const { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); - this->getParent()->addExpectedMethod(this->getMethodName());"; + MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); + this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier());"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " parameter" . $p . ".addExpected(p" . $p . ");"; } @@ -215,20 +215,19 @@ if ($numArgs > 0) { -print OUT " +print OUT " /** Perform the internals to verify a mocked method."; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } - + print OUT " */ void forward_param(" . $parms . ") const { - - if (!this->method->isActivated() ) + if (!this->getVisitableMockObject()->isActivated() ) { - this->getParent()->addExpectedMethod(this->getMethodName());"; + this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier());"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " parameter" . $p . ".addExpected(p" . $p . ");"; } @@ -240,7 +239,7 @@ { try { - this->getParent()->addActualMethod(this->getMethodName()); + this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); Throwable *t; if (this->responseValues.find(t, " . $args . ")) @@ -265,37 +264,37 @@ print OUT " } - }" ; -} + } +" ; +} else { print OUT " /** Perform the internals to verify a mocked method."; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } - + print OUT " */ void forward_param(" . $parms . ") const { - - if (!this->method->isActivated() ) + if (!this->getVisitableMockObject()->isActivated() ) { - this->getParent()->addExpectedMethod(this->getMethodName()); + this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); } else { - this->getParent()->addActualMethod(this->getMethodName()); + this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); this->throwAvailableException(); } - }"; + }"; } print OUT " public: - + /** Helper object to easily set up the visitable expectations. * \@ingroup grp_controller */ @@ -304,63 +303,67 @@ public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; - + + /** Construct the controller object. + * \@meth poiinter to according method mock. + */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { - } -"; - + }"; + if ($numArgs > 0) { -print OUT " +print OUT " + /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * \@param t the throwable object"; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } - -print OUT " + +print OUT " * \@param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, " . $parms . ", unsigned count = MOCKPP_UNLIMITED) { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); + MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, " . $args . ", count); } - + /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * \@param t the throwable object"; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " - * \@param p" . $p . " mock method parameter " . $p; } + * \@param p" . $p . " mock method parameter " . $p; } -print OUT " +print OUT " * \@param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, " . $holderParms . ", unsigned count = MOCKPP_UNLIMITED) { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); + MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, " . $args . ", count); }"; } -print OUT " +print OUT " }; - friend class ControllerFor; -"; + friend class ControllerFor;"; if ($numArgs > 0) { print OUT " + private: - - mutable ResponseThrowableVector" . $numArgs . "<" . $templateArgs . "> responseThrowables;"; + + mutable ResponseThrowableVector" . $numArgs . "<" . $templateArgs . "> responseThrowables; +"; } for($p = 1; $p <= $numArgs; ++$p) { print OUT " @@ -374,7 +377,7 @@ * \@ingroup grp_controller */ template <typename R" . $templateParms_colon . "> -class VisitableMockMethod" . $numArgs . " +class VisitableMockMethod" . $numArgs . " : public VisitableMockMethod" . $numArgs . "Common<R" . $templateArgs_colon . "> { public: @@ -385,19 +388,19 @@ */ VisitableMockMethod" . $numArgs . "(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod" . $numArgs . "Common<R" . $templateArgs_colon . ">(name, parent)"; - + if ($numArgs > 0) { -print OUT " - , responseValues(this->getMethodName() + MOCKPP_PCHAR(\"/responseValues\") , this)"; +print OUT " + , responseValues(this->getMethodName() + MOCKPP_PCHAR(\"/responseValues\") , this)"; } - -print OUT " + +print OUT " { } /** Actually verifies the mocked method. Must be called by the client code."; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } @@ -413,7 +416,7 @@ R ret_val; if (this->method->responseValues.find(ret_val, " . $args . ")) - return ret_val; + return ret_val; "; } @@ -429,32 +432,32 @@ public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; - - /** Helper object to easily set up the visitable expectations. - * \@ingroup grp_controller + + /** Construct the controller object. + * \@meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { }"; - + if ($numArgs > 0) { -print OUT " +print OUT " /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * \@param rv the return value"; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } -print OUT " +print OUT " * \@param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, " . $parms . ", unsigned count = MOCKPP_UNLIMITED) { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); + MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, " . $args . ", count); } @@ -462,31 +465,32 @@ * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * \@param rv the return value"; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } -print OUT " +print OUT " * \@param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, " . $holderParms . ", unsigned count = MOCKPP_UNLIMITED) { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); + MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, " . $args . ", count); } "; } -print OUT " +print OUT " }; friend class ControllerFor;"; if ($numArgs > 0) { -print OUT " +print OUT " + private: - + mutable ResponseVector" . $numArgs . "<R, " . $templateArgs . "> responseValues;"; } @@ -499,7 +503,7 @@ * \@ingroup grp_controller */ template <" . $templateParms . "> -class VisitableMockMethod" . $numArgs . "<void" . $templateArgs_colon . "> +class VisitableMockMethod" . $numArgs . "<void" . $templateArgs_colon . "> : public VisitableMockMethod" . $numArgs . "Common<void" . $templateArgs_colon . "> { public: @@ -514,7 +518,7 @@ } /** Actually verifies the mocked method. Must be called by the client code."; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } @@ -533,15 +537,14 @@ public: typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; - - /** Helper object to easily set up the visitable expectations. - * \@ingroup grp_controller + + /** Construct the controller object. + * \@meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) { } - }; friend class ControllerFor; |