00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
00037 #define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
00038
00039 #ifndef _WIN32_WCE
00040 # include <errno.h>
00041 #endif
00042
00043 #include <algorithm>
00044 #include <string>
00045
00046 #include "gmock/internal/gmock-internal-utils.h"
00047 #include "gmock/internal/gmock-port.h"
00048
00049 namespace testing {
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 namespace internal {
00061
00062 template <typename F1, typename F2>
00063 class ActionAdaptor;
00064
00065
00066
00067
00068
00069
00070 template <typename T>
00071 class BuiltInDefaultValue {
00072 public:
00073
00074 static bool Exists() { return false; }
00075 static T Get() {
00076 Assert(false, __FILE__, __LINE__,
00077 "Default action undefined for the function return type.");
00078 return internal::Invalid<T>();
00079
00080
00081 }
00082 };
00083
00084
00085
00086 template <typename T>
00087 class BuiltInDefaultValue<const T> {
00088 public:
00089 static bool Exists() { return BuiltInDefaultValue<T>::Exists(); }
00090 static T Get() { return BuiltInDefaultValue<T>::Get(); }
00091 };
00092
00093
00094
00095 template <typename T>
00096 class BuiltInDefaultValue<T*> {
00097 public:
00098 static bool Exists() { return true; }
00099 static T* Get() { return NULL; }
00100 };
00101
00102
00103
00104 #define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
00105 template <> \
00106 class BuiltInDefaultValue<type> { \
00107 public: \
00108 static bool Exists() { return true; } \
00109 static type Get() { return value; } \
00110 }
00111
00112 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, );
00113 #if GTEST_HAS_GLOBAL_STRING
00114 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::string, "");
00115 #endif // GTEST_HAS_GLOBAL_STRING
00116 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::std::string, "");
00117 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(bool, false);
00118 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned char, '\0');
00119 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed char, '\0');
00120 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(char, '\0');
00121
00122
00123
00124
00125
00126
00127
00128 #if GMOCK_WCHAR_T_IS_NATIVE_
00129 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(wchar_t, 0U);
00130 #endif
00131
00132 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U);
00133 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0);
00134 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U);
00135 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0);
00136 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL);
00137 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L);
00138 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(UInt64, 0);
00139 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(Int64, 0);
00140 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(float, 0);
00141 GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0);
00142
00143 #undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
00144
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 template <typename T>
00161 class DefaultValue {
00162 public:
00163
00164
00165 static void Set(T x) {
00166 delete value_;
00167 value_ = new T(x);
00168 }
00169
00170
00171 static void Clear() {
00172 delete value_;
00173 value_ = NULL;
00174 }
00175
00176
00177 static bool IsSet() { return value_ != NULL; }
00178
00179
00180
00181 static bool Exists() {
00182 return IsSet() || internal::BuiltInDefaultValue<T>::Exists();
00183 }
00184
00185
00186
00187
00188 static T Get() {
00189 return value_ == NULL ?
00190 internal::BuiltInDefaultValue<T>::Get() : *value_;
00191 }
00192
00193 private:
00194 static const T* value_;
00195 };
00196
00197
00198
00199 template <typename T>
00200 class DefaultValue<T&> {
00201 public:
00202
00203 static void Set(T& x) {
00204 address_ = &x;
00205 }
00206
00207
00208 static void Clear() {
00209 address_ = NULL;
00210 }
00211
00212
00213 static bool IsSet() { return address_ != NULL; }
00214
00215
00216
00217 static bool Exists() {
00218 return IsSet() || internal::BuiltInDefaultValue<T&>::Exists();
00219 }
00220
00221
00222
00223
00224 static T& Get() {
00225 return address_ == NULL ?
00226 internal::BuiltInDefaultValue<T&>::Get() : *address_;
00227 }
00228
00229 private:
00230 static T* address_;
00231 };
00232
00233
00234
00235 template <>
00236 class DefaultValue<void> {
00237 public:
00238 static bool Exists() { return true; }
00239 static void Get() {}
00240 };
00241
00242
00243 template <typename T>
00244 const T* DefaultValue<T>::value_ = NULL;
00245
00246
00247 template <typename T>
00248 T* DefaultValue<T&>::address_ = NULL;
00249
00250
00251 template <typename F>
00252 class ActionInterface {
00253 public:
00254 typedef typename internal::Function<F>::Result Result;
00255 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
00256
00257 ActionInterface() {}
00258 virtual ~ActionInterface() {}
00259
00260
00261
00262
00263
00264 virtual Result Perform(const ArgumentTuple& args) = 0;
00265
00266 private:
00267 GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface);
00268 };
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279 template <typename F>
00280 class Action {
00281 public:
00282 typedef typename internal::Function<F>::Result Result;
00283 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
00284
00285
00286
00287 Action() : impl_(NULL) {}
00288
00289
00290
00291 explicit Action(ActionInterface<F>* impl) : impl_(impl) {}
00292
00293
00294 Action(const Action& action) : impl_(action.impl_) {}
00295
00296
00297
00298
00299
00300 template <typename Func>
00301 explicit Action(const Action<Func>& action);
00302
00303
00304 bool IsDoDefault() const { return impl_.get() == NULL; }
00305
00306
00307
00308
00309
00310
00311
00312 Result Perform(const ArgumentTuple& args) const {
00313 internal::Assert(
00314 !IsDoDefault(), __FILE__, __LINE__,
00315 "You are using DoDefault() inside a composite action like "
00316 "DoAll() or WithArgs(). This is not supported for technical "
00317 "reasons. Please instead spell out the default action, or "
00318 "assign the default action to an Action variable and use "
00319 "the variable in various places.");
00320 return impl_->Perform(args);
00321 }
00322
00323 private:
00324 template <typename F1, typename F2>
00325 friend class internal::ActionAdaptor;
00326
00327 internal::linked_ptr<ActionInterface<F> > impl_;
00328 };
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351 template <typename Impl>
00352 class PolymorphicAction {
00353 public:
00354 explicit PolymorphicAction(const Impl& impl) : impl_(impl) {}
00355
00356 template <typename F>
00357 operator Action<F>() const {
00358 return Action<F>(new MonomorphicImpl<F>(impl_));
00359 }
00360
00361 private:
00362 template <typename F>
00363 class MonomorphicImpl : public ActionInterface<F> {
00364 public:
00365 typedef typename internal::Function<F>::Result Result;
00366 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
00367
00368 explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
00369
00370 virtual Result Perform(const ArgumentTuple& args) {
00371 return impl_.template Perform<Result>(args);
00372 }
00373
00374 private:
00375 Impl impl_;
00376
00377 GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
00378 };
00379
00380 Impl impl_;
00381
00382 GTEST_DISALLOW_ASSIGN_(PolymorphicAction);
00383 };
00384
00385
00386
00387 template <typename F>
00388 Action<F> MakeAction(ActionInterface<F>* impl) {
00389 return Action<F>(impl);
00390 }
00391
00392
00393
00394
00395
00396
00397
00398
00399 template <typename Impl>
00400 inline PolymorphicAction<Impl> MakePolymorphicAction(const Impl& impl) {
00401 return PolymorphicAction<Impl>(impl);
00402 }
00403
00404 namespace internal {
00405
00406
00407
00408 template <typename F1, typename F2>
00409 class ActionAdaptor : public ActionInterface<F1> {
00410 public:
00411 typedef typename internal::Function<F1>::Result Result;
00412 typedef typename internal::Function<F1>::ArgumentTuple ArgumentTuple;
00413
00414 explicit ActionAdaptor(const Action<F2>& from) : impl_(from.impl_) {}
00415
00416 virtual Result Perform(const ArgumentTuple& args) {
00417 return impl_->Perform(args);
00418 }
00419
00420 private:
00421 const internal::linked_ptr<ActionInterface<F2> > impl_;
00422
00423 GTEST_DISALLOW_ASSIGN_(ActionAdaptor);
00424 };
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450 template <typename R>
00451 class ReturnAction {
00452 public:
00453
00454
00455
00456 explicit ReturnAction(R value) : value_(value) {}
00457
00458
00459
00460 template <typename F>
00461 operator Action<F>() const {
00462
00463
00464
00465
00466
00467
00468
00469
00470 typedef typename Function<F>::Result Result;
00471 GTEST_COMPILE_ASSERT_(
00472 !internal::is_reference<Result>::value,
00473 use_ReturnRef_instead_of_Return_to_return_a_reference);
00474 return Action<F>(new Impl<F>(value_));
00475 }
00476
00477 private:
00478
00479 template <typename F>
00480 class Impl : public ActionInterface<F> {
00481 public:
00482 typedef typename Function<F>::Result Result;
00483 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
00484
00485
00486
00487
00488
00489
00490
00491
00492 explicit Impl(R value)
00493 : value_(::testing::internal::ImplicitCast_<Result>(value)) {}
00494
00495 virtual Result Perform(const ArgumentTuple&) { return value_; }
00496
00497 private:
00498 GTEST_COMPILE_ASSERT_(!internal::is_reference<Result>::value,
00499 Result_cannot_be_a_reference_type);
00500 Result value_;
00501
00502 GTEST_DISALLOW_ASSIGN_(Impl);
00503 };
00504
00505 R value_;
00506
00507 GTEST_DISALLOW_ASSIGN_(ReturnAction);
00508 };
00509
00510
00511 class ReturnNullAction {
00512 public:
00513
00514 template <typename Result, typename ArgumentTuple>
00515 static Result Perform(const ArgumentTuple&) {
00516 GTEST_COMPILE_ASSERT_(internal::is_pointer<Result>::value,
00517 ReturnNull_can_be_used_to_return_a_pointer_only);
00518 return NULL;
00519 }
00520 };
00521
00522
00523 class ReturnVoidAction {
00524 public:
00525
00526 template <typename Result, typename ArgumentTuple>
00527 static void Perform(const ArgumentTuple&) {
00528 CompileAssertTypesEqual<void, Result>();
00529 }
00530 };
00531
00532
00533
00534
00535 template <typename T>
00536 class ReturnRefAction {
00537 public:
00538
00539 explicit ReturnRefAction(T& ref) : ref_(ref) {}
00540
00541
00542
00543 template <typename F>
00544 operator Action<F>() const {
00545 typedef typename Function<F>::Result Result;
00546
00547
00548
00549 GTEST_COMPILE_ASSERT_(internal::is_reference<Result>::value,
00550 use_Return_instead_of_ReturnRef_to_return_a_value);
00551 return Action<F>(new Impl<F>(ref_));
00552 }
00553
00554 private:
00555
00556 template <typename F>
00557 class Impl : public ActionInterface<F> {
00558 public:
00559 typedef typename Function<F>::Result Result;
00560 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
00561
00562 explicit Impl(T& ref) : ref_(ref) {}
00563
00564 virtual Result Perform(const ArgumentTuple&) {
00565 return ref_;
00566 }
00567
00568 private:
00569 T& ref_;
00570
00571 GTEST_DISALLOW_ASSIGN_(Impl);
00572 };
00573
00574 T& ref_;
00575
00576 GTEST_DISALLOW_ASSIGN_(ReturnRefAction);
00577 };
00578
00579
00580
00581
00582 template <typename T>
00583 class ReturnRefOfCopyAction {
00584 public:
00585
00586
00587 explicit ReturnRefOfCopyAction(const T& value) : value_(value) {}
00588
00589
00590
00591 template <typename F>
00592 operator Action<F>() const {
00593 typedef typename Function<F>::Result Result;
00594
00595
00596
00597 GTEST_COMPILE_ASSERT_(
00598 internal::is_reference<Result>::value,
00599 use_Return_instead_of_ReturnRefOfCopy_to_return_a_value);
00600 return Action<F>(new Impl<F>(value_));
00601 }
00602
00603 private:
00604
00605 template <typename F>
00606 class Impl : public ActionInterface<F> {
00607 public:
00608 typedef typename Function<F>::Result Result;
00609 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
00610
00611 explicit Impl(const T& value) : value_(value) {}
00612
00613 virtual Result Perform(const ArgumentTuple&) {
00614 return value_;
00615 }
00616
00617 private:
00618 T value_;
00619
00620 GTEST_DISALLOW_ASSIGN_(Impl);
00621 };
00622
00623 const T value_;
00624
00625 GTEST_DISALLOW_ASSIGN_(ReturnRefOfCopyAction);
00626 };
00627
00628
00629 class DoDefaultAction {
00630 public:
00631
00632
00633 template <typename F>
00634 operator Action<F>() const { return Action<F>(NULL); }
00635 };
00636
00637
00638
00639 template <typename T1, typename T2>
00640 class AssignAction {
00641 public:
00642 AssignAction(T1* ptr, T2 value) : ptr_(ptr), value_(value) {}
00643
00644 template <typename Result, typename ArgumentTuple>
00645 void Perform(const ArgumentTuple& ) const {
00646 *ptr_ = value_;
00647 }
00648
00649 private:
00650 T1* const ptr_;
00651 const T2 value_;
00652
00653 GTEST_DISALLOW_ASSIGN_(AssignAction);
00654 };
00655
00656 #if !GTEST_OS_WINDOWS_MOBILE
00657
00658
00659
00660 template <typename T>
00661 class SetErrnoAndReturnAction {
00662 public:
00663 SetErrnoAndReturnAction(int errno_value, T result)
00664 : errno_(errno_value),
00665 result_(result) {}
00666 template <typename Result, typename ArgumentTuple>
00667 Result Perform(const ArgumentTuple& ) const {
00668 errno = errno_;
00669 return result_;
00670 }
00671
00672 private:
00673 const int errno_;
00674 const T result_;
00675
00676 GTEST_DISALLOW_ASSIGN_(SetErrnoAndReturnAction);
00677 };
00678
00679 #endif // !GTEST_OS_WINDOWS_MOBILE
00680
00681
00682
00683
00684
00685 template <size_t N, typename A, bool kIsProto>
00686 class SetArgumentPointeeAction {
00687 public:
00688
00689
00690 explicit SetArgumentPointeeAction(const A& value) : value_(value) {}
00691
00692 template <typename Result, typename ArgumentTuple>
00693 void Perform(const ArgumentTuple& args) const {
00694 CompileAssertTypesEqual<void, Result>();
00695 *::std::tr1::get<N>(args) = value_;
00696 }
00697
00698 private:
00699 const A value_;
00700
00701 GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
00702 };
00703
00704 template <size_t N, typename Proto>
00705 class SetArgumentPointeeAction<N, Proto, true> {
00706 public:
00707
00708
00709
00710
00711 explicit SetArgumentPointeeAction(const Proto& proto) : proto_(new Proto) {
00712 proto_->CopyFrom(proto);
00713 }
00714
00715 template <typename Result, typename ArgumentTuple>
00716 void Perform(const ArgumentTuple& args) const {
00717 CompileAssertTypesEqual<void, Result>();
00718 ::std::tr1::get<N>(args)->CopyFrom(*proto_);
00719 }
00720
00721 private:
00722 const internal::linked_ptr<Proto> proto_;
00723
00724 GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
00725 };
00726
00727
00728
00729
00730
00731
00732 template <typename FunctionImpl>
00733 class InvokeWithoutArgsAction {
00734 public:
00735
00736
00737 explicit InvokeWithoutArgsAction(FunctionImpl function_impl)
00738 : function_impl_(function_impl) {}
00739
00740
00741
00742 template <typename Result, typename ArgumentTuple>
00743 Result Perform(const ArgumentTuple&) { return function_impl_(); }
00744
00745 private:
00746 FunctionImpl function_impl_;
00747
00748 GTEST_DISALLOW_ASSIGN_(InvokeWithoutArgsAction);
00749 };
00750
00751
00752 template <class Class, typename MethodPtr>
00753 class InvokeMethodWithoutArgsAction {
00754 public:
00755 InvokeMethodWithoutArgsAction(Class* obj_ptr, MethodPtr method_ptr)
00756 : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}
00757
00758 template <typename Result, typename ArgumentTuple>
00759 Result Perform(const ArgumentTuple&) const {
00760 return (obj_ptr_->*method_ptr_)();
00761 }
00762
00763 private:
00764 Class* const obj_ptr_;
00765 const MethodPtr method_ptr_;
00766
00767 GTEST_DISALLOW_ASSIGN_(InvokeMethodWithoutArgsAction);
00768 };
00769
00770
00771 template <typename A>
00772 class IgnoreResultAction {
00773 public:
00774 explicit IgnoreResultAction(const A& action) : action_(action) {}
00775
00776 template <typename F>
00777 operator Action<F>() const {
00778
00779
00780
00781
00782
00783
00784
00785
00786 typedef typename internal::Function<F>::Result Result;
00787
00788
00789 CompileAssertTypesEqual<void, Result>();
00790
00791 return Action<F>(new Impl<F>(action_));
00792 }
00793
00794 private:
00795 template <typename F>
00796 class Impl : public ActionInterface<F> {
00797 public:
00798 typedef typename internal::Function<F>::Result Result;
00799 typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
00800
00801 explicit Impl(const A& action) : action_(action) {}
00802
00803 virtual void Perform(const ArgumentTuple& args) {
00804
00805 action_.Perform(args);
00806 }
00807
00808 private:
00809
00810
00811 typedef typename internal::Function<F>::MakeResultIgnoredValue
00812 OriginalFunction;
00813
00814 const Action<OriginalFunction> action_;
00815
00816 GTEST_DISALLOW_ASSIGN_(Impl);
00817 };
00818
00819 const A action_;
00820
00821 GTEST_DISALLOW_ASSIGN_(IgnoreResultAction);
00822 };
00823
00824
00825
00826
00827
00828
00829
00830
00831 template <typename T>
00832 class ReferenceWrapper {
00833 public:
00834
00835 explicit ReferenceWrapper(T& l_value) : pointer_(&l_value) {}
00836
00837
00838
00839 operator T&() const { return *pointer_; }
00840 private:
00841 T* pointer_;
00842 };
00843
00844
00845 template <typename T>
00846 void PrintTo(const ReferenceWrapper<T>& ref, ::std::ostream* os) {
00847 T& value = ref;
00848 UniversalPrinter<T&>::Print(value, os);
00849 }
00850
00851
00852
00853 template <typename Action1, typename Action2>
00854 class DoBothAction {
00855 public:
00856 DoBothAction(Action1 action1, Action2 action2)
00857 : action1_(action1), action2_(action2) {}
00858
00859
00860
00861 template <typename F>
00862 operator Action<F>() const {
00863 return Action<F>(new Impl<F>(action1_, action2_));
00864 }
00865
00866 private:
00867
00868 template <typename F>
00869 class Impl : public ActionInterface<F> {
00870 public:
00871 typedef typename Function<F>::Result Result;
00872 typedef typename Function<F>::ArgumentTuple ArgumentTuple;
00873 typedef typename Function<F>::MakeResultVoid VoidResult;
00874
00875 Impl(const Action<VoidResult>& action1, const Action<F>& action2)
00876 : action1_(action1), action2_(action2) {}
00877
00878 virtual Result Perform(const ArgumentTuple& args) {
00879 action1_.Perform(args);
00880 return action2_.Perform(args);
00881 }
00882
00883 private:
00884 const Action<VoidResult> action1_;
00885 const Action<F> action2_;
00886
00887 GTEST_DISALLOW_ASSIGN_(Impl);
00888 };
00889
00890 Action1 action1_;
00891 Action2 action2_;
00892
00893 GTEST_DISALLOW_ASSIGN_(DoBothAction);
00894 };
00895
00896 }
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928 typedef internal::IgnoredValue Unused;
00929
00930
00931
00932
00933
00934 template <typename To>
00935 template <typename From>
00936 Action<To>::Action(const Action<From>& from)
00937 : impl_(new internal::ActionAdaptor<To, From>(from)) {}
00938
00939
00940
00941
00942 template <typename R>
00943 internal::ReturnAction<R> Return(R value) {
00944 return internal::ReturnAction<R>(value);
00945 }
00946
00947
00948 inline PolymorphicAction<internal::ReturnNullAction> ReturnNull() {
00949 return MakePolymorphicAction(internal::ReturnNullAction());
00950 }
00951
00952
00953 inline PolymorphicAction<internal::ReturnVoidAction> Return() {
00954 return MakePolymorphicAction(internal::ReturnVoidAction());
00955 }
00956
00957
00958 template <typename R>
00959 inline internal::ReturnRefAction<R> ReturnRef(R& x) {
00960 return internal::ReturnRefAction<R>(x);
00961 }
00962
00963
00964
00965
00966 template <typename R>
00967 inline internal::ReturnRefOfCopyAction<R> ReturnRefOfCopy(const R& x) {
00968 return internal::ReturnRefOfCopyAction<R>(x);
00969 }
00970
00971
00972 inline internal::DoDefaultAction DoDefault() {
00973 return internal::DoDefaultAction();
00974 }
00975
00976
00977
00978 template <size_t N, typename T>
00979 PolymorphicAction<
00980 internal::SetArgumentPointeeAction<
00981 N, T, internal::IsAProtocolMessage<T>::value> >
00982 SetArgPointee(const T& x) {
00983 return MakePolymorphicAction(internal::SetArgumentPointeeAction<
00984 N, T, internal::IsAProtocolMessage<T>::value>(x));
00985 }
00986
00987 #if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)
00988
00989
00990
00991 template <size_t N>
00992 PolymorphicAction<
00993 internal::SetArgumentPointeeAction<N, const char*, false> >
00994 SetArgPointee(const char* p) {
00995 return MakePolymorphicAction(internal::SetArgumentPointeeAction<
00996 N, const char*, false>(p));
00997 }
00998
00999 template <size_t N>
01000 PolymorphicAction<
01001 internal::SetArgumentPointeeAction<N, const wchar_t*, false> >
01002 SetArgPointee(const wchar_t* p) {
01003 return MakePolymorphicAction(internal::SetArgumentPointeeAction<
01004 N, const wchar_t*, false>(p));
01005 }
01006 #endif
01007
01008
01009 template <size_t N, typename T>
01010 PolymorphicAction<
01011 internal::SetArgumentPointeeAction<
01012 N, T, internal::IsAProtocolMessage<T>::value> >
01013 SetArgumentPointee(const T& x) {
01014 return MakePolymorphicAction(internal::SetArgumentPointeeAction<
01015 N, T, internal::IsAProtocolMessage<T>::value>(x));
01016 }
01017
01018
01019 template <typename T1, typename T2>
01020 PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
01021 return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val));
01022 }
01023
01024 #if !GTEST_OS_WINDOWS_MOBILE
01025
01026
01027 template <typename T>
01028 PolymorphicAction<internal::SetErrnoAndReturnAction<T> >
01029 SetErrnoAndReturn(int errval, T result) {
01030 return MakePolymorphicAction(
01031 internal::SetErrnoAndReturnAction<T>(errval, result));
01032 }
01033
01034 #endif // !GTEST_OS_WINDOWS_MOBILE
01035
01036
01037
01038
01039 template <typename FunctionImpl>
01040 PolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl> >
01041 InvokeWithoutArgs(FunctionImpl function_impl) {
01042 return MakePolymorphicAction(
01043 internal::InvokeWithoutArgsAction<FunctionImpl>(function_impl));
01044 }
01045
01046
01047
01048 template <class Class, typename MethodPtr>
01049 PolymorphicAction<internal::InvokeMethodWithoutArgsAction<Class, MethodPtr> >
01050 InvokeWithoutArgs(Class* obj_ptr, MethodPtr method_ptr) {
01051 return MakePolymorphicAction(
01052 internal::InvokeMethodWithoutArgsAction<Class, MethodPtr>(
01053 obj_ptr, method_ptr));
01054 }
01055
01056
01057
01058
01059 template <typename A>
01060 inline internal::IgnoreResultAction<A> IgnoreResult(const A& an_action) {
01061 return internal::IgnoreResultAction<A>(an_action);
01062 }
01063
01064
01065
01066
01067
01068
01069
01070
01071 template <typename T>
01072 inline internal::ReferenceWrapper<T> ByRef(T& l_value) {
01073 return internal::ReferenceWrapper<T>(l_value);
01074 }
01075
01076 }
01077
01078 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_