diff options
| author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-02-19 22:30:22 +0000 | 
|---|---|---|
| committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-02-19 22:30:22 +0000 | 
| commit | 38ca64dd5f8dd4a5ee1822d805f16911213f18fb (patch) | |
| tree | b1d01ee93e3f13594d87292640af07719a954692 /include | |
| parent | 4a5330d3d6e582248dbcf602f70048dc72cc8182 (diff) | |
| download | googletest-38ca64dd5f8dd4a5ee1822d805f16911213f18fb.tar.gz googletest-38ca64dd5f8dd4a5ee1822d805f16911213f18fb.tar.bz2 googletest-38ca64dd5f8dd4a5ee1822d805f16911213f18fb.zip | |
Fixes link errors due to an MS VC bug.  By Vlad Losev.
Diffstat (limited to 'include')
| -rw-r--r-- | include/gmock/gmock-generated-actions.h | 71 | ||||
| -rw-r--r-- | include/gmock/gmock-generated-actions.h.pump | 72 | 
2 files changed, 76 insertions, 67 deletions
| diff --git a/include/gmock/gmock-generated-actions.h b/include/gmock/gmock-generated-actions.h index 64475910..ee26f385 100644 --- a/include/gmock/gmock-generated-actions.h +++ b/include/gmock/gmock-generated-actions.h @@ -908,31 +908,33 @@ class WithArgsAction {    explicit WithArgsAction(const InnerAction& action) : action_(action) {}    template <typename F> -  operator Action<F>() const { +  operator Action<F>() const { return MakeAction(new Impl<F>(action_)); } + + private: +  template <typename F> +  class Impl : public ActionInterface<F> { +   public:      typedef typename Function<F>::Result Result;      typedef typename Function<F>::ArgumentTuple ArgumentTuple; -    typedef typename SelectArgs<Result, ArgumentTuple, -        k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type -            InnerFunctionType; -    class Impl : public ActionInterface<F> { -     public: -      explicit Impl(const InnerAction& action) : action_(action) {} +    explicit Impl(const InnerAction& action) : action_(action) {} -      virtual Result Perform(const ArgumentTuple& args) { -        return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, -            k4, k5, k6, k7, k8, k9, k10>::Select(args)); -      } -     private: -      Action<InnerFunctionType> action_; -    }; +    virtual Result Perform(const ArgumentTuple& args) { +      return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, k4, +          k5, k6, k7, k8, k9, k10>::Select(args)); +    } + +   private: +    typedef typename SelectArgs<Result, ArgumentTuple, +        k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType; + +    Action<InnerFunctionType> action_; +  }; -    return MakeAction(new Impl(action_)); -  } - private:    const InnerAction action_;  }; +  // Does two actions sequentially.  Used for implementing the DoAll(a1,  // a2, ...) action.  template <typename Action1, typename Action2> @@ -945,28 +947,31 @@ class DoBothAction {    // to be used in ANY function of compatible type.    template <typename F>    operator Action<F>() const { +    return Action<F>(new Impl<F>(action1_, action2_)); +  } + + private: +  // Implements the DoAll(...) action for a particular function type F. +  template <typename F> +  class Impl : public ActionInterface<F> { +   public:      typedef typename Function<F>::Result Result;      typedef typename Function<F>::ArgumentTuple ArgumentTuple;      typedef typename Function<F>::MakeResultVoid VoidResult; -    // Implements the DoAll(...) action for a particular function type F. -    class Impl : public ActionInterface<F> { -     public: -      Impl(const Action<VoidResult>& action1, const Action<F>& action2) -          : action1_(action1), action2_(action2) {} +    Impl(const Action<VoidResult>& action1, const Action<F>& action2) +        : action1_(action1), action2_(action2) {} -      virtual Result Perform(const ArgumentTuple& args) { -        action1_.Perform(args); -        return action2_.Perform(args); -      } -     private: -      const Action<VoidResult> action1_; -      const Action<F> action2_; -    }; +    virtual Result Perform(const ArgumentTuple& args) { +      action1_.Perform(args); +      return action2_.Perform(args); +    } + +   private: +    const Action<VoidResult> action1_; +    const Action<F> action2_; +  }; -    return Action<F>(new Impl(action1_, action2_)); -  } - private:    Action1 action1_;    Action2 action2_;  }; diff --git a/include/gmock/gmock-generated-actions.h.pump b/include/gmock/gmock-generated-actions.h.pump index 1db69d1c..f8bec55d 100644 --- a/include/gmock/gmock-generated-actions.h.pump +++ b/include/gmock/gmock-generated-actions.h.pump @@ -333,27 +333,28 @@ class WithArgsAction {    explicit WithArgsAction(const InnerAction& action) : action_(action) {}    template <typename F> -  operator Action<F>() const { +  operator Action<F>() const { return MakeAction(new Impl<F>(action_)); } + + private: +  template <typename F> +  class Impl : public ActionInterface<F> { +   public:      typedef typename Function<F>::Result Result;      typedef typename Function<F>::ArgumentTuple ArgumentTuple; -    typedef typename SelectArgs<Result, ArgumentTuple, -        $ks>::type -            InnerFunctionType; -    class Impl : public ActionInterface<F> { -     public: -      explicit Impl(const InnerAction& action) : action_(action) {} +    explicit Impl(const InnerAction& action) : action_(action) {} -      virtual Result Perform(const ArgumentTuple& args) { -        return action_.Perform(SelectArgs<Result, ArgumentTuple, $ks>::Select(args)); -      } -     private: -      Action<InnerFunctionType> action_; -    }; +    virtual Result Perform(const ArgumentTuple& args) { +      return action_.Perform(SelectArgs<Result, ArgumentTuple, $ks>::Select(args)); +    } + +   private: +    typedef typename SelectArgs<Result, ArgumentTuple, +        $ks>::type InnerFunctionType; + +    Action<InnerFunctionType> action_; +  }; -    return MakeAction(new Impl(action_)); -  } - private:    const InnerAction action_;  }; @@ -369,28 +370,31 @@ class DoBothAction {    // to be used in ANY function of compatible type.    template <typename F>    operator Action<F>() const { +    return Action<F>(new Impl<F>(action1_, action2_)); +  } + + private: +  // Implements the DoAll(...) action for a particular function type F. +  template <typename F> +  class Impl : public ActionInterface<F> { +   public:      typedef typename Function<F>::Result Result;      typedef typename Function<F>::ArgumentTuple ArgumentTuple;      typedef typename Function<F>::MakeResultVoid VoidResult; -    // Implements the DoAll(...) action for a particular function type F. -    class Impl : public ActionInterface<F> { -     public: -      Impl(const Action<VoidResult>& action1, const Action<F>& action2) -          : action1_(action1), action2_(action2) {} - -      virtual Result Perform(const ArgumentTuple& args) { -        action1_.Perform(args); -        return action2_.Perform(args); -      } -     private: -      const Action<VoidResult> action1_; -      const Action<F> action2_; -    }; - -    return Action<F>(new Impl(action1_, action2_)); -  } - private: +    Impl(const Action<VoidResult>& action1, const Action<F>& action2) +        : action1_(action1), action2_(action2) {} + +    virtual Result Perform(const ArgumentTuple& args) { +      action1_.Perform(args); +      return action2_.Perform(args); +    } + +   private: +    const Action<VoidResult> action1_; +    const Action<F> action2_; +  }; +    Action1 action1_;    Action2 action2_;  }; | 
