File indexing completed on 2024-04-21 04:50:51

0001 #pragma once
0002 /*
0003  *  FakeIt - A Simplified C++ Mocking Framework
0004  *  Copyright (c) Eran Pe'er 2013
0005  *  Generated: 2018-08-17 00:22:01.852984
0006  *  Distributed under the MIT License. Please refer to the LICENSE file at:
0007  *  https://github.com/eranpeer/FakeIt
0008  */
0009 /*
0010     SPDX-FileCopyrightText: (c) Eran Pe'er 2013 https://github.com/eranpeer/FakeIt
0011     SPDX-License-Identifier: MIT
0012 */
0013 
0014 #if defined __GNUC__
0015 #    pragma GCC diagnostic push
0016 #    pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
0017 #    pragma GCC diagnostic ignored "-Wsuggest-override"
0018 #endif
0019 
0020 
0021 
0022 #include <functional>
0023 #include <memory>
0024 #include <set>
0025 #include <vector>
0026 #include <stdexcept>
0027 #if defined (__GNUG__) || _MSC_VER >= 1900
0028 #define THROWS noexcept(false)
0029 #define NO_THROWS noexcept(true)
0030 #elif defined (_MSC_VER)
0031 #define THROWS throw(...)
0032 #define NO_THROWS
0033 #endif
0034 #include <typeinfo>
0035 #include <unordered_set>
0036 #include <tuple>
0037 #include <string>
0038 #include <iosfwd>
0039 #include <atomic>
0040 #include <tuple>
0041 
0042 
0043 namespace fakeit {
0044 
0045     template<class C>
0046     struct naked_type {
0047         typedef typename std::remove_cv<typename std::remove_reference<C>::type>::type type;
0048     };
0049 
0050     template< class T > struct tuple_arg         { typedef T  type; };
0051     template< class T > struct tuple_arg < T& >  { typedef T& type; };
0052     template< class T > struct tuple_arg < T&& > { typedef T&&  type; };
0053 
0054 
0055 
0056 
0057     template<typename... arglist>
0058     using ArgumentsTuple = std::tuple < arglist... > ;
0059 
0060     template< class T > struct test_arg         { typedef T& type; };
0061     template< class T > struct test_arg< T& >   { typedef T& type; };
0062     template< class T > struct test_arg< T&& >  { typedef T& type; };
0063 
0064     template< class T > struct production_arg         { typedef T& type; };
0065     template< class T > struct production_arg< T& >   { typedef T& type; };
0066     template< class T > struct production_arg< T&& >  { typedef T&&  type; };
0067 
0068     template <typename T>
0069     class is_ostreamable {
0070         struct no {};
0071 #if defined(_MSC_VER) && _MSC_VER < 1900
0072         template <typename T1>
0073         static decltype(operator<<(std::declval<std::ostream&>(), std::declval<const T1>())) test(std::ostream &s, const T1 &t);
0074 #else
0075         template <typename T1>
0076         static auto test(std::ostream &s, const T1 &t) -> decltype(s << t);
0077 #endif
0078         static no test(...);
0079     public:
0080 
0081         static const bool value =
0082             std::is_arithmetic<T>::value ||
0083             std::is_pointer<T>::value ||
0084             std::is_same<decltype(test(*(std::ostream *)nullptr,
0085                 std::declval<T>())), std::ostream &>::value;
0086     };
0087 
0088 
0089     template <>
0090     class is_ostreamable<std::ios_base& (*)(std::ios_base&)> {
0091     public:
0092         static const bool value = true;
0093     };
0094 
0095     template <typename CharT, typename Traits>
0096     class is_ostreamable<std::basic_ios<CharT,Traits>& (*)(std::basic_ios<CharT,Traits>&)> {
0097     public:
0098         static const bool value = true;
0099     };
0100 
0101     template <typename CharT, typename Traits>
0102     class is_ostreamable<std::basic_ostream<CharT,Traits>& (*)(std::basic_ostream<CharT,Traits>&)> {
0103     public:
0104         static const bool value = true;
0105     };
0106 
0107     template<typename R, typename... arglist>
0108     struct VTableMethodType {
0109 #if defined (__GNUG__)
0110         typedef R(*type)(void *, arglist...);
0111 #elif defined (_MSC_VER)
0112         typedef R(__thiscall *type)(void *, arglist...);
0113 #endif
0114     };
0115 }
0116 #include <typeinfo>
0117 #include <tuple>
0118 #include <string>
0119 #include <iosfwd>
0120 #include <sstream>
0121 #include <string>
0122 
0123 namespace fakeit {
0124 
0125     struct FakeitContext;
0126 
0127     template<typename C>
0128     struct MockObject {
0129         virtual ~MockObject() THROWS { };
0130 
0131         virtual C &get() = 0;
0132 
0133         virtual FakeitContext &getFakeIt() = 0;
0134     };
0135 
0136     struct MethodInfo {
0137 
0138         static unsigned int nextMethodOrdinal() {
0139             static std::atomic_uint ordinal{0};
0140             return ++ordinal;
0141         }
0142 
0143         MethodInfo(unsigned int anId, std::string aName) :
0144                 _id(anId), _name(aName) { }
0145 
0146         unsigned int id() const {
0147             return _id;
0148         }
0149 
0150         std::string name() const {
0151             return _name;
0152         }
0153 
0154         void setName(const std::string &value) {
0155             _name = value;
0156         }
0157 
0158     private:
0159         unsigned int _id;
0160         std::string _name;
0161     };
0162 
0163     struct UnknownMethod {
0164 
0165         static MethodInfo &instance() {
0166             static MethodInfo instance(MethodInfo::nextMethodOrdinal(), "unknown");
0167             return instance;
0168         }
0169 
0170     };
0171 
0172 }
0173 namespace fakeit {
0174     class Destructible {
0175     public:
0176         virtual ~Destructible() {}
0177     };
0178 }
0179 
0180 namespace fakeit {
0181 
0182     struct Invocation : Destructible {
0183 
0184         static unsigned int nextInvocationOrdinal() {
0185             static std::atomic_uint invocationOrdinal{0};
0186             return ++invocationOrdinal;
0187         }
0188 
0189         struct Matcher {
0190 
0191             virtual ~Matcher() THROWS {
0192             }
0193 
0194             virtual bool matches(Invocation &invocation) = 0;
0195 
0196             virtual std::string format() const = 0;
0197         };
0198 
0199         Invocation(unsigned int ordinal, MethodInfo &method) :
0200                 _ordinal(ordinal), _method(method), _isVerified(false) {
0201         }
0202 
0203         virtual ~Invocation() override = default;
0204 
0205         unsigned int getOrdinal() const {
0206             return _ordinal;
0207         }
0208 
0209         MethodInfo &getMethod() const {
0210             return _method;
0211         }
0212 
0213         void markAsVerified() {
0214             _isVerified = true;
0215         }
0216 
0217         bool isVerified() const {
0218             return _isVerified;
0219         }
0220 
0221         virtual std::string format() const = 0;
0222 
0223     private:
0224         const unsigned int _ordinal;
0225         MethodInfo &_method;
0226         bool _isVerified;
0227     };
0228 
0229 }
0230 #include <iosfwd>
0231 #include <tuple>
0232 #include <string>
0233 #include <sstream>
0234 #include <ostream>
0235 
0236 namespace fakeit {
0237 
0238     template<typename T, class Enable = void>
0239     struct Formatter;
0240 
0241     template <>
0242     struct Formatter<bool>
0243     {
0244         static std::string format(bool const &val)
0245         {
0246             return val ? "true" : "false";
0247         }
0248     };
0249 
0250     template <>
0251     struct Formatter<char>
0252     {
0253         static std::string format(char const &val)
0254         {
0255             std::string s;
0256             s += "'";
0257             s += val;
0258             s += "'";
0259             return s;
0260         }
0261     };
0262 
0263     template <>
0264     struct Formatter<char const*>
0265     {
0266         static std::string format(char const* const &val)
0267         {
0268             std::string s;
0269             if(val != nullptr)
0270             {
0271                 s += '"';
0272                 s += val;
0273                 s += '"';
0274             }
0275             else
0276             {
0277                 s = "[nullptr]";
0278             }
0279             return s;
0280         }
0281     };
0282 
0283     template <>
0284     struct Formatter<char*>
0285     {
0286         static std::string format(char* const &val)
0287         {
0288             return Formatter<char const*>::format( val );
0289         }
0290     };
0291 
0292     template<class C>
0293     struct Formatter<C, typename std::enable_if<!is_ostreamable<C>::value>::type> {
0294         static std::string format(C const &)
0295         {
0296             return "?";
0297         }
0298     };
0299 
0300     template<class C>
0301     struct Formatter<C, typename std::enable_if<is_ostreamable<C>::value>::type> {
0302         static std::string format(C const &val)
0303         {
0304             std::ostringstream os;
0305             os << val;
0306             return os.str();
0307         }
0308     };
0309 
0310 
0311     template <typename T>
0312     using TypeFormatter = Formatter<typename fakeit::naked_type<T>::type>;
0313 }
0314 
0315 namespace fakeit {
0316 
0317 
0318     template<class Tuple, std::size_t N>
0319     struct TuplePrinter {
0320         static void print(std::ostream &strm, const Tuple &t) {
0321             TuplePrinter<Tuple, N - 1>::print(strm, t);
0322             strm << ", " << fakeit::TypeFormatter<decltype(std::get<N - 1>(t))>::format(std::get<N - 1>(t));
0323         }
0324     };
0325 
0326     template<class Tuple>
0327     struct TuplePrinter<Tuple, 1> {
0328         static void print(std::ostream &strm, const Tuple &t) {
0329             strm << fakeit::TypeFormatter<decltype(std::get<0>(t))>::format(std::get<0>(t));
0330         }
0331     };
0332 
0333     template<class Tuple>
0334     struct TuplePrinter<Tuple, 0> {
0335         static void print(std::ostream &, const Tuple &) {
0336         }
0337     };
0338 
0339     template<class ... Args>
0340     void print(std::ostream &strm, const std::tuple<Args...> &t) {
0341         strm << "(";
0342         TuplePrinter<decltype(t), sizeof...(Args)>::print(strm, t);
0343         strm << ")";
0344     }
0345 
0346     template<class ... Args>
0347     std::ostream &operator<<(std::ostream &strm, const std::tuple<Args...> &t) {
0348         print(strm, t);
0349         return strm;
0350     }
0351 
0352 }
0353 
0354 
0355 namespace fakeit {
0356 
0357     template<typename ... arglist>
0358     struct ActualInvocation : public Invocation {
0359 
0360         struct Matcher : public virtual Destructible {
0361             virtual bool matches(ActualInvocation<arglist...> &actualInvocation) = 0;
0362 
0363             virtual std::string format() const = 0;
0364         };
0365 
0366         ActualInvocation(unsigned int ordinal, MethodInfo &method, const typename fakeit::production_arg<arglist>::type... args) :
0367             Invocation(ordinal, method), _matcher{ nullptr }
0368             , actualArguments{ std::forward<arglist>(args)... }
0369         {
0370         }
0371 
0372         ArgumentsTuple<arglist...> & getActualArguments() {
0373             return actualArguments;
0374         }
0375 
0376 
0377         void setActualMatcher(Matcher *matcher) {
0378             this->_matcher = matcher;
0379         }
0380 
0381         Matcher *getActualMatcher() {
0382             return _matcher;
0383         }
0384 
0385         virtual std::string format() const override {
0386             std::ostringstream out;
0387             out << getMethod().name();
0388             print(out, actualArguments);
0389             return out.str();
0390         }
0391 
0392     private:
0393 
0394         Matcher *_matcher;
0395         ArgumentsTuple<arglist...> actualArguments;
0396     };
0397 
0398     template<typename ... arglist>
0399     std::ostream &operator<<(std::ostream &strm, const ActualInvocation<arglist...> &ai) {
0400         strm << ai.format();
0401         return strm;
0402     }
0403 
0404 }
0405 
0406 
0407 
0408 
0409 
0410 #include <unordered_set>
0411 
0412 namespace fakeit {
0413 
0414     struct ActualInvocationsContainer {
0415         virtual void clear() = 0;
0416 
0417         virtual ~ActualInvocationsContainer() NO_THROWS { }
0418     };
0419 
0420     struct ActualInvocationsSource {
0421         virtual void getActualInvocations(std::unordered_set<fakeit::Invocation *> &into) const = 0;
0422 
0423         virtual ~ActualInvocationsSource() NO_THROWS { }
0424     };
0425 
0426     struct InvocationsSourceProxy : public ActualInvocationsSource {
0427 
0428         InvocationsSourceProxy(ActualInvocationsSource *inner) :
0429                 _inner(inner) {
0430         }
0431 
0432         void getActualInvocations(std::unordered_set<fakeit::Invocation *> &into) const override {
0433             _inner->getActualInvocations(into);
0434         }
0435 
0436     private:
0437         std::shared_ptr<ActualInvocationsSource> _inner;
0438     };
0439 
0440     struct UnverifiedInvocationsSource : public ActualInvocationsSource {
0441 
0442         UnverifiedInvocationsSource(InvocationsSourceProxy decorated) : _decorated(decorated) {
0443         }
0444 
0445         void getActualInvocations(std::unordered_set<fakeit::Invocation *> &into) const override {
0446             std::unordered_set<fakeit::Invocation *> all;
0447             _decorated.getActualInvocations(all);
0448             for (fakeit::Invocation *i : all) {
0449                 if (!i->isVerified()) {
0450                     into.insert(i);
0451                 }
0452             }
0453         }
0454 
0455     private:
0456         InvocationsSourceProxy _decorated;
0457     };
0458 
0459     struct AggregateInvocationsSource : public ActualInvocationsSource {
0460 
0461         AggregateInvocationsSource(std::vector<ActualInvocationsSource *> &sources) : _sources(sources) {
0462         }
0463 
0464         void getActualInvocations(std::unordered_set<fakeit::Invocation *> &into) const override {
0465             std::unordered_set<fakeit::Invocation *> tmp;
0466             for (ActualInvocationsSource *source : _sources) {
0467                 source->getActualInvocations(tmp);
0468             }
0469             filter(tmp, into);
0470         }
0471 
0472     protected:
0473         bool shouldInclude(fakeit::Invocation *) const {
0474             return true;
0475         }
0476 
0477     private:
0478         std::vector<ActualInvocationsSource *> _sources;
0479 
0480         void filter(std::unordered_set<Invocation *> &source, std::unordered_set<Invocation *> &target) const {
0481             for (Invocation *i:source) {
0482                 if (shouldInclude(i)) {
0483                     target.insert(i);
0484                 }
0485             }
0486         }
0487     };
0488 }
0489 
0490 namespace fakeit {
0491 
0492     class Sequence {
0493     private:
0494 
0495     protected:
0496 
0497         Sequence() {
0498         }
0499 
0500         virtual ~Sequence() THROWS {
0501         }
0502 
0503     public:
0504 
0505 
0506         virtual void getExpectedSequence(std::vector<Invocation::Matcher *> &into) const = 0;
0507 
0508 
0509         virtual void getInvolvedMocks(std::vector<ActualInvocationsSource *> &into) const = 0;
0510 
0511         virtual unsigned int size() const = 0;
0512 
0513         friend class VerifyFunctor;
0514     };
0515 
0516     class ConcatenatedSequence : public virtual Sequence {
0517     private:
0518         const Sequence &s1;
0519         const Sequence &s2;
0520 
0521     protected:
0522         ConcatenatedSequence(const Sequence &seq1, const Sequence &seq2) :
0523                 s1(seq1), s2(seq2) {
0524         }
0525 
0526     public:
0527 
0528         virtual ~ConcatenatedSequence() {
0529         }
0530 
0531         unsigned int size() const override {
0532             return s1.size() + s2.size();
0533         }
0534 
0535         const Sequence &getLeft() const {
0536             return s1;
0537         }
0538 
0539         const Sequence &getRight() const {
0540             return s2;
0541         }
0542 
0543         void getExpectedSequence(std::vector<Invocation::Matcher *> &into) const override {
0544             s1.getExpectedSequence(into);
0545             s2.getExpectedSequence(into);
0546         }
0547 
0548         virtual void getInvolvedMocks(std::vector<ActualInvocationsSource *> &into) const override {
0549             s1.getInvolvedMocks(into);
0550             s2.getInvolvedMocks(into);
0551         }
0552 
0553         friend inline ConcatenatedSequence operator+(const Sequence &s1, const Sequence &s2);
0554     };
0555 
0556     class RepeatedSequence : public virtual Sequence {
0557     private:
0558         const Sequence &_s;
0559         const int times;
0560 
0561     protected:
0562         RepeatedSequence(const Sequence &s, const int t) :
0563                 _s(s), times(t) {
0564         }
0565 
0566     public:
0567 
0568         ~RepeatedSequence() {
0569         }
0570 
0571         unsigned int size() const override {
0572             return _s.size() * times;
0573         }
0574 
0575         friend inline RepeatedSequence operator*(const Sequence &s, int times);
0576 
0577         friend inline RepeatedSequence operator*(int times, const Sequence &s);
0578 
0579         void getInvolvedMocks(std::vector<ActualInvocationsSource *> &into) const override {
0580             _s.getInvolvedMocks(into);
0581         }
0582 
0583         void getExpectedSequence(std::vector<Invocation::Matcher *> &into) const override {
0584             for (int i = 0; i < times; i++)
0585                 _s.getExpectedSequence(into);
0586         }
0587 
0588         int getTimes() const {
0589             return times;
0590         }
0591 
0592         const Sequence &getSequence() const {
0593             return _s;
0594         }
0595     };
0596 
0597     inline ConcatenatedSequence operator+(const Sequence &s1, const Sequence &s2) {
0598         return ConcatenatedSequence(s1, s2);
0599     }
0600 
0601     inline RepeatedSequence operator*(const Sequence &s, int times) {
0602         if (times <= 0)
0603             throw std::invalid_argument("times");
0604         return RepeatedSequence(s, times);
0605     }
0606 
0607     inline RepeatedSequence operator*(int times, const Sequence &s) {
0608         if (times <= 0)
0609             throw std::invalid_argument("times");
0610         return RepeatedSequence(s, times);
0611     }
0612 
0613 }
0614 
0615 namespace fakeit {
0616 
0617     enum class VerificationType {
0618         Exact, AtLeast, NoMoreInvocations
0619     };
0620 
0621     enum class UnexpectedType {
0622         Unmocked, Unmatched
0623     };
0624 
0625     struct VerificationEvent {
0626 
0627         VerificationEvent(VerificationType aVerificationType) :
0628                 _verificationType(aVerificationType), _line(0) {
0629         }
0630 
0631         virtual ~VerificationEvent() = default;
0632 
0633         VerificationType verificationType() const {
0634             return _verificationType;
0635         }
0636 
0637         void setFileInfo(const char * aFile, int aLine, const char * aCallingMethod) {
0638             _file = aFile;
0639             _callingMethod = aCallingMethod;
0640             _line = aLine;
0641         }
0642 
0643         const char * file() const {
0644             return _file;
0645         }
0646 
0647         int line() const {
0648             return _line;
0649         }
0650 
0651         const char * callingMethod() const {
0652             return _callingMethod;
0653         }
0654 
0655     private:
0656         VerificationType _verificationType;
0657         const char * _file;
0658         int _line;
0659         const char * _callingMethod;
0660     };
0661 
0662     struct NoMoreInvocationsVerificationEvent : public VerificationEvent {
0663 
0664         ~NoMoreInvocationsVerificationEvent() = default;
0665 
0666         NoMoreInvocationsVerificationEvent(
0667                 std::vector<Invocation *> &allTheIvocations,
0668                 std::vector<Invocation *> &anUnverifedIvocations) :
0669                 VerificationEvent(VerificationType::NoMoreInvocations),
0670                 _allIvocations(allTheIvocations),
0671                 _unverifedIvocations(anUnverifedIvocations) {
0672         }
0673 
0674         const std::vector<Invocation *> &allIvocations() const {
0675             return _allIvocations;
0676         }
0677 
0678         const std::vector<Invocation *> &unverifedIvocations() const {
0679             return _unverifedIvocations;
0680         }
0681 
0682     private:
0683         const std::vector<Invocation *> _allIvocations;
0684         const std::vector<Invocation *> _unverifedIvocations;
0685     };
0686 
0687     struct SequenceVerificationEvent : public VerificationEvent {
0688 
0689         ~SequenceVerificationEvent() = default;
0690 
0691         SequenceVerificationEvent(VerificationType aVerificationType,
0692                                   std::vector<Sequence *> &anExpectedPattern,
0693                                   std::vector<Invocation *> &anActualSequence,
0694                                   int anExpectedCount,
0695                                   int anActualCount) :
0696                 VerificationEvent(aVerificationType),
0697                 _expectedPattern(anExpectedPattern),
0698                 _actualSequence(anActualSequence),
0699                 _expectedCount(anExpectedCount),
0700                 _actualCount(anActualCount)
0701         {
0702         }
0703 
0704         const std::vector<Sequence *> &expectedPattern() const {
0705             return _expectedPattern;
0706         }
0707 
0708         const std::vector<Invocation *> &actualSequence() const {
0709             return _actualSequence;
0710         }
0711 
0712         int expectedCount() const {
0713             return _expectedCount;
0714         }
0715 
0716         int actualCount() const {
0717             return _actualCount;
0718         }
0719 
0720     private:
0721         const std::vector<Sequence *> _expectedPattern;
0722         const std::vector<Invocation *> _actualSequence;
0723         const int _expectedCount;
0724         const int _actualCount;
0725     };
0726 
0727     struct UnexpectedMethodCallEvent {
0728         UnexpectedMethodCallEvent(UnexpectedType unexpectedType, const Invocation &invocation) :
0729                 _unexpectedType(unexpectedType), _invocation(invocation) {
0730         }
0731 
0732         const Invocation &getInvocation() const {
0733             return _invocation;
0734         }
0735 
0736         UnexpectedType getUnexpectedType() const {
0737             return _unexpectedType;
0738         }
0739 
0740         const UnexpectedType _unexpectedType;
0741         const Invocation &_invocation;
0742     };
0743 
0744 }
0745 
0746 namespace fakeit {
0747 
0748     struct VerificationEventHandler {
0749         virtual void handle(const SequenceVerificationEvent &e) = 0;
0750 
0751         virtual void handle(const NoMoreInvocationsVerificationEvent &e) = 0;
0752     };
0753 
0754     struct EventHandler : public VerificationEventHandler {
0755         using VerificationEventHandler::handle;
0756 
0757         virtual void handle(const UnexpectedMethodCallEvent &e) = 0;
0758     };
0759 
0760 }
0761 #include <vector>
0762 #include <string>
0763 
0764 namespace fakeit {
0765 
0766     struct UnexpectedMethodCallEvent;
0767     struct SequenceVerificationEvent;
0768     struct NoMoreInvocationsVerificationEvent;
0769 
0770     struct EventFormatter {
0771 
0772         virtual std::string format(const fakeit::UnexpectedMethodCallEvent &e) = 0;
0773 
0774         virtual std::string format(const fakeit::SequenceVerificationEvent &e) = 0;
0775 
0776         virtual std::string format(const fakeit::NoMoreInvocationsVerificationEvent &e) = 0;
0777 
0778     };
0779 
0780 }
0781 #ifdef FAKEIT_ASSERT_ON_UNEXPECTED_METHOD_INVOCATION
0782 #include <cassert>
0783 #endif
0784 
0785 namespace fakeit {
0786 
0787     struct FakeitContext : public EventHandler, protected EventFormatter {
0788 
0789         virtual ~FakeitContext() = default;
0790 
0791         void handle(const UnexpectedMethodCallEvent &e) override {
0792             fireEvent(e);
0793             auto &eh = getTestingFrameworkAdapter();
0794             #ifdef FAKEIT_ASSERT_ON_UNEXPECTED_METHOD_INVOCATION
0795             assert(!"Unexpected method invocation");
0796             #endif
0797             eh.handle(e);
0798         }
0799 
0800         void handle(const SequenceVerificationEvent &e) override {
0801             fireEvent(e);
0802             auto &eh = getTestingFrameworkAdapter();
0803             return eh.handle(e);
0804         }
0805 
0806         void handle(const NoMoreInvocationsVerificationEvent &e) override {
0807             fireEvent(e);
0808             auto &eh = getTestingFrameworkAdapter();
0809             return eh.handle(e);
0810         }
0811 
0812         std::string format(const UnexpectedMethodCallEvent &e) override {
0813             auto &eventFormatter = getEventFormatter();
0814             return eventFormatter.format(e);
0815         }
0816 
0817         std::string format(const SequenceVerificationEvent &e) override {
0818             auto &eventFormatter = getEventFormatter();
0819             return eventFormatter.format(e);
0820         }
0821 
0822         std::string format(const NoMoreInvocationsVerificationEvent &e) override {
0823             auto &eventFormatter = getEventFormatter();
0824             return eventFormatter.format(e);
0825         }
0826 
0827         void addEventHandler(EventHandler &eventListener) {
0828             _eventListeners.push_back(&eventListener);
0829         }
0830 
0831         void clearEventHandlers() {
0832             _eventListeners.clear();
0833         }
0834 
0835     protected:
0836         virtual EventHandler &getTestingFrameworkAdapter() = 0;
0837 
0838         virtual EventFormatter &getEventFormatter() = 0;
0839 
0840     private:
0841         std::vector<EventHandler *> _eventListeners;
0842 
0843         void fireEvent(const NoMoreInvocationsVerificationEvent &evt) {
0844             for (auto listener : _eventListeners)
0845                 listener->handle(evt);
0846         }
0847 
0848         void fireEvent(const UnexpectedMethodCallEvent &evt) {
0849             for (auto listener : _eventListeners)
0850                 listener->handle(evt);
0851         }
0852 
0853         void fireEvent(const SequenceVerificationEvent &evt) {
0854             for (auto listener : _eventListeners)
0855                 listener->handle(evt);
0856         }
0857 
0858     };
0859 
0860 }
0861 #include <iostream>
0862 #include <iosfwd>
0863 
0864 namespace fakeit {
0865 
0866     struct DefaultEventFormatter : public EventFormatter {
0867 
0868         virtual std::string format(const UnexpectedMethodCallEvent &e) override {
0869             std::ostringstream out;
0870             out << "Unexpected method invocation: ";
0871             out << e.getInvocation().format() << std::endl;
0872             if (UnexpectedType::Unmatched == e.getUnexpectedType()) {
0873                 out << "  Could not find any recorded behavior to support this method call.";
0874             } else {
0875                 out << "  An unmocked method was invoked. All used virtual methods must be stubbed!";
0876             }
0877             return out.str();
0878         }
0879 
0880 
0881         virtual std::string format(const SequenceVerificationEvent &e) override {
0882             std::ostringstream out;
0883             out << "Verification error" << std::endl;
0884 
0885             out << "Expected pattern: ";
0886             const std::vector<fakeit::Sequence *> expectedPattern = e.expectedPattern();
0887             out << formatExpectedPattern(expectedPattern) << std::endl;
0888 
0889             out << "Expected matches: ";
0890             formatExpectedCount(out, e.verificationType(), e.expectedCount());
0891             out << std::endl;
0892 
0893             out << "Actual matches  : " << e.actualCount() << std::endl;
0894 
0895             auto actualSequence = e.actualSequence();
0896             out << "Actual sequence : total of " << actualSequence.size() << " actual invocations";
0897             if (actualSequence.size() == 0) {
0898                 out << ".";
0899             } else {
0900                 out << ":" << std::endl;
0901             }
0902             formatInvocationList(out, actualSequence);
0903 
0904             return out.str();
0905         }
0906 
0907         virtual std::string format(const NoMoreInvocationsVerificationEvent &e) override {
0908             std::ostringstream out;
0909             out << "Verification error" << std::endl;
0910             out << "Expected no more invocations!! but the following unverified invocations were found:" << std::endl;
0911             formatInvocationList(out, e.unverifedIvocations());
0912             return out.str();
0913         }
0914 
0915         static std::string formatExpectedPattern(const std::vector<fakeit::Sequence *> &expectedPattern) {
0916             std::string expectedPatternStr;
0917             for (unsigned int i = 0; i < expectedPattern.size(); i++) {
0918                 Sequence *s = expectedPattern[i];
0919                 expectedPatternStr += formatSequence(*s);
0920                 if (i < expectedPattern.size() - 1)
0921                     expectedPatternStr += " ... ";
0922             }
0923             return expectedPatternStr;
0924         }
0925 
0926     private:
0927 
0928         static std::string formatSequence(const Sequence &val) {
0929             const ConcatenatedSequence *cs = dynamic_cast<const ConcatenatedSequence *>(&val);
0930             if (cs) {
0931                 return format(*cs);
0932             }
0933             const RepeatedSequence *rs = dynamic_cast<const RepeatedSequence *>(&val);
0934             if (rs) {
0935                 return format(*rs);
0936             }
0937 
0938 
0939             std::vector<Invocation::Matcher *> vec;
0940             val.getExpectedSequence(vec);
0941             return vec[0]->format();
0942         }
0943 
0944         static void formatExpectedCount(std::ostream &out, fakeit::VerificationType verificationType,
0945                                         int expectedCount) {
0946             if (verificationType == fakeit::VerificationType::Exact)
0947                 out << "exactly ";
0948 
0949             if (verificationType == fakeit::VerificationType::AtLeast)
0950                 out << "at least ";
0951 
0952             out << expectedCount;
0953         }
0954 
0955         static void formatInvocationList(std::ostream &out, const std::vector<fakeit::Invocation *> &actualSequence) {
0956             size_t max_size = actualSequence.size();
0957             if (max_size > 50)
0958                 max_size = 50;
0959 
0960             for (unsigned int i = 0; i < max_size; i++) {
0961                 out << "  ";
0962                 auto invocation = actualSequence[i];
0963                 out << invocation->format();
0964                 if (i < max_size - 1)
0965                     out << std::endl;
0966             }
0967 
0968             if (actualSequence.size() > max_size)
0969                 out << std::endl << "  ...";
0970         }
0971 
0972         static std::string format(const ConcatenatedSequence &val) {
0973             std::ostringstream out;
0974             out << formatSequence(val.getLeft()) << " + " << formatSequence(val.getRight());
0975             return out.str();
0976         }
0977 
0978         static std::string format(const RepeatedSequence &val) {
0979             std::ostringstream out;
0980             const ConcatenatedSequence *cs = dynamic_cast<const ConcatenatedSequence *>(&val.getSequence());
0981             const RepeatedSequence *rs = dynamic_cast<const RepeatedSequence *>(&val.getSequence());
0982             if (rs || cs)
0983                 out << '(';
0984             out << formatSequence(val.getSequence());
0985             if (rs || cs)
0986                 out << ')';
0987 
0988             out << " * " << val.getTimes();
0989             return out.str();
0990         }
0991     };
0992 }
0993 namespace fakeit {
0994 
0995     struct FakeitException {
0996         std::exception err;
0997 
0998         virtual ~FakeitException() = default;
0999 
1000         virtual std::string what() const = 0;
1001 
1002         friend std::ostream &operator<<(std::ostream &os, const FakeitException &val) {
1003             os << val.what();
1004             return os;
1005         }
1006     };
1007 
1008 
1009 
1010 
1011     struct UnexpectedMethodCallException : public FakeitException {
1012 
1013         UnexpectedMethodCallException(std::string format) :
1014                 _format(format) {
1015         }
1016 
1017         virtual std::string what() const override {
1018             return _format;
1019         }
1020 
1021     private:
1022         std::string _format;
1023     };
1024 
1025 }
1026 
1027 namespace fakeit {
1028 
1029     struct DefaultEventLogger : public fakeit::EventHandler {
1030 
1031         DefaultEventLogger(EventFormatter &formatter) : _formatter(formatter), _out(std::cout) { }
1032 
1033         virtual void handle(const UnexpectedMethodCallEvent &e) override {
1034             _out << _formatter.format(e) << std::endl;
1035         }
1036 
1037         virtual void handle(const SequenceVerificationEvent &e) override {
1038             _out << _formatter.format(e) << std::endl;
1039         }
1040 
1041         virtual void handle(const NoMoreInvocationsVerificationEvent &e) override {
1042             _out << _formatter.format(e) << std::endl;
1043         }
1044 
1045     private:
1046         EventFormatter &_formatter;
1047         std::ostream &_out;
1048     };
1049 
1050 }
1051 
1052 namespace fakeit {
1053 
1054     class AbstractFakeit : public FakeitContext {
1055     public:
1056         virtual ~AbstractFakeit() = default;
1057 
1058     protected:
1059 
1060         virtual fakeit::EventHandler &accessTestingFrameworkAdapter() = 0;
1061 
1062         virtual EventFormatter &accessEventFormatter() = 0;
1063     };
1064 
1065     class DefaultFakeit : public AbstractFakeit {
1066         DefaultEventFormatter _formatter;
1067         fakeit::EventFormatter *_customFormatter;
1068         fakeit::EventHandler *_testingFrameworkAdapter;
1069 
1070     public:
1071 
1072         DefaultFakeit() : _formatter(),
1073                           _customFormatter(nullptr),
1074                           _testingFrameworkAdapter(nullptr) {
1075         }
1076 
1077         virtual ~DefaultFakeit() = default;
1078 
1079         void setCustomEventFormatter(fakeit::EventFormatter &customEventFormatter) {
1080             _customFormatter = &customEventFormatter;
1081         }
1082 
1083         void resetCustomEventFormatter() {
1084             _customFormatter = nullptr;
1085         }
1086 
1087         void setTestingFrameworkAdapter(fakeit::EventHandler &testingFrameforkAdapter) {
1088             _testingFrameworkAdapter = &testingFrameforkAdapter;
1089         }
1090 
1091         void resetTestingFrameworkAdapter() {
1092             _testingFrameworkAdapter = nullptr;
1093         }
1094 
1095     protected:
1096 
1097         fakeit::EventHandler &getTestingFrameworkAdapter() override {
1098             if (_testingFrameworkAdapter)
1099                 return *_testingFrameworkAdapter;
1100             return accessTestingFrameworkAdapter();
1101         }
1102 
1103         EventFormatter &getEventFormatter() override {
1104             if (_customFormatter)
1105                 return *_customFormatter;
1106             return accessEventFormatter();
1107         }
1108 
1109         EventFormatter &accessEventFormatter() override {
1110             return _formatter;
1111         }
1112 
1113     };
1114 }
1115 #include <string>
1116 #include <sstream>
1117 #include <iomanip>
1118 
1119 namespace fakeit {
1120 
1121     template<typename T>
1122     static std::string to_string(const T &n) {
1123         std::ostringstream stm;
1124         stm << n;
1125         return stm.str();
1126     }
1127 
1128 }
1129 
1130 namespace fakeit {
1131 
1132     struct VerificationException : public std::exception {
1133         virtual ~VerificationException() NO_THROWS{};
1134 
1135         VerificationException(std::string format) :
1136             _format(format) {
1137         }
1138 
1139         friend std::ostream &operator<<(std::ostream &os, const VerificationException &val) {
1140             os << val.what();
1141             return os;
1142         }
1143 
1144         void setFileInfo(std::string aFile, int aLine, std::string aCallingMethod) {
1145             _file = aFile;
1146             _callingMethod = aCallingMethod;
1147             _line = aLine;
1148         }
1149 
1150         const std::string& file() const {
1151             return _file;
1152         }
1153         int line() const {
1154             return _line;
1155         }
1156         const std::string& callingMethod() const {
1157             return _callingMethod;
1158         }
1159 
1160         const char* what() const NO_THROWS override{
1161             return _format.c_str();
1162         }
1163     private:
1164         std::string _file;
1165         int _line;
1166         std::string _callingMethod;
1167         std::string _format;
1168     };
1169 
1170     struct NoMoreInvocationsVerificationException : public VerificationException {
1171         NoMoreInvocationsVerificationException(std::string format) :
1172             VerificationException(format) {
1173         }
1174     };
1175 
1176     struct SequenceVerificationException : public VerificationException {
1177         SequenceVerificationException(std::string format) :
1178             VerificationException(format) {
1179         }
1180     };
1181 
1182     struct StandaloneAdapter : public EventHandler {
1183 
1184         std::string formatLineNumner(std::string file, int num){
1185 #ifndef __GNUG__
1186             return file + std::string("(") + fakeit::to_string(num) + std::string(")");
1187 #else
1188             return file + std::string(":") + fakeit::to_string(num);
1189 #endif
1190         }
1191 
1192         virtual ~StandaloneAdapter() = default;
1193 
1194         StandaloneAdapter(EventFormatter &formatter)
1195             : _formatter(formatter) {
1196         }
1197 
1198         virtual void handle(const UnexpectedMethodCallEvent &evt) override {
1199             std::string format = _formatter.format(evt);
1200             UnexpectedMethodCallException ex(format);
1201             throw ex;
1202         }
1203 
1204         virtual void handle(const SequenceVerificationEvent &evt) override {
1205             std::string format(formatLineNumner(evt.file(), evt.line()) + ": " + _formatter.format(evt));
1206             SequenceVerificationException e(format);
1207             e.setFileInfo(evt.file(), evt.line(), evt.callingMethod());
1208             throw e;
1209         }
1210 
1211         virtual void handle(const NoMoreInvocationsVerificationEvent &evt) override {
1212             std::string format(formatLineNumner(evt.file(), evt.line()) + ": " + _formatter.format(evt));
1213             NoMoreInvocationsVerificationException e(format);
1214             e.setFileInfo(evt.file(), evt.line(), evt.callingMethod());
1215             throw e;
1216         }
1217 
1218     private:
1219         EventFormatter &_formatter;
1220     };
1221 
1222     class StandaloneFakeit : public DefaultFakeit {
1223 
1224     public:
1225         virtual ~StandaloneFakeit() = default;
1226 
1227         StandaloneFakeit() : _standaloneAdapter(*this) {
1228         }
1229 
1230         static StandaloneFakeit &getInstance() {
1231             static StandaloneFakeit instance;
1232             return instance;
1233         }
1234 
1235     protected:
1236 
1237         fakeit::EventHandler &accessTestingFrameworkAdapter() override {
1238             return _standaloneAdapter;
1239         }
1240 
1241     private:
1242 
1243         StandaloneAdapter _standaloneAdapter;
1244     };
1245 }
1246 
1247 static fakeit::DefaultFakeit& Fakeit = fakeit::StandaloneFakeit::getInstance();
1248 
1249 
1250 #include <type_traits>
1251 #include <unordered_set>
1252 
1253 #include <memory>
1254 #undef max
1255 #include <functional>
1256 #include <type_traits>
1257 #include <vector>
1258 #include <array>
1259 #include <new>
1260 #include <limits>
1261 
1262 #include <functional>
1263 #include <type_traits>
1264 namespace fakeit {
1265 
1266     struct VirtualOffsetSelector {
1267 
1268         unsigned int offset;
1269 
1270         virtual unsigned int offset0(int) {
1271             return offset = 0;
1272         }
1273 
1274         virtual unsigned int offset1(int) {
1275             return offset = 1;
1276         }
1277 
1278         virtual unsigned int offset2(int) {
1279             return offset = 2;
1280         }
1281 
1282         virtual unsigned int offset3(int) {
1283             return offset = 3;
1284         }
1285 
1286         virtual unsigned int offset4(int) {
1287             return offset = 4;
1288         }
1289 
1290         virtual unsigned int offset5(int) {
1291             return offset = 5;
1292         }
1293 
1294         virtual unsigned int offset6(int) {
1295             return offset = 6;
1296         }
1297 
1298         virtual unsigned int offset7(int) {
1299             return offset = 7;
1300         }
1301 
1302         virtual unsigned int offset8(int) {
1303             return offset = 8;
1304         }
1305 
1306         virtual unsigned int offset9(int) {
1307             return offset = 9;
1308         }
1309 
1310         virtual unsigned int offset10(int) {
1311             return offset = 10;
1312         }
1313 
1314         virtual unsigned int offset11(int) {
1315             return offset = 11;
1316         }
1317 
1318         virtual unsigned int offset12(int) {
1319             return offset = 12;
1320         }
1321 
1322         virtual unsigned int offset13(int) {
1323             return offset = 13;
1324         }
1325 
1326         virtual unsigned int offset14(int) {
1327             return offset = 14;
1328         }
1329 
1330         virtual unsigned int offset15(int) {
1331             return offset = 15;
1332         }
1333 
1334         virtual unsigned int offset16(int) {
1335             return offset = 16;
1336         }
1337 
1338         virtual unsigned int offset17(int) {
1339             return offset = 17;
1340         }
1341 
1342         virtual unsigned int offset18(int) {
1343             return offset = 18;
1344         }
1345 
1346         virtual unsigned int offset19(int) {
1347             return offset = 19;
1348         }
1349 
1350         virtual unsigned int offset20(int) {
1351             return offset = 20;
1352         }
1353 
1354         virtual unsigned int offset21(int) {
1355             return offset = 21;
1356         }
1357 
1358         virtual unsigned int offset22(int) {
1359             return offset = 22;
1360         }
1361 
1362         virtual unsigned int offset23(int) {
1363             return offset = 23;
1364         }
1365 
1366         virtual unsigned int offset24(int) {
1367             return offset = 24;
1368         }
1369 
1370         virtual unsigned int offset25(int) {
1371             return offset = 25;
1372         }
1373 
1374         virtual unsigned int offset26(int) {
1375             return offset = 26;
1376         }
1377 
1378         virtual unsigned int offset27(int) {
1379             return offset = 27;
1380         }
1381 
1382         virtual unsigned int offset28(int) {
1383             return offset = 28;
1384         }
1385 
1386         virtual unsigned int offset29(int) {
1387             return offset = 29;
1388         }
1389 
1390         virtual unsigned int offset30(int) {
1391             return offset = 30;
1392         }
1393 
1394         virtual unsigned int offset31(int) {
1395             return offset = 31;
1396         }
1397 
1398         virtual unsigned int offset32(int) {
1399             return offset = 32;
1400         }
1401 
1402         virtual unsigned int offset33(int) {
1403             return offset = 33;
1404         }
1405 
1406         virtual unsigned int offset34(int) {
1407             return offset = 34;
1408         }
1409 
1410         virtual unsigned int offset35(int) {
1411             return offset = 35;
1412         }
1413 
1414         virtual unsigned int offset36(int) {
1415             return offset = 36;
1416         }
1417 
1418         virtual unsigned int offset37(int) {
1419             return offset = 37;
1420         }
1421 
1422         virtual unsigned int offset38(int) {
1423             return offset = 38;
1424         }
1425 
1426         virtual unsigned int offset39(int) {
1427             return offset = 39;
1428         }
1429 
1430         virtual unsigned int offset40(int) {
1431             return offset = 40;
1432         }
1433 
1434         virtual unsigned int offset41(int) {
1435             return offset = 41;
1436         }
1437 
1438         virtual unsigned int offset42(int) {
1439             return offset = 42;
1440         }
1441 
1442         virtual unsigned int offset43(int) {
1443             return offset = 43;
1444         }
1445 
1446         virtual unsigned int offset44(int) {
1447             return offset = 44;
1448         }
1449 
1450         virtual unsigned int offset45(int) {
1451             return offset = 45;
1452         }
1453 
1454         virtual unsigned int offset46(int) {
1455             return offset = 46;
1456         }
1457 
1458         virtual unsigned int offset47(int) {
1459             return offset = 47;
1460         }
1461 
1462         virtual unsigned int offset48(int) {
1463             return offset = 48;
1464         }
1465 
1466         virtual unsigned int offset49(int) {
1467             return offset = 49;
1468         }
1469 
1470         virtual unsigned int offset50(int) {
1471             return offset = 50;
1472         }
1473 
1474         virtual unsigned int offset51(int) {
1475             return offset = 51;
1476         }
1477 
1478         virtual unsigned int offset52(int) {
1479             return offset = 52;
1480         }
1481 
1482         virtual unsigned int offset53(int) {
1483             return offset = 53;
1484         }
1485 
1486         virtual unsigned int offset54(int) {
1487             return offset = 54;
1488         }
1489 
1490         virtual unsigned int offset55(int) {
1491             return offset = 55;
1492         }
1493 
1494         virtual unsigned int offset56(int) {
1495             return offset = 56;
1496         }
1497 
1498         virtual unsigned int offset57(int) {
1499             return offset = 57;
1500         }
1501 
1502         virtual unsigned int offset58(int) {
1503             return offset = 58;
1504         }
1505 
1506         virtual unsigned int offset59(int) {
1507             return offset = 59;
1508         }
1509 
1510         virtual unsigned int offset60(int) {
1511             return offset = 60;
1512         }
1513 
1514         virtual unsigned int offset61(int) {
1515             return offset = 61;
1516         }
1517 
1518         virtual unsigned int offset62(int) {
1519             return offset = 62;
1520         }
1521 
1522         virtual unsigned int offset63(int) {
1523             return offset = 63;
1524         }
1525 
1526         virtual unsigned int offset64(int) {
1527             return offset = 64;
1528         }
1529 
1530         virtual unsigned int offset65(int) {
1531             return offset = 65;
1532         }
1533 
1534         virtual unsigned int offset66(int) {
1535             return offset = 66;
1536         }
1537 
1538         virtual unsigned int offset67(int) {
1539             return offset = 67;
1540         }
1541 
1542         virtual unsigned int offset68(int) {
1543             return offset = 68;
1544         }
1545 
1546         virtual unsigned int offset69(int) {
1547             return offset = 69;
1548         }
1549 
1550         virtual unsigned int offset70(int) {
1551             return offset = 70;
1552         }
1553 
1554         virtual unsigned int offset71(int) {
1555             return offset = 71;
1556         }
1557 
1558         virtual unsigned int offset72(int) {
1559             return offset = 72;
1560         }
1561 
1562         virtual unsigned int offset73(int) {
1563             return offset = 73;
1564         }
1565 
1566         virtual unsigned int offset74(int) {
1567             return offset = 74;
1568         }
1569 
1570         virtual unsigned int offset75(int) {
1571             return offset = 75;
1572         }
1573 
1574         virtual unsigned int offset76(int) {
1575             return offset = 76;
1576         }
1577 
1578         virtual unsigned int offset77(int) {
1579             return offset = 77;
1580         }
1581 
1582         virtual unsigned int offset78(int) {
1583             return offset = 78;
1584         }
1585 
1586         virtual unsigned int offset79(int) {
1587             return offset = 79;
1588         }
1589 
1590         virtual unsigned int offset80(int) {
1591             return offset = 80;
1592         }
1593 
1594         virtual unsigned int offset81(int) {
1595             return offset = 81;
1596         }
1597 
1598         virtual unsigned int offset82(int) {
1599             return offset = 82;
1600         }
1601 
1602         virtual unsigned int offset83(int) {
1603             return offset = 83;
1604         }
1605 
1606         virtual unsigned int offset84(int) {
1607             return offset = 84;
1608         }
1609 
1610         virtual unsigned int offset85(int) {
1611             return offset = 85;
1612         }
1613 
1614         virtual unsigned int offset86(int) {
1615             return offset = 86;
1616         }
1617 
1618         virtual unsigned int offset87(int) {
1619             return offset = 87;
1620         }
1621 
1622         virtual unsigned int offset88(int) {
1623             return offset = 88;
1624         }
1625 
1626         virtual unsigned int offset89(int) {
1627             return offset = 89;
1628         }
1629 
1630         virtual unsigned int offset90(int) {
1631             return offset = 90;
1632         }
1633 
1634         virtual unsigned int offset91(int) {
1635             return offset = 91;
1636         }
1637 
1638         virtual unsigned int offset92(int) {
1639             return offset = 92;
1640         }
1641 
1642         virtual unsigned int offset93(int) {
1643             return offset = 93;
1644         }
1645 
1646         virtual unsigned int offset94(int) {
1647             return offset = 94;
1648         }
1649 
1650         virtual unsigned int offset95(int) {
1651             return offset = 95;
1652         }
1653 
1654         virtual unsigned int offset96(int) {
1655             return offset = 96;
1656         }
1657 
1658         virtual unsigned int offset97(int) {
1659             return offset = 97;
1660         }
1661 
1662         virtual unsigned int offset98(int) {
1663             return offset = 98;
1664         }
1665 
1666         virtual unsigned int offset99(int) {
1667             return offset = 99;
1668         }
1669 
1670         virtual unsigned int offset100(int) {
1671             return offset = 100;
1672         }
1673 
1674         virtual unsigned int offset101(int) {
1675             return offset = 101;
1676         }
1677 
1678         virtual unsigned int offset102(int) {
1679             return offset = 102;
1680         }
1681 
1682         virtual unsigned int offset103(int) {
1683             return offset = 103;
1684         }
1685 
1686         virtual unsigned int offset104(int) {
1687             return offset = 104;
1688         }
1689 
1690         virtual unsigned int offset105(int) {
1691             return offset = 105;
1692         }
1693 
1694         virtual unsigned int offset106(int) {
1695             return offset = 106;
1696         }
1697 
1698         virtual unsigned int offset107(int) {
1699             return offset = 107;
1700         }
1701 
1702         virtual unsigned int offset108(int) {
1703             return offset = 108;
1704         }
1705 
1706         virtual unsigned int offset109(int) {
1707             return offset = 109;
1708         }
1709 
1710         virtual unsigned int offset110(int) {
1711             return offset = 110;
1712         }
1713 
1714         virtual unsigned int offset111(int) {
1715             return offset = 111;
1716         }
1717 
1718         virtual unsigned int offset112(int) {
1719             return offset = 112;
1720         }
1721 
1722         virtual unsigned int offset113(int) {
1723             return offset = 113;
1724         }
1725 
1726         virtual unsigned int offset114(int) {
1727             return offset = 114;
1728         }
1729 
1730         virtual unsigned int offset115(int) {
1731             return offset = 115;
1732         }
1733 
1734         virtual unsigned int offset116(int) {
1735             return offset = 116;
1736         }
1737 
1738         virtual unsigned int offset117(int) {
1739             return offset = 117;
1740         }
1741 
1742         virtual unsigned int offset118(int) {
1743             return offset = 118;
1744         }
1745 
1746         virtual unsigned int offset119(int) {
1747             return offset = 119;
1748         }
1749 
1750         virtual unsigned int offset120(int) {
1751             return offset = 120;
1752         }
1753 
1754         virtual unsigned int offset121(int) {
1755             return offset = 121;
1756         }
1757 
1758         virtual unsigned int offset122(int) {
1759             return offset = 122;
1760         }
1761 
1762         virtual unsigned int offset123(int) {
1763             return offset = 123;
1764         }
1765 
1766         virtual unsigned int offset124(int) {
1767             return offset = 124;
1768         }
1769 
1770         virtual unsigned int offset125(int) {
1771             return offset = 125;
1772         }
1773 
1774         virtual unsigned int offset126(int) {
1775             return offset = 126;
1776         }
1777 
1778         virtual unsigned int offset127(int) {
1779             return offset = 127;
1780         }
1781 
1782         virtual unsigned int offset128(int) {
1783             return offset = 128;
1784         }
1785 
1786         virtual unsigned int offset129(int) {
1787             return offset = 129;
1788         }
1789 
1790         virtual unsigned int offset130(int) {
1791             return offset = 130;
1792         }
1793 
1794         virtual unsigned int offset131(int) {
1795             return offset = 131;
1796         }
1797 
1798         virtual unsigned int offset132(int) {
1799             return offset = 132;
1800         }
1801 
1802         virtual unsigned int offset133(int) {
1803             return offset = 133;
1804         }
1805 
1806         virtual unsigned int offset134(int) {
1807             return offset = 134;
1808         }
1809 
1810         virtual unsigned int offset135(int) {
1811             return offset = 135;
1812         }
1813 
1814         virtual unsigned int offset136(int) {
1815             return offset = 136;
1816         }
1817 
1818         virtual unsigned int offset137(int) {
1819             return offset = 137;
1820         }
1821 
1822         virtual unsigned int offset138(int) {
1823             return offset = 138;
1824         }
1825 
1826         virtual unsigned int offset139(int) {
1827             return offset = 139;
1828         }
1829 
1830         virtual unsigned int offset140(int) {
1831             return offset = 140;
1832         }
1833 
1834         virtual unsigned int offset141(int) {
1835             return offset = 141;
1836         }
1837 
1838         virtual unsigned int offset142(int) {
1839             return offset = 142;
1840         }
1841 
1842         virtual unsigned int offset143(int) {
1843             return offset = 143;
1844         }
1845 
1846         virtual unsigned int offset144(int) {
1847             return offset = 144;
1848         }
1849 
1850         virtual unsigned int offset145(int) {
1851             return offset = 145;
1852         }
1853 
1854         virtual unsigned int offset146(int) {
1855             return offset = 146;
1856         }
1857 
1858         virtual unsigned int offset147(int) {
1859             return offset = 147;
1860         }
1861 
1862         virtual unsigned int offset148(int) {
1863             return offset = 148;
1864         }
1865 
1866         virtual unsigned int offset149(int) {
1867             return offset = 149;
1868         }
1869 
1870         virtual unsigned int offset150(int) {
1871             return offset = 150;
1872         }
1873 
1874         virtual unsigned int offset151(int) {
1875             return offset = 151;
1876         }
1877 
1878         virtual unsigned int offset152(int) {
1879             return offset = 152;
1880         }
1881 
1882         virtual unsigned int offset153(int) {
1883             return offset = 153;
1884         }
1885 
1886         virtual unsigned int offset154(int) {
1887             return offset = 154;
1888         }
1889 
1890         virtual unsigned int offset155(int) {
1891             return offset = 155;
1892         }
1893 
1894         virtual unsigned int offset156(int) {
1895             return offset = 156;
1896         }
1897 
1898         virtual unsigned int offset157(int) {
1899             return offset = 157;
1900         }
1901 
1902         virtual unsigned int offset158(int) {
1903             return offset = 158;
1904         }
1905 
1906         virtual unsigned int offset159(int) {
1907             return offset = 159;
1908         }
1909 
1910         virtual unsigned int offset160(int) {
1911             return offset = 160;
1912         }
1913 
1914         virtual unsigned int offset161(int) {
1915             return offset = 161;
1916         }
1917 
1918         virtual unsigned int offset162(int) {
1919             return offset = 162;
1920         }
1921 
1922         virtual unsigned int offset163(int) {
1923             return offset = 163;
1924         }
1925 
1926         virtual unsigned int offset164(int) {
1927             return offset = 164;
1928         }
1929 
1930         virtual unsigned int offset165(int) {
1931             return offset = 165;
1932         }
1933 
1934         virtual unsigned int offset166(int) {
1935             return offset = 166;
1936         }
1937 
1938         virtual unsigned int offset167(int) {
1939             return offset = 167;
1940         }
1941 
1942         virtual unsigned int offset168(int) {
1943             return offset = 168;
1944         }
1945 
1946         virtual unsigned int offset169(int) {
1947             return offset = 169;
1948         }
1949 
1950         virtual unsigned int offset170(int) {
1951             return offset = 170;
1952         }
1953 
1954         virtual unsigned int offset171(int) {
1955             return offset = 171;
1956         }
1957 
1958         virtual unsigned int offset172(int) {
1959             return offset = 172;
1960         }
1961 
1962         virtual unsigned int offset173(int) {
1963             return offset = 173;
1964         }
1965 
1966         virtual unsigned int offset174(int) {
1967             return offset = 174;
1968         }
1969 
1970         virtual unsigned int offset175(int) {
1971             return offset = 175;
1972         }
1973 
1974         virtual unsigned int offset176(int) {
1975             return offset = 176;
1976         }
1977 
1978         virtual unsigned int offset177(int) {
1979             return offset = 177;
1980         }
1981 
1982         virtual unsigned int offset178(int) {
1983             return offset = 178;
1984         }
1985 
1986         virtual unsigned int offset179(int) {
1987             return offset = 179;
1988         }
1989 
1990         virtual unsigned int offset180(int) {
1991             return offset = 180;
1992         }
1993 
1994         virtual unsigned int offset181(int) {
1995             return offset = 181;
1996         }
1997 
1998         virtual unsigned int offset182(int) {
1999             return offset = 182;
2000         }
2001 
2002         virtual unsigned int offset183(int) {
2003             return offset = 183;
2004         }
2005 
2006         virtual unsigned int offset184(int) {
2007             return offset = 184;
2008         }
2009 
2010         virtual unsigned int offset185(int) {
2011             return offset = 185;
2012         }
2013 
2014         virtual unsigned int offset186(int) {
2015             return offset = 186;
2016         }
2017 
2018         virtual unsigned int offset187(int) {
2019             return offset = 187;
2020         }
2021 
2022         virtual unsigned int offset188(int) {
2023             return offset = 188;
2024         }
2025 
2026         virtual unsigned int offset189(int) {
2027             return offset = 189;
2028         }
2029 
2030         virtual unsigned int offset190(int) {
2031             return offset = 190;
2032         }
2033 
2034         virtual unsigned int offset191(int) {
2035             return offset = 191;
2036         }
2037 
2038         virtual unsigned int offset192(int) {
2039             return offset = 192;
2040         }
2041 
2042         virtual unsigned int offset193(int) {
2043             return offset = 193;
2044         }
2045 
2046         virtual unsigned int offset194(int) {
2047             return offset = 194;
2048         }
2049 
2050         virtual unsigned int offset195(int) {
2051             return offset = 195;
2052         }
2053 
2054         virtual unsigned int offset196(int) {
2055             return offset = 196;
2056         }
2057 
2058         virtual unsigned int offset197(int) {
2059             return offset = 197;
2060         }
2061 
2062         virtual unsigned int offset198(int) {
2063             return offset = 198;
2064         }
2065 
2066         virtual unsigned int offset199(int) {
2067             return offset = 199;
2068         }
2069 
2070 
2071         virtual unsigned int offset200(int) {
2072             return offset = 200;
2073         }
2074 
2075         virtual unsigned int offset201(int) {
2076             return offset = 201;
2077         }
2078 
2079         virtual unsigned int offset202(int) {
2080             return offset = 202;
2081         }
2082 
2083         virtual unsigned int offset203(int) {
2084             return offset = 203;
2085         }
2086 
2087         virtual unsigned int offset204(int) {
2088             return offset = 204;
2089         }
2090 
2091         virtual unsigned int offset205(int) {
2092             return offset = 205;
2093         }
2094 
2095         virtual unsigned int offset206(int) {
2096             return offset = 206;
2097         }
2098 
2099         virtual unsigned int offset207(int) {
2100             return offset = 207;
2101         }
2102 
2103         virtual unsigned int offset208(int) {
2104             return offset = 208;
2105         }
2106 
2107         virtual unsigned int offset209(int) {
2108             return offset = 209;
2109         }
2110 
2111         virtual unsigned int offset210(int) {
2112             return offset = 210;
2113         }
2114 
2115         virtual unsigned int offset211(int) {
2116             return offset = 211;
2117         }
2118 
2119         virtual unsigned int offset212(int) {
2120             return offset = 212;
2121         }
2122 
2123         virtual unsigned int offset213(int) {
2124             return offset = 213;
2125         }
2126 
2127         virtual unsigned int offset214(int) {
2128             return offset = 214;
2129         }
2130 
2131         virtual unsigned int offset215(int) {
2132             return offset = 215;
2133         }
2134 
2135         virtual unsigned int offset216(int) {
2136             return offset = 216;
2137         }
2138 
2139         virtual unsigned int offset217(int) {
2140             return offset = 217;
2141         }
2142 
2143         virtual unsigned int offset218(int) {
2144             return offset = 218;
2145         }
2146 
2147         virtual unsigned int offset219(int) {
2148             return offset = 219;
2149         }
2150 
2151         virtual unsigned int offset220(int) {
2152             return offset = 220;
2153         }
2154 
2155         virtual unsigned int offset221(int) {
2156             return offset = 221;
2157         }
2158 
2159         virtual unsigned int offset222(int) {
2160             return offset = 222;
2161         }
2162 
2163         virtual unsigned int offset223(int) {
2164             return offset = 223;
2165         }
2166 
2167         virtual unsigned int offset224(int) {
2168             return offset = 224;
2169         }
2170 
2171         virtual unsigned int offset225(int) {
2172             return offset = 225;
2173         }
2174 
2175         virtual unsigned int offset226(int) {
2176             return offset = 226;
2177         }
2178 
2179         virtual unsigned int offset227(int) {
2180             return offset = 227;
2181         }
2182 
2183         virtual unsigned int offset228(int) {
2184             return offset = 228;
2185         }
2186 
2187         virtual unsigned int offset229(int) {
2188             return offset = 229;
2189         }
2190 
2191         virtual unsigned int offset230(int) {
2192             return offset = 230;
2193         }
2194 
2195         virtual unsigned int offset231(int) {
2196             return offset = 231;
2197         }
2198 
2199         virtual unsigned int offset232(int) {
2200             return offset = 232;
2201         }
2202 
2203         virtual unsigned int offset233(int) {
2204             return offset = 233;
2205         }
2206 
2207         virtual unsigned int offset234(int) {
2208             return offset = 234;
2209         }
2210 
2211         virtual unsigned int offset235(int) {
2212             return offset = 235;
2213         }
2214 
2215         virtual unsigned int offset236(int) {
2216             return offset = 236;
2217         }
2218 
2219         virtual unsigned int offset237(int) {
2220             return offset = 237;
2221         }
2222 
2223         virtual unsigned int offset238(int) {
2224             return offset = 238;
2225         }
2226 
2227         virtual unsigned int offset239(int) {
2228             return offset = 239;
2229         }
2230 
2231         virtual unsigned int offset240(int) {
2232             return offset = 240;
2233         }
2234 
2235         virtual unsigned int offset241(int) {
2236             return offset = 241;
2237         }
2238 
2239         virtual unsigned int offset242(int) {
2240             return offset = 242;
2241         }
2242 
2243         virtual unsigned int offset243(int) {
2244             return offset = 243;
2245         }
2246 
2247         virtual unsigned int offset244(int) {
2248             return offset = 244;
2249         }
2250 
2251         virtual unsigned int offset245(int) {
2252             return offset = 245;
2253         }
2254 
2255         virtual unsigned int offset246(int) {
2256             return offset = 246;
2257         }
2258 
2259         virtual unsigned int offset247(int) {
2260             return offset = 247;
2261         }
2262 
2263         virtual unsigned int offset248(int) {
2264             return offset = 248;
2265         }
2266 
2267         virtual unsigned int offset249(int) {
2268             return offset = 249;
2269         }
2270 
2271         virtual unsigned int offset250(int) {
2272             return offset = 250;
2273         }
2274 
2275         virtual unsigned int offset251(int) {
2276             return offset = 251;
2277         }
2278 
2279         virtual unsigned int offset252(int) {
2280             return offset = 252;
2281         }
2282 
2283         virtual unsigned int offset253(int) {
2284             return offset = 253;
2285         }
2286 
2287         virtual unsigned int offset254(int) {
2288             return offset = 254;
2289         }
2290 
2291         virtual unsigned int offset255(int) {
2292             return offset = 255;
2293         }
2294 
2295         virtual unsigned int offset256(int) {
2296             return offset = 256;
2297         }
2298 
2299         virtual unsigned int offset257(int) {
2300             return offset = 257;
2301         }
2302 
2303         virtual unsigned int offset258(int) {
2304             return offset = 258;
2305         }
2306 
2307         virtual unsigned int offset259(int) {
2308             return offset = 259;
2309         }
2310 
2311         virtual unsigned int offset260(int) {
2312             return offset = 260;
2313         }
2314 
2315         virtual unsigned int offset261(int) {
2316             return offset = 261;
2317         }
2318 
2319         virtual unsigned int offset262(int) {
2320             return offset = 262;
2321         }
2322 
2323         virtual unsigned int offset263(int) {
2324             return offset = 263;
2325         }
2326 
2327         virtual unsigned int offset264(int) {
2328             return offset = 264;
2329         }
2330 
2331         virtual unsigned int offset265(int) {
2332             return offset = 265;
2333         }
2334 
2335         virtual unsigned int offset266(int) {
2336             return offset = 266;
2337         }
2338 
2339         virtual unsigned int offset267(int) {
2340             return offset = 267;
2341         }
2342 
2343         virtual unsigned int offset268(int) {
2344             return offset = 268;
2345         }
2346 
2347         virtual unsigned int offset269(int) {
2348             return offset = 269;
2349         }
2350 
2351         virtual unsigned int offset270(int) {
2352             return offset = 270;
2353         }
2354 
2355         virtual unsigned int offset271(int) {
2356             return offset = 271;
2357         }
2358 
2359         virtual unsigned int offset272(int) {
2360             return offset = 272;
2361         }
2362 
2363         virtual unsigned int offset273(int) {
2364             return offset = 273;
2365         }
2366 
2367         virtual unsigned int offset274(int) {
2368             return offset = 274;
2369         }
2370 
2371         virtual unsigned int offset275(int) {
2372             return offset = 275;
2373         }
2374 
2375         virtual unsigned int offset276(int) {
2376             return offset = 276;
2377         }
2378 
2379         virtual unsigned int offset277(int) {
2380             return offset = 277;
2381         }
2382 
2383         virtual unsigned int offset278(int) {
2384             return offset = 278;
2385         }
2386 
2387         virtual unsigned int offset279(int) {
2388             return offset = 279;
2389         }
2390 
2391         virtual unsigned int offset280(int) {
2392             return offset = 280;
2393         }
2394 
2395         virtual unsigned int offset281(int) {
2396             return offset = 281;
2397         }
2398 
2399         virtual unsigned int offset282(int) {
2400             return offset = 282;
2401         }
2402 
2403         virtual unsigned int offset283(int) {
2404             return offset = 283;
2405         }
2406 
2407         virtual unsigned int offset284(int) {
2408             return offset = 284;
2409         }
2410 
2411         virtual unsigned int offset285(int) {
2412             return offset = 285;
2413         }
2414 
2415         virtual unsigned int offset286(int) {
2416             return offset = 286;
2417         }
2418 
2419         virtual unsigned int offset287(int) {
2420             return offset = 287;
2421         }
2422 
2423         virtual unsigned int offset288(int) {
2424             return offset = 288;
2425         }
2426 
2427         virtual unsigned int offset289(int) {
2428             return offset = 289;
2429         }
2430 
2431         virtual unsigned int offset290(int) {
2432             return offset = 290;
2433         }
2434 
2435         virtual unsigned int offset291(int) {
2436             return offset = 291;
2437         }
2438 
2439         virtual unsigned int offset292(int) {
2440             return offset = 292;
2441         }
2442 
2443         virtual unsigned int offset293(int) {
2444             return offset = 293;
2445         }
2446 
2447         virtual unsigned int offset294(int) {
2448             return offset = 294;
2449         }
2450 
2451         virtual unsigned int offset295(int) {
2452             return offset = 295;
2453         }
2454 
2455         virtual unsigned int offset296(int) {
2456             return offset = 296;
2457         }
2458 
2459         virtual unsigned int offset297(int) {
2460             return offset = 297;
2461         }
2462 
2463         virtual unsigned int offset298(int) {
2464             return offset = 298;
2465         }
2466 
2467         virtual unsigned int offset299(int) {
2468             return offset = 299;
2469         }
2470 
2471 
2472         virtual unsigned int offset300(int) {
2473             return offset = 300;
2474         }
2475 
2476         virtual unsigned int offset301(int) {
2477             return offset = 301;
2478         }
2479 
2480         virtual unsigned int offset302(int) {
2481             return offset = 302;
2482         }
2483 
2484         virtual unsigned int offset303(int) {
2485             return offset = 303;
2486         }
2487 
2488         virtual unsigned int offset304(int) {
2489             return offset = 304;
2490         }
2491 
2492         virtual unsigned int offset305(int) {
2493             return offset = 305;
2494         }
2495 
2496         virtual unsigned int offset306(int) {
2497             return offset = 306;
2498         }
2499 
2500         virtual unsigned int offset307(int) {
2501             return offset = 307;
2502         }
2503 
2504         virtual unsigned int offset308(int) {
2505             return offset = 308;
2506         }
2507 
2508         virtual unsigned int offset309(int) {
2509             return offset = 309;
2510         }
2511 
2512         virtual unsigned int offset310(int) {
2513             return offset = 310;
2514         }
2515 
2516         virtual unsigned int offset311(int) {
2517             return offset = 311;
2518         }
2519 
2520         virtual unsigned int offset312(int) {
2521             return offset = 312;
2522         }
2523 
2524         virtual unsigned int offset313(int) {
2525             return offset = 313;
2526         }
2527 
2528         virtual unsigned int offset314(int) {
2529             return offset = 314;
2530         }
2531 
2532         virtual unsigned int offset315(int) {
2533             return offset = 315;
2534         }
2535 
2536         virtual unsigned int offset316(int) {
2537             return offset = 316;
2538         }
2539 
2540         virtual unsigned int offset317(int) {
2541             return offset = 317;
2542         }
2543 
2544         virtual unsigned int offset318(int) {
2545             return offset = 318;
2546         }
2547 
2548         virtual unsigned int offset319(int) {
2549             return offset = 319;
2550         }
2551 
2552         virtual unsigned int offset320(int) {
2553             return offset = 320;
2554         }
2555 
2556         virtual unsigned int offset321(int) {
2557             return offset = 321;
2558         }
2559 
2560         virtual unsigned int offset322(int) {
2561             return offset = 322;
2562         }
2563 
2564         virtual unsigned int offset323(int) {
2565             return offset = 323;
2566         }
2567 
2568         virtual unsigned int offset324(int) {
2569             return offset = 324;
2570         }
2571 
2572         virtual unsigned int offset325(int) {
2573             return offset = 325;
2574         }
2575 
2576         virtual unsigned int offset326(int) {
2577             return offset = 326;
2578         }
2579 
2580         virtual unsigned int offset327(int) {
2581             return offset = 327;
2582         }
2583 
2584         virtual unsigned int offset328(int) {
2585             return offset = 328;
2586         }
2587 
2588         virtual unsigned int offset329(int) {
2589             return offset = 329;
2590         }
2591 
2592         virtual unsigned int offset330(int) {
2593             return offset = 330;
2594         }
2595 
2596         virtual unsigned int offset331(int) {
2597             return offset = 331;
2598         }
2599 
2600         virtual unsigned int offset332(int) {
2601             return offset = 332;
2602         }
2603 
2604         virtual unsigned int offset333(int) {
2605             return offset = 333;
2606         }
2607 
2608         virtual unsigned int offset334(int) {
2609             return offset = 334;
2610         }
2611 
2612         virtual unsigned int offset335(int) {
2613             return offset = 335;
2614         }
2615 
2616         virtual unsigned int offset336(int) {
2617             return offset = 336;
2618         }
2619 
2620         virtual unsigned int offset337(int) {
2621             return offset = 337;
2622         }
2623 
2624         virtual unsigned int offset338(int) {
2625             return offset = 338;
2626         }
2627 
2628         virtual unsigned int offset339(int) {
2629             return offset = 339;
2630         }
2631 
2632         virtual unsigned int offset340(int) {
2633             return offset = 340;
2634         }
2635 
2636         virtual unsigned int offset341(int) {
2637             return offset = 341;
2638         }
2639 
2640         virtual unsigned int offset342(int) {
2641             return offset = 342;
2642         }
2643 
2644         virtual unsigned int offset343(int) {
2645             return offset = 343;
2646         }
2647 
2648         virtual unsigned int offset344(int) {
2649             return offset = 344;
2650         }
2651 
2652         virtual unsigned int offset345(int) {
2653             return offset = 345;
2654         }
2655 
2656         virtual unsigned int offset346(int) {
2657             return offset = 346;
2658         }
2659 
2660         virtual unsigned int offset347(int) {
2661             return offset = 347;
2662         }
2663 
2664         virtual unsigned int offset348(int) {
2665             return offset = 348;
2666         }
2667 
2668         virtual unsigned int offset349(int) {
2669             return offset = 349;
2670         }
2671 
2672         virtual unsigned int offset350(int) {
2673             return offset = 350;
2674         }
2675 
2676         virtual unsigned int offset351(int) {
2677             return offset = 351;
2678         }
2679 
2680         virtual unsigned int offset352(int) {
2681             return offset = 352;
2682         }
2683 
2684         virtual unsigned int offset353(int) {
2685             return offset = 353;
2686         }
2687 
2688         virtual unsigned int offset354(int) {
2689             return offset = 354;
2690         }
2691 
2692         virtual unsigned int offset355(int) {
2693             return offset = 355;
2694         }
2695 
2696         virtual unsigned int offset356(int) {
2697             return offset = 356;
2698         }
2699 
2700         virtual unsigned int offset357(int) {
2701             return offset = 357;
2702         }
2703 
2704         virtual unsigned int offset358(int) {
2705             return offset = 358;
2706         }
2707 
2708         virtual unsigned int offset359(int) {
2709             return offset = 359;
2710         }
2711 
2712         virtual unsigned int offset360(int) {
2713             return offset = 360;
2714         }
2715 
2716         virtual unsigned int offset361(int) {
2717             return offset = 361;
2718         }
2719 
2720         virtual unsigned int offset362(int) {
2721             return offset = 362;
2722         }
2723 
2724         virtual unsigned int offset363(int) {
2725             return offset = 363;
2726         }
2727 
2728         virtual unsigned int offset364(int) {
2729             return offset = 364;
2730         }
2731 
2732         virtual unsigned int offset365(int) {
2733             return offset = 365;
2734         }
2735 
2736         virtual unsigned int offset366(int) {
2737             return offset = 366;
2738         }
2739 
2740         virtual unsigned int offset367(int) {
2741             return offset = 367;
2742         }
2743 
2744         virtual unsigned int offset368(int) {
2745             return offset = 368;
2746         }
2747 
2748         virtual unsigned int offset369(int) {
2749             return offset = 369;
2750         }
2751 
2752         virtual unsigned int offset370(int) {
2753             return offset = 370;
2754         }
2755 
2756         virtual unsigned int offset371(int) {
2757             return offset = 371;
2758         }
2759 
2760         virtual unsigned int offset372(int) {
2761             return offset = 372;
2762         }
2763 
2764         virtual unsigned int offset373(int) {
2765             return offset = 373;
2766         }
2767 
2768         virtual unsigned int offset374(int) {
2769             return offset = 374;
2770         }
2771 
2772         virtual unsigned int offset375(int) {
2773             return offset = 375;
2774         }
2775 
2776         virtual unsigned int offset376(int) {
2777             return offset = 376;
2778         }
2779 
2780         virtual unsigned int offset377(int) {
2781             return offset = 377;
2782         }
2783 
2784         virtual unsigned int offset378(int) {
2785             return offset = 378;
2786         }
2787 
2788         virtual unsigned int offset379(int) {
2789             return offset = 379;
2790         }
2791 
2792         virtual unsigned int offset380(int) {
2793             return offset = 380;
2794         }
2795 
2796         virtual unsigned int offset381(int) {
2797             return offset = 381;
2798         }
2799 
2800         virtual unsigned int offset382(int) {
2801             return offset = 382;
2802         }
2803 
2804         virtual unsigned int offset383(int) {
2805             return offset = 383;
2806         }
2807 
2808         virtual unsigned int offset384(int) {
2809             return offset = 384;
2810         }
2811 
2812         virtual unsigned int offset385(int) {
2813             return offset = 385;
2814         }
2815 
2816         virtual unsigned int offset386(int) {
2817             return offset = 386;
2818         }
2819 
2820         virtual unsigned int offset387(int) {
2821             return offset = 387;
2822         }
2823 
2824         virtual unsigned int offset388(int) {
2825             return offset = 388;
2826         }
2827 
2828         virtual unsigned int offset389(int) {
2829             return offset = 389;
2830         }
2831 
2832         virtual unsigned int offset390(int) {
2833             return offset = 390;
2834         }
2835 
2836         virtual unsigned int offset391(int) {
2837             return offset = 391;
2838         }
2839 
2840         virtual unsigned int offset392(int) {
2841             return offset = 392;
2842         }
2843 
2844         virtual unsigned int offset393(int) {
2845             return offset = 393;
2846         }
2847 
2848         virtual unsigned int offset394(int) {
2849             return offset = 394;
2850         }
2851 
2852         virtual unsigned int offset395(int) {
2853             return offset = 395;
2854         }
2855 
2856         virtual unsigned int offset396(int) {
2857             return offset = 396;
2858         }
2859 
2860         virtual unsigned int offset397(int) {
2861             return offset = 397;
2862         }
2863 
2864         virtual unsigned int offset398(int) {
2865             return offset = 398;
2866         }
2867 
2868         virtual unsigned int offset399(int) {
2869             return offset = 399;
2870         }
2871 
2872 
2873         virtual unsigned int offset400(int) {
2874             return offset = 400;
2875         }
2876 
2877         virtual unsigned int offset401(int) {
2878             return offset = 401;
2879         }
2880 
2881         virtual unsigned int offset402(int) {
2882             return offset = 402;
2883         }
2884 
2885         virtual unsigned int offset403(int) {
2886             return offset = 403;
2887         }
2888 
2889         virtual unsigned int offset404(int) {
2890             return offset = 404;
2891         }
2892 
2893         virtual unsigned int offset405(int) {
2894             return offset = 405;
2895         }
2896 
2897         virtual unsigned int offset406(int) {
2898             return offset = 406;
2899         }
2900 
2901         virtual unsigned int offset407(int) {
2902             return offset = 407;
2903         }
2904 
2905         virtual unsigned int offset408(int) {
2906             return offset = 408;
2907         }
2908 
2909         virtual unsigned int offset409(int) {
2910             return offset = 409;
2911         }
2912 
2913         virtual unsigned int offset410(int) {
2914             return offset = 410;
2915         }
2916 
2917         virtual unsigned int offset411(int) {
2918             return offset = 411;
2919         }
2920 
2921         virtual unsigned int offset412(int) {
2922             return offset = 412;
2923         }
2924 
2925         virtual unsigned int offset413(int) {
2926             return offset = 413;
2927         }
2928 
2929         virtual unsigned int offset414(int) {
2930             return offset = 414;
2931         }
2932 
2933         virtual unsigned int offset415(int) {
2934             return offset = 415;
2935         }
2936 
2937         virtual unsigned int offset416(int) {
2938             return offset = 416;
2939         }
2940 
2941         virtual unsigned int offset417(int) {
2942             return offset = 417;
2943         }
2944 
2945         virtual unsigned int offset418(int) {
2946             return offset = 418;
2947         }
2948 
2949         virtual unsigned int offset419(int) {
2950             return offset = 419;
2951         }
2952 
2953         virtual unsigned int offset420(int) {
2954             return offset = 420;
2955         }
2956 
2957         virtual unsigned int offset421(int) {
2958             return offset = 421;
2959         }
2960 
2961         virtual unsigned int offset422(int) {
2962             return offset = 422;
2963         }
2964 
2965         virtual unsigned int offset423(int) {
2966             return offset = 423;
2967         }
2968 
2969         virtual unsigned int offset424(int) {
2970             return offset = 424;
2971         }
2972 
2973         virtual unsigned int offset425(int) {
2974             return offset = 425;
2975         }
2976 
2977         virtual unsigned int offset426(int) {
2978             return offset = 426;
2979         }
2980 
2981         virtual unsigned int offset427(int) {
2982             return offset = 427;
2983         }
2984 
2985         virtual unsigned int offset428(int) {
2986             return offset = 428;
2987         }
2988 
2989         virtual unsigned int offset429(int) {
2990             return offset = 429;
2991         }
2992 
2993         virtual unsigned int offset430(int) {
2994             return offset = 430;
2995         }
2996 
2997         virtual unsigned int offset431(int) {
2998             return offset = 431;
2999         }
3000 
3001         virtual unsigned int offset432(int) {
3002             return offset = 432;
3003         }
3004 
3005         virtual unsigned int offset433(int) {
3006             return offset = 433;
3007         }
3008 
3009         virtual unsigned int offset434(int) {
3010             return offset = 434;
3011         }
3012 
3013         virtual unsigned int offset435(int) {
3014             return offset = 435;
3015         }
3016 
3017         virtual unsigned int offset436(int) {
3018             return offset = 436;
3019         }
3020 
3021         virtual unsigned int offset437(int) {
3022             return offset = 437;
3023         }
3024 
3025         virtual unsigned int offset438(int) {
3026             return offset = 438;
3027         }
3028 
3029         virtual unsigned int offset439(int) {
3030             return offset = 439;
3031         }
3032 
3033         virtual unsigned int offset440(int) {
3034             return offset = 440;
3035         }
3036 
3037         virtual unsigned int offset441(int) {
3038             return offset = 441;
3039         }
3040 
3041         virtual unsigned int offset442(int) {
3042             return offset = 442;
3043         }
3044 
3045         virtual unsigned int offset443(int) {
3046             return offset = 443;
3047         }
3048 
3049         virtual unsigned int offset444(int) {
3050             return offset = 444;
3051         }
3052 
3053         virtual unsigned int offset445(int) {
3054             return offset = 445;
3055         }
3056 
3057         virtual unsigned int offset446(int) {
3058             return offset = 446;
3059         }
3060 
3061         virtual unsigned int offset447(int) {
3062             return offset = 447;
3063         }
3064 
3065         virtual unsigned int offset448(int) {
3066             return offset = 448;
3067         }
3068 
3069         virtual unsigned int offset449(int) {
3070             return offset = 449;
3071         }
3072 
3073         virtual unsigned int offset450(int) {
3074             return offset = 450;
3075         }
3076 
3077         virtual unsigned int offset451(int) {
3078             return offset = 451;
3079         }
3080 
3081         virtual unsigned int offset452(int) {
3082             return offset = 452;
3083         }
3084 
3085         virtual unsigned int offset453(int) {
3086             return offset = 453;
3087         }
3088 
3089         virtual unsigned int offset454(int) {
3090             return offset = 454;
3091         }
3092 
3093         virtual unsigned int offset455(int) {
3094             return offset = 455;
3095         }
3096 
3097         virtual unsigned int offset456(int) {
3098             return offset = 456;
3099         }
3100 
3101         virtual unsigned int offset457(int) {
3102             return offset = 457;
3103         }
3104 
3105         virtual unsigned int offset458(int) {
3106             return offset = 458;
3107         }
3108 
3109         virtual unsigned int offset459(int) {
3110             return offset = 459;
3111         }
3112 
3113         virtual unsigned int offset460(int) {
3114             return offset = 460;
3115         }
3116 
3117         virtual unsigned int offset461(int) {
3118             return offset = 461;
3119         }
3120 
3121         virtual unsigned int offset462(int) {
3122             return offset = 462;
3123         }
3124 
3125         virtual unsigned int offset463(int) {
3126             return offset = 463;
3127         }
3128 
3129         virtual unsigned int offset464(int) {
3130             return offset = 464;
3131         }
3132 
3133         virtual unsigned int offset465(int) {
3134             return offset = 465;
3135         }
3136 
3137         virtual unsigned int offset466(int) {
3138             return offset = 466;
3139         }
3140 
3141         virtual unsigned int offset467(int) {
3142             return offset = 467;
3143         }
3144 
3145         virtual unsigned int offset468(int) {
3146             return offset = 468;
3147         }
3148 
3149         virtual unsigned int offset469(int) {
3150             return offset = 469;
3151         }
3152 
3153         virtual unsigned int offset470(int) {
3154             return offset = 470;
3155         }
3156 
3157         virtual unsigned int offset471(int) {
3158             return offset = 471;
3159         }
3160 
3161         virtual unsigned int offset472(int) {
3162             return offset = 472;
3163         }
3164 
3165         virtual unsigned int offset473(int) {
3166             return offset = 473;
3167         }
3168 
3169         virtual unsigned int offset474(int) {
3170             return offset = 474;
3171         }
3172 
3173         virtual unsigned int offset475(int) {
3174             return offset = 475;
3175         }
3176 
3177         virtual unsigned int offset476(int) {
3178             return offset = 476;
3179         }
3180 
3181         virtual unsigned int offset477(int) {
3182             return offset = 477;
3183         }
3184 
3185         virtual unsigned int offset478(int) {
3186             return offset = 478;
3187         }
3188 
3189         virtual unsigned int offset479(int) {
3190             return offset = 479;
3191         }
3192 
3193         virtual unsigned int offset480(int) {
3194             return offset = 480;
3195         }
3196 
3197         virtual unsigned int offset481(int) {
3198             return offset = 481;
3199         }
3200 
3201         virtual unsigned int offset482(int) {
3202             return offset = 482;
3203         }
3204 
3205         virtual unsigned int offset483(int) {
3206             return offset = 483;
3207         }
3208 
3209         virtual unsigned int offset484(int) {
3210             return offset = 484;
3211         }
3212 
3213         virtual unsigned int offset485(int) {
3214             return offset = 485;
3215         }
3216 
3217         virtual unsigned int offset486(int) {
3218             return offset = 486;
3219         }
3220 
3221         virtual unsigned int offset487(int) {
3222             return offset = 487;
3223         }
3224 
3225         virtual unsigned int offset488(int) {
3226             return offset = 488;
3227         }
3228 
3229         virtual unsigned int offset489(int) {
3230             return offset = 489;
3231         }
3232 
3233         virtual unsigned int offset490(int) {
3234             return offset = 490;
3235         }
3236 
3237         virtual unsigned int offset491(int) {
3238             return offset = 491;
3239         }
3240 
3241         virtual unsigned int offset492(int) {
3242             return offset = 492;
3243         }
3244 
3245         virtual unsigned int offset493(int) {
3246             return offset = 493;
3247         }
3248 
3249         virtual unsigned int offset494(int) {
3250             return offset = 494;
3251         }
3252 
3253         virtual unsigned int offset495(int) {
3254             return offset = 495;
3255         }
3256 
3257         virtual unsigned int offset496(int) {
3258             return offset = 496;
3259         }
3260 
3261         virtual unsigned int offset497(int) {
3262             return offset = 497;
3263         }
3264 
3265         virtual unsigned int offset498(int) {
3266             return offset = 498;
3267         }
3268 
3269         virtual unsigned int offset499(int) {
3270             return offset = 499;
3271         }
3272 
3273 
3274         virtual unsigned int offset500(int) {
3275             return offset = 500;
3276         }
3277 
3278         virtual unsigned int offset501(int) {
3279             return offset = 501;
3280         }
3281 
3282         virtual unsigned int offset502(int) {
3283             return offset = 502;
3284         }
3285 
3286         virtual unsigned int offset503(int) {
3287             return offset = 503;
3288         }
3289 
3290         virtual unsigned int offset504(int) {
3291             return offset = 504;
3292         }
3293 
3294         virtual unsigned int offset505(int) {
3295             return offset = 505;
3296         }
3297 
3298         virtual unsigned int offset506(int) {
3299             return offset = 506;
3300         }
3301 
3302         virtual unsigned int offset507(int) {
3303             return offset = 507;
3304         }
3305 
3306         virtual unsigned int offset508(int) {
3307             return offset = 508;
3308         }
3309 
3310         virtual unsigned int offset509(int) {
3311             return offset = 509;
3312         }
3313 
3314         virtual unsigned int offset510(int) {
3315             return offset = 510;
3316         }
3317 
3318         virtual unsigned int offset511(int) {
3319             return offset = 511;
3320         }
3321 
3322         virtual unsigned int offset512(int) {
3323             return offset = 512;
3324         }
3325 
3326         virtual unsigned int offset513(int) {
3327             return offset = 513;
3328         }
3329 
3330         virtual unsigned int offset514(int) {
3331             return offset = 514;
3332         }
3333 
3334         virtual unsigned int offset515(int) {
3335             return offset = 515;
3336         }
3337 
3338         virtual unsigned int offset516(int) {
3339             return offset = 516;
3340         }
3341 
3342         virtual unsigned int offset517(int) {
3343             return offset = 517;
3344         }
3345 
3346         virtual unsigned int offset518(int) {
3347             return offset = 518;
3348         }
3349 
3350         virtual unsigned int offset519(int) {
3351             return offset = 519;
3352         }
3353 
3354         virtual unsigned int offset520(int) {
3355             return offset = 520;
3356         }
3357 
3358         virtual unsigned int offset521(int) {
3359             return offset = 521;
3360         }
3361 
3362         virtual unsigned int offset522(int) {
3363             return offset = 522;
3364         }
3365 
3366         virtual unsigned int offset523(int) {
3367             return offset = 523;
3368         }
3369 
3370         virtual unsigned int offset524(int) {
3371             return offset = 524;
3372         }
3373 
3374         virtual unsigned int offset525(int) {
3375             return offset = 525;
3376         }
3377 
3378         virtual unsigned int offset526(int) {
3379             return offset = 526;
3380         }
3381 
3382         virtual unsigned int offset527(int) {
3383             return offset = 527;
3384         }
3385 
3386         virtual unsigned int offset528(int) {
3387             return offset = 528;
3388         }
3389 
3390         virtual unsigned int offset529(int) {
3391             return offset = 529;
3392         }
3393 
3394         virtual unsigned int offset530(int) {
3395             return offset = 530;
3396         }
3397 
3398         virtual unsigned int offset531(int) {
3399             return offset = 531;
3400         }
3401 
3402         virtual unsigned int offset532(int) {
3403             return offset = 532;
3404         }
3405 
3406         virtual unsigned int offset533(int) {
3407             return offset = 533;
3408         }
3409 
3410         virtual unsigned int offset534(int) {
3411             return offset = 534;
3412         }
3413 
3414         virtual unsigned int offset535(int) {
3415             return offset = 535;
3416         }
3417 
3418         virtual unsigned int offset536(int) {
3419             return offset = 536;
3420         }
3421 
3422         virtual unsigned int offset537(int) {
3423             return offset = 537;
3424         }
3425 
3426         virtual unsigned int offset538(int) {
3427             return offset = 538;
3428         }
3429 
3430         virtual unsigned int offset539(int) {
3431             return offset = 539;
3432         }
3433 
3434         virtual unsigned int offset540(int) {
3435             return offset = 540;
3436         }
3437 
3438         virtual unsigned int offset541(int) {
3439             return offset = 541;
3440         }
3441 
3442         virtual unsigned int offset542(int) {
3443             return offset = 542;
3444         }
3445 
3446         virtual unsigned int offset543(int) {
3447             return offset = 543;
3448         }
3449 
3450         virtual unsigned int offset544(int) {
3451             return offset = 544;
3452         }
3453 
3454         virtual unsigned int offset545(int) {
3455             return offset = 545;
3456         }
3457 
3458         virtual unsigned int offset546(int) {
3459             return offset = 546;
3460         }
3461 
3462         virtual unsigned int offset547(int) {
3463             return offset = 547;
3464         }
3465 
3466         virtual unsigned int offset548(int) {
3467             return offset = 548;
3468         }
3469 
3470         virtual unsigned int offset549(int) {
3471             return offset = 549;
3472         }
3473 
3474         virtual unsigned int offset550(int) {
3475             return offset = 550;
3476         }
3477 
3478         virtual unsigned int offset551(int) {
3479             return offset = 551;
3480         }
3481 
3482         virtual unsigned int offset552(int) {
3483             return offset = 552;
3484         }
3485 
3486         virtual unsigned int offset553(int) {
3487             return offset = 553;
3488         }
3489 
3490         virtual unsigned int offset554(int) {
3491             return offset = 554;
3492         }
3493 
3494         virtual unsigned int offset555(int) {
3495             return offset = 555;
3496         }
3497 
3498         virtual unsigned int offset556(int) {
3499             return offset = 556;
3500         }
3501 
3502         virtual unsigned int offset557(int) {
3503             return offset = 557;
3504         }
3505 
3506         virtual unsigned int offset558(int) {
3507             return offset = 558;
3508         }
3509 
3510         virtual unsigned int offset559(int) {
3511             return offset = 559;
3512         }
3513 
3514         virtual unsigned int offset560(int) {
3515             return offset = 560;
3516         }
3517 
3518         virtual unsigned int offset561(int) {
3519             return offset = 561;
3520         }
3521 
3522         virtual unsigned int offset562(int) {
3523             return offset = 562;
3524         }
3525 
3526         virtual unsigned int offset563(int) {
3527             return offset = 563;
3528         }
3529 
3530         virtual unsigned int offset564(int) {
3531             return offset = 564;
3532         }
3533 
3534         virtual unsigned int offset565(int) {
3535             return offset = 565;
3536         }
3537 
3538         virtual unsigned int offset566(int) {
3539             return offset = 566;
3540         }
3541 
3542         virtual unsigned int offset567(int) {
3543             return offset = 567;
3544         }
3545 
3546         virtual unsigned int offset568(int) {
3547             return offset = 568;
3548         }
3549 
3550         virtual unsigned int offset569(int) {
3551             return offset = 569;
3552         }
3553 
3554         virtual unsigned int offset570(int) {
3555             return offset = 570;
3556         }
3557 
3558         virtual unsigned int offset571(int) {
3559             return offset = 571;
3560         }
3561 
3562         virtual unsigned int offset572(int) {
3563             return offset = 572;
3564         }
3565 
3566         virtual unsigned int offset573(int) {
3567             return offset = 573;
3568         }
3569 
3570         virtual unsigned int offset574(int) {
3571             return offset = 574;
3572         }
3573 
3574         virtual unsigned int offset575(int) {
3575             return offset = 575;
3576         }
3577 
3578         virtual unsigned int offset576(int) {
3579             return offset = 576;
3580         }
3581 
3582         virtual unsigned int offset577(int) {
3583             return offset = 577;
3584         }
3585 
3586         virtual unsigned int offset578(int) {
3587             return offset = 578;
3588         }
3589 
3590         virtual unsigned int offset579(int) {
3591             return offset = 579;
3592         }
3593 
3594         virtual unsigned int offset580(int) {
3595             return offset = 580;
3596         }
3597 
3598         virtual unsigned int offset581(int) {
3599             return offset = 581;
3600         }
3601 
3602         virtual unsigned int offset582(int) {
3603             return offset = 582;
3604         }
3605 
3606         virtual unsigned int offset583(int) {
3607             return offset = 583;
3608         }
3609 
3610         virtual unsigned int offset584(int) {
3611             return offset = 584;
3612         }
3613 
3614         virtual unsigned int offset585(int) {
3615             return offset = 585;
3616         }
3617 
3618         virtual unsigned int offset586(int) {
3619             return offset = 586;
3620         }
3621 
3622         virtual unsigned int offset587(int) {
3623             return offset = 587;
3624         }
3625 
3626         virtual unsigned int offset588(int) {
3627             return offset = 588;
3628         }
3629 
3630         virtual unsigned int offset589(int) {
3631             return offset = 589;
3632         }
3633 
3634         virtual unsigned int offset590(int) {
3635             return offset = 590;
3636         }
3637 
3638         virtual unsigned int offset591(int) {
3639             return offset = 591;
3640         }
3641 
3642         virtual unsigned int offset592(int) {
3643             return offset = 592;
3644         }
3645 
3646         virtual unsigned int offset593(int) {
3647             return offset = 593;
3648         }
3649 
3650         virtual unsigned int offset594(int) {
3651             return offset = 594;
3652         }
3653 
3654         virtual unsigned int offset595(int) {
3655             return offset = 595;
3656         }
3657 
3658         virtual unsigned int offset596(int) {
3659             return offset = 596;
3660         }
3661 
3662         virtual unsigned int offset597(int) {
3663             return offset = 597;
3664         }
3665 
3666         virtual unsigned int offset598(int) {
3667             return offset = 598;
3668         }
3669 
3670         virtual unsigned int offset599(int) {
3671             return offset = 599;
3672         }
3673 
3674 
3675         virtual unsigned int offset600(int) {
3676             return offset = 600;
3677         }
3678 
3679         virtual unsigned int offset601(int) {
3680             return offset = 601;
3681         }
3682 
3683         virtual unsigned int offset602(int) {
3684             return offset = 602;
3685         }
3686 
3687         virtual unsigned int offset603(int) {
3688             return offset = 603;
3689         }
3690 
3691         virtual unsigned int offset604(int) {
3692             return offset = 604;
3693         }
3694 
3695         virtual unsigned int offset605(int) {
3696             return offset = 605;
3697         }
3698 
3699         virtual unsigned int offset606(int) {
3700             return offset = 606;
3701         }
3702 
3703         virtual unsigned int offset607(int) {
3704             return offset = 607;
3705         }
3706 
3707         virtual unsigned int offset608(int) {
3708             return offset = 608;
3709         }
3710 
3711         virtual unsigned int offset609(int) {
3712             return offset = 609;
3713         }
3714 
3715         virtual unsigned int offset610(int) {
3716             return offset = 610;
3717         }
3718 
3719         virtual unsigned int offset611(int) {
3720             return offset = 611;
3721         }
3722 
3723         virtual unsigned int offset612(int) {
3724             return offset = 612;
3725         }
3726 
3727         virtual unsigned int offset613(int) {
3728             return offset = 613;
3729         }
3730 
3731         virtual unsigned int offset614(int) {
3732             return offset = 614;
3733         }
3734 
3735         virtual unsigned int offset615(int) {
3736             return offset = 615;
3737         }
3738 
3739         virtual unsigned int offset616(int) {
3740             return offset = 616;
3741         }
3742 
3743         virtual unsigned int offset617(int) {
3744             return offset = 617;
3745         }
3746 
3747         virtual unsigned int offset618(int) {
3748             return offset = 618;
3749         }
3750 
3751         virtual unsigned int offset619(int) {
3752             return offset = 619;
3753         }
3754 
3755         virtual unsigned int offset620(int) {
3756             return offset = 620;
3757         }
3758 
3759         virtual unsigned int offset621(int) {
3760             return offset = 621;
3761         }
3762 
3763         virtual unsigned int offset622(int) {
3764             return offset = 622;
3765         }
3766 
3767         virtual unsigned int offset623(int) {
3768             return offset = 623;
3769         }
3770 
3771         virtual unsigned int offset624(int) {
3772             return offset = 624;
3773         }
3774 
3775         virtual unsigned int offset625(int) {
3776             return offset = 625;
3777         }
3778 
3779         virtual unsigned int offset626(int) {
3780             return offset = 626;
3781         }
3782 
3783         virtual unsigned int offset627(int) {
3784             return offset = 627;
3785         }
3786 
3787         virtual unsigned int offset628(int) {
3788             return offset = 628;
3789         }
3790 
3791         virtual unsigned int offset629(int) {
3792             return offset = 629;
3793         }
3794 
3795         virtual unsigned int offset630(int) {
3796             return offset = 630;
3797         }
3798 
3799         virtual unsigned int offset631(int) {
3800             return offset = 631;
3801         }
3802 
3803         virtual unsigned int offset632(int) {
3804             return offset = 632;
3805         }
3806 
3807         virtual unsigned int offset633(int) {
3808             return offset = 633;
3809         }
3810 
3811         virtual unsigned int offset634(int) {
3812             return offset = 634;
3813         }
3814 
3815         virtual unsigned int offset635(int) {
3816             return offset = 635;
3817         }
3818 
3819         virtual unsigned int offset636(int) {
3820             return offset = 636;
3821         }
3822 
3823         virtual unsigned int offset637(int) {
3824             return offset = 637;
3825         }
3826 
3827         virtual unsigned int offset638(int) {
3828             return offset = 638;
3829         }
3830 
3831         virtual unsigned int offset639(int) {
3832             return offset = 639;
3833         }
3834 
3835         virtual unsigned int offset640(int) {
3836             return offset = 640;
3837         }
3838 
3839         virtual unsigned int offset641(int) {
3840             return offset = 641;
3841         }
3842 
3843         virtual unsigned int offset642(int) {
3844             return offset = 642;
3845         }
3846 
3847         virtual unsigned int offset643(int) {
3848             return offset = 643;
3849         }
3850 
3851         virtual unsigned int offset644(int) {
3852             return offset = 644;
3853         }
3854 
3855         virtual unsigned int offset645(int) {
3856             return offset = 645;
3857         }
3858 
3859         virtual unsigned int offset646(int) {
3860             return offset = 646;
3861         }
3862 
3863         virtual unsigned int offset647(int) {
3864             return offset = 647;
3865         }
3866 
3867         virtual unsigned int offset648(int) {
3868             return offset = 648;
3869         }
3870 
3871         virtual unsigned int offset649(int) {
3872             return offset = 649;
3873         }
3874 
3875         virtual unsigned int offset650(int) {
3876             return offset = 650;
3877         }
3878 
3879         virtual unsigned int offset651(int) {
3880             return offset = 651;
3881         }
3882 
3883         virtual unsigned int offset652(int) {
3884             return offset = 652;
3885         }
3886 
3887         virtual unsigned int offset653(int) {
3888             return offset = 653;
3889         }
3890 
3891         virtual unsigned int offset654(int) {
3892             return offset = 654;
3893         }
3894 
3895         virtual unsigned int offset655(int) {
3896             return offset = 655;
3897         }
3898 
3899         virtual unsigned int offset656(int) {
3900             return offset = 656;
3901         }
3902 
3903         virtual unsigned int offset657(int) {
3904             return offset = 657;
3905         }
3906 
3907         virtual unsigned int offset658(int) {
3908             return offset = 658;
3909         }
3910 
3911         virtual unsigned int offset659(int) {
3912             return offset = 659;
3913         }
3914 
3915         virtual unsigned int offset660(int) {
3916             return offset = 660;
3917         }
3918 
3919         virtual unsigned int offset661(int) {
3920             return offset = 661;
3921         }
3922 
3923         virtual unsigned int offset662(int) {
3924             return offset = 662;
3925         }
3926 
3927         virtual unsigned int offset663(int) {
3928             return offset = 663;
3929         }
3930 
3931         virtual unsigned int offset664(int) {
3932             return offset = 664;
3933         }
3934 
3935         virtual unsigned int offset665(int) {
3936             return offset = 665;
3937         }
3938 
3939         virtual unsigned int offset666(int) {
3940             return offset = 666;
3941         }
3942 
3943         virtual unsigned int offset667(int) {
3944             return offset = 667;
3945         }
3946 
3947         virtual unsigned int offset668(int) {
3948             return offset = 668;
3949         }
3950 
3951         virtual unsigned int offset669(int) {
3952             return offset = 669;
3953         }
3954 
3955         virtual unsigned int offset670(int) {
3956             return offset = 670;
3957         }
3958 
3959         virtual unsigned int offset671(int) {
3960             return offset = 671;
3961         }
3962 
3963         virtual unsigned int offset672(int) {
3964             return offset = 672;
3965         }
3966 
3967         virtual unsigned int offset673(int) {
3968             return offset = 673;
3969         }
3970 
3971         virtual unsigned int offset674(int) {
3972             return offset = 674;
3973         }
3974 
3975         virtual unsigned int offset675(int) {
3976             return offset = 675;
3977         }
3978 
3979         virtual unsigned int offset676(int) {
3980             return offset = 676;
3981         }
3982 
3983         virtual unsigned int offset677(int) {
3984             return offset = 677;
3985         }
3986 
3987         virtual unsigned int offset678(int) {
3988             return offset = 678;
3989         }
3990 
3991         virtual unsigned int offset679(int) {
3992             return offset = 679;
3993         }
3994 
3995         virtual unsigned int offset680(int) {
3996             return offset = 680;
3997         }
3998 
3999         virtual unsigned int offset681(int) {
4000             return offset = 681;
4001         }
4002 
4003         virtual unsigned int offset682(int) {
4004             return offset = 682;
4005         }
4006 
4007         virtual unsigned int offset683(int) {
4008             return offset = 683;
4009         }
4010 
4011         virtual unsigned int offset684(int) {
4012             return offset = 684;
4013         }
4014 
4015         virtual unsigned int offset685(int) {
4016             return offset = 685;
4017         }
4018 
4019         virtual unsigned int offset686(int) {
4020             return offset = 686;
4021         }
4022 
4023         virtual unsigned int offset687(int) {
4024             return offset = 687;
4025         }
4026 
4027         virtual unsigned int offset688(int) {
4028             return offset = 688;
4029         }
4030 
4031         virtual unsigned int offset689(int) {
4032             return offset = 689;
4033         }
4034 
4035         virtual unsigned int offset690(int) {
4036             return offset = 690;
4037         }
4038 
4039         virtual unsigned int offset691(int) {
4040             return offset = 691;
4041         }
4042 
4043         virtual unsigned int offset692(int) {
4044             return offset = 692;
4045         }
4046 
4047         virtual unsigned int offset693(int) {
4048             return offset = 693;
4049         }
4050 
4051         virtual unsigned int offset694(int) {
4052             return offset = 694;
4053         }
4054 
4055         virtual unsigned int offset695(int) {
4056             return offset = 695;
4057         }
4058 
4059         virtual unsigned int offset696(int) {
4060             return offset = 696;
4061         }
4062 
4063         virtual unsigned int offset697(int) {
4064             return offset = 697;
4065         }
4066 
4067         virtual unsigned int offset698(int) {
4068             return offset = 698;
4069         }
4070 
4071         virtual unsigned int offset699(int) {
4072             return offset = 699;
4073         }
4074 
4075 
4076         virtual unsigned int offset700(int) {
4077             return offset = 700;
4078         }
4079 
4080         virtual unsigned int offset701(int) {
4081             return offset = 701;
4082         }
4083 
4084         virtual unsigned int offset702(int) {
4085             return offset = 702;
4086         }
4087 
4088         virtual unsigned int offset703(int) {
4089             return offset = 703;
4090         }
4091 
4092         virtual unsigned int offset704(int) {
4093             return offset = 704;
4094         }
4095 
4096         virtual unsigned int offset705(int) {
4097             return offset = 705;
4098         }
4099 
4100         virtual unsigned int offset706(int) {
4101             return offset = 706;
4102         }
4103 
4104         virtual unsigned int offset707(int) {
4105             return offset = 707;
4106         }
4107 
4108         virtual unsigned int offset708(int) {
4109             return offset = 708;
4110         }
4111 
4112         virtual unsigned int offset709(int) {
4113             return offset = 709;
4114         }
4115 
4116         virtual unsigned int offset710(int) {
4117             return offset = 710;
4118         }
4119 
4120         virtual unsigned int offset711(int) {
4121             return offset = 711;
4122         }
4123 
4124         virtual unsigned int offset712(int) {
4125             return offset = 712;
4126         }
4127 
4128         virtual unsigned int offset713(int) {
4129             return offset = 713;
4130         }
4131 
4132         virtual unsigned int offset714(int) {
4133             return offset = 714;
4134         }
4135 
4136         virtual unsigned int offset715(int) {
4137             return offset = 715;
4138         }
4139 
4140         virtual unsigned int offset716(int) {
4141             return offset = 716;
4142         }
4143 
4144         virtual unsigned int offset717(int) {
4145             return offset = 717;
4146         }
4147 
4148         virtual unsigned int offset718(int) {
4149             return offset = 718;
4150         }
4151 
4152         virtual unsigned int offset719(int) {
4153             return offset = 719;
4154         }
4155 
4156         virtual unsigned int offset720(int) {
4157             return offset = 720;
4158         }
4159 
4160         virtual unsigned int offset721(int) {
4161             return offset = 721;
4162         }
4163 
4164         virtual unsigned int offset722(int) {
4165             return offset = 722;
4166         }
4167 
4168         virtual unsigned int offset723(int) {
4169             return offset = 723;
4170         }
4171 
4172         virtual unsigned int offset724(int) {
4173             return offset = 724;
4174         }
4175 
4176         virtual unsigned int offset725(int) {
4177             return offset = 725;
4178         }
4179 
4180         virtual unsigned int offset726(int) {
4181             return offset = 726;
4182         }
4183 
4184         virtual unsigned int offset727(int) {
4185             return offset = 727;
4186         }
4187 
4188         virtual unsigned int offset728(int) {
4189             return offset = 728;
4190         }
4191 
4192         virtual unsigned int offset729(int) {
4193             return offset = 729;
4194         }
4195 
4196         virtual unsigned int offset730(int) {
4197             return offset = 730;
4198         }
4199 
4200         virtual unsigned int offset731(int) {
4201             return offset = 731;
4202         }
4203 
4204         virtual unsigned int offset732(int) {
4205             return offset = 732;
4206         }
4207 
4208         virtual unsigned int offset733(int) {
4209             return offset = 733;
4210         }
4211 
4212         virtual unsigned int offset734(int) {
4213             return offset = 734;
4214         }
4215 
4216         virtual unsigned int offset735(int) {
4217             return offset = 735;
4218         }
4219 
4220         virtual unsigned int offset736(int) {
4221             return offset = 736;
4222         }
4223 
4224         virtual unsigned int offset737(int) {
4225             return offset = 737;
4226         }
4227 
4228         virtual unsigned int offset738(int) {
4229             return offset = 738;
4230         }
4231 
4232         virtual unsigned int offset739(int) {
4233             return offset = 739;
4234         }
4235 
4236         virtual unsigned int offset740(int) {
4237             return offset = 740;
4238         }
4239 
4240         virtual unsigned int offset741(int) {
4241             return offset = 741;
4242         }
4243 
4244         virtual unsigned int offset742(int) {
4245             return offset = 742;
4246         }
4247 
4248         virtual unsigned int offset743(int) {
4249             return offset = 743;
4250         }
4251 
4252         virtual unsigned int offset744(int) {
4253             return offset = 744;
4254         }
4255 
4256         virtual unsigned int offset745(int) {
4257             return offset = 745;
4258         }
4259 
4260         virtual unsigned int offset746(int) {
4261             return offset = 746;
4262         }
4263 
4264         virtual unsigned int offset747(int) {
4265             return offset = 747;
4266         }
4267 
4268         virtual unsigned int offset748(int) {
4269             return offset = 748;
4270         }
4271 
4272         virtual unsigned int offset749(int) {
4273             return offset = 749;
4274         }
4275 
4276         virtual unsigned int offset750(int) {
4277             return offset = 750;
4278         }
4279 
4280         virtual unsigned int offset751(int) {
4281             return offset = 751;
4282         }
4283 
4284         virtual unsigned int offset752(int) {
4285             return offset = 752;
4286         }
4287 
4288         virtual unsigned int offset753(int) {
4289             return offset = 753;
4290         }
4291 
4292         virtual unsigned int offset754(int) {
4293             return offset = 754;
4294         }
4295 
4296         virtual unsigned int offset755(int) {
4297             return offset = 755;
4298         }
4299 
4300         virtual unsigned int offset756(int) {
4301             return offset = 756;
4302         }
4303 
4304         virtual unsigned int offset757(int) {
4305             return offset = 757;
4306         }
4307 
4308         virtual unsigned int offset758(int) {
4309             return offset = 758;
4310         }
4311 
4312         virtual unsigned int offset759(int) {
4313             return offset = 759;
4314         }
4315 
4316         virtual unsigned int offset760(int) {
4317             return offset = 760;
4318         }
4319 
4320         virtual unsigned int offset761(int) {
4321             return offset = 761;
4322         }
4323 
4324         virtual unsigned int offset762(int) {
4325             return offset = 762;
4326         }
4327 
4328         virtual unsigned int offset763(int) {
4329             return offset = 763;
4330         }
4331 
4332         virtual unsigned int offset764(int) {
4333             return offset = 764;
4334         }
4335 
4336         virtual unsigned int offset765(int) {
4337             return offset = 765;
4338         }
4339 
4340         virtual unsigned int offset766(int) {
4341             return offset = 766;
4342         }
4343 
4344         virtual unsigned int offset767(int) {
4345             return offset = 767;
4346         }
4347 
4348         virtual unsigned int offset768(int) {
4349             return offset = 768;
4350         }
4351 
4352         virtual unsigned int offset769(int) {
4353             return offset = 769;
4354         }
4355 
4356         virtual unsigned int offset770(int) {
4357             return offset = 770;
4358         }
4359 
4360         virtual unsigned int offset771(int) {
4361             return offset = 771;
4362         }
4363 
4364         virtual unsigned int offset772(int) {
4365             return offset = 772;
4366         }
4367 
4368         virtual unsigned int offset773(int) {
4369             return offset = 773;
4370         }
4371 
4372         virtual unsigned int offset774(int) {
4373             return offset = 774;
4374         }
4375 
4376         virtual unsigned int offset775(int) {
4377             return offset = 775;
4378         }
4379 
4380         virtual unsigned int offset776(int) {
4381             return offset = 776;
4382         }
4383 
4384         virtual unsigned int offset777(int) {
4385             return offset = 777;
4386         }
4387 
4388         virtual unsigned int offset778(int) {
4389             return offset = 778;
4390         }
4391 
4392         virtual unsigned int offset779(int) {
4393             return offset = 779;
4394         }
4395 
4396         virtual unsigned int offset780(int) {
4397             return offset = 780;
4398         }
4399 
4400         virtual unsigned int offset781(int) {
4401             return offset = 781;
4402         }
4403 
4404         virtual unsigned int offset782(int) {
4405             return offset = 782;
4406         }
4407 
4408         virtual unsigned int offset783(int) {
4409             return offset = 783;
4410         }
4411 
4412         virtual unsigned int offset784(int) {
4413             return offset = 784;
4414         }
4415 
4416         virtual unsigned int offset785(int) {
4417             return offset = 785;
4418         }
4419 
4420         virtual unsigned int offset786(int) {
4421             return offset = 786;
4422         }
4423 
4424         virtual unsigned int offset787(int) {
4425             return offset = 787;
4426         }
4427 
4428         virtual unsigned int offset788(int) {
4429             return offset = 788;
4430         }
4431 
4432         virtual unsigned int offset789(int) {
4433             return offset = 789;
4434         }
4435 
4436         virtual unsigned int offset790(int) {
4437             return offset = 790;
4438         }
4439 
4440         virtual unsigned int offset791(int) {
4441             return offset = 791;
4442         }
4443 
4444         virtual unsigned int offset792(int) {
4445             return offset = 792;
4446         }
4447 
4448         virtual unsigned int offset793(int) {
4449             return offset = 793;
4450         }
4451 
4452         virtual unsigned int offset794(int) {
4453             return offset = 794;
4454         }
4455 
4456         virtual unsigned int offset795(int) {
4457             return offset = 795;
4458         }
4459 
4460         virtual unsigned int offset796(int) {
4461             return offset = 796;
4462         }
4463 
4464         virtual unsigned int offset797(int) {
4465             return offset = 797;
4466         }
4467 
4468         virtual unsigned int offset798(int) {
4469             return offset = 798;
4470         }
4471 
4472         virtual unsigned int offset799(int) {
4473             return offset = 799;
4474         }
4475 
4476 
4477         virtual unsigned int offset800(int) {
4478             return offset = 800;
4479         }
4480 
4481         virtual unsigned int offset801(int) {
4482             return offset = 801;
4483         }
4484 
4485         virtual unsigned int offset802(int) {
4486             return offset = 802;
4487         }
4488 
4489         virtual unsigned int offset803(int) {
4490             return offset = 803;
4491         }
4492 
4493         virtual unsigned int offset804(int) {
4494             return offset = 804;
4495         }
4496 
4497         virtual unsigned int offset805(int) {
4498             return offset = 805;
4499         }
4500 
4501         virtual unsigned int offset806(int) {
4502             return offset = 806;
4503         }
4504 
4505         virtual unsigned int offset807(int) {
4506             return offset = 807;
4507         }
4508 
4509         virtual unsigned int offset808(int) {
4510             return offset = 808;
4511         }
4512 
4513         virtual unsigned int offset809(int) {
4514             return offset = 809;
4515         }
4516 
4517         virtual unsigned int offset810(int) {
4518             return offset = 810;
4519         }
4520 
4521         virtual unsigned int offset811(int) {
4522             return offset = 811;
4523         }
4524 
4525         virtual unsigned int offset812(int) {
4526             return offset = 812;
4527         }
4528 
4529         virtual unsigned int offset813(int) {
4530             return offset = 813;
4531         }
4532 
4533         virtual unsigned int offset814(int) {
4534             return offset = 814;
4535         }
4536 
4537         virtual unsigned int offset815(int) {
4538             return offset = 815;
4539         }
4540 
4541         virtual unsigned int offset816(int) {
4542             return offset = 816;
4543         }
4544 
4545         virtual unsigned int offset817(int) {
4546             return offset = 817;
4547         }
4548 
4549         virtual unsigned int offset818(int) {
4550             return offset = 818;
4551         }
4552 
4553         virtual unsigned int offset819(int) {
4554             return offset = 819;
4555         }
4556 
4557         virtual unsigned int offset820(int) {
4558             return offset = 820;
4559         }
4560 
4561         virtual unsigned int offset821(int) {
4562             return offset = 821;
4563         }
4564 
4565         virtual unsigned int offset822(int) {
4566             return offset = 822;
4567         }
4568 
4569         virtual unsigned int offset823(int) {
4570             return offset = 823;
4571         }
4572 
4573         virtual unsigned int offset824(int) {
4574             return offset = 824;
4575         }
4576 
4577         virtual unsigned int offset825(int) {
4578             return offset = 825;
4579         }
4580 
4581         virtual unsigned int offset826(int) {
4582             return offset = 826;
4583         }
4584 
4585         virtual unsigned int offset827(int) {
4586             return offset = 827;
4587         }
4588 
4589         virtual unsigned int offset828(int) {
4590             return offset = 828;
4591         }
4592 
4593         virtual unsigned int offset829(int) {
4594             return offset = 829;
4595         }
4596 
4597         virtual unsigned int offset830(int) {
4598             return offset = 830;
4599         }
4600 
4601         virtual unsigned int offset831(int) {
4602             return offset = 831;
4603         }
4604 
4605         virtual unsigned int offset832(int) {
4606             return offset = 832;
4607         }
4608 
4609         virtual unsigned int offset833(int) {
4610             return offset = 833;
4611         }
4612 
4613         virtual unsigned int offset834(int) {
4614             return offset = 834;
4615         }
4616 
4617         virtual unsigned int offset835(int) {
4618             return offset = 835;
4619         }
4620 
4621         virtual unsigned int offset836(int) {
4622             return offset = 836;
4623         }
4624 
4625         virtual unsigned int offset837(int) {
4626             return offset = 837;
4627         }
4628 
4629         virtual unsigned int offset838(int) {
4630             return offset = 838;
4631         }
4632 
4633         virtual unsigned int offset839(int) {
4634             return offset = 839;
4635         }
4636 
4637         virtual unsigned int offset840(int) {
4638             return offset = 840;
4639         }
4640 
4641         virtual unsigned int offset841(int) {
4642             return offset = 841;
4643         }
4644 
4645         virtual unsigned int offset842(int) {
4646             return offset = 842;
4647         }
4648 
4649         virtual unsigned int offset843(int) {
4650             return offset = 843;
4651         }
4652 
4653         virtual unsigned int offset844(int) {
4654             return offset = 844;
4655         }
4656 
4657         virtual unsigned int offset845(int) {
4658             return offset = 845;
4659         }
4660 
4661         virtual unsigned int offset846(int) {
4662             return offset = 846;
4663         }
4664 
4665         virtual unsigned int offset847(int) {
4666             return offset = 847;
4667         }
4668 
4669         virtual unsigned int offset848(int) {
4670             return offset = 848;
4671         }
4672 
4673         virtual unsigned int offset849(int) {
4674             return offset = 849;
4675         }
4676 
4677         virtual unsigned int offset850(int) {
4678             return offset = 850;
4679         }
4680 
4681         virtual unsigned int offset851(int) {
4682             return offset = 851;
4683         }
4684 
4685         virtual unsigned int offset852(int) {
4686             return offset = 852;
4687         }
4688 
4689         virtual unsigned int offset853(int) {
4690             return offset = 853;
4691         }
4692 
4693         virtual unsigned int offset854(int) {
4694             return offset = 854;
4695         }
4696 
4697         virtual unsigned int offset855(int) {
4698             return offset = 855;
4699         }
4700 
4701         virtual unsigned int offset856(int) {
4702             return offset = 856;
4703         }
4704 
4705         virtual unsigned int offset857(int) {
4706             return offset = 857;
4707         }
4708 
4709         virtual unsigned int offset858(int) {
4710             return offset = 858;
4711         }
4712 
4713         virtual unsigned int offset859(int) {
4714             return offset = 859;
4715         }
4716 
4717         virtual unsigned int offset860(int) {
4718             return offset = 860;
4719         }
4720 
4721         virtual unsigned int offset861(int) {
4722             return offset = 861;
4723         }
4724 
4725         virtual unsigned int offset862(int) {
4726             return offset = 862;
4727         }
4728 
4729         virtual unsigned int offset863(int) {
4730             return offset = 863;
4731         }
4732 
4733         virtual unsigned int offset864(int) {
4734             return offset = 864;
4735         }
4736 
4737         virtual unsigned int offset865(int) {
4738             return offset = 865;
4739         }
4740 
4741         virtual unsigned int offset866(int) {
4742             return offset = 866;
4743         }
4744 
4745         virtual unsigned int offset867(int) {
4746             return offset = 867;
4747         }
4748 
4749         virtual unsigned int offset868(int) {
4750             return offset = 868;
4751         }
4752 
4753         virtual unsigned int offset869(int) {
4754             return offset = 869;
4755         }
4756 
4757         virtual unsigned int offset870(int) {
4758             return offset = 870;
4759         }
4760 
4761         virtual unsigned int offset871(int) {
4762             return offset = 871;
4763         }
4764 
4765         virtual unsigned int offset872(int) {
4766             return offset = 872;
4767         }
4768 
4769         virtual unsigned int offset873(int) {
4770             return offset = 873;
4771         }
4772 
4773         virtual unsigned int offset874(int) {
4774             return offset = 874;
4775         }
4776 
4777         virtual unsigned int offset875(int) {
4778             return offset = 875;
4779         }
4780 
4781         virtual unsigned int offset876(int) {
4782             return offset = 876;
4783         }
4784 
4785         virtual unsigned int offset877(int) {
4786             return offset = 877;
4787         }
4788 
4789         virtual unsigned int offset878(int) {
4790             return offset = 878;
4791         }
4792 
4793         virtual unsigned int offset879(int) {
4794             return offset = 879;
4795         }
4796 
4797         virtual unsigned int offset880(int) {
4798             return offset = 880;
4799         }
4800 
4801         virtual unsigned int offset881(int) {
4802             return offset = 881;
4803         }
4804 
4805         virtual unsigned int offset882(int) {
4806             return offset = 882;
4807         }
4808 
4809         virtual unsigned int offset883(int) {
4810             return offset = 883;
4811         }
4812 
4813         virtual unsigned int offset884(int) {
4814             return offset = 884;
4815         }
4816 
4817         virtual unsigned int offset885(int) {
4818             return offset = 885;
4819         }
4820 
4821         virtual unsigned int offset886(int) {
4822             return offset = 886;
4823         }
4824 
4825         virtual unsigned int offset887(int) {
4826             return offset = 887;
4827         }
4828 
4829         virtual unsigned int offset888(int) {
4830             return offset = 888;
4831         }
4832 
4833         virtual unsigned int offset889(int) {
4834             return offset = 889;
4835         }
4836 
4837         virtual unsigned int offset890(int) {
4838             return offset = 890;
4839         }
4840 
4841         virtual unsigned int offset891(int) {
4842             return offset = 891;
4843         }
4844 
4845         virtual unsigned int offset892(int) {
4846             return offset = 892;
4847         }
4848 
4849         virtual unsigned int offset893(int) {
4850             return offset = 893;
4851         }
4852 
4853         virtual unsigned int offset894(int) {
4854             return offset = 894;
4855         }
4856 
4857         virtual unsigned int offset895(int) {
4858             return offset = 895;
4859         }
4860 
4861         virtual unsigned int offset896(int) {
4862             return offset = 896;
4863         }
4864 
4865         virtual unsigned int offset897(int) {
4866             return offset = 897;
4867         }
4868 
4869         virtual unsigned int offset898(int) {
4870             return offset = 898;
4871         }
4872 
4873         virtual unsigned int offset899(int) {
4874             return offset = 899;
4875         }
4876 
4877 
4878         virtual unsigned int offset900(int) {
4879             return offset = 900;
4880         }
4881 
4882         virtual unsigned int offset901(int) {
4883             return offset = 901;
4884         }
4885 
4886         virtual unsigned int offset902(int) {
4887             return offset = 902;
4888         }
4889 
4890         virtual unsigned int offset903(int) {
4891             return offset = 903;
4892         }
4893 
4894         virtual unsigned int offset904(int) {
4895             return offset = 904;
4896         }
4897 
4898         virtual unsigned int offset905(int) {
4899             return offset = 905;
4900         }
4901 
4902         virtual unsigned int offset906(int) {
4903             return offset = 906;
4904         }
4905 
4906         virtual unsigned int offset907(int) {
4907             return offset = 907;
4908         }
4909 
4910         virtual unsigned int offset908(int) {
4911             return offset = 908;
4912         }
4913 
4914         virtual unsigned int offset909(int) {
4915             return offset = 909;
4916         }
4917 
4918         virtual unsigned int offset910(int) {
4919             return offset = 910;
4920         }
4921 
4922         virtual unsigned int offset911(int) {
4923             return offset = 911;
4924         }
4925 
4926         virtual unsigned int offset912(int) {
4927             return offset = 912;
4928         }
4929 
4930         virtual unsigned int offset913(int) {
4931             return offset = 913;
4932         }
4933 
4934         virtual unsigned int offset914(int) {
4935             return offset = 914;
4936         }
4937 
4938         virtual unsigned int offset915(int) {
4939             return offset = 915;
4940         }
4941 
4942         virtual unsigned int offset916(int) {
4943             return offset = 916;
4944         }
4945 
4946         virtual unsigned int offset917(int) {
4947             return offset = 917;
4948         }
4949 
4950         virtual unsigned int offset918(int) {
4951             return offset = 918;
4952         }
4953 
4954         virtual unsigned int offset919(int) {
4955             return offset = 919;
4956         }
4957 
4958         virtual unsigned int offset920(int) {
4959             return offset = 920;
4960         }
4961 
4962         virtual unsigned int offset921(int) {
4963             return offset = 921;
4964         }
4965 
4966         virtual unsigned int offset922(int) {
4967             return offset = 922;
4968         }
4969 
4970         virtual unsigned int offset923(int) {
4971             return offset = 923;
4972         }
4973 
4974         virtual unsigned int offset924(int) {
4975             return offset = 924;
4976         }
4977 
4978         virtual unsigned int offset925(int) {
4979             return offset = 925;
4980         }
4981 
4982         virtual unsigned int offset926(int) {
4983             return offset = 926;
4984         }
4985 
4986         virtual unsigned int offset927(int) {
4987             return offset = 927;
4988         }
4989 
4990         virtual unsigned int offset928(int) {
4991             return offset = 928;
4992         }
4993 
4994         virtual unsigned int offset929(int) {
4995             return offset = 929;
4996         }
4997 
4998         virtual unsigned int offset930(int) {
4999             return offset = 930;
5000         }
5001 
5002         virtual unsigned int offset931(int) {
5003             return offset = 931;
5004         }
5005 
5006         virtual unsigned int offset932(int) {
5007             return offset = 932;
5008         }
5009 
5010         virtual unsigned int offset933(int) {
5011             return offset = 933;
5012         }
5013 
5014         virtual unsigned int offset934(int) {
5015             return offset = 934;
5016         }
5017 
5018         virtual unsigned int offset935(int) {
5019             return offset = 935;
5020         }
5021 
5022         virtual unsigned int offset936(int) {
5023             return offset = 936;
5024         }
5025 
5026         virtual unsigned int offset937(int) {
5027             return offset = 937;
5028         }
5029 
5030         virtual unsigned int offset938(int) {
5031             return offset = 938;
5032         }
5033 
5034         virtual unsigned int offset939(int) {
5035             return offset = 939;
5036         }
5037 
5038         virtual unsigned int offset940(int) {
5039             return offset = 940;
5040         }
5041 
5042         virtual unsigned int offset941(int) {
5043             return offset = 941;
5044         }
5045 
5046         virtual unsigned int offset942(int) {
5047             return offset = 942;
5048         }
5049 
5050         virtual unsigned int offset943(int) {
5051             return offset = 943;
5052         }
5053 
5054         virtual unsigned int offset944(int) {
5055             return offset = 944;
5056         }
5057 
5058         virtual unsigned int offset945(int) {
5059             return offset = 945;
5060         }
5061 
5062         virtual unsigned int offset946(int) {
5063             return offset = 946;
5064         }
5065 
5066         virtual unsigned int offset947(int) {
5067             return offset = 947;
5068         }
5069 
5070         virtual unsigned int offset948(int) {
5071             return offset = 948;
5072         }
5073 
5074         virtual unsigned int offset949(int) {
5075             return offset = 949;
5076         }
5077 
5078         virtual unsigned int offset950(int) {
5079             return offset = 950;
5080         }
5081 
5082         virtual unsigned int offset951(int) {
5083             return offset = 951;
5084         }
5085 
5086         virtual unsigned int offset952(int) {
5087             return offset = 952;
5088         }
5089 
5090         virtual unsigned int offset953(int) {
5091             return offset = 953;
5092         }
5093 
5094         virtual unsigned int offset954(int) {
5095             return offset = 954;
5096         }
5097 
5098         virtual unsigned int offset955(int) {
5099             return offset = 955;
5100         }
5101 
5102         virtual unsigned int offset956(int) {
5103             return offset = 956;
5104         }
5105 
5106         virtual unsigned int offset957(int) {
5107             return offset = 957;
5108         }
5109 
5110         virtual unsigned int offset958(int) {
5111             return offset = 958;
5112         }
5113 
5114         virtual unsigned int offset959(int) {
5115             return offset = 959;
5116         }
5117 
5118         virtual unsigned int offset960(int) {
5119             return offset = 960;
5120         }
5121 
5122         virtual unsigned int offset961(int) {
5123             return offset = 961;
5124         }
5125 
5126         virtual unsigned int offset962(int) {
5127             return offset = 962;
5128         }
5129 
5130         virtual unsigned int offset963(int) {
5131             return offset = 963;
5132         }
5133 
5134         virtual unsigned int offset964(int) {
5135             return offset = 964;
5136         }
5137 
5138         virtual unsigned int offset965(int) {
5139             return offset = 965;
5140         }
5141 
5142         virtual unsigned int offset966(int) {
5143             return offset = 966;
5144         }
5145 
5146         virtual unsigned int offset967(int) {
5147             return offset = 967;
5148         }
5149 
5150         virtual unsigned int offset968(int) {
5151             return offset = 968;
5152         }
5153 
5154         virtual unsigned int offset969(int) {
5155             return offset = 969;
5156         }
5157 
5158         virtual unsigned int offset970(int) {
5159             return offset = 970;
5160         }
5161 
5162         virtual unsigned int offset971(int) {
5163             return offset = 971;
5164         }
5165 
5166         virtual unsigned int offset972(int) {
5167             return offset = 972;
5168         }
5169 
5170         virtual unsigned int offset973(int) {
5171             return offset = 973;
5172         }
5173 
5174         virtual unsigned int offset974(int) {
5175             return offset = 974;
5176         }
5177 
5178         virtual unsigned int offset975(int) {
5179             return offset = 975;
5180         }
5181 
5182         virtual unsigned int offset976(int) {
5183             return offset = 976;
5184         }
5185 
5186         virtual unsigned int offset977(int) {
5187             return offset = 977;
5188         }
5189 
5190         virtual unsigned int offset978(int) {
5191             return offset = 978;
5192         }
5193 
5194         virtual unsigned int offset979(int) {
5195             return offset = 979;
5196         }
5197 
5198         virtual unsigned int offset980(int) {
5199             return offset = 980;
5200         }
5201 
5202         virtual unsigned int offset981(int) {
5203             return offset = 981;
5204         }
5205 
5206         virtual unsigned int offset982(int) {
5207             return offset = 982;
5208         }
5209 
5210         virtual unsigned int offset983(int) {
5211             return offset = 983;
5212         }
5213 
5214         virtual unsigned int offset984(int) {
5215             return offset = 984;
5216         }
5217 
5218         virtual unsigned int offset985(int) {
5219             return offset = 985;
5220         }
5221 
5222         virtual unsigned int offset986(int) {
5223             return offset = 986;
5224         }
5225 
5226         virtual unsigned int offset987(int) {
5227             return offset = 987;
5228         }
5229 
5230         virtual unsigned int offset988(int) {
5231             return offset = 988;
5232         }
5233 
5234         virtual unsigned int offset989(int) {
5235             return offset = 989;
5236         }
5237 
5238         virtual unsigned int offset990(int) {
5239             return offset = 990;
5240         }
5241 
5242         virtual unsigned int offset991(int) {
5243             return offset = 991;
5244         }
5245 
5246         virtual unsigned int offset992(int) {
5247             return offset = 992;
5248         }
5249 
5250         virtual unsigned int offset993(int) {
5251             return offset = 993;
5252         }
5253 
5254         virtual unsigned int offset994(int) {
5255             return offset = 994;
5256         }
5257 
5258         virtual unsigned int offset995(int) {
5259             return offset = 995;
5260         }
5261 
5262         virtual unsigned int offset996(int) {
5263             return offset = 996;
5264         }
5265 
5266         virtual unsigned int offset997(int) {
5267             return offset = 997;
5268         }
5269 
5270         virtual unsigned int offset998(int) {
5271             return offset = 998;
5272         }
5273 
5274         virtual unsigned int offset999(int) {
5275             return offset = 999;
5276         }
5277 
5278         virtual unsigned int offset1000(int) {
5279             return offset = 1000;
5280         }
5281 
5282     };
5283 }
5284 namespace fakeit {
5285 
5286     template<typename TARGET, typename SOURCE>
5287     TARGET union_cast(SOURCE source) {
5288 
5289         union {
5290             SOURCE source;
5291             TARGET target;
5292         } u;
5293         u.source = source;
5294         return u.target;
5295     }
5296 
5297 }
5298 
5299 namespace fakeit {
5300     class NoVirtualDtor : public std::runtime_error {
5301     public:
5302         NoVirtualDtor() :std::runtime_error("Can't mock the destructor. No virtual destructor was found") {}
5303     };
5304 
5305     class VTUtils {
5306     public:
5307 
5308         template<typename C, typename R, typename ... arglist>
5309         static unsigned int getOffset(R (C::*vMethod)(arglist...)) {
5310             auto sMethod = reinterpret_cast<unsigned int (VirtualOffsetSelector::*)(int)>(vMethod);
5311             VirtualOffsetSelector offsetSelctor;
5312             return (offsetSelctor.*sMethod)(0);
5313         }
5314 
5315         template<typename C>
5316         static typename std::enable_if<std::has_virtual_destructor<C>::value, unsigned int>::type
5317         getDestructorOffset() {
5318             VirtualOffsetSelector offsetSelctor;
5319             union_cast<C *>(&offsetSelctor)->~C();
5320             return offsetSelctor.offset;
5321         }
5322 
5323         template<typename C>
5324         static typename std::enable_if<!std::has_virtual_destructor<C>::value, unsigned int>::type
5325         getDestructorOffset() {
5326             throw NoVirtualDtor();
5327         }
5328 
5329         template<typename C>
5330         static typename std::enable_if<std::has_virtual_destructor<C>::value, bool>::type
5331             hasVirtualDestructor() {
5332             return true;
5333         }
5334 
5335         template<typename C>
5336         static typename std::enable_if<!std::has_virtual_destructor<C>::value, bool>::type
5337             hasVirtualDestructor() {
5338             return false;
5339         }
5340 
5341         template<typename C>
5342         static unsigned int getVTSize() {
5343             struct Derived : public C {
5344                 virtual void endOfVt() {
5345                 }
5346             };
5347 
5348             unsigned int vtSize = getOffset(&Derived::endOfVt);
5349             return vtSize;
5350         }
5351     };
5352 
5353 
5354 }
5355 #ifdef _MSC_VER
5356 namespace fakeit {
5357 
5358     typedef unsigned long dword_;
5359 
5360     struct TypeDescriptor {
5361         TypeDescriptor() :
5362                 ptrToVTable(0), spare(0) {
5363 
5364             int **tiVFTPtr = (int **) (&typeid(void));
5365             int *i = (int *) tiVFTPtr[0];
5366             char *type_info_vft_ptr = (char *) i;
5367             ptrToVTable = type_info_vft_ptr;
5368         }
5369 
5370         char *ptrToVTable;
5371         dword_ spare;
5372         char name[8];
5373     };
5374 
5375     struct PMD {
5376 
5377 
5378 
5379         int mdisp;
5380 
5381         int pdisp;
5382         int vdisp;
5383 
5384         PMD() :
5385                 mdisp(0), pdisp(-1), vdisp(0) {
5386         }
5387     };
5388 
5389     struct RTTIBaseClassDescriptor {
5390         RTTIBaseClassDescriptor() :
5391                 pTypeDescriptor(nullptr), numContainedBases(0), attributes(0) {
5392         }
5393 
5394         const std::type_info *pTypeDescriptor;
5395         dword_ numContainedBases;
5396         struct PMD where;
5397         dword_ attributes;
5398     };
5399 
5400     template<typename C, typename... baseclasses>
5401     struct RTTIClassHierarchyDescriptor {
5402         RTTIClassHierarchyDescriptor() :
5403                 signature(0),
5404                 attributes(0),
5405                 numBaseClasses(0),
5406                 pBaseClassArray(nullptr) {
5407             pBaseClassArray = new RTTIBaseClassDescriptor *[1 + sizeof...(baseclasses)];
5408             addBaseClass < C, baseclasses...>();
5409         }
5410 
5411         ~RTTIClassHierarchyDescriptor() {
5412             for (int i = 0; i < 1 + sizeof...(baseclasses); i++) {
5413                 RTTIBaseClassDescriptor *desc = pBaseClassArray[i];
5414                 delete desc;
5415             }
5416             delete[] pBaseClassArray;
5417         }
5418 
5419         dword_ signature;
5420         dword_ attributes;
5421         dword_ numBaseClasses;
5422         RTTIBaseClassDescriptor **pBaseClassArray;
5423 
5424         template<typename BaseType>
5425         void addBaseClass() {
5426             static_assert(std::is_base_of<BaseType, C>::value, "C must be a derived class of BaseType");
5427             RTTIBaseClassDescriptor *desc = new RTTIBaseClassDescriptor();
5428             desc->pTypeDescriptor = &typeid(BaseType);
5429             pBaseClassArray[numBaseClasses] = desc;
5430             for (unsigned int i = 0; i < numBaseClasses; i++) {
5431                 pBaseClassArray[i]->numContainedBases++;
5432             }
5433             numBaseClasses++;
5434         }
5435 
5436         template<typename head, typename B1, typename... tail>
5437         void addBaseClass() {
5438             static_assert(std::is_base_of<B1, head>::value, "invalid inheritance list");
5439             addBaseClass<head>();
5440             addBaseClass<B1, tail...>();
5441         }
5442 
5443     };
5444 
5445     template<typename C, typename... baseclasses>
5446     struct RTTICompleteObjectLocator {
5447 #ifdef _WIN64
5448         RTTICompleteObjectLocator(const std::type_info &unused) :
5449             signature(0), offset(0), cdOffset(0),
5450             typeDescriptorOffset(0), classDescriptorOffset(0)
5451         {
5452         }
5453 
5454         dword_ signature;
5455         dword_ offset;
5456         dword_ cdOffset;
5457         dword_ typeDescriptorOffset;
5458         dword_ classDescriptorOffset;
5459 #else
5460         RTTICompleteObjectLocator(const std::type_info &info) :
5461             signature(0), offset(0), cdOffset(0),
5462             pTypeDescriptor(&info),
5463             pClassDescriptor(new RTTIClassHierarchyDescriptor<C, baseclasses...>()) {
5464         }
5465 
5466         ~RTTICompleteObjectLocator() {
5467             delete pClassDescriptor;
5468         }
5469 
5470         dword_ signature;
5471         dword_ offset;
5472         dword_ cdOffset;
5473         const std::type_info *pTypeDescriptor;
5474         struct RTTIClassHierarchyDescriptor<C, baseclasses...> *pClassDescriptor;
5475 #endif
5476     };
5477 
5478 
5479     struct VirtualTableBase {
5480 
5481         static VirtualTableBase &getVTable(void *instance) {
5482             fakeit::VirtualTableBase *vt = (fakeit::VirtualTableBase *) (instance);
5483             return *vt;
5484         }
5485 
5486         VirtualTableBase(void **firstMethod) : _firstMethod(firstMethod) { }
5487 
5488         void *getCookie(int index) {
5489             return _firstMethod[-2 - index];
5490         }
5491 
5492         void setCookie(int index, void *value) {
5493             _firstMethod[-2 - index] = value;
5494         }
5495 
5496         void *getMethod(unsigned int index) const {
5497             return _firstMethod[index];
5498         }
5499 
5500         void setMethod(unsigned int index, void *method) {
5501             _firstMethod[index] = method;
5502         }
5503 
5504     protected:
5505         void **_firstMethod;
5506     };
5507 
5508     template<class C, class... baseclasses>
5509     struct VirtualTable : public VirtualTableBase {
5510 
5511         class Handle {
5512 
5513             friend struct VirtualTable<C, baseclasses...>;
5514 
5515             void **firstMethod;
5516 
5517             Handle(void **method) : firstMethod(method) { }
5518 
5519         public:
5520 
5521             VirtualTable<C, baseclasses...> &restore() {
5522                 VirtualTable<C, baseclasses...> *vt = (VirtualTable<C, baseclasses...> *) this;
5523                 return *vt;
5524             }
5525         };
5526 
5527         static VirtualTable<C, baseclasses...> &getVTable(C &instance) {
5528             fakeit::VirtualTable<C, baseclasses...> *vt = (fakeit::VirtualTable<C, baseclasses...> *) (&instance);
5529             return *vt;
5530         }
5531 
5532         void copyFrom(VirtualTable<C, baseclasses...> &from) {
5533             unsigned int size = VTUtils::getVTSize<C>();
5534             for (unsigned int i = 0; i < size; i++) {
5535                 _firstMethod[i] = from.getMethod(i);
5536             }
5537         }
5538 
5539         VirtualTable() : VirtualTable(buildVTArray()) {
5540         }
5541 
5542         ~VirtualTable() {
5543 
5544         }
5545 
5546         void dispose() {
5547             _firstMethod--;
5548             RTTICompleteObjectLocator<C, baseclasses...> *locator = (RTTICompleteObjectLocator<C, baseclasses...> *) _firstMethod[0];
5549             delete locator;
5550             _firstMethod -= numOfCookies;
5551             delete[] _firstMethod;
5552         }
5553 
5554 
5555         unsigned int dtor(int) {
5556             C *c = (C *) this;
5557             C &cRef = *c;
5558             auto vt = VirtualTable<C, baseclasses...>::getVTable(cRef);
5559             void *dtorPtr = vt.getCookie(numOfCookies - 1);
5560             void(*method)(C *) = reinterpret_cast<void (*)(C *)>(dtorPtr);
5561             method(c);
5562             return 0;
5563         }
5564 
5565         void setDtor(void *method) {
5566 
5567 
5568 
5569 
5570 
5571             void *dtorPtr = union_cast<void *>(&VirtualTable<C, baseclasses...>::dtor);
5572             unsigned int index = VTUtils::getDestructorOffset<C>();
5573             _firstMethod[index] = dtorPtr;
5574             setCookie(numOfCookies - 1, method);
5575         }
5576 
5577         unsigned int getSize() {
5578             return VTUtils::getVTSize<C>();
5579         }
5580 
5581         void initAll(void *value) {
5582             auto size = getSize();
5583             for (unsigned int i = 0; i < size; i++) {
5584                 setMethod(i, value);
5585             }
5586         }
5587 
5588         Handle createHandle() {
5589             Handle h(_firstMethod);
5590             return h;
5591         }
5592 
5593     private:
5594 
5595         class SimpleType {
5596         };
5597 
5598         static_assert(sizeof(unsigned int (SimpleType::*)()) == sizeof(unsigned int (C::*)()),
5599             "Can't mock a type with multiple inheritance or with non-polymorphic base class");
5600         static const unsigned int numOfCookies = 3;
5601 
5602         static void **buildVTArray() {
5603             int vtSize = VTUtils::getVTSize<C>();
5604             auto array = new void *[vtSize + numOfCookies + 1]{};
5605             RTTICompleteObjectLocator<C, baseclasses...> *objectLocator = new RTTICompleteObjectLocator<C, baseclasses...>(
5606                     typeid(C));
5607             array += numOfCookies;
5608             array[0] = objectLocator;
5609             array++;
5610             return array;
5611         }
5612 
5613         VirtualTable(void **firstMethod) : VirtualTableBase(firstMethod) {
5614         }
5615     };
5616 }
5617 #else
5618 #ifndef __clang__
5619 #include <type_traits>
5620 #include <tr2/type_traits>
5621 
5622 namespace fakeit {
5623     template<typename ... T1>
5624     class has_one_base {
5625     };
5626 
5627     template<typename T1, typename T2, typename ... types>
5628     class has_one_base<std::tr2::__reflection_typelist<T1, T2, types...>> : public std::false_type {
5629     };
5630 
5631     template<typename T1>
5632     class has_one_base<std::tr2::__reflection_typelist<T1>>
5633             : public has_one_base<typename std::tr2::direct_bases<T1>::type> {
5634     };
5635 
5636     template<>
5637     class has_one_base<std::tr2::__reflection_typelist<>> : public std::true_type {
5638     };
5639 
5640     template<typename T>
5641     class is_simple_inheritance_layout : public has_one_base<typename std::tr2::direct_bases<T>::type> {
5642     };
5643 }
5644 
5645 #endif
5646 
5647 namespace fakeit {
5648 
5649     struct VirtualTableBase {
5650 
5651         static VirtualTableBase &getVTable(void *instance) {
5652             fakeit::VirtualTableBase *vt = (fakeit::VirtualTableBase *) (instance);
5653             return *vt;
5654         }
5655 
5656         VirtualTableBase(void **firstMethod) : _firstMethod(firstMethod) { }
5657 
5658         void *getCookie(int index) {
5659             return _firstMethod[-3 - index];
5660         }
5661 
5662         void setCookie(int index, void *value) {
5663             _firstMethod[-3 - index] = value;
5664         }
5665 
5666         void *getMethod(unsigned int index) const {
5667             return _firstMethod[index];
5668         }
5669 
5670         void setMethod(unsigned int index, void *method) {
5671             _firstMethod[index] = method;
5672         }
5673 
5674     protected:
5675         void **_firstMethod;
5676     };
5677 
5678     template<class C, class ... baseclasses>
5679     struct VirtualTable : public VirtualTableBase {
5680 
5681 #ifndef __clang__
5682         static_assert(is_simple_inheritance_layout<C>::value, "Can't mock a type with multiple inheritance");
5683 #endif
5684 
5685         class Handle {
5686 
5687             friend struct VirtualTable<C, baseclasses...>;
5688             void **firstMethod;
5689 
5690             Handle(void **method) :
5691                     firstMethod(method) {
5692             }
5693 
5694         public:
5695 
5696             VirtualTable<C, baseclasses...> &restore() {
5697                 VirtualTable<C, baseclasses...> *vt = (VirtualTable<C, baseclasses...> *) this;
5698                 return *vt;
5699             }
5700         };
5701 
5702         static VirtualTable<C, baseclasses...> &getVTable(C &instance) {
5703             fakeit::VirtualTable<C, baseclasses...> *vt = (fakeit::VirtualTable<C, baseclasses...> *) (&instance);
5704             return *vt;
5705         }
5706 
5707         void copyFrom(VirtualTable<C, baseclasses...> &from) {
5708             unsigned int size = VTUtils::getVTSize<C>();
5709 
5710             for (size_t i = 0; i < size; ++i) {
5711                 _firstMethod[i] = from.getMethod(i);
5712             }
5713         }
5714 
5715         VirtualTable() :
5716                 VirtualTable(buildVTArray()) {
5717         }
5718 
5719         void dispose() {
5720             _firstMethod--;
5721             _firstMethod--;
5722             _firstMethod -= numOfCookies;
5723             delete[] _firstMethod;
5724         }
5725 
5726         unsigned int dtor(int) {
5727             C *c = (C *) this;
5728             C &cRef = *c;
5729             auto vt = VirtualTable<C, baseclasses...>::getVTable(cRef);
5730             unsigned int index = VTUtils::getDestructorOffset<C>();
5731             void *dtorPtr = vt.getMethod(index);
5732             void(*method)(C *) = union_cast<void (*)(C *)>(dtorPtr);
5733             method(c);
5734             return 0;
5735         }
5736 
5737 
5738         void setDtor(void *method) {
5739             unsigned int index = VTUtils::getDestructorOffset<C>();
5740             void *dtorPtr = union_cast<void *>(&VirtualTable<C, baseclasses...>::dtor);
5741 
5742 
5743             _firstMethod[index] = method;
5744 
5745             _firstMethod[index + 1] = dtorPtr;
5746         }
5747 
5748 
5749         unsigned int getSize() {
5750             return VTUtils::getVTSize<C>();
5751         }
5752 
5753         void initAll(void *value) {
5754             unsigned int size = getSize();
5755             for (unsigned int i = 0; i < size; i++) {
5756                 setMethod(i, value);
5757             }
5758         }
5759 
5760         const std::type_info *getTypeId() {
5761             return (const std::type_info *) (_firstMethod[-1]);
5762         }
5763 
5764         Handle createHandle() {
5765             Handle h(_firstMethod);
5766             return h;
5767         }
5768 
5769     private:
5770         static const unsigned int numOfCookies = 2;
5771 
5772         static void **buildVTArray() {
5773             int size = VTUtils::getVTSize<C>();
5774             auto array = new void *[size + 2 + numOfCookies]{};
5775             array += numOfCookies;
5776             array++;
5777             array[0] = const_cast<std::type_info *>(&typeid(C));
5778             array++;
5779             return array;
5780         }
5781 
5782         VirtualTable(void **firstMethod) : VirtualTableBase(firstMethod) {
5783         }
5784 
5785     };
5786 }
5787 #endif
5788 namespace fakeit {
5789 
5790     struct NoMoreRecordedActionException {
5791     };
5792 
5793     template<typename R, typename ... arglist>
5794     struct MethodInvocationHandler : Destructible {
5795         virtual R handleMethodInvocation(const typename fakeit::production_arg<arglist>::type... args) = 0;
5796     };
5797 
5798 }
5799 #include <new>
5800 
5801 namespace fakeit {
5802 
5803 #ifdef __GNUG__
5804 #ifndef __clang__
5805 #pragma GCC diagnostic ignored "-Wpedantic"
5806 #endif
5807 #endif
5808 
5809 
5810 #ifdef _MSC_VER
5811 #pragma warning( push )
5812 #pragma warning( disable : 4200 )
5813 #endif
5814 
5815 
5816     template<typename C, typename ... baseclasses>
5817     class FakeObject {
5818 
5819         VirtualTable<C, baseclasses...> vtable;
5820 
5821         static const size_t SIZE = sizeof(C) - sizeof(VirtualTable<C, baseclasses...>);
5822         char instanceArea[SIZE ? SIZE : 0];
5823 
5824         FakeObject(FakeObject const &) = delete;
5825         FakeObject &operator=(FakeObject const &) = delete;
5826 
5827     public:
5828 
5829         FakeObject() : vtable() {
5830             initializeDataMembersArea();
5831         }
5832 
5833         ~FakeObject() {
5834             vtable.dispose();
5835         }
5836 
5837         void initializeDataMembersArea() {
5838             for (size_t i = 0; i < SIZE; ++i) instanceArea[i] = (char) 0;
5839         }
5840 
5841         void setMethod(unsigned int index, void *method) {
5842             vtable.setMethod(index, method);
5843         }
5844 
5845         VirtualTable<C, baseclasses...> &getVirtualTable() {
5846             return vtable;
5847         }
5848 
5849         void setVirtualTable(VirtualTable<C, baseclasses...> &t) {
5850             vtable = t;
5851         }
5852 
5853         void setDtor(void *dtor) {
5854             vtable.setDtor(dtor);
5855         }
5856     };
5857 
5858 #ifdef _MSC_VER
5859 #pragma warning( pop )
5860 #endif
5861 
5862 #ifdef __GNUG__
5863 #ifndef __clang__
5864 #pragma GCC diagnostic pop
5865 #endif
5866 #endif
5867 
5868 }
5869 namespace fakeit {
5870 
5871     struct MethodProxy {
5872 
5873         MethodProxy(unsigned int id, unsigned int offset, void *vMethod) :
5874                 _id(id),
5875                 _offset(offset),
5876                 _vMethod(vMethod) {
5877         }
5878 
5879         unsigned int getOffset() const {
5880             return _offset;
5881         }
5882 
5883         unsigned int getId() const {
5884             return _id;
5885         }
5886 
5887         void *getProxy() const {
5888             return union_cast<void *>(_vMethod);
5889         }
5890 
5891     private:
5892         unsigned int _id;
5893         unsigned int _offset;
5894         void *_vMethod;
5895     };
5896 }
5897 #include <utility>
5898 
5899 
5900 namespace fakeit {
5901 
5902     struct InvocationHandlerCollection {
5903         static const unsigned int VT_COOKIE_INDEX = 0;
5904 
5905         virtual Destructible *getInvocatoinHandlerPtrById(unsigned int index) = 0;
5906 
5907         static InvocationHandlerCollection *getInvocationHandlerCollection(void *instance) {
5908             VirtualTableBase &vt = VirtualTableBase::getVTable(instance);
5909             InvocationHandlerCollection *invocationHandlerCollection = (InvocationHandlerCollection *) vt.getCookie(
5910                     InvocationHandlerCollection::VT_COOKIE_INDEX);
5911             return invocationHandlerCollection;
5912         }
5913     };
5914 
5915 
5916     template<typename R, typename ... arglist>
5917     class MethodProxyCreator {
5918 
5919 
5920 
5921     public:
5922 
5923         template<unsigned int id>
5924         MethodProxy createMethodProxy(unsigned int offset) {
5925             return MethodProxy(id, offset, union_cast<void *>(&MethodProxyCreator::methodProxyX < id > ));
5926         }
5927 
5928     protected:
5929 
5930         R methodProxy(unsigned int id, const typename fakeit::production_arg<arglist>::type... args) {
5931             InvocationHandlerCollection *invocationHandlerCollection = InvocationHandlerCollection::getInvocationHandlerCollection(
5932                     this);
5933             MethodInvocationHandler<R, arglist...> *invocationHandler =
5934                     (MethodInvocationHandler<R, arglist...> *) invocationHandlerCollection->getInvocatoinHandlerPtrById(
5935                             id);
5936             return invocationHandler->handleMethodInvocation(std::forward<const typename fakeit::production_arg<arglist>::type>(args)...);
5937         }
5938 
5939         template<int id>
5940         R methodProxyX(arglist ... args) {
5941             return methodProxy(id, std::forward<const typename fakeit::production_arg<arglist>::type>(args)...);
5942         }
5943     };
5944 }
5945 
5946 namespace fakeit {
5947 
5948     class InvocationHandlers : public InvocationHandlerCollection {
5949         std::vector<std::shared_ptr<Destructible>> &_methodMocks;
5950         std::vector<unsigned int> &_offsets;
5951 
5952         unsigned int getOffset(unsigned int id) const
5953         {
5954             unsigned int offset = 0;
5955             for (; offset < _offsets.size(); offset++) {
5956                 if (_offsets[offset] == id) {
5957                     break;
5958                 }
5959             }
5960             return offset;
5961         }
5962 
5963     public:
5964         InvocationHandlers(
5965                 std::vector<std::shared_ptr<Destructible>> &methodMocks,
5966                 std::vector<unsigned int> &offsets) :
5967                 _methodMocks(methodMocks), _offsets(offsets) {
5968             for (std::vector<unsigned int>::iterator it = _offsets.begin(); it != _offsets.end(); ++it)
5969             {
5970                 *it = std::numeric_limits<int>::max();
5971             }
5972         }
5973 
5974         Destructible *getInvocatoinHandlerPtrById(unsigned int id) override {
5975             unsigned int offset = getOffset(id);
5976             std::shared_ptr<Destructible> ptr = _methodMocks[offset];
5977             return ptr.get();
5978         }
5979 
5980     };
5981 
5982     template<typename C, typename ... baseclasses>
5983     struct DynamicProxy {
5984 
5985         static_assert(std::is_polymorphic<C>::value, "DynamicProxy requires a polymorphic type");
5986 
5987         DynamicProxy(C &inst) :
5988                 instance(inst),
5989                 originalVtHandle(VirtualTable<C, baseclasses...>::getVTable(instance).createHandle()),
5990                 _methodMocks(VTUtils::getVTSize<C>()),
5991                 _offsets(VTUtils::getVTSize<C>()),
5992                 _invocationHandlers(_methodMocks, _offsets) {
5993             _cloneVt.copyFrom(originalVtHandle.restore());
5994             _cloneVt.setCookie(InvocationHandlerCollection::VT_COOKIE_INDEX, &_invocationHandlers);
5995             getFake().setVirtualTable(_cloneVt);
5996         }
5997 
5998         void detach() {
5999             getFake().setVirtualTable(originalVtHandle.restore());
6000         }
6001 
6002         ~DynamicProxy() {
6003             _cloneVt.dispose();
6004         }
6005 
6006         C &get() {
6007             return instance;
6008         }
6009 
6010         void Reset() {
6011             _methodMocks = {};
6012             _methodMocks.resize(VTUtils::getVTSize<C>());
6013             _members = {};
6014             _offsets = {};
6015             _offsets.resize(VTUtils::getVTSize<C>());
6016             _cloneVt.copyFrom(originalVtHandle.restore());
6017         }
6018 
6019         void Clear()
6020         {
6021         }
6022 
6023         template<int id, typename R, typename ... arglist>
6024         void stubMethod(R(C::*vMethod)(arglist...), MethodInvocationHandler<R, arglist...> *methodInvocationHandler) {
6025             auto offset = VTUtils::getOffset(vMethod);
6026             MethodProxyCreator<R, arglist...> creator;
6027             bind(creator.template createMethodProxy<id + 1>(offset), methodInvocationHandler);
6028         }
6029 
6030         void stubDtor(MethodInvocationHandler<void> *methodInvocationHandler) {
6031             auto offset = VTUtils::getDestructorOffset<C>();
6032             MethodProxyCreator<void> creator;
6033             bindDtor(creator.createMethodProxy<0>(offset), methodInvocationHandler);
6034         }
6035 
6036         template<typename R, typename ... arglist>
6037         bool isMethodStubbed(R(C::*vMethod)(arglist...)) {
6038             unsigned int offset = VTUtils::getOffset(vMethod);
6039             return isBinded(offset);
6040         }
6041 
6042         bool isDtorStubbed() {
6043             unsigned int offset = VTUtils::getDestructorOffset<C>();
6044             return isBinded(offset);
6045         }
6046 
6047         template<typename R, typename ... arglist>
6048         Destructible *getMethodMock(R(C::*vMethod)(arglist...)) {
6049             auto offset = VTUtils::getOffset(vMethod);
6050             std::shared_ptr<Destructible> ptr = _methodMocks[offset];
6051             return ptr.get();
6052         }
6053 
6054         Destructible *getDtorMock() {
6055             auto offset = VTUtils::getDestructorOffset<C>();
6056             std::shared_ptr<Destructible> ptr = _methodMocks[offset];
6057             return ptr.get();
6058         }
6059 
6060         template<typename DATA_TYPE, typename ... arglist>
6061         void stubDataMember(DATA_TYPE C::*member, const arglist &... initargs) {
6062             DATA_TYPE C::*theMember = (DATA_TYPE C::*) member;
6063             C &mock = get();
6064             DATA_TYPE *memberPtr = &(mock.*theMember);
6065             _members.push_back(
6066                     std::shared_ptr<DataMemeberWrapper < DATA_TYPE, arglist...> >
6067                     {new DataMemeberWrapper < DATA_TYPE, arglist...>(memberPtr,
6068                     initargs...)});
6069         }
6070 
6071         template<typename DATA_TYPE>
6072         void getMethodMocks(std::vector<DATA_TYPE> &into) const {
6073             for (std::shared_ptr<Destructible> ptr : _methodMocks) {
6074                 DATA_TYPE p = dynamic_cast<DATA_TYPE>(ptr.get());
6075                 if (p) {
6076                     into.push_back(p);
6077                 }
6078             }
6079         }
6080 
6081         VirtualTable<C, baseclasses...> &getOriginalVT() {
6082             VirtualTable<C, baseclasses...> &vt = originalVtHandle.restore();
6083             return vt;
6084         }
6085 
6086     private:
6087 
6088         template<typename DATA_TYPE, typename ... arglist>
6089         class DataMemeberWrapper : public Destructible {
6090         private:
6091             DATA_TYPE *dataMember;
6092         public:
6093             DataMemeberWrapper(DATA_TYPE *dataMem, const arglist &... initargs) :
6094                     dataMember(dataMem) {
6095                 new(dataMember) DATA_TYPE{initargs ...};
6096             }
6097 
6098             ~DataMemeberWrapper() override
6099             {
6100                 dataMember->~DATA_TYPE();
6101             }
6102         };
6103 
6104         static_assert(sizeof(C) == sizeof(FakeObject<C, baseclasses...>), "This is a problem");
6105 
6106         C &instance;
6107         typename VirtualTable<C, baseclasses...>::Handle originalVtHandle;
6108         VirtualTable<C, baseclasses...> _cloneVt;
6109 
6110         std::vector<std::shared_ptr<Destructible>> _methodMocks;
6111         std::vector<std::shared_ptr<Destructible>> _members;
6112         std::vector<unsigned int> _offsets;
6113         InvocationHandlers _invocationHandlers;
6114 
6115         FakeObject<C, baseclasses...> &getFake() {
6116             return reinterpret_cast<FakeObject<C, baseclasses...> &>(instance);
6117         }
6118 
6119         void bind(const MethodProxy &methodProxy, Destructible *invocationHandler) {
6120             getFake().setMethod(methodProxy.getOffset(), methodProxy.getProxy());
6121             _methodMocks[methodProxy.getOffset()].reset(invocationHandler);
6122             _offsets[methodProxy.getOffset()] = methodProxy.getId();
6123         }
6124 
6125         void bindDtor(const MethodProxy &methodProxy, Destructible *invocationHandler) {
6126             getFake().setDtor(methodProxy.getProxy());
6127             _methodMocks[methodProxy.getOffset()].reset(invocationHandler);
6128             _offsets[methodProxy.getOffset()] = methodProxy.getId();
6129         }
6130 
6131         template<typename DATA_TYPE>
6132         DATA_TYPE getMethodMock(unsigned int offset) {
6133             std::shared_ptr<Destructible> ptr = _methodMocks[offset];
6134             return dynamic_cast<DATA_TYPE>(ptr.get());
6135         }
6136 
6137         template<typename BaseClass>
6138         void checkMultipleInheritance() {
6139             C *ptr = (C *) (unsigned int) 1;
6140             BaseClass *basePtr = ptr;
6141             int delta = (unsigned long) basePtr - (unsigned long) ptr;
6142             if (delta > 0) {
6143 
6144 
6145                 throw std::invalid_argument(std::string("multiple inheritance is not supported"));
6146             }
6147         }
6148 
6149         bool isBinded(unsigned int offset) {
6150             std::shared_ptr<Destructible> ptr = _methodMocks[offset];
6151             return ptr.get() != nullptr;
6152         }
6153 
6154     };
6155 }
6156 #include <functional>
6157 #include <type_traits>
6158 #include <memory>
6159 #include <iosfwd>
6160 #include <vector>
6161 #include <functional>
6162 #include <tuple>
6163 #include <tuple>
6164 
6165 namespace fakeit {
6166 
6167     template<int N>
6168     struct apply_func {
6169         template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args>
6170         static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> &t, Args &... args) {
6171             return apply_func<N - 1>::template applyTuple(f, t, std::get<N - 1>(t), args...);
6172         }
6173     };
6174 
6175     template<>
6176     struct apply_func < 0 > {
6177         template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args>
6178         static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> & , Args &... args) {
6179             return f(args...);
6180         }
6181     };
6182 
6183     struct TupleDispatcher {
6184 
6185         template<typename R, typename ... ArgsF, typename ... ArgsT>
6186         static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> &t) {
6187             return apply_func<sizeof...(ArgsT)>::template applyTuple(f, t);
6188         }
6189 
6190         template<typename R, typename ...arglist>
6191         static R invoke(std::function<R(arglist &...)> func, const std::tuple<arglist...> &arguments) {
6192             std::tuple<arglist...> &args = const_cast<std::tuple<arglist...> &>(arguments);
6193             return applyTuple(func, args);
6194         }
6195 
6196         template<typename TupleType, typename FunctionType>
6197         static void for_each(TupleType &&, FunctionType &,
6198             std::integral_constant<size_t, std::tuple_size<typename std::remove_reference<TupleType>::type>::value>) {
6199         }
6200 
6201         template<std::size_t I, typename TupleType, typename FunctionType, typename = typename std::enable_if<
6202             I != std::tuple_size<typename std::remove_reference<TupleType>::type>::value>::type>
6203             static void for_each(TupleType &&t, FunctionType &f, std::integral_constant<size_t, I>) {
6204             f(I, std::get < I >(t));
6205             for_each(std::forward < TupleType >(t), f, std::integral_constant<size_t, I + 1>());
6206         }
6207 
6208         template<typename TupleType, typename FunctionType>
6209         static void for_each(TupleType &&t, FunctionType &f) {
6210             for_each(std::forward < TupleType >(t), f, std::integral_constant<size_t, 0>());
6211         }
6212 
6213         template<typename TupleType1, typename TupleType2, typename FunctionType>
6214         static void for_each(TupleType1 &&, TupleType2 &&, FunctionType &,
6215             std::integral_constant<size_t, std::tuple_size<typename std::remove_reference<TupleType1>::type>::value>) {
6216         }
6217 
6218         template<std::size_t I, typename TupleType1, typename TupleType2, typename FunctionType, typename = typename std::enable_if<
6219             I != std::tuple_size<typename std::remove_reference<TupleType1>::type>::value>::type>
6220             static void for_each(TupleType1 &&t, TupleType2 &&t2, FunctionType &f, std::integral_constant<size_t, I>) {
6221             f(I, std::get < I >(t), std::get < I >(t2));
6222             for_each(std::forward < TupleType1 >(t), std::forward < TupleType2 >(t2), f, std::integral_constant<size_t, I + 1>());
6223         }
6224 
6225         template<typename TupleType1, typename TupleType2, typename FunctionType>
6226         static void for_each(TupleType1 &&t, TupleType2 &&t2, FunctionType &f) {
6227             for_each(std::forward < TupleType1 >(t), std::forward < TupleType2 >(t2), f, std::integral_constant<size_t, 0>());
6228         }
6229     };
6230 }
6231 namespace fakeit {
6232 
6233     template<typename R, typename ... arglist>
6234     struct ActualInvocationHandler : Destructible {
6235         virtual R handleMethodInvocation(ArgumentsTuple<arglist...> & args) = 0;
6236     };
6237 
6238 }
6239 #include <functional>
6240 #include <tuple>
6241 #include <string>
6242 #include <iosfwd>
6243 #include <type_traits>
6244 #include <typeinfo>
6245 
6246 namespace fakeit {
6247 
6248     struct DefaultValueInstatiationException {
6249         virtual ~DefaultValueInstatiationException() = default;
6250 
6251         virtual std::string what() const = 0;
6252     };
6253 
6254 
6255     template<class C>
6256     struct is_constructible_type {
6257         static const bool value =
6258                 std::is_default_constructible<typename naked_type<C>::type>::value
6259                 && !std::is_abstract<typename naked_type<C>::type>::value;
6260     };
6261 
6262     template<class C, class Enable = void>
6263     struct DefaultValue;
6264 
6265     template<class C>
6266     struct DefaultValue<C, typename std::enable_if<!is_constructible_type<C>::value>::type> {
6267         static C &value() {
6268             if (std::is_reference<C>::value) {
6269                 typename naked_type<C>::type *ptr = nullptr;
6270                 return *ptr;
6271             }
6272 
6273             class Exception : public DefaultValueInstatiationException {
6274                 virtual std::string what() const
6275 
6276                 override {
6277                     return (std::string("Type ") + std::string(typeid(C).name())
6278                             + std::string(
6279                             " is not default constructible. Could not instantiate a default return value")).c_str();
6280                 }
6281             };
6282 
6283             throw Exception();
6284         }
6285     };
6286 
6287     template<class C>
6288     struct DefaultValue<C, typename std::enable_if<is_constructible_type<C>::value>::type> {
6289         static C &value() {
6290             static typename naked_type<C>::type val{};
6291             return val;
6292         }
6293     };
6294 
6295 
6296     template<>
6297     struct DefaultValue<void> {
6298         static void value() {
6299             return;
6300         }
6301     };
6302 
6303     template<>
6304     struct DefaultValue<bool> {
6305         static bool &value() {
6306             static bool value{false};
6307             return value;
6308         }
6309     };
6310 
6311     template<>
6312     struct DefaultValue<char> {
6313         static char &value() {
6314             static char value{0};
6315             return value;
6316         }
6317     };
6318 
6319     template<>
6320     struct DefaultValue<char16_t> {
6321         static char16_t &value() {
6322             static char16_t value{0};
6323             return value;
6324         }
6325     };
6326 
6327     template<>
6328     struct DefaultValue<char32_t> {
6329         static char32_t &value() {
6330             static char32_t value{0};
6331             return value;
6332         }
6333     };
6334 
6335     template<>
6336     struct DefaultValue<wchar_t> {
6337         static wchar_t &value() {
6338             static wchar_t value{0};
6339             return value;
6340         }
6341     };
6342 
6343     template<>
6344     struct DefaultValue<short> {
6345         static short &value() {
6346             static short value{0};
6347             return value;
6348         }
6349     };
6350 
6351     template<>
6352     struct DefaultValue<int> {
6353         static int &value() {
6354             static int value{0};
6355             return value;
6356         }
6357     };
6358 
6359     template<>
6360     struct DefaultValue<long> {
6361         static long &value() {
6362             static long value{0};
6363             return value;
6364         }
6365     };
6366 
6367     template<>
6368     struct DefaultValue<long long> {
6369         static long long &value() {
6370             static long long value{0};
6371             return value;
6372         }
6373     };
6374 
6375     template<>
6376     struct DefaultValue<std::string> {
6377         static std::string &value() {
6378             static std::string value{};
6379             return value;
6380         }
6381     };
6382 
6383 }
6384 namespace fakeit {
6385 
6386     struct IMatcher : Destructible {
6387         ~IMatcher() = default;
6388         virtual std::string format() const = 0;
6389     };
6390 
6391     template<typename T>
6392     struct TypedMatcher : IMatcher {
6393         virtual bool matches(const T &actual) const = 0;
6394     };
6395 
6396     template<typename T>
6397     struct TypedMatcherCreator {
6398 
6399         virtual ~TypedMatcherCreator() = default;
6400 
6401         virtual TypedMatcher<T> *createMatcher() const = 0;
6402     };
6403 
6404     template<typename T>
6405     struct ComparisonMatcherCreator : public TypedMatcherCreator<T> {
6406 
6407         virtual ~ComparisonMatcherCreator() = default;
6408 
6409         ComparisonMatcherCreator(const T &arg)
6410                 : _expected(arg) {
6411         }
6412 
6413         struct Matcher : public TypedMatcher<T> {
6414             Matcher(const T &expected)
6415                     : _expected(expected) {
6416             }
6417 
6418             const T _expected;
6419         };
6420 
6421         const T &_expected;
6422     };
6423 
6424     namespace internal {
6425         template<typename T>
6426         struct TypedAnyMatcher : public TypedMatcherCreator<T> {
6427 
6428             virtual ~TypedAnyMatcher() = default;
6429 
6430             TypedAnyMatcher() {
6431             }
6432 
6433             struct Matcher : public TypedMatcher<T> {
6434                 virtual bool matches(const T &) const override {
6435                     return true;
6436                 }
6437 
6438                 virtual std::string format() const override {
6439                     return "Any";
6440                 }
6441             };
6442 
6443             virtual TypedMatcher<T> *createMatcher() const override {
6444                 return new Matcher();
6445             }
6446 
6447         };
6448 
6449         template<typename T>
6450         struct EqMatcherCreator : public ComparisonMatcherCreator<T> {
6451 
6452             virtual ~EqMatcherCreator() = default;
6453 
6454             EqMatcherCreator(const T &expected)
6455                     : ComparisonMatcherCreator<T>(expected) {
6456             }
6457 
6458             struct Matcher : public ComparisonMatcherCreator<T>::Matcher {
6459                 Matcher(const T &expected)
6460                         : ComparisonMatcherCreator<T>::Matcher(expected) {
6461                 }
6462 
6463                 virtual std::string format() const override {
6464                     return TypeFormatter<T>::format(this->_expected);
6465                 }
6466 
6467                 virtual bool matches(const T &actual) const override {
6468                     return actual == this->_expected;
6469                 }
6470             };
6471 
6472             virtual TypedMatcher<T> *createMatcher() const {
6473                 return new Matcher(this->_expected);
6474             }
6475 
6476         };
6477 
6478         template<typename T>
6479         struct GtMatcherCreator : public ComparisonMatcherCreator<T> {
6480 
6481             virtual ~GtMatcherCreator() = default;
6482 
6483             GtMatcherCreator(const T &expected)
6484                     : ComparisonMatcherCreator<T>(expected) {
6485             }
6486 
6487             struct Matcher : public ComparisonMatcherCreator<T>::Matcher {
6488                 Matcher(const T &expected)
6489                         : ComparisonMatcherCreator<T>::Matcher(expected) {
6490                 }
6491 
6492                 virtual bool matches(const T &actual) const override {
6493                     return actual > this->_expected;
6494                 }
6495 
6496                 virtual std::string format() const override {
6497                     return std::string(">") + TypeFormatter<T>::format(this->_expected);
6498                 }
6499             };
6500 
6501             virtual TypedMatcher<T> *createMatcher() const override {
6502                 return new Matcher(this->_expected);
6503             }
6504         };
6505 
6506         template<typename T>
6507         struct GeMatcherCreator : public ComparisonMatcherCreator<T> {
6508 
6509             virtual ~GeMatcherCreator() = default;
6510 
6511             GeMatcherCreator(const T &expected)
6512                     : ComparisonMatcherCreator<T>(expected) {
6513             }
6514 
6515             struct Matcher : public ComparisonMatcherCreator<T>::Matcher {
6516                 Matcher(const T &expected)
6517                         : ComparisonMatcherCreator<T>::Matcher(expected) {
6518                 }
6519 
6520                 virtual bool matches(const T &actual) const override {
6521                     return actual >= this->_expected;
6522                 }
6523 
6524                 virtual std::string format() const override {
6525                     return std::string(">=") + TypeFormatter<T>::format(this->_expected);
6526                 }
6527             };
6528 
6529             virtual TypedMatcher<T> *createMatcher() const override {
6530                 return new Matcher(this->_expected);
6531             }
6532         };
6533 
6534         template<typename T>
6535         struct LtMatcherCreator : public ComparisonMatcherCreator<T> {
6536 
6537             virtual ~LtMatcherCreator() = default;
6538 
6539             LtMatcherCreator(const T &expected)
6540                     : ComparisonMatcherCreator<T>(expected) {
6541             }
6542 
6543             struct Matcher : public ComparisonMatcherCreator<T>::Matcher {
6544                 Matcher(const T &expected)
6545                         : ComparisonMatcherCreator<T>::Matcher(expected) {
6546                 }
6547 
6548                 virtual bool matches(const T &actual) const override {
6549                     return actual < this->_expected;
6550                 }
6551 
6552                 virtual std::string format() const override {
6553                     return std::string("<") + TypeFormatter<T>::format(this->_expected);
6554                 }
6555             };
6556 
6557             virtual TypedMatcher<T> *createMatcher() const override {
6558                 return new Matcher(this->_expected);
6559             }
6560 
6561         };
6562 
6563         template<typename T>
6564         struct LeMatcherCreator : public ComparisonMatcherCreator<T> {
6565 
6566             virtual ~LeMatcherCreator() = default;
6567 
6568             LeMatcherCreator(const T &expected)
6569                     : ComparisonMatcherCreator<T>(expected) {
6570             }
6571 
6572             struct Matcher : public ComparisonMatcherCreator<T>::Matcher {
6573                 Matcher(const T &expected)
6574                         : ComparisonMatcherCreator<T>::Matcher(expected) {
6575                 }
6576 
6577                 virtual bool matches(const T &actual) const override {
6578                     return actual <= this->_expected;
6579                 }
6580 
6581                 virtual std::string format() const override {
6582                     return std::string("<=") + TypeFormatter<T>::format(this->_expected);
6583                 }
6584             };
6585 
6586             virtual TypedMatcher<T> *createMatcher() const override {
6587                 return new Matcher(this->_expected);
6588             }
6589 
6590         };
6591 
6592         template<typename T>
6593         struct NeMatcherCreator : public ComparisonMatcherCreator<T> {
6594 
6595             virtual ~NeMatcherCreator() = default;
6596 
6597             NeMatcherCreator(const T &expected)
6598                     : ComparisonMatcherCreator<T>(expected) {
6599             }
6600 
6601             struct Matcher : public ComparisonMatcherCreator<T>::Matcher {
6602                 Matcher(const T &expected)
6603                         : ComparisonMatcherCreator<T>::Matcher(expected) {
6604                 }
6605 
6606                 virtual bool matches(const T &actual) const override {
6607                     return actual != this->_expected;
6608                 }
6609 
6610                 virtual std::string format() const override {
6611                     return std::string("!=") + TypeFormatter<T>::format(this->_expected);
6612                 }
6613 
6614             };
6615 
6616             virtual TypedMatcher<T> *createMatcher() const override {
6617                 return new Matcher(this->_expected);
6618             }
6619 
6620         };
6621     }
6622 
6623     struct AnyMatcher {
6624     } static _;
6625 
6626     template<typename T>
6627     internal::TypedAnyMatcher<T> Any() {
6628         internal::TypedAnyMatcher<T> rv;
6629         return rv;
6630     }
6631 
6632     template<typename T>
6633     internal::EqMatcherCreator<T> Eq(const T &arg) {
6634         internal::EqMatcherCreator<T> rv(arg);
6635         return rv;
6636     }
6637 
6638     template<typename T>
6639     internal::GtMatcherCreator<T> Gt(const T &arg) {
6640         internal::GtMatcherCreator<T> rv(arg);
6641         return rv;
6642     }
6643 
6644     template<typename T>
6645     internal::GeMatcherCreator<T> Ge(const T &arg) {
6646         internal::GeMatcherCreator<T> rv(arg);
6647         return rv;
6648     }
6649 
6650     template<typename T>
6651     internal::LtMatcherCreator<T> Lt(const T &arg) {
6652         internal::LtMatcherCreator<T> rv(arg);
6653         return rv;
6654     }
6655 
6656     template<typename T>
6657     internal::LeMatcherCreator<T> Le(const T &arg) {
6658         internal::LeMatcherCreator<T> rv(arg);
6659         return rv;
6660     }
6661 
6662     template<typename T>
6663     internal::NeMatcherCreator<T> Ne(const T &arg) {
6664         internal::NeMatcherCreator<T> rv(arg);
6665         return rv;
6666     }
6667 
6668 }
6669 
6670 namespace fakeit {
6671 
6672     template<typename ... arglist>
6673     struct ArgumentsMatcherInvocationMatcher : public ActualInvocation<arglist...>::Matcher {
6674 
6675         virtual ~ArgumentsMatcherInvocationMatcher() {
6676             for (unsigned int i = 0; i < _matchers.size(); i++)
6677                 delete _matchers[i];
6678         }
6679 
6680         ArgumentsMatcherInvocationMatcher(const std::vector<Destructible *> &args)
6681                 : _matchers(args) {
6682         }
6683 
6684         virtual bool matches(ActualInvocation<arglist...> &invocation) override {
6685             if (invocation.getActualMatcher() == this)
6686                 return true;
6687             return matches(invocation.getActualArguments());
6688         }
6689 
6690         virtual std::string format() const override {
6691             std::ostringstream out;
6692             out << "(";
6693             for (unsigned int i = 0; i < _matchers.size(); i++) {
6694                 if (i > 0) out << ", ";
6695                 IMatcher *m = dynamic_cast<IMatcher *>(_matchers[i]);
6696                 out << m->format();
6697             }
6698             out << ")";
6699             return out.str();
6700         }
6701 
6702     private:
6703 
6704         struct MatchingLambda {
6705             MatchingLambda(const std::vector<Destructible *> &matchers)
6706                     : _matchers(matchers) {
6707             }
6708 
6709             template<typename A>
6710             void operator()(int index, A &actualArg) {
6711                 TypedMatcher<typename naked_type<A>::type> *matcher =
6712                         dynamic_cast<TypedMatcher<typename naked_type<A>::type> *>(_matchers[index]);
6713                 if (_matching)
6714                     _matching = matcher->matches(actualArg);
6715             }
6716 
6717             bool isMatching() {
6718                 return _matching;
6719             }
6720 
6721         private:
6722             bool _matching = true;
6723             const std::vector<Destructible *> &_matchers;
6724         };
6725 
6726         virtual bool matches(ArgumentsTuple<arglist...>& actualArguments) {
6727             MatchingLambda l(_matchers);
6728             fakeit::TupleDispatcher::for_each(actualArguments, l);
6729             return l.isMatching();
6730         }
6731 
6732         const std::vector<Destructible *> _matchers;
6733     };
6734 
6735 
6736 
6737 
6738 
6739 
6740 
6741 
6742 
6743 
6744 
6745 
6746 
6747 
6748 
6749 
6750 
6751 
6752 
6753 
6754 
6755 
6756 
6757 
6758 
6759 
6760 
6761 
6762 
6763 
6764 
6765 
6766     template<typename ... arglist>
6767     struct UserDefinedInvocationMatcher : ActualInvocation<arglist...>::Matcher {
6768         virtual ~UserDefinedInvocationMatcher() = default;
6769 
6770         UserDefinedInvocationMatcher(std::function<bool(arglist &...)> match)
6771                 : matcher{match} {
6772         }
6773 
6774         virtual bool matches(ActualInvocation<arglist...> &invocation) override {
6775             if (invocation.getActualMatcher() == this)
6776                 return true;
6777             return matches(invocation.getActualArguments());
6778         }
6779 
6780         virtual std::string format() const override {
6781             return {"( user defined matcher )"};
6782         }
6783 
6784     private:
6785         virtual bool matches(ArgumentsTuple<arglist...>& actualArguments) {
6786             return TupleDispatcher::invoke<bool, typename tuple_arg<arglist>::type...>(matcher, actualArguments);
6787         }
6788 
6789         const std::function<bool(arglist &...)> matcher;
6790     };
6791 
6792     template<typename ... arglist>
6793     struct DefaultInvocationMatcher : public ActualInvocation<arglist...>::Matcher {
6794 
6795         virtual ~DefaultInvocationMatcher() = default;
6796 
6797         DefaultInvocationMatcher() {
6798         }
6799 
6800         virtual bool matches(ActualInvocation<arglist...> &invocation) override {
6801             return matches(invocation.getActualArguments());
6802         }
6803 
6804         virtual std::string format() const override {
6805             return {"( Any arguments )"};
6806         }
6807 
6808     private:
6809 
6810         virtual bool matches(const ArgumentsTuple<arglist...>&) {
6811             return true;
6812         }
6813     };
6814 
6815 }
6816 
6817 namespace fakeit {
6818 
6819 
6820     template<typename R, typename ... arglist>
6821     class RecordedMethodBody : public MethodInvocationHandler<R, arglist...>, public ActualInvocationsSource, public ActualInvocationsContainer {
6822 
6823         struct MatchedInvocationHandler : ActualInvocationHandler<R, arglist...> {
6824 
6825             virtual ~MatchedInvocationHandler() = default;
6826 
6827             MatchedInvocationHandler(typename ActualInvocation<arglist...>::Matcher *matcher,
6828                 ActualInvocationHandler<R, arglist...> *invocationHandler) :
6829                     _matcher{matcher}, _invocationHandler{invocationHandler} {
6830             }
6831 
6832             virtual R handleMethodInvocation(ArgumentsTuple<arglist...> & args) override
6833             {
6834                 Destructible &destructable = *_invocationHandler;
6835                 ActualInvocationHandler<R, arglist...> &invocationHandler = dynamic_cast<ActualInvocationHandler<R, arglist...> &>(destructable);
6836                 return invocationHandler.handleMethodInvocation(args);
6837             }
6838 
6839             typename ActualInvocation<arglist...>::Matcher &getMatcher() const {
6840                 Destructible &destructable = *_matcher;
6841                 typename ActualInvocation<arglist...>::Matcher &matcher = dynamic_cast<typename ActualInvocation<arglist...>::Matcher &>(destructable);
6842                 return matcher;
6843             }
6844 
6845         private:
6846             std::shared_ptr<Destructible> _matcher;
6847             std::shared_ptr<Destructible> _invocationHandler;
6848         };
6849 
6850 
6851         FakeitContext &_fakeit;
6852         MethodInfo _method;
6853 
6854         std::vector<std::shared_ptr<Destructible>> _invocationHandlers;
6855         std::vector<std::shared_ptr<Destructible>> _actualInvocations;
6856 
6857         MatchedInvocationHandler *buildMatchedInvocationHandler(
6858                 typename ActualInvocation<arglist...>::Matcher *invocationMatcher,
6859                 ActualInvocationHandler<R, arglist...> *invocationHandler) {
6860             return new MatchedInvocationHandler(invocationMatcher, invocationHandler);
6861         }
6862 
6863         MatchedInvocationHandler *getInvocationHandlerForActualArgs(ActualInvocation<arglist...> &invocation) {
6864             for (auto i = _invocationHandlers.rbegin(); i != _invocationHandlers.rend(); ++i) {
6865                 std::shared_ptr<Destructible> curr = *i;
6866                 Destructible &destructable = *curr;
6867                 MatchedInvocationHandler &im = asMatchedInvocationHandler(destructable);
6868                 if (im.getMatcher().matches(invocation)) {
6869                     return &im;
6870                 }
6871             }
6872             return nullptr;
6873         }
6874 
6875         MatchedInvocationHandler &asMatchedInvocationHandler(Destructible &destructable) {
6876             MatchedInvocationHandler &im = dynamic_cast<MatchedInvocationHandler &>(destructable);
6877             return im;
6878         }
6879 
6880         ActualInvocation<arglist...> &asActualInvocation(Destructible &destructable) const {
6881             ActualInvocation<arglist...> &invocation = dynamic_cast<ActualInvocation<arglist...> &>(destructable);
6882             return invocation;
6883         }
6884 
6885     public:
6886 
6887         RecordedMethodBody(FakeitContext &fakeit, std::string name) :
6888                 _fakeit(fakeit), _method{MethodInfo::nextMethodOrdinal(), name} { }
6889 
6890         virtual ~RecordedMethodBody() NO_THROWS {
6891         }
6892 
6893         MethodInfo &getMethod() {
6894             return _method;
6895         }
6896 
6897         bool isOfMethod(MethodInfo &method) {
6898 
6899             return method.id() == _method.id();
6900         }
6901 
6902         void addMethodInvocationHandler(typename ActualInvocation<arglist...>::Matcher *matcher,
6903             ActualInvocationHandler<R, arglist...> *invocationHandler) {
6904             ActualInvocationHandler<R, arglist...> *mock = buildMatchedInvocationHandler(matcher, invocationHandler);
6905             std::shared_ptr<Destructible> destructable{mock};
6906             _invocationHandlers.push_back(destructable);
6907         }
6908 
6909         void reset() {
6910             _invocationHandlers.clear();
6911             _actualInvocations.clear();
6912         }
6913 
6914         void clear() override {
6915             _actualInvocations.clear();
6916         }
6917 
6918         R handleMethodInvocation(const typename fakeit::production_arg<arglist>::type... args) override {
6919             unsigned int ordinal = Invocation::nextInvocationOrdinal();
6920             MethodInfo &method = this->getMethod();
6921             auto actualInvocation = new ActualInvocation<arglist...>(ordinal, method, std::forward<const typename fakeit::production_arg<arglist>::type>(args)...);
6922 
6923 
6924             std::shared_ptr<Destructible> actualInvocationDtor{actualInvocation};
6925 
6926             auto invocationHandler = getInvocationHandlerForActualArgs(*actualInvocation);
6927             if (invocationHandler) {
6928                 auto &matcher = invocationHandler->getMatcher();
6929                 actualInvocation->setActualMatcher(&matcher);
6930                 _actualInvocations.push_back(actualInvocationDtor);
6931                 try {
6932                     return invocationHandler->handleMethodInvocation(actualInvocation->getActualArguments());
6933                 } catch (NoMoreRecordedActionException &) {
6934                 }
6935             }
6936 
6937             UnexpectedMethodCallEvent event(UnexpectedType::Unmatched, *actualInvocation);
6938             _fakeit.handle(event);
6939             std::string format{_fakeit.format(event)};
6940             UnexpectedMethodCallException e(format);
6941             throw e;
6942         }
6943 
6944         void scanActualInvocations(const std::function<void(ActualInvocation<arglist...> &)> &scanner) {
6945             for (auto destructablePtr : _actualInvocations) {
6946                 ActualInvocation<arglist...> &invocation = asActualInvocation(*destructablePtr);
6947                 scanner(invocation);
6948             }
6949         }
6950 
6951         void getActualInvocations(std::unordered_set<Invocation *> &into) const override {
6952             for (auto destructablePtr : _actualInvocations) {
6953                 Invocation &invocation = asActualInvocation(*destructablePtr);
6954                 into.insert(&invocation);
6955             }
6956         }
6957 
6958         void setMethodDetails(const std::string &mockName, const std::string &methodName) {
6959             const std::string fullName{mockName + "." + methodName};
6960             _method.setName(fullName);
6961         }
6962 
6963     };
6964 
6965 }
6966 #include <functional>
6967 #include <type_traits>
6968 #include <stdexcept>
6969 #include <utility>
6970 #include <functional>
6971 #include <type_traits>
6972 
6973 namespace fakeit {
6974 
6975     struct Quantity {
6976         Quantity(const int q) :
6977                 quantity(q) {
6978         }
6979 
6980         const int quantity;
6981     } static Once(1);
6982 
6983     template<typename R>
6984     struct Quantifier : public Quantity {
6985         Quantifier(const int q, const R &val) :
6986                 Quantity(q), value(val) {
6987         }
6988 
6989         const R &value;
6990     };
6991 
6992     template<>
6993     struct Quantifier<void> : public Quantity {
6994         explicit Quantifier(const int q) :
6995                 Quantity(q) {
6996         }
6997     };
6998 
6999     struct QuantifierFunctor : public Quantifier<void> {
7000         QuantifierFunctor(const int q) :
7001                 Quantifier<void>(q) {
7002         }
7003 
7004         template<typename R>
7005         Quantifier<R> operator()(const R &value) {
7006             return Quantifier<R>(quantity, value);
7007         }
7008     };
7009 
7010     template<int q>
7011     struct Times : public Quantity {
7012 
7013         Times<q>() : Quantity(q) { }
7014 
7015         template<typename R>
7016         static Quantifier<R> of(const R &value) {
7017             return Quantifier<R>(q, value);
7018         }
7019 
7020         static Quantifier<void> Void() {
7021             return Quantifier<void>(q);
7022         }
7023     };
7024 
7025 #if defined (__GNUG__) || (_MSC_VER >= 1900)
7026 
7027     inline QuantifierFunctor operator
7028     ""
7029 
7030     _Times(unsigned long long n) {
7031         return QuantifierFunctor((int) n);
7032     }
7033 
7034     inline QuantifierFunctor operator
7035     ""
7036 
7037     _Time(unsigned long long n) {
7038         if (n != 1)
7039             throw std::invalid_argument("Only 1_Time is supported. Use X_Times (with s) if X is bigger than 1");
7040         return QuantifierFunctor((int) n);
7041     }
7042 
7043 #endif
7044 
7045 }
7046 #include <functional>
7047 #include <atomic>
7048 #include <tuple>
7049 #include <type_traits>
7050 
7051 
7052 namespace fakeit {
7053 
7054     template<typename R, typename ... arglist>
7055     struct Action : Destructible {
7056         virtual R invoke(const ArgumentsTuple<arglist...> &) = 0;
7057 
7058         virtual bool isDone() = 0;
7059     };
7060 
7061     template<typename R, typename ... arglist>
7062     struct Repeat : Action<R, arglist...> {
7063         virtual ~Repeat() = default;
7064 
7065         Repeat(std::function<R(typename fakeit::test_arg<arglist>::type...)> func) :
7066                 f(func), times(1) {
7067         }
7068 
7069         Repeat(std::function<R(typename fakeit::test_arg<arglist>::type...)> func, long t) :
7070                 f(func), times(t) {
7071         }
7072 
7073         virtual R invoke(const ArgumentsTuple<arglist...> & args) override {
7074             times--;
7075             return TupleDispatcher::invoke<R, arglist...>(f, args);
7076         }
7077 
7078         virtual bool isDone() override {
7079             return times == 0;
7080         }
7081 
7082     private:
7083         std::function<R(typename fakeit::test_arg<arglist>::type...)> f;
7084         long times;
7085     };
7086 
7087     template<typename R, typename ... arglist>
7088     struct RepeatForever : public Action<R, arglist...> {
7089 
7090         virtual ~RepeatForever() = default;
7091 
7092         RepeatForever(std::function<R(typename fakeit::test_arg<arglist>::type...)> func) :
7093                 f(func) {
7094         }
7095 
7096         virtual R invoke(const ArgumentsTuple<arglist...> & args) override {
7097             return TupleDispatcher::invoke<R, arglist...>(f, args);
7098         }
7099 
7100         virtual bool isDone() override {
7101             return false;
7102         }
7103 
7104     private:
7105         std::function<R(typename fakeit::test_arg<arglist>::type...)> f;
7106     };
7107 
7108     template<typename R, typename ... arglist>
7109     struct ReturnDefaultValue : public Action<R, arglist...> {
7110         virtual ~ReturnDefaultValue() = default;
7111 
7112         virtual R invoke(const ArgumentsTuple<arglist...> &) override {
7113             return DefaultValue<R>::value();
7114         }
7115 
7116         virtual bool isDone() override {
7117             return false;
7118         }
7119     };
7120 
7121     template<typename R, typename ... arglist>
7122     struct ReturnDelegateValue : public Action<R, arglist...> {
7123 
7124         ReturnDelegateValue(std::function<R(const typename fakeit::test_arg<arglist>::type...)> delegate) : _delegate(delegate) { }
7125 
7126         virtual ~ReturnDelegateValue() = default;
7127 
7128         virtual R invoke(const ArgumentsTuple<arglist...> & args) override {
7129             return TupleDispatcher::invoke<R, arglist...>(_delegate, args);
7130         }
7131 
7132         virtual bool isDone() override {
7133             return false;
7134         }
7135 
7136     private:
7137         std::function<R(const typename fakeit::test_arg<arglist>::type...)> _delegate;
7138     };
7139 
7140 }
7141 
7142 namespace fakeit {
7143 
7144     template<typename R, typename ... arglist>
7145     struct MethodStubbingProgress {
7146 
7147         virtual ~MethodStubbingProgress() THROWS {
7148         }
7149 
7150         template<typename U = R>
7151         typename std::enable_if<!std::is_reference<U>::value, MethodStubbingProgress<R, arglist...> &>::type
7152         Return(const R &r) {
7153             return Do([r](const typename fakeit::test_arg<arglist>::type...) -> R { return r; });
7154         }
7155 
7156         template<typename U = R>
7157         typename std::enable_if<std::is_reference<U>::value, MethodStubbingProgress<R, arglist...> &>::type
7158         Return(const R &r) {
7159             return Do([&r](const typename fakeit::test_arg<arglist>::type...) -> R { return r; });
7160         }
7161 
7162         MethodStubbingProgress<R, arglist...> &
7163         Return(const Quantifier<R> &q) {
7164             const R &value = q.value;
7165             auto method = [value](const arglist &...) -> R { return value; };
7166             return DoImpl(new Repeat<R, arglist...>(method, q.quantity));
7167         }
7168 
7169         template<typename first, typename second, typename ... tail>
7170         MethodStubbingProgress<R, arglist...> &
7171         Return(const first &f, const second &s, const tail &... t) {
7172             Return(f);
7173             return Return(s, t...);
7174         }
7175 
7176 
7177         template<typename U = R>
7178         typename std::enable_if<!std::is_reference<U>::value, void>::type
7179         AlwaysReturn(const R &r) {
7180             return AlwaysDo([r](const typename fakeit::test_arg<arglist>::type...) -> R { return r; });
7181         }
7182 
7183         template<typename U = R>
7184         typename std::enable_if<std::is_reference<U>::value, void>::type
7185         AlwaysReturn(const R &r) {
7186             return AlwaysDo([&r](const typename fakeit::test_arg<arglist>::type...) -> R { return r; });
7187         }
7188 
7189         MethodStubbingProgress<R, arglist...> &
7190         Return() {
7191             return Do([](const typename fakeit::test_arg<arglist>::type...) -> R { return DefaultValue<R>::value(); });
7192         }
7193 
7194         void AlwaysReturn() {
7195             return AlwaysDo([](const typename fakeit::test_arg<arglist>::type...) -> R { return DefaultValue<R>::value(); });
7196         }
7197 
7198         template<typename E>
7199         MethodStubbingProgress<R, arglist...> &Throw(const E &e) {
7200             return Do([e](const typename fakeit::test_arg<arglist>::type...) -> R { throw e; });
7201         }
7202 
7203         template<typename E>
7204         MethodStubbingProgress<R, arglist...> &
7205         Throw(const Quantifier<E> &q) {
7206             const E &value = q.value;
7207             auto method = [value](const arglist &...) -> R { throw value; };
7208             return DoImpl(new Repeat<R, arglist...>(method, q.quantity));
7209         }
7210 
7211         template<typename first, typename second, typename ... tail>
7212         MethodStubbingProgress<R, arglist...> &
7213         Throw(const first &f, const second &s, const tail &... t) {
7214             Throw(f);
7215             return Throw(s, t...);
7216         }
7217 
7218         template<typename E>
7219         void AlwaysThrow(const E &e) {
7220             return AlwaysDo([e](const typename fakeit::test_arg<arglist>::type...) -> R { throw e; });
7221         }
7222 
7223         virtual MethodStubbingProgress<R, arglist...> &
7224             Do(std::function<R(const typename fakeit::test_arg<arglist>::type...)> method) {
7225             return DoImpl(new Repeat<R, arglist...>(method));
7226         }
7227 
7228         template<typename F>
7229         MethodStubbingProgress<R, arglist...> &
7230         Do(const Quantifier<F> &q) {
7231             return DoImpl(new Repeat<R, arglist...>(q.value, q.quantity));
7232         }
7233 
7234         template<typename first, typename second, typename ... tail>
7235         MethodStubbingProgress<R, arglist...> &
7236         Do(const first &f, const second &s, const tail &... t) {
7237             Do(f);
7238             return Do(s, t...);
7239         }
7240 
7241         virtual void AlwaysDo(std::function<R(const typename fakeit::test_arg<arglist>::type...)> method) {
7242             DoImpl(new RepeatForever<R, arglist...>(method));
7243         }
7244 
7245     protected:
7246 
7247         virtual MethodStubbingProgress<R, arglist...> &DoImpl(Action<R, arglist...> *action) = 0;
7248 
7249     private:
7250         MethodStubbingProgress &operator=(const MethodStubbingProgress &other) = delete;
7251     };
7252 
7253 
7254     template<typename ... arglist>
7255     struct MethodStubbingProgress<void, arglist...> {
7256 
7257         virtual ~MethodStubbingProgress() THROWS {
7258         }
7259 
7260         MethodStubbingProgress<void, arglist...> &Return() {
7261             auto lambda = [](const typename fakeit::test_arg<arglist>::type...) -> void {
7262                 return DefaultValue<void>::value();
7263             };
7264             return Do(lambda);
7265         }
7266 
7267         virtual MethodStubbingProgress<void, arglist...> &Do(
7268             std::function<void(const typename fakeit::test_arg<arglist>::type...)> method) {
7269             return DoImpl(new Repeat<void, arglist...>(method));
7270         }
7271 
7272 
7273         void AlwaysReturn() {
7274             return AlwaysDo([](const typename fakeit::test_arg<arglist>::type...) -> void { return DefaultValue<void>::value(); });
7275         }
7276 
7277         MethodStubbingProgress<void, arglist...> &
7278         Return(const Quantifier<void> &q) {
7279             auto method = [](const arglist &...) -> void { return DefaultValue<void>::value(); };
7280             return DoImpl(new Repeat<void, arglist...>(method, q.quantity));
7281         }
7282 
7283         template<typename E>
7284         MethodStubbingProgress<void, arglist...> &Throw(const E &e) {
7285             return Do([e](const typename fakeit::test_arg<arglist>::type...) -> void { throw e; });
7286         }
7287 
7288         template<typename E>
7289         MethodStubbingProgress<void, arglist...> &
7290         Throw(const Quantifier<E> &q) {
7291             const E &value = q.value;
7292             auto method = [value](const typename fakeit::test_arg<arglist>::type...) -> void { throw value; };
7293             return DoImpl(new Repeat<void, arglist...>(method, q.quantity));
7294         }
7295 
7296         template<typename first, typename second, typename ... tail>
7297         MethodStubbingProgress<void, arglist...> &
7298         Throw(const first &f, const second &s, const tail &... t) {
7299             Throw(f);
7300             return Throw(s, t...);
7301         }
7302 
7303         template<typename E>
7304         void AlwaysThrow(const E e) {
7305             return AlwaysDo([e](const typename fakeit::test_arg<arglist>::type...) -> void { throw e; });
7306         }
7307 
7308            template<typename F>
7309         MethodStubbingProgress<void, arglist...> &
7310         Do(const Quantifier<F> &q) {
7311             return DoImpl(new Repeat<void, arglist...>(q.value, q.quantity));
7312         }
7313 
7314         template<typename first, typename second, typename ... tail>
7315         MethodStubbingProgress<void, arglist...> &
7316         Do(const first &f, const second &s, const tail &... t) {
7317             Do(f);
7318             return Do(s, t...);
7319         }
7320 
7321         virtual void AlwaysDo(std::function<void(const typename fakeit::test_arg<arglist>::type...)> method) {
7322             DoImpl(new RepeatForever<void, arglist...>(method));
7323         }
7324 
7325     protected:
7326 
7327         virtual MethodStubbingProgress<void, arglist...> &DoImpl(Action<void, arglist...> *action) = 0;
7328 
7329     private:
7330         MethodStubbingProgress &operator=(const MethodStubbingProgress &other) = delete;
7331     };
7332 
7333 
7334 }
7335 #include <vector>
7336 #include <functional>
7337 
7338 namespace fakeit {
7339 
7340     class Finally {
7341     private:
7342         std::function<void()> _finallyClause;
7343 
7344         Finally(const Finally &);
7345 
7346         Finally &operator=(const Finally &);
7347 
7348     public:
7349         explicit Finally(std::function<void()> f) :
7350                 _finallyClause(f) {
7351         }
7352 
7353         ~Finally() {
7354             _finallyClause();
7355         }
7356     };
7357 }
7358 
7359 namespace fakeit {
7360 
7361 
7362     template<typename R, typename ... arglist>
7363     struct ActionSequence : ActualInvocationHandler<R,arglist...> {
7364 
7365         ActionSequence() {
7366             clear();
7367         }
7368 
7369         void AppendDo(Action<R, arglist...> *action) {
7370             append(action);
7371         }
7372 
7373         virtual R handleMethodInvocation(ArgumentsTuple<arglist...> & args) override
7374         {
7375             std::shared_ptr<Destructible> destructablePtr = _recordedActions.front();
7376             Destructible &destructable = *destructablePtr;
7377             Action<R, arglist...> &action = dynamic_cast<Action<R, arglist...> &>(destructable);
7378             std::function<void()> finallyClause = [&]() -> void {
7379                 if (action.isDone())
7380                     _recordedActions.erase(_recordedActions.begin());
7381             };
7382             Finally onExit(finallyClause);
7383             return action.invoke(args);
7384         }
7385 
7386     private:
7387 
7388         struct NoMoreRecordedAction : Action<R, arglist...> {
7389 
7390 
7391 
7392 
7393 
7394 
7395 
7396             virtual R invoke(const ArgumentsTuple<arglist...> &) override {
7397                 throw NoMoreRecordedActionException();
7398             }
7399 
7400             virtual bool isDone() override {
7401                 return false;
7402             }
7403         };
7404 
7405         void append(Action<R, arglist...> *action) {
7406             std::shared_ptr<Destructible> destructable{action};
7407             _recordedActions.insert(_recordedActions.end() - 1, destructable);
7408         }
7409 
7410         void clear() {
7411             _recordedActions.clear();
7412             auto actionPtr = std::shared_ptr<Destructible> {new NoMoreRecordedAction()};
7413             _recordedActions.push_back(actionPtr);
7414         }
7415 
7416         std::vector<std::shared_ptr<Destructible>> _recordedActions;
7417     };
7418 
7419 }
7420 
7421 namespace fakeit {
7422 
7423     template<typename C, typename DATA_TYPE>
7424     class DataMemberStubbingRoot {
7425     private:
7426 
7427     public:
7428         DataMemberStubbingRoot(const DataMemberStubbingRoot &) = default;
7429 
7430         DataMemberStubbingRoot() = default;
7431 
7432         void operator=(const DATA_TYPE&) {
7433         }
7434     };
7435 
7436 }
7437 #include <functional>
7438 #include <utility>
7439 #include <type_traits>
7440 #include <tuple>
7441 #include <memory>
7442 #include <vector>
7443 #include <unordered_set>
7444 #include <set>
7445 #include <iosfwd>
7446 
7447 namespace fakeit {
7448 
7449     struct Xaction {
7450         virtual void commit() = 0;
7451     };
7452 }
7453 
7454 namespace fakeit {
7455 
7456 
7457     template<typename R, typename ... arglist>
7458     struct SpyingContext : Xaction {
7459         virtual void appendAction(Action<R, arglist...> *action) = 0;
7460 
7461         virtual std::function<R(arglist&...)> getOriginalMethod() = 0;
7462     };
7463 }
7464 namespace fakeit {
7465 
7466 
7467     template<typename R, typename ... arglist>
7468     struct StubbingContext : public Xaction {
7469         virtual void appendAction(Action<R, arglist...> *action) = 0;
7470     };
7471 }
7472 #include <functional>
7473 #include <type_traits>
7474 #include <tuple>
7475 #include <memory>
7476 #include <vector>
7477 #include <unordered_set>
7478 
7479 
7480 namespace fakeit {
7481 
7482     template<unsigned int index, typename ... arglist>
7483     class MatchersCollector {
7484 
7485         std::vector<Destructible *> &_matchers;
7486 
7487     public:
7488 
7489 
7490         template<std::size_t N>
7491         using ArgType = typename std::tuple_element<N, std::tuple<arglist...>>::type;
7492 
7493         template<std::size_t N>
7494         using NakedArgType = typename naked_type<ArgType<index>>::type;
7495 
7496         template<std::size_t N>
7497         using ArgMatcherCreatorType = decltype(std::declval<TypedMatcherCreator<NakedArgType<N>>>());
7498 
7499         MatchersCollector(std::vector<Destructible *> &matchers)
7500                 : _matchers(matchers) {
7501         }
7502 
7503         void CollectMatchers() {
7504         }
7505 
7506         template<typename Head>
7507         typename std::enable_if<
7508                 std::is_constructible<NakedArgType<index>, Head>::value, void>
7509         ::type CollectMatchers(const Head &value) {
7510 
7511             TypedMatcher<NakedArgType<index>> *d = Eq<NakedArgType<index>>(value).createMatcher();
7512             _matchers.push_back(d);
7513         }
7514 
7515         template<typename Head, typename ...Tail>
7516         typename std::enable_if<
7517                 std::is_constructible<NakedArgType<index>, Head>::value
7518                 , void>
7519         ::type CollectMatchers(const Head &head, const Tail &... tail) {
7520             CollectMatchers(head);
7521             MatchersCollector<index + 1, arglist...> c(_matchers);
7522             c.CollectMatchers(tail...);
7523         }
7524 
7525         template<typename Head>
7526         typename std::enable_if<
7527                 std::is_base_of<TypedMatcherCreator<NakedArgType<index>>, Head>::value, void>
7528         ::type CollectMatchers(const Head &creator) {
7529             TypedMatcher<NakedArgType<index>> *d = creator.createMatcher();
7530             _matchers.push_back(d);
7531         }
7532 
7533         template<typename Head, typename ...Tail>
7534 
7535         typename std::enable_if<
7536                 std::is_base_of<TypedMatcherCreator<NakedArgType<index>>, Head>::value, void>
7537         ::type CollectMatchers(const Head &head, const Tail &... tail) {
7538             CollectMatchers(head);
7539             MatchersCollector<index + 1, arglist...> c(_matchers);
7540             c.CollectMatchers(tail...);
7541         }
7542 
7543         template<typename Head>
7544         typename std::enable_if<
7545                 std::is_same<AnyMatcher, Head>::value, void>
7546         ::type CollectMatchers(const Head &) {
7547             TypedMatcher<NakedArgType<index>> *d = Any<NakedArgType<index>>().createMatcher();
7548             _matchers.push_back(d);
7549         }
7550 
7551         template<typename Head, typename ...Tail>
7552         typename std::enable_if<
7553                 std::is_same<AnyMatcher, Head>::value, void>
7554         ::type CollectMatchers(const Head &head, const Tail &... tail) {
7555             CollectMatchers(head);
7556             MatchersCollector<index + 1, arglist...> c(_matchers);
7557             c.CollectMatchers(tail...);
7558         }
7559 
7560     };
7561 
7562 }
7563 
7564 namespace fakeit {
7565 
7566     template<typename R, typename ... arglist>
7567     class MethodMockingContext :
7568             public Sequence,
7569             public ActualInvocationsSource,
7570             public virtual StubbingContext<R, arglist...>,
7571             public virtual SpyingContext<R, arglist...>,
7572             private Invocation::Matcher {
7573     public:
7574 
7575         struct Context : Destructible {
7576 
7577 
7578             virtual typename std::function<R(arglist&...)> getOriginalMethod() = 0;
7579 
7580             virtual std::string getMethodName() = 0;
7581 
7582             virtual void addMethodInvocationHandler(typename ActualInvocation<arglist...>::Matcher *matcher,
7583                 ActualInvocationHandler<R, arglist...> *invocationHandler) = 0;
7584 
7585             virtual void scanActualInvocations(const std::function<void(ActualInvocation<arglist...> &)> &scanner) = 0;
7586 
7587             virtual void setMethodDetails(std::string mockName, std::string methodName) = 0;
7588 
7589             virtual bool isOfMethod(MethodInfo &method) = 0;
7590 
7591             virtual ActualInvocationsSource &getInvolvedMock() = 0;
7592         };
7593 
7594     private:
7595         class Implementation {
7596 
7597             Context *_stubbingContext;
7598             ActionSequence<R, arglist...> *_recordedActionSequence;
7599             typename ActualInvocation<arglist...>::Matcher *_invocationMatcher;
7600             bool _commited;
7601 
7602             Context &getStubbingContext() const {
7603                 return *_stubbingContext;
7604             }
7605 
7606         public:
7607 
7608             Implementation(Context *stubbingContext)
7609                     : _stubbingContext(stubbingContext),
7610                       _recordedActionSequence(new ActionSequence<R, arglist...>()),
7611                       _invocationMatcher
7612                               {
7613                                       new DefaultInvocationMatcher<arglist...>()}, _commited(false) {
7614             }
7615 
7616             ~Implementation() {
7617                 delete _stubbingContext;
7618                 if (!_commited) {
7619 
7620                     delete _recordedActionSequence;
7621                     delete _invocationMatcher;
7622                 }
7623             }
7624 
7625             ActionSequence<R, arglist...> &getRecordedActionSequence() {
7626                 return *_recordedActionSequence;
7627             }
7628 
7629             std::string format() const {
7630                 std::string s = getStubbingContext().getMethodName();
7631                 s += _invocationMatcher->format();
7632                 return s;
7633             }
7634 
7635             void getActualInvocations(std::unordered_set<Invocation *> &into) const {
7636                 auto scanner = [&](ActualInvocation<arglist...> &a) {
7637                     if (_invocationMatcher->matches(a)) {
7638                         into.insert(&a);
7639                     }
7640                 };
7641                 getStubbingContext().scanActualInvocations(scanner);
7642             }
7643 
7644 
7645             bool matches(Invocation &invocation) {
7646                 MethodInfo &actualMethod = invocation.getMethod();
7647                 if (!getStubbingContext().isOfMethod(actualMethod)) {
7648                     return false;
7649                 }
7650 
7651                 ActualInvocation<arglist...> &actualInvocation = dynamic_cast<ActualInvocation<arglist...> &>(invocation);
7652                 return _invocationMatcher->matches(actualInvocation);
7653             }
7654 
7655             void commit() {
7656                 getStubbingContext().addMethodInvocationHandler(_invocationMatcher, _recordedActionSequence);
7657                 _commited = true;
7658             }
7659 
7660             void appendAction(Action<R, arglist...> *action) {
7661                 getRecordedActionSequence().AppendDo(action);
7662             }
7663 
7664             void setMethodBodyByAssignment(std::function<R(const typename fakeit::test_arg<arglist>::type...)> method) {
7665                 appendAction(new RepeatForever<R, arglist...>(method));
7666                 commit();
7667             }
7668 
7669             void setMethodDetails(std::string mockName, std::string methodName) {
7670                 getStubbingContext().setMethodDetails(mockName, methodName);
7671             }
7672 
7673             void getInvolvedMocks(std::vector<ActualInvocationsSource *> &into) const {
7674                 into.push_back(&getStubbingContext().getInvolvedMock());
7675             }
7676 
7677             typename std::function<R(arglist &...)> getOriginalMethod() {
7678                 return getStubbingContext().getOriginalMethod();
7679             }
7680 
7681             void setInvocationMatcher(typename ActualInvocation<arglist...>::Matcher *matcher) {
7682                 delete _invocationMatcher;
7683                 _invocationMatcher = matcher;
7684             }
7685         };
7686 
7687     protected:
7688 
7689         MethodMockingContext(Context *stubbingContext)
7690                 : _impl{new Implementation(stubbingContext)} {
7691         }
7692 
7693         MethodMockingContext(MethodMockingContext &) = default;
7694 
7695 
7696 
7697         MethodMockingContext(MethodMockingContext &&other)
7698                 : _impl(std::move(other._impl)) {
7699         }
7700 
7701         virtual ~MethodMockingContext() NO_THROWS { }
7702 
7703         std::string format() const override {
7704             return _impl->format();
7705         }
7706 
7707         unsigned int size() const override {
7708             return 1;
7709         }
7710 
7711 
7712         void getInvolvedMocks(std::vector<ActualInvocationsSource *> &into) const override {
7713             _impl->getInvolvedMocks(into);
7714         }
7715 
7716         void getExpectedSequence(std::vector<Invocation::Matcher *> &into) const override {
7717             const Invocation::Matcher *b = this;
7718             Invocation::Matcher *c = const_cast<Invocation::Matcher *>(b);
7719             into.push_back(c);
7720         }
7721 
7722 
7723         void getActualInvocations(std::unordered_set<Invocation *> &into) const override {
7724             _impl->getActualInvocations(into);
7725         }
7726 
7727 
7728         bool matches(Invocation &invocation) override {
7729             return _impl->matches(invocation);
7730         }
7731 
7732         void commit() override {
7733             _impl->commit();
7734         }
7735 
7736         void setMethodDetails(std::string mockName, std::string methodName) {
7737             _impl->setMethodDetails(mockName, methodName);
7738         }
7739 
7740         void setMatchingCriteria(std::function<bool(arglist &...)> predicate) {
7741             typename ActualInvocation<arglist...>::Matcher *matcher{
7742                     new UserDefinedInvocationMatcher<arglist...>(predicate)};
7743             _impl->setInvocationMatcher(matcher);
7744         }
7745 
7746         void setMatchingCriteria(const std::vector<Destructible *> &matchers) {
7747             typename ActualInvocation<arglist...>::Matcher *matcher{
7748                     new ArgumentsMatcherInvocationMatcher<arglist...>(matchers)};
7749             _impl->setInvocationMatcher(matcher);
7750         }
7751 
7752 
7753         void appendAction(Action<R, arglist...> *action) override {
7754             _impl->appendAction(action);
7755         }
7756 
7757         void setMethodBodyByAssignment(std::function<R(const typename fakeit::test_arg<arglist>::type...)> method) {
7758             _impl->setMethodBodyByAssignment(method);
7759         }
7760 
7761         template<class ...matcherCreators, class = typename std::enable_if<
7762                 sizeof...(matcherCreators) == sizeof...(arglist)>::type>
7763         void setMatchingCriteria(const matcherCreators &... matcherCreator) {
7764             std::vector<Destructible *> matchers;
7765 
7766             MatchersCollector<0, arglist...> c(matchers);
7767             c.CollectMatchers(matcherCreator...);
7768 
7769             MethodMockingContext<R, arglist...>::setMatchingCriteria(matchers);
7770         }
7771 
7772     private:
7773 
7774         typename std::function<R(arglist&...)> getOriginalMethod() override {
7775             return _impl->getOriginalMethod();
7776         }
7777 
7778         std::shared_ptr<Implementation> _impl;
7779     };
7780 
7781     template<typename R, typename ... arglist>
7782     class MockingContext :
7783             public MethodMockingContext<R, arglist...> {
7784         MockingContext &operator=(const MockingContext &) = delete;
7785 
7786     public:
7787 
7788         MockingContext(typename MethodMockingContext<R, arglist...>::Context *stubbingContext)
7789                 : MethodMockingContext<R, arglist...>(stubbingContext) {
7790         }
7791 
7792         MockingContext(MockingContext &) = default;
7793 
7794         MockingContext(MockingContext &&other)
7795                 : MethodMockingContext<R, arglist...>(std::move(other)) {
7796         }
7797 
7798         MockingContext<R, arglist...> &setMethodDetails(std::string mockName, std::string methodName) {
7799             MethodMockingContext<R, arglist...>::setMethodDetails(mockName, methodName);
7800             return *this;
7801         }
7802 
7803         MockingContext<R, arglist...> &Using(const arglist &... args) {
7804             MethodMockingContext<R, arglist...>::setMatchingCriteria(args...);
7805             return *this;
7806         }
7807 
7808         template<class ...arg_matcher>
7809         MockingContext<R, arglist...> &Using(const arg_matcher &... arg_matchers) {
7810             MethodMockingContext<R, arglist...>::setMatchingCriteria(arg_matchers...);
7811             return *this;
7812         }
7813 
7814         MockingContext<R, arglist...> &Matching(std::function<bool(arglist &...)> matcher) {
7815             MethodMockingContext<R, arglist...>::setMatchingCriteria(matcher);
7816             return *this;
7817         }
7818 
7819         MockingContext<R, arglist...> &operator()(const arglist &... args) {
7820             MethodMockingContext<R, arglist...>::setMatchingCriteria(args...);
7821             return *this;
7822         }
7823 
7824         MockingContext<R, arglist...> &operator()(std::function<bool(arglist &...)> matcher) {
7825             MethodMockingContext<R, arglist...>::setMatchingCriteria(matcher);
7826             return *this;
7827         }
7828 
7829         void operator=(std::function<R(arglist &...)> method) {
7830             MethodMockingContext<R, arglist...>::setMethodBodyByAssignment(method);
7831         }
7832 
7833         template<typename U = R>
7834         typename std::enable_if<!std::is_reference<U>::value, void>::type operator=(const R &r) {
7835             auto method = [r](const typename fakeit::test_arg<arglist>::type...) -> R { return r; };
7836             MethodMockingContext<R, arglist...>::setMethodBodyByAssignment(method);
7837         }
7838 
7839         template<typename U = R>
7840         typename std::enable_if<std::is_reference<U>::value, void>::type operator=(const R &r) {
7841             auto method = [&r](const typename fakeit::test_arg<arglist>::type...) -> R { return r; };
7842             MethodMockingContext<R, arglist...>::setMethodBodyByAssignment(method);
7843         }
7844     };
7845 
7846     template<typename ... arglist>
7847     class MockingContext<void, arglist...> :
7848             public MethodMockingContext<void, arglist...> {
7849         MockingContext &operator=(const MockingContext &) = delete;
7850 
7851     public:
7852 
7853         MockingContext(typename MethodMockingContext<void, arglist...>::Context *stubbingContext)
7854                 : MethodMockingContext<void, arglist...>(stubbingContext) {
7855         }
7856 
7857         MockingContext(MockingContext &) = default;
7858 
7859         MockingContext(MockingContext &&other)
7860                 : MethodMockingContext<void, arglist...>(std::move(other)) {
7861         }
7862 
7863         MockingContext<void, arglist...> &setMethodDetails(std::string mockName, std::string methodName) {
7864             MethodMockingContext<void, arglist...>::setMethodDetails(mockName, methodName);
7865             return *this;
7866         }
7867 
7868         MockingContext<void, arglist...> &Using(const arglist &... args) {
7869             MethodMockingContext<void, arglist...>::setMatchingCriteria(args...);
7870             return *this;
7871         }
7872 
7873         template<class ...arg_matcher>
7874         MockingContext<void, arglist...> &Using(const arg_matcher &... arg_matchers) {
7875             MethodMockingContext<void, arglist...>::setMatchingCriteria(arg_matchers...);
7876             return *this;
7877         }
7878 
7879         MockingContext<void, arglist...> &Matching(std::function<bool(arglist &...)> matcher) {
7880             MethodMockingContext<void, arglist...>::setMatchingCriteria(matcher);
7881             return *this;
7882         }
7883 
7884         MockingContext<void, arglist...> &operator()(const arglist &... args) {
7885             MethodMockingContext<void, arglist...>::setMatchingCriteria(args...);
7886             return *this;
7887         }
7888 
7889         MockingContext<void, arglist...> &operator()(std::function<bool(arglist &...)> matcher) {
7890             MethodMockingContext<void, arglist...>::setMatchingCriteria(matcher);
7891             return *this;
7892         }
7893 
7894         void operator=(std::function<void(arglist &...)> method) {
7895             MethodMockingContext<void, arglist...>::setMethodBodyByAssignment(method);
7896         }
7897 
7898     };
7899 
7900     class DtorMockingContext : public MethodMockingContext<void> {
7901     public:
7902 
7903         DtorMockingContext(MethodMockingContext<void>::Context *stubbingContext)
7904                 : MethodMockingContext<void>(stubbingContext) {
7905         }
7906 
7907         DtorMockingContext(DtorMockingContext &other) : MethodMockingContext<void>(other) {
7908         }
7909 
7910         DtorMockingContext(DtorMockingContext &&other) : MethodMockingContext<void>(std::move(other)) {
7911         }
7912 
7913         void operator=(std::function<void()> method) {
7914             MethodMockingContext<void>::setMethodBodyByAssignment(method);
7915         }
7916 
7917         DtorMockingContext &setMethodDetails(std::string mockName, std::string methodName) {
7918             MethodMockingContext<void>::setMethodDetails(mockName, methodName);
7919             return *this;
7920         }
7921     };
7922 
7923 }
7924 
7925 namespace fakeit {
7926 
7927 
7928     template<typename C, typename ... baseclasses>
7929     class MockImpl : private MockObject<C>, public virtual ActualInvocationsSource {
7930     public:
7931 
7932         MockImpl(FakeitContext &fakeit, C &obj)
7933                 : MockImpl<C, baseclasses...>(fakeit, obj, true) {
7934         }
7935 
7936         MockImpl(FakeitContext &fakeit)
7937                 : MockImpl<C, baseclasses...>(fakeit, *(createFakeInstance()), false){
7938             FakeObject<C, baseclasses...> *fake = asFakeObject(_instanceOwner.get());
7939             fake->getVirtualTable().setCookie(1, this);
7940         }
7941 
7942         virtual ~MockImpl() NO_THROWS {
7943             _proxy.detach();
7944         }
7945 
7946 
7947         void getActualInvocations(std::unordered_set<Invocation *> &into) const override {
7948             std::vector<ActualInvocationsSource *> vec;
7949             _proxy.getMethodMocks(vec);
7950             for (ActualInvocationsSource *s : vec) {
7951                 s->getActualInvocations(into);
7952             }
7953         }
7954 
7955         void initDataMembersIfOwner()
7956         {
7957             if (isOwner()) {
7958                 FakeObject<C, baseclasses...> *fake = asFakeObject(_instanceOwner.get());
7959                 fake->initializeDataMembersArea();
7960             }
7961         }
7962 
7963         void reset() {
7964             _proxy.Reset();
7965             initDataMembersIfOwner();
7966         }
7967 
7968         void clear()
7969         {
7970             std::vector<ActualInvocationsContainer *> vec;
7971             _proxy.getMethodMocks(vec);
7972             for (ActualInvocationsContainer *s : vec) {
7973                 s->clear();
7974             }
7975             initDataMembersIfOwner();
7976         }
7977 
7978         virtual C &get() override {
7979             return _proxy.get();
7980         }
7981 
7982         virtual FakeitContext &getFakeIt() override {
7983             return _fakeit;
7984         }
7985 
7986         template<class DATA_TYPE, typename T, typename ... arglist, class = typename std::enable_if<std::is_base_of<T, C>::value>::type>
7987         DataMemberStubbingRoot<C, DATA_TYPE> stubDataMember(DATA_TYPE T::*member, const arglist &... ctorargs) {
7988             _proxy.stubDataMember(member, ctorargs...);
7989             return DataMemberStubbingRoot<T, DATA_TYPE>();
7990         }
7991 
7992         template<int id, typename R, typename T, typename ... arglist, class = typename std::enable_if<std::is_base_of<T, C>::value>::type>
7993         MockingContext<R, arglist...> stubMethod(R(T::*vMethod)(arglist...)) {
7994             return MockingContext<R, arglist...>(new UniqueMethodMockingContextImpl < id, R, arglist... >
7995                    (*this, vMethod));
7996         }
7997 
7998         DtorMockingContext stubDtor() {
7999             return DtorMockingContext(new DtorMockingContextImpl(*this));
8000         }
8001 
8002 
8003 
8004 
8005 
8006 
8007 
8008     private:
8009 
8010 
8011 
8012 
8013 
8014 
8015 
8016 
8017 
8018         std::shared_ptr<FakeObject<C, baseclasses...>> _instanceOwner;
8019         DynamicProxy<C, baseclasses...> _proxy;
8020         FakeitContext &_fakeit;
8021 
8022         MockImpl(FakeitContext &fakeit, C &obj, bool isSpy)
8023                 : _instanceOwner(isSpy ? nullptr : asFakeObject(&obj))
8024                 , _proxy{obj}
8025                 , _fakeit(fakeit) {}
8026 
8027         static FakeObject<C, baseclasses...>* asFakeObject(void* instance){
8028             return reinterpret_cast<FakeObject<C, baseclasses...> *>(instance);
8029         }
8030 
8031         template<typename R, typename ... arglist>
8032         class MethodMockingContextBase : public MethodMockingContext<R, arglist...>::Context {
8033         protected:
8034             MockImpl<C, baseclasses...> &_mock;
8035 
8036             virtual RecordedMethodBody<R, arglist...> &getRecordedMethodBody() = 0;
8037 
8038         public:
8039             MethodMockingContextBase(MockImpl<C, baseclasses...> &mock) : _mock(mock) { }
8040 
8041             virtual ~MethodMockingContextBase() = default;
8042 
8043             void addMethodInvocationHandler(typename ActualInvocation<arglist...>::Matcher *matcher,
8044                 ActualInvocationHandler<R, arglist...> *invocationHandler) {
8045                 getRecordedMethodBody().addMethodInvocationHandler(matcher, invocationHandler);
8046             }
8047 
8048             void scanActualInvocations(const std::function<void(ActualInvocation<arglist...> &)> &scanner) {
8049                 getRecordedMethodBody().scanActualInvocations(scanner);
8050             }
8051 
8052             void setMethodDetails(std::string mockName, std::string methodName) {
8053                 getRecordedMethodBody().setMethodDetails(mockName, methodName);
8054             }
8055 
8056             bool isOfMethod(MethodInfo &method) {
8057                 return getRecordedMethodBody().isOfMethod(method);
8058             }
8059 
8060             ActualInvocationsSource &getInvolvedMock() {
8061                 return _mock;
8062             }
8063 
8064             std::string getMethodName() {
8065                 return getRecordedMethodBody().getMethod().name();
8066             }
8067 
8068         };
8069 
8070         template<typename R, typename ... arglist>
8071         class MethodMockingContextImpl : public MethodMockingContextBase<R, arglist...> {
8072         protected:
8073 
8074             R (C::*_vMethod)(arglist...);
8075 
8076         public:
8077             virtual ~MethodMockingContextImpl() = default;
8078 
8079             MethodMockingContextImpl(MockImpl<C, baseclasses...> &mock, R (C::*vMethod)(arglist...))
8080                     : MethodMockingContextBase<R, arglist...>(mock), _vMethod(vMethod) {
8081             }
8082 
8083 
8084             virtual std::function<R(arglist&...)> getOriginalMethod() override {
8085                 void *mPtr = MethodMockingContextBase<R, arglist...>::_mock.getOriginalMethod(_vMethod);
8086                 C * instance = &(MethodMockingContextBase<R, arglist...>::_mock.get());
8087                 return [=](arglist&... args) -> R {
8088                     auto m = union_cast<typename VTableMethodType<R,arglist...>::type>(mPtr);
8089                     return m(instance, std::forward<arglist>(args)...);
8090                 };
8091             }
8092         };
8093 
8094 
8095         template<int id, typename R, typename ... arglist>
8096         class UniqueMethodMockingContextImpl : public MethodMockingContextImpl<R, arglist...> {
8097         protected:
8098 
8099             virtual RecordedMethodBody<R, arglist...> &getRecordedMethodBody() override {
8100                 return MethodMockingContextBase<R, arglist...>::_mock.template stubMethodIfNotStubbed<id>(
8101                         MethodMockingContextBase<R, arglist...>::_mock._proxy,
8102                         MethodMockingContextImpl<R, arglist...>::_vMethod);
8103             }
8104 
8105         public:
8106 
8107             UniqueMethodMockingContextImpl(MockImpl<C, baseclasses...> &mock, R (C::*vMethod)(arglist...))
8108                     : MethodMockingContextImpl<R, arglist...>(mock, vMethod) {
8109             }
8110         };
8111 
8112         class DtorMockingContextImpl : public MethodMockingContextBase<void> {
8113 
8114         protected:
8115 
8116             virtual RecordedMethodBody<void> &getRecordedMethodBody() override {
8117                 return MethodMockingContextBase<void>::_mock.stubDtorIfNotStubbed(
8118                         MethodMockingContextBase<void>::_mock._proxy);
8119             }
8120 
8121         public:
8122             virtual ~DtorMockingContextImpl() = default;
8123 
8124             DtorMockingContextImpl(MockImpl<C, baseclasses...> &mock)
8125                     : MethodMockingContextBase<void>(mock) {
8126             }
8127 
8128             virtual std::function<void()> getOriginalMethod() override {
8129                 C &instance = MethodMockingContextBase<void>::_mock.get();
8130                 return [=, &instance]() -> void {
8131                 };
8132             }
8133 
8134         };
8135 
8136         static MockImpl<C, baseclasses...> *getMockImpl(void *instance) {
8137             FakeObject<C, baseclasses...> *fake = asFakeObject(instance);
8138             MockImpl<C, baseclasses...> *mock = reinterpret_cast<MockImpl<C, baseclasses...> *>(fake->getVirtualTable().getCookie(
8139                     1));
8140             return mock;
8141         }
8142 
8143         bool isOwner(){ return _instanceOwner != nullptr;}
8144 
8145         void unmockedDtor() {}
8146 
8147         void unmocked() {
8148             ActualInvocation<> invocation(Invocation::nextInvocationOrdinal(), UnknownMethod::instance());
8149             UnexpectedMethodCallEvent event(UnexpectedType::Unmocked, invocation);
8150             auto &fakeit = getMockImpl(this)->_fakeit;
8151             fakeit.handle(event);
8152 
8153             std::string format = fakeit.format(event);
8154             UnexpectedMethodCallException e(format);
8155             throw e;
8156         }
8157 
8158         static C *createFakeInstance() {
8159             FakeObject<C, baseclasses...> *fake = new FakeObject<C, baseclasses...>();
8160             void *unmockedMethodStubPtr = union_cast<void *>(&MockImpl<C, baseclasses...>::unmocked);
8161             void *unmockedDtorStubPtr = union_cast<void *>(&MockImpl<C, baseclasses...>::unmockedDtor);
8162             fake->getVirtualTable().initAll(unmockedMethodStubPtr);
8163             if (VTUtils::hasVirtualDestructor<C>())
8164                 fake->setDtor(unmockedDtorStubPtr);
8165             return reinterpret_cast<C *>(fake);
8166         }
8167 
8168         template<typename R, typename ... arglist>
8169         void *getOriginalMethod(R (C::*vMethod)(arglist...)) {
8170             auto vt = _proxy.getOriginalVT();
8171             auto offset = VTUtils::getOffset(vMethod);
8172             void *origMethodPtr = vt.getMethod(offset);
8173             return origMethodPtr;
8174         }
8175 
8176         void *getOriginalDtor() {
8177             auto vt = _proxy.getOriginalVT();
8178             auto offset = VTUtils::getDestructorOffset<C>();
8179             void *origMethodPtr = vt.getMethod(offset);
8180             return origMethodPtr;
8181         }
8182 
8183         template<unsigned int id, typename R, typename ... arglist>
8184         RecordedMethodBody<R, arglist...> &stubMethodIfNotStubbed(DynamicProxy<C, baseclasses...> &proxy,
8185                                                                   R (C::*vMethod)(arglist...)) {
8186             if (!proxy.isMethodStubbed(vMethod)) {
8187                 proxy.template stubMethod<id>(vMethod, createRecordedMethodBody < R, arglist... > (*this, vMethod));
8188             }
8189             Destructible *d = proxy.getMethodMock(vMethod);
8190             RecordedMethodBody<R, arglist...> *methodMock = dynamic_cast<RecordedMethodBody<R, arglist...> *>(d);
8191             return *methodMock;
8192         }
8193 
8194         RecordedMethodBody<void> &stubDtorIfNotStubbed(DynamicProxy<C, baseclasses...> &proxy) {
8195             if (!proxy.isDtorStubbed()) {
8196                 proxy.stubDtor(createRecordedDtorBody(*this));
8197             }
8198             Destructible *d = proxy.getDtorMock();
8199             RecordedMethodBody<void> *dtorMock = dynamic_cast<RecordedMethodBody<void> *>(d);
8200             return *dtorMock;
8201         }
8202 
8203         template<typename R, typename ... arglist>
8204         static RecordedMethodBody<R, arglist...> *createRecordedMethodBody(MockObject<C> &mock,
8205                                                                            R(C::*vMethod)(arglist...)) {
8206             return new RecordedMethodBody<R, arglist...>(mock.getFakeIt(), typeid(vMethod).name());
8207         }
8208 
8209         static RecordedMethodBody<void> *createRecordedDtorBody(MockObject<C> &mock) {
8210             return new RecordedMethodBody<void>(mock.getFakeIt(), "dtor");
8211         }
8212     };
8213 }
8214 namespace fakeit {
8215 
8216     template<typename R, typename... Args>
8217     struct Prototype;
8218 
8219     template<typename R, typename... Args>
8220     struct Prototype<R(Args...)> {
8221 
8222         typedef R Type(Args...);
8223 
8224         typedef R ConstType(Args...) const;
8225 
8226         template<class C>
8227         struct MemberType {
8228 
8229             typedef Type(C::*type);
8230             typedef ConstType(C::*cosntType);
8231 
8232             static type get(type t) {
8233                 return t;
8234             }
8235 
8236             static cosntType getconst(cosntType t) {
8237                 return t;
8238             }
8239 
8240         };
8241 
8242     };
8243 
8244     template<int X, typename R, typename C, typename... arglist>
8245     struct UniqueMethod {
8246         R (C::*method)(arglist...);
8247 
8248         UniqueMethod(R (C::*vMethod)(arglist...)) : method(vMethod) { }
8249 
8250         int uniqueId() {
8251             return X;
8252         }
8253 
8254 
8255 
8256 
8257     };
8258 
8259 }
8260 
8261 
8262 namespace fakeit {
8263     namespace internal {
8264     }
8265     using namespace fakeit::internal;
8266 
8267     template<typename C, typename ... baseclasses>
8268     class Mock : public ActualInvocationsSource {
8269         MockImpl<C, baseclasses...> impl;
8270     public:
8271         virtual ~Mock() = default;
8272 
8273         static_assert(std::is_polymorphic<C>::value, "Can only mock a polymorphic type");
8274 
8275         Mock() : impl(Fakeit) {
8276         }
8277 
8278         explicit Mock(C &obj) : impl(Fakeit, obj) {
8279         }
8280 
8281         virtual C &get() {
8282             return impl.get();
8283         }
8284 
8285 
8286 
8287 
8288 
8289         C &operator()() {
8290             return get();
8291         }
8292 
8293         void Reset() {
8294             impl.reset();
8295         }
8296 
8297         void ClearInvocationHistory() {
8298             impl.clear();
8299         }
8300 
8301         template<class DATA_TYPE, typename ... arglist,
8302                 class = typename std::enable_if<std::is_member_object_pointer<DATA_TYPE C::*>::value>::type>
8303         DataMemberStubbingRoot<C, DATA_TYPE> Stub(DATA_TYPE C::* member, const arglist &... ctorargs) {
8304             return impl.stubDataMember(member, ctorargs...);
8305         }
8306 
8307         template<int id, typename R, typename T, typename ... arglist, class = typename std::enable_if<
8308                 !std::is_void<R>::value && std::is_base_of<T, C>::value>::type>
8309         MockingContext<R, arglist...> stub(R (T::*vMethod)(arglist...) const) {
8310             auto methodWithoutConstVolatile = reinterpret_cast<R (T::*)(arglist...)>(vMethod);
8311             return impl.template stubMethod<id>(methodWithoutConstVolatile);
8312         }
8313 
8314         template<int id, typename R, typename T, typename... arglist, class = typename std::enable_if<
8315                 !std::is_void<R>::value && std::is_base_of<T, C>::value>::type>
8316         MockingContext<R, arglist...> stub(R(T::*vMethod)(arglist...) volatile) {
8317             auto methodWithoutConstVolatile = reinterpret_cast<R(T::*)(arglist...)>(vMethod);
8318             return impl.template stubMethod<id>(methodWithoutConstVolatile);
8319         }
8320 
8321         template<int id, typename R, typename T, typename... arglist, class = typename std::enable_if<
8322                 !std::is_void<R>::value && std::is_base_of<T, C>::value>::type>
8323         MockingContext<R, arglist...> stub(R(T::*vMethod)(arglist...) const volatile) {
8324             auto methodWithoutConstVolatile = reinterpret_cast<R(T::*)(arglist...)>(vMethod);
8325             return impl.template stubMethod<id>(methodWithoutConstVolatile);
8326         }
8327 
8328         template<int id, typename R, typename T, typename... arglist, class = typename std::enable_if<
8329                 !std::is_void<R>::value && std::is_base_of<T, C>::value>::type>
8330         MockingContext<R, arglist...> stub(R(T::*vMethod)(arglist...)) {
8331             return impl.template stubMethod<id>(vMethod);
8332         }
8333 
8334         template<int id, typename R, typename T, typename... arglist, class = typename std::enable_if<
8335                 std::is_void<R>::value && std::is_base_of<T, C>::value>::type>
8336         MockingContext<void, arglist...> stub(R(T::*vMethod)(arglist...) const) {
8337             auto methodWithoutConstVolatile = reinterpret_cast<void (T::*)(arglist...)>(vMethod);
8338             return impl.template stubMethod<id>(methodWithoutConstVolatile);
8339         }
8340 
8341         template<int id, typename R, typename T, typename... arglist, class = typename std::enable_if<
8342                 std::is_void<R>::value && std::is_base_of<T, C>::value>::type>
8343         MockingContext<void, arglist...> stub(R(T::*vMethod)(arglist...) volatile) {
8344             auto methodWithoutConstVolatile = reinterpret_cast<void (T::*)(arglist...)>(vMethod);
8345             return impl.template stubMethod<id>(methodWithoutConstVolatile);
8346         }
8347 
8348         template<int id, typename R, typename T, typename... arglist, class = typename std::enable_if<
8349                 std::is_void<R>::value && std::is_base_of<T, C>::value>::type>
8350         MockingContext<void, arglist...> stub(R(T::*vMethod)(arglist...) const volatile) {
8351             auto methodWithoutConstVolatile = reinterpret_cast<void (T::*)(arglist...)>(vMethod);
8352             return impl.template stubMethod<id>(methodWithoutConstVolatile);
8353         }
8354 
8355         template<int id, typename R, typename T, typename... arglist, class = typename std::enable_if<
8356                 std::is_void<R>::value && std::is_base_of<T, C>::value>::type>
8357         MockingContext<void, arglist...> stub(R(T::*vMethod)(arglist...)) {
8358             auto methodWithoutConstVolatile = reinterpret_cast<void (T::*)(arglist...)>(vMethod);
8359             return impl.template stubMethod<id>(methodWithoutConstVolatile);
8360         }
8361 
8362         DtorMockingContext dtor() {
8363             return impl.stubDtor();
8364         }
8365 
8366         void getActualInvocations(std::unordered_set<Invocation *> &into) const override {
8367             impl.getActualInvocations(into);
8368         }
8369 
8370     };
8371 
8372 }
8373 
8374 #include <exception>
8375 
8376 namespace fakeit {
8377 
8378     class RefCount {
8379     private:
8380         int count;
8381 
8382     public:
8383         void AddRef() {
8384             count++;
8385         }
8386 
8387         int Release() {
8388             return --count;
8389         }
8390     };
8391 
8392     template<typename T>
8393     class smart_ptr {
8394     private:
8395         T *pData;
8396         RefCount *reference;
8397 
8398     public:
8399         smart_ptr() : pData(0), reference(0) {
8400             reference = new RefCount();
8401             reference->AddRef();
8402         }
8403 
8404         smart_ptr(T *pValue) : pData(pValue), reference(0) {
8405             reference = new RefCount();
8406             reference->AddRef();
8407         }
8408 
8409         smart_ptr(const smart_ptr<T> &sp) : pData(sp.pData), reference(sp.reference) {
8410             reference->AddRef();
8411         }
8412 
8413         ~smart_ptr() THROWS {
8414             if (reference->Release() == 0) {
8415                 delete reference;
8416                 delete pData;
8417             }
8418         }
8419 
8420         T &operator*() {
8421             return *pData;
8422         }
8423 
8424         T *operator->() {
8425             return pData;
8426         }
8427 
8428         smart_ptr<T> &operator=(const smart_ptr<T> &sp) {
8429             if (this != &sp) {
8430 
8431 
8432                 if (reference->Release() == 0) {
8433                     delete reference;
8434                     delete pData;
8435                 }
8436 
8437 
8438 
8439                 pData = sp.pData;
8440                 reference = sp.reference;
8441                 reference->AddRef();
8442             }
8443             return *this;
8444         }
8445     };
8446 
8447 }
8448 
8449 namespace fakeit {
8450 
8451     class WhenFunctor {
8452 
8453         struct StubbingChange {
8454 
8455             friend class WhenFunctor;
8456 
8457             virtual ~StubbingChange() THROWS {
8458 
8459                 if (std::uncaught_exception()) {
8460                     return;
8461                 }
8462 
8463                 _xaction.commit();
8464             }
8465 
8466             StubbingChange(StubbingChange &other) :
8467                     _xaction(other._xaction) {
8468             }
8469 
8470         private:
8471 
8472             StubbingChange(Xaction &xaction)
8473                     : _xaction(xaction) {
8474             }
8475 
8476             Xaction &_xaction;
8477         };
8478 
8479     public:
8480 
8481         template<typename R, typename ... arglist>
8482         struct MethodProgress : MethodStubbingProgress<R, arglist...> {
8483 
8484             friend class WhenFunctor;
8485 
8486             virtual ~MethodProgress() override = default;
8487 
8488             MethodProgress(MethodProgress &other) :
8489                     _progress(other._progress), _context(other._context) {
8490             }
8491 
8492             MethodProgress(StubbingContext<R, arglist...> &xaction) :
8493                     _progress(new StubbingChange(xaction)), _context(xaction) {
8494             }
8495 
8496         protected:
8497 
8498             virtual MethodStubbingProgress<R, arglist...> &DoImpl(Action<R, arglist...> *action) override {
8499                 _context.appendAction(action);
8500                 return *this;
8501             }
8502 
8503         private:
8504             smart_ptr<StubbingChange> _progress;
8505             StubbingContext<R, arglist...> &_context;
8506         };
8507 
8508 
8509         WhenFunctor() {
8510         }
8511 
8512         template<typename R, typename ... arglist>
8513         MethodProgress<R, arglist...> operator()(const StubbingContext<R, arglist...> &stubbingContext) {
8514             StubbingContext<R, arglist...> &rootWithoutConst = const_cast<StubbingContext<R, arglist...> &>(stubbingContext);
8515             MethodProgress<R, arglist...> progress(rootWithoutConst);
8516             return progress;
8517         }
8518 
8519     };
8520 
8521 }
8522 namespace fakeit {
8523 
8524     class FakeFunctor {
8525     private:
8526         template<typename R, typename ... arglist>
8527         void fake(const StubbingContext<R, arglist...> &root) {
8528             StubbingContext<R, arglist...> &rootWithoutConst = const_cast<StubbingContext<R, arglist...> &>(root);
8529             rootWithoutConst.appendAction(new ReturnDefaultValue<R, arglist...>());
8530             rootWithoutConst.commit();
8531         }
8532 
8533         void operator()() {
8534         }
8535 
8536     public:
8537 
8538         template<typename H, typename ... M>
8539         void operator()(const H &head, const M &... tail) {
8540             fake(head);
8541             this->operator()(tail...);
8542         }
8543 
8544     };
8545 
8546 }
8547 #include <set>
8548 #include <set>
8549 
8550 
8551 namespace fakeit {
8552 
8553     struct InvocationUtils {
8554 
8555         static void sortByInvocationOrder(std::unordered_set<Invocation *> &ivocations,
8556                                           std::vector<Invocation *> &result) {
8557             auto comparator = [](Invocation *a, Invocation *b) -> bool {
8558                 return a->getOrdinal() < b->getOrdinal();
8559             };
8560             std::set<Invocation *, bool (*)(Invocation *a, Invocation *b)> sortedIvocations(comparator);
8561             for (auto i : ivocations)
8562                 sortedIvocations.insert(i);
8563 
8564             for (auto i : sortedIvocations)
8565                 result.push_back(i);
8566         }
8567 
8568         static void collectActualInvocations(std::unordered_set<Invocation *> &actualInvocations,
8569                                              std::vector<ActualInvocationsSource *> &invocationSources) {
8570             for (auto source : invocationSources) {
8571                 source->getActualInvocations(actualInvocations);
8572             }
8573         }
8574 
8575         static void selectNonVerifiedInvocations(std::unordered_set<Invocation *> &actualInvocations,
8576                                                  std::unordered_set<Invocation *> &into) {
8577             for (auto invocation : actualInvocations) {
8578                 if (!invocation->isVerified()) {
8579                     into.insert(invocation);
8580                 }
8581             }
8582         }
8583 
8584         static void collectInvocationSources(std::vector<ActualInvocationsSource *> &) {
8585         }
8586 
8587         template<typename ... list>
8588         static void collectInvocationSources(std::vector<ActualInvocationsSource *> &into,
8589                                              const ActualInvocationsSource &mock,
8590                                              const list &... tail) {
8591             into.push_back(const_cast<ActualInvocationsSource *>(&mock));
8592             collectInvocationSources(into, tail...);
8593         }
8594 
8595         static void collectSequences(std::vector<Sequence *> &) {
8596         }
8597 
8598         template<typename ... list>
8599         static void collectSequences(std::vector<Sequence *> &vec, const Sequence &sequence, const list &... tail) {
8600             vec.push_back(&const_cast<Sequence &>(sequence));
8601             collectSequences(vec, tail...);
8602         }
8603 
8604         static void collectInvolvedMocks(std::vector<Sequence *> &allSequences,
8605                                          std::vector<ActualInvocationsSource *> &involvedMocks) {
8606             for (auto sequence : allSequences) {
8607                 sequence->getInvolvedMocks(involvedMocks);
8608             }
8609         }
8610 
8611         template<class T>
8612         static T &remove_const(const T &s) {
8613             return const_cast<T &>(s);
8614         }
8615 
8616     };
8617 
8618 }
8619 
8620 #include <memory>
8621 
8622 #include <vector>
8623 #include <unordered_set>
8624 
8625 namespace fakeit {
8626     struct MatchAnalysis {
8627         std::vector<Invocation *> actualSequence;
8628         std::vector<Invocation *> matchedInvocations;
8629         int count;
8630 
8631         void run(InvocationsSourceProxy &involvedInvocationSources, std::vector<Sequence *> &expectedPattern) {
8632             getActualInvocationSequence(involvedInvocationSources, actualSequence);
8633             count = countMatches(expectedPattern, actualSequence, matchedInvocations);
8634         }
8635 
8636     private:
8637         static void getActualInvocationSequence(InvocationsSourceProxy &involvedMocks,
8638                                                 std::vector<Invocation *> &actualSequence) {
8639             std::unordered_set<Invocation *> actualInvocations;
8640             collectActualInvocations(involvedMocks, actualInvocations);
8641             InvocationUtils::sortByInvocationOrder(actualInvocations, actualSequence);
8642         }
8643 
8644         static int countMatches(std::vector<Sequence *> &pattern, std::vector<Invocation *> &actualSequence,
8645                                 std::vector<Invocation *> &matchedInvocations) {
8646             int end = -1;
8647             int count = 0;
8648             int startSearchIndex = 0;
8649             while (findNextMatch(pattern, actualSequence, startSearchIndex, end, matchedInvocations)) {
8650                 count++;
8651                 startSearchIndex = end;
8652             }
8653             return count;
8654         }
8655 
8656         static void collectActualInvocations(InvocationsSourceProxy &involvedMocks,
8657                                              std::unordered_set<Invocation *> &actualInvocations) {
8658             involvedMocks.getActualInvocations(actualInvocations);
8659         }
8660 
8661         static bool findNextMatch(std::vector<Sequence *> &pattern, std::vector<Invocation *> &actualSequence,
8662                                   int startSearchIndex, int &end,
8663                                   std::vector<Invocation *> &matchedInvocations) {
8664             for (auto sequence : pattern) {
8665                 int index = findNextMatch(sequence, actualSequence, startSearchIndex);
8666                 if (index == -1) {
8667                     return false;
8668                 }
8669                 collectMatchedInvocations(actualSequence, matchedInvocations, index, sequence->size());
8670                 startSearchIndex = index + sequence->size();
8671             }
8672             end = startSearchIndex;
8673             return true;
8674         }
8675 
8676 
8677         static void collectMatchedInvocations(std::vector<Invocation *> &actualSequence,
8678                                               std::vector<Invocation *> &matchedInvocations, int start,
8679                                               int length) {
8680             int indexAfterMatchedPattern = start + length;
8681             for (; start < indexAfterMatchedPattern; start++) {
8682                 matchedInvocations.push_back(actualSequence[start]);
8683             }
8684         }
8685 
8686 
8687         static bool isMatch(std::vector<Invocation *> &actualSequence,
8688                             std::vector<Invocation::Matcher *> &expectedSequence, int start) {
8689             bool found = true;
8690             for (unsigned int j = 0; found && j < expectedSequence.size(); j++) {
8691                 Invocation *actual = actualSequence[start + j];
8692                 Invocation::Matcher *expected = expectedSequence[j];
8693                 found = found && expected->matches(*actual);
8694             }
8695             return found;
8696         }
8697 
8698         static int findNextMatch(Sequence *&pattern, std::vector<Invocation *> &actualSequence, int startSearchIndex) {
8699             std::vector<Invocation::Matcher *> expectedSequence;
8700             pattern->getExpectedSequence(expectedSequence);
8701             for (int i = startSearchIndex; i < ((int) actualSequence.size() - (int) expectedSequence.size() + 1); i++) {
8702                 if (isMatch(actualSequence, expectedSequence, i)) {
8703                     return i;
8704                 }
8705             }
8706             return -1;
8707         }
8708 
8709     };
8710 }
8711 
8712 namespace fakeit {
8713 
8714     struct SequenceVerificationExpectation {
8715 
8716         friend class SequenceVerificationProgress;
8717 
8718         ~SequenceVerificationExpectation() THROWS {
8719             if (std::uncaught_exception()) {
8720                 return;
8721             }
8722             VerifyExpectation(_fakeit);
8723         }
8724 
8725         void setExpectedPattern(std::vector<Sequence *> expectedPattern) {
8726             _expectedPattern = expectedPattern;
8727         }
8728 
8729         void setExpectedCount(const int count) {
8730             _expectedCount = count;
8731         }
8732 
8733         void setFileInfo(const char * file, int line, const char * callingMethod) {
8734             _file = file;
8735             _line = line;
8736             _testMethod = callingMethod;
8737         }
8738 
8739     private:
8740 
8741         VerificationEventHandler &_fakeit;
8742         InvocationsSourceProxy _involvedInvocationSources;
8743         std::vector<Sequence *> _expectedPattern;
8744         int _expectedCount;
8745 
8746         const char * _file;
8747         int _line;
8748         const char * _testMethod;
8749         bool _isVerified;
8750 
8751         SequenceVerificationExpectation(
8752                 VerificationEventHandler &fakeit,
8753                 InvocationsSourceProxy mocks,
8754                 std::vector<Sequence *> &expectedPattern) :
8755                 _fakeit(fakeit),
8756                 _involvedInvocationSources(mocks),
8757                 _expectedPattern(expectedPattern),
8758                 _expectedCount(-1),
8759                 _line(0),
8760                 _isVerified(false) {
8761         }
8762 
8763 
8764         void VerifyExpectation(VerificationEventHandler &verificationErrorHandler) {
8765             if (_isVerified)
8766                 return;
8767             _isVerified = true;
8768 
8769             MatchAnalysis ma;
8770             ma.run(_involvedInvocationSources, _expectedPattern);
8771 
8772             if (isAtLeastVerification() && atLeastLimitNotReached(ma.count)) {
8773                 return handleAtLeastVerificationEvent(verificationErrorHandler, ma.actualSequence, ma.count);
8774             }
8775 
8776             if (isExactVerification() && exactLimitNotMatched(ma.count)) {
8777                 return handleExactVerificationEvent(verificationErrorHandler, ma.actualSequence, ma.count);
8778             }
8779 
8780             markAsVerified(ma.matchedInvocations);
8781         }
8782 
8783         std::vector<Sequence *> &collectSequences(std::vector<Sequence *> &vec) {
8784             return vec;
8785         }
8786 
8787         template<typename ... list>
8788         std::vector<Sequence *> &collectSequences(std::vector<Sequence *> &vec, const Sequence &sequence,
8789                                                   const list &... tail) {
8790             vec.push_back(&const_cast<Sequence &>(sequence));
8791             return collectSequences(vec, tail...);
8792         }
8793 
8794 
8795         static void markAsVerified(std::vector<Invocation *> &matchedInvocations) {
8796             for (auto i : matchedInvocations) {
8797                 i->markAsVerified();
8798             }
8799         }
8800 
8801         bool isAtLeastVerification() {
8802 
8803             return _expectedCount < 0;
8804         }
8805 
8806         bool isExactVerification() {
8807             return !isAtLeastVerification();
8808         }
8809 
8810         bool atLeastLimitNotReached(int actualCount) {
8811             return actualCount < -_expectedCount;
8812         }
8813 
8814         bool exactLimitNotMatched(int actualCount) {
8815             return actualCount != _expectedCount;
8816         }
8817 
8818         void handleExactVerificationEvent(VerificationEventHandler &verificationErrorHandler,
8819                                           std::vector<Invocation *> actualSequence, int count) {
8820             SequenceVerificationEvent evt(VerificationType::Exact, _expectedPattern, actualSequence, _expectedCount,
8821                                           count);
8822             evt.setFileInfo(_file, _line, _testMethod);
8823             return verificationErrorHandler.handle(evt);
8824         }
8825 
8826         void handleAtLeastVerificationEvent(VerificationEventHandler &verificationErrorHandler,
8827                                             std::vector<Invocation *> actualSequence, int count) {
8828             SequenceVerificationEvent evt(VerificationType::AtLeast, _expectedPattern, actualSequence, -_expectedCount,
8829                                           count);
8830             evt.setFileInfo(_file, _line, _testMethod);
8831             return verificationErrorHandler.handle(evt);
8832         }
8833 
8834     };
8835 
8836 }
8837 namespace fakeit {
8838     class ThrowFalseEventHandler : public VerificationEventHandler {
8839 
8840         void handle(const SequenceVerificationEvent &) override {
8841             throw false;
8842         }
8843 
8844         void handle(const NoMoreInvocationsVerificationEvent &) override {
8845             throw false;
8846         }
8847     };
8848 }
8849 
8850 
8851 namespace fakeit {
8852 
8853     struct FakeitContext;
8854 
8855     class SequenceVerificationProgress {
8856 
8857         friend class UsingFunctor;
8858 
8859         friend class VerifyFunctor;
8860 
8861         friend class UsingProgress;
8862 
8863         smart_ptr<SequenceVerificationExpectation> _expectationPtr;
8864 
8865         SequenceVerificationProgress(SequenceVerificationExpectation *ptr) : _expectationPtr(ptr) {
8866         }
8867 
8868         SequenceVerificationProgress(
8869                 FakeitContext &fakeit,
8870                 InvocationsSourceProxy sources,
8871                 std::vector<Sequence *> &allSequences) :
8872                 SequenceVerificationProgress(new SequenceVerificationExpectation(fakeit, sources, allSequences)) {
8873         }
8874 
8875         virtual void verifyInvocations(const int times) {
8876             _expectationPtr->setExpectedCount(times);
8877         }
8878 
8879         class Terminator {
8880             smart_ptr<SequenceVerificationExpectation> _expectationPtr;
8881 
8882             bool toBool() {
8883                 try {
8884                     ThrowFalseEventHandler eh;
8885                     _expectationPtr->VerifyExpectation(eh);
8886                     return true;
8887                 }
8888                 catch (bool e) {
8889                     return e;
8890                 }
8891             }
8892 
8893         public:
8894             Terminator(smart_ptr<SequenceVerificationExpectation> expectationPtr) : _expectationPtr(expectationPtr) { };
8895 
8896             operator bool() {
8897                 return toBool();
8898             }
8899 
8900             bool operator!() const { return !const_cast<Terminator *>(this)->toBool(); }
8901         };
8902 
8903     public:
8904 
8905         ~SequenceVerificationProgress() THROWS { };
8906 
8907         operator bool() const {
8908             return Terminator(_expectationPtr);
8909         }
8910 
8911         bool operator!() const { return !Terminator(_expectationPtr); }
8912 
8913         Terminator Never() {
8914             Exactly(0);
8915             return Terminator(_expectationPtr);
8916         }
8917 
8918         Terminator Once() {
8919             Exactly(1);
8920             return Terminator(_expectationPtr);
8921         }
8922 
8923         Terminator Twice() {
8924             Exactly(2);
8925             return Terminator(_expectationPtr);
8926         }
8927 
8928         Terminator AtLeastOnce() {
8929             verifyInvocations(-1);
8930             return Terminator(_expectationPtr);
8931         }
8932 
8933         Terminator Exactly(const int times) {
8934             if (times < 0) {
8935                 throw std::invalid_argument(std::string("bad argument times:").append(fakeit::to_string(times)));
8936             }
8937             verifyInvocations(times);
8938             return Terminator(_expectationPtr);
8939         }
8940 
8941         Terminator Exactly(const Quantity &q) {
8942             Exactly(q.quantity);
8943             return Terminator(_expectationPtr);
8944         }
8945 
8946         Terminator AtLeast(const int times) {
8947             if (times < 0) {
8948                 throw std::invalid_argument(std::string("bad argument times:").append(fakeit::to_string(times)));
8949             }
8950             verifyInvocations(-times);
8951             return Terminator(_expectationPtr);
8952         }
8953 
8954         Terminator AtLeast(const Quantity &q) {
8955             AtLeast(q.quantity);
8956             return Terminator(_expectationPtr);
8957         }
8958 
8959         SequenceVerificationProgress setFileInfo(const char * file, int line, const char * callingMethod) {
8960             _expectationPtr->setFileInfo(file, line, callingMethod);
8961             return *this;
8962         }
8963     };
8964 }
8965 
8966 namespace fakeit {
8967 
8968     class UsingProgress {
8969         fakeit::FakeitContext &_fakeit;
8970         InvocationsSourceProxy _sources;
8971 
8972         void collectSequences(std::vector<fakeit::Sequence *> &) {
8973         }
8974 
8975         template<typename ... list>
8976         void collectSequences(std::vector<fakeit::Sequence *> &vec, const fakeit::Sequence &sequence,
8977                               const list &... tail) {
8978             vec.push_back(&const_cast<fakeit::Sequence &>(sequence));
8979             collectSequences(vec, tail...);
8980         }
8981 
8982     public:
8983 
8984         UsingProgress(fakeit::FakeitContext &fakeit, InvocationsSourceProxy source) :
8985                 _fakeit(fakeit),
8986                 _sources(source) {
8987         }
8988 
8989         template<typename ... list>
8990         SequenceVerificationProgress Verify(const fakeit::Sequence &sequence, const list &... tail) {
8991             std::vector<fakeit::Sequence *> allSequences;
8992             collectSequences(allSequences, sequence, tail...);
8993             SequenceVerificationProgress progress(_fakeit, _sources, allSequences);
8994             return progress;
8995         }
8996 
8997     };
8998 }
8999 
9000 namespace fakeit {
9001 
9002     class UsingFunctor {
9003 
9004         friend class VerifyFunctor;
9005 
9006         FakeitContext &_fakeit;
9007 
9008     public:
9009 
9010         UsingFunctor(FakeitContext &fakeit) : _fakeit(fakeit) {
9011         }
9012 
9013         template<typename ... list>
9014         UsingProgress operator()(const ActualInvocationsSource &head, const list &... tail) {
9015             std::vector<ActualInvocationsSource *> allMocks{&InvocationUtils::remove_const(head),
9016                                                             &InvocationUtils::remove_const(tail)...};
9017             InvocationsSourceProxy aggregateInvocationsSource{new AggregateInvocationsSource(allMocks)};
9018             UsingProgress progress(_fakeit, aggregateInvocationsSource);
9019             return progress;
9020         }
9021 
9022     };
9023 }
9024 #include <set>
9025 
9026 namespace fakeit {
9027 
9028     class VerifyFunctor {
9029 
9030         FakeitContext &_fakeit;
9031 
9032 
9033     public:
9034 
9035         VerifyFunctor(FakeitContext &fakeit) : _fakeit(fakeit) {
9036         }
9037 
9038         template<typename ... list>
9039         SequenceVerificationProgress operator()(const Sequence &sequence, const list &... tail) {
9040             std::vector<Sequence *> allSequences{&InvocationUtils::remove_const(sequence),
9041                                                  &InvocationUtils::remove_const(tail)...};
9042 
9043             std::vector<ActualInvocationsSource *> involvedSources;
9044             InvocationUtils::collectInvolvedMocks(allSequences, involvedSources);
9045             InvocationsSourceProxy aggregateInvocationsSource{new AggregateInvocationsSource(involvedSources)};
9046 
9047             UsingProgress usingProgress(_fakeit, aggregateInvocationsSource);
9048             return usingProgress.Verify(sequence, tail...);
9049         }
9050 
9051     };
9052 
9053 }
9054 #include <set>
9055 #include <memory>
9056 namespace fakeit {
9057 
9058     class VerifyNoOtherInvocationsVerificationProgress {
9059 
9060         friend class VerifyNoOtherInvocationsFunctor;
9061 
9062         struct VerifyNoOtherInvocationsExpectation {
9063 
9064             friend class VerifyNoOtherInvocationsVerificationProgress;
9065 
9066             ~VerifyNoOtherInvocationsExpectation() THROWS {
9067                 if (std::uncaught_exception()) {
9068                     return;
9069                 }
9070 
9071                 VerifyExpectation(_fakeit);
9072             }
9073 
9074             void setFileInfo(const char * file, int line, const char * callingMethod) {
9075                 _file = file;
9076                 _line = line;
9077                 _callingMethod = callingMethod;
9078             }
9079 
9080         private:
9081 
9082             VerificationEventHandler &_fakeit;
9083             std::vector<ActualInvocationsSource *> _mocks;
9084 
9085             const char * _file;
9086             int _line;
9087             const char * _callingMethod;
9088             bool _isVerified;
9089 
9090             VerifyNoOtherInvocationsExpectation(VerificationEventHandler &fakeit,
9091                                                 std::vector<ActualInvocationsSource *> mocks) :
9092                     _fakeit(fakeit),
9093                     _mocks(mocks),
9094                     _line(0),
9095                     _isVerified(false) {
9096             }
9097 
9098             VerifyNoOtherInvocationsExpectation(VerifyNoOtherInvocationsExpectation &other) = default;
9099 
9100             void VerifyExpectation(VerificationEventHandler &verificationErrorHandler) {
9101                 if (_isVerified)
9102                     return;
9103                 _isVerified = true;
9104 
9105                 std::unordered_set<Invocation *> actualInvocations;
9106                 InvocationUtils::collectActualInvocations(actualInvocations, _mocks);
9107 
9108                 std::unordered_set<Invocation *> nonVerifiedInvocations;
9109                 InvocationUtils::selectNonVerifiedInvocations(actualInvocations, nonVerifiedInvocations);
9110 
9111                 if (nonVerifiedInvocations.size() > 0) {
9112                     std::vector<Invocation *> sortedNonVerifiedInvocations;
9113                     InvocationUtils::sortByInvocationOrder(nonVerifiedInvocations, sortedNonVerifiedInvocations);
9114 
9115                     std::vector<Invocation *> sortedActualInvocations;
9116                     InvocationUtils::sortByInvocationOrder(actualInvocations, sortedActualInvocations);
9117 
9118                     NoMoreInvocationsVerificationEvent evt(sortedActualInvocations, sortedNonVerifiedInvocations);
9119                     evt.setFileInfo(_file, _line, _callingMethod);
9120                     return verificationErrorHandler.handle(evt);
9121                 }
9122             }
9123 
9124         };
9125 
9126         fakeit::smart_ptr<VerifyNoOtherInvocationsExpectation> _ptr;
9127 
9128         VerifyNoOtherInvocationsVerificationProgress(VerifyNoOtherInvocationsExpectation *ptr) :
9129                 _ptr(ptr) {
9130         }
9131 
9132         VerifyNoOtherInvocationsVerificationProgress(FakeitContext &fakeit,
9133                                                      std::vector<ActualInvocationsSource *> &invocationSources)
9134                 : VerifyNoOtherInvocationsVerificationProgress(
9135                 new VerifyNoOtherInvocationsExpectation(fakeit, invocationSources)
9136         ) {
9137         }
9138 
9139         bool toBool() {
9140             try {
9141                 ThrowFalseEventHandler ev;
9142                 _ptr->VerifyExpectation(ev);
9143                 return true;
9144             }
9145             catch (bool e) {
9146                 return e;
9147             }
9148         }
9149 
9150     public:
9151 
9152 
9153         ~VerifyNoOtherInvocationsVerificationProgress() THROWS {
9154         };
9155 
9156         VerifyNoOtherInvocationsVerificationProgress setFileInfo(const char * file, int line,
9157             const char * callingMethod) {
9158             _ptr->setFileInfo(file, line, callingMethod);
9159             return *this;
9160         }
9161 
9162         operator bool() const {
9163             return const_cast<VerifyNoOtherInvocationsVerificationProgress *>(this)->toBool();
9164         }
9165 
9166         bool operator!() const { return !const_cast<VerifyNoOtherInvocationsVerificationProgress *>(this)->toBool(); }
9167 
9168     };
9169 
9170 }
9171 
9172 
9173 namespace fakeit {
9174     class VerifyNoOtherInvocationsFunctor {
9175 
9176         FakeitContext &_fakeit;
9177 
9178     public:
9179 
9180         VerifyNoOtherInvocationsFunctor(FakeitContext &fakeit) : _fakeit(fakeit) {
9181         }
9182 
9183         void operator()() {
9184         }
9185 
9186         template<typename ... list>
9187         VerifyNoOtherInvocationsVerificationProgress operator()(const ActualInvocationsSource &head,
9188                                                                 const list &... tail) {
9189             std::vector<ActualInvocationsSource *> invocationSources{&InvocationUtils::remove_const(head),
9190                                                                      &InvocationUtils::remove_const(tail)...};
9191             VerifyNoOtherInvocationsVerificationProgress progress{_fakeit, invocationSources};
9192             return progress;
9193         }
9194     };
9195 
9196 }
9197 namespace fakeit {
9198 
9199     class SpyFunctor {
9200     private:
9201 
9202         template<typename R, typename ... arglist>
9203         void spy(const SpyingContext<R, arglist...> &root) {
9204             SpyingContext<R, arglist...> &rootWithoutConst = const_cast<SpyingContext<R, arglist...> &>(root);
9205             auto methodFromOriginalVT = rootWithoutConst.getOriginalMethod();
9206             rootWithoutConst.appendAction(new ReturnDelegateValue<R, arglist...>(methodFromOriginalVT));
9207             rootWithoutConst.commit();
9208         }
9209 
9210         void operator()() {
9211         }
9212 
9213     public:
9214 
9215         template<typename H, typename ... M>
9216         void operator()(const H &head, const M &... tail) {
9217             spy(head);
9218             this->operator()(tail...);
9219         }
9220 
9221     };
9222 
9223 }
9224 
9225 #include <vector>
9226 #include <set>
9227 
9228 namespace fakeit {
9229     class VerifyUnverifiedFunctor {
9230 
9231         FakeitContext &_fakeit;
9232 
9233     public:
9234 
9235         VerifyUnverifiedFunctor(FakeitContext &fakeit) : _fakeit(fakeit) {
9236         }
9237 
9238         template<typename ... list>
9239         SequenceVerificationProgress operator()(const Sequence &sequence, const list &... tail) {
9240             std::vector<Sequence *> allSequences{&InvocationUtils::remove_const(sequence),
9241                                                  &InvocationUtils::remove_const(tail)...};
9242 
9243             std::vector<ActualInvocationsSource *> involvedSources;
9244             InvocationUtils::collectInvolvedMocks(allSequences, involvedSources);
9245 
9246             InvocationsSourceProxy aggregateInvocationsSource{new AggregateInvocationsSource(involvedSources)};
9247             InvocationsSourceProxy unverifiedInvocationsSource{
9248                     new UnverifiedInvocationsSource(aggregateInvocationsSource)};
9249 
9250             UsingProgress usingProgress(_fakeit, unverifiedInvocationsSource);
9251             return usingProgress.Verify(sequence, tail...);
9252         }
9253 
9254     };
9255 
9256     class UnverifiedFunctor {
9257     public:
9258         UnverifiedFunctor(FakeitContext &fakeit) : Verify(fakeit) {
9259         }
9260 
9261         VerifyUnverifiedFunctor Verify;
9262 
9263         template<typename ... list>
9264         UnverifiedInvocationsSource operator()(const ActualInvocationsSource &head, const list &... tail) {
9265             std::vector<ActualInvocationsSource *> allMocks{&InvocationUtils::remove_const(head),
9266                                                             &InvocationUtils::remove_const(tail)...};
9267             InvocationsSourceProxy aggregateInvocationsSource{new AggregateInvocationsSource(allMocks)};
9268             UnverifiedInvocationsSource unverifiedInvocationsSource{aggregateInvocationsSource};
9269             return unverifiedInvocationsSource;
9270         }
9271 
9272 
9273 
9274 
9275 
9276 
9277 
9278 
9279 
9280 
9281 
9282 
9283 
9284     };
9285 }
9286 
9287 namespace fakeit {
9288 
9289     static UsingFunctor Using(Fakeit);
9290     static VerifyFunctor Verify(Fakeit);
9291     static VerifyNoOtherInvocationsFunctor VerifyNoOtherInvocations(Fakeit);
9292     static UnverifiedFunctor Unverified(Fakeit);
9293     static SpyFunctor Spy;
9294     static FakeFunctor Fake;
9295     static WhenFunctor When;
9296 
9297     template<class T>
9298     class SilenceUnusedVariableWarnings {
9299 
9300         void use(void *) {
9301         }
9302 
9303         SilenceUnusedVariableWarnings() {
9304             use(&Fake);
9305             use(&When);
9306             use(&Spy);
9307             use(&Using);
9308             use(&Verify);
9309             use(&VerifyNoOtherInvocations);
9310             use(&_);
9311         }
9312     };
9313 
9314 }
9315 #ifdef _MSC_VER
9316 #define __func__ __FUNCTION__
9317 #endif
9318 
9319 #define MOCK_TYPE(mock) \
9320     std::remove_reference<decltype(mock.get())>::type
9321 
9322 #define OVERLOADED_METHOD_PTR(mock, method, prototype) \
9323     fakeit::Prototype<prototype>::MemberType<MOCK_TYPE(mock)>::get(&MOCK_TYPE(mock)::method)
9324 
9325 #define CONST_OVERLOADED_METHOD_PTR(mock, method, prototype) \
9326     fakeit::Prototype<prototype>::MemberType<MOCK_TYPE(mock)>::getconst(&MOCK_TYPE(mock)::method)
9327 
9328 #define Dtor(mock) \
9329     mock.dtor().setMethodDetails(#mock,"destructor")
9330 
9331 #define Method(mock, method) \
9332     mock.template stub<__COUNTER__>(&MOCK_TYPE(mock)::method).setMethodDetails(#mock,#method)
9333 
9334 #define OverloadedMethod(mock, method, prototype) \
9335     mock.template stub<__COUNTER__>(OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)
9336 
9337 #define ConstOverloadedMethod(mock, method, prototype) \
9338     mock.template stub<__COUNTER__>(CONST_OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)
9339 
9340 #define Verify(...) \
9341         Verify( __VA_ARGS__ ).setFileInfo(__FILE__, __LINE__, __func__)
9342 
9343 #define Using(...) \
9344         Using( __VA_ARGS__ )
9345 
9346 #define VerifyNoOtherInvocations(...) \
9347     VerifyNoOtherInvocations( __VA_ARGS__ ).setFileInfo(__FILE__, __LINE__, __func__)
9348 
9349 #define Fake(...) \
9350     Fake( __VA_ARGS__ )
9351 
9352 #define When(call) \
9353     When(call)
9354 
9355 
9356 #if defined __GNUC__
9357 #    pragma GCC diagnostic pop
9358 #endif