summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--lib/gtest/CMakeLists.txt1
-rw-r--r--lib/gtest/include/gmock/gmock-actions.h1076
-rw-r--r--lib/gtest/include/gmock/gmock-cardinalities.h146
-rw-r--r--lib/gtest/include/gmock/gmock-generated-actions.h2419
-rw-r--r--lib/gtest/include/gmock/gmock-generated-actions.h.pump825
-rw-r--r--lib/gtest/include/gmock/gmock-generated-function-mockers.h929
-rw-r--r--lib/gtest/include/gmock/gmock-generated-function-mockers.h.pump258
-rw-r--r--lib/gtest/include/gmock/gmock-generated-matchers.h2054
-rw-r--r--lib/gtest/include/gmock/gmock-generated-matchers.h.pump651
-rw-r--r--lib/gtest/include/gmock/gmock-generated-nice-strict.h274
-rw-r--r--lib/gtest/include/gmock/gmock-generated-nice-strict.h.pump160
-rw-r--r--lib/gtest/include/gmock/gmock-matchers.h3066
-rw-r--r--lib/gtest/include/gmock/gmock-more-actions.h233
-rw-r--r--lib/gtest/include/gmock/gmock-spec-builders.h1749
-rw-r--r--lib/gtest/include/gmock/gmock.h93
-rw-r--r--lib/gtest/include/gmock/internal/gmock-generated-internal-utils.h277
-rw-r--r--lib/gtest/include/gmock/internal/gmock-generated-internal-utils.h.pump136
-rw-r--r--lib/gtest/include/gmock/internal/gmock-internal-utils.h463
-rw-r--r--lib/gtest/include/gmock/internal/gmock-port.h78
-rw-r--r--lib/gtest/src/gmock-all.cc47
-rw-r--r--lib/gtest/src/gmock-cardinalities.cc155
-rw-r--r--lib/gtest/src/gmock-internal-utils.cc173
-rw-r--r--lib/gtest/src/gmock-matchers.cc101
-rw-r--r--lib/gtest/src/gmock-spec-builders.cc797
-rw-r--r--lib/gtest/src/gmock.cc182
-rw-r--r--lib/gtest/src/gmock_main.cc54
-rw-r--r--src/CBot/resource.h8
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/app/app.h2
-rw-r--r--src/app/main.cpp3
-rw-r--r--src/app/system.cpp7
-rw-r--r--src/common/error_ids.h151
-rw-r--r--src/common/event.cpp1
-rw-r--r--src/common/event.h526
-rw-r--r--src/common/event_ids.h541
-rw-r--r--src/common/global.h139
-rw-r--r--src/common/image.cpp3
-rw-r--r--src/common/image.h2
-rw-r--r--src/common/iman.cpp1
-rw-r--r--src/common/iman.h6
-rw-r--r--src/common/ioutils.h2
-rw-r--r--src/common/key.h5
-rw-r--r--src/common/logger.cpp3
-rw-r--r--src/common/logger.h30
-rw-r--r--src/common/misc.cpp2
-rw-r--r--src/common/misc.h15
-rw-r--r--src/common/profile.cpp3
-rw-r--r--src/common/profile.h63
-rw-r--r--src/common/restext.cpp729
-rw-r--r--src/common/restext.h131
-rw-r--r--src/common/restext_ids.h122
-rw-r--r--src/common/restext_strings.c717
-rw-r--r--src/common/singleton.h1
-rw-r--r--src/common/stringutils.cpp3
-rw-r--r--src/graphics/engine/lightning.cpp2
-rw-r--r--src/graphics/engine/particle.h2
-rw-r--r--src/graphics/engine/text.cpp5
-rw-r--r--src/graphics/engine/text.h8
-rw-r--r--src/graphics/opengl/gldevice.cpp4
-rw-r--r--src/graphics/opengl/gldevice.h2
-rw-r--r--src/object/auto/auto.cpp4
-rw-r--r--src/object/auto/autobase.cpp2
-rw-r--r--src/object/auto/autoconvert.cpp2
-rw-r--r--src/object/auto/autodestroyer.cpp2
-rw-r--r--src/object/auto/autoegg.cpp2
-rw-r--r--src/object/auto/autoenergy.cpp2
-rw-r--r--src/object/auto/autoflag.cpp2
-rw-r--r--src/object/auto/autohuston.cpp2
-rw-r--r--src/object/auto/autoinfo.cpp2
-rw-r--r--src/object/auto/autokid.cpp2
-rw-r--r--src/object/auto/autolabo.cpp2
-rw-r--r--src/object/auto/automush.cpp2
-rw-r--r--src/object/auto/autonest.cpp2
-rw-r--r--src/object/auto/autonuclear.cpp2
-rw-r--r--src/object/auto/autopara.cpp2
-rw-r--r--src/object/auto/autoportico.cpp2
-rw-r--r--src/object/auto/autoradar.cpp2
-rw-r--r--src/object/auto/autorepair.cpp2
-rw-r--r--src/object/auto/autoresearch.cpp2
-rw-r--r--src/object/auto/autoroot.cpp2
-rw-r--r--src/object/auto/autosafe.cpp2
-rw-r--r--src/object/auto/autostation.cpp2
-rw-r--r--src/object/auto/autotower.cpp2
-rw-r--r--src/object/brain.cpp18
-rw-r--r--src/object/brain.h6
-rw-r--r--src/object/mainmovie.cpp14
-rw-r--r--src/object/mainmovie.h5
-rw-r--r--src/object/motion/motion.cpp2
-rw-r--r--src/object/object.cpp43
-rw-r--r--src/object/object.h259
-rw-r--r--src/object/object_ids.h262
-rw-r--r--src/object/robotmain.cpp272
-rw-r--r--src/object/robotmain.h17
-rw-r--r--src/physics/physics.cpp25
-rw-r--r--src/physics/physics.h5
-rw-r--r--src/plugins/plugininterface.h30
-rw-r--r--src/plugins/pluginloader.cpp10
-rw-r--r--src/plugins/pluginloader.h41
-rw-r--r--src/plugins/pluginmanager.cpp4
-rw-r--r--src/plugins/pluginmanager.h51
-rw-r--r--src/script/cbottoken.h5
-rw-r--r--src/script/cmdtoken.h6
-rw-r--r--src/script/script.cpp40
-rw-r--r--src/script/script.h10
-rw-r--r--src/sound/sound.h126
-rw-r--r--src/ui/control.cpp1
-rw-r--r--src/ui/control.h7
-rw-r--r--src/ui/displayinfo.cpp4
-rw-r--r--src/ui/edit.cpp9
-rw-r--r--src/ui/edit.h2
-rw-r--r--src/ui/key.cpp169
-rw-r--r--src/ui/key.h45
-rw-r--r--src/ui/maindialog.cpp117
-rw-r--r--src/ui/mainshort.cpp2
-rw-r--r--src/ui/mainshort.h2
-rw-r--r--src/ui/studio.cpp4
-rw-r--r--src/ui/test/CMakeLists.txt33
-rw-r--r--src/ui/test/edit_test.cpp73
-rw-r--r--src/ui/test/mocks/text_mock.h21
-rw-r--r--src/ui/test/stubs/app_stub.cpp26
-rw-r--r--src/ui/test/stubs/engine_stub.cpp79
-rw-r--r--src/ui/test/stubs/particle_stub.cpp291
-rw-r--r--src/ui/test/stubs/restext_stub.cpp11
-rw-r--r--src/ui/test/stubs/robotmain_stub.cpp17
125 files changed, 19354 insertions, 2499 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ec7297..5873776 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -116,7 +116,10 @@ if(NOT ${ASSERTS})
endif()
if(${TESTS})
+ add_definitions(-DTEST_VIRTUAL=virtual)
enable_testing()
+else()
+ add_definitions(-DTEST_VIRTUAL)
endif()
diff --git a/lib/gtest/CMakeLists.txt b/lib/gtest/CMakeLists.txt
index 1279f7d..61813ae 100644
--- a/lib/gtest/CMakeLists.txt
+++ b/lib/gtest/CMakeLists.txt
@@ -7,3 +7,4 @@ add_definitions(-DGTEST_HAS_PTHREAD=0)
# gtest-all.cc includes all other sources
add_library(gtest STATIC src/gtest-all.cc)
+add_library(gmock STATIC src/gmock-all.cc)
diff --git a/lib/gtest/include/gmock/gmock-actions.h b/lib/gtest/include/gmock/gmock-actions.h
new file mode 100644
index 0000000..d6a3e14
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-actions.h
@@ -0,0 +1,1076 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements some commonly used actions.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
+
+#include <algorithm>
+#include <string>
+
+#ifndef _WIN32_WCE
+# include <errno.h>
+#endif
+
+#include "gmock/internal/gmock-internal-utils.h"
+#include "gmock/internal/gmock-port.h"
+
+namespace testing {
+
+// To implement an action Foo, define:
+// 1. a class FooAction that implements the ActionInterface interface, and
+// 2. a factory function that creates an Action object from a
+// const FooAction*.
+//
+// The two-level delegation design follows that of Matcher, providing
+// consistency for extension developers. It also eases ownership
+// management as Action objects can now be copied like plain values.
+
+namespace internal {
+
+template <typename F1, typename F2>
+class ActionAdaptor;
+
+// BuiltInDefaultValue<T>::Get() returns the "built-in" default
+// value for type T, which is NULL when T is a pointer type, 0 when T
+// is a numeric type, false when T is bool, or "" when T is string or
+// std::string. For any other type T, this value is undefined and the
+// function will abort the process.
+template <typename T>
+class BuiltInDefaultValue {
+ public:
+ // This function returns true iff type T has a built-in default value.
+ static bool Exists() { return false; }
+ static T Get() {
+ Assert(false, __FILE__, __LINE__,
+ "Default action undefined for the function return type.");
+ return internal::Invalid<T>();
+ // The above statement will never be reached, but is required in
+ // order for this function to compile.
+ }
+};
+
+// This partial specialization says that we use the same built-in
+// default value for T and const T.
+template <typename T>
+class BuiltInDefaultValue<const T> {
+ public:
+ static bool Exists() { return BuiltInDefaultValue<T>::Exists(); }
+ static T Get() { return BuiltInDefaultValue<T>::Get(); }
+};
+
+// This partial specialization defines the default values for pointer
+// types.
+template <typename T>
+class BuiltInDefaultValue<T*> {
+ public:
+ static bool Exists() { return true; }
+ static T* Get() { return NULL; }
+};
+
+// The following specializations define the default values for
+// specific types we care about.
+#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
+ template <> \
+ class BuiltInDefaultValue<type> { \
+ public: \
+ static bool Exists() { return true; } \
+ static type Get() { return value; } \
+ }
+
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, ); // NOLINT
+#if GTEST_HAS_GLOBAL_STRING
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::string, "");
+#endif // GTEST_HAS_GLOBAL_STRING
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::std::string, "");
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(bool, false);
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned char, '\0');
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed char, '\0');
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(char, '\0');
+
+// There's no need for a default action for signed wchar_t, as that
+// type is the same as wchar_t for gcc, and invalid for MSVC.
+//
+// There's also no need for a default action for unsigned wchar_t, as
+// that type is the same as unsigned int for gcc, and invalid for
+// MSVC.
+#if GMOCK_WCHAR_T_IS_NATIVE_
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(wchar_t, 0U); // NOLINT
+#endif
+
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U); // NOLINT
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0); // NOLINT
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U);
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0);
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL); // NOLINT
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L); // NOLINT
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(UInt64, 0);
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(Int64, 0);
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(float, 0);
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0);
+
+#undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
+
+} // namespace internal
+
+// When an unexpected function call is encountered, Google Mock will
+// let it return a default value if the user has specified one for its
+// return type, or if the return type has a built-in default value;
+// otherwise Google Mock won't know what value to return and will have
+// to abort the process.
+//
+// The DefaultValue<T> class allows a user to specify the
+// default value for a type T that is both copyable and publicly
+// destructible (i.e. anything that can be used as a function return
+// type). The usage is:
+//
+// // Sets the default value for type T to be foo.
+// DefaultValue<T>::Set(foo);
+template <typename T>
+class DefaultValue {
+ public:
+ // Sets the default value for type T; requires T to be
+ // copy-constructable and have a public destructor.
+ static void Set(T x) {
+ delete value_;
+ value_ = new T(x);
+ }
+
+ // Unsets the default value for type T.
+ static void Clear() {
+ delete value_;
+ value_ = NULL;
+ }
+
+ // Returns true iff the user has set the default value for type T.
+ static bool IsSet() { return value_ != NULL; }
+
+ // Returns true if T has a default return value set by the user or there
+ // exists a built-in default value.
+ static bool Exists() {
+ return IsSet() || internal::BuiltInDefaultValue<T>::Exists();
+ }
+
+ // Returns the default value for type T if the user has set one;
+ // otherwise returns the built-in default value if there is one;
+ // otherwise aborts the process.
+ static T Get() {
+ return value_ == NULL ?
+ internal::BuiltInDefaultValue<T>::Get() : *value_;
+ }
+ private:
+ static const T* value_;
+};
+
+// This partial specialization allows a user to set default values for
+// reference types.
+template <typename T>
+class DefaultValue<T&> {
+ public:
+ // Sets the default value for type T&.
+ static void Set(T& x) { // NOLINT
+ address_ = &x;
+ }
+
+ // Unsets the default value for type T&.
+ static void Clear() {
+ address_ = NULL;
+ }
+
+ // Returns true iff the user has set the default value for type T&.
+ static bool IsSet() { return address_ != NULL; }
+
+ // Returns true if T has a default return value set by the user or there
+ // exists a built-in default value.
+ static bool Exists() {
+ return IsSet() || internal::BuiltInDefaultValue<T&>::Exists();
+ }
+
+ // Returns the default value for type T& if the user has set one;
+ // otherwise returns the built-in default value if there is one;
+ // otherwise aborts the process.
+ static T& Get() {
+ return address_ == NULL ?
+ internal::BuiltInDefaultValue<T&>::Get() : *address_;
+ }
+ private:
+ static T* address_;
+};
+
+// This specialization allows DefaultValue<void>::Get() to
+// compile.
+template <>
+class DefaultValue<void> {
+ public:
+ static bool Exists() { return true; }
+ static void Get() {}
+};
+
+// Points to the user-set default value for type T.
+template <typename T>
+const T* DefaultValue<T>::value_ = NULL;
+
+// Points to the user-set default value for type T&.
+template <typename T>
+T* DefaultValue<T&>::address_ = NULL;
+
+// Implement this interface to define an action for function type F.
+template <typename F>
+class ActionInterface {
+ public:
+ typedef typename internal::Function<F>::Result Result;
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ ActionInterface() {}
+ virtual ~ActionInterface() {}
+
+ // Performs the action. This method is not const, as in general an
+ // action can have side effects and be stateful. For example, a
+ // get-the-next-element-from-the-collection action will need to
+ // remember the current element.
+ virtual Result Perform(const ArgumentTuple& args) = 0;
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface);
+};
+
+// An Action<F> is a copyable and IMMUTABLE (except by assignment)
+// object that represents an action to be taken when a mock function
+// of type F is called. The implementation of Action<T> is just a
+// linked_ptr to const ActionInterface<T>, so copying is fairly cheap.
+// Don't inherit from Action!
+//
+// You can view an object implementing ActionInterface<F> as a
+// concrete action (including its current state), and an Action<F>
+// object as a handle to it.
+template <typename F>
+class Action {
+ public:
+ typedef typename internal::Function<F>::Result Result;
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ // Constructs a null Action. Needed for storing Action objects in
+ // STL containers.
+ Action() : impl_(NULL) {}
+
+ // Constructs an Action from its implementation. A NULL impl is
+ // used to represent the "do-default" action.
+ explicit Action(ActionInterface<F>* impl) : impl_(impl) {}
+
+ // Copy constructor.
+ Action(const Action& action) : impl_(action.impl_) {}
+
+ // This constructor allows us to turn an Action<Func> object into an
+ // Action<F>, as long as F's arguments can be implicitly converted
+ // to Func's and Func's return type can be implicitly converted to
+ // F's.
+ template <typename Func>
+ explicit Action(const Action<Func>& action);
+
+ // Returns true iff this is the DoDefault() action.
+ bool IsDoDefault() const { return impl_.get() == NULL; }
+
+ // Performs the action. Note that this method is const even though
+ // the corresponding method in ActionInterface is not. The reason
+ // is that a const Action<F> means that it cannot be re-bound to
+ // another concrete action, not that the concrete action it binds to
+ // cannot change state. (Think of the difference between a const
+ // pointer and a pointer to const.)
+ Result Perform(const ArgumentTuple& args) const {
+ internal::Assert(
+ !IsDoDefault(), __FILE__, __LINE__,
+ "You are using DoDefault() inside a composite action like "
+ "DoAll() or WithArgs(). This is not supported for technical "
+ "reasons. Please instead spell out the default action, or "
+ "assign the default action to an Action variable and use "
+ "the variable in various places.");
+ return impl_->Perform(args);
+ }
+
+ private:
+ template <typename F1, typename F2>
+ friend class internal::ActionAdaptor;
+
+ internal::linked_ptr<ActionInterface<F> > impl_;
+};
+
+// The PolymorphicAction class template makes it easy to implement a
+// polymorphic action (i.e. an action that can be used in mock
+// functions of than one type, e.g. Return()).
+//
+// To define a polymorphic action, a user first provides a COPYABLE
+// implementation class that has a Perform() method template:
+//
+// class FooAction {
+// public:
+// template <typename Result, typename ArgumentTuple>
+// Result Perform(const ArgumentTuple& args) const {
+// // Processes the arguments and returns a result, using
+// // tr1::get<N>(args) to get the N-th (0-based) argument in the tuple.
+// }
+// ...
+// };
+//
+// Then the user creates the polymorphic action using
+// MakePolymorphicAction(object) where object has type FooAction. See
+// the definition of Return(void) and SetArgumentPointee<N>(value) for
+// complete examples.
+template <typename Impl>
+class PolymorphicAction {
+ public:
+ explicit PolymorphicAction(const Impl& impl) : impl_(impl) {}
+
+ template <typename F>
+ operator Action<F>() const {
+ return Action<F>(new MonomorphicImpl<F>(impl_));
+ }
+
+ private:
+ template <typename F>
+ class MonomorphicImpl : public ActionInterface<F> {
+ public:
+ typedef typename internal::Function<F>::Result Result;
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
+
+ virtual Result Perform(const ArgumentTuple& args) {
+ return impl_.template Perform<Result>(args);
+ }
+
+ private:
+ Impl impl_;
+
+ GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
+ };
+
+ Impl impl_;
+
+ GTEST_DISALLOW_ASSIGN_(PolymorphicAction);
+};
+
+// Creates an Action from its implementation and returns it. The
+// created Action object owns the implementation.
+template <typename F>
+Action<F> MakeAction(ActionInterface<F>* impl) {
+ return Action<F>(impl);
+}
+
+// Creates a polymorphic action from its implementation. This is
+// easier to use than the PolymorphicAction<Impl> constructor as it
+// doesn't require you to explicitly write the template argument, e.g.
+//
+// MakePolymorphicAction(foo);
+// vs
+// PolymorphicAction<TypeOfFoo>(foo);
+template <typename Impl>
+inline PolymorphicAction<Impl> MakePolymorphicAction(const Impl& impl) {
+ return PolymorphicAction<Impl>(impl);
+}
+
+namespace internal {
+
+// Allows an Action<F2> object to pose as an Action<F1>, as long as F2
+// and F1 are compatible.
+template <typename F1, typename F2>
+class ActionAdaptor : public ActionInterface<F1> {
+ public:
+ typedef typename internal::Function<F1>::Result Result;
+ typedef typename internal::Function<F1>::ArgumentTuple ArgumentTuple;
+
+ explicit ActionAdaptor(const Action<F2>& from) : impl_(from.impl_) {}
+
+ virtual Result Perform(const ArgumentTuple& args) {
+ return impl_->Perform(args);
+ }
+
+ private:
+ const internal::linked_ptr<ActionInterface<F2> > impl_;
+
+ GTEST_DISALLOW_ASSIGN_(ActionAdaptor);
+};
+
+// Implements the polymorphic Return(x) action, which can be used in
+// any function that returns the type of x, regardless of the argument
+// types.
+//
+// Note: The value passed into Return must be converted into
+// Function<F>::Result when this action is cast to Action<F> rather than
+// when that action is performed. This is important in scenarios like
+//
+// MOCK_METHOD1(Method, T(U));
+// ...
+// {
+// Foo foo;
+// X x(&foo);
+// EXPECT_CALL(mock, Method(_)).WillOnce(Return(x));
+// }
+//
+// In the example above the variable x holds reference to foo which leaves
+// scope and gets destroyed. If copying X just copies a reference to foo,
+// that copy will be left with a hanging reference. If conversion to T
+// makes a copy of foo, the above code is safe. To support that scenario, we
+// need to make sure that the type conversion happens inside the EXPECT_CALL
+// statement, and conversion of the result of Return to Action<T(U)> is a
+// good place for that.
+//
+template <typename R>
+class ReturnAction {
+ public:
+ // Constructs a ReturnAction object from the value to be returned.
+ // 'value' is passed by value instead of by const reference in order
+ // to allow Return("string literal") to compile.
+ explicit ReturnAction(R value) : value_(value) {}
+
+ // This template type conversion operator allows Return(x) to be
+ // used in ANY function that returns x's type.
+ template <typename F>
+ operator Action<F>() const {
+ // Assert statement belongs here because this is the best place to verify
+ // conditions on F. It produces the clearest error messages
+ // in most compilers.
+ // Impl really belongs in this scope as a local class but can't
+ // because MSVC produces duplicate symbols in different translation units
+ // in this case. Until MS fixes that bug we put Impl into the class scope
+ // and put the typedef both here (for use in assert statement) and
+ // in the Impl class. But both definitions must be the same.
+ typedef typename Function<F>::Result Result;
+ GTEST_COMPILE_ASSERT_(
+ !internal::is_reference<Result>::value,
+ use_ReturnRef_instead_of_Return_to_return_a_reference);
+ return Action<F>(new Impl<F>(value_));
+ }
+
+ private:
+ // Implements the Return(x) action for a particular function type F.
+ template <typename F>
+ class Impl : public ActionInterface<F> {
+ public:
+ typedef typename Function<F>::Result Result;
+ typedef typename Function<F>::ArgumentTuple ArgumentTuple;
+
+ // The implicit cast is necessary when Result has more than one
+ // single-argument constructor (e.g. Result is std::vector<int>) and R
+ // has a type conversion operator template. In that case, value_(value)
+ // won't compile as the compiler doesn't known which constructor of
+ // Result to call. ImplicitCast_ forces the compiler to convert R to
+ // Result without considering explicit constructors, thus resolving the
+ // ambiguity. value_ is then initialized using its copy constructor.
+ explicit Impl(R value)
+ : value_(::testing::internal::ImplicitCast_<Result>(value)) {}
+
+ virtual Result Perform(const ArgumentTuple&) { return value_; }
+
+ private:
+ GTEST_COMPILE_ASSERT_(!internal::is_reference<Result>::value,
+ Result_cannot_be_a_reference_type);
+ Result value_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
+ };
+
+ R value_;
+
+ GTEST_DISALLOW_ASSIGN_(ReturnAction);
+};
+
+// Implements the ReturnNull() action.
+class ReturnNullAction {
+ public:
+ // Allows ReturnNull() to be used in any pointer-returning function.
+ template <typename Result, typename ArgumentTuple>
+ static Result Perform(const ArgumentTuple&) {
+ GTEST_COMPILE_ASSERT_(internal::is_pointer<Result>::value,
+ ReturnNull_can_be_used_to_return_a_pointer_only);
+ return NULL;
+ }
+};
+
+// Implements the Return() action.
+class ReturnVoidAction {
+ public:
+ // Allows Return() to be used in any void-returning function.
+ template <typename Result, typename ArgumentTuple>
+ static void Perform(const ArgumentTuple&) {
+ CompileAssertTypesEqual<void, Result>();
+ }
+};
+
+// Implements the polymorphic ReturnRef(x) action, which can be used
+// in any function that returns a reference to the type of x,
+// regardless of the argument types.
+template <typename T>
+class ReturnRefAction {
+ public:
+ // Constructs a ReturnRefAction object from the reference to be returned.
+ explicit ReturnRefAction(T& ref) : ref_(ref) {} // NOLINT
+
+ // This template type conversion operator allows ReturnRef(x) to be
+ // used in ANY function that returns a reference to x's type.
+ template <typename F>
+ operator Action<F>() const {
+ typedef typename Function<F>::Result Result;
+ // Asserts that the function return type is a reference. This
+ // catches the user error of using ReturnRef(x) when Return(x)
+ // should be used, and generates some helpful error message.
+ GTEST_COMPILE_ASSERT_(internal::is_reference<Result>::value,
+ use_Return_instead_of_ReturnRef_to_return_a_value);
+ return Action<F>(new Impl<F>(ref_));
+ }
+
+ private:
+ // Implements the ReturnRef(x) action for a particular function type F.
+ template <typename F>
+ class Impl : public ActionInterface<F> {
+ public:
+ typedef typename Function<F>::Result Result;
+ typedef typename Function<F>::ArgumentTuple ArgumentTuple;
+
+ explicit Impl(T& ref) : ref_(ref) {} // NOLINT
+
+ virtual Result Perform(const ArgumentTuple&) {
+ return ref_;
+ }
+
+ private:
+ T& ref_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
+ };
+
+ T& ref_;
+
+ GTEST_DISALLOW_ASSIGN_(ReturnRefAction);
+};
+
+// Implements the polymorphic ReturnRefOfCopy(x) action, which can be
+// used in any function that returns a reference to the type of x,
+// regardless of the argument types.
+template <typename T>
+class ReturnRefOfCopyAction {
+ public:
+ // Constructs a ReturnRefOfCopyAction object from the reference to
+ // be returned.
+ explicit ReturnRefOfCopyAction(const T& value) : value_(value) {} // NOLINT
+
+ // This template type conversion operator allows ReturnRefOfCopy(x) to be
+ // used in ANY function that returns a reference to x's type.
+ template <typename F>
+ operator Action<F>() const {
+ typedef typename Function<F>::Result Result;
+ // Asserts that the function return type is a reference. This
+ // catches the user error of using ReturnRefOfCopy(x) when Return(x)
+ // should be used, and generates some helpful error message.
+ GTEST_COMPILE_ASSERT_(
+ internal::is_reference<Result>::value,
+ use_Return_instead_of_ReturnRefOfCopy_to_return_a_value);
+ return Action<F>(new Impl<F>(value_));
+ }
+
+ private:
+ // Implements the ReturnRefOfCopy(x) action for a particular function type F.
+ template <typename F>
+ class Impl : public ActionInterface<F> {
+ public:
+ typedef typename Function<F>::Result Result;
+ typedef typename Function<F>::ArgumentTuple ArgumentTuple;
+
+ explicit Impl(const T& value) : value_(value) {} // NOLINT
+
+ virtual Result Perform(const ArgumentTuple&) {
+ return value_;
+ }
+
+ private:
+ T value_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
+ };
+
+ const T value_;
+
+ GTEST_DISALLOW_ASSIGN_(ReturnRefOfCopyAction);
+};
+
+// Implements the polymorphic DoDefault() action.
+class DoDefaultAction {
+ public:
+ // This template type conversion operator allows DoDefault() to be
+ // used in any function.
+ template <typename F>
+ operator Action<F>() const { return Action<F>(NULL); }
+};
+
+// Implements the Assign action to set a given pointer referent to a
+// particular value.
+template <typename T1, typename T2>
+class AssignAction {
+ public:
+ AssignAction(T1* ptr, T2 value) : ptr_(ptr), value_(value) {}
+
+ template <typename Result, typename ArgumentTuple>
+ void Perform(const ArgumentTuple& /* args */) const {
+ *ptr_ = value_;
+ }
+
+ private:
+ T1* const ptr_;
+ const T2 value_;
+
+ GTEST_DISALLOW_ASSIGN_(AssignAction);
+};
+
+#if !GTEST_OS_WINDOWS_MOBILE
+
+// Implements the SetErrnoAndReturn action to simulate return from
+// various system calls and libc functions.
+template <typename T>
+class SetErrnoAndReturnAction {
+ public:
+ SetErrnoAndReturnAction(int errno_value, T result)
+ : errno_(errno_value),
+ result_(result) {}
+ template <typename Result, typename ArgumentTuple>
+ Result Perform(const ArgumentTuple& /* args */) const {
+ errno = errno_;
+ return result_;
+ }
+
+ private:
+ const int errno_;
+ const T result_;
+
+ GTEST_DISALLOW_ASSIGN_(SetErrnoAndReturnAction);
+};
+
+#endif // !GTEST_OS_WINDOWS_MOBILE
+
+// Implements the SetArgumentPointee<N>(x) action for any function
+// whose N-th argument (0-based) is a pointer to x's type. The
+// template parameter kIsProto is true iff type A is ProtocolMessage,
+// proto2::Message, or a sub-class of those.
+template <size_t N, typename A, bool kIsProto>
+class SetArgumentPointeeAction {
+ public:
+ // Constructs an action that sets the variable pointed to by the
+ // N-th function argument to 'value'.
+ explicit SetArgumentPointeeAction(const A& value) : value_(value) {}
+
+ template <typename Result, typename ArgumentTuple>
+ void Perform(const ArgumentTuple& args) const {
+ CompileAssertTypesEqual<void, Result>();
+ *::std::tr1::get<N>(args) = value_;
+ }
+
+ private:
+ const A value_;
+
+ GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
+};
+
+template <size_t N, typename Proto>
+class SetArgumentPointeeAction<N, Proto, true> {
+ public:
+ // Constructs an action that sets the variable pointed to by the
+ // N-th function argument to 'proto'. Both ProtocolMessage and
+ // proto2::Message have the CopyFrom() method, so the same
+ // implementation works for both.
+ explicit SetArgumentPointeeAction(const Proto& proto) : proto_(new Proto) {
+ proto_->CopyFrom(proto);
+ }
+
+ template <typename Result, typename ArgumentTuple>
+ void Perform(const ArgumentTuple& args) const {
+ CompileAssertTypesEqual<void, Result>();
+ ::std::tr1::get<N>(args)->CopyFrom(*proto_);
+ }
+
+ private:
+ const internal::linked_ptr<Proto> proto_;
+
+ GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
+};
+
+// Implements the InvokeWithoutArgs(f) action. The template argument
+// FunctionImpl is the implementation type of f, which can be either a
+// function pointer or a functor. InvokeWithoutArgs(f) can be used as an
+// Action<F> as long as f's type is compatible with F (i.e. f can be
+// assigned to a tr1::function<F>).
+template <typename FunctionImpl>
+class InvokeWithoutArgsAction {
+ public:
+ // The c'tor makes a copy of function_impl (either a function
+ // pointer or a functor).
+ explicit InvokeWithoutArgsAction(FunctionImpl function_impl)
+ : function_impl_(function_impl) {}
+
+ // Allows InvokeWithoutArgs(f) to be used as any action whose type is
+ // compatible with f.
+ template <typename Result, typename ArgumentTuple>
+ Result Perform(const ArgumentTuple&) { return function_impl_(); }
+
+ private:
+ FunctionImpl function_impl_;
+
+ GTEST_DISALLOW_ASSIGN_(InvokeWithoutArgsAction);
+};
+
+// Implements the InvokeWithoutArgs(object_ptr, &Class::Method) action.
+template <class Class, typename MethodPtr>
+class InvokeMethodWithoutArgsAction {
+ public:
+ InvokeMethodWithoutArgsAction(Class* obj_ptr, MethodPtr method_ptr)
+ : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}
+
+ template <typename Result, typename ArgumentTuple>
+ Result Perform(const ArgumentTuple&) const {
+ return (obj_ptr_->*method_ptr_)();
+ }
+
+ private:
+ Class* const obj_ptr_;
+ const MethodPtr method_ptr_;
+
+ GTEST_DISALLOW_ASSIGN_(InvokeMethodWithoutArgsAction);
+};
+
+// Implements the IgnoreResult(action) action.
+template <typename A>
+class IgnoreResultAction {
+ public:
+ explicit IgnoreResultAction(const A& action) : action_(action) {}
+
+ template <typename F>
+ operator Action<F>() const {
+ // Assert statement belongs here because this is the best place to verify
+ // conditions on F. It produces the clearest error messages
+ // in most compilers.
+ // Impl really belongs in this scope as a local class but can't
+ // because MSVC produces duplicate symbols in different translation units
+ // in this case. Until MS fixes that bug we put Impl into the class scope
+ // and put the typedef both here (for use in assert statement) and
+ // in the Impl class. But both definitions must be the same.
+ typedef typename internal::Function<F>::Result Result;
+
+ // Asserts at compile time that F returns void.
+ CompileAssertTypesEqual<void, Result>();
+
+ return Action<F>(new Impl<F>(action_));
+ }
+
+ private:
+ template <typename F>
+ class Impl : public ActionInterface<F> {
+ public:
+ typedef typename internal::Function<F>::Result Result;
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ explicit Impl(const A& action) : action_(action) {}
+
+ virtual void Perform(const ArgumentTuple& args) {
+ // Performs the action and ignores its result.
+ action_.Perform(args);
+ }
+
+ private:
+ // Type OriginalFunction is the same as F except that its return
+ // type is IgnoredValue.
+ typedef typename internal::Function<F>::MakeResultIgnoredValue
+ OriginalFunction;
+
+ const Action<OriginalFunction> action_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
+ };
+
+ const A action_;
+
+ GTEST_DISALLOW_ASSIGN_(IgnoreResultAction);
+};
+
+// A ReferenceWrapper<T> object represents a reference to type T,
+// which can be either const or not. It can be explicitly converted
+// from, and implicitly converted to, a T&. Unlike a reference,
+// ReferenceWrapper<T> can be copied and can survive template type
+// inference. This is used to support by-reference arguments in the
+// InvokeArgument<N>(...) action. The idea was from "reference
+// wrappers" in tr1, which we don't have in our source tree yet.
+template <typename T>
+class ReferenceWrapper {
+ public:
+ // Constructs a ReferenceWrapper<T> object from a T&.
+ explicit ReferenceWrapper(T& l_value) : pointer_(&l_value) {} // NOLINT
+
+ // Allows a ReferenceWrapper<T> object to be implicitly converted to
+ // a T&.
+ operator T&() const { return *pointer_; }
+ private:
+ T* pointer_;
+};
+
+// Allows the expression ByRef(x) to be printed as a reference to x.
+template <typename T>
+void PrintTo(const ReferenceWrapper<T>& ref, ::std::ostream* os) {
+ T& value = ref;
+ UniversalPrinter<T&>::Print(value, os);
+}
+
+// Does two actions sequentially. Used for implementing the DoAll(a1,
+// a2, ...) action.
+template <typename Action1, typename Action2>
+class DoBothAction {
+ public:
+ DoBothAction(Action1 action1, Action2 action2)
+ : action1_(action1), action2_(action2) {}
+
+ // This template type conversion operator allows DoAll(a1, ..., a_n)
+ // to be used in ANY function of compatible type.
+ template <typename F>
+ operator Action<F>() const {
+ return Action<F>(new Impl<F>(action1_, action2_));
+ }
+
+ private:
+ // Implements the DoAll(...) action for a particular function type F.
+ template <typename F>
+ class Impl : public ActionInterface<F> {
+ public:
+ typedef typename Function<F>::Result Result;
+ typedef typename Function<F>::ArgumentTuple ArgumentTuple;
+ typedef typename Function<F>::MakeResultVoid VoidResult;
+
+ Impl(const Action<VoidResult>& action1, const Action<F>& action2)
+ : action1_(action1), action2_(action2) {}
+
+ virtual Result Perform(const ArgumentTuple& args) {
+ action1_.Perform(args);
+ return action2_.Perform(args);
+ }
+
+ private:
+ const Action<VoidResult> action1_;
+ const Action<F> action2_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
+ };
+
+ Action1 action1_;
+ Action2 action2_;
+
+ GTEST_DISALLOW_ASSIGN_(DoBothAction);
+};
+
+} // namespace internal
+
+// An Unused object can be implicitly constructed from ANY value.
+// This is handy when defining actions that ignore some or all of the
+// mock function arguments. For example, given
+//
+// MOCK_METHOD3(Foo, double(const string& label, double x, double y));
+// MOCK_METHOD3(Bar, double(int index, double x, double y));
+//
+// instead of
+//
+// double DistanceToOriginWithLabel(const string& label, double x, double y) {
+// return sqrt(x*x + y*y);
+// }
+// double DistanceToOriginWithIndex(int index, double x, double y) {
+// return sqrt(x*x + y*y);
+// }
+// ...
+// EXEPCT_CALL(mock, Foo("abc", _, _))
+// .WillOnce(Invoke(DistanceToOriginWithLabel));
+// EXEPCT_CALL(mock, Bar(5, _, _))
+// .WillOnce(Invoke(DistanceToOriginWithIndex));
+//
+// you could write
+//
+// // We can declare any uninteresting argument as Unused.
+// double DistanceToOrigin(Unused, double x, double y) {
+// return sqrt(x*x + y*y);
+// }
+// ...
+// EXEPCT_CALL(mock, Foo("abc", _, _)).WillOnce(Invoke(DistanceToOrigin));
+// EXEPCT_CALL(mock, Bar(5, _, _)).WillOnce(Invoke(DistanceToOrigin));
+typedef internal::IgnoredValue Unused;
+
+// This constructor allows us to turn an Action<From> object into an
+// Action<To>, as long as To's arguments can be implicitly converted
+// to From's and From's return type cann be implicitly converted to
+// To's.
+template <typename To>
+template <typename From>
+Action<To>::Action(const Action<From>& from)
+ : impl_(new internal::ActionAdaptor<To, From>(from)) {}
+
+// Creates an action that returns 'value'. 'value' is passed by value
+// instead of const reference - otherwise Return("string literal")
+// will trigger a compiler error about using array as initializer.
+template <typename R>
+internal::ReturnAction<R> Return(R value) {
+ return internal::ReturnAction<R>(value);
+}
+
+// Creates an action that returns NULL.
+inline PolymorphicAction<internal::ReturnNullAction> ReturnNull() {
+ return MakePolymorphicAction(internal::ReturnNullAction());
+}
+
+// Creates an action that returns from a void function.
+inline PolymorphicAction<internal::ReturnVoidAction> Return() {
+ return MakePolymorphicAction(internal::ReturnVoidAction());
+}
+
+// Creates an action that returns the reference to a variable.
+template <typename R>
+inline internal::ReturnRefAction<R> ReturnRef(R& x) { // NOLINT
+ return internal::ReturnRefAction<R>(x);
+}
+
+// Creates an action that returns the reference to a copy of the
+// argument. The copy is created when the action is constructed and
+// lives as long as the action.
+template <typename R>
+inline internal::ReturnRefOfCopyAction<R> ReturnRefOfCopy(const R& x) {
+ return internal::ReturnRefOfCopyAction<R>(x);
+}
+
+// Creates an action that does the default action for the give mock function.
+inline internal::DoDefaultAction DoDefault() {
+ return internal::DoDefaultAction();
+}
+
+// Creates an action that sets the variable pointed by the N-th
+// (0-based) function argument to 'value'.
+template <size_t N, typename T>
+PolymorphicAction<
+ internal::SetArgumentPointeeAction<
+ N, T, internal::IsAProtocolMessage<T>::value> >
+SetArgPointee(const T& x) {
+ return MakePolymorphicAction(internal::SetArgumentPointeeAction<
+ N, T, internal::IsAProtocolMessage<T>::value>(x));
+}
+
+#if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)
+// This overload allows SetArgPointee() to accept a string literal.
+// GCC prior to the version 4.0 and Symbian C++ compiler cannot distinguish
+// this overload from the templated version and emit a compile error.
+template <size_t N>
+PolymorphicAction<
+ internal::SetArgumentPointeeAction<N, const char*, false> >
+SetArgPointee(const char* p) {
+ return MakePolymorphicAction(internal::SetArgumentPointeeAction<
+ N, const char*, false>(p));
+}
+
+template <size_t N>
+PolymorphicAction<
+ internal::SetArgumentPointeeAction<N, const wchar_t*, false> >
+SetArgPointee(const wchar_t* p) {
+ return MakePolymorphicAction(internal::SetArgumentPointeeAction<
+ N, const wchar_t*, false>(p));
+}
+#endif
+
+// The following version is DEPRECATED.
+template <size_t N, typename T>
+PolymorphicAction<
+ internal::SetArgumentPointeeAction<
+ N, T, internal::IsAProtocolMessage<T>::value> >
+SetArgumentPointee(const T& x) {
+ return MakePolymorphicAction(internal::SetArgumentPointeeAction<
+ N, T, internal::IsAProtocolMessage<T>::value>(x));
+}
+
+// Creates an action that sets a pointer referent to a given value.
+template <typename T1, typename T2>
+PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
+ return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val));
+}
+
+#if !GTEST_OS_WINDOWS_MOBILE
+
+// Creates an action that sets errno and returns the appropriate error.
+template <typename T>
+PolymorphicAction<internal::SetErrnoAndReturnAction<T> >
+SetErrnoAndReturn(int errval, T result) {
+ return MakePolymorphicAction(
+ internal::SetErrnoAndReturnAction<T>(errval, result));
+}
+
+#endif // !GTEST_OS_WINDOWS_MOBILE
+
+// Various overloads for InvokeWithoutArgs().
+
+// Creates an action that invokes 'function_impl' with no argument.
+template <typename FunctionImpl>
+PolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl> >
+InvokeWithoutArgs(FunctionImpl function_impl) {
+ return MakePolymorphicAction(
+ internal::InvokeWithoutArgsAction<FunctionImpl>(function_impl));
+}
+
+// Creates an action that invokes the given method on the given object
+// with no argument.
+template <class Class, typename MethodPtr>
+PolymorphicAction<internal::InvokeMethodWithoutArgsAction<Class, MethodPtr> >
+InvokeWithoutArgs(Class* obj_ptr, MethodPtr method_ptr) {
+ return MakePolymorphicAction(
+ internal::InvokeMethodWithoutArgsAction<Class, MethodPtr>(
+ obj_ptr, method_ptr));
+}
+
+// Creates an action that performs an_action and throws away its
+// result. In other words, it changes the return type of an_action to
+// void. an_action MUST NOT return void, or the code won't compile.
+template <typename A>
+inline internal::IgnoreResultAction<A> IgnoreResult(const A& an_action) {
+ return internal::IgnoreResultAction<A>(an_action);
+}
+
+// Creates a reference wrapper for the given L-value. If necessary,
+// you can explicitly specify the type of the reference. For example,
+// suppose 'derived' is an object of type Derived, ByRef(derived)
+// would wrap a Derived&. If you want to wrap a const Base& instead,
+// where Base is a base class of Derived, just write:
+//
+// ByRef<const Base>(derived)
+template <typename T>
+inline internal::ReferenceWrapper<T> ByRef(T& l_value) { // NOLINT
+ return internal::ReferenceWrapper<T>(l_value);
+}
+
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
diff --git a/lib/gtest/include/gmock/gmock-cardinalities.h b/lib/gtest/include/gmock/gmock-cardinalities.h
new file mode 100644
index 0000000..954a86e
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-cardinalities.h
@@ -0,0 +1,146 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements some commonly used cardinalities. More
+// cardinalities can be defined by the user implementing the
+// CardinalityInterface interface if necessary.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
+
+#include <limits.h>
+#include <ostream> // NOLINT
+#include "gmock/internal/gmock-port.h"
+#include "gtest/gtest.h"
+
+namespace testing {
+
+// To implement a cardinality Foo, define:
+// 1. a class FooCardinality that implements the
+// CardinalityInterface interface, and
+// 2. a factory function that creates a Cardinality object from a
+// const FooCardinality*.
+//
+// The two-level delegation design follows that of Matcher, providing
+// consistency for extension developers. It also eases ownership
+// management as Cardinality objects can now be copied like plain values.
+
+// The implementation of a cardinality.
+class CardinalityInterface {
+ public:
+ virtual ~CardinalityInterface() {}
+
+ // Conservative estimate on the lower/upper bound of the number of
+ // calls allowed.
+ virtual int ConservativeLowerBound() const { return 0; }
+ virtual int ConservativeUpperBound() const { return INT_MAX; }
+
+ // Returns true iff call_count calls will satisfy this cardinality.
+ virtual bool IsSatisfiedByCallCount(int call_count) const = 0;
+
+ // Returns true iff call_count calls will saturate this cardinality.
+ virtual bool IsSaturatedByCallCount(int call_count) const = 0;
+
+ // Describes self to an ostream.
+ virtual void DescribeTo(::std::ostream* os) const = 0;
+};
+
+// A Cardinality is a copyable and IMMUTABLE (except by assignment)
+// object that specifies how many times a mock function is expected to
+// be called. The implementation of Cardinality is just a linked_ptr
+// to const CardinalityInterface, so copying is fairly cheap.
+// Don't inherit from Cardinality!
+class Cardinality {
+ public:
+ // Constructs a null cardinality. Needed for storing Cardinality
+ // objects in STL containers.
+ Cardinality() {}
+
+ // Constructs a Cardinality from its implementation.
+ explicit Cardinality(const CardinalityInterface* impl) : impl_(impl) {}
+
+ // Conservative estimate on the lower/upper bound of the number of
+ // calls allowed.
+ int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); }
+ int ConservativeUpperBound() const { return impl_->ConservativeUpperBound(); }
+
+ // Returns true iff call_count calls will satisfy this cardinality.
+ bool IsSatisfiedByCallCount(int call_count) const {
+ return impl_->IsSatisfiedByCallCount(call_count);
+ }
+
+ // Returns true iff call_count calls will saturate this cardinality.
+ bool IsSaturatedByCallCount(int call_count) const {
+ return impl_->IsSaturatedByCallCount(call_count);
+ }
+
+ // Returns true iff call_count calls will over-saturate this
+ // cardinality, i.e. exceed the maximum number of allowed calls.
+ bool IsOverSaturatedByCallCount(int call_count) const {
+ return impl_->IsSaturatedByCallCount(call_count) &&
+ !impl_->IsSatisfiedByCallCount(call_count);
+ }
+
+ // Describes self to an ostream
+ void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }
+
+ // Describes the given actual call count to an ostream.
+ static void DescribeActualCallCountTo(int actual_call_count,
+ ::std::ostream* os);
+ private:
+ internal::linked_ptr<const CardinalityInterface> impl_;
+};
+
+// Creates a cardinality that allows at least n calls.
+Cardinality AtLeast(int n);
+
+// Creates a cardinality that allows at most n calls.
+Cardinality AtMost(int n);
+
+// Creates a cardinality that allows any number of calls.
+Cardinality AnyNumber();
+
+// Creates a cardinality that allows between min and max calls.
+Cardinality Between(int min, int max);
+
+// Creates a cardinality that allows exactly n calls.
+Cardinality Exactly(int n);
+
+// Creates a cardinality from its implementation.
+inline Cardinality MakeCardinality(const CardinalityInterface* c) {
+ return Cardinality(c);
+}
+
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
diff --git a/lib/gtest/include/gmock/gmock-generated-actions.h b/lib/gtest/include/gmock/gmock-generated-actions.h
new file mode 100644
index 0000000..635bb59
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-generated-actions.h
@@ -0,0 +1,2419 @@
+// This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
+
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements some commonly used variadic actions.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
+
+#include "gmock/gmock-actions.h"
+#include "gmock/internal/gmock-port.h"
+
+namespace testing {
+namespace internal {
+
+// InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary
+// function or method with the unpacked values, where F is a function
+// type that takes N arguments.
+template <typename Result, typename ArgumentTuple>
+class InvokeHelper;
+
+template <typename R>
+class InvokeHelper<R, ::std::tr1::tuple<> > {
+ public:
+ template <typename Function>
+ static R Invoke(Function function, const ::std::tr1::tuple<>&) {
+ return function();
+ }
+
+ template <class Class, typename MethodPtr>
+ static R InvokeMethod(Class* obj_ptr,
+ MethodPtr method_ptr,
+ const ::std::tr1::tuple<>&) {
+ return (obj_ptr->*method_ptr)();
+ }
+};
+
+template <typename R, typename A1>
+class InvokeHelper<R, ::std::tr1::tuple<A1> > {
+ public:
+ template <typename Function>
+ static R Invoke(Function function, const ::std::tr1::tuple<A1>& args) {
+ using ::std::tr1::get;
+ return function(get<0>(args));
+ }
+
+ template <class Class, typename MethodPtr>
+ static R InvokeMethod(Class* obj_ptr,
+ MethodPtr method_ptr,
+ const ::std::tr1::tuple<A1>& args) {
+ using ::std::tr1::get;
+ return (obj_ptr->*method_ptr)(get<0>(args));
+ }
+};
+
+template <typename R, typename A1, typename A2>
+class InvokeHelper<R, ::std::tr1::tuple<A1, A2> > {
+ public:
+ template <typename Function>
+ static R Invoke(Function function, const ::std::tr1::tuple<A1, A2>& args) {
+ using ::std::tr1::get;
+ return function(get<0>(args), get<1>(args));
+ }
+
+ template <class Class, typename MethodPtr>
+ static R InvokeMethod(Class* obj_ptr,
+ MethodPtr method_ptr,
+ const ::std::tr1::tuple<A1, A2>& args) {
+ using ::std::tr1::get;
+ return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3>
+class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3> > {
+ public:
+ template <typename Function>
+ static R Invoke(Function function, const ::std::tr1::tuple<A1, A2,
+ A3>& args) {
+ using ::std::tr1::get;
+ return function(get<0>(args), get<1>(args), get<2>(args));
+ }
+
+ template <class Class, typename MethodPtr>
+ static R InvokeMethod(Class* obj_ptr,
+ MethodPtr method_ptr,
+ const ::std::tr1::tuple<A1, A2, A3>& args) {
+ using ::std::tr1::get;
+ return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4>
+class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4> > {
+ public:
+ template <typename Function>
+ static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3,
+ A4>& args) {
+ using ::std::tr1::get;
+ return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args));
+ }
+
+ template <class Class, typename MethodPtr>
+ static R InvokeMethod(Class* obj_ptr,
+ MethodPtr method_ptr,
+ const ::std::tr1::tuple<A1, A2, A3, A4>& args) {
+ using ::std::tr1::get;
+ return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
+ get<3>(args));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5>
+class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5> > {
+ public:
+ template <typename Function>
+ static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
+ A5>& args) {
+ using ::std::tr1::get;
+ return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
+ get<4>(args));
+ }
+
+ template <class Class, typename MethodPtr>
+ static R InvokeMethod(Class* obj_ptr,
+ MethodPtr method_ptr,
+ const ::std::tr1::tuple<A1, A2, A3, A4, A5>& args) {
+ using ::std::tr1::get;
+ return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
+ get<3>(args), get<4>(args));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6>
+class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> > {
+ public:
+ template <typename Function>
+ static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
+ A5, A6>& args) {
+ using ::std::tr1::get;
+ return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
+ get<4>(args), get<5>(args));
+ }
+
+ template <class Class, typename MethodPtr>
+ static R InvokeMethod(Class* obj_ptr,
+ MethodPtr method_ptr,
+ const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6>& args) {
+ using ::std::tr1::get;
+ return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
+ get<3>(args), get<4>(args), get<5>(args));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7>
+class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> > {
+ public:
+ template <typename Function>
+ static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
+ A5, A6, A7>& args) {
+ using ::std::tr1::get;
+ return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
+ get<4>(args), get<5>(args), get<6>(args));
+ }
+
+ template <class Class, typename MethodPtr>
+ static R InvokeMethod(Class* obj_ptr,
+ MethodPtr method_ptr,
+ const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6,
+ A7>& args) {
+ using ::std::tr1::get;
+ return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
+ get<3>(args), get<4>(args), get<5>(args), get<6>(args));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7, typename A8>
+class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
+ public:
+ template <typename Function>
+ static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
+ A5, A6, A7, A8>& args) {
+ using ::std::tr1::get;
+ return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
+ get<4>(args), get<5>(args), get<6>(args), get<7>(args));
+ }
+
+ template <class Class, typename MethodPtr>
+ static R InvokeMethod(Class* obj_ptr,
+ MethodPtr method_ptr,
+ const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7,
+ A8>& args) {
+ using ::std::tr1::get;
+ return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
+ get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7, typename A8, typename A9>
+class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
+ public:
+ template <typename Function>
+ static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
+ A5, A6, A7, A8, A9>& args) {
+ using ::std::tr1::get;
+ return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
+ get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args));
+ }
+
+ template <class Class, typename MethodPtr>
+ static R InvokeMethod(Class* obj_ptr,
+ MethodPtr method_ptr,
+ const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
+ A9>& args) {
+ using ::std::tr1::get;
+ return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
+ get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args),
+ get<8>(args));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7, typename A8, typename A9,
+ typename A10>
+class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
+ A10> > {
+ public:
+ template <typename Function>
+ static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
+ A5, A6, A7, A8, A9, A10>& args) {
+ using ::std::tr1::get;
+ return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
+ get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
+ get<9>(args));
+ }
+
+ template <class Class, typename MethodPtr>
+ static R InvokeMethod(Class* obj_ptr,
+ MethodPtr method_ptr,
+ const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
+ A9, A10>& args) {
+ using ::std::tr1::get;
+ return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
+ get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args),
+ get<8>(args), get<9>(args));
+ }
+};
+
+// CallableHelper has static methods for invoking "callables",
+// i.e. function pointers and functors. It uses overloading to
+// provide a uniform interface for invoking different kinds of
+// callables. In particular, you can use:
+//
+// CallableHelper<R>::Call(callable, a1, a2, ..., an)
+//
+// to invoke an n-ary callable, where R is its return type. If an
+// argument, say a2, needs to be passed by reference, you should write
+// ByRef(a2) instead of a2 in the above expression.
+template <typename R>
+class CallableHelper {
+ public:
+ // Calls a nullary callable.
+ template <typename Function>
+ static R Call(Function function) { return function(); }
+
+ // Calls a unary callable.
+
+ // We deliberately pass a1 by value instead of const reference here
+ // in case it is a C-string literal. If we had declared the
+ // parameter as 'const A1& a1' and write Call(function, "Hi"), the
+ // compiler would've thought A1 is 'char[3]', which causes trouble
+ // when you need to copy a value of type A1. By declaring the
+ // parameter as 'A1 a1', the compiler will correctly infer that A1
+ // is 'const char*' when it sees Call(function, "Hi").
+ //
+ // Since this function is defined inline, the compiler can get rid
+ // of the copying of the arguments. Therefore the performance won't
+ // be hurt.
+ template <typename Function, typename A1>
+ static R Call(Function function, A1 a1) { return function(a1); }
+
+ // Calls a binary callable.
+ template <typename Function, typename A1, typename A2>
+ static R Call(Function function, A1 a1, A2 a2) {
+ return function(a1, a2);
+ }
+
+ // Calls a ternary callable.
+ template <typename Function, typename A1, typename A2, typename A3>
+ static R Call(Function function, A1 a1, A2 a2, A3 a3) {
+ return function(a1, a2, a3);
+ }
+
+ // Calls a 4-ary callable.
+ template <typename Function, typename A1, typename A2, typename A3,
+ typename A4>
+ static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4) {
+ return function(a1, a2, a3, a4);
+ }
+
+ // Calls a 5-ary callable.
+ template <typename Function, typename A1, typename A2, typename A3,
+ typename A4, typename A5>
+ static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
+ return function(a1, a2, a3, a4, a5);
+ }
+
+ // Calls a 6-ary callable.
+ template <typename Function, typename A1, typename A2, typename A3,
+ typename A4, typename A5, typename A6>
+ static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
+ return function(a1, a2, a3, a4, a5, a6);
+ }
+
+ // Calls a 7-ary callable.
+ template <typename Function, typename A1, typename A2, typename A3,
+ typename A4, typename A5, typename A6, typename A7>
+ static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
+ A7 a7) {
+ return function(a1, a2, a3, a4, a5, a6, a7);
+ }
+
+ // Calls a 8-ary callable.
+ template <typename Function, typename A1, typename A2, typename A3,
+ typename A4, typename A5, typename A6, typename A7, typename A8>
+ static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
+ A7 a7, A8 a8) {
+ return function(a1, a2, a3, a4, a5, a6, a7, a8);
+ }
+
+ // Calls a 9-ary callable.
+ template <typename Function, typename A1, typename A2, typename A3,
+ typename A4, typename A5, typename A6, typename A7, typename A8,
+ typename A9>
+ static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
+ A7 a7, A8 a8, A9 a9) {
+ return function(a1, a2, a3, a4, a5, a6, a7, a8, a9);
+ }
+
+ // Calls a 10-ary callable.
+ template <typename Function, typename A1, typename A2, typename A3,
+ typename A4, typename A5, typename A6, typename A7, typename A8,
+ typename A9, typename A10>
+ static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
+ A7 a7, A8 a8, A9 a9, A10 a10) {
+ return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
+ }
+
+}; // class CallableHelper
+
+// An INTERNAL macro for extracting the type of a tuple field. It's
+// subject to change without notice - DO NOT USE IN USER CODE!
+#define GMOCK_FIELD_(Tuple, N) \
+ typename ::std::tr1::tuple_element<N, Tuple>::type
+
+// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the
+// type of an n-ary function whose i-th (1-based) argument type is the
+// k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
+// type, and whose return type is Result. For example,
+// SelectArgs<int, ::std::tr1::tuple<bool, char, double, long>, 0, 3>::type
+// is int(bool, long).
+//
+// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
+// returns the selected fields (k1, k2, ..., k_n) of args as a tuple.
+// For example,
+// SelectArgs<int, ::std::tr1::tuple<bool, char, double>, 2, 0>::Select(
+// ::std::tr1::make_tuple(true, 'a', 2.5))
+// returns ::std::tr1::tuple (2.5, true).
+//
+// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be
+// in the range [0, 10]. Duplicates are allowed and they don't have
+// to be in an ascending or descending order.
+
+template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
+ int k4, int k5, int k6, int k7, int k8, int k9, int k10>
+class SelectArgs {
+ public:
+ typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
+ GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
+ GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
+ GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
+ GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9),
+ GMOCK_FIELD_(ArgumentTuple, k10));
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& args) {
+ using ::std::tr1::get;
+ return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
+ get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
+ get<k8>(args), get<k9>(args), get<k10>(args));
+ }
+};
+
+template <typename Result, typename ArgumentTuple>
+class SelectArgs<Result, ArgumentTuple,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
+ public:
+ typedef Result type();
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& /* args */) {
+ using ::std::tr1::get;
+ return SelectedArgs();
+ }
+};
+
+template <typename Result, typename ArgumentTuple, int k1>
+class SelectArgs<Result, ArgumentTuple,
+ k1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
+ public:
+ typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1));
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& args) {
+ using ::std::tr1::get;
+ return SelectedArgs(get<k1>(args));
+ }
+};
+
+template <typename Result, typename ArgumentTuple, int k1, int k2>
+class SelectArgs<Result, ArgumentTuple,
+ k1, k2, -1, -1, -1, -1, -1, -1, -1, -1> {
+ public:
+ typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
+ GMOCK_FIELD_(ArgumentTuple, k2));
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& args) {
+ using ::std::tr1::get;
+ return SelectedArgs(get<k1>(args), get<k2>(args));
+ }
+};
+
+template <typename Result, typename ArgumentTuple, int k1, int k2, int k3>
+class SelectArgs<Result, ArgumentTuple,
+ k1, k2, k3, -1, -1, -1, -1, -1, -1, -1> {
+ public:
+ typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
+ GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3));
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& args) {
+ using ::std::tr1::get;
+ return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args));
+ }
+};
+
+template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
+ int k4>
+class SelectArgs<Result, ArgumentTuple,
+ k1, k2, k3, k4, -1, -1, -1, -1, -1, -1> {
+ public:
+ typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
+ GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
+ GMOCK_FIELD_(ArgumentTuple, k4));
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& args) {
+ using ::std::tr1::get;
+ return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
+ get<k4>(args));
+ }
+};
+
+template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
+ int k4, int k5>
+class SelectArgs<Result, ArgumentTuple,
+ k1, k2, k3, k4, k5, -1, -1, -1, -1, -1> {
+ public:
+ typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
+ GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
+ GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5));
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& args) {
+ using ::std::tr1::get;
+ return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
+ get<k4>(args), get<k5>(args));
+ }
+};
+
+template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
+ int k4, int k5, int k6>
+class SelectArgs<Result, ArgumentTuple,
+ k1, k2, k3, k4, k5, k6, -1, -1, -1, -1> {
+ public:
+ typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
+ GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
+ GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
+ GMOCK_FIELD_(ArgumentTuple, k6));
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& args) {
+ using ::std::tr1::get;
+ return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
+ get<k4>(args), get<k5>(args), get<k6>(args));
+ }
+};
+
+template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
+ int k4, int k5, int k6, int k7>
+class SelectArgs<Result, ArgumentTuple,
+ k1, k2, k3, k4, k5, k6, k7, -1, -1, -1> {
+ public:
+ typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
+ GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
+ GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
+ GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7));
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& args) {
+ using ::std::tr1::get;
+ return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
+ get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args));
+ }
+};
+
+template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
+ int k4, int k5, int k6, int k7, int k8>
+class SelectArgs<Result, ArgumentTuple,
+ k1, k2, k3, k4, k5, k6, k7, k8, -1, -1> {
+ public:
+ typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
+ GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
+ GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
+ GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
+ GMOCK_FIELD_(ArgumentTuple, k8));
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& args) {
+ using ::std::tr1::get;
+ return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
+ get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
+ get<k8>(args));
+ }
+};
+
+template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
+ int k4, int k5, int k6, int k7, int k8, int k9>
+class SelectArgs<Result, ArgumentTuple,
+ k1, k2, k3, k4, k5, k6, k7, k8, k9, -1> {
+ public:
+ typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
+ GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
+ GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
+ GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
+ GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9));
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& args) {
+ using ::std::tr1::get;
+ return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
+ get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
+ get<k8>(args), get<k9>(args));
+ }
+};
+
+#undef GMOCK_FIELD_
+
+// Implements the WithArgs action.
+template <typename InnerAction, int k1 = -1, int k2 = -1, int k3 = -1,
+ int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
+ int k9 = -1, int k10 = -1>
+class WithArgsAction {
+ public:
+ explicit WithArgsAction(const InnerAction& action) : action_(action) {}
+
+ template <typename F>
+ operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }
+
+ private:
+ template <typename F>
+ class Impl : public ActionInterface<F> {
+ public:
+ typedef typename Function<F>::Result Result;
+ typedef typename Function<F>::ArgumentTuple ArgumentTuple;
+
+ explicit Impl(const InnerAction& action) : action_(action) {}
+
+ virtual Result Perform(const ArgumentTuple& args) {
+ return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, k4,
+ k5, k6, k7, k8, k9, k10>::Select(args));
+ }
+
+ private:
+ typedef typename SelectArgs<Result, ArgumentTuple,
+ k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType;
+
+ Action<InnerFunctionType> action_;
+ };
+
+ const InnerAction action_;
+
+ GTEST_DISALLOW_ASSIGN_(WithArgsAction);
+};
+
+// A macro from the ACTION* family (defined later in this file)
+// defines an action that can be used in a mock function. Typically,
+// these actions only care about a subset of the arguments of the mock
+// function. For example, if such an action only uses the second
+// argument, it can be used in any mock function that takes >= 2
+// arguments where the type of the second argument is compatible.
+//
+// Therefore, the action implementation must be prepared to take more
+// arguments than it needs. The ExcessiveArg type is used to
+// represent those excessive arguments. In order to keep the compiler
+// error messages tractable, we define it in the testing namespace
+// instead of testing::internal. However, this is an INTERNAL TYPE
+// and subject to change without notice, so a user MUST NOT USE THIS
+// TYPE DIRECTLY.
+struct ExcessiveArg {};
+
+// A helper class needed for implementing the ACTION* macros.
+template <typename Result, class Impl>
+class ActionHelper {
+ public:
+ static Result Perform(Impl* impl, const ::std::tr1::tuple<>& args) {
+ using ::std::tr1::get;
+ return impl->template gmock_PerformImpl<>(args, ExcessiveArg(),
+ ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
+ ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
+ ExcessiveArg());
+ }
+
+ template <typename A0>
+ static Result Perform(Impl* impl, const ::std::tr1::tuple<A0>& args) {
+ using ::std::tr1::get;
+ return impl->template gmock_PerformImpl<A0>(args, get<0>(args),
+ ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
+ ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
+ ExcessiveArg());
+ }
+
+ template <typename A0, typename A1>
+ static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1>& args) {
+ using ::std::tr1::get;
+ return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args),
+ get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
+ ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
+ ExcessiveArg());
+ }
+
+ template <typename A0, typename A1, typename A2>
+ static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2>& args) {
+ using ::std::tr1::get;
+ return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args),
+ get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(),
+ ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
+ ExcessiveArg());
+ }
+
+ template <typename A0, typename A1, typename A2, typename A3>
+ static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2,
+ A3>& args) {
+ using ::std::tr1::get;
+ return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(args),
+ get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(),
+ ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
+ ExcessiveArg());
+ }
+
+ template <typename A0, typename A1, typename A2, typename A3, typename A4>
+ static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3,
+ A4>& args) {
+ using ::std::tr1::get;
+ return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args,
+ get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
+ ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
+ ExcessiveArg());
+ }
+
+ template <typename A0, typename A1, typename A2, typename A3, typename A4,
+ typename A5>
+ static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
+ A5>& args) {
+ using ::std::tr1::get;
+ return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args,
+ get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
+ get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
+ ExcessiveArg());
+ }
+
+ template <typename A0, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6>
+ static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
+ A5, A6>& args) {
+ using ::std::tr1::get;
+ return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args,
+ get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
+ get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(),
+ ExcessiveArg());
+ }
+
+ template <typename A0, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7>
+ static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
+ A5, A6, A7>& args) {
+ using ::std::tr1::get;
+ return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6,
+ A7>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
+ get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(),
+ ExcessiveArg());
+ }
+
+ template <typename A0, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7, typename A8>
+ static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
+ A5, A6, A7, A8>& args) {
+ using ::std::tr1::get;
+ return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7,
+ A8>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
+ get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
+ ExcessiveArg());
+ }
+
+ template <typename A0, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7, typename A8, typename A9>
+ static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
+ A5, A6, A7, A8, A9>& args) {
+ using ::std::tr1::get;
+ return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8,
+ A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
+ get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
+ get<9>(args));
+ }
+};
+
+} // namespace internal
+
+// Various overloads for Invoke().
+
+// WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes
+// the selected arguments of the mock function to an_action and
+// performs it. It serves as an adaptor between actions with
+// different argument lists. C++ doesn't support default arguments for
+// function templates, so we have to overload it.
+template <int k1, typename InnerAction>
+inline internal::WithArgsAction<InnerAction, k1>
+WithArgs(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction, k1>(action);
+}
+
+template <int k1, int k2, typename InnerAction>
+inline internal::WithArgsAction<InnerAction, k1, k2>
+WithArgs(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction, k1, k2>(action);
+}
+
+template <int k1, int k2, int k3, typename InnerAction>
+inline internal::WithArgsAction<InnerAction, k1, k2, k3>
+WithArgs(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction, k1, k2, k3>(action);
+}
+
+template <int k1, int k2, int k3, int k4, typename InnerAction>
+inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4>
+WithArgs(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction, k1, k2, k3, k4>(action);
+}
+
+template <int k1, int k2, int k3, int k4, int k5, typename InnerAction>
+inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>
+WithArgs(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>(action);
+}
+
+template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerAction>
+inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>
+WithArgs(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>(action);
+}
+
+template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
+ typename InnerAction>
+inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7>
+WithArgs(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6,
+ k7>(action);
+}
+
+template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
+ typename InnerAction>
+inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8>
+WithArgs(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7,
+ k8>(action);
+}
+
+template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
+ int k9, typename InnerAction>
+inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, k9>
+WithArgs(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
+ k9>(action);
+}
+
+template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
+ int k9, int k10, typename InnerAction>
+inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
+ k9, k10>
+WithArgs(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
+ k9, k10>(action);
+}
+
+// Creates an action that does actions a1, a2, ..., sequentially in
+// each invocation.
+template <typename Action1, typename Action2>
+inline internal::DoBothAction<Action1, Action2>
+DoAll(Action1 a1, Action2 a2) {
+ return internal::DoBothAction<Action1, Action2>(a1, a2);
+}
+
+template <typename Action1, typename Action2, typename Action3>
+inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
+ Action3> >
+DoAll(Action1 a1, Action2 a2, Action3 a3) {
+ return DoAll(a1, DoAll(a2, a3));
+}
+
+template <typename Action1, typename Action2, typename Action3,
+ typename Action4>
+inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
+ internal::DoBothAction<Action3, Action4> > >
+DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4) {
+ return DoAll(a1, DoAll(a2, a3, a4));
+}
+
+template <typename Action1, typename Action2, typename Action3,
+ typename Action4, typename Action5>
+inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
+ internal::DoBothAction<Action3, internal::DoBothAction<Action4,
+ Action5> > > >
+DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5) {
+ return DoAll(a1, DoAll(a2, a3, a4, a5));
+}
+
+template <typename Action1, typename Action2, typename Action3,
+ typename Action4, typename Action5, typename Action6>
+inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
+ internal::DoBothAction<Action3, internal::DoBothAction<Action4,
+ internal::DoBothAction<Action5, Action6> > > > >
+DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6) {
+ return DoAll(a1, DoAll(a2, a3, a4, a5, a6));
+}
+
+template <typename Action1, typename Action2, typename Action3,
+ typename Action4, typename Action5, typename Action6, typename Action7>
+inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
+ internal::DoBothAction<Action3, internal::DoBothAction<Action4,
+ internal::DoBothAction<Action5, internal::DoBothAction<Action6,
+ Action7> > > > > >
+DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
+ Action7 a7) {
+ return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7));
+}
+
+template <typename Action1, typename Action2, typename Action3,
+ typename Action4, typename Action5, typename Action6, typename Action7,
+ typename Action8>
+inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
+ internal::DoBothAction<Action3, internal::DoBothAction<Action4,
+ internal::DoBothAction<Action5, internal::DoBothAction<Action6,
+ internal::DoBothAction<Action7, Action8> > > > > > >
+DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
+ Action7 a7, Action8 a8) {
+ return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8));
+}
+
+template <typename Action1, typename Action2, typename Action3,
+ typename Action4, typename Action5, typename Action6, typename Action7,
+ typename Action8, typename Action9>
+inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
+ internal::DoBothAction<Action3, internal::DoBothAction<Action4,
+ internal::DoBothAction<Action5, internal::DoBothAction<Action6,
+ internal::DoBothAction<Action7, internal::DoBothAction<Action8,
+ Action9> > > > > > > >
+DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
+ Action7 a7, Action8 a8, Action9 a9) {
+ return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9));
+}
+
+template <typename Action1, typename Action2, typename Action3,
+ typename Action4, typename Action5, typename Action6, typename Action7,
+ typename Action8, typename Action9, typename Action10>
+inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
+ internal::DoBothAction<Action3, internal::DoBothAction<Action4,
+ internal::DoBothAction<Action5, internal::DoBothAction<Action6,
+ internal::DoBothAction<Action7, internal::DoBothAction<Action8,
+ internal::DoBothAction<Action9, Action10> > > > > > > > >
+DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
+ Action7 a7, Action8 a8, Action9 a9, Action10 a10) {
+ return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10));
+}
+
+} // namespace testing
+
+// The ACTION* family of macros can be used in a namespace scope to
+// define custom actions easily. The syntax:
+//
+// ACTION(name) { statements; }
+//
+// will define an action with the given name that executes the
+// statements. The value returned by the statements will be used as
+// the return value of the action. Inside the statements, you can
+// refer to the K-th (0-based) argument of the mock function by
+// 'argK', and refer to its type by 'argK_type'. For example:
+//
+// ACTION(IncrementArg1) {
+// arg1_type temp = arg1;
+// return ++(*temp);
+// }
+//
+// allows you to write
+//
+// ...WillOnce(IncrementArg1());
+//
+// You can also refer to the entire argument tuple and its type by
+// 'args' and 'args_type', and refer to the mock function type and its
+// return type by 'function_type' and 'return_type'.
+//
+// Note that you don't need to specify the types of the mock function
+// arguments. However rest assured that your code is still type-safe:
+// you'll get a compiler error if *arg1 doesn't support the ++
+// operator, or if the type of ++(*arg1) isn't compatible with the
+// mock function's return type, for example.
+//
+// Sometimes you'll want to parameterize the action. For that you can use
+// another macro:
+//
+// ACTION_P(name, param_name) { statements; }
+//
+// For example:
+//
+// ACTION_P(Add, n) { return arg0 + n; }
+//
+// will allow you to write:
+//
+// ...WillOnce(Add(5));
+//
+// Note that you don't need to provide the type of the parameter
+// either. If you need to reference the type of a parameter named
+// 'foo', you can write 'foo_type'. For example, in the body of
+// ACTION_P(Add, n) above, you can write 'n_type' to refer to the type
+// of 'n'.
+//
+// We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support
+// multi-parameter actions.
+//
+// For the purpose of typing, you can view
+//
+// ACTION_Pk(Foo, p1, ..., pk) { ... }
+//
+// as shorthand for
+//
+// template <typename p1_type, ..., typename pk_type>
+// FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... }
+//
+// In particular, you can provide the template type arguments
+// explicitly when invoking Foo(), as in Foo<long, bool>(5, false);
+// although usually you can rely on the compiler to infer the types
+// for you automatically. You can assign the result of expression
+// Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ...,
+// pk_type>. This can be useful when composing actions.
+//
+// You can also overload actions with different numbers of parameters:
+//
+// ACTION_P(Plus, a) { ... }
+// ACTION_P2(Plus, a, b) { ... }
+//
+// While it's tempting to always use the ACTION* macros when defining
+// a new action, you should also consider implementing ActionInterface
+// or using MakePolymorphicAction() instead, especially if you need to
+// use the action a lot. While these approaches require more work,
+// they give you more control on the types of the mock function
+// arguments and the action parameters, which in general leads to
+// better compiler error messages that pay off in the long run. They
+// also allow overloading actions based on parameter types (as opposed
+// to just based on the number of parameters).
+//
+// CAVEAT:
+//
+// ACTION*() can only be used in a namespace scope. The reason is
+// that C++ doesn't yet allow function-local types to be used to
+// instantiate templates. The up-coming C++0x standard will fix this.
+// Once that's done, we'll consider supporting using ACTION*() inside
+// a function.
+//
+// MORE INFORMATION:
+//
+// To learn more about using these macros, please search for 'ACTION'
+// on http://code.google.com/p/googlemock/wiki/CookBook.
+
+// An internal macro needed for implementing ACTION*().
+#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
+ const args_type& args GTEST_ATTRIBUTE_UNUSED_,\
+ arg0_type arg0 GTEST_ATTRIBUTE_UNUSED_,\
+ arg1_type arg1 GTEST_ATTRIBUTE_UNUSED_,\
+ arg2_type arg2 GTEST_ATTRIBUTE_UNUSED_,\
+ arg3_type arg3 GTEST_ATTRIBUTE_UNUSED_,\
+ arg4_type arg4 GTEST_ATTRIBUTE_UNUSED_,\
+ arg5_type arg5 GTEST_ATTRIBUTE_UNUSED_,\
+ arg6_type arg6 GTEST_ATTRIBUTE_UNUSED_,\
+ arg7_type arg7 GTEST_ATTRIBUTE_UNUSED_,\
+ arg8_type arg8 GTEST_ATTRIBUTE_UNUSED_,\
+ arg9_type arg9 GTEST_ATTRIBUTE_UNUSED_
+
+// Sometimes you want to give an action explicit template parameters
+// that cannot be inferred from its value parameters. ACTION() and
+// ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that
+// and can be viewed as an extension to ACTION() and ACTION_P*().
+//
+// The syntax:
+//
+// ACTION_TEMPLATE(ActionName,
+// HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),
+// AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }
+//
+// defines an action template that takes m explicit template
+// parameters and n value parameters. name_i is the name of the i-th
+// template parameter, and kind_i specifies whether it's a typename,
+// an integral constant, or a template. p_i is the name of the i-th
+// value parameter.
+//
+// Example:
+//
+// // DuplicateArg<k, T>(output) converts the k-th argument of the mock
+// // function to type T and copies it to *output.
+// ACTION_TEMPLATE(DuplicateArg,
+// HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
+// AND_1_VALUE_PARAMS(output)) {
+// *output = T(std::tr1::get<k>(args));
+// }
+// ...
+// int n;
+// EXPECT_CALL(mock, Foo(_, _))
+// .WillOnce(DuplicateArg<1, unsigned char>(&n));
+//
+// To create an instance of an action template, write:
+//
+// ActionName<t1, ..., t_m>(v1, ..., v_n)
+//
+// where the ts are the template arguments and the vs are the value
+// arguments. The value argument types are inferred by the compiler.
+// If you want to explicitly specify the value argument types, you can
+// provide additional template arguments:
+//
+// ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)
+//
+// where u_i is the desired type of v_i.
+//
+// ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the
+// number of value parameters, but not on the number of template
+// parameters. Without the restriction, the meaning of the following
+// is unclear:
+//
+// OverloadedAction<int, bool>(x);
+//
+// Are we using a single-template-parameter action where 'bool' refers
+// to the type of x, or are we using a two-template-parameter action
+// where the compiler is asked to infer the type of x?
+//
+// Implementation notes:
+//
+// GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and
+// GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for
+// implementing ACTION_TEMPLATE. The main trick we use is to create
+// new macro invocations when expanding a macro. For example, we have
+//
+// #define ACTION_TEMPLATE(name, template_params, value_params)
+// ... GMOCK_INTERNAL_DECL_##template_params ...
+//
+// which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)
+// to expand to
+//
+// ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...
+//
+// Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the
+// preprocessor will continue to expand it to
+//
+// ... typename T ...
+//
+// This technique conforms to the C++ standard and is portable. It
+// allows us to implement action templates using O(N) code, where N is
+// the maximum number of template/value parameters supported. Without
+// using it, we'd have to devote O(N^2) amount of code to implement all
+// combinations of m and n.
+
+// Declares the template parameters.
+#define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0
+#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
+ name1) kind0 name0, kind1 name1
+#define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2) kind0 name0, kind1 name1, kind2 name2
+#define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \
+ kind3 name3
+#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \
+ kind2 name2, kind3 name3, kind4 name4
+#define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \
+ kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
+#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
+ name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
+ kind5 name5, kind6 name6
+#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
+ kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \
+ kind4 name4, kind5 name5, kind6 name6, kind7 name7
+#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
+ kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \
+ kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \
+ kind8 name8
+#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
+ name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
+ name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \
+ kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \
+ kind6 name6, kind7 name7, kind8 name8, kind9 name9
+
+// Lists the template parameters.
+#define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0
+#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
+ name1) name0, name1
+#define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2) name0, name1, name2
+#define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2, kind3, name3) name0, name1, name2, name3
+#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \
+ name4
+#define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \
+ name2, name3, name4, name5
+#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
+ name6) name0, name1, name2, name3, name4, name5, name6
+#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
+ kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7
+#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
+ kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
+ kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \
+ name6, name7, name8
+#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
+ name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
+ name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \
+ name3, name4, name5, name6, name7, name8, name9
+
+// Declares the types of value parameters.
+#define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()
+#define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \
+ typename p0##_type, typename p1##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \
+ typename p0##_type, typename p1##_type, typename p2##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
+ typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
+ typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
+ typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
+ p6) , typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
+ p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
+ p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
+ p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \
+ typename p2##_type, typename p3##_type, typename p4##_type, \
+ typename p5##_type, typename p6##_type, typename p7##_type, \
+ typename p8##_type, typename p9##_type
+
+// Initializes the value parameters.
+#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\
+ ()
+#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\
+ (p0##_type gmock_p0) : p0(gmock_p0)
+#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\
+ (p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), p1(gmock_p1)
+#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\
+ (p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2)
+#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3)
+#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), \
+ p2(gmock_p2), p3(gmock_p3), p4(gmock_p4)
+#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, \
+ p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5)
+#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6)
+#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), \
+ p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
+ p7(gmock_p7)
+#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7, p8)\
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6, p7##_type gmock_p7, \
+ p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
+ p8(gmock_p8)
+#define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7, p8, p9)\
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
+ p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
+ p8(gmock_p8), p9(gmock_p9)
+
+// Declares the fields for storing the value parameters.
+#define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()
+#define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;
+#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \
+ p1##_type p1;
+#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \
+ p1##_type p1; p2##_type p2;
+#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \
+ p1##_type p1; p2##_type p2; p3##_type p3;
+#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
+ p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4;
+#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
+ p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
+ p5##_type p5;
+#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
+ p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
+ p5##_type p5; p6##_type p6;
+#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
+ p5##_type p5; p6##_type p6; p7##_type p7;
+#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
+ p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8;
+#define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
+ p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \
+ p9##_type p9;
+
+// Lists the value parameters.
+#define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()
+#define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0
+#define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1
+#define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2
+#define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3
+#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \
+ p2, p3, p4
+#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \
+ p1, p2, p3, p4, p5
+#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
+ p6) p0, p1, p2, p3, p4, p5, p6
+#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7) p0, p1, p2, p3, p4, p5, p6, p7
+#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8
+#define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
+
+// Lists the value parameter types.
+#define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()
+#define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \
+ p1##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \
+ p1##_type, p2##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
+ p0##_type, p1##_type, p2##_type, p3##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
+ p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
+ p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
+ p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
+ p6##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
+ p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
+ p5##_type, p6##_type, p7##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
+ p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
+ p5##_type, p6##_type, p7##_type, p8##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
+ p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
+ p5##_type, p6##_type, p7##_type, p8##_type, p9##_type
+
+// Declares the value parameters.
+#define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()
+#define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0
+#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \
+ p1##_type p1
+#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \
+ p1##_type p1, p2##_type p2
+#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \
+ p1##_type p1, p2##_type p2, p3##_type p3
+#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
+ p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4
+#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
+ p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
+ p5##_type p5
+#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
+ p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
+ p5##_type p5, p6##_type p6
+#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
+ p5##_type p5, p6##_type p6, p7##_type p7
+#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
+ p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8
+#define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
+ p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
+ p9##_type p9
+
+// The suffix of the class template implementing the action template.
+#define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()
+#define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P
+#define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2
+#define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3
+#define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4
+#define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5
+#define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6
+#define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7
+#define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7) P8
+#define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7, p8) P9
+#define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
+ p7, p8, p9) P10
+
+// The name of the class template implementing the action template.
+#define GMOCK_ACTION_CLASS_(name, value_params)\
+ GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
+
+#define ACTION_TEMPLATE(name, template_params, value_params)\
+ template <GMOCK_INTERNAL_DECL_##template_params\
+ GMOCK_INTERNAL_DECL_TYPE_##value_params>\
+ class GMOCK_ACTION_CLASS_(name, value_params) {\
+ public:\
+ GMOCK_ACTION_CLASS_(name, value_params)\
+ GMOCK_INTERNAL_INIT_##value_params {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
+ arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
+ arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
+ arg9_type arg9) const;\
+ GMOCK_INTERNAL_DEFN_##value_params\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(\
+ new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
+ }\
+ GMOCK_INTERNAL_DEFN_##value_params\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
+ };\
+ template <GMOCK_INTERNAL_DECL_##template_params\
+ GMOCK_INTERNAL_DECL_TYPE_##value_params>\
+ inline GMOCK_ACTION_CLASS_(name, value_params)<\
+ GMOCK_INTERNAL_LIST_##template_params\
+ GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\
+ GMOCK_INTERNAL_DECL_##value_params) {\
+ return GMOCK_ACTION_CLASS_(name, value_params)<\
+ GMOCK_INTERNAL_LIST_##template_params\
+ GMOCK_INTERNAL_LIST_TYPE_##value_params>(\
+ GMOCK_INTERNAL_LIST_##value_params);\
+ }\
+ template <GMOCK_INTERNAL_DECL_##template_params\
+ GMOCK_INTERNAL_DECL_TYPE_##value_params>\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type,\
+ typename arg3_type, typename arg4_type, typename arg5_type,\
+ typename arg6_type, typename arg7_type, typename arg8_type,\
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ GMOCK_ACTION_CLASS_(name, value_params)<\
+ GMOCK_INTERNAL_LIST_##template_params\
+ GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\
+ gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+#define ACTION(name)\
+ class name##Action {\
+ public:\
+ name##Action() {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ gmock_Impl() {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
+ arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
+ arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
+ arg9_type arg9) const;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(new gmock_Impl<F>());\
+ }\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##Action);\
+ };\
+ inline name##Action name() {\
+ return name##Action();\
+ }\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ name##Action::gmock_Impl<F>::gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+#define ACTION_P(name, p0)\
+ template <typename p0##_type>\
+ class name##ActionP {\
+ public:\
+ name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ explicit gmock_Impl(p0##_type gmock_p0) : p0(gmock_p0) {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
+ arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
+ arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
+ arg9_type arg9) const;\
+ p0##_type p0;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(new gmock_Impl<F>(p0));\
+ }\
+ p0##_type p0;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP);\
+ };\
+ template <typename p0##_type>\
+ inline name##ActionP<p0##_type> name(p0##_type p0) {\
+ return name##ActionP<p0##_type>(p0);\
+ }\
+ template <typename p0##_type>\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ name##ActionP<p0##_type>::gmock_Impl<F>::gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+#define ACTION_P2(name, p0, p1)\
+ template <typename p0##_type, typename p1##_type>\
+ class name##ActionP2 {\
+ public:\
+ name##ActionP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
+ p1(gmock_p1) {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
+ p1(gmock_p1) {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
+ arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
+ arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
+ arg9_type arg9) const;\
+ p0##_type p0;\
+ p1##_type p1;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP2);\
+ };\
+ template <typename p0##_type, typename p1##_type>\
+ inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \
+ p1##_type p1) {\
+ return name##ActionP2<p0##_type, p1##_type>(p0, p1);\
+ }\
+ template <typename p0##_type, typename p1##_type>\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ name##ActionP2<p0##_type, p1##_type>::gmock_Impl<F>::gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+#define ACTION_P3(name, p0, p1, p2)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type>\
+ class name##ActionP3 {\
+ public:\
+ name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
+ arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
+ arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
+ arg9_type arg9) const;\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP3);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type>\
+ inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
+ p1##_type p1, p2##_type p2) {\
+ return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type>\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ name##ActionP3<p0##_type, p1##_type, \
+ p2##_type>::gmock_Impl<F>::gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+#define ACTION_P4(name, p0, p1, p2, p3)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type>\
+ class name##ActionP4 {\
+ public:\
+ name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
+ p2(gmock_p2), p3(gmock_p3) {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3) {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
+ arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
+ arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
+ arg9_type arg9) const;\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP4);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type>\
+ inline name##ActionP4<p0##_type, p1##_type, p2##_type, \
+ p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
+ p3##_type p3) {\
+ return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p1, \
+ p2, p3);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type>\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ name##ActionP4<p0##_type, p1##_type, p2##_type, \
+ p3##_type>::gmock_Impl<F>::gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+#define ACTION_P5(name, p0, p1, p2, p3, p4)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type>\
+ class name##ActionP5 {\
+ public:\
+ name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3, \
+ p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4) {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), \
+ p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4) {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
+ arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
+ arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
+ arg9_type arg9) const;\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP5);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type>\
+ inline name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
+ p4##_type p4) {\
+ return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type>(p0, p1, p2, p3, p4);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type>\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type>::gmock_Impl<F>::gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+#define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type>\
+ class name##ActionP6 {\
+ public:\
+ name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
+ p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, \
+ p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
+ arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
+ arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
+ arg9_type arg9) const;\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5));\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP6);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type>\
+ inline name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
+ p3##_type p3, p4##_type p4, p5##_type p5) {\
+ return name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type>\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
+ p5##_type>::gmock_Impl<F>::gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+#define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type>\
+ class name##ActionP7 {\
+ public:\
+ name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
+ p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
+ p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
+ p6(gmock_p6) {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
+ arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
+ arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
+ arg9_type arg9) const;\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
+ p6));\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP7);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type>\
+ inline name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
+ p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
+ p6##_type p6) {\
+ return name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type>\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
+ p5##_type, p6##_type>::gmock_Impl<F>::gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+#define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type>\
+ class name##ActionP8 {\
+ public:\
+ name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
+ p5##_type gmock_p5, p6##_type gmock_p6, \
+ p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
+ p7(gmock_p7) {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), \
+ p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), \
+ p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
+ arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
+ arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
+ arg9_type arg9) const;\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ p7##_type p7;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
+ p6, p7));\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ p7##_type p7;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP8);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type>\
+ inline name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
+ p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
+ p6##_type p6, p7##_type p7) {\
+ return name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
+ p6, p7);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type>\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
+ p5##_type, p6##_type, \
+ p7##_type>::gmock_Impl<F>::gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+#define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type>\
+ class name##ActionP9 {\
+ public:\
+ name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
+ p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
+ p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
+ p8(gmock_p8) {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6, p7##_type gmock_p7, \
+ p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
+ p7(gmock_p7), p8(gmock_p8) {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
+ arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
+ arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
+ arg9_type arg9) const;\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ p7##_type p7;\
+ p8##_type p8;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
+ p6, p7, p8));\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ p7##_type p7;\
+ p8##_type p8;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP9);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type>\
+ inline name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type, \
+ p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
+ p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
+ p8##_type p8) {\
+ return name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
+ p3, p4, p5, p6, p7, p8);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type>\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
+ p5##_type, p6##_type, p7##_type, \
+ p8##_type>::gmock_Impl<F>::gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+#define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type, \
+ typename p9##_type>\
+ class name##ActionP10 {\
+ public:\
+ name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
+ p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
+ p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
+ p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
+ p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
+ p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
+ p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
+ arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
+ arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
+ arg9_type arg9) const;\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ p7##_type p7;\
+ p8##_type p8;\
+ p9##_type p9;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
+ p6, p7, p8, p9));\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ p7##_type p7;\
+ p8##_type p8;\
+ p9##_type p9;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP10);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type, \
+ typename p9##_type>\
+ inline name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
+ p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
+ p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
+ p9##_type p9) {\
+ return name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
+ p1, p2, p3, p4, p5, p6, p7, p8, p9);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type, \
+ typename p9##_type>\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type, \
+ typename arg3_type, typename arg4_type, typename arg5_type, \
+ typename arg6_type, typename arg7_type, typename arg8_type, \
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
+ p5##_type, p6##_type, p7##_type, p8##_type, \
+ p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+// TODO(wan@google.com): move the following to a different .h file
+// such that we don't have to run 'pump' every time the code is
+// updated.
+namespace testing {
+
+// The ACTION*() macros trigger warning C4100 (unreferenced formal
+// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
+// the macro definition, as the warnings are generated when the macro
+// is expanded and macro expansion cannot contain #pragma. Therefore
+// we suppress them here.
+#ifdef _MSC_VER
+# pragma warning(push)
+# pragma warning(disable:4100)
+#endif
+
+// Various overloads for InvokeArgument<N>().
+//
+// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
+// (0-based) argument, which must be a k-ary callable, of the mock
+// function, with arguments a1, a2, ..., a_k.
+//
+// Notes:
+//
+// 1. The arguments are passed by value by default. If you need to
+// pass an argument by reference, wrap it inside ByRef(). For
+// example,
+//
+// InvokeArgument<1>(5, string("Hello"), ByRef(foo))
+//
+// passes 5 and string("Hello") by value, and passes foo by
+// reference.
+//
+// 2. If the callable takes an argument by reference but ByRef() is
+// not used, it will receive the reference to a copy of the value,
+// instead of the original value. For example, when the 0-th
+// argument of the mock function takes a const string&, the action
+//
+// InvokeArgument<0>(string("Hello"))
+//
+// makes a copy of the temporary string("Hello") object and passes a
+// reference of the copy, instead of the original temporary object,
+// to the callable. This makes it easy for a user to define an
+// InvokeArgument action from temporary values and have it performed
+// later.
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_0_VALUE_PARAMS()) {
+ return internal::CallableHelper<return_type>::Call(
+ ::std::tr1::get<k>(args));
+}
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_1_VALUE_PARAMS(p0)) {
+ return internal::CallableHelper<return_type>::Call(
+ ::std::tr1::get<k>(args), p0);
+}
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_2_VALUE_PARAMS(p0, p1)) {
+ return internal::CallableHelper<return_type>::Call(
+ ::std::tr1::get<k>(args), p0, p1);
+}
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_3_VALUE_PARAMS(p0, p1, p2)) {
+ return internal::CallableHelper<return_type>::Call(
+ ::std::tr1::get<k>(args), p0, p1, p2);
+}
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
+ return internal::CallableHelper<return_type>::Call(
+ ::std::tr1::get<k>(args), p0, p1, p2, p3);
+}
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
+ return internal::CallableHelper<return_type>::Call(
+ ::std::tr1::get<k>(args), p0, p1, p2, p3, p4);
+}
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
+ return internal::CallableHelper<return_type>::Call(
+ ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5);
+}
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
+ return internal::CallableHelper<return_type>::Call(
+ ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
+}
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
+ return internal::CallableHelper<return_type>::Call(
+ ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
+}
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
+ return internal::CallableHelper<return_type>::Call(
+ ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);
+}
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
+ return internal::CallableHelper<return_type>::Call(
+ ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
+}
+
+// Various overloads for ReturnNew<T>().
+//
+// The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new
+// instance of type T, constructed on the heap with constructor arguments
+// a1, a2, ..., and a_k. The caller assumes ownership of the returned value.
+ACTION_TEMPLATE(ReturnNew,
+ HAS_1_TEMPLATE_PARAMS(typename, T),
+ AND_0_VALUE_PARAMS()) {
+ return new T();
+}
+
+ACTION_TEMPLATE(ReturnNew,
+ HAS_1_TEMPLATE_PARAMS(typename, T),
+ AND_1_VALUE_PARAMS(p0)) {
+ return new T(p0);
+}
+
+ACTION_TEMPLATE(ReturnNew,
+ HAS_1_TEMPLATE_PARAMS(typename, T),
+ AND_2_VALUE_PARAMS(p0, p1)) {
+ return new T(p0, p1);
+}
+
+ACTION_TEMPLATE(ReturnNew,
+ HAS_1_TEMPLATE_PARAMS(typename, T),
+ AND_3_VALUE_PARAMS(p0, p1, p2)) {
+ return new T(p0, p1, p2);
+}
+
+ACTION_TEMPLATE(ReturnNew,
+ HAS_1_TEMPLATE_PARAMS(typename, T),
+ AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
+ return new T(p0, p1, p2, p3);
+}
+
+ACTION_TEMPLATE(ReturnNew,
+ HAS_1_TEMPLATE_PARAMS(typename, T),
+ AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
+ return new T(p0, p1, p2, p3, p4);
+}
+
+ACTION_TEMPLATE(ReturnNew,
+ HAS_1_TEMPLATE_PARAMS(typename, T),
+ AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
+ return new T(p0, p1, p2, p3, p4, p5);
+}
+
+ACTION_TEMPLATE(ReturnNew,
+ HAS_1_TEMPLATE_PARAMS(typename, T),
+ AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
+ return new T(p0, p1, p2, p3, p4, p5, p6);
+}
+
+ACTION_TEMPLATE(ReturnNew,
+ HAS_1_TEMPLATE_PARAMS(typename, T),
+ AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
+ return new T(p0, p1, p2, p3, p4, p5, p6, p7);
+}
+
+ACTION_TEMPLATE(ReturnNew,
+ HAS_1_TEMPLATE_PARAMS(typename, T),
+ AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
+ return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8);
+}
+
+ACTION_TEMPLATE(ReturnNew,
+ HAS_1_TEMPLATE_PARAMS(typename, T),
+ AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
+ return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
+}
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
diff --git a/lib/gtest/include/gmock/gmock-generated-actions.h.pump b/lib/gtest/include/gmock/gmock-generated-actions.h.pump
new file mode 100644
index 0000000..001fd7d
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-generated-actions.h.pump
@@ -0,0 +1,825 @@
+$$ -*- mode: c++; -*-
+$$ This is a Pump source file. Please use Pump to convert it to
+$$ gmock-generated-actions.h.
+$$
+$var n = 10 $$ The maximum arity we support.
+$$}} This meta comment fixes auto-indentation in editors.
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements some commonly used variadic actions.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
+
+#include "gmock/gmock-actions.h"
+#include "gmock/internal/gmock-port.h"
+
+namespace testing {
+namespace internal {
+
+// InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary
+// function or method with the unpacked values, where F is a function
+// type that takes N arguments.
+template <typename Result, typename ArgumentTuple>
+class InvokeHelper;
+
+
+$range i 0..n
+$for i [[
+$range j 1..i
+$var types = [[$for j [[, typename A$j]]]]
+$var as = [[$for j, [[A$j]]]]
+$var args = [[$if i==0 [[]] $else [[ args]]]]
+$var import = [[$if i==0 [[]] $else [[
+ using ::std::tr1::get;
+
+]]]]
+$var gets = [[$for j, [[get<$(j - 1)>(args)]]]]
+template <typename R$types>
+class InvokeHelper<R, ::std::tr1::tuple<$as> > {
+ public:
+ template <typename Function>
+ static R Invoke(Function function, const ::std::tr1::tuple<$as>&$args) {
+$import return function($gets);
+ }
+
+ template <class Class, typename MethodPtr>
+ static R InvokeMethod(Class* obj_ptr,
+ MethodPtr method_ptr,
+ const ::std::tr1::tuple<$as>&$args) {
+$import return (obj_ptr->*method_ptr)($gets);
+ }
+};
+
+
+]]
+// CallableHelper has static methods for invoking "callables",
+// i.e. function pointers and functors. It uses overloading to
+// provide a uniform interface for invoking different kinds of
+// callables. In particular, you can use:
+//
+// CallableHelper<R>::Call(callable, a1, a2, ..., an)
+//
+// to invoke an n-ary callable, where R is its return type. If an
+// argument, say a2, needs to be passed by reference, you should write
+// ByRef(a2) instead of a2 in the above expression.
+template <typename R>
+class CallableHelper {
+ public:
+ // Calls a nullary callable.
+ template <typename Function>
+ static R Call(Function function) { return function(); }
+
+ // Calls a unary callable.
+
+ // We deliberately pass a1 by value instead of const reference here
+ // in case it is a C-string literal. If we had declared the
+ // parameter as 'const A1& a1' and write Call(function, "Hi"), the
+ // compiler would've thought A1 is 'char[3]', which causes trouble
+ // when you need to copy a value of type A1. By declaring the
+ // parameter as 'A1 a1', the compiler will correctly infer that A1
+ // is 'const char*' when it sees Call(function, "Hi").
+ //
+ // Since this function is defined inline, the compiler can get rid
+ // of the copying of the arguments. Therefore the performance won't
+ // be hurt.
+ template <typename Function, typename A1>
+ static R Call(Function function, A1 a1) { return function(a1); }
+
+$range i 2..n
+$for i
+[[
+$var arity = [[$if i==2 [[binary]] $elif i==3 [[ternary]] $else [[$i-ary]]]]
+
+ // Calls a $arity callable.
+
+$range j 1..i
+$var typename_As = [[$for j, [[typename A$j]]]]
+$var Aas = [[$for j, [[A$j a$j]]]]
+$var as = [[$for j, [[a$j]]]]
+$var typename_Ts = [[$for j, [[typename T$j]]]]
+$var Ts = [[$for j, [[T$j]]]]
+ template <typename Function, $typename_As>
+ static R Call(Function function, $Aas) {
+ return function($as);
+ }
+
+]]
+
+}; // class CallableHelper
+
+// An INTERNAL macro for extracting the type of a tuple field. It's
+// subject to change without notice - DO NOT USE IN USER CODE!
+#define GMOCK_FIELD_(Tuple, N) \
+ typename ::std::tr1::tuple_element<N, Tuple>::type
+
+$range i 1..n
+
+// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the
+// type of an n-ary function whose i-th (1-based) argument type is the
+// k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
+// type, and whose return type is Result. For example,
+// SelectArgs<int, ::std::tr1::tuple<bool, char, double, long>, 0, 3>::type
+// is int(bool, long).
+//
+// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
+// returns the selected fields (k1, k2, ..., k_n) of args as a tuple.
+// For example,
+// SelectArgs<int, ::std::tr1::tuple<bool, char, double>, 2, 0>::Select(
+// ::std::tr1::make_tuple(true, 'a', 2.5))
+// returns ::std::tr1::tuple (2.5, true).
+//
+// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be
+// in the range [0, $n]. Duplicates are allowed and they don't have
+// to be in an ascending or descending order.
+
+template <typename Result, typename ArgumentTuple, $for i, [[int k$i]]>
+class SelectArgs {
+ public:
+ typedef Result type($for i, [[GMOCK_FIELD_(ArgumentTuple, k$i)]]);
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& args) {
+ using ::std::tr1::get;
+ return SelectedArgs($for i, [[get<k$i>(args)]]);
+ }
+};
+
+
+$for i [[
+$range j 1..n
+$range j1 1..i-1
+template <typename Result, typename ArgumentTuple$for j1[[, int k$j1]]>
+class SelectArgs<Result, ArgumentTuple,
+ $for j, [[$if j <= i-1 [[k$j]] $else [[-1]]]]> {
+ public:
+ typedef Result type($for j1, [[GMOCK_FIELD_(ArgumentTuple, k$j1)]]);
+ typedef typename Function<type>::ArgumentTuple SelectedArgs;
+ static SelectedArgs Select(const ArgumentTuple& [[]]
+$if i == 1 [[/* args */]] $else [[args]]) {
+ using ::std::tr1::get;
+ return SelectedArgs($for j1, [[get<k$j1>(args)]]);
+ }
+};
+
+
+]]
+#undef GMOCK_FIELD_
+
+$var ks = [[$for i, [[k$i]]]]
+
+// Implements the WithArgs action.
+template <typename InnerAction, $for i, [[int k$i = -1]]>
+class WithArgsAction {
+ public:
+ explicit WithArgsAction(const InnerAction& action) : action_(action) {}
+
+ template <typename F>
+ operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }
+
+ private:
+ template <typename F>
+ class Impl : public ActionInterface<F> {
+ public:
+ typedef typename Function<F>::Result Result;
+ typedef typename Function<F>::ArgumentTuple ArgumentTuple;
+
+ explicit Impl(const InnerAction& action) : action_(action) {}
+
+ virtual Result Perform(const ArgumentTuple& args) {
+ return action_.Perform(SelectArgs<Result, ArgumentTuple, $ks>::Select(args));
+ }
+
+ private:
+ typedef typename SelectArgs<Result, ArgumentTuple,
+ $ks>::type InnerFunctionType;
+
+ Action<InnerFunctionType> action_;
+ };
+
+ const InnerAction action_;
+
+ GTEST_DISALLOW_ASSIGN_(WithArgsAction);
+};
+
+// A macro from the ACTION* family (defined later in this file)
+// defines an action that can be used in a mock function. Typically,
+// these actions only care about a subset of the arguments of the mock
+// function. For example, if such an action only uses the second
+// argument, it can be used in any mock function that takes >= 2
+// arguments where the type of the second argument is compatible.
+//
+// Therefore, the action implementation must be prepared to take more
+// arguments than it needs. The ExcessiveArg type is used to
+// represent those excessive arguments. In order to keep the compiler
+// error messages tractable, we define it in the testing namespace
+// instead of testing::internal. However, this is an INTERNAL TYPE
+// and subject to change without notice, so a user MUST NOT USE THIS
+// TYPE DIRECTLY.
+struct ExcessiveArg {};
+
+// A helper class needed for implementing the ACTION* macros.
+template <typename Result, class Impl>
+class ActionHelper {
+ public:
+$range i 0..n
+$for i
+
+[[
+$var template = [[$if i==0 [[]] $else [[
+$range j 0..i-1
+ template <$for j, [[typename A$j]]>
+]]]]
+$range j 0..i-1
+$var As = [[$for j, [[A$j]]]]
+$var as = [[$for j, [[get<$j>(args)]]]]
+$range k 1..n-i
+$var eas = [[$for k, [[ExcessiveArg()]]]]
+$var arg_list = [[$if (i==0) | (i==n) [[$as$eas]] $else [[$as, $eas]]]]
+$template
+ static Result Perform(Impl* impl, const ::std::tr1::tuple<$As>& args) {
+ using ::std::tr1::get;
+ return impl->template gmock_PerformImpl<$As>(args, $arg_list);
+ }
+
+]]
+};
+
+} // namespace internal
+
+// Various overloads for Invoke().
+
+// WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes
+// the selected arguments of the mock function to an_action and
+// performs it. It serves as an adaptor between actions with
+// different argument lists. C++ doesn't support default arguments for
+// function templates, so we have to overload it.
+
+$range i 1..n
+$for i [[
+$range j 1..i
+template <$for j [[int k$j, ]]typename InnerAction>
+inline internal::WithArgsAction<InnerAction$for j [[, k$j]]>
+WithArgs(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction$for j [[, k$j]]>(action);
+}
+
+
+]]
+// Creates an action that does actions a1, a2, ..., sequentially in
+// each invocation.
+$range i 2..n
+$for i [[
+$range j 2..i
+$var types = [[$for j, [[typename Action$j]]]]
+$var Aas = [[$for j [[, Action$j a$j]]]]
+
+template <typename Action1, $types>
+$range k 1..i-1
+
+inline $for k [[internal::DoBothAction<Action$k, ]]Action$i$for k [[>]]
+
+DoAll(Action1 a1$Aas) {
+$if i==2 [[
+
+ return internal::DoBothAction<Action1, Action2>(a1, a2);
+]] $else [[
+$range j2 2..i
+
+ return DoAll(a1, DoAll($for j2, [[a$j2]]));
+]]
+
+}
+
+]]
+
+} // namespace testing
+
+// The ACTION* family of macros can be used in a namespace scope to
+// define custom actions easily. The syntax:
+//
+// ACTION(name) { statements; }
+//
+// will define an action with the given name that executes the
+// statements. The value returned by the statements will be used as
+// the return value of the action. Inside the statements, you can
+// refer to the K-th (0-based) argument of the mock function by
+// 'argK', and refer to its type by 'argK_type'. For example:
+//
+// ACTION(IncrementArg1) {
+// arg1_type temp = arg1;
+// return ++(*temp);
+// }
+//
+// allows you to write
+//
+// ...WillOnce(IncrementArg1());
+//
+// You can also refer to the entire argument tuple and its type by
+// 'args' and 'args_type', and refer to the mock function type and its
+// return type by 'function_type' and 'return_type'.
+//
+// Note that you don't need to specify the types of the mock function
+// arguments. However rest assured that your code is still type-safe:
+// you'll get a compiler error if *arg1 doesn't support the ++
+// operator, or if the type of ++(*arg1) isn't compatible with the
+// mock function's return type, for example.
+//
+// Sometimes you'll want to parameterize the action. For that you can use
+// another macro:
+//
+// ACTION_P(name, param_name) { statements; }
+//
+// For example:
+//
+// ACTION_P(Add, n) { return arg0 + n; }
+//
+// will allow you to write:
+//
+// ...WillOnce(Add(5));
+//
+// Note that you don't need to provide the type of the parameter
+// either. If you need to reference the type of a parameter named
+// 'foo', you can write 'foo_type'. For example, in the body of
+// ACTION_P(Add, n) above, you can write 'n_type' to refer to the type
+// of 'n'.
+//
+// We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P$n to support
+// multi-parameter actions.
+//
+// For the purpose of typing, you can view
+//
+// ACTION_Pk(Foo, p1, ..., pk) { ... }
+//
+// as shorthand for
+//
+// template <typename p1_type, ..., typename pk_type>
+// FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... }
+//
+// In particular, you can provide the template type arguments
+// explicitly when invoking Foo(), as in Foo<long, bool>(5, false);
+// although usually you can rely on the compiler to infer the types
+// for you automatically. You can assign the result of expression
+// Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ...,
+// pk_type>. This can be useful when composing actions.
+//
+// You can also overload actions with different numbers of parameters:
+//
+// ACTION_P(Plus, a) { ... }
+// ACTION_P2(Plus, a, b) { ... }
+//
+// While it's tempting to always use the ACTION* macros when defining
+// a new action, you should also consider implementing ActionInterface
+// or using MakePolymorphicAction() instead, especially if you need to
+// use the action a lot. While these approaches require more work,
+// they give you more control on the types of the mock function
+// arguments and the action parameters, which in general leads to
+// better compiler error messages that pay off in the long run. They
+// also allow overloading actions based on parameter types (as opposed
+// to just based on the number of parameters).
+//
+// CAVEAT:
+//
+// ACTION*() can only be used in a namespace scope. The reason is
+// that C++ doesn't yet allow function-local types to be used to
+// instantiate templates. The up-coming C++0x standard will fix this.
+// Once that's done, we'll consider supporting using ACTION*() inside
+// a function.
+//
+// MORE INFORMATION:
+//
+// To learn more about using these macros, please search for 'ACTION'
+// on http://code.google.com/p/googlemock/wiki/CookBook.
+
+$range i 0..n
+$range k 0..n-1
+
+// An internal macro needed for implementing ACTION*().
+#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
+ const args_type& args GTEST_ATTRIBUTE_UNUSED_
+$for k [[,\
+ arg$k[[]]_type arg$k GTEST_ATTRIBUTE_UNUSED_]]
+
+
+// Sometimes you want to give an action explicit template parameters
+// that cannot be inferred from its value parameters. ACTION() and
+// ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that
+// and can be viewed as an extension to ACTION() and ACTION_P*().
+//
+// The syntax:
+//
+// ACTION_TEMPLATE(ActionName,
+// HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),
+// AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }
+//
+// defines an action template that takes m explicit template
+// parameters and n value parameters. name_i is the name of the i-th
+// template parameter, and kind_i specifies whether it's a typename,
+// an integral constant, or a template. p_i is the name of the i-th
+// value parameter.
+//
+// Example:
+//
+// // DuplicateArg<k, T>(output) converts the k-th argument of the mock
+// // function to type T and copies it to *output.
+// ACTION_TEMPLATE(DuplicateArg,
+// HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
+// AND_1_VALUE_PARAMS(output)) {
+// *output = T(std::tr1::get<k>(args));
+// }
+// ...
+// int n;
+// EXPECT_CALL(mock, Foo(_, _))
+// .WillOnce(DuplicateArg<1, unsigned char>(&n));
+//
+// To create an instance of an action template, write:
+//
+// ActionName<t1, ..., t_m>(v1, ..., v_n)
+//
+// where the ts are the template arguments and the vs are the value
+// arguments. The value argument types are inferred by the compiler.
+// If you want to explicitly specify the value argument types, you can
+// provide additional template arguments:
+//
+// ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)
+//
+// where u_i is the desired type of v_i.
+//
+// ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the
+// number of value parameters, but not on the number of template
+// parameters. Without the restriction, the meaning of the following
+// is unclear:
+//
+// OverloadedAction<int, bool>(x);
+//
+// Are we using a single-template-parameter action where 'bool' refers
+// to the type of x, or are we using a two-template-parameter action
+// where the compiler is asked to infer the type of x?
+//
+// Implementation notes:
+//
+// GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and
+// GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for
+// implementing ACTION_TEMPLATE. The main trick we use is to create
+// new macro invocations when expanding a macro. For example, we have
+//
+// #define ACTION_TEMPLATE(name, template_params, value_params)
+// ... GMOCK_INTERNAL_DECL_##template_params ...
+//
+// which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)
+// to expand to
+//
+// ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...
+//
+// Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the
+// preprocessor will continue to expand it to
+//
+// ... typename T ...
+//
+// This technique conforms to the C++ standard and is portable. It
+// allows us to implement action templates using O(N) code, where N is
+// the maximum number of template/value parameters supported. Without
+// using it, we'd have to devote O(N^2) amount of code to implement all
+// combinations of m and n.
+
+// Declares the template parameters.
+
+$range j 1..n
+$for j [[
+$range m 0..j-1
+#define GMOCK_INTERNAL_DECL_HAS_$j[[]]
+_TEMPLATE_PARAMS($for m, [[kind$m, name$m]]) $for m, [[kind$m name$m]]
+
+
+]]
+
+// Lists the template parameters.
+
+$for j [[
+$range m 0..j-1
+#define GMOCK_INTERNAL_LIST_HAS_$j[[]]
+_TEMPLATE_PARAMS($for m, [[kind$m, name$m]]) $for m, [[name$m]]
+
+
+]]
+
+// Declares the types of value parameters.
+
+$for i [[
+$range j 0..i-1
+#define GMOCK_INTERNAL_DECL_TYPE_AND_$i[[]]
+_VALUE_PARAMS($for j, [[p$j]]) $for j [[, typename p$j##_type]]
+
+
+]]
+
+// Initializes the value parameters.
+
+$for i [[
+$range j 0..i-1
+#define GMOCK_INTERNAL_INIT_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])\
+ ($for j, [[p$j##_type gmock_p$j]])$if i>0 [[ : ]]$for j, [[p$j(gmock_p$j)]]
+
+
+]]
+
+// Declares the fields for storing the value parameters.
+
+$for i [[
+$range j 0..i-1
+#define GMOCK_INTERNAL_DEFN_AND_$i[[]]
+_VALUE_PARAMS($for j, [[p$j]]) $for j [[p$j##_type p$j; ]]
+
+
+]]
+
+// Lists the value parameters.
+
+$for i [[
+$range j 0..i-1
+#define GMOCK_INTERNAL_LIST_AND_$i[[]]
+_VALUE_PARAMS($for j, [[p$j]]) $for j, [[p$j]]
+
+
+]]
+
+// Lists the value parameter types.
+
+$for i [[
+$range j 0..i-1
+#define GMOCK_INTERNAL_LIST_TYPE_AND_$i[[]]
+_VALUE_PARAMS($for j, [[p$j]]) $for j [[, p$j##_type]]
+
+
+]]
+
+// Declares the value parameters.
+
+$for i [[
+$range j 0..i-1
+#define GMOCK_INTERNAL_DECL_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]]) [[]]
+$for j, [[p$j##_type p$j]]
+
+
+]]
+
+// The suffix of the class template implementing the action template.
+$for i [[
+
+
+$range j 0..i-1
+#define GMOCK_INTERNAL_COUNT_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]]) [[]]
+$if i==1 [[P]] $elif i>=2 [[P$i]]
+]]
+
+
+// The name of the class template implementing the action template.
+#define GMOCK_ACTION_CLASS_(name, value_params)\
+ GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
+
+$range k 0..n-1
+
+#define ACTION_TEMPLATE(name, template_params, value_params)\
+ template <GMOCK_INTERNAL_DECL_##template_params\
+ GMOCK_INTERNAL_DECL_TYPE_##value_params>\
+ class GMOCK_ACTION_CLASS_(name, value_params) {\
+ public:\
+ GMOCK_ACTION_CLASS_(name, value_params)\
+ GMOCK_INTERNAL_INIT_##value_params {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <$for k, [[typename arg$k[[]]_type]]>\
+ return_type gmock_PerformImpl(const args_type& args[[]]
+$for k [[, arg$k[[]]_type arg$k]]) const;\
+ GMOCK_INTERNAL_DEFN_##value_params\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(\
+ new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
+ }\
+ GMOCK_INTERNAL_DEFN_##value_params\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
+ };\
+ template <GMOCK_INTERNAL_DECL_##template_params\
+ GMOCK_INTERNAL_DECL_TYPE_##value_params>\
+ inline GMOCK_ACTION_CLASS_(name, value_params)<\
+ GMOCK_INTERNAL_LIST_##template_params\
+ GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\
+ GMOCK_INTERNAL_DECL_##value_params) {\
+ return GMOCK_ACTION_CLASS_(name, value_params)<\
+ GMOCK_INTERNAL_LIST_##template_params\
+ GMOCK_INTERNAL_LIST_TYPE_##value_params>(\
+ GMOCK_INTERNAL_LIST_##value_params);\
+ }\
+ template <GMOCK_INTERNAL_DECL_##template_params\
+ GMOCK_INTERNAL_DECL_TYPE_##value_params>\
+ template <typename F>\
+ template <typename arg0_type, typename arg1_type, typename arg2_type,\
+ typename arg3_type, typename arg4_type, typename arg5_type,\
+ typename arg6_type, typename arg7_type, typename arg8_type,\
+ typename arg9_type>\
+ typename ::testing::internal::Function<F>::Result\
+ GMOCK_ACTION_CLASS_(name, value_params)<\
+ GMOCK_INTERNAL_LIST_##template_params\
+ GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\
+ gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+
+$for i
+
+[[
+$var template = [[$if i==0 [[]] $else [[
+$range j 0..i-1
+
+ template <$for j, [[typename p$j##_type]]>\
+]]]]
+$var class_name = [[name##Action[[$if i==0 [[]] $elif i==1 [[P]]
+ $else [[P$i]]]]]]
+$range j 0..i-1
+$var ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]]
+$var param_types_and_names = [[$for j, [[p$j##_type p$j]]]]
+$var inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(gmock_p$j)]]]]]]
+$var param_field_decls = [[$for j
+[[
+
+ p$j##_type p$j;\
+]]]]
+$var param_field_decls2 = [[$for j
+[[
+
+ p$j##_type p$j;\
+]]]]
+$var params = [[$for j, [[p$j]]]]
+$var param_types = [[$if i==0 [[]] $else [[<$for j, [[p$j##_type]]>]]]]
+$var typename_arg_types = [[$for k, [[typename arg$k[[]]_type]]]]
+$var arg_types_and_names = [[$for k, [[arg$k[[]]_type arg$k]]]]
+$var macro_name = [[$if i==0 [[ACTION]] $elif i==1 [[ACTION_P]]
+ $else [[ACTION_P$i]]]]
+
+#define $macro_name(name$for j [[, p$j]])\$template
+ class $class_name {\
+ public:\
+ $class_name($ctor_param_list)$inits {}\
+ template <typename F>\
+ class gmock_Impl : public ::testing::ActionInterface<F> {\
+ public:\
+ typedef F function_type;\
+ typedef typename ::testing::internal::Function<F>::Result return_type;\
+ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
+ args_type;\
+ [[$if i==1 [[explicit ]]]]gmock_Impl($ctor_param_list)$inits {}\
+ virtual return_type Perform(const args_type& args) {\
+ return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
+ Perform(this, args);\
+ }\
+ template <$typename_arg_types>\
+ return_type gmock_PerformImpl(const args_type& args, [[]]
+$arg_types_and_names) const;\$param_field_decls
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename F> operator ::testing::Action<F>() const {\
+ return ::testing::Action<F>(new gmock_Impl<F>($params));\
+ }\$param_field_decls2
+ private:\
+ GTEST_DISALLOW_ASSIGN_($class_name);\
+ };\$template
+ inline $class_name$param_types name($param_types_and_names) {\
+ return $class_name$param_types($params);\
+ }\$template
+ template <typename F>\
+ template <$typename_arg_types>\
+ typename ::testing::internal::Function<F>::Result\
+ $class_name$param_types::gmock_Impl<F>::gmock_PerformImpl(\
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+]]
+$$ } // This meta comment fixes auto-indentation in Emacs. It won't
+$$ // show up in the generated code.
+
+
+// TODO(wan@google.com): move the following to a different .h file
+// such that we don't have to run 'pump' every time the code is
+// updated.
+namespace testing {
+
+// The ACTION*() macros trigger warning C4100 (unreferenced formal
+// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
+// the macro definition, as the warnings are generated when the macro
+// is expanded and macro expansion cannot contain #pragma. Therefore
+// we suppress them here.
+#ifdef _MSC_VER
+# pragma warning(push)
+# pragma warning(disable:4100)
+#endif
+
+// Various overloads for InvokeArgument<N>().
+//
+// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
+// (0-based) argument, which must be a k-ary callable, of the mock
+// function, with arguments a1, a2, ..., a_k.
+//
+// Notes:
+//
+// 1. The arguments are passed by value by default. If you need to
+// pass an argument by reference, wrap it inside ByRef(). For
+// example,
+//
+// InvokeArgument<1>(5, string("Hello"), ByRef(foo))
+//
+// passes 5 and string("Hello") by value, and passes foo by
+// reference.
+//
+// 2. If the callable takes an argument by reference but ByRef() is
+// not used, it will receive the reference to a copy of the value,
+// instead of the original value. For example, when the 0-th
+// argument of the mock function takes a const string&, the action
+//
+// InvokeArgument<0>(string("Hello"))
+//
+// makes a copy of the temporary string("Hello") object and passes a
+// reference of the copy, instead of the original temporary object,
+// to the callable. This makes it easy for a user to define an
+// InvokeArgument action from temporary values and have it performed
+// later.
+
+$range i 0..n
+$for i [[
+$range j 0..i-1
+
+ACTION_TEMPLATE(InvokeArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])) {
+ return internal::CallableHelper<return_type>::Call(
+ ::std::tr1::get<k>(args)$for j [[, p$j]]);
+}
+
+]]
+
+// Various overloads for ReturnNew<T>().
+//
+// The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new
+// instance of type T, constructed on the heap with constructor arguments
+// a1, a2, ..., and a_k. The caller assumes ownership of the returned value.
+$range i 0..n
+$for i [[
+$range j 0..i-1
+$var ps = [[$for j, [[p$j]]]]
+
+ACTION_TEMPLATE(ReturnNew,
+ HAS_1_TEMPLATE_PARAMS(typename, T),
+ AND_$i[[]]_VALUE_PARAMS($ps)) {
+ return new T($ps);
+}
+
+]]
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
diff --git a/lib/gtest/include/gmock/gmock-generated-function-mockers.h b/lib/gtest/include/gmock/gmock-generated-function-mockers.h
new file mode 100644
index 0000000..509d46c
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-generated-function-mockers.h
@@ -0,0 +1,929 @@
+// This file was GENERATED by command:
+// pump.py gmock-generated-function-mockers.h.pump
+// DO NOT EDIT BY HAND!!!
+
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements function mockers of various arities.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
+
+#include "gmock/gmock-spec-builders.h"
+#include "gmock/internal/gmock-internal-utils.h"
+
+namespace testing {
+namespace internal {
+
+template <typename F>
+class FunctionMockerBase;
+
+// Note: class FunctionMocker really belongs to the ::testing
+// namespace. However if we define it in ::testing, MSVC will
+// complain when classes in ::testing::internal declare it as a
+// friend class template. To workaround this compiler bug, we define
+// FunctionMocker in ::testing::internal and import it into ::testing.
+template <typename F>
+class FunctionMocker;
+
+template <typename R>
+class FunctionMocker<R()> : public
+ internal::FunctionMockerBase<R()> {
+ public:
+ typedef R F();
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ MockSpec<F>& With() {
+ return this->current_spec();
+ }
+
+ R Invoke() {
+ // Even though gcc and MSVC don't enforce it, 'this->' is required
+ // by the C++ standard [14.6.4] here, as the base class type is
+ // dependent on the template argument (and thus shouldn't be
+ // looked into when resolving InvokeWith).
+ return this->InvokeWith(ArgumentTuple());
+ }
+};
+
+template <typename R, typename A1>
+class FunctionMocker<R(A1)> : public
+ internal::FunctionMockerBase<R(A1)> {
+ public:
+ typedef R F(A1);
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ MockSpec<F>& With(const Matcher<A1>& m1) {
+ this->current_spec().SetMatchers(::std::tr1::make_tuple(m1));
+ return this->current_spec();
+ }
+
+ R Invoke(A1 a1) {
+ // Even though gcc and MSVC don't enforce it, 'this->' is required
+ // by the C++ standard [14.6.4] here, as the base class type is
+ // dependent on the template argument (and thus shouldn't be
+ // looked into when resolving InvokeWith).
+ return this->InvokeWith(ArgumentTuple(a1));
+ }
+};
+
+template <typename R, typename A1, typename A2>
+class FunctionMocker<R(A1, A2)> : public
+ internal::FunctionMockerBase<R(A1, A2)> {
+ public:
+ typedef R F(A1, A2);
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2) {
+ this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2));
+ return this->current_spec();
+ }
+
+ R Invoke(A1 a1, A2 a2) {
+ // Even though gcc and MSVC don't enforce it, 'this->' is required
+ // by the C++ standard [14.6.4] here, as the base class type is
+ // dependent on the template argument (and thus shouldn't be
+ // looked into when resolving InvokeWith).
+ return this->InvokeWith(ArgumentTuple(a1, a2));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3>
+class FunctionMocker<R(A1, A2, A3)> : public
+ internal::FunctionMockerBase<R(A1, A2, A3)> {
+ public:
+ typedef R F(A1, A2, A3);
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
+ const Matcher<A3>& m3) {
+ this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3));
+ return this->current_spec();
+ }
+
+ R Invoke(A1 a1, A2 a2, A3 a3) {
+ // Even though gcc and MSVC don't enforce it, 'this->' is required
+ // by the C++ standard [14.6.4] here, as the base class type is
+ // dependent on the template argument (and thus shouldn't be
+ // looked into when resolving InvokeWith).
+ return this->InvokeWith(ArgumentTuple(a1, a2, a3));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4>
+class FunctionMocker<R(A1, A2, A3, A4)> : public
+ internal::FunctionMockerBase<R(A1, A2, A3, A4)> {
+ public:
+ typedef R F(A1, A2, A3, A4);
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
+ const Matcher<A3>& m3, const Matcher<A4>& m4) {
+ this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4));
+ return this->current_spec();
+ }
+
+ R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) {
+ // Even though gcc and MSVC don't enforce it, 'this->' is required
+ // by the C++ standard [14.6.4] here, as the base class type is
+ // dependent on the template argument (and thus shouldn't be
+ // looked into when resolving InvokeWith).
+ return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5>
+class FunctionMocker<R(A1, A2, A3, A4, A5)> : public
+ internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)> {
+ public:
+ typedef R F(A1, A2, A3, A4, A5);
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
+ const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5) {
+ this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
+ m5));
+ return this->current_spec();
+ }
+
+ R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
+ // Even though gcc and MSVC don't enforce it, 'this->' is required
+ // by the C++ standard [14.6.4] here, as the base class type is
+ // dependent on the template argument (and thus shouldn't be
+ // looked into when resolving InvokeWith).
+ return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6>
+class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public
+ internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6)> {
+ public:
+ typedef R F(A1, A2, A3, A4, A5, A6);
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
+ const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
+ const Matcher<A6>& m6) {
+ this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
+ m6));
+ return this->current_spec();
+ }
+
+ R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
+ // Even though gcc and MSVC don't enforce it, 'this->' is required
+ // by the C++ standard [14.6.4] here, as the base class type is
+ // dependent on the template argument (and thus shouldn't be
+ // looked into when resolving InvokeWith).
+ return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7>
+class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public
+ internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)> {
+ public:
+ typedef R F(A1, A2, A3, A4, A5, A6, A7);
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
+ const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
+ const Matcher<A6>& m6, const Matcher<A7>& m7) {
+ this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
+ m6, m7));
+ return this->current_spec();
+ }
+
+ R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
+ // Even though gcc and MSVC don't enforce it, 'this->' is required
+ // by the C++ standard [14.6.4] here, as the base class type is
+ // dependent on the template argument (and thus shouldn't be
+ // looked into when resolving InvokeWith).
+ return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7, typename A8>
+class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public
+ internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
+ public:
+ typedef R F(A1, A2, A3, A4, A5, A6, A7, A8);
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
+ const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
+ const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8) {
+ this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
+ m6, m7, m8));
+ return this->current_spec();
+ }
+
+ R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) {
+ // Even though gcc and MSVC don't enforce it, 'this->' is required
+ // by the C++ standard [14.6.4] here, as the base class type is
+ // dependent on the template argument (and thus shouldn't be
+ // looked into when resolving InvokeWith).
+ return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7, typename A8, typename A9>
+class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public
+ internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
+ public:
+ typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9);
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
+ const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
+ const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
+ const Matcher<A9>& m9) {
+ this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
+ m6, m7, m8, m9));
+ return this->current_spec();
+ }
+
+ R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) {
+ // Even though gcc and MSVC don't enforce it, 'this->' is required
+ // by the C++ standard [14.6.4] here, as the base class type is
+ // dependent on the template argument (and thus shouldn't be
+ // looked into when resolving InvokeWith).
+ return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9));
+ }
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7, typename A8, typename A9,
+ typename A10>
+class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
+ internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> {
+ public:
+ typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
+ const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
+ const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
+ const Matcher<A9>& m9, const Matcher<A10>& m10) {
+ this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
+ m6, m7, m8, m9, m10));
+ return this->current_spec();
+ }
+
+ R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
+ A10 a10) {
+ // Even though gcc and MSVC don't enforce it, 'this->' is required
+ // by the C++ standard [14.6.4] here, as the base class type is
+ // dependent on the template argument (and thus shouldn't be
+ // looked into when resolving InvokeWith).
+ return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10));
+ }
+};
+
+} // namespace internal
+
+// The style guide prohibits "using" statements in a namespace scope
+// inside a header file. However, the FunctionMocker class template
+// is meant to be defined in the ::testing namespace. The following
+// line is just a trick for working around a bug in MSVC 8.0, which
+// cannot handle it if we define FunctionMocker in ::testing.
+using internal::FunctionMocker;
+
+// The result type of function type F.
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_RESULT_(tn, F) tn ::testing::internal::Function<F>::Result
+
+// The type of argument N of function type F.
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_ARG_(tn, F, N) tn ::testing::internal::Function<F>::Argument##N
+
+// The matcher type for argument N of function type F.
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_MATCHER_(tn, F, N) const ::testing::Matcher<GMOCK_ARG_(tn, F, N)>&
+
+// The variable for mocking the given method.
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_MOCKER_(arity, constness, Method) \
+ GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
+
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_METHOD0_(tn, constness, ct, Method, F) \
+ GMOCK_RESULT_(tn, F) ct Method() constness { \
+ GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
+ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 0, \
+ this_method_does_not_take_0_arguments); \
+ GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \
+ return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
+ } \
+ ::testing::MockSpec<F>& \
+ gmock_##Method() constness { \
+ GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \
+ return GMOCK_MOCKER_(0, constness, Method).With(); \
+ } \
+ mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(0, constness, Method)
+
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_METHOD1_(tn, constness, ct, Method, F) \
+ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1) constness { \
+ GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
+ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 1, \
+ this_method_does_not_take_1_argument); \
+ GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \
+ return GMOCK_MOCKER_(1, constness, Method).Invoke(gmock_a1); \
+ } \
+ ::testing::MockSpec<F>& \
+ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1) constness { \
+ GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \
+ return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \
+ } \
+ mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(1, constness, Method)
+
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_METHOD2_(tn, constness, ct, Method, F) \
+ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
+ GMOCK_ARG_(tn, F, 2) gmock_a2) constness { \
+ GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
+ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 2, \
+ this_method_does_not_take_2_arguments); \
+ GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \
+ return GMOCK_MOCKER_(2, constness, Method).Invoke(gmock_a1, gmock_a2); \
+ } \
+ ::testing::MockSpec<F>& \
+ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
+ GMOCK_MATCHER_(tn, F, 2) gmock_a2) constness { \
+ GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \
+ return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \
+ } \
+ mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(2, constness, Method)
+
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_METHOD3_(tn, constness, ct, Method, F) \
+ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
+ GMOCK_ARG_(tn, F, 2) gmock_a2, \
+ GMOCK_ARG_(tn, F, 3) gmock_a3) constness { \
+ GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
+ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 3, \
+ this_method_does_not_take_3_arguments); \
+ GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \
+ return GMOCK_MOCKER_(3, constness, Method).Invoke(gmock_a1, gmock_a2, \
+ gmock_a3); \
+ } \
+ ::testing::MockSpec<F>& \
+ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
+ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
+ GMOCK_MATCHER_(tn, F, 3) gmock_a3) constness { \
+ GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \
+ return GMOCK_MOCKER_(3, constness, Method).With(gmock_a1, gmock_a2, \
+ gmock_a3); \
+ } \
+ mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(3, constness, Method)
+
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_METHOD4_(tn, constness, ct, Method, F) \
+ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
+ GMOCK_ARG_(tn, F, 2) gmock_a2, \
+ GMOCK_ARG_(tn, F, 3) gmock_a3, \
+ GMOCK_ARG_(tn, F, 4) gmock_a4) constness { \
+ GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
+ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 4, \
+ this_method_does_not_take_4_arguments); \
+ GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \
+ return GMOCK_MOCKER_(4, constness, Method).Invoke(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4); \
+ } \
+ ::testing::MockSpec<F>& \
+ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
+ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
+ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
+ GMOCK_MATCHER_(tn, F, 4) gmock_a4) constness { \
+ GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \
+ return GMOCK_MOCKER_(4, constness, Method).With(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4); \
+ } \
+ mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(4, constness, Method)
+
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_METHOD5_(tn, constness, ct, Method, F) \
+ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
+ GMOCK_ARG_(tn, F, 2) gmock_a2, \
+ GMOCK_ARG_(tn, F, 3) gmock_a3, \
+ GMOCK_ARG_(tn, F, 4) gmock_a4, \
+ GMOCK_ARG_(tn, F, 5) gmock_a5) constness { \
+ GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
+ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 5, \
+ this_method_does_not_take_5_arguments); \
+ GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \
+ return GMOCK_MOCKER_(5, constness, Method).Invoke(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4, gmock_a5); \
+ } \
+ ::testing::MockSpec<F>& \
+ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
+ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
+ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
+ GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
+ GMOCK_MATCHER_(tn, F, 5) gmock_a5) constness { \
+ GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \
+ return GMOCK_MOCKER_(5, constness, Method).With(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4, gmock_a5); \
+ } \
+ mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(5, constness, Method)
+
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_METHOD6_(tn, constness, ct, Method, F) \
+ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
+ GMOCK_ARG_(tn, F, 2) gmock_a2, \
+ GMOCK_ARG_(tn, F, 3) gmock_a3, \
+ GMOCK_ARG_(tn, F, 4) gmock_a4, \
+ GMOCK_ARG_(tn, F, 5) gmock_a5, \
+ GMOCK_ARG_(tn, F, 6) gmock_a6) constness { \
+ GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
+ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 6, \
+ this_method_does_not_take_6_arguments); \
+ GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \
+ return GMOCK_MOCKER_(6, constness, Method).Invoke(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
+ } \
+ ::testing::MockSpec<F>& \
+ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
+ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
+ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
+ GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
+ GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
+ GMOCK_MATCHER_(tn, F, 6) gmock_a6) constness { \
+ GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \
+ return GMOCK_MOCKER_(6, constness, Method).With(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
+ } \
+ mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(6, constness, Method)
+
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_METHOD7_(tn, constness, ct, Method, F) \
+ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
+ GMOCK_ARG_(tn, F, 2) gmock_a2, \
+ GMOCK_ARG_(tn, F, 3) gmock_a3, \
+ GMOCK_ARG_(tn, F, 4) gmock_a4, \
+ GMOCK_ARG_(tn, F, 5) gmock_a5, \
+ GMOCK_ARG_(tn, F, 6) gmock_a6, \
+ GMOCK_ARG_(tn, F, 7) gmock_a7) constness { \
+ GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
+ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 7, \
+ this_method_does_not_take_7_arguments); \
+ GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \
+ return GMOCK_MOCKER_(7, constness, Method).Invoke(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
+ } \
+ ::testing::MockSpec<F>& \
+ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
+ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
+ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
+ GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
+ GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
+ GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
+ GMOCK_MATCHER_(tn, F, 7) gmock_a7) constness { \
+ GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \
+ return GMOCK_MOCKER_(7, constness, Method).With(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
+ } \
+ mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(7, constness, Method)
+
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_METHOD8_(tn, constness, ct, Method, F) \
+ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
+ GMOCK_ARG_(tn, F, 2) gmock_a2, \
+ GMOCK_ARG_(tn, F, 3) gmock_a3, \
+ GMOCK_ARG_(tn, F, 4) gmock_a4, \
+ GMOCK_ARG_(tn, F, 5) gmock_a5, \
+ GMOCK_ARG_(tn, F, 6) gmock_a6, \
+ GMOCK_ARG_(tn, F, 7) gmock_a7, \
+ GMOCK_ARG_(tn, F, 8) gmock_a8) constness { \
+ GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
+ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 8, \
+ this_method_does_not_take_8_arguments); \
+ GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \
+ return GMOCK_MOCKER_(8, constness, Method).Invoke(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
+ } \
+ ::testing::MockSpec<F>& \
+ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
+ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
+ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
+ GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
+ GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
+ GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
+ GMOCK_MATCHER_(tn, F, 7) gmock_a7, \
+ GMOCK_MATCHER_(tn, F, 8) gmock_a8) constness { \
+ GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \
+ return GMOCK_MOCKER_(8, constness, Method).With(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
+ } \
+ mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(8, constness, Method)
+
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_METHOD9_(tn, constness, ct, Method, F) \
+ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
+ GMOCK_ARG_(tn, F, 2) gmock_a2, \
+ GMOCK_ARG_(tn, F, 3) gmock_a3, \
+ GMOCK_ARG_(tn, F, 4) gmock_a4, \
+ GMOCK_ARG_(tn, F, 5) gmock_a5, \
+ GMOCK_ARG_(tn, F, 6) gmock_a6, \
+ GMOCK_ARG_(tn, F, 7) gmock_a7, \
+ GMOCK_ARG_(tn, F, 8) gmock_a8, \
+ GMOCK_ARG_(tn, F, 9) gmock_a9) constness { \
+ GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
+ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 9, \
+ this_method_does_not_take_9_arguments); \
+ GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \
+ return GMOCK_MOCKER_(9, constness, Method).Invoke(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
+ gmock_a9); \
+ } \
+ ::testing::MockSpec<F>& \
+ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
+ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
+ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
+ GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
+ GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
+ GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
+ GMOCK_MATCHER_(tn, F, 7) gmock_a7, \
+ GMOCK_MATCHER_(tn, F, 8) gmock_a8, \
+ GMOCK_MATCHER_(tn, F, 9) gmock_a9) constness { \
+ GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \
+ return GMOCK_MOCKER_(9, constness, Method).With(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
+ gmock_a9); \
+ } \
+ mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(9, constness, Method)
+
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_METHOD10_(tn, constness, ct, Method, F) \
+ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
+ GMOCK_ARG_(tn, F, 2) gmock_a2, \
+ GMOCK_ARG_(tn, F, 3) gmock_a3, \
+ GMOCK_ARG_(tn, F, 4) gmock_a4, \
+ GMOCK_ARG_(tn, F, 5) gmock_a5, \
+ GMOCK_ARG_(tn, F, 6) gmock_a6, \
+ GMOCK_ARG_(tn, F, 7) gmock_a7, \
+ GMOCK_ARG_(tn, F, 8) gmock_a8, \
+ GMOCK_ARG_(tn, F, 9) gmock_a9, \
+ GMOCK_ARG_(tn, F, 10) gmock_a10) constness { \
+ GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
+ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 10, \
+ this_method_does_not_take_10_arguments); \
+ GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \
+ return GMOCK_MOCKER_(10, constness, Method).Invoke(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
+ gmock_a10); \
+ } \
+ ::testing::MockSpec<F>& \
+ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
+ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
+ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
+ GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
+ GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
+ GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
+ GMOCK_MATCHER_(tn, F, 7) gmock_a7, \
+ GMOCK_MATCHER_(tn, F, 8) gmock_a8, \
+ GMOCK_MATCHER_(tn, F, 9) gmock_a9, \
+ GMOCK_MATCHER_(tn, F, 10) gmock_a10) constness { \
+ GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \
+ return GMOCK_MOCKER_(10, constness, Method).With(gmock_a1, gmock_a2, \
+ gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
+ gmock_a10); \
+ } \
+ mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(10, constness, Method)
+
+#define MOCK_METHOD0(m, F) GMOCK_METHOD0_(, , , m, F)
+#define MOCK_METHOD1(m, F) GMOCK_METHOD1_(, , , m, F)
+#define MOCK_METHOD2(m, F) GMOCK_METHOD2_(, , , m, F)
+#define MOCK_METHOD3(m, F) GMOCK_METHOD3_(, , , m, F)
+#define MOCK_METHOD4(m, F) GMOCK_METHOD4_(, , , m, F)
+#define MOCK_METHOD5(m, F) GMOCK_METHOD5_(, , , m, F)
+#define MOCK_METHOD6(m, F) GMOCK_METHOD6_(, , , m, F)
+#define MOCK_METHOD7(m, F) GMOCK_METHOD7_(, , , m, F)
+#define MOCK_METHOD8(m, F) GMOCK_METHOD8_(, , , m, F)
+#define MOCK_METHOD9(m, F) GMOCK_METHOD9_(, , , m, F)
+#define MOCK_METHOD10(m, F) GMOCK_METHOD10_(, , , m, F)
+
+#define MOCK_CONST_METHOD0(m, F) GMOCK_METHOD0_(, const, , m, F)
+#define MOCK_CONST_METHOD1(m, F) GMOCK_METHOD1_(, const, , m, F)
+#define MOCK_CONST_METHOD2(m, F) GMOCK_METHOD2_(, const, , m, F)
+#define MOCK_CONST_METHOD3(m, F) GMOCK_METHOD3_(, const, , m, F)
+#define MOCK_CONST_METHOD4(m, F) GMOCK_METHOD4_(, const, , m, F)
+#define MOCK_CONST_METHOD5(m, F) GMOCK_METHOD5_(, const, , m, F)
+#define MOCK_CONST_METHOD6(m, F) GMOCK_METHOD6_(, const, , m, F)
+#define MOCK_CONST_METHOD7(m, F) GMOCK_METHOD7_(, const, , m, F)
+#define MOCK_CONST_METHOD8(m, F) GMOCK_METHOD8_(, const, , m, F)
+#define MOCK_CONST_METHOD9(m, F) GMOCK_METHOD9_(, const, , m, F)
+#define MOCK_CONST_METHOD10(m, F) GMOCK_METHOD10_(, const, , m, F)
+
+#define MOCK_METHOD0_T(m, F) GMOCK_METHOD0_(typename, , , m, F)
+#define MOCK_METHOD1_T(m, F) GMOCK_METHOD1_(typename, , , m, F)
+#define MOCK_METHOD2_T(m, F) GMOCK_METHOD2_(typename, , , m, F)
+#define MOCK_METHOD3_T(m, F) GMOCK_METHOD3_(typename, , , m, F)
+#define MOCK_METHOD4_T(m, F) GMOCK_METHOD4_(typename, , , m, F)
+#define MOCK_METHOD5_T(m, F) GMOCK_METHOD5_(typename, , , m, F)
+#define MOCK_METHOD6_T(m, F) GMOCK_METHOD6_(typename, , , m, F)
+#define MOCK_METHOD7_T(m, F) GMOCK_METHOD7_(typename, , , m, F)
+#define MOCK_METHOD8_T(m, F) GMOCK_METHOD8_(typename, , , m, F)
+#define MOCK_METHOD9_T(m, F) GMOCK_METHOD9_(typename, , , m, F)
+#define MOCK_METHOD10_T(m, F) GMOCK_METHOD10_(typename, , , m, F)
+
+#define MOCK_CONST_METHOD0_T(m, F) GMOCK_METHOD0_(typename, const, , m, F)
+#define MOCK_CONST_METHOD1_T(m, F) GMOCK_METHOD1_(typename, const, , m, F)
+#define MOCK_CONST_METHOD2_T(m, F) GMOCK_METHOD2_(typename, const, , m, F)
+#define MOCK_CONST_METHOD3_T(m, F) GMOCK_METHOD3_(typename, const, , m, F)
+#define MOCK_CONST_METHOD4_T(m, F) GMOCK_METHOD4_(typename, const, , m, F)
+#define MOCK_CONST_METHOD5_T(m, F) GMOCK_METHOD5_(typename, const, , m, F)
+#define MOCK_CONST_METHOD6_T(m, F) GMOCK_METHOD6_(typename, const, , m, F)
+#define MOCK_CONST_METHOD7_T(m, F) GMOCK_METHOD7_(typename, const, , m, F)
+#define MOCK_CONST_METHOD8_T(m, F) GMOCK_METHOD8_(typename, const, , m, F)
+#define MOCK_CONST_METHOD9_T(m, F) GMOCK_METHOD9_(typename, const, , m, F)
+#define MOCK_CONST_METHOD10_T(m, F) GMOCK_METHOD10_(typename, const, , m, F)
+
+#define MOCK_METHOD0_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD0_(, , ct, m, F)
+#define MOCK_METHOD1_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD1_(, , ct, m, F)
+#define MOCK_METHOD2_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD2_(, , ct, m, F)
+#define MOCK_METHOD3_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD3_(, , ct, m, F)
+#define MOCK_METHOD4_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD4_(, , ct, m, F)
+#define MOCK_METHOD5_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD5_(, , ct, m, F)
+#define MOCK_METHOD6_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD6_(, , ct, m, F)
+#define MOCK_METHOD7_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD7_(, , ct, m, F)
+#define MOCK_METHOD8_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD8_(, , ct, m, F)
+#define MOCK_METHOD9_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD9_(, , ct, m, F)
+#define MOCK_METHOD10_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD10_(, , ct, m, F)
+
+#define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD0_(, const, ct, m, F)
+#define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD1_(, const, ct, m, F)
+#define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD2_(, const, ct, m, F)
+#define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD3_(, const, ct, m, F)
+#define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD4_(, const, ct, m, F)
+#define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD5_(, const, ct, m, F)
+#define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD6_(, const, ct, m, F)
+#define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD7_(, const, ct, m, F)
+#define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD8_(, const, ct, m, F)
+#define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD9_(, const, ct, m, F)
+#define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD10_(, const, ct, m, F)
+
+#define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD0_(typename, , ct, m, F)
+#define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD1_(typename, , ct, m, F)
+#define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD2_(typename, , ct, m, F)
+#define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD3_(typename, , ct, m, F)
+#define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD4_(typename, , ct, m, F)
+#define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD5_(typename, , ct, m, F)
+#define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD6_(typename, , ct, m, F)
+#define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD7_(typename, , ct, m, F)
+#define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD8_(typename, , ct, m, F)
+#define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD9_(typename, , ct, m, F)
+#define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD10_(typename, , ct, m, F)
+
+#define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD0_(typename, const, ct, m, F)
+#define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD1_(typename, const, ct, m, F)
+#define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD2_(typename, const, ct, m, F)
+#define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD3_(typename, const, ct, m, F)
+#define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD4_(typename, const, ct, m, F)
+#define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD5_(typename, const, ct, m, F)
+#define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD6_(typename, const, ct, m, F)
+#define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD7_(typename, const, ct, m, F)
+#define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD8_(typename, const, ct, m, F)
+#define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD9_(typename, const, ct, m, F)
+#define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD10_(typename, const, ct, m, F)
+
+// A MockFunction<F> class has one mock method whose type is F. It is
+// useful when you just want your test code to emit some messages and
+// have Google Mock verify the right messages are sent (and perhaps at
+// the right times). For example, if you are exercising code:
+//
+// Foo(1);
+// Foo(2);
+// Foo(3);
+//
+// and want to verify that Foo(1) and Foo(3) both invoke
+// mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
+//
+// TEST(FooTest, InvokesBarCorrectly) {
+// MyMock mock;
+// MockFunction<void(string check_point_name)> check;
+// {
+// InSequence s;
+//
+// EXPECT_CALL(mock, Bar("a"));
+// EXPECT_CALL(check, Call("1"));
+// EXPECT_CALL(check, Call("2"));
+// EXPECT_CALL(mock, Bar("a"));
+// }
+// Foo(1);
+// check.Call("1");
+// Foo(2);
+// check.Call("2");
+// Foo(3);
+// }
+//
+// The expectation spec says that the first Bar("a") must happen
+// before check point "1", the second Bar("a") must happen after check
+// point "2", and nothing should happen between the two check
+// points. The explicit check points make it easy to tell which
+// Bar("a") is called by which call to Foo().
+template <typename F>
+class MockFunction;
+
+template <typename R>
+class MockFunction<R()> {
+ public:
+ MockFunction() {}
+
+ MOCK_METHOD0_T(Call, R());
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
+};
+
+template <typename R, typename A0>
+class MockFunction<R(A0)> {
+ public:
+ MockFunction() {}
+
+ MOCK_METHOD1_T(Call, R(A0));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
+};
+
+template <typename R, typename A0, typename A1>
+class MockFunction<R(A0, A1)> {
+ public:
+ MockFunction() {}
+
+ MOCK_METHOD2_T(Call, R(A0, A1));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
+};
+
+template <typename R, typename A0, typename A1, typename A2>
+class MockFunction<R(A0, A1, A2)> {
+ public:
+ MockFunction() {}
+
+ MOCK_METHOD3_T(Call, R(A0, A1, A2));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
+};
+
+template <typename R, typename A0, typename A1, typename A2, typename A3>
+class MockFunction<R(A0, A1, A2, A3)> {
+ public:
+ MockFunction() {}
+
+ MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
+};
+
+template <typename R, typename A0, typename A1, typename A2, typename A3,
+ typename A4>
+class MockFunction<R(A0, A1, A2, A3, A4)> {
+ public:
+ MockFunction() {}
+
+ MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
+};
+
+template <typename R, typename A0, typename A1, typename A2, typename A3,
+ typename A4, typename A5>
+class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
+ public:
+ MockFunction() {}
+
+ MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
+};
+
+template <typename R, typename A0, typename A1, typename A2, typename A3,
+ typename A4, typename A5, typename A6>
+class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
+ public:
+ MockFunction() {}
+
+ MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
+};
+
+template <typename R, typename A0, typename A1, typename A2, typename A3,
+ typename A4, typename A5, typename A6, typename A7>
+class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
+ public:
+ MockFunction() {}
+
+ MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
+};
+
+template <typename R, typename A0, typename A1, typename A2, typename A3,
+ typename A4, typename A5, typename A6, typename A7, typename A8>
+class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
+ public:
+ MockFunction() {}
+
+ MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
+};
+
+template <typename R, typename A0, typename A1, typename A2, typename A3,
+ typename A4, typename A5, typename A6, typename A7, typename A8,
+ typename A9>
+class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
+ public:
+ MockFunction() {}
+
+ MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
+};
+
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
diff --git a/lib/gtest/include/gmock/gmock-generated-function-mockers.h.pump b/lib/gtest/include/gmock/gmock-generated-function-mockers.h.pump
new file mode 100644
index 0000000..4f82d62
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-generated-function-mockers.h.pump
@@ -0,0 +1,258 @@
+$$ -*- mode: c++; -*-
+$$ This is a Pump source file. Please use Pump to convert it to
+$$ gmock-generated-function-mockers.h.
+$$
+$var n = 10 $$ The maximum arity we support.
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements function mockers of various arities.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
+
+#include "gmock/gmock-spec-builders.h"
+#include "gmock/internal/gmock-internal-utils.h"
+
+namespace testing {
+namespace internal {
+
+template <typename F>
+class FunctionMockerBase;
+
+// Note: class FunctionMocker really belongs to the ::testing
+// namespace. However if we define it in ::testing, MSVC will
+// complain when classes in ::testing::internal declare it as a
+// friend class template. To workaround this compiler bug, we define
+// FunctionMocker in ::testing::internal and import it into ::testing.
+template <typename F>
+class FunctionMocker;
+
+
+$range i 0..n
+$for i [[
+$range j 1..i
+$var typename_As = [[$for j [[, typename A$j]]]]
+$var As = [[$for j, [[A$j]]]]
+$var as = [[$for j, [[a$j]]]]
+$var Aas = [[$for j, [[A$j a$j]]]]
+$var ms = [[$for j, [[m$j]]]]
+$var matchers = [[$for j, [[const Matcher<A$j>& m$j]]]]
+template <typename R$typename_As>
+class FunctionMocker<R($As)> : public
+ internal::FunctionMockerBase<R($As)> {
+ public:
+ typedef R F($As);
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+
+ MockSpec<F>& With($matchers) {
+
+$if i >= 1 [[
+ this->current_spec().SetMatchers(::std::tr1::make_tuple($ms));
+
+]]
+ return this->current_spec();
+ }
+
+ R Invoke($Aas) {
+ // Even though gcc and MSVC don't enforce it, 'this->' is required
+ // by the C++ standard [14.6.4] here, as the base class type is
+ // dependent on the template argument (and thus shouldn't be
+ // looked into when resolving InvokeWith).
+ return this->InvokeWith(ArgumentTuple($as));
+ }
+};
+
+
+]]
+} // namespace internal
+
+// The style guide prohibits "using" statements in a namespace scope
+// inside a header file. However, the FunctionMocker class template
+// is meant to be defined in the ::testing namespace. The following
+// line is just a trick for working around a bug in MSVC 8.0, which
+// cannot handle it if we define FunctionMocker in ::testing.
+using internal::FunctionMocker;
+
+// The result type of function type F.
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_RESULT_(tn, F) tn ::testing::internal::Function<F>::Result
+
+// The type of argument N of function type F.
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_ARG_(tn, F, N) tn ::testing::internal::Function<F>::Argument##N
+
+// The matcher type for argument N of function type F.
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_MATCHER_(tn, F, N) const ::testing::Matcher<GMOCK_ARG_(tn, F, N)>&
+
+// The variable for mocking the given method.
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_MOCKER_(arity, constness, Method) \
+ GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
+
+
+$for i [[
+$range j 1..i
+$var arg_as = [[$for j, \
+ [[GMOCK_ARG_(tn, F, $j) gmock_a$j]]]]
+$var as = [[$for j, [[gmock_a$j]]]]
+$var matcher_as = [[$for j, \
+ [[GMOCK_MATCHER_(tn, F, $j) gmock_a$j]]]]
+// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
+#define GMOCK_METHOD$i[[]]_(tn, constness, ct, Method, F) \
+ GMOCK_RESULT_(tn, F) ct Method($arg_as) constness { \
+ GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
+ tn ::testing::internal::Function<F>::ArgumentTuple>::value == $i, \
+ this_method_does_not_take_$i[[]]_argument[[$if i != 1 [[s]]]]); \
+ GMOCK_MOCKER_($i, constness, Method).SetOwnerAndName(this, #Method); \
+ return GMOCK_MOCKER_($i, constness, Method).Invoke($as); \
+ } \
+ ::testing::MockSpec<F>& \
+ gmock_##Method($matcher_as) constness { \
+ GMOCK_MOCKER_($i, constness, Method).RegisterOwner(this); \
+ return GMOCK_MOCKER_($i, constness, Method).With($as); \
+ } \
+ mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_($i, constness, Method)
+
+
+]]
+$for i [[
+#define MOCK_METHOD$i(m, F) GMOCK_METHOD$i[[]]_(, , , m, F)
+
+]]
+
+
+$for i [[
+#define MOCK_CONST_METHOD$i(m, F) GMOCK_METHOD$i[[]]_(, const, , m, F)
+
+]]
+
+
+$for i [[
+#define MOCK_METHOD$i[[]]_T(m, F) GMOCK_METHOD$i[[]]_(typename, , , m, F)
+
+]]
+
+
+$for i [[
+#define MOCK_CONST_METHOD$i[[]]_T(m, F) [[]]
+GMOCK_METHOD$i[[]]_(typename, const, , m, F)
+
+]]
+
+
+$for i [[
+#define MOCK_METHOD$i[[]]_WITH_CALLTYPE(ct, m, F) [[]]
+GMOCK_METHOD$i[[]]_(, , ct, m, F)
+
+]]
+
+
+$for i [[
+#define MOCK_CONST_METHOD$i[[]]_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD$i[[]]_(, const, ct, m, F)
+
+]]
+
+
+$for i [[
+#define MOCK_METHOD$i[[]]_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD$i[[]]_(typename, , ct, m, F)
+
+]]
+
+
+$for i [[
+#define MOCK_CONST_METHOD$i[[]]_T_WITH_CALLTYPE(ct, m, F) \
+ GMOCK_METHOD$i[[]]_(typename, const, ct, m, F)
+
+]]
+
+// A MockFunction<F> class has one mock method whose type is F. It is
+// useful when you just want your test code to emit some messages and
+// have Google Mock verify the right messages are sent (and perhaps at
+// the right times). For example, if you are exercising code:
+//
+// Foo(1);
+// Foo(2);
+// Foo(3);
+//
+// and want to verify that Foo(1) and Foo(3) both invoke
+// mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
+//
+// TEST(FooTest, InvokesBarCorrectly) {
+// MyMock mock;
+// MockFunction<void(string check_point_name)> check;
+// {
+// InSequence s;
+//
+// EXPECT_CALL(mock, Bar("a"));
+// EXPECT_CALL(check, Call("1"));
+// EXPECT_CALL(check, Call("2"));
+// EXPECT_CALL(mock, Bar("a"));
+// }
+// Foo(1);
+// check.Call("1");
+// Foo(2);
+// check.Call("2");
+// Foo(3);
+// }
+//
+// The expectation spec says that the first Bar("a") must happen
+// before check point "1", the second Bar("a") must happen after check
+// point "2", and nothing should happen between the two check
+// points. The explicit check points make it easy to tell which
+// Bar("a") is called by which call to Foo().
+template <typename F>
+class MockFunction;
+
+
+$for i [[
+$range j 0..i-1
+template <typename R$for j [[, typename A$j]]>
+class MockFunction<R($for j, [[A$j]])> {
+ public:
+ MockFunction() {}
+
+ MOCK_METHOD$i[[]]_T(Call, R($for j, [[A$j]]));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
+};
+
+
+]]
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
diff --git a/lib/gtest/include/gmock/gmock-generated-matchers.h b/lib/gtest/include/gmock/gmock-generated-matchers.h
new file mode 100644
index 0000000..6feaf1a
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-generated-matchers.h
@@ -0,0 +1,2054 @@
+// This file was GENERATED by command:
+// pump.py gmock-generated-matchers.h.pump
+// DO NOT EDIT BY HAND!!!
+
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements some commonly used variadic matchers.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
+
+#include <sstream>
+#include <string>
+#include <vector>
+#include "gmock/gmock-matchers.h"
+
+namespace testing {
+namespace internal {
+
+// The type of the i-th (0-based) field of Tuple.
+#define GMOCK_FIELD_TYPE_(Tuple, i) \
+ typename ::std::tr1::tuple_element<i, Tuple>::type
+
+// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
+// tuple of type Tuple. It has two members:
+//
+// type: a tuple type whose i-th field is the ki-th field of Tuple.
+// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
+//
+// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
+//
+// type is tuple<int, bool>, and
+// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
+
+template <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
+ int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
+ int k9 = -1>
+class TupleFields;
+
+// This generic version is used when there are 10 selectors.
+template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
+ int k7, int k8, int k9>
+class TupleFields {
+ public:
+ typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
+ GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
+ GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
+ GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
+ GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
+ GMOCK_FIELD_TYPE_(Tuple, k9)> type;
+ static type GetSelectedFields(const Tuple& t) {
+ using ::std::tr1::get;
+ return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
+ get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
+ }
+};
+
+// The following specialization is used for 0 ~ 9 selectors.
+
+template <class Tuple>
+class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
+ public:
+ typedef ::std::tr1::tuple<> type;
+ static type GetSelectedFields(const Tuple& /* t */) {
+ using ::std::tr1::get;
+ return type();
+ }
+};
+
+template <class Tuple, int k0>
+class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
+ public:
+ typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
+ static type GetSelectedFields(const Tuple& t) {
+ using ::std::tr1::get;
+ return type(get<k0>(t));
+ }
+};
+
+template <class Tuple, int k0, int k1>
+class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
+ public:
+ typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
+ GMOCK_FIELD_TYPE_(Tuple, k1)> type;
+ static type GetSelectedFields(const Tuple& t) {
+ using ::std::tr1::get;
+ return type(get<k0>(t), get<k1>(t));
+ }
+};
+
+template <class Tuple, int k0, int k1, int k2>
+class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
+ public:
+ typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
+ GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
+ static type GetSelectedFields(const Tuple& t) {
+ using ::std::tr1::get;
+ return type(get<k0>(t), get<k1>(t), get<k2>(t));
+ }
+};
+
+template <class Tuple, int k0, int k1, int k2, int k3>
+class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
+ public:
+ typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
+ GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
+ GMOCK_FIELD_TYPE_(Tuple, k3)> type;
+ static type GetSelectedFields(const Tuple& t) {
+ using ::std::tr1::get;
+ return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
+ }
+};
+
+template <class Tuple, int k0, int k1, int k2, int k3, int k4>
+class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
+ public:
+ typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
+ GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
+ GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
+ static type GetSelectedFields(const Tuple& t) {
+ using ::std::tr1::get;
+ return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
+ }
+};
+
+template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
+class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
+ public:
+ typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
+ GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
+ GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
+ GMOCK_FIELD_TYPE_(Tuple, k5)> type;
+ static type GetSelectedFields(const Tuple& t) {
+ using ::std::tr1::get;
+ return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
+ get<k5>(t));
+ }
+};
+
+template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
+class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
+ public:
+ typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
+ GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
+ GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
+ GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
+ static type GetSelectedFields(const Tuple& t) {
+ using ::std::tr1::get;
+ return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
+ get<k5>(t), get<k6>(t));
+ }
+};
+
+template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
+ int k7>
+class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
+ public:
+ typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
+ GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
+ GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
+ GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
+ GMOCK_FIELD_TYPE_(Tuple, k7)> type;
+ static type GetSelectedFields(const Tuple& t) {
+ using ::std::tr1::get;
+ return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
+ get<k5>(t), get<k6>(t), get<k7>(t));
+ }
+};
+
+template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
+ int k7, int k8>
+class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
+ public:
+ typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
+ GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
+ GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
+ GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
+ GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
+ static type GetSelectedFields(const Tuple& t) {
+ using ::std::tr1::get;
+ return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
+ get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
+ }
+};
+
+#undef GMOCK_FIELD_TYPE_
+
+// Implements the Args() matcher.
+template <class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
+ int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
+ int k9 = -1>
+class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
+ public:
+ // ArgsTuple may have top-level const or reference modifiers.
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;
+ typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,
+ k6, k7, k8, k9>::type SelectedArgs;
+ typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
+
+ template <typename InnerMatcher>
+ explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
+ : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
+
+ virtual bool MatchAndExplain(ArgsTuple args,
+ MatchResultListener* listener) const {
+ const SelectedArgs& selected_args = GetSelectedArgs(args);
+ if (!listener->IsInterested())
+ return inner_matcher_.Matches(selected_args);
+
+ PrintIndices(listener->stream());
+ *listener << "are " << PrintToString(selected_args);
+
+ StringMatchResultListener inner_listener;
+ const bool match = inner_matcher_.MatchAndExplain(selected_args,
+ &inner_listener);
+ PrintIfNotEmpty(inner_listener.str(), listener->stream());
+ return match;
+ }
+
+ virtual void DescribeTo(::std::ostream* os) const {
+ *os << "are a tuple ";
+ PrintIndices(os);
+ inner_matcher_.DescribeTo(os);
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "are a tuple ";
+ PrintIndices(os);
+ inner_matcher_.DescribeNegationTo(os);
+ }
+
+ private:
+ static SelectedArgs GetSelectedArgs(ArgsTuple args) {
+ return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
+ k9>::GetSelectedFields(args);
+ }
+
+ // Prints the indices of the selected fields.
+ static void PrintIndices(::std::ostream* os) {
+ *os << "whose fields (";
+ const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
+ for (int i = 0; i < 10; i++) {
+ if (indices[i] < 0)
+ break;
+
+ if (i >= 1)
+ *os << ", ";
+
+ *os << "#" << indices[i];
+ }
+ *os << ") ";
+ }
+
+ const MonomorphicInnerMatcher inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
+};
+
+template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
+ int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,
+ int k8 = -1, int k9 = -1>
+class ArgsMatcher {
+ public:
+ explicit ArgsMatcher(const InnerMatcher& inner_matcher)
+ : inner_matcher_(inner_matcher) {}
+
+ template <typename ArgsTuple>
+ operator Matcher<ArgsTuple>() const {
+ return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k5,
+ k6, k7, k8, k9>(inner_matcher_));
+ }
+
+ private:
+ const InnerMatcher inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
+};
+
+// Implements ElementsAre() of 1-10 arguments.
+
+template <typename T1>
+class ElementsAreMatcher1 {
+ public:
+ explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+ // Nokia's Symbian Compiler has a nasty bug where the object put
+ // in a one-element local array is not destructed when the array
+ // goes out of scope. This leads to obvious badness as we've
+ // added the linked_ptr in it to our other linked_ptrs list.
+ // Hence we implement ElementsAreMatcher1 specially to avoid using
+ // a local array.
+ const Matcher<const Element&> matcher =
+ MatcherCast<const Element&>(e1_);
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(&matcher, 1));
+ }
+
+ private:
+ const T1& e1_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher1);
+};
+
+template <typename T1, typename T2>
+class ElementsAreMatcher2 {
+ public:
+ ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+ const Matcher<const Element&> matchers[] = {
+ MatcherCast<const Element&>(e1_),
+ MatcherCast<const Element&>(e2_),
+ };
+
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 2));
+ }
+
+ private:
+ const T1& e1_;
+ const T2& e2_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher2);
+};
+
+template <typename T1, typename T2, typename T3>
+class ElementsAreMatcher3 {
+ public:
+ ElementsAreMatcher3(const T1& e1, const T2& e2, const T3& e3) : e1_(e1),
+ e2_(e2), e3_(e3) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+ const Matcher<const Element&> matchers[] = {
+ MatcherCast<const Element&>(e1_),
+ MatcherCast<const Element&>(e2_),
+ MatcherCast<const Element&>(e3_),
+ };
+
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 3));
+ }
+
+ private:
+ const T1& e1_;
+ const T2& e2_;
+ const T3& e3_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher3);
+};
+
+template <typename T1, typename T2, typename T3, typename T4>
+class ElementsAreMatcher4 {
+ public:
+ ElementsAreMatcher4(const T1& e1, const T2& e2, const T3& e3,
+ const T4& e4) : e1_(e1), e2_(e2), e3_(e3), e4_(e4) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+ const Matcher<const Element&> matchers[] = {
+ MatcherCast<const Element&>(e1_),
+ MatcherCast<const Element&>(e2_),
+ MatcherCast<const Element&>(e3_),
+ MatcherCast<const Element&>(e4_),
+ };
+
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 4));
+ }
+
+ private:
+ const T1& e1_;
+ const T2& e2_;
+ const T3& e3_;
+ const T4& e4_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher4);
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5>
+class ElementsAreMatcher5 {
+ public:
+ ElementsAreMatcher5(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
+ const T5& e5) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+ const Matcher<const Element&> matchers[] = {
+ MatcherCast<const Element&>(e1_),
+ MatcherCast<const Element&>(e2_),
+ MatcherCast<const Element&>(e3_),
+ MatcherCast<const Element&>(e4_),
+ MatcherCast<const Element&>(e5_),
+ };
+
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 5));
+ }
+
+ private:
+ const T1& e1_;
+ const T2& e2_;
+ const T3& e3_;
+ const T4& e4_;
+ const T5& e5_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher5);
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6>
+class ElementsAreMatcher6 {
+ public:
+ ElementsAreMatcher6(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
+ const T5& e5, const T6& e6) : e1_(e1), e2_(e2), e3_(e3), e4_(e4),
+ e5_(e5), e6_(e6) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+ const Matcher<const Element&> matchers[] = {
+ MatcherCast<const Element&>(e1_),
+ MatcherCast<const Element&>(e2_),
+ MatcherCast<const Element&>(e3_),
+ MatcherCast<const Element&>(e4_),
+ MatcherCast<const Element&>(e5_),
+ MatcherCast<const Element&>(e6_),
+ };
+
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 6));
+ }
+
+ private:
+ const T1& e1_;
+ const T2& e2_;
+ const T3& e3_;
+ const T4& e4_;
+ const T5& e5_;
+ const T6& e6_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher6);
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7>
+class ElementsAreMatcher7 {
+ public:
+ ElementsAreMatcher7(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
+ const T5& e5, const T6& e6, const T7& e7) : e1_(e1), e2_(e2), e3_(e3),
+ e4_(e4), e5_(e5), e6_(e6), e7_(e7) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+ const Matcher<const Element&> matchers[] = {
+ MatcherCast<const Element&>(e1_),
+ MatcherCast<const Element&>(e2_),
+ MatcherCast<const Element&>(e3_),
+ MatcherCast<const Element&>(e4_),
+ MatcherCast<const Element&>(e5_),
+ MatcherCast<const Element&>(e6_),
+ MatcherCast<const Element&>(e7_),
+ };
+
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 7));
+ }
+
+ private:
+ const T1& e1_;
+ const T2& e2_;
+ const T3& e3_;
+ const T4& e4_;
+ const T5& e5_;
+ const T6& e6_;
+ const T7& e7_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher7);
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7, typename T8>
+class ElementsAreMatcher8 {
+ public:
+ ElementsAreMatcher8(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
+ const T5& e5, const T6& e6, const T7& e7, const T8& e8) : e1_(e1),
+ e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+ const Matcher<const Element&> matchers[] = {
+ MatcherCast<const Element&>(e1_),
+ MatcherCast<const Element&>(e2_),
+ MatcherCast<const Element&>(e3_),
+ MatcherCast<const Element&>(e4_),
+ MatcherCast<const Element&>(e5_),
+ MatcherCast<const Element&>(e6_),
+ MatcherCast<const Element&>(e7_),
+ MatcherCast<const Element&>(e8_),
+ };
+
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 8));
+ }
+
+ private:
+ const T1& e1_;
+ const T2& e2_;
+ const T3& e3_;
+ const T4& e4_;
+ const T5& e5_;
+ const T6& e6_;
+ const T7& e7_;
+ const T8& e8_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher8);
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7, typename T8, typename T9>
+class ElementsAreMatcher9 {
+ public:
+ ElementsAreMatcher9(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
+ const T5& e5, const T6& e6, const T7& e7, const T8& e8,
+ const T9& e9) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
+ e7_(e7), e8_(e8), e9_(e9) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+ const Matcher<const Element&> matchers[] = {
+ MatcherCast<const Element&>(e1_),
+ MatcherCast<const Element&>(e2_),
+ MatcherCast<const Element&>(e3_),
+ MatcherCast<const Element&>(e4_),
+ MatcherCast<const Element&>(e5_),
+ MatcherCast<const Element&>(e6_),
+ MatcherCast<const Element&>(e7_),
+ MatcherCast<const Element&>(e8_),
+ MatcherCast<const Element&>(e9_),
+ };
+
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 9));
+ }
+
+ private:
+ const T1& e1_;
+ const T2& e2_;
+ const T3& e3_;
+ const T4& e4_;
+ const T5& e5_;
+ const T6& e6_;
+ const T7& e7_;
+ const T8& e8_;
+ const T9& e9_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher9);
+};
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7, typename T8, typename T9, typename T10>
+class ElementsAreMatcher10 {
+ public:
+ ElementsAreMatcher10(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
+ const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
+ const T10& e10) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
+ e7_(e7), e8_(e8), e9_(e9), e10_(e10) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+ const Matcher<const Element&> matchers[] = {
+ MatcherCast<const Element&>(e1_),
+ MatcherCast<const Element&>(e2_),
+ MatcherCast<const Element&>(e3_),
+ MatcherCast<const Element&>(e4_),
+ MatcherCast<const Element&>(e5_),
+ MatcherCast<const Element&>(e6_),
+ MatcherCast<const Element&>(e7_),
+ MatcherCast<const Element&>(e8_),
+ MatcherCast<const Element&>(e9_),
+ MatcherCast<const Element&>(e10_),
+ };
+
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 10));
+ }
+
+ private:
+ const T1& e1_;
+ const T2& e2_;
+ const T3& e3_;
+ const T4& e4_;
+ const T5& e5_;
+ const T6& e6_;
+ const T7& e7_;
+ const T8& e8_;
+ const T9& e9_;
+ const T10& e10_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher10);
+};
+
+} // namespace internal
+
+// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
+// fields of it matches a_matcher. C++ doesn't support default
+// arguments for function templates, so we have to overload it.
+template <typename InnerMatcher>
+inline internal::ArgsMatcher<InnerMatcher>
+Args(const InnerMatcher& matcher) {
+ return internal::ArgsMatcher<InnerMatcher>(matcher);
+}
+
+template <int k1, typename InnerMatcher>
+inline internal::ArgsMatcher<InnerMatcher, k1>
+Args(const InnerMatcher& matcher) {
+ return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
+}
+
+template <int k1, int k2, typename InnerMatcher>
+inline internal::ArgsMatcher<InnerMatcher, k1, k2>
+Args(const InnerMatcher& matcher) {
+ return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
+}
+
+template <int k1, int k2, int k3, typename InnerMatcher>
+inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
+Args(const InnerMatcher& matcher) {
+ return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
+}
+
+template <int k1, int k2, int k3, int k4, typename InnerMatcher>
+inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
+Args(const InnerMatcher& matcher) {
+ return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
+}
+
+template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
+inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
+Args(const InnerMatcher& matcher) {
+ return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
+}
+
+template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
+inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
+Args(const InnerMatcher& matcher) {
+ return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
+}
+
+template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
+ typename InnerMatcher>
+inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
+Args(const InnerMatcher& matcher) {
+ return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
+ k7>(matcher);
+}
+
+template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
+ typename InnerMatcher>
+inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
+Args(const InnerMatcher& matcher) {
+ return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
+ k8>(matcher);
+}
+
+template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
+ int k9, typename InnerMatcher>
+inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
+Args(const InnerMatcher& matcher) {
+ return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
+ k9>(matcher);
+}
+
+template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
+ int k9, int k10, typename InnerMatcher>
+inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
+ k10>
+Args(const InnerMatcher& matcher) {
+ return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
+ k9, k10>(matcher);
+}
+
+// ElementsAre(e0, e1, ..., e_n) matches an STL-style container with
+// (n + 1) elements, where the i-th element in the container must
+// match the i-th argument in the list. Each argument of
+// ElementsAre() can be either a value or a matcher. We support up to
+// 10 arguments.
+//
+// NOTE: Since ElementsAre() cares about the order of the elements, it
+// must not be used with containers whose elements's order is
+// undefined (e.g. hash_map).
+
+inline internal::ElementsAreMatcher0 ElementsAre() {
+ return internal::ElementsAreMatcher0();
+}
+
+template <typename T1>
+inline internal::ElementsAreMatcher1<T1> ElementsAre(const T1& e1) {
+ return internal::ElementsAreMatcher1<T1>(e1);
+}
+
+template <typename T1, typename T2>
+inline internal::ElementsAreMatcher2<T1, T2> ElementsAre(const T1& e1,
+ const T2& e2) {
+ return internal::ElementsAreMatcher2<T1, T2>(e1, e2);
+}
+
+template <typename T1, typename T2, typename T3>
+inline internal::ElementsAreMatcher3<T1, T2, T3> ElementsAre(const T1& e1,
+ const T2& e2, const T3& e3) {
+ return internal::ElementsAreMatcher3<T1, T2, T3>(e1, e2, e3);
+}
+
+template <typename T1, typename T2, typename T3, typename T4>
+inline internal::ElementsAreMatcher4<T1, T2, T3, T4> ElementsAre(const T1& e1,
+ const T2& e2, const T3& e3, const T4& e4) {
+ return internal::ElementsAreMatcher4<T1, T2, T3, T4>(e1, e2, e3, e4);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5>
+inline internal::ElementsAreMatcher5<T1, T2, T3, T4,
+ T5> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
+ const T5& e5) {
+ return internal::ElementsAreMatcher5<T1, T2, T3, T4, T5>(e1, e2, e3, e4, e5);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6>
+inline internal::ElementsAreMatcher6<T1, T2, T3, T4, T5,
+ T6> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
+ const T5& e5, const T6& e6) {
+ return internal::ElementsAreMatcher6<T1, T2, T3, T4, T5, T6>(e1, e2, e3, e4,
+ e5, e6);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7>
+inline internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6,
+ T7> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
+ const T5& e5, const T6& e6, const T7& e7) {
+ return internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6, T7>(e1, e2, e3,
+ e4, e5, e6, e7);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7, typename T8>
+inline internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7,
+ T8> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
+ const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
+ return internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7, T8>(e1, e2,
+ e3, e4, e5, e6, e7, e8);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7, typename T8, typename T9>
+inline internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8,
+ T9> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
+ const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
+ return internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(e1,
+ e2, e3, e4, e5, e6, e7, e8, e9);
+}
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7, typename T8, typename T9, typename T10>
+inline internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
+ T10> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
+ const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
+ const T10& e10) {
+ return internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
+ T10>(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
+}
+
+// ElementsAreArray(array) and ElementAreArray(array, count) are like
+// ElementsAre(), except that they take an array of values or
+// matchers. The former form infers the size of 'array', which must
+// be a static C-style array. In the latter form, 'array' can either
+// be a static array or a pointer to a dynamically created array.
+
+template <typename T>
+inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
+ const T* first, size_t count) {
+ return internal::ElementsAreArrayMatcher<T>(first, count);
+}
+
+template <typename T, size_t N>
+inline internal::ElementsAreArrayMatcher<T>
+ElementsAreArray(const T (&array)[N]) {
+ return internal::ElementsAreArrayMatcher<T>(array, N);
+}
+
+// AllOf(m1, m2, ..., mk) matches any value that matches all of the given
+// sub-matchers. AllOf is called fully qualified to prevent ADL from firing.
+
+template <typename Matcher1, typename Matcher2>
+inline internal::BothOfMatcher<Matcher1, Matcher2>
+AllOf(Matcher1 m1, Matcher2 m2) {
+ return internal::BothOfMatcher<Matcher1, Matcher2>(m1, m2);
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3>
+inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
+ Matcher3> >
+AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3) {
+ return ::testing::AllOf(m1, ::testing::AllOf(m2, m3));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4>
+inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
+ internal::BothOfMatcher<Matcher3, Matcher4> > >
+AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4) {
+ return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4, typename Matcher5>
+inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
+ internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
+ Matcher5> > > >
+AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5) {
+ return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4, m5));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4, typename Matcher5, typename Matcher6>
+inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
+ internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
+ internal::BothOfMatcher<Matcher5, Matcher6> > > > >
+AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
+ Matcher6 m6) {
+ return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4, m5, m6));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7>
+inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
+ internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
+ internal::BothOfMatcher<Matcher5, internal::BothOfMatcher<Matcher6,
+ Matcher7> > > > > >
+AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
+ Matcher6 m6, Matcher7 m7) {
+ return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4, m5, m6, m7));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
+ typename Matcher8>
+inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
+ internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
+ internal::BothOfMatcher<Matcher5, internal::BothOfMatcher<Matcher6,
+ internal::BothOfMatcher<Matcher7, Matcher8> > > > > > >
+AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
+ Matcher6 m6, Matcher7 m7, Matcher8 m8) {
+ return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4, m5, m6, m7, m8));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
+ typename Matcher8, typename Matcher9>
+inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
+ internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
+ internal::BothOfMatcher<Matcher5, internal::BothOfMatcher<Matcher6,
+ internal::BothOfMatcher<Matcher7, internal::BothOfMatcher<Matcher8,
+ Matcher9> > > > > > > >
+AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
+ Matcher6 m6, Matcher7 m7, Matcher8 m8, Matcher9 m9) {
+ return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4, m5, m6, m7, m8, m9));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
+ typename Matcher8, typename Matcher9, typename Matcher10>
+inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
+ internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
+ internal::BothOfMatcher<Matcher5, internal::BothOfMatcher<Matcher6,
+ internal::BothOfMatcher<Matcher7, internal::BothOfMatcher<Matcher8,
+ internal::BothOfMatcher<Matcher9, Matcher10> > > > > > > > >
+AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
+ Matcher6 m6, Matcher7 m7, Matcher8 m8, Matcher9 m9, Matcher10 m10) {
+ return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4, m5, m6, m7, m8, m9,
+ m10));
+}
+
+// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
+// sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
+
+template <typename Matcher1, typename Matcher2>
+inline internal::EitherOfMatcher<Matcher1, Matcher2>
+AnyOf(Matcher1 m1, Matcher2 m2) {
+ return internal::EitherOfMatcher<Matcher1, Matcher2>(m1, m2);
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3>
+inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
+ Matcher3> >
+AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3) {
+ return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4>
+inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
+ internal::EitherOfMatcher<Matcher3, Matcher4> > >
+AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4) {
+ return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4, typename Matcher5>
+inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
+ internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
+ Matcher5> > > >
+AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5) {
+ return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4, m5));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4, typename Matcher5, typename Matcher6>
+inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
+ internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
+ internal::EitherOfMatcher<Matcher5, Matcher6> > > > >
+AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
+ Matcher6 m6) {
+ return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4, m5, m6));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7>
+inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
+ internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
+ internal::EitherOfMatcher<Matcher5, internal::EitherOfMatcher<Matcher6,
+ Matcher7> > > > > >
+AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
+ Matcher6 m6, Matcher7 m7) {
+ return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4, m5, m6, m7));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
+ typename Matcher8>
+inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
+ internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
+ internal::EitherOfMatcher<Matcher5, internal::EitherOfMatcher<Matcher6,
+ internal::EitherOfMatcher<Matcher7, Matcher8> > > > > > >
+AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
+ Matcher6 m6, Matcher7 m7, Matcher8 m8) {
+ return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4, m5, m6, m7, m8));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
+ typename Matcher8, typename Matcher9>
+inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
+ internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
+ internal::EitherOfMatcher<Matcher5, internal::EitherOfMatcher<Matcher6,
+ internal::EitherOfMatcher<Matcher7, internal::EitherOfMatcher<Matcher8,
+ Matcher9> > > > > > > >
+AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
+ Matcher6 m6, Matcher7 m7, Matcher8 m8, Matcher9 m9) {
+ return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4, m5, m6, m7, m8, m9));
+}
+
+template <typename Matcher1, typename Matcher2, typename Matcher3,
+ typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
+ typename Matcher8, typename Matcher9, typename Matcher10>
+inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
+ internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
+ internal::EitherOfMatcher<Matcher5, internal::EitherOfMatcher<Matcher6,
+ internal::EitherOfMatcher<Matcher7, internal::EitherOfMatcher<Matcher8,
+ internal::EitherOfMatcher<Matcher9, Matcher10> > > > > > > > >
+AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
+ Matcher6 m6, Matcher7 m7, Matcher8 m8, Matcher9 m9, Matcher10 m10) {
+ return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4, m5, m6, m7, m8, m9,
+ m10));
+}
+
+} // namespace testing
+
+
+// The MATCHER* family of macros can be used in a namespace scope to
+// define custom matchers easily.
+//
+// Basic Usage
+// ===========
+//
+// The syntax
+//
+// MATCHER(name, description_string) { statements; }
+//
+// defines a matcher with the given name that executes the statements,
+// which must return a bool to indicate if the match succeeds. Inside
+// the statements, you can refer to the value being matched by 'arg',
+// and refer to its type by 'arg_type'.
+//
+// The description string documents what the matcher does, and is used
+// to generate the failure message when the match fails. Since a
+// MATCHER() is usually defined in a header file shared by multiple
+// C++ source files, we require the description to be a C-string
+// literal to avoid possible side effects. It can be empty, in which
+// case we'll use the sequence of words in the matcher name as the
+// description.
+//
+// For example:
+//
+// MATCHER(IsEven, "") { return (arg % 2) == 0; }
+//
+// allows you to write
+//
+// // Expects mock_foo.Bar(n) to be called where n is even.
+// EXPECT_CALL(mock_foo, Bar(IsEven()));
+//
+// or,
+//
+// // Verifies that the value of some_expression is even.
+// EXPECT_THAT(some_expression, IsEven());
+//
+// If the above assertion fails, it will print something like:
+//
+// Value of: some_expression
+// Expected: is even
+// Actual: 7
+//
+// where the description "is even" is automatically calculated from the
+// matcher name IsEven.
+//
+// Argument Type
+// =============
+//
+// Note that the type of the value being matched (arg_type) is
+// determined by the context in which you use the matcher and is
+// supplied to you by the compiler, so you don't need to worry about
+// declaring it (nor can you). This allows the matcher to be
+// polymorphic. For example, IsEven() can be used to match any type
+// where the value of "(arg % 2) == 0" can be implicitly converted to
+// a bool. In the "Bar(IsEven())" example above, if method Bar()
+// takes an int, 'arg_type' will be int; if it takes an unsigned long,
+// 'arg_type' will be unsigned long; and so on.
+//
+// Parameterizing Matchers
+// =======================
+//
+// Sometimes you'll want to parameterize the matcher. For that you
+// can use another macro:
+//
+// MATCHER_P(name, param_name, description_string) { statements; }
+//
+// For example:
+//
+// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
+//
+// will allow you to write:
+//
+// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
+//
+// which may lead to this message (assuming n is 10):
+//
+// Value of: Blah("a")
+// Expected: has absolute value 10
+// Actual: -9
+//
+// Note that both the matcher description and its parameter are
+// printed, making the message human-friendly.
+//
+// In the matcher definition body, you can write 'foo_type' to
+// reference the type of a parameter named 'foo'. For example, in the
+// body of MATCHER_P(HasAbsoluteValue, value) above, you can write
+// 'value_type' to refer to the type of 'value'.
+//
+// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
+// support multi-parameter matchers.
+//
+// Describing Parameterized Matchers
+// =================================
+//
+// The last argument to MATCHER*() is a string-typed expression. The
+// expression can reference all of the matcher's parameters and a
+// special bool-typed variable named 'negation'. When 'negation' is
+// false, the expression should evaluate to the matcher's description;
+// otherwise it should evaluate to the description of the negation of
+// the matcher. For example,
+//
+// using testing::PrintToString;
+//
+// MATCHER_P2(InClosedRange, low, hi,
+// string(negation ? "is not" : "is") + " in range [" +
+// PrintToString(low) + ", " + PrintToString(hi) + "]") {
+// return low <= arg && arg <= hi;
+// }
+// ...
+// EXPECT_THAT(3, InClosedRange(4, 6));
+// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
+//
+// would generate two failures that contain the text:
+//
+// Expected: is in range [4, 6]
+// ...
+// Expected: is not in range [2, 4]
+//
+// If you specify "" as the description, the failure message will
+// contain the sequence of words in the matcher name followed by the
+// parameter values printed as a tuple. For example,
+//
+// MATCHER_P2(InClosedRange, low, hi, "") { ... }
+// ...
+// EXPECT_THAT(3, InClosedRange(4, 6));
+// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
+//
+// would generate two failures that contain the text:
+//
+// Expected: in closed range (4, 6)
+// ...
+// Expected: not (in closed range (2, 4))
+//
+// Types of Matcher Parameters
+// ===========================
+//
+// For the purpose of typing, you can view
+//
+// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
+//
+// as shorthand for
+//
+// template <typename p1_type, ..., typename pk_type>
+// FooMatcherPk<p1_type, ..., pk_type>
+// Foo(p1_type p1, ..., pk_type pk) { ... }
+//
+// When you write Foo(v1, ..., vk), the compiler infers the types of
+// the parameters v1, ..., and vk for you. If you are not happy with
+// the result of the type inference, you can specify the types by
+// explicitly instantiating the template, as in Foo<long, bool>(5,
+// false). As said earlier, you don't get to (or need to) specify
+// 'arg_type' as that's determined by the context in which the matcher
+// is used. You can assign the result of expression Foo(p1, ..., pk)
+// to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
+// can be useful when composing matchers.
+//
+// While you can instantiate a matcher template with reference types,
+// passing the parameters by pointer usually makes your code more
+// readable. If, however, you still want to pass a parameter by
+// reference, be aware that in the failure message generated by the
+// matcher you will see the value of the referenced object but not its
+// address.
+//
+// Explaining Match Results
+// ========================
+//
+// Sometimes the matcher description alone isn't enough to explain why
+// the match has failed or succeeded. For example, when expecting a
+// long string, it can be very helpful to also print the diff between
+// the expected string and the actual one. To achieve that, you can
+// optionally stream additional information to a special variable
+// named result_listener, whose type is a pointer to class
+// MatchResultListener:
+//
+// MATCHER_P(EqualsLongString, str, "") {
+// if (arg == str) return true;
+//
+// *result_listener << "the difference: "
+/// << DiffStrings(str, arg);
+// return false;
+// }
+//
+// Overloading Matchers
+// ====================
+//
+// You can overload matchers with different numbers of parameters:
+//
+// MATCHER_P(Blah, a, description_string1) { ... }
+// MATCHER_P2(Blah, a, b, description_string2) { ... }
+//
+// Caveats
+// =======
+//
+// When defining a new matcher, you should also consider implementing
+// MatcherInterface or using MakePolymorphicMatcher(). These
+// approaches require more work than the MATCHER* macros, but also
+// give you more control on the types of the value being matched and
+// the matcher parameters, which may leads to better compiler error
+// messages when the matcher is used wrong. They also allow
+// overloading matchers based on parameter types (as opposed to just
+// based on the number of parameters).
+//
+// MATCHER*() can only be used in a namespace scope. The reason is
+// that C++ doesn't yet allow function-local types to be used to
+// instantiate templates. The up-coming C++0x standard will fix this.
+// Once that's done, we'll consider supporting using MATCHER*() inside
+// a function.
+//
+// More Information
+// ================
+//
+// To learn more about using these macros, please search for 'MATCHER'
+// on http://code.google.com/p/googlemock/wiki/CookBook.
+
+#define MATCHER(name, description)\
+ class name##Matcher {\
+ public:\
+ template <typename arg_type>\
+ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
+ public:\
+ gmock_Impl()\
+ {}\
+ virtual bool MatchAndExplain(\
+ arg_type arg, ::testing::MatchResultListener* result_listener) const;\
+ virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(false);\
+ }\
+ virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(true);\
+ }\
+ private:\
+ ::testing::internal::string FormatDescription(bool negation) const {\
+ const ::testing::internal::string gmock_description = (description);\
+ if (!gmock_description.empty())\
+ return gmock_description;\
+ return ::testing::internal::FormatMatcherDescription(\
+ negation, #name,\
+ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
+ ::std::tr1::tuple<>()));\
+ }\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename arg_type>\
+ operator ::testing::Matcher<arg_type>() const {\
+ return ::testing::Matcher<arg_type>(\
+ new gmock_Impl<arg_type>());\
+ }\
+ name##Matcher() {\
+ }\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##Matcher);\
+ };\
+ inline name##Matcher name() {\
+ return name##Matcher();\
+ }\
+ template <typename arg_type>\
+ bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
+ arg_type arg,\
+ ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
+ const
+
+#define MATCHER_P(name, p0, description)\
+ template <typename p0##_type>\
+ class name##MatcherP {\
+ public:\
+ template <typename arg_type>\
+ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
+ public:\
+ explicit gmock_Impl(p0##_type gmock_p0)\
+ : p0(gmock_p0) {}\
+ virtual bool MatchAndExplain(\
+ arg_type arg, ::testing::MatchResultListener* result_listener) const;\
+ virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(false);\
+ }\
+ virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(true);\
+ }\
+ p0##_type p0;\
+ private:\
+ ::testing::internal::string FormatDescription(bool negation) const {\
+ const ::testing::internal::string gmock_description = (description);\
+ if (!gmock_description.empty())\
+ return gmock_description;\
+ return ::testing::internal::FormatMatcherDescription(\
+ negation, #name,\
+ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
+ ::std::tr1::tuple<p0##_type>(p0)));\
+ }\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename arg_type>\
+ operator ::testing::Matcher<arg_type>() const {\
+ return ::testing::Matcher<arg_type>(\
+ new gmock_Impl<arg_type>(p0));\
+ }\
+ name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
+ }\
+ p0##_type p0;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
+ };\
+ template <typename p0##_type>\
+ inline name##MatcherP<p0##_type> name(p0##_type p0) {\
+ return name##MatcherP<p0##_type>(p0);\
+ }\
+ template <typename p0##_type>\
+ template <typename arg_type>\
+ bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
+ arg_type arg,\
+ ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
+ const
+
+#define MATCHER_P2(name, p0, p1, description)\
+ template <typename p0##_type, typename p1##_type>\
+ class name##MatcherP2 {\
+ public:\
+ template <typename arg_type>\
+ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
+ public:\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
+ : p0(gmock_p0), p1(gmock_p1) {}\
+ virtual bool MatchAndExplain(\
+ arg_type arg, ::testing::MatchResultListener* result_listener) const;\
+ virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(false);\
+ }\
+ virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(true);\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ private:\
+ ::testing::internal::string FormatDescription(bool negation) const {\
+ const ::testing::internal::string gmock_description = (description);\
+ if (!gmock_description.empty())\
+ return gmock_description;\
+ return ::testing::internal::FormatMatcherDescription(\
+ negation, #name,\
+ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
+ ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\
+ }\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename arg_type>\
+ operator ::testing::Matcher<arg_type>() const {\
+ return ::testing::Matcher<arg_type>(\
+ new gmock_Impl<arg_type>(p0, p1));\
+ }\
+ name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
+ p1(gmock_p1) {\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
+ };\
+ template <typename p0##_type, typename p1##_type>\
+ inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
+ p1##_type p1) {\
+ return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
+ }\
+ template <typename p0##_type, typename p1##_type>\
+ template <typename arg_type>\
+ bool name##MatcherP2<p0##_type, \
+ p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
+ arg_type arg,\
+ ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
+ const
+
+#define MATCHER_P3(name, p0, p1, p2, description)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type>\
+ class name##MatcherP3 {\
+ public:\
+ template <typename arg_type>\
+ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
+ public:\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
+ : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
+ virtual bool MatchAndExplain(\
+ arg_type arg, ::testing::MatchResultListener* result_listener) const;\
+ virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(false);\
+ }\
+ virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(true);\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ private:\
+ ::testing::internal::string FormatDescription(bool negation) const {\
+ const ::testing::internal::string gmock_description = (description);\
+ if (!gmock_description.empty())\
+ return gmock_description;\
+ return ::testing::internal::FormatMatcherDescription(\
+ negation, #name,\
+ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
+ ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
+ p2)));\
+ }\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename arg_type>\
+ operator ::testing::Matcher<arg_type>() const {\
+ return ::testing::Matcher<arg_type>(\
+ new gmock_Impl<arg_type>(p0, p1, p2));\
+ }\
+ name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type>\
+ inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
+ p1##_type p1, p2##_type p2) {\
+ return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type>\
+ template <typename arg_type>\
+ bool name##MatcherP3<p0##_type, p1##_type, \
+ p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
+ arg_type arg,\
+ ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
+ const
+
+#define MATCHER_P4(name, p0, p1, p2, p3, description)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type>\
+ class name##MatcherP4 {\
+ public:\
+ template <typename arg_type>\
+ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
+ public:\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3)\
+ : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\
+ virtual bool MatchAndExplain(\
+ arg_type arg, ::testing::MatchResultListener* result_listener) const;\
+ virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(false);\
+ }\
+ virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(true);\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ private:\
+ ::testing::internal::string FormatDescription(bool negation) const {\
+ const ::testing::internal::string gmock_description = (description);\
+ if (!gmock_description.empty())\
+ return gmock_description;\
+ return ::testing::internal::FormatMatcherDescription(\
+ negation, #name,\
+ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
+ ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
+ p3##_type>(p0, p1, p2, p3)));\
+ }\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename arg_type>\
+ operator ::testing::Matcher<arg_type>() const {\
+ return ::testing::Matcher<arg_type>(\
+ new gmock_Impl<arg_type>(p0, p1, p2, p3));\
+ }\
+ name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
+ p2(gmock_p2), p3(gmock_p3) {\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type>\
+ inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
+ p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
+ p3##_type p3) {\
+ return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
+ p1, p2, p3);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type>\
+ template <typename arg_type>\
+ bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
+ p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
+ arg_type arg,\
+ ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
+ const
+
+#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type>\
+ class name##MatcherP5 {\
+ public:\
+ template <typename arg_type>\
+ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
+ public:\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4)\
+ : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
+ p4(gmock_p4) {}\
+ virtual bool MatchAndExplain(\
+ arg_type arg, ::testing::MatchResultListener* result_listener) const;\
+ virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(false);\
+ }\
+ virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(true);\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ private:\
+ ::testing::internal::string FormatDescription(bool negation) const {\
+ const ::testing::internal::string gmock_description = (description);\
+ if (!gmock_description.empty())\
+ return gmock_description;\
+ return ::testing::internal::FormatMatcherDescription(\
+ negation, #name,\
+ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
+ ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type>(p0, p1, p2, p3, p4)));\
+ }\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename arg_type>\
+ operator ::testing::Matcher<arg_type>() const {\
+ return ::testing::Matcher<arg_type>(\
+ new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\
+ }\
+ name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3, \
+ p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4) {\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type>\
+ inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
+ p4##_type p4) {\
+ return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type>(p0, p1, p2, p3, p4);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type>\
+ template <typename arg_type>\
+ bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
+ arg_type arg,\
+ ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
+ const
+
+#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type>\
+ class name##MatcherP6 {\
+ public:\
+ template <typename arg_type>\
+ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
+ public:\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
+ : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
+ p4(gmock_p4), p5(gmock_p5) {}\
+ virtual bool MatchAndExplain(\
+ arg_type arg, ::testing::MatchResultListener* result_listener) const;\
+ virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(false);\
+ }\
+ virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(true);\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ private:\
+ ::testing::internal::string FormatDescription(bool negation) const {\
+ const ::testing::internal::string gmock_description = (description);\
+ if (!gmock_description.empty())\
+ return gmock_description;\
+ return ::testing::internal::FormatMatcherDescription(\
+ negation, #name,\
+ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
+ ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
+ }\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename arg_type>\
+ operator ::testing::Matcher<arg_type>() const {\
+ return ::testing::Matcher<arg_type>(\
+ new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\
+ }\
+ name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
+ p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type>\
+ inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
+ p3##_type p3, p4##_type p4, p5##_type p5) {\
+ return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type>\
+ template <typename arg_type>\
+ bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
+ p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
+ arg_type arg,\
+ ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
+ const
+
+#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type>\
+ class name##MatcherP7 {\
+ public:\
+ template <typename arg_type>\
+ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
+ public:\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6)\
+ : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
+ p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
+ virtual bool MatchAndExplain(\
+ arg_type arg, ::testing::MatchResultListener* result_listener) const;\
+ virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(false);\
+ }\
+ virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(true);\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ private:\
+ ::testing::internal::string FormatDescription(bool negation) const {\
+ const ::testing::internal::string gmock_description = (description);\
+ if (!gmock_description.empty())\
+ return gmock_description;\
+ return ::testing::internal::FormatMatcherDescription(\
+ negation, #name,\
+ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
+ ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
+ p6)));\
+ }\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename arg_type>\
+ operator ::testing::Matcher<arg_type>() const {\
+ return ::testing::Matcher<arg_type>(\
+ new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\
+ }\
+ name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
+ p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
+ p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
+ p6(gmock_p6) {\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type>\
+ inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
+ p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
+ p6##_type p6) {\
+ return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type>\
+ template <typename arg_type>\
+ bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
+ p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
+ arg_type arg,\
+ ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
+ const
+
+#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type>\
+ class name##MatcherP8 {\
+ public:\
+ template <typename arg_type>\
+ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
+ public:\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6, p7##_type gmock_p7)\
+ : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
+ p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
+ virtual bool MatchAndExplain(\
+ arg_type arg, ::testing::MatchResultListener* result_listener) const;\
+ virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(false);\
+ }\
+ virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(true);\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ p7##_type p7;\
+ private:\
+ ::testing::internal::string FormatDescription(bool negation) const {\
+ const ::testing::internal::string gmock_description = (description);\
+ if (!gmock_description.empty())\
+ return gmock_description;\
+ return ::testing::internal::FormatMatcherDescription(\
+ negation, #name,\
+ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
+ ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
+ p3, p4, p5, p6, p7)));\
+ }\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename arg_type>\
+ operator ::testing::Matcher<arg_type>() const {\
+ return ::testing::Matcher<arg_type>(\
+ new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\
+ }\
+ name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
+ p5##_type gmock_p5, p6##_type gmock_p6, \
+ p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
+ p7(gmock_p7) {\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ p7##_type p7;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type>\
+ inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
+ p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
+ p6##_type p6, p7##_type p7) {\
+ return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
+ p6, p7);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type>\
+ template <typename arg_type>\
+ bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
+ p5##_type, p6##_type, \
+ p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
+ arg_type arg,\
+ ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
+ const
+
+#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type>\
+ class name##MatcherP9 {\
+ public:\
+ template <typename arg_type>\
+ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
+ public:\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
+ : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
+ p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
+ p8(gmock_p8) {}\
+ virtual bool MatchAndExplain(\
+ arg_type arg, ::testing::MatchResultListener* result_listener) const;\
+ virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(false);\
+ }\
+ virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(true);\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ p7##_type p7;\
+ p8##_type p8;\
+ private:\
+ ::testing::internal::string FormatDescription(bool negation) const {\
+ const ::testing::internal::string gmock_description = (description);\
+ if (!gmock_description.empty())\
+ return gmock_description;\
+ return ::testing::internal::FormatMatcherDescription(\
+ negation, #name,\
+ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
+ ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type, \
+ p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
+ }\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename arg_type>\
+ operator ::testing::Matcher<arg_type>() const {\
+ return ::testing::Matcher<arg_type>(\
+ new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
+ }\
+ name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
+ p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
+ p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
+ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
+ p8(gmock_p8) {\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ p7##_type p7;\
+ p8##_type p8;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type>\
+ inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type, \
+ p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
+ p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
+ p8##_type p8) {\
+ return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
+ p3, p4, p5, p6, p7, p8);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type>\
+ template <typename arg_type>\
+ bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
+ p5##_type, p6##_type, p7##_type, \
+ p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
+ arg_type arg,\
+ ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
+ const
+
+#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type, \
+ typename p9##_type>\
+ class name##MatcherP10 {\
+ public:\
+ template <typename arg_type>\
+ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
+ public:\
+ gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
+ p9##_type gmock_p9)\
+ : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
+ p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
+ p8(gmock_p8), p9(gmock_p9) {}\
+ virtual bool MatchAndExplain(\
+ arg_type arg, ::testing::MatchResultListener* result_listener) const;\
+ virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(false);\
+ }\
+ virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(true);\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ p7##_type p7;\
+ p8##_type p8;\
+ p9##_type p9;\
+ private:\
+ ::testing::internal::string FormatDescription(bool negation) const {\
+ const ::testing::internal::string gmock_description = (description);\
+ if (!gmock_description.empty())\
+ return gmock_description;\
+ return ::testing::internal::FormatMatcherDescription(\
+ negation, #name,\
+ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
+ ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
+ p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
+ }\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename arg_type>\
+ operator ::testing::Matcher<arg_type>() const {\
+ return ::testing::Matcher<arg_type>(\
+ new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
+ }\
+ name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
+ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
+ p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
+ p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
+ p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
+ p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
+ }\
+ p0##_type p0;\
+ p1##_type p1;\
+ p2##_type p2;\
+ p3##_type p3;\
+ p4##_type p4;\
+ p5##_type p5;\
+ p6##_type p6;\
+ p7##_type p7;\
+ p8##_type p8;\
+ p9##_type p9;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
+ };\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type, \
+ typename p9##_type>\
+ inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
+ p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
+ p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
+ p9##_type p9) {\
+ return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
+ p1, p2, p3, p4, p5, p6, p7, p8, p9);\
+ }\
+ template <typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type, \
+ typename p9##_type>\
+ template <typename arg_type>\
+ bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
+ p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
+ p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
+ arg_type arg,\
+ ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
+ const
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
diff --git a/lib/gtest/include/gmock/gmock-generated-matchers.h.pump b/lib/gtest/include/gmock/gmock-generated-matchers.h.pump
new file mode 100644
index 0000000..8c09444
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-generated-matchers.h.pump
@@ -0,0 +1,651 @@
+$$ -*- mode: c++; -*-
+$$ This is a Pump source file. Please use Pump to convert it to
+$$ gmock-generated-actions.h.
+$$
+$var n = 10 $$ The maximum arity we support.
+$$ }} This line fixes auto-indentation of the following code in Emacs.
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements some commonly used variadic matchers.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
+
+#include <sstream>
+#include <string>
+#include <vector>
+#include "gmock/gmock-matchers.h"
+
+namespace testing {
+namespace internal {
+
+$range i 0..n-1
+
+// The type of the i-th (0-based) field of Tuple.
+#define GMOCK_FIELD_TYPE_(Tuple, i) \
+ typename ::std::tr1::tuple_element<i, Tuple>::type
+
+// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
+// tuple of type Tuple. It has two members:
+//
+// type: a tuple type whose i-th field is the ki-th field of Tuple.
+// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
+//
+// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
+//
+// type is tuple<int, bool>, and
+// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
+
+template <class Tuple$for i [[, int k$i = -1]]>
+class TupleFields;
+
+// This generic version is used when there are $n selectors.
+template <class Tuple$for i [[, int k$i]]>
+class TupleFields {
+ public:
+ typedef ::std::tr1::tuple<$for i, [[GMOCK_FIELD_TYPE_(Tuple, k$i)]]> type;
+ static type GetSelectedFields(const Tuple& t) {
+ using ::std::tr1::get;
+ return type($for i, [[get<k$i>(t)]]);
+ }
+};
+
+// The following specialization is used for 0 ~ $(n-1) selectors.
+
+$for i [[
+$$ }}}
+$range j 0..i-1
+$range k 0..n-1
+
+template <class Tuple$for j [[, int k$j]]>
+class TupleFields<Tuple, $for k, [[$if k < i [[k$k]] $else [[-1]]]]> {
+ public:
+ typedef ::std::tr1::tuple<$for j, [[GMOCK_FIELD_TYPE_(Tuple, k$j)]]> type;
+ static type GetSelectedFields(const Tuple& $if i==0 [[/* t */]] $else [[t]]) {
+ using ::std::tr1::get;
+ return type($for j, [[get<k$j>(t)]]);
+ }
+};
+
+]]
+
+#undef GMOCK_FIELD_TYPE_
+
+// Implements the Args() matcher.
+
+$var ks = [[$for i, [[k$i]]]]
+template <class ArgsTuple$for i [[, int k$i = -1]]>
+class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
+ public:
+ // ArgsTuple may have top-level const or reference modifiers.
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;
+ typedef typename internal::TupleFields<RawArgsTuple, $ks>::type SelectedArgs;
+ typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
+
+ template <typename InnerMatcher>
+ explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
+ : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
+
+ virtual bool MatchAndExplain(ArgsTuple args,
+ MatchResultListener* listener) const {
+ const SelectedArgs& selected_args = GetSelectedArgs(args);
+ if (!listener->IsInterested())
+ return inner_matcher_.Matches(selected_args);
+
+ PrintIndices(listener->stream());
+ *listener << "are " << PrintToString(selected_args);
+
+ StringMatchResultListener inner_listener;
+ const bool match = inner_matcher_.MatchAndExplain(selected_args,
+ &inner_listener);
+ PrintIfNotEmpty(inner_listener.str(), listener->stream());
+ return match;
+ }
+
+ virtual void DescribeTo(::std::ostream* os) const {
+ *os << "are a tuple ";
+ PrintIndices(os);
+ inner_matcher_.DescribeTo(os);
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "are a tuple ";
+ PrintIndices(os);
+ inner_matcher_.DescribeNegationTo(os);
+ }
+
+ private:
+ static SelectedArgs GetSelectedArgs(ArgsTuple args) {
+ return TupleFields<RawArgsTuple, $ks>::GetSelectedFields(args);
+ }
+
+ // Prints the indices of the selected fields.
+ static void PrintIndices(::std::ostream* os) {
+ *os << "whose fields (";
+ const int indices[$n] = { $ks };
+ for (int i = 0; i < $n; i++) {
+ if (indices[i] < 0)
+ break;
+
+ if (i >= 1)
+ *os << ", ";
+
+ *os << "#" << indices[i];
+ }
+ *os << ") ";
+ }
+
+ const MonomorphicInnerMatcher inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
+};
+
+template <class InnerMatcher$for i [[, int k$i = -1]]>
+class ArgsMatcher {
+ public:
+ explicit ArgsMatcher(const InnerMatcher& inner_matcher)
+ : inner_matcher_(inner_matcher) {}
+
+ template <typename ArgsTuple>
+ operator Matcher<ArgsTuple>() const {
+ return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, $ks>(inner_matcher_));
+ }
+
+ private:
+ const InnerMatcher inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
+};
+
+// Implements ElementsAre() of 1-$n arguments.
+
+
+$range i 1..n
+$for i [[
+$range j 1..i
+template <$for j, [[typename T$j]]>
+class ElementsAreMatcher$i {
+ public:
+ $if i==1 [[explicit ]]ElementsAreMatcher$i($for j, [[const T$j& e$j]])$if i > 0 [[ : ]]
+ $for j, [[e$j[[]]_(e$j)]] {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+$if i==1 [[
+
+ // Nokia's Symbian Compiler has a nasty bug where the object put
+ // in a one-element local array is not destructed when the array
+ // goes out of scope. This leads to obvious badness as we've
+ // added the linked_ptr in it to our other linked_ptrs list.
+ // Hence we implement ElementsAreMatcher1 specially to avoid using
+ // a local array.
+ const Matcher<const Element&> matcher =
+ MatcherCast<const Element&>(e1_);
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(&matcher, 1));
+]] $else [[
+
+ const Matcher<const Element&> matchers[] = {
+
+$for j [[
+ MatcherCast<const Element&>(e$j[[]]_),
+
+]]
+ };
+
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, $i));
+]]
+
+ }
+
+ private:
+
+$for j [[
+ const T$j& e$j[[]]_;
+
+]]
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher$i);
+};
+
+
+]]
+} // namespace internal
+
+// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
+// fields of it matches a_matcher. C++ doesn't support default
+// arguments for function templates, so we have to overload it.
+
+$range i 0..n
+$for i [[
+$range j 1..i
+template <$for j [[int k$j, ]]typename InnerMatcher>
+inline internal::ArgsMatcher<InnerMatcher$for j [[, k$j]]>
+Args(const InnerMatcher& matcher) {
+ return internal::ArgsMatcher<InnerMatcher$for j [[, k$j]]>(matcher);
+}
+
+
+]]
+// ElementsAre(e0, e1, ..., e_n) matches an STL-style container with
+// (n + 1) elements, where the i-th element in the container must
+// match the i-th argument in the list. Each argument of
+// ElementsAre() can be either a value or a matcher. We support up to
+// $n arguments.
+//
+// NOTE: Since ElementsAre() cares about the order of the elements, it
+// must not be used with containers whose elements's order is
+// undefined (e.g. hash_map).
+
+inline internal::ElementsAreMatcher0 ElementsAre() {
+ return internal::ElementsAreMatcher0();
+}
+
+$range i 1..n
+$for i [[
+$range j 1..i
+
+template <$for j, [[typename T$j]]>
+inline internal::ElementsAreMatcher$i<$for j, [[T$j]]> ElementsAre($for j, [[const T$j& e$j]]) {
+ return internal::ElementsAreMatcher$i<$for j, [[T$j]]>($for j, [[e$j]]);
+}
+
+]]
+
+// ElementsAreArray(array) and ElementAreArray(array, count) are like
+// ElementsAre(), except that they take an array of values or
+// matchers. The former form infers the size of 'array', which must
+// be a static C-style array. In the latter form, 'array' can either
+// be a static array or a pointer to a dynamically created array.
+
+template <typename T>
+inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
+ const T* first, size_t count) {
+ return internal::ElementsAreArrayMatcher<T>(first, count);
+}
+
+template <typename T, size_t N>
+inline internal::ElementsAreArrayMatcher<T>
+ElementsAreArray(const T (&array)[N]) {
+ return internal::ElementsAreArrayMatcher<T>(array, N);
+}
+
+// AllOf(m1, m2, ..., mk) matches any value that matches all of the given
+// sub-matchers. AllOf is called fully qualified to prevent ADL from firing.
+
+$range i 2..n
+$for i [[
+$range j 1..i
+$range k 1..i-1
+
+template <$for j, [[typename Matcher$j]]>
+inline $for k[[internal::BothOfMatcher<Matcher$k, ]]Matcher$i[[]]$for k [[> ]]
+
+AllOf($for j, [[Matcher$j m$j]]) {
+
+$if i == 2 [[
+ return internal::BothOfMatcher<Matcher1, Matcher2>(m1, m2);
+]] $else [[
+ return ::testing::AllOf(m1, ::testing::AllOf($for k, [[m$(k + 1)]]));
+]]
+
+}
+
+]]
+
+// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
+// sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
+
+$range i 2..n
+$for i [[
+$range j 1..i
+$range k 1..i-1
+
+template <$for j, [[typename Matcher$j]]>
+inline $for k[[internal::EitherOfMatcher<Matcher$k, ]]Matcher$i[[]]$for k [[> ]]
+
+AnyOf($for j, [[Matcher$j m$j]]) {
+
+$if i == 2 [[
+ return internal::EitherOfMatcher<Matcher1, Matcher2>(m1, m2);
+]] $else [[
+ return ::testing::AnyOf(m1, ::testing::AnyOf($for k, [[m$(k + 1)]]));
+]]
+
+}
+
+]]
+
+} // namespace testing
+$$ } // This Pump meta comment fixes auto-indentation in Emacs. It will not
+$$ // show up in the generated code.
+
+
+// The MATCHER* family of macros can be used in a namespace scope to
+// define custom matchers easily.
+//
+// Basic Usage
+// ===========
+//
+// The syntax
+//
+// MATCHER(name, description_string) { statements; }
+//
+// defines a matcher with the given name that executes the statements,
+// which must return a bool to indicate if the match succeeds. Inside
+// the statements, you can refer to the value being matched by 'arg',
+// and refer to its type by 'arg_type'.
+//
+// The description string documents what the matcher does, and is used
+// to generate the failure message when the match fails. Since a
+// MATCHER() is usually defined in a header file shared by multiple
+// C++ source files, we require the description to be a C-string
+// literal to avoid possible side effects. It can be empty, in which
+// case we'll use the sequence of words in the matcher name as the
+// description.
+//
+// For example:
+//
+// MATCHER(IsEven, "") { return (arg % 2) == 0; }
+//
+// allows you to write
+//
+// // Expects mock_foo.Bar(n) to be called where n is even.
+// EXPECT_CALL(mock_foo, Bar(IsEven()));
+//
+// or,
+//
+// // Verifies that the value of some_expression is even.
+// EXPECT_THAT(some_expression, IsEven());
+//
+// If the above assertion fails, it will print something like:
+//
+// Value of: some_expression
+// Expected: is even
+// Actual: 7
+//
+// where the description "is even" is automatically calculated from the
+// matcher name IsEven.
+//
+// Argument Type
+// =============
+//
+// Note that the type of the value being matched (arg_type) is
+// determined by the context in which you use the matcher and is
+// supplied to you by the compiler, so you don't need to worry about
+// declaring it (nor can you). This allows the matcher to be
+// polymorphic. For example, IsEven() can be used to match any type
+// where the value of "(arg % 2) == 0" can be implicitly converted to
+// a bool. In the "Bar(IsEven())" example above, if method Bar()
+// takes an int, 'arg_type' will be int; if it takes an unsigned long,
+// 'arg_type' will be unsigned long; and so on.
+//
+// Parameterizing Matchers
+// =======================
+//
+// Sometimes you'll want to parameterize the matcher. For that you
+// can use another macro:
+//
+// MATCHER_P(name, param_name, description_string) { statements; }
+//
+// For example:
+//
+// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
+//
+// will allow you to write:
+//
+// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
+//
+// which may lead to this message (assuming n is 10):
+//
+// Value of: Blah("a")
+// Expected: has absolute value 10
+// Actual: -9
+//
+// Note that both the matcher description and its parameter are
+// printed, making the message human-friendly.
+//
+// In the matcher definition body, you can write 'foo_type' to
+// reference the type of a parameter named 'foo'. For example, in the
+// body of MATCHER_P(HasAbsoluteValue, value) above, you can write
+// 'value_type' to refer to the type of 'value'.
+//
+// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P$n to
+// support multi-parameter matchers.
+//
+// Describing Parameterized Matchers
+// =================================
+//
+// The last argument to MATCHER*() is a string-typed expression. The
+// expression can reference all of the matcher's parameters and a
+// special bool-typed variable named 'negation'. When 'negation' is
+// false, the expression should evaluate to the matcher's description;
+// otherwise it should evaluate to the description of the negation of
+// the matcher. For example,
+//
+// using testing::PrintToString;
+//
+// MATCHER_P2(InClosedRange, low, hi,
+// string(negation ? "is not" : "is") + " in range [" +
+// PrintToString(low) + ", " + PrintToString(hi) + "]") {
+// return low <= arg && arg <= hi;
+// }
+// ...
+// EXPECT_THAT(3, InClosedRange(4, 6));
+// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
+//
+// would generate two failures that contain the text:
+//
+// Expected: is in range [4, 6]
+// ...
+// Expected: is not in range [2, 4]
+//
+// If you specify "" as the description, the failure message will
+// contain the sequence of words in the matcher name followed by the
+// parameter values printed as a tuple. For example,
+//
+// MATCHER_P2(InClosedRange, low, hi, "") { ... }
+// ...
+// EXPECT_THAT(3, InClosedRange(4, 6));
+// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
+//
+// would generate two failures that contain the text:
+//
+// Expected: in closed range (4, 6)
+// ...
+// Expected: not (in closed range (2, 4))
+//
+// Types of Matcher Parameters
+// ===========================
+//
+// For the purpose of typing, you can view
+//
+// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
+//
+// as shorthand for
+//
+// template <typename p1_type, ..., typename pk_type>
+// FooMatcherPk<p1_type, ..., pk_type>
+// Foo(p1_type p1, ..., pk_type pk) { ... }
+//
+// When you write Foo(v1, ..., vk), the compiler infers the types of
+// the parameters v1, ..., and vk for you. If you are not happy with
+// the result of the type inference, you can specify the types by
+// explicitly instantiating the template, as in Foo<long, bool>(5,
+// false). As said earlier, you don't get to (or need to) specify
+// 'arg_type' as that's determined by the context in which the matcher
+// is used. You can assign the result of expression Foo(p1, ..., pk)
+// to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
+// can be useful when composing matchers.
+//
+// While you can instantiate a matcher template with reference types,
+// passing the parameters by pointer usually makes your code more
+// readable. If, however, you still want to pass a parameter by
+// reference, be aware that in the failure message generated by the
+// matcher you will see the value of the referenced object but not its
+// address.
+//
+// Explaining Match Results
+// ========================
+//
+// Sometimes the matcher description alone isn't enough to explain why
+// the match has failed or succeeded. For example, when expecting a
+// long string, it can be very helpful to also print the diff between
+// the expected string and the actual one. To achieve that, you can
+// optionally stream additional information to a special variable
+// named result_listener, whose type is a pointer to class
+// MatchResultListener:
+//
+// MATCHER_P(EqualsLongString, str, "") {
+// if (arg == str) return true;
+//
+// *result_listener << "the difference: "
+/// << DiffStrings(str, arg);
+// return false;
+// }
+//
+// Overloading Matchers
+// ====================
+//
+// You can overload matchers with different numbers of parameters:
+//
+// MATCHER_P(Blah, a, description_string1) { ... }
+// MATCHER_P2(Blah, a, b, description_string2) { ... }
+//
+// Caveats
+// =======
+//
+// When defining a new matcher, you should also consider implementing
+// MatcherInterface or using MakePolymorphicMatcher(). These
+// approaches require more work than the MATCHER* macros, but also
+// give you more control on the types of the value being matched and
+// the matcher parameters, which may leads to better compiler error
+// messages when the matcher is used wrong. They also allow
+// overloading matchers based on parameter types (as opposed to just
+// based on the number of parameters).
+//
+// MATCHER*() can only be used in a namespace scope. The reason is
+// that C++ doesn't yet allow function-local types to be used to
+// instantiate templates. The up-coming C++0x standard will fix this.
+// Once that's done, we'll consider supporting using MATCHER*() inside
+// a function.
+//
+// More Information
+// ================
+//
+// To learn more about using these macros, please search for 'MATCHER'
+// on http://code.google.com/p/googlemock/wiki/CookBook.
+
+$range i 0..n
+$for i
+
+[[
+$var macro_name = [[$if i==0 [[MATCHER]] $elif i==1 [[MATCHER_P]]
+ $else [[MATCHER_P$i]]]]
+$var class_name = [[name##Matcher[[$if i==0 [[]] $elif i==1 [[P]]
+ $else [[P$i]]]]]]
+$range j 0..i-1
+$var template = [[$if i==0 [[]] $else [[
+
+ template <$for j, [[typename p$j##_type]]>\
+]]]]
+$var ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]]
+$var impl_ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]]
+$var impl_inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(gmock_p$j)]]]]]]
+$var inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(gmock_p$j)]]]]]]
+$var params = [[$for j, [[p$j]]]]
+$var param_types = [[$if i==0 [[]] $else [[<$for j, [[p$j##_type]]>]]]]
+$var param_types_and_names = [[$for j, [[p$j##_type p$j]]]]
+$var param_field_decls = [[$for j
+[[
+
+ p$j##_type p$j;\
+]]]]
+$var param_field_decls2 = [[$for j
+[[
+
+ p$j##_type p$j;\
+]]]]
+
+#define $macro_name(name$for j [[, p$j]], description)\$template
+ class $class_name {\
+ public:\
+ template <typename arg_type>\
+ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
+ public:\
+ [[$if i==1 [[explicit ]]]]gmock_Impl($impl_ctor_param_list)\
+ $impl_inits {}\
+ virtual bool MatchAndExplain(\
+ arg_type arg, ::testing::MatchResultListener* result_listener) const;\
+ virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(false);\
+ }\
+ virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ *gmock_os << FormatDescription(true);\
+ }\$param_field_decls
+ private:\
+ ::testing::internal::string FormatDescription(bool negation) const {\
+ const ::testing::internal::string gmock_description = (description);\
+ if (!gmock_description.empty())\
+ return gmock_description;\
+ return ::testing::internal::FormatMatcherDescription(\
+ negation, #name,\
+ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
+ ::std::tr1::tuple<$for j, [[p$j##_type]]>($for j, [[p$j]])));\
+ }\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
+ };\
+ template <typename arg_type>\
+ operator ::testing::Matcher<arg_type>() const {\
+ return ::testing::Matcher<arg_type>(\
+ new gmock_Impl<arg_type>($params));\
+ }\
+ $class_name($ctor_param_list)$inits {\
+ }\$param_field_decls2
+ private:\
+ GTEST_DISALLOW_ASSIGN_($class_name);\
+ };\$template
+ inline $class_name$param_types name($param_types_and_names) {\
+ return $class_name$param_types($params);\
+ }\$template
+ template <typename arg_type>\
+ bool $class_name$param_types::gmock_Impl<arg_type>::MatchAndExplain(\
+ arg_type arg,\
+ ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
+ const
+]]
+
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
diff --git a/lib/gtest/include/gmock/gmock-generated-nice-strict.h b/lib/gtest/include/gmock/gmock-generated-nice-strict.h
new file mode 100644
index 0000000..6099e81
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-generated-nice-strict.h
@@ -0,0 +1,274 @@
+// This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
+
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Implements class templates NiceMock and StrictMock.
+//
+// Given a mock class MockFoo that is created using Google Mock,
+// NiceMock<MockFoo> is a subclass of MockFoo that allows
+// uninteresting calls (i.e. calls to mock methods that have no
+// EXPECT_CALL specs), and StrictMock<MockFoo> is a subclass of
+// MockFoo that treats all uninteresting calls as errors.
+//
+// NiceMock and StrictMock "inherits" the constructors of their
+// respective base class, with up-to 10 arguments. Therefore you can
+// write NiceMock<MockFoo>(5, "a") to construct a nice mock where
+// MockFoo has a constructor that accepts (int, const char*), for
+// example.
+//
+// A known limitation is that NiceMock<MockFoo> and
+// StrictMock<MockFoo> only works for mock methods defined using the
+// MOCK_METHOD* family of macros DIRECTLY in the MockFoo class. If a
+// mock method is defined in a base class of MockFoo, the "nice" or
+// "strict" modifier may not affect it, depending on the compiler. In
+// particular, nesting NiceMock and StrictMock is NOT supported.
+//
+// Another known limitation is that the constructors of the base mock
+// cannot have arguments passed by non-const reference, which are
+// banned by the Google C++ style guide anyway.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
+
+#include "gmock/gmock-spec-builders.h"
+#include "gmock/internal/gmock-port.h"
+
+namespace testing {
+
+template <class MockClass>
+class NiceMock : public MockClass {
+ public:
+ // We don't factor out the constructor body to a common method, as
+ // we have to avoid a possible clash with members of MockClass.
+ NiceMock() {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ // C++ doesn't (yet) allow inheritance of constructors, so we have
+ // to define it for each arity.
+ template <typename A1>
+ explicit NiceMock(const A1& a1) : MockClass(a1) {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+ template <typename A1, typename A2>
+ NiceMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3>
+ NiceMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4>
+ NiceMock(const A1& a1, const A2& a2, const A3& a3,
+ const A4& a4) : MockClass(a1, a2, a3, a4) {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4, typename A5>
+ NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
+ const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6>
+ NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
+ const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6, typename A7>
+ NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
+ const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
+ a6, a7) {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6, typename A7, typename A8>
+ NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
+ const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
+ a2, a3, a4, a5, a6, a7, a8) {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6, typename A7, typename A8, typename A9>
+ NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
+ const A5& a5, const A6& a6, const A7& a7, const A8& a8,
+ const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6, typename A7, typename A8, typename A9, typename A10>
+ NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
+ const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
+ const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ virtual ~NiceMock() {
+ ::testing::Mock::UnregisterCallReaction(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock);
+};
+
+template <class MockClass>
+class StrictMock : public MockClass {
+ public:
+ // We don't factor out the constructor body to a common method, as
+ // we have to avoid a possible clash with members of MockClass.
+ StrictMock() {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1>
+ explicit StrictMock(const A1& a1) : MockClass(a1) {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+ template <typename A1, typename A2>
+ StrictMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3>
+ StrictMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4>
+ StrictMock(const A1& a1, const A2& a2, const A3& a3,
+ const A4& a4) : MockClass(a1, a2, a3, a4) {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4, typename A5>
+ StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
+ const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6>
+ StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
+ const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6, typename A7>
+ StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
+ const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
+ a6, a7) {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6, typename A7, typename A8>
+ StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
+ const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
+ a2, a3, a4, a5, a6, a7, a8) {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6, typename A7, typename A8, typename A9>
+ StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
+ const A5& a5, const A6& a6, const A7& a7, const A8& a8,
+ const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6, typename A7, typename A8, typename A9, typename A10>
+ StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
+ const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
+ const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ virtual ~StrictMock() {
+ ::testing::Mock::UnregisterCallReaction(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock);
+};
+
+// The following specializations catch some (relatively more common)
+// user errors of nesting nice and strict mocks. They do NOT catch
+// all possible errors.
+
+// These specializations are declared but not defined, as NiceMock and
+// StrictMock cannot be nested.
+template <typename MockClass>
+class NiceMock<NiceMock<MockClass> >;
+template <typename MockClass>
+class NiceMock<StrictMock<MockClass> >;
+template <typename MockClass>
+class StrictMock<NiceMock<MockClass> >;
+template <typename MockClass>
+class StrictMock<StrictMock<MockClass> >;
+
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
diff --git a/lib/gtest/include/gmock/gmock-generated-nice-strict.h.pump b/lib/gtest/include/gmock/gmock-generated-nice-strict.h.pump
new file mode 100644
index 0000000..b7964db
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-generated-nice-strict.h.pump
@@ -0,0 +1,160 @@
+$$ -*- mode: c++; -*-
+$$ This is a Pump source file. Please use Pump to convert it to
+$$ gmock-generated-nice-strict.h.
+$$
+$var n = 10 $$ The maximum arity we support.
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Implements class templates NiceMock and StrictMock.
+//
+// Given a mock class MockFoo that is created using Google Mock,
+// NiceMock<MockFoo> is a subclass of MockFoo that allows
+// uninteresting calls (i.e. calls to mock methods that have no
+// EXPECT_CALL specs), and StrictMock<MockFoo> is a subclass of
+// MockFoo that treats all uninteresting calls as errors.
+//
+// NiceMock and StrictMock "inherits" the constructors of their
+// respective base class, with up-to $n arguments. Therefore you can
+// write NiceMock<MockFoo>(5, "a") to construct a nice mock where
+// MockFoo has a constructor that accepts (int, const char*), for
+// example.
+//
+// A known limitation is that NiceMock<MockFoo> and
+// StrictMock<MockFoo> only works for mock methods defined using the
+// MOCK_METHOD* family of macros DIRECTLY in the MockFoo class. If a
+// mock method is defined in a base class of MockFoo, the "nice" or
+// "strict" modifier may not affect it, depending on the compiler. In
+// particular, nesting NiceMock and StrictMock is NOT supported.
+//
+// Another known limitation is that the constructors of the base mock
+// cannot have arguments passed by non-const reference, which are
+// banned by the Google C++ style guide anyway.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
+
+#include "gmock/gmock-spec-builders.h"
+#include "gmock/internal/gmock-port.h"
+
+namespace testing {
+
+template <class MockClass>
+class NiceMock : public MockClass {
+ public:
+ // We don't factor out the constructor body to a common method, as
+ // we have to avoid a possible clash with members of MockClass.
+ NiceMock() {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ // C++ doesn't (yet) allow inheritance of constructors, so we have
+ // to define it for each arity.
+ template <typename A1>
+ explicit NiceMock(const A1& a1) : MockClass(a1) {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+$range i 2..n
+$for i [[
+$range j 1..i
+ template <$for j, [[typename A$j]]>
+ NiceMock($for j, [[const A$j& a$j]]) : MockClass($for j, [[a$j]]) {
+ ::testing::Mock::AllowUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+
+]]
+ virtual ~NiceMock() {
+ ::testing::Mock::UnregisterCallReaction(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock);
+};
+
+template <class MockClass>
+class StrictMock : public MockClass {
+ public:
+ // We don't factor out the constructor body to a common method, as
+ // we have to avoid a possible clash with members of MockClass.
+ StrictMock() {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ template <typename A1>
+ explicit StrictMock(const A1& a1) : MockClass(a1) {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+$for i [[
+$range j 1..i
+ template <$for j, [[typename A$j]]>
+ StrictMock($for j, [[const A$j& a$j]]) : MockClass($for j, [[a$j]]) {
+ ::testing::Mock::FailUninterestingCalls(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+
+]]
+ virtual ~StrictMock() {
+ ::testing::Mock::UnregisterCallReaction(
+ internal::ImplicitCast_<MockClass*>(this));
+ }
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock);
+};
+
+// The following specializations catch some (relatively more common)
+// user errors of nesting nice and strict mocks. They do NOT catch
+// all possible errors.
+
+// These specializations are declared but not defined, as NiceMock and
+// StrictMock cannot be nested.
+template <typename MockClass>
+class NiceMock<NiceMock<MockClass> >;
+template <typename MockClass>
+class NiceMock<StrictMock<MockClass> >;
+template <typename MockClass>
+class StrictMock<NiceMock<MockClass> >;
+template <typename MockClass>
+class StrictMock<StrictMock<MockClass> >;
+
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
diff --git a/lib/gtest/include/gmock/gmock-matchers.h b/lib/gtest/include/gmock/gmock-matchers.h
new file mode 100644
index 0000000..c21fa51
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-matchers.h
@@ -0,0 +1,3066 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements some commonly used argument matchers. More
+// matchers can be defined by the user implementing the
+// MatcherInterface<T> interface if necessary.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
+
+#include <algorithm>
+#include <limits>
+#include <ostream> // NOLINT
+#include <sstream>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "gmock/internal/gmock-internal-utils.h"
+#include "gmock/internal/gmock-port.h"
+#include "gtest/gtest.h"
+
+namespace testing {
+
+// To implement a matcher Foo for type T, define:
+// 1. a class FooMatcherImpl that implements the
+// MatcherInterface<T> interface, and
+// 2. a factory function that creates a Matcher<T> object from a
+// FooMatcherImpl*.
+//
+// The two-level delegation design makes it possible to allow a user
+// to write "v" instead of "Eq(v)" where a Matcher is expected, which
+// is impossible if we pass matchers by pointers. It also eases
+// ownership management as Matcher objects can now be copied like
+// plain values.
+
+// MatchResultListener is an abstract class. Its << operator can be
+// used by a matcher to explain why a value matches or doesn't match.
+//
+// TODO(wan@google.com): add method
+// bool InterestedInWhy(bool result) const;
+// to indicate whether the listener is interested in why the match
+// result is 'result'.
+class MatchResultListener {
+ public:
+ // Creates a listener object with the given underlying ostream. The
+ // listener does not own the ostream.
+ explicit MatchResultListener(::std::ostream* os) : stream_(os) {}
+ virtual ~MatchResultListener() = 0; // Makes this class abstract.
+
+ // Streams x to the underlying ostream; does nothing if the ostream
+ // is NULL.
+ template <typename T>
+ MatchResultListener& operator<<(const T& x) {
+ if (stream_ != NULL)
+ *stream_ << x;
+ return *this;
+ }
+
+ // Returns the underlying ostream.
+ ::std::ostream* stream() { return stream_; }
+
+ // Returns true iff the listener is interested in an explanation of
+ // the match result. A matcher's MatchAndExplain() method can use
+ // this information to avoid generating the explanation when no one
+ // intends to hear it.
+ bool IsInterested() const { return stream_ != NULL; }
+
+ private:
+ ::std::ostream* const stream_;
+
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener);
+};
+
+inline MatchResultListener::~MatchResultListener() {
+}
+
+// The implementation of a matcher.
+template <typename T>
+class MatcherInterface {
+ public:
+ virtual ~MatcherInterface() {}
+
+ // Returns true iff the matcher matches x; also explains the match
+ // result to 'listener', in the form of a non-restrictive relative
+ // clause ("which ...", "whose ...", etc) that describes x. For
+ // example, the MatchAndExplain() method of the Pointee(...) matcher
+ // should generate an explanation like "which points to ...".
+ //
+ // You should override this method when defining a new matcher.
+ //
+ // It's the responsibility of the caller (Google Mock) to guarantee
+ // that 'listener' is not NULL. This helps to simplify a matcher's
+ // implementation when it doesn't care about the performance, as it
+ // can talk to 'listener' without checking its validity first.
+ // However, in order to implement dummy listeners efficiently,
+ // listener->stream() may be NULL.
+ virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;
+
+ // Describes this matcher to an ostream. The function should print
+ // a verb phrase that describes the property a value matching this
+ // matcher should have. The subject of the verb phrase is the value
+ // being matched. For example, the DescribeTo() method of the Gt(7)
+ // matcher prints "is greater than 7".
+ virtual void DescribeTo(::std::ostream* os) const = 0;
+
+ // Describes the negation of this matcher to an ostream. For
+ // example, if the description of this matcher is "is greater than
+ // 7", the negated description could be "is not greater than 7".
+ // You are not required to override this when implementing
+ // MatcherInterface, but it is highly advised so that your matcher
+ // can produce good error messages.
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "not (";
+ DescribeTo(os);
+ *os << ")";
+ }
+};
+
+namespace internal {
+
+// A match result listener that ignores the explanation.
+class DummyMatchResultListener : public MatchResultListener {
+ public:
+ DummyMatchResultListener() : MatchResultListener(NULL) {}
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener);
+};
+
+// A match result listener that forwards the explanation to a given
+// ostream. The difference between this and MatchResultListener is
+// that the former is concrete.
+class StreamMatchResultListener : public MatchResultListener {
+ public:
+ explicit StreamMatchResultListener(::std::ostream* os)
+ : MatchResultListener(os) {}
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener);
+};
+
+// A match result listener that stores the explanation in a string.
+class StringMatchResultListener : public MatchResultListener {
+ public:
+ StringMatchResultListener() : MatchResultListener(&ss_) {}
+
+ // Returns the explanation heard so far.
+ internal::string str() const { return ss_.str(); }
+
+ private:
+ ::std::stringstream ss_;
+
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(StringMatchResultListener);
+};
+
+// An internal class for implementing Matcher<T>, which will derive
+// from it. We put functionalities common to all Matcher<T>
+// specializations here to avoid code duplication.
+template <typename T>
+class MatcherBase {
+ public:
+ // Returns true iff the matcher matches x; also explains the match
+ // result to 'listener'.
+ bool MatchAndExplain(T x, MatchResultListener* listener) const {
+ return impl_->MatchAndExplain(x, listener);
+ }
+
+ // Returns true iff this matcher matches x.
+ bool Matches(T x) const {
+ DummyMatchResultListener dummy;
+ return MatchAndExplain(x, &dummy);
+ }
+
+ // Describes this matcher to an ostream.
+ void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }
+
+ // Describes the negation of this matcher to an ostream.
+ void DescribeNegationTo(::std::ostream* os) const {
+ impl_->DescribeNegationTo(os);
+ }
+
+ // Explains why x matches, or doesn't match, the matcher.
+ void ExplainMatchResultTo(T x, ::std::ostream* os) const {
+ StreamMatchResultListener listener(os);
+ MatchAndExplain(x, &listener);
+ }
+
+ protected:
+ MatcherBase() {}
+
+ // Constructs a matcher from its implementation.
+ explicit MatcherBase(const MatcherInterface<T>* impl)
+ : impl_(impl) {}
+
+ virtual ~MatcherBase() {}
+
+ private:
+ // shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar
+ // interfaces. The former dynamically allocates a chunk of memory
+ // to hold the reference count, while the latter tracks all
+ // references using a circular linked list without allocating
+ // memory. It has been observed that linked_ptr performs better in
+ // typical scenarios. However, shared_ptr can out-perform
+ // linked_ptr when there are many more uses of the copy constructor
+ // than the default constructor.
+ //
+ // If performance becomes a problem, we should see if using
+ // shared_ptr helps.
+ ::testing::internal::linked_ptr<const MatcherInterface<T> > impl_;
+};
+
+} // namespace internal
+
+// A Matcher<T> is a copyable and IMMUTABLE (except by assignment)
+// object that can check whether a value of type T matches. The
+// implementation of Matcher<T> is just a linked_ptr to const
+// MatcherInterface<T>, so copying is fairly cheap. Don't inherit
+// from Matcher!
+template <typename T>
+class Matcher : public internal::MatcherBase<T> {
+ public:
+ // Constructs a null matcher. Needed for storing Matcher objects in STL
+ // containers. A default-constructed matcher is not yet initialized. You
+ // cannot use it until a valid value has been assigned to it.
+ Matcher() {}
+
+ // Constructs a matcher from its implementation.
+ explicit Matcher(const MatcherInterface<T>* impl)
+ : internal::MatcherBase<T>(impl) {}
+
+ // Implicit constructor here allows people to write
+ // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes
+ Matcher(T value); // NOLINT
+};
+
+// The following two specializations allow the user to write str
+// instead of Eq(str) and "foo" instead of Eq("foo") when a string
+// matcher is expected.
+template <>
+class Matcher<const internal::string&>
+ : public internal::MatcherBase<const internal::string&> {
+ public:
+ Matcher() {}
+
+ explicit Matcher(const MatcherInterface<const internal::string&>* impl)
+ : internal::MatcherBase<const internal::string&>(impl) {}
+
+ // Allows the user to write str instead of Eq(str) sometimes, where
+ // str is a string object.
+ Matcher(const internal::string& s); // NOLINT
+
+ // Allows the user to write "foo" instead of Eq("foo") sometimes.
+ Matcher(const char* s); // NOLINT
+};
+
+template <>
+class Matcher<internal::string>
+ : public internal::MatcherBase<internal::string> {
+ public:
+ Matcher() {}
+
+ explicit Matcher(const MatcherInterface<internal::string>* impl)
+ : internal::MatcherBase<internal::string>(impl) {}
+
+ // Allows the user to write str instead of Eq(str) sometimes, where
+ // str is a string object.
+ Matcher(const internal::string& s); // NOLINT
+
+ // Allows the user to write "foo" instead of Eq("foo") sometimes.
+ Matcher(const char* s); // NOLINT
+};
+
+// The PolymorphicMatcher class template makes it easy to implement a
+// polymorphic matcher (i.e. a matcher that can match values of more
+// than one type, e.g. Eq(n) and NotNull()).
+//
+// To define a polymorphic matcher, a user should provide an Impl
+// class that has a DescribeTo() method and a DescribeNegationTo()
+// method, and define a member function (or member function template)
+//
+// bool MatchAndExplain(const Value& value,
+// MatchResultListener* listener) const;
+//
+// See the definition of NotNull() for a complete example.
+template <class Impl>
+class PolymorphicMatcher {
+ public:
+ explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {}
+
+ // Returns a mutable reference to the underlying matcher
+ // implementation object.
+ Impl& mutable_impl() { return impl_; }
+
+ // Returns an immutable reference to the underlying matcher
+ // implementation object.
+ const Impl& impl() const { return impl_; }
+
+ template <typename T>
+ operator Matcher<T>() const {
+ return Matcher<T>(new MonomorphicImpl<T>(impl_));
+ }
+
+ private:
+ template <typename T>
+ class MonomorphicImpl : public MatcherInterface<T> {
+ public:
+ explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
+
+ virtual void DescribeTo(::std::ostream* os) const {
+ impl_.DescribeTo(os);
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ impl_.DescribeNegationTo(os);
+ }
+
+ virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
+ return impl_.MatchAndExplain(x, listener);
+ }
+
+ private:
+ const Impl impl_;
+
+ GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
+ };
+
+ Impl impl_;
+
+ GTEST_DISALLOW_ASSIGN_(PolymorphicMatcher);
+};
+
+// Creates a matcher from its implementation. This is easier to use
+// than the Matcher<T> constructor as it doesn't require you to
+// explicitly write the template argument, e.g.
+//
+// MakeMatcher(foo);
+// vs
+// Matcher<const string&>(foo);
+template <typename T>
+inline Matcher<T> MakeMatcher(const MatcherInterface<T>* impl) {
+ return Matcher<T>(impl);
+};
+
+// Creates a polymorphic matcher from its implementation. This is
+// easier to use than the PolymorphicMatcher<Impl> constructor as it
+// doesn't require you to explicitly write the template argument, e.g.
+//
+// MakePolymorphicMatcher(foo);
+// vs
+// PolymorphicMatcher<TypeOfFoo>(foo);
+template <class Impl>
+inline PolymorphicMatcher<Impl> MakePolymorphicMatcher(const Impl& impl) {
+ return PolymorphicMatcher<Impl>(impl);
+}
+
+// In order to be safe and clear, casting between different matcher
+// types is done explicitly via MatcherCast<T>(m), which takes a
+// matcher m and returns a Matcher<T>. It compiles only when T can be
+// statically converted to the argument type of m.
+template <typename T, typename M>
+Matcher<T> MatcherCast(M m);
+
+// Implements SafeMatcherCast().
+//
+// We use an intermediate class to do the actual safe casting as Nokia's
+// Symbian compiler cannot decide between
+// template <T, M> ... (M) and
+// template <T, U> ... (const Matcher<U>&)
+// for function templates but can for member function templates.
+template <typename T>
+class SafeMatcherCastImpl {
+ public:
+ // This overload handles polymorphic matchers only since monomorphic
+ // matchers are handled by the next one.
+ template <typename M>
+ static inline Matcher<T> Cast(M polymorphic_matcher) {
+ return Matcher<T>(polymorphic_matcher);
+ }
+
+ // This overload handles monomorphic matchers.
+ //
+ // In general, if type T can be implicitly converted to type U, we can
+ // safely convert a Matcher<U> to a Matcher<T> (i.e. Matcher is
+ // contravariant): just keep a copy of the original Matcher<U>, convert the
+ // argument from type T to U, and then pass it to the underlying Matcher<U>.
+ // The only exception is when U is a reference and T is not, as the
+ // underlying Matcher<U> may be interested in the argument's address, which
+ // is not preserved in the conversion from T to U.
+ template <typename U>
+ static inline Matcher<T> Cast(const Matcher<U>& matcher) {
+ // Enforce that T can be implicitly converted to U.
+ GTEST_COMPILE_ASSERT_((internal::ImplicitlyConvertible<T, U>::value),
+ T_must_be_implicitly_convertible_to_U);
+ // Enforce that we are not converting a non-reference type T to a reference
+ // type U.
+ GTEST_COMPILE_ASSERT_(
+ internal::is_reference<T>::value || !internal::is_reference<U>::value,
+ cannot_convert_non_referentce_arg_to_reference);
+ // In case both T and U are arithmetic types, enforce that the
+ // conversion is not lossy.
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(T) RawT;
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(U) RawU;
+ const bool kTIsOther = GMOCK_KIND_OF_(RawT) == internal::kOther;
+ const bool kUIsOther = GMOCK_KIND_OF_(RawU) == internal::kOther;
+ GTEST_COMPILE_ASSERT_(
+ kTIsOther || kUIsOther ||
+ (internal::LosslessArithmeticConvertible<RawT, RawU>::value),
+ conversion_of_arithmetic_types_must_be_lossless);
+ return MatcherCast<T>(matcher);
+ }
+};
+
+template <typename T, typename M>
+inline Matcher<T> SafeMatcherCast(const M& polymorphic_matcher) {
+ return SafeMatcherCastImpl<T>::Cast(polymorphic_matcher);
+}
+
+// A<T>() returns a matcher that matches any value of type T.
+template <typename T>
+Matcher<T> A();
+
+// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
+// and MUST NOT BE USED IN USER CODE!!!
+namespace internal {
+
+// If the explanation is not empty, prints it to the ostream.
+inline void PrintIfNotEmpty(const internal::string& explanation,
+ std::ostream* os) {
+ if (explanation != "" && os != NULL) {
+ *os << ", " << explanation;
+ }
+}
+
+// Returns true if the given type name is easy to read by a human.
+// This is used to decide whether printing the type of a value might
+// be helpful.
+inline bool IsReadableTypeName(const string& type_name) {
+ // We consider a type name readable if it's short or doesn't contain
+ // a template or function type.
+ return (type_name.length() <= 20 ||
+ type_name.find_first_of("<(") == string::npos);
+}
+
+// Matches the value against the given matcher, prints the value and explains
+// the match result to the listener. Returns the match result.
+// 'listener' must not be NULL.
+// Value cannot be passed by const reference, because some matchers take a
+// non-const argument.
+template <typename Value, typename T>
+bool MatchPrintAndExplain(Value& value, const Matcher<T>& matcher,
+ MatchResultListener* listener) {
+ if (!listener->IsInterested()) {
+ // If the listener is not interested, we do not need to construct the
+ // inner explanation.
+ return matcher.Matches(value);
+ }
+
+ StringMatchResultListener inner_listener;
+ const bool match = matcher.MatchAndExplain(value, &inner_listener);
+
+ UniversalPrint(value, listener->stream());
+#if GTEST_HAS_RTTI
+ const string& type_name = GetTypeName<Value>();
+ if (IsReadableTypeName(type_name))
+ *listener->stream() << " (of type " << type_name << ")";
+#endif
+ PrintIfNotEmpty(inner_listener.str(), listener->stream());
+
+ return match;
+}
+
+// An internal helper class for doing compile-time loop on a tuple's
+// fields.
+template <size_t N>
+class TuplePrefix {
+ public:
+ // TuplePrefix<N>::Matches(matcher_tuple, value_tuple) returns true
+ // iff the first N fields of matcher_tuple matches the first N
+ // fields of value_tuple, respectively.
+ template <typename MatcherTuple, typename ValueTuple>
+ static bool Matches(const MatcherTuple& matcher_tuple,
+ const ValueTuple& value_tuple) {
+ using ::std::tr1::get;
+ return TuplePrefix<N - 1>::Matches(matcher_tuple, value_tuple)
+ && get<N - 1>(matcher_tuple).Matches(get<N - 1>(value_tuple));
+ }
+
+ // TuplePrefix<N>::ExplainMatchFailuresTo(matchers, values, os)
+ // describes failures in matching the first N fields of matchers
+ // against the first N fields of values. If there is no failure,
+ // nothing will be streamed to os.
+ template <typename MatcherTuple, typename ValueTuple>
+ static void ExplainMatchFailuresTo(const MatcherTuple& matchers,
+ const ValueTuple& values,
+ ::std::ostream* os) {
+ using ::std::tr1::tuple_element;
+ using ::std::tr1::get;
+
+ // First, describes failures in the first N - 1 fields.
+ TuplePrefix<N - 1>::ExplainMatchFailuresTo(matchers, values, os);
+
+ // Then describes the failure (if any) in the (N - 1)-th (0-based)
+ // field.
+ typename tuple_element<N - 1, MatcherTuple>::type matcher =
+ get<N - 1>(matchers);
+ typedef typename tuple_element<N - 1, ValueTuple>::type Value;
+ Value value = get<N - 1>(values);
+ StringMatchResultListener listener;
+ if (!matcher.MatchAndExplain(value, &listener)) {
+ // TODO(wan): include in the message the name of the parameter
+ // as used in MOCK_METHOD*() when possible.
+ *os << " Expected arg #" << N - 1 << ": ";
+ get<N - 1>(matchers).DescribeTo(os);
+ *os << "\n Actual: ";
+ // We remove the reference in type Value to prevent the
+ // universal printer from printing the address of value, which
+ // isn't interesting to the user most of the time. The
+ // matcher's MatchAndExplain() method handles the case when
+ // the address is interesting.
+ internal::UniversalPrint(value, os);
+ PrintIfNotEmpty(listener.str(), os);
+ *os << "\n";
+ }
+ }
+};
+
+// The base case.
+template <>
+class TuplePrefix<0> {
+ public:
+ template <typename MatcherTuple, typename ValueTuple>
+ static bool Matches(const MatcherTuple& /* matcher_tuple */,
+ const ValueTuple& /* value_tuple */) {
+ return true;
+ }
+
+ template <typename MatcherTuple, typename ValueTuple>
+ static void ExplainMatchFailuresTo(const MatcherTuple& /* matchers */,
+ const ValueTuple& /* values */,
+ ::std::ostream* /* os */) {}
+};
+
+// TupleMatches(matcher_tuple, value_tuple) returns true iff all
+// matchers in matcher_tuple match the corresponding fields in
+// value_tuple. It is a compiler error if matcher_tuple and
+// value_tuple have different number of fields or incompatible field
+// types.
+template <typename MatcherTuple, typename ValueTuple>
+bool TupleMatches(const MatcherTuple& matcher_tuple,
+ const ValueTuple& value_tuple) {
+ using ::std::tr1::tuple_size;
+ // Makes sure that matcher_tuple and value_tuple have the same
+ // number of fields.
+ GTEST_COMPILE_ASSERT_(tuple_size<MatcherTuple>::value ==
+ tuple_size<ValueTuple>::value,
+ matcher_and_value_have_different_numbers_of_fields);
+ return TuplePrefix<tuple_size<ValueTuple>::value>::
+ Matches(matcher_tuple, value_tuple);
+}
+
+// Describes failures in matching matchers against values. If there
+// is no failure, nothing will be streamed to os.
+template <typename MatcherTuple, typename ValueTuple>
+void ExplainMatchFailureTupleTo(const MatcherTuple& matchers,
+ const ValueTuple& values,
+ ::std::ostream* os) {
+ using ::std::tr1::tuple_size;
+ TuplePrefix<tuple_size<MatcherTuple>::value>::ExplainMatchFailuresTo(
+ matchers, values, os);
+}
+
+// The MatcherCastImpl class template is a helper for implementing
+// MatcherCast(). We need this helper in order to partially
+// specialize the implementation of MatcherCast() (C++ allows
+// class/struct templates to be partially specialized, but not
+// function templates.).
+
+// This general version is used when MatcherCast()'s argument is a
+// polymorphic matcher (i.e. something that can be converted to a
+// Matcher but is not one yet; for example, Eq(value)).
+template <typename T, typename M>
+class MatcherCastImpl {
+ public:
+ static Matcher<T> Cast(M polymorphic_matcher) {
+ return Matcher<T>(polymorphic_matcher);
+ }
+};
+
+// This more specialized version is used when MatcherCast()'s argument
+// is already a Matcher. This only compiles when type T can be
+// statically converted to type U.
+template <typename T, typename U>
+class MatcherCastImpl<T, Matcher<U> > {
+ public:
+ static Matcher<T> Cast(const Matcher<U>& source_matcher) {
+ return Matcher<T>(new Impl(source_matcher));
+ }
+
+ private:
+ class Impl : public MatcherInterface<T> {
+ public:
+ explicit Impl(const Matcher<U>& source_matcher)
+ : source_matcher_(source_matcher) {}
+
+ // We delegate the matching logic to the source matcher.
+ virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
+ return source_matcher_.MatchAndExplain(static_cast<U>(x), listener);
+ }
+
+ virtual void DescribeTo(::std::ostream* os) const {
+ source_matcher_.DescribeTo(os);
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ source_matcher_.DescribeNegationTo(os);
+ }
+
+ private:
+ const Matcher<U> source_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
+ };
+};
+
+// This even more specialized version is used for efficiently casting
+// a matcher to its own type.
+template <typename T>
+class MatcherCastImpl<T, Matcher<T> > {
+ public:
+ static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; }
+};
+
+// Implements A<T>().
+template <typename T>
+class AnyMatcherImpl : public MatcherInterface<T> {
+ public:
+ virtual bool MatchAndExplain(
+ T /* x */, MatchResultListener* /* listener */) const { return true; }
+ virtual void DescribeTo(::std::ostream* os) const { *os << "is anything"; }
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ // This is mostly for completeness' safe, as it's not very useful
+ // to write Not(A<bool>()). However we cannot completely rule out
+ // such a possibility, and it doesn't hurt to be prepared.
+ *os << "never matches";
+ }
+};
+
+// Implements _, a matcher that matches any value of any
+// type. This is a polymorphic matcher, so we need a template type
+// conversion operator to make it appearing as a Matcher<T> for any
+// type T.
+class AnythingMatcher {
+ public:
+ template <typename T>
+ operator Matcher<T>() const { return A<T>(); }
+};
+
+// Implements a matcher that compares a given value with a
+// pre-supplied value using one of the ==, <=, <, etc, operators. The
+// two values being compared don't have to have the same type.
+//
+// The matcher defined here is polymorphic (for example, Eq(5) can be
+// used to match an int, a short, a double, etc). Therefore we use
+// a template type conversion operator in the implementation.
+//
+// We define this as a macro in order to eliminate duplicated source
+// code.
+//
+// The following template definition assumes that the Rhs parameter is
+// a "bare" type (i.e. neither 'const T' nor 'T&').
+#define GMOCK_IMPLEMENT_COMPARISON_MATCHER_( \
+ name, op, relation, negated_relation) \
+ template <typename Rhs> class name##Matcher { \
+ public: \
+ explicit name##Matcher(const Rhs& rhs) : rhs_(rhs) {} \
+ template <typename Lhs> \
+ operator Matcher<Lhs>() const { \
+ return MakeMatcher(new Impl<Lhs>(rhs_)); \
+ } \
+ private: \
+ template <typename Lhs> \
+ class Impl : public MatcherInterface<Lhs> { \
+ public: \
+ explicit Impl(const Rhs& rhs) : rhs_(rhs) {} \
+ virtual bool MatchAndExplain(\
+ Lhs lhs, MatchResultListener* /* listener */) const { \
+ return lhs op rhs_; \
+ } \
+ virtual void DescribeTo(::std::ostream* os) const { \
+ *os << relation " "; \
+ UniversalPrint(rhs_, os); \
+ } \
+ virtual void DescribeNegationTo(::std::ostream* os) const { \
+ *os << negated_relation " "; \
+ UniversalPrint(rhs_, os); \
+ } \
+ private: \
+ Rhs rhs_; \
+ GTEST_DISALLOW_ASSIGN_(Impl); \
+ }; \
+ Rhs rhs_; \
+ GTEST_DISALLOW_ASSIGN_(name##Matcher); \
+ }
+
+// Implements Eq(v), Ge(v), Gt(v), Le(v), Lt(v), and Ne(v)
+// respectively.
+GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Eq, ==, "is equal to", "isn't equal to");
+GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ge, >=, "is >=", "isn't >=");
+GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Gt, >, "is >", "isn't >");
+GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Le, <=, "is <=", "isn't <=");
+GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Lt, <, "is <", "isn't <");
+GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ne, !=, "isn't equal to", "is equal to");
+
+#undef GMOCK_IMPLEMENT_COMPARISON_MATCHER_
+
+// Implements the polymorphic IsNull() matcher, which matches any raw or smart
+// pointer that is NULL.
+class IsNullMatcher {
+ public:
+ template <typename Pointer>
+ bool MatchAndExplain(const Pointer& p,
+ MatchResultListener* /* listener */) const {
+ return GetRawPointer(p) == NULL;
+ }
+
+ void DescribeTo(::std::ostream* os) const { *os << "is NULL"; }
+ void DescribeNegationTo(::std::ostream* os) const {
+ *os << "isn't NULL";
+ }
+};
+
+// Implements the polymorphic NotNull() matcher, which matches any raw or smart
+// pointer that is not NULL.
+class NotNullMatcher {
+ public:
+ template <typename Pointer>
+ bool MatchAndExplain(const Pointer& p,
+ MatchResultListener* /* listener */) const {
+ return GetRawPointer(p) != NULL;
+ }
+
+ void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; }
+ void DescribeNegationTo(::std::ostream* os) const {
+ *os << "is NULL";
+ }
+};
+
+// Ref(variable) matches any argument that is a reference to
+// 'variable'. This matcher is polymorphic as it can match any
+// super type of the type of 'variable'.
+//
+// The RefMatcher template class implements Ref(variable). It can
+// only be instantiated with a reference type. This prevents a user
+// from mistakenly using Ref(x) to match a non-reference function
+// argument. For example, the following will righteously cause a
+// compiler error:
+//
+// int n;
+// Matcher<int> m1 = Ref(n); // This won't compile.
+// Matcher<int&> m2 = Ref(n); // This will compile.
+template <typename T>
+class RefMatcher;
+
+template <typename T>
+class RefMatcher<T&> {
+ // Google Mock is a generic framework and thus needs to support
+ // mocking any function types, including those that take non-const
+ // reference arguments. Therefore the template parameter T (and
+ // Super below) can be instantiated to either a const type or a
+ // non-const type.
+ public:
+ // RefMatcher() takes a T& instead of const T&, as we want the
+ // compiler to catch using Ref(const_value) as a matcher for a
+ // non-const reference.
+ explicit RefMatcher(T& x) : object_(x) {} // NOLINT
+
+ template <typename Super>
+ operator Matcher<Super&>() const {
+ // By passing object_ (type T&) to Impl(), which expects a Super&,
+ // we make sure that Super is a super type of T. In particular,
+ // this catches using Ref(const_value) as a matcher for a
+ // non-const reference, as you cannot implicitly convert a const
+ // reference to a non-const reference.
+ return MakeMatcher(new Impl<Super>(object_));
+ }
+
+ private:
+ template <typename Super>
+ class Impl : public MatcherInterface<Super&> {
+ public:
+ explicit Impl(Super& x) : object_(x) {} // NOLINT
+
+ // MatchAndExplain() takes a Super& (as opposed to const Super&)
+ // in order to match the interface MatcherInterface<Super&>.
+ virtual bool MatchAndExplain(
+ Super& x, MatchResultListener* listener) const {
+ *listener << "which is located @" << static_cast<const void*>(&x);
+ return &x == &object_;
+ }
+
+ virtual void DescribeTo(::std::ostream* os) const {
+ *os << "references the variable ";
+ UniversalPrinter<Super&>::Print(object_, os);
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "does not reference the variable ";
+ UniversalPrinter<Super&>::Print(object_, os);
+ }
+
+ private:
+ const Super& object_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
+ };
+
+ T& object_;
+
+ GTEST_DISALLOW_ASSIGN_(RefMatcher);
+};
+
+// Polymorphic helper functions for narrow and wide string matchers.
+inline bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs) {
+ return String::CaseInsensitiveCStringEquals(lhs, rhs);
+}
+
+inline bool CaseInsensitiveCStringEquals(const wchar_t* lhs,
+ const wchar_t* rhs) {
+ return String::CaseInsensitiveWideCStringEquals(lhs, rhs);
+}
+
+// String comparison for narrow or wide strings that can have embedded NUL
+// characters.
+template <typename StringType>
+bool CaseInsensitiveStringEquals(const StringType& s1,
+ const StringType& s2) {
+ // Are the heads equal?
+ if (!CaseInsensitiveCStringEquals(s1.c_str(), s2.c_str())) {
+ return false;
+ }
+
+ // Skip the equal heads.
+ const typename StringType::value_type nul = 0;
+ const size_t i1 = s1.find(nul), i2 = s2.find(nul);
+
+ // Are we at the end of either s1 or s2?
+ if (i1 == StringType::npos || i2 == StringType::npos) {
+ return i1 == i2;
+ }
+
+ // Are the tails equal?
+ return CaseInsensitiveStringEquals(s1.substr(i1 + 1), s2.substr(i2 + 1));
+}
+
+// String matchers.
+
+// Implements equality-based string matchers like StrEq, StrCaseNe, and etc.
+template <typename StringType>
+class StrEqualityMatcher {
+ public:
+ typedef typename StringType::const_pointer ConstCharPointer;
+
+ StrEqualityMatcher(const StringType& str, bool expect_eq,
+ bool case_sensitive)
+ : string_(str), expect_eq_(expect_eq), case_sensitive_(case_sensitive) {}
+
+ // When expect_eq_ is true, returns true iff s is equal to string_;
+ // otherwise returns true iff s is not equal to string_.
+ bool MatchAndExplain(ConstCharPointer s,
+ MatchResultListener* listener) const {
+ if (s == NULL) {
+ return !expect_eq_;
+ }
+ return MatchAndExplain(StringType(s), listener);
+ }
+
+ bool MatchAndExplain(const StringType& s,
+ MatchResultListener* /* listener */) const {
+ const bool eq = case_sensitive_ ? s == string_ :
+ CaseInsensitiveStringEquals(s, string_);
+ return expect_eq_ == eq;
+ }
+
+ void DescribeTo(::std::ostream* os) const {
+ DescribeToHelper(expect_eq_, os);
+ }
+
+ void DescribeNegationTo(::std::ostream* os) const {
+ DescribeToHelper(!expect_eq_, os);
+ }
+
+ private:
+ void DescribeToHelper(bool expect_eq, ::std::ostream* os) const {
+ *os << (expect_eq ? "is " : "isn't ");
+ *os << "equal to ";
+ if (!case_sensitive_) {
+ *os << "(ignoring case) ";
+ }
+ UniversalPrint(string_, os);
+ }
+
+ const StringType string_;
+ const bool expect_eq_;
+ const bool case_sensitive_;
+
+ GTEST_DISALLOW_ASSIGN_(StrEqualityMatcher);
+};
+
+// Implements the polymorphic HasSubstr(substring) matcher, which
+// can be used as a Matcher<T> as long as T can be converted to a
+// string.
+template <typename StringType>
+class HasSubstrMatcher {
+ public:
+ typedef typename StringType::const_pointer ConstCharPointer;
+
+ explicit HasSubstrMatcher(const StringType& substring)
+ : substring_(substring) {}
+
+ // These overloaded methods allow HasSubstr(substring) to be used as a
+ // Matcher<T> as long as T can be converted to string. Returns true
+ // iff s contains substring_ as a substring.
+ bool MatchAndExplain(ConstCharPointer s,
+ MatchResultListener* listener) const {
+ return s != NULL && MatchAndExplain(StringType(s), listener);
+ }
+
+ bool MatchAndExplain(const StringType& s,
+ MatchResultListener* /* listener */) const {
+ return s.find(substring_) != StringType::npos;
+ }
+
+ // Describes what this matcher matches.
+ void DescribeTo(::std::ostream* os) const {
+ *os << "has substring ";
+ UniversalPrint(substring_, os);
+ }
+
+ void DescribeNegationTo(::std::ostream* os) const {
+ *os << "has no substring ";
+ UniversalPrint(substring_, os);
+ }
+
+ private:
+ const StringType substring_;
+
+ GTEST_DISALLOW_ASSIGN_(HasSubstrMatcher);
+};
+
+// Implements the polymorphic StartsWith(substring) matcher, which
+// can be used as a Matcher<T> as long as T can be converted to a
+// string.
+template <typename StringType>
+class StartsWithMatcher {
+ public:
+ typedef typename StringType::const_pointer ConstCharPointer;
+
+ explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) {
+ }
+
+ // These overloaded methods allow StartsWith(prefix) to be used as a
+ // Matcher<T> as long as T can be converted to string. Returns true
+ // iff s starts with prefix_.
+ bool MatchAndExplain(ConstCharPointer s,
+ MatchResultListener* listener) const {
+ return s != NULL && MatchAndExplain(StringType(s), listener);
+ }
+
+ bool MatchAndExplain(const StringType& s,
+ MatchResultListener* /* listener */) const {
+ return s.length() >= prefix_.length() &&
+ s.substr(0, prefix_.length()) == prefix_;
+ }
+
+ void DescribeTo(::std::ostream* os) const {
+ *os << "starts with ";
+ UniversalPrint(prefix_, os);
+ }
+
+ void DescribeNegationTo(::std::ostream* os) const {
+ *os << "doesn't start with ";
+ UniversalPrint(prefix_, os);
+ }
+
+ private:
+ const StringType prefix_;
+
+ GTEST_DISALLOW_ASSIGN_(StartsWithMatcher);
+};
+
+// Implements the polymorphic EndsWith(substring) matcher, which
+// can be used as a Matcher<T> as long as T can be converted to a
+// string.
+template <typename StringType>
+class EndsWithMatcher {
+ public:
+ typedef typename StringType::const_pointer ConstCharPointer;
+
+ explicit EndsWithMatcher(const StringType& suffix) : suffix_(suffix) {}
+
+ // These overloaded methods allow EndsWith(suffix) to be used as a
+ // Matcher<T> as long as T can be converted to string. Returns true
+ // iff s ends with suffix_.
+ bool MatchAndExplain(ConstCharPointer s,
+ MatchResultListener* listener) const {
+ return s != NULL && MatchAndExplain(StringType(s), listener);
+ }
+
+ bool MatchAndExplain(const StringType& s,
+ MatchResultListener* /* listener */) const {
+ return s.length() >= suffix_.length() &&
+ s.substr(s.length() - suffix_.length()) == suffix_;
+ }
+
+ void DescribeTo(::std::ostream* os) const {
+ *os << "ends with ";
+ UniversalPrint(suffix_, os);
+ }
+
+ void DescribeNegationTo(::std::ostream* os) const {
+ *os << "doesn't end with ";
+ UniversalPrint(suffix_, os);
+ }
+
+ private:
+ const StringType suffix_;
+
+ GTEST_DISALLOW_ASSIGN_(EndsWithMatcher);
+};
+
+// Implements polymorphic matchers MatchesRegex(regex) and
+// ContainsRegex(regex), which can be used as a Matcher<T> as long as
+// T can be converted to a string.
+class MatchesRegexMatcher {
+ public:
+ MatchesRegexMatcher(const RE* regex, bool full_match)
+ : regex_(regex), full_match_(full_match) {}
+
+ // These overloaded methods allow MatchesRegex(regex) to be used as
+ // a Matcher<T> as long as T can be converted to string. Returns
+ // true iff s matches regular expression regex. When full_match_ is
+ // true, a full match is done; otherwise a partial match is done.
+ bool MatchAndExplain(const char* s,
+ MatchResultListener* listener) const {
+ return s != NULL && MatchAndExplain(internal::string(s), listener);
+ }
+
+ bool MatchAndExplain(const internal::string& s,
+ MatchResultListener* /* listener */) const {
+ return full_match_ ? RE::FullMatch(s, *regex_) :
+ RE::PartialMatch(s, *regex_);
+ }
+
+ void DescribeTo(::std::ostream* os) const {
+ *os << (full_match_ ? "matches" : "contains")
+ << " regular expression ";
+ UniversalPrinter<internal::string>::Print(regex_->pattern(), os);
+ }
+
+ void DescribeNegationTo(::std::ostream* os) const {
+ *os << "doesn't " << (full_match_ ? "match" : "contain")
+ << " regular expression ";
+ UniversalPrinter<internal::string>::Print(regex_->pattern(), os);
+ }
+
+ private:
+ const internal::linked_ptr<const RE> regex_;
+ const bool full_match_;
+
+ GTEST_DISALLOW_ASSIGN_(MatchesRegexMatcher);
+};
+
+// Implements a matcher that compares the two fields of a 2-tuple
+// using one of the ==, <=, <, etc, operators. The two fields being
+// compared don't have to have the same type.
+//
+// The matcher defined here is polymorphic (for example, Eq() can be
+// used to match a tuple<int, short>, a tuple<const long&, double>,
+// etc). Therefore we use a template type conversion operator in the
+// implementation.
+//
+// We define this as a macro in order to eliminate duplicated source
+// code.
+#define GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(name, op, relation) \
+ class name##2Matcher { \
+ public: \
+ template <typename T1, typename T2> \
+ operator Matcher< ::std::tr1::tuple<T1, T2> >() const { \
+ return MakeMatcher(new Impl< ::std::tr1::tuple<T1, T2> >); \
+ } \
+ template <typename T1, typename T2> \
+ operator Matcher<const ::std::tr1::tuple<T1, T2>&>() const { \
+ return MakeMatcher(new Impl<const ::std::tr1::tuple<T1, T2>&>); \
+ } \
+ private: \
+ template <typename Tuple> \
+ class Impl : public MatcherInterface<Tuple> { \
+ public: \
+ virtual bool MatchAndExplain( \
+ Tuple args, \
+ MatchResultListener* /* listener */) const { \
+ return ::std::tr1::get<0>(args) op ::std::tr1::get<1>(args); \
+ } \
+ virtual void DescribeTo(::std::ostream* os) const { \
+ *os << "are " relation; \
+ } \
+ virtual void DescribeNegationTo(::std::ostream* os) const { \
+ *os << "aren't " relation; \
+ } \
+ }; \
+ }
+
+// Implements Eq(), Ge(), Gt(), Le(), Lt(), and Ne() respectively.
+GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Eq, ==, "an equal pair");
+GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
+ Ge, >=, "a pair where the first >= the second");
+GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
+ Gt, >, "a pair where the first > the second");
+GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
+ Le, <=, "a pair where the first <= the second");
+GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
+ Lt, <, "a pair where the first < the second");
+GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Ne, !=, "an unequal pair");
+
+#undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
+
+// Implements the Not(...) matcher for a particular argument type T.
+// We do not nest it inside the NotMatcher class template, as that
+// will prevent different instantiations of NotMatcher from sharing
+// the same NotMatcherImpl<T> class.
+template <typename T>
+class NotMatcherImpl : public MatcherInterface<T> {
+ public:
+ explicit NotMatcherImpl(const Matcher<T>& matcher)
+ : matcher_(matcher) {}
+
+ virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
+ return !matcher_.MatchAndExplain(x, listener);
+ }
+
+ virtual void DescribeTo(::std::ostream* os) const {
+ matcher_.DescribeNegationTo(os);
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ matcher_.DescribeTo(os);
+ }
+
+ private:
+ const Matcher<T> matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(NotMatcherImpl);
+};
+
+// Implements the Not(m) matcher, which matches a value that doesn't
+// match matcher m.
+template <typename InnerMatcher>
+class NotMatcher {
+ public:
+ explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {}
+
+ // This template type conversion operator allows Not(m) to be used
+ // to match any type m can match.
+ template <typename T>
+ operator Matcher<T>() const {
+ return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_)));
+ }
+
+ private:
+ InnerMatcher matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(NotMatcher);
+};
+
+// Implements the AllOf(m1, m2) matcher for a particular argument type
+// T. We do not nest it inside the BothOfMatcher class template, as
+// that will prevent different instantiations of BothOfMatcher from
+// sharing the same BothOfMatcherImpl<T> class.
+template <typename T>
+class BothOfMatcherImpl : public MatcherInterface<T> {
+ public:
+ BothOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
+ : matcher1_(matcher1), matcher2_(matcher2) {}
+
+ virtual void DescribeTo(::std::ostream* os) const {
+ *os << "(";
+ matcher1_.DescribeTo(os);
+ *os << ") and (";
+ matcher2_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "(";
+ matcher1_.DescribeNegationTo(os);
+ *os << ") or (";
+ matcher2_.DescribeNegationTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
+ // If either matcher1_ or matcher2_ doesn't match x, we only need
+ // to explain why one of them fails.
+ StringMatchResultListener listener1;
+ if (!matcher1_.MatchAndExplain(x, &listener1)) {
+ *listener << listener1.str();
+ return false;
+ }
+
+ StringMatchResultListener listener2;
+ if (!matcher2_.MatchAndExplain(x, &listener2)) {
+ *listener << listener2.str();
+ return false;
+ }
+
+ // Otherwise we need to explain why *both* of them match.
+ const internal::string s1 = listener1.str();
+ const internal::string s2 = listener2.str();
+
+ if (s1 == "") {
+ *listener << s2;
+ } else {
+ *listener << s1;
+ if (s2 != "") {
+ *listener << ", and " << s2;
+ }
+ }
+ return true;
+ }
+
+ private:
+ const Matcher<T> matcher1_;
+ const Matcher<T> matcher2_;
+
+ GTEST_DISALLOW_ASSIGN_(BothOfMatcherImpl);
+};
+
+// Used for implementing the AllOf(m_1, ..., m_n) matcher, which
+// matches a value that matches all of the matchers m_1, ..., and m_n.
+template <typename Matcher1, typename Matcher2>
+class BothOfMatcher {
+ public:
+ BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
+ : matcher1_(matcher1), matcher2_(matcher2) {}
+
+ // This template type conversion operator allows a
+ // BothOfMatcher<Matcher1, Matcher2> object to match any type that
+ // both Matcher1 and Matcher2 can match.
+ template <typename T>
+ operator Matcher<T>() const {
+ return Matcher<T>(new BothOfMatcherImpl<T>(SafeMatcherCast<T>(matcher1_),
+ SafeMatcherCast<T>(matcher2_)));
+ }
+
+ private:
+ Matcher1 matcher1_;
+ Matcher2 matcher2_;
+
+ GTEST_DISALLOW_ASSIGN_(BothOfMatcher);
+};
+
+// Implements the AnyOf(m1, m2) matcher for a particular argument type
+// T. We do not nest it inside the AnyOfMatcher class template, as
+// that will prevent different instantiations of AnyOfMatcher from
+// sharing the same EitherOfMatcherImpl<T> class.
+template <typename T>
+class EitherOfMatcherImpl : public MatcherInterface<T> {
+ public:
+ EitherOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
+ : matcher1_(matcher1), matcher2_(matcher2) {}
+
+ virtual void DescribeTo(::std::ostream* os) const {
+ *os << "(";
+ matcher1_.DescribeTo(os);
+ *os << ") or (";
+ matcher2_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "(";
+ matcher1_.DescribeNegationTo(os);
+ *os << ") and (";
+ matcher2_.DescribeNegationTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
+ // If either matcher1_ or matcher2_ matches x, we just need to
+ // explain why *one* of them matches.
+ StringMatchResultListener listener1;
+ if (matcher1_.MatchAndExplain(x, &listener1)) {
+ *listener << listener1.str();
+ return true;
+ }
+
+ StringMatchResultListener listener2;
+ if (matcher2_.MatchAndExplain(x, &listener2)) {
+ *listener << listener2.str();
+ return true;
+ }
+
+ // Otherwise we need to explain why *both* of them fail.
+ const internal::string s1 = listener1.str();
+ const internal::string s2 = listener2.str();
+
+ if (s1 == "") {
+ *listener << s2;
+ } else {
+ *listener << s1;
+ if (s2 != "") {
+ *listener << ", and " << s2;
+ }
+ }
+ return false;
+ }
+
+ private:
+ const Matcher<T> matcher1_;
+ const Matcher<T> matcher2_;
+
+ GTEST_DISALLOW_ASSIGN_(EitherOfMatcherImpl);
+};
+
+// Used for implementing the AnyOf(m_1, ..., m_n) matcher, which
+// matches a value that matches at least one of the matchers m_1, ...,
+// and m_n.
+template <typename Matcher1, typename Matcher2>
+class EitherOfMatcher {
+ public:
+ EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
+ : matcher1_(matcher1), matcher2_(matcher2) {}
+
+ // This template type conversion operator allows a
+ // EitherOfMatcher<Matcher1, Matcher2> object to match any type that
+ // both Matcher1 and Matcher2 can match.
+ template <typename T>
+ operator Matcher<T>() const {
+ return Matcher<T>(new EitherOfMatcherImpl<T>(
+ SafeMatcherCast<T>(matcher1_), SafeMatcherCast<T>(matcher2_)));
+ }
+
+ private:
+ Matcher1 matcher1_;
+ Matcher2 matcher2_;
+
+ GTEST_DISALLOW_ASSIGN_(EitherOfMatcher);
+};
+
+// Used for implementing Truly(pred), which turns a predicate into a
+// matcher.
+template <typename Predicate>
+class TrulyMatcher {
+ public:
+ explicit TrulyMatcher(Predicate pred) : predicate_(pred) {}
+
+ // This method template allows Truly(pred) to be used as a matcher
+ // for type T where T is the argument type of predicate 'pred'. The
+ // argument is passed by reference as the predicate may be
+ // interested in the address of the argument.
+ template <typename T>
+ bool MatchAndExplain(T& x, // NOLINT
+ MatchResultListener* /* listener */) const {
+ // Without the if-statement, MSVC sometimes warns about converting
+ // a value to bool (warning 4800).
+ //
+ // We cannot write 'return !!predicate_(x);' as that doesn't work
+ // when predicate_(x) returns a class convertible to bool but
+ // having no operator!().
+ if (predicate_(x))
+ return true;
+ return false;
+ }
+
+ void DescribeTo(::std::ostream* os) const {
+ *os << "satisfies the given predicate";
+ }
+
+ void DescribeNegationTo(::std::ostream* os) const {
+ *os << "doesn't satisfy the given predicate";
+ }
+
+ private:
+ Predicate predicate_;
+
+ GTEST_DISALLOW_ASSIGN_(TrulyMatcher);
+};
+
+// Used for implementing Matches(matcher), which turns a matcher into
+// a predicate.
+template <typename M>
+class MatcherAsPredicate {
+ public:
+ explicit MatcherAsPredicate(M matcher) : matcher_(matcher) {}
+
+ // This template operator() allows Matches(m) to be used as a
+ // predicate on type T where m is a matcher on type T.
+ //
+ // The argument x is passed by reference instead of by value, as
+ // some matcher may be interested in its address (e.g. as in
+ // Matches(Ref(n))(x)).
+ template <typename T>
+ bool operator()(const T& x) const {
+ // We let matcher_ commit to a particular type here instead of
+ // when the MatcherAsPredicate object was constructed. This
+ // allows us to write Matches(m) where m is a polymorphic matcher
+ // (e.g. Eq(5)).
+ //
+ // If we write Matcher<T>(matcher_).Matches(x) here, it won't
+ // compile when matcher_ has type Matcher<const T&>; if we write
+ // Matcher<const T&>(matcher_).Matches(x) here, it won't compile
+ // when matcher_ has type Matcher<T>; if we just write
+ // matcher_.Matches(x), it won't compile when matcher_ is
+ // polymorphic, e.g. Eq(5).
+ //
+ // MatcherCast<const T&>() is necessary for making the code work
+ // in all of the above situations.
+ return MatcherCast<const T&>(matcher_).Matches(x);
+ }
+
+ private:
+ M matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(MatcherAsPredicate);
+};
+
+// For implementing ASSERT_THAT() and EXPECT_THAT(). The template
+// argument M must be a type that can be converted to a matcher.
+template <typename M>
+class PredicateFormatterFromMatcher {
+ public:
+ explicit PredicateFormatterFromMatcher(const M& m) : matcher_(m) {}
+
+ // This template () operator allows a PredicateFormatterFromMatcher
+ // object to act as a predicate-formatter suitable for using with
+ // Google Test's EXPECT_PRED_FORMAT1() macro.
+ template <typename T>
+ AssertionResult operator()(const char* value_text, const T& x) const {
+ // We convert matcher_ to a Matcher<const T&> *now* instead of
+ // when the PredicateFormatterFromMatcher object was constructed,
+ // as matcher_ may be polymorphic (e.g. NotNull()) and we won't
+ // know which type to instantiate it to until we actually see the
+ // type of x here.
+ //
+ // We write MatcherCast<const T&>(matcher_) instead of
+ // Matcher<const T&>(matcher_), as the latter won't compile when
+ // matcher_ has type Matcher<T> (e.g. An<int>()).
+ const Matcher<const T&> matcher = MatcherCast<const T&>(matcher_);
+ StringMatchResultListener listener;
+ if (MatchPrintAndExplain(x, matcher, &listener))
+ return AssertionSuccess();
+
+ ::std::stringstream ss;
+ ss << "Value of: " << value_text << "\n"
+ << "Expected: ";
+ matcher.DescribeTo(&ss);
+ ss << "\n Actual: " << listener.str();
+ return AssertionFailure() << ss.str();
+ }
+
+ private:
+ const M matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(PredicateFormatterFromMatcher);
+};
+
+// A helper function for converting a matcher to a predicate-formatter
+// without the user needing to explicitly write the type. This is
+// used for implementing ASSERT_THAT() and EXPECT_THAT().
+template <typename M>
+inline PredicateFormatterFromMatcher<M>
+MakePredicateFormatterFromMatcher(const M& matcher) {
+ return PredicateFormatterFromMatcher<M>(matcher);
+}
+
+// Implements the polymorphic floating point equality matcher, which
+// matches two float values using ULP-based approximation. The
+// template is meant to be instantiated with FloatType being either
+// float or double.
+template <typename FloatType>
+class FloatingEqMatcher {
+ public:
+ // Constructor for FloatingEqMatcher.
+ // The matcher's input will be compared with rhs. The matcher treats two
+ // NANs as equal if nan_eq_nan is true. Otherwise, under IEEE standards,
+ // equality comparisons between NANs will always return false.
+ FloatingEqMatcher(FloatType rhs, bool nan_eq_nan) :
+ rhs_(rhs), nan_eq_nan_(nan_eq_nan) {}
+
+ // Implements floating point equality matcher as a Matcher<T>.
+ template <typename T>
+ class Impl : public MatcherInterface<T> {
+ public:
+ Impl(FloatType rhs, bool nan_eq_nan) :
+ rhs_(rhs), nan_eq_nan_(nan_eq_nan) {}
+
+ virtual bool MatchAndExplain(T value,
+ MatchResultListener* /* listener */) const {
+ const FloatingPoint<FloatType> lhs(value), rhs(rhs_);
+
+ // Compares NaNs first, if nan_eq_nan_ is true.
+ if (nan_eq_nan_ && lhs.is_nan()) {
+ return rhs.is_nan();
+ }
+
+ return lhs.AlmostEquals(rhs);
+ }
+
+ virtual void DescribeTo(::std::ostream* os) const {
+ // os->precision() returns the previously set precision, which we
+ // store to restore the ostream to its original configuration
+ // after outputting.
+ const ::std::streamsize old_precision = os->precision(
+ ::std::numeric_limits<FloatType>::digits10 + 2);
+ if (FloatingPoint<FloatType>(rhs_).is_nan()) {
+ if (nan_eq_nan_) {
+ *os << "is NaN";
+ } else {
+ *os << "never matches";
+ }
+ } else {
+ *os << "is approximately " << rhs_;
+ }
+ os->precision(old_precision);
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ // As before, get original precision.
+ const ::std::streamsize old_precision = os->precision(
+ ::std::numeric_limits<FloatType>::digits10 + 2);
+ if (FloatingPoint<FloatType>(rhs_).is_nan()) {
+ if (nan_eq_nan_) {
+ *os << "isn't NaN";
+ } else {
+ *os << "is anything";
+ }
+ } else {
+ *os << "isn't approximately " << rhs_;
+ }
+ // Restore original precision.
+ os->precision(old_precision);
+ }
+
+ private:
+ const FloatType rhs_;
+ const bool nan_eq_nan_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
+ };
+
+ // The following 3 type conversion operators allow FloatEq(rhs) and
+ // NanSensitiveFloatEq(rhs) to be used as a Matcher<float>, a
+ // Matcher<const float&>, or a Matcher<float&>, but nothing else.
+ // (While Google's C++ coding style doesn't allow arguments passed
+ // by non-const reference, we may see them in code not conforming to
+ // the style. Therefore Google Mock needs to support them.)
+ operator Matcher<FloatType>() const {
+ return MakeMatcher(new Impl<FloatType>(rhs_, nan_eq_nan_));
+ }
+
+ operator Matcher<const FloatType&>() const {
+ return MakeMatcher(new Impl<const FloatType&>(rhs_, nan_eq_nan_));
+ }
+
+ operator Matcher<FloatType&>() const {
+ return MakeMatcher(new Impl<FloatType&>(rhs_, nan_eq_nan_));
+ }
+ private:
+ const FloatType rhs_;
+ const bool nan_eq_nan_;
+
+ GTEST_DISALLOW_ASSIGN_(FloatingEqMatcher);
+};
+
+// Implements the Pointee(m) matcher for matching a pointer whose
+// pointee matches matcher m. The pointer can be either raw or smart.
+template <typename InnerMatcher>
+class PointeeMatcher {
+ public:
+ explicit PointeeMatcher(const InnerMatcher& matcher) : matcher_(matcher) {}
+
+ // This type conversion operator template allows Pointee(m) to be
+ // used as a matcher for any pointer type whose pointee type is
+ // compatible with the inner matcher, where type Pointer can be
+ // either a raw pointer or a smart pointer.
+ //
+ // The reason we do this instead of relying on
+ // MakePolymorphicMatcher() is that the latter is not flexible
+ // enough for implementing the DescribeTo() method of Pointee().
+ template <typename Pointer>
+ operator Matcher<Pointer>() const {
+ return MakeMatcher(new Impl<Pointer>(matcher_));
+ }
+
+ private:
+ // The monomorphic implementation that works for a particular pointer type.
+ template <typename Pointer>
+ class Impl : public MatcherInterface<Pointer> {
+ public:
+ typedef typename PointeeOf<GTEST_REMOVE_CONST_( // NOLINT
+ GTEST_REMOVE_REFERENCE_(Pointer))>::type Pointee;
+
+ explicit Impl(const InnerMatcher& matcher)
+ : matcher_(MatcherCast<const Pointee&>(matcher)) {}
+
+ virtual void DescribeTo(::std::ostream* os) const {
+ *os << "points to a value that ";
+ matcher_.DescribeTo(os);
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "does not point to a value that ";
+ matcher_.DescribeTo(os);
+ }
+
+ virtual bool MatchAndExplain(Pointer pointer,
+ MatchResultListener* listener) const {
+ if (GetRawPointer(pointer) == NULL)
+ return false;
+
+ *listener << "which points to ";
+ return MatchPrintAndExplain(*pointer, matcher_, listener);
+ }
+
+ private:
+ const Matcher<const Pointee&> matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
+ };
+
+ const InnerMatcher matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(PointeeMatcher);
+};
+
+// Implements the Field() matcher for matching a field (i.e. member
+// variable) of an object.
+template <typename Class, typename FieldType>
+class FieldMatcher {
+ public:
+ FieldMatcher(FieldType Class::*field,
+ const Matcher<const FieldType&>& matcher)
+ : field_(field), matcher_(matcher) {}
+
+ void DescribeTo(::std::ostream* os) const {
+ *os << "is an object whose given field ";
+ matcher_.DescribeTo(os);
+ }
+
+ void DescribeNegationTo(::std::ostream* os) const {
+ *os << "is an object whose given field ";
+ matcher_.DescribeNegationTo(os);
+ }
+
+ template <typename T>
+ bool MatchAndExplain(const T& value, MatchResultListener* listener) const {
+ return MatchAndExplainImpl(
+ typename ::testing::internal::
+ is_pointer<GTEST_REMOVE_CONST_(T)>::type(),
+ value, listener);
+ }
+
+ private:
+ // The first argument of MatchAndExplainImpl() is needed to help
+ // Symbian's C++ compiler choose which overload to use. Its type is
+ // true_type iff the Field() matcher is used to match a pointer.
+ bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class& obj,
+ MatchResultListener* listener) const {
+ *listener << "whose given field is ";
+ return MatchPrintAndExplain(obj.*field_, matcher_, listener);
+ }
+
+ bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p,
+ MatchResultListener* listener) const {
+ if (p == NULL)
+ return false;
+
+ *listener << "which points to an object ";
+ // Since *p has a field, it must be a class/struct/union type and
+ // thus cannot be a pointer. Therefore we pass false_type() as
+ // the first argument.
+ return MatchAndExplainImpl(false_type(), *p, listener);
+ }
+
+ const FieldType Class::*field_;
+ const Matcher<const FieldType&> matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(FieldMatcher);
+};
+
+// Implements the Property() matcher for matching a property
+// (i.e. return value of a getter method) of an object.
+template <typename Class, typename PropertyType>
+class PropertyMatcher {
+ public:
+ // The property may have a reference type, so 'const PropertyType&'
+ // may cause double references and fail to compile. That's why we
+ // need GTEST_REFERENCE_TO_CONST, which works regardless of
+ // PropertyType being a reference or not.
+ typedef GTEST_REFERENCE_TO_CONST_(PropertyType) RefToConstProperty;
+
+ PropertyMatcher(PropertyType (Class::*property)() const,
+ const Matcher<RefToConstProperty>& matcher)
+ : property_(property), matcher_(matcher) {}
+
+ void DescribeTo(::std::ostream* os) const {
+ *os << "is an object whose given property ";
+ matcher_.DescribeTo(os);
+ }
+
+ void DescribeNegationTo(::std::ostream* os) const {
+ *os << "is an object whose given property ";
+ matcher_.DescribeNegationTo(os);
+ }
+
+ template <typename T>
+ bool MatchAndExplain(const T&value, MatchResultListener* listener) const {
+ return MatchAndExplainImpl(
+ typename ::testing::internal::
+ is_pointer<GTEST_REMOVE_CONST_(T)>::type(),
+ value, listener);
+ }
+
+ private:
+ // The first argument of MatchAndExplainImpl() is needed to help
+ // Symbian's C++ compiler choose which overload to use. Its type is
+ // true_type iff the Property() matcher is used to match a pointer.
+ bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class& obj,
+ MatchResultListener* listener) const {
+ *listener << "whose given property is ";
+ // Cannot pass the return value (for example, int) to MatchPrintAndExplain,
+ // which takes a non-const reference as argument.
+ RefToConstProperty result = (obj.*property_)();
+ return MatchPrintAndExplain(result, matcher_, listener);
+ }
+
+ bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p,
+ MatchResultListener* listener) const {
+ if (p == NULL)
+ return false;
+
+ *listener << "which points to an object ";
+ // Since *p has a property method, it must be a class/struct/union
+ // type and thus cannot be a pointer. Therefore we pass
+ // false_type() as the first argument.
+ return MatchAndExplainImpl(false_type(), *p, listener);
+ }
+
+ PropertyType (Class::*property_)() const;
+ const Matcher<RefToConstProperty> matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(PropertyMatcher);
+};
+
+// Type traits specifying various features of different functors for ResultOf.
+// The default template specifies features for functor objects.
+// Functor classes have to typedef argument_type and result_type
+// to be compatible with ResultOf.
+template <typename Functor>
+struct CallableTraits {
+ typedef typename Functor::result_type ResultType;
+ typedef Functor StorageType;
+
+ static void CheckIsValid(Functor /* functor */) {}
+ template <typename T>
+ static ResultType Invoke(Functor f, T arg) { return f(arg); }
+};
+
+// Specialization for function pointers.
+template <typename ArgType, typename ResType>
+struct CallableTraits<ResType(*)(ArgType)> {
+ typedef ResType ResultType;
+ typedef ResType(*StorageType)(ArgType);
+
+ static void CheckIsValid(ResType(*f)(ArgType)) {
+ GTEST_CHECK_(f != NULL)
+ << "NULL function pointer is passed into ResultOf().";
+ }
+ template <typename T>
+ static ResType Invoke(ResType(*f)(ArgType), T arg) {
+ return (*f)(arg);
+ }
+};
+
+// Implements the ResultOf() matcher for matching a return value of a
+// unary function of an object.
+template <typename Callable>
+class ResultOfMatcher {
+ public:
+ typedef typename CallableTraits<Callable>::ResultType ResultType;
+
+ ResultOfMatcher(Callable callable, const Matcher<ResultType>& matcher)
+ : callable_(callable), matcher_(matcher) {
+ CallableTraits<Callable>::CheckIsValid(callable_);
+ }
+
+ template <typename T>
+ operator Matcher<T>() const {
+ return Matcher<T>(new Impl<T>(callable_, matcher_));
+ }
+
+ private:
+ typedef typename CallableTraits<Callable>::StorageType CallableStorageType;
+
+ template <typename T>
+ class Impl : public MatcherInterface<T> {
+ public:
+ Impl(CallableStorageType callable, const Matcher<ResultType>& matcher)
+ : callable_(callable), matcher_(matcher) {}
+
+ virtual void DescribeTo(::std::ostream* os) const {
+ *os << "is mapped by the given callable to a value that ";
+ matcher_.DescribeTo(os);
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "is mapped by the given callable to a value that ";
+ matcher_.DescribeNegationTo(os);
+ }
+
+ virtual bool MatchAndExplain(T obj, MatchResultListener* listener) const {
+ *listener << "which is mapped by the given callable to ";
+ // Cannot pass the return value (for example, int) to
+ // MatchPrintAndExplain, which takes a non-const reference as argument.
+ ResultType result =
+ CallableTraits<Callable>::template Invoke<T>(callable_, obj);
+ return MatchPrintAndExplain(result, matcher_, listener);
+ }
+
+ private:
+ // Functors often define operator() as non-const method even though
+ // they are actualy stateless. But we need to use them even when
+ // 'this' is a const pointer. It's the user's responsibility not to
+ // use stateful callables with ResultOf(), which does't guarantee
+ // how many times the callable will be invoked.
+ mutable CallableStorageType callable_;
+ const Matcher<ResultType> matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
+ }; // class Impl
+
+ const CallableStorageType callable_;
+ const Matcher<ResultType> matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ResultOfMatcher);
+};
+
+// Implements an equality matcher for any STL-style container whose elements
+// support ==. This matcher is like Eq(), but its failure explanations provide
+// more detailed information that is useful when the container is used as a set.
+// The failure message reports elements that are in one of the operands but not
+// the other. The failure messages do not report duplicate or out-of-order
+// elements in the containers (which don't properly matter to sets, but can
+// occur if the containers are vectors or lists, for example).
+//
+// Uses the container's const_iterator, value_type, operator ==,
+// begin(), and end().
+template <typename Container>
+class ContainerEqMatcher {
+ public:
+ typedef internal::StlContainerView<Container> View;
+ typedef typename View::type StlContainer;
+ typedef typename View::const_reference StlContainerReference;
+
+ // We make a copy of rhs in case the elements in it are modified
+ // after this matcher is created.
+ explicit ContainerEqMatcher(const Container& rhs) : rhs_(View::Copy(rhs)) {
+ // Makes sure the user doesn't instantiate this class template
+ // with a const or reference type.
+ (void)testing::StaticAssertTypeEq<Container,
+ GTEST_REMOVE_REFERENCE_AND_CONST_(Container)>();
+ }
+
+ void DescribeTo(::std::ostream* os) const {
+ *os << "equals ";
+ UniversalPrint(rhs_, os);
+ }
+ void DescribeNegationTo(::std::ostream* os) const {
+ *os << "does not equal ";
+ UniversalPrint(rhs_, os);
+ }
+
+ template <typename LhsContainer>
+ bool MatchAndExplain(const LhsContainer& lhs,
+ MatchResultListener* listener) const {
+ // GTEST_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug
+ // that causes LhsContainer to be a const type sometimes.
+ typedef internal::StlContainerView<GTEST_REMOVE_CONST_(LhsContainer)>
+ LhsView;
+ typedef typename LhsView::type LhsStlContainer;
+ StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
+ if (lhs_stl_container == rhs_)
+ return true;
+
+ ::std::ostream* const os = listener->stream();
+ if (os != NULL) {
+ // Something is different. Check for extra values first.
+ bool printed_header = false;
+ for (typename LhsStlContainer::const_iterator it =
+ lhs_stl_container.begin();
+ it != lhs_stl_container.end(); ++it) {
+ if (internal::ArrayAwareFind(rhs_.begin(), rhs_.end(), *it) ==
+ rhs_.end()) {
+ if (printed_header) {
+ *os << ", ";
+ } else {
+ *os << "which has these unexpected elements: ";
+ printed_header = true;
+ }
+ UniversalPrint(*it, os);
+ }
+ }
+
+ // Now check for missing values.
+ bool printed_header2 = false;
+ for (typename StlContainer::const_iterator it = rhs_.begin();
+ it != rhs_.end(); ++it) {
+ if (internal::ArrayAwareFind(
+ lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
+ lhs_stl_container.end()) {
+ if (printed_header2) {
+ *os << ", ";
+ } else {
+ *os << (printed_header ? ",\nand" : "which")
+ << " doesn't have these expected elements: ";
+ printed_header2 = true;
+ }
+ UniversalPrint(*it, os);
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private:
+ const StlContainer rhs_;
+
+ GTEST_DISALLOW_ASSIGN_(ContainerEqMatcher);
+};
+
+// Implements Pointwise(tuple_matcher, rhs_container). tuple_matcher
+// must be able to be safely cast to Matcher<tuple<const T1&, const
+// T2&> >, where T1 and T2 are the types of elements in the LHS
+// container and the RHS container respectively.
+template <typename TupleMatcher, typename RhsContainer>
+class PointwiseMatcher {
+ public:
+ typedef internal::StlContainerView<RhsContainer> RhsView;
+ typedef typename RhsView::type RhsStlContainer;
+ typedef typename RhsStlContainer::value_type RhsValue;
+
+ // Like ContainerEq, we make a copy of rhs in case the elements in
+ // it are modified after this matcher is created.
+ PointwiseMatcher(const TupleMatcher& tuple_matcher, const RhsContainer& rhs)
+ : tuple_matcher_(tuple_matcher), rhs_(RhsView::Copy(rhs)) {
+ // Makes sure the user doesn't instantiate this class template
+ // with a const or reference type.
+ (void)testing::StaticAssertTypeEq<RhsContainer,
+ GTEST_REMOVE_REFERENCE_AND_CONST_(RhsContainer)>();
+ }
+
+ template <typename LhsContainer>
+ operator Matcher<LhsContainer>() const {
+ return MakeMatcher(new Impl<LhsContainer>(tuple_matcher_, rhs_));
+ }
+
+ template <typename LhsContainer>
+ class Impl : public MatcherInterface<LhsContainer> {
+ public:
+ typedef internal::StlContainerView<
+ GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView;
+ typedef typename LhsView::type LhsStlContainer;
+ typedef typename LhsView::const_reference LhsStlContainerReference;
+ typedef typename LhsStlContainer::value_type LhsValue;
+ // We pass the LHS value and the RHS value to the inner matcher by
+ // reference, as they may be expensive to copy. We must use tuple
+ // instead of pair here, as a pair cannot hold references (C++ 98,
+ // 20.2.2 [lib.pairs]).
+ typedef std::tr1::tuple<const LhsValue&, const RhsValue&> InnerMatcherArg;
+
+ Impl(const TupleMatcher& tuple_matcher, const RhsStlContainer& rhs)
+ // mono_tuple_matcher_ holds a monomorphic version of the tuple matcher.
+ : mono_tuple_matcher_(SafeMatcherCast<InnerMatcherArg>(tuple_matcher)),
+ rhs_(rhs) {}
+
+ virtual void DescribeTo(::std::ostream* os) const {
+ *os << "contains " << rhs_.size()
+ << " values, where each value and its corresponding value in ";
+ UniversalPrinter<RhsStlContainer>::Print(rhs_, os);
+ *os << " ";
+ mono_tuple_matcher_.DescribeTo(os);
+ }
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "doesn't contain exactly " << rhs_.size()
+ << " values, or contains a value x at some index i"
+ << " where x and the i-th value of ";
+ UniversalPrint(rhs_, os);
+ *os << " ";
+ mono_tuple_matcher_.DescribeNegationTo(os);
+ }
+
+ virtual bool MatchAndExplain(LhsContainer lhs,
+ MatchResultListener* listener) const {
+ LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
+ const size_t actual_size = lhs_stl_container.size();
+ if (actual_size != rhs_.size()) {
+ *listener << "which contains " << actual_size << " values";
+ return false;
+ }
+
+ typename LhsStlContainer::const_iterator left = lhs_stl_container.begin();
+ typename RhsStlContainer::const_iterator right = rhs_.begin();
+ for (size_t i = 0; i != actual_size; ++i, ++left, ++right) {
+ const InnerMatcherArg value_pair(*left, *right);
+
+ if (listener->IsInterested()) {
+ StringMatchResultListener inner_listener;
+ if (!mono_tuple_matcher_.MatchAndExplain(
+ value_pair, &inner_listener)) {
+ *listener << "where the value pair (";
+ UniversalPrint(*left, listener->stream());
+ *listener << ", ";
+ UniversalPrint(*right, listener->stream());
+ *listener << ") at index #" << i << " don't match";
+ PrintIfNotEmpty(inner_listener.str(), listener->stream());
+ return false;
+ }
+ } else {
+ if (!mono_tuple_matcher_.Matches(value_pair))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private:
+ const Matcher<InnerMatcherArg> mono_tuple_matcher_;
+ const RhsStlContainer rhs_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
+ };
+
+ private:
+ const TupleMatcher tuple_matcher_;
+ const RhsStlContainer rhs_;
+
+ GTEST_DISALLOW_ASSIGN_(PointwiseMatcher);
+};
+
+// Holds the logic common to ContainsMatcherImpl and EachMatcherImpl.
+template <typename Container>
+class QuantifierMatcherImpl : public MatcherInterface<Container> {
+ public:
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef StlContainerView<RawContainer> View;
+ typedef typename View::type StlContainer;
+ typedef typename View::const_reference StlContainerReference;
+ typedef typename StlContainer::value_type Element;
+
+ template <typename InnerMatcher>
+ explicit QuantifierMatcherImpl(InnerMatcher inner_matcher)
+ : inner_matcher_(
+ testing::SafeMatcherCast<const Element&>(inner_matcher)) {}
+
+ // Checks whether:
+ // * All elements in the container match, if all_elements_should_match.
+ // * Any element in the container matches, if !all_elements_should_match.
+ bool MatchAndExplainImpl(bool all_elements_should_match,
+ Container container,
+ MatchResultListener* listener) const {
+ StlContainerReference stl_container = View::ConstReference(container);
+ size_t i = 0;
+ for (typename StlContainer::const_iterator it = stl_container.begin();
+ it != stl_container.end(); ++it, ++i) {
+ StringMatchResultListener inner_listener;
+ const bool matches = inner_matcher_.MatchAndExplain(*it, &inner_listener);
+
+ if (matches != all_elements_should_match) {
+ *listener << "whose element #" << i
+ << (matches ? " matches" : " doesn't match");
+ PrintIfNotEmpty(inner_listener.str(), listener->stream());
+ return !all_elements_should_match;
+ }
+ }
+ return all_elements_should_match;
+ }
+
+ protected:
+ const Matcher<const Element&> inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(QuantifierMatcherImpl);
+};
+
+// Implements Contains(element_matcher) for the given argument type Container.
+// Symmetric to EachMatcherImpl.
+template <typename Container>
+class ContainsMatcherImpl : public QuantifierMatcherImpl<Container> {
+ public:
+ template <typename InnerMatcher>
+ explicit ContainsMatcherImpl(InnerMatcher inner_matcher)
+ : QuantifierMatcherImpl<Container>(inner_matcher) {}
+
+ // Describes what this matcher does.
+ virtual void DescribeTo(::std::ostream* os) const {
+ *os << "contains at least one element that ";
+ this->inner_matcher_.DescribeTo(os);
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "doesn't contain any element that ";
+ this->inner_matcher_.DescribeTo(os);
+ }
+
+ virtual bool MatchAndExplain(Container container,
+ MatchResultListener* listener) const {
+ return this->MatchAndExplainImpl(false, container, listener);
+ }
+
+ private:
+ GTEST_DISALLOW_ASSIGN_(ContainsMatcherImpl);
+};
+
+// Implements Each(element_matcher) for the given argument type Container.
+// Symmetric to ContainsMatcherImpl.
+template <typename Container>
+class EachMatcherImpl : public QuantifierMatcherImpl<Container> {
+ public:
+ template <typename InnerMatcher>
+ explicit EachMatcherImpl(InnerMatcher inner_matcher)
+ : QuantifierMatcherImpl<Container>(inner_matcher) {}
+
+ // Describes what this matcher does.
+ virtual void DescribeTo(::std::ostream* os) const {
+ *os << "only contains elements that ";
+ this->inner_matcher_.DescribeTo(os);
+ }
+
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "contains some element that ";
+ this->inner_matcher_.DescribeNegationTo(os);
+ }
+
+ virtual bool MatchAndExplain(Container container,
+ MatchResultListener* listener) const {
+ return this->MatchAndExplainImpl(true, container, listener);
+ }
+
+ private:
+ GTEST_DISALLOW_ASSIGN_(EachMatcherImpl);
+};
+
+// Implements polymorphic Contains(element_matcher).
+template <typename M>
+class ContainsMatcher {
+ public:
+ explicit ContainsMatcher(M m) : inner_matcher_(m) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ return MakeMatcher(new ContainsMatcherImpl<Container>(inner_matcher_));
+ }
+
+ private:
+ const M inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ContainsMatcher);
+};
+
+// Implements polymorphic Each(element_matcher).
+template <typename M>
+class EachMatcher {
+ public:
+ explicit EachMatcher(M m) : inner_matcher_(m) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ return MakeMatcher(new EachMatcherImpl<Container>(inner_matcher_));
+ }
+
+ private:
+ const M inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(EachMatcher);
+};
+
+// Implements Key(inner_matcher) for the given argument pair type.
+// Key(inner_matcher) matches an std::pair whose 'first' field matches
+// inner_matcher. For example, Contains(Key(Ge(5))) can be used to match an
+// std::map that contains at least one element whose key is >= 5.
+template <typename PairType>
+class KeyMatcherImpl : public MatcherInterface<PairType> {
+ public:
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;
+ typedef typename RawPairType::first_type KeyType;
+
+ template <typename InnerMatcher>
+ explicit KeyMatcherImpl(InnerMatcher inner_matcher)
+ : inner_matcher_(
+ testing::SafeMatcherCast<const KeyType&>(inner_matcher)) {
+ }
+
+ // Returns true iff 'key_value.first' (the key) matches the inner matcher.
+ virtual bool MatchAndExplain(PairType key_value,
+ MatchResultListener* listener) const {
+ StringMatchResultListener inner_listener;
+ const bool match = inner_matcher_.MatchAndExplain(key_value.first,
+ &inner_listener);
+ const internal::string explanation = inner_listener.str();
+ if (explanation != "") {
+ *listener << "whose first field is a value " << explanation;
+ }
+ return match;
+ }
+
+ // Describes what this matcher does.
+ virtual void DescribeTo(::std::ostream* os) const {
+ *os << "has a key that ";
+ inner_matcher_.DescribeTo(os);
+ }
+
+ // Describes what the negation of this matcher does.
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "doesn't have a key that ";
+ inner_matcher_.DescribeTo(os);
+ }
+
+ private:
+ const Matcher<const KeyType&> inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(KeyMatcherImpl);
+};
+
+// Implements polymorphic Key(matcher_for_key).
+template <typename M>
+class KeyMatcher {
+ public:
+ explicit KeyMatcher(M m) : matcher_for_key_(m) {}
+
+ template <typename PairType>
+ operator Matcher<PairType>() const {
+ return MakeMatcher(new KeyMatcherImpl<PairType>(matcher_for_key_));
+ }
+
+ private:
+ const M matcher_for_key_;
+
+ GTEST_DISALLOW_ASSIGN_(KeyMatcher);
+};
+
+// Implements Pair(first_matcher, second_matcher) for the given argument pair
+// type with its two matchers. See Pair() function below.
+template <typename PairType>
+class PairMatcherImpl : public MatcherInterface<PairType> {
+ public:
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;
+ typedef typename RawPairType::first_type FirstType;
+ typedef typename RawPairType::second_type SecondType;
+
+ template <typename FirstMatcher, typename SecondMatcher>
+ PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher)
+ : first_matcher_(
+ testing::SafeMatcherCast<const FirstType&>(first_matcher)),
+ second_matcher_(
+ testing::SafeMatcherCast<const SecondType&>(second_matcher)) {
+ }
+
+ // Describes what this matcher does.
+ virtual void DescribeTo(::std::ostream* os) const {
+ *os << "has a first field that ";
+ first_matcher_.DescribeTo(os);
+ *os << ", and has a second field that ";
+ second_matcher_.DescribeTo(os);
+ }
+
+ // Describes what the negation of this matcher does.
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ *os << "has a first field that ";
+ first_matcher_.DescribeNegationTo(os);
+ *os << ", or has a second field that ";
+ second_matcher_.DescribeNegationTo(os);
+ }
+
+ // Returns true iff 'a_pair.first' matches first_matcher and 'a_pair.second'
+ // matches second_matcher.
+ virtual bool MatchAndExplain(PairType a_pair,
+ MatchResultListener* listener) const {
+ if (!listener->IsInterested()) {
+ // If the listener is not interested, we don't need to construct the
+ // explanation.
+ return first_matcher_.Matches(a_pair.first) &&
+ second_matcher_.Matches(a_pair.second);
+ }
+ StringMatchResultListener first_inner_listener;
+ if (!first_matcher_.MatchAndExplain(a_pair.first,
+ &first_inner_listener)) {
+ *listener << "whose first field does not match";
+ PrintIfNotEmpty(first_inner_listener.str(), listener->stream());
+ return false;
+ }
+ StringMatchResultListener second_inner_listener;
+ if (!second_matcher_.MatchAndExplain(a_pair.second,
+ &second_inner_listener)) {
+ *listener << "whose second field does not match";
+ PrintIfNotEmpty(second_inner_listener.str(), listener->stream());
+ return false;
+ }
+ ExplainSuccess(first_inner_listener.str(), second_inner_listener.str(),
+ listener);
+ return true;
+ }
+
+ private:
+ void ExplainSuccess(const internal::string& first_explanation,
+ const internal::string& second_explanation,
+ MatchResultListener* listener) const {
+ *listener << "whose both fields match";
+ if (first_explanation != "") {
+ *listener << ", where the first field is a value " << first_explanation;
+ }
+ if (second_explanation != "") {
+ *listener << ", ";
+ if (first_explanation != "") {
+ *listener << "and ";
+ } else {
+ *listener << "where ";
+ }
+ *listener << "the second field is a value " << second_explanation;
+ }
+ }
+
+ const Matcher<const FirstType&> first_matcher_;
+ const Matcher<const SecondType&> second_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(PairMatcherImpl);
+};
+
+// Implements polymorphic Pair(first_matcher, second_matcher).
+template <typename FirstMatcher, typename SecondMatcher>
+class PairMatcher {
+ public:
+ PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher)
+ : first_matcher_(first_matcher), second_matcher_(second_matcher) {}
+
+ template <typename PairType>
+ operator Matcher<PairType> () const {
+ return MakeMatcher(
+ new PairMatcherImpl<PairType>(
+ first_matcher_, second_matcher_));
+ }
+
+ private:
+ const FirstMatcher first_matcher_;
+ const SecondMatcher second_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(PairMatcher);
+};
+
+// Implements ElementsAre() and ElementsAreArray().
+template <typename Container>
+class ElementsAreMatcherImpl : public MatcherInterface<Container> {
+ public:
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef internal::StlContainerView<RawContainer> View;
+ typedef typename View::type StlContainer;
+ typedef typename View::const_reference StlContainerReference;
+ typedef typename StlContainer::value_type Element;
+
+ // Constructs the matcher from a sequence of element values or
+ // element matchers.
+ template <typename InputIter>
+ ElementsAreMatcherImpl(InputIter first, size_t a_count) {
+ matchers_.reserve(a_count);
+ InputIter it = first;
+ for (size_t i = 0; i != a_count; ++i, ++it) {
+ matchers_.push_back(MatcherCast<const Element&>(*it));
+ }
+ }
+
+ // Describes what this matcher does.
+ virtual void DescribeTo(::std::ostream* os) const {
+ if (count() == 0) {
+ *os << "is empty";
+ } else if (count() == 1) {
+ *os << "has 1 element that ";
+ matchers_[0].DescribeTo(os);
+ } else {
+ *os << "has " << Elements(count()) << " where\n";
+ for (size_t i = 0; i != count(); ++i) {
+ *os << "element #" << i << " ";
+ matchers_[i].DescribeTo(os);
+ if (i + 1 < count()) {
+ *os << ",\n";
+ }
+ }
+ }
+ }
+
+ // Describes what the negation of this matcher does.
+ virtual void DescribeNegationTo(::std::ostream* os) const {
+ if (count() == 0) {
+ *os << "isn't empty";
+ return;
+ }
+
+ *os << "doesn't have " << Elements(count()) << ", or\n";
+ for (size_t i = 0; i != count(); ++i) {
+ *os << "element #" << i << " ";
+ matchers_[i].DescribeNegationTo(os);
+ if (i + 1 < count()) {
+ *os << ", or\n";
+ }
+ }
+ }
+
+ virtual bool MatchAndExplain(Container container,
+ MatchResultListener* listener) const {
+ StlContainerReference stl_container = View::ConstReference(container);
+ const size_t actual_count = stl_container.size();
+ if (actual_count != count()) {
+ // The element count doesn't match. If the container is empty,
+ // there's no need to explain anything as Google Mock already
+ // prints the empty container. Otherwise we just need to show
+ // how many elements there actually are.
+ if (actual_count != 0) {
+ *listener << "which has " << Elements(actual_count);
+ }
+ return false;
+ }
+
+ typename StlContainer::const_iterator it = stl_container.begin();
+ // explanations[i] is the explanation of the element at index i.
+ std::vector<internal::string> explanations(count());
+ for (size_t i = 0; i != count(); ++it, ++i) {
+ StringMatchResultListener s;
+ if (matchers_[i].MatchAndExplain(*it, &s)) {
+ explanations[i] = s.str();
+ } else {
+ // The container has the right size but the i-th element
+ // doesn't match its expectation.
+ *listener << "whose element #" << i << " doesn't match";
+ PrintIfNotEmpty(s.str(), listener->stream());
+ return false;
+ }
+ }
+
+ // Every element matches its expectation. We need to explain why
+ // (the obvious ones can be skipped).
+ bool reason_printed = false;
+ for (size_t i = 0; i != count(); ++i) {
+ const internal::string& s = explanations[i];
+ if (!s.empty()) {
+ if (reason_printed) {
+ *listener << ",\nand ";
+ }
+ *listener << "whose element #" << i << " matches, " << s;
+ reason_printed = true;
+ }
+ }
+
+ return true;
+ }
+
+ private:
+ static Message Elements(size_t count) {
+ return Message() << count << (count == 1 ? " element" : " elements");
+ }
+
+ size_t count() const { return matchers_.size(); }
+ std::vector<Matcher<const Element&> > matchers_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcherImpl);
+};
+
+// Implements ElementsAre() of 0 arguments.
+class ElementsAreMatcher0 {
+ public:
+ ElementsAreMatcher0() {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+ const Matcher<const Element&>* const matchers = NULL;
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 0));
+ }
+};
+
+// Implements ElementsAreArray().
+template <typename T>
+class ElementsAreArrayMatcher {
+ public:
+ ElementsAreArrayMatcher(const T* first, size_t count) :
+ first_(first), count_(count) {}
+
+ template <typename Container>
+ operator Matcher<Container>() const {
+ typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
+ typedef typename internal::StlContainerView<RawContainer>::type::value_type
+ Element;
+
+ return MakeMatcher(new ElementsAreMatcherImpl<Container>(first_, count_));
+ }
+
+ private:
+ const T* const first_;
+ const size_t count_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreArrayMatcher);
+};
+
+// Returns the description for a matcher defined using the MATCHER*()
+// macro where the user-supplied description string is "", if
+// 'negation' is false; otherwise returns the description of the
+// negation of the matcher. 'param_values' contains a list of strings
+// that are the print-out of the matcher's parameters.
+string FormatMatcherDescription(bool negation, const char* matcher_name,
+ const Strings& param_values);
+
+} // namespace internal
+
+// Implements MatcherCast().
+template <typename T, typename M>
+inline Matcher<T> MatcherCast(M matcher) {
+ return internal::MatcherCastImpl<T, M>::Cast(matcher);
+}
+
+// _ is a matcher that matches anything of any type.
+//
+// This definition is fine as:
+//
+// 1. The C++ standard permits using the name _ in a namespace that
+// is not the global namespace or ::std.
+// 2. The AnythingMatcher class has no data member or constructor,
+// so it's OK to create global variables of this type.
+// 3. c-style has approved of using _ in this case.
+const internal::AnythingMatcher _ = {};
+// Creates a matcher that matches any value of the given type T.
+template <typename T>
+inline Matcher<T> A() { return MakeMatcher(new internal::AnyMatcherImpl<T>()); }
+
+// Creates a matcher that matches any value of the given type T.
+template <typename T>
+inline Matcher<T> An() { return A<T>(); }
+
+// Creates a polymorphic matcher that matches anything equal to x.
+// Note: if the parameter of Eq() were declared as const T&, Eq("foo")
+// wouldn't compile.
+template <typename T>
+inline internal::EqMatcher<T> Eq(T x) { return internal::EqMatcher<T>(x); }
+
+// Constructs a Matcher<T> from a 'value' of type T. The constructed
+// matcher matches any value that's equal to 'value'.
+template <typename T>
+Matcher<T>::Matcher(T value) { *this = Eq(value); }
+
+// Creates a monomorphic matcher that matches anything with type Lhs
+// and equal to rhs. A user may need to use this instead of Eq(...)
+// in order to resolve an overloading ambiguity.
+//
+// TypedEq<T>(x) is just a convenient short-hand for Matcher<T>(Eq(x))
+// or Matcher<T>(x), but more readable than the latter.
+//
+// We could define similar monomorphic matchers for other comparison
+// operations (e.g. TypedLt, TypedGe, and etc), but decided not to do
+// it yet as those are used much less than Eq() in practice. A user
+// can always write Matcher<T>(Lt(5)) to be explicit about the type,
+// for example.
+template <typename Lhs, typename Rhs>
+inline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }
+
+// Creates a polymorphic matcher that matches anything >= x.
+template <typename Rhs>
+inline internal::GeMatcher<Rhs> Ge(Rhs x) {
+ return internal::GeMatcher<Rhs>(x);
+}
+
+// Creates a polymorphic matcher that matches anything > x.
+template <typename Rhs>
+inline internal::GtMatcher<Rhs> Gt(Rhs x) {
+ return internal::GtMatcher<Rhs>(x);
+}
+
+// Creates a polymorphic matcher that matches anything <= x.
+template <typename Rhs>
+inline internal::LeMatcher<Rhs> Le(Rhs x) {
+ return internal::LeMatcher<Rhs>(x);
+}
+
+// Creates a polymorphic matcher that matches anything < x.
+template <typename Rhs>
+inline internal::LtMatcher<Rhs> Lt(Rhs x) {
+ return internal::LtMatcher<Rhs>(x);
+}
+
+// Creates a polymorphic matcher that matches anything != x.
+template <typename Rhs>
+inline internal::NeMatcher<Rhs> Ne(Rhs x) {
+ return internal::NeMatcher<Rhs>(x);
+}
+
+// Creates a polymorphic matcher that matches any NULL pointer.
+inline PolymorphicMatcher<internal::IsNullMatcher > IsNull() {
+ return MakePolymorphicMatcher(internal::IsNullMatcher());
+}
+
+// Creates a polymorphic matcher that matches any non-NULL pointer.
+// This is convenient as Not(NULL) doesn't compile (the compiler
+// thinks that that expression is comparing a pointer with an integer).
+inline PolymorphicMatcher<internal::NotNullMatcher > NotNull() {
+ return MakePolymorphicMatcher(internal::NotNullMatcher());
+}
+
+// Creates a polymorphic matcher that matches any argument that
+// references variable x.
+template <typename T>
+inline internal::RefMatcher<T&> Ref(T& x) { // NOLINT
+ return internal::RefMatcher<T&>(x);
+}
+
+// Creates a matcher that matches any double argument approximately
+// equal to rhs, where two NANs are considered unequal.
+inline internal::FloatingEqMatcher<double> DoubleEq(double rhs) {
+ return internal::FloatingEqMatcher<double>(rhs, false);
+}
+
+// Creates a matcher that matches any double argument approximately
+// equal to rhs, including NaN values when rhs is NaN.
+inline internal::FloatingEqMatcher<double> NanSensitiveDoubleEq(double rhs) {
+ return internal::FloatingEqMatcher<double>(rhs, true);
+}
+
+// Creates a matcher that matches any float argument approximately
+// equal to rhs, where two NANs are considered unequal.
+inline internal::FloatingEqMatcher<float> FloatEq(float rhs) {
+ return internal::FloatingEqMatcher<float>(rhs, false);
+}
+
+// Creates a matcher that matches any double argument approximately
+// equal to rhs, including NaN values when rhs is NaN.
+inline internal::FloatingEqMatcher<float> NanSensitiveFloatEq(float rhs) {
+ return internal::FloatingEqMatcher<float>(rhs, true);
+}
+
+// Creates a matcher that matches a pointer (raw or smart) that points
+// to a value that matches inner_matcher.
+template <typename InnerMatcher>
+inline internal::PointeeMatcher<InnerMatcher> Pointee(
+ const InnerMatcher& inner_matcher) {
+ return internal::PointeeMatcher<InnerMatcher>(inner_matcher);
+}
+
+// Creates a matcher that matches an object whose given field matches
+// 'matcher'. For example,
+// Field(&Foo::number, Ge(5))
+// matches a Foo object x iff x.number >= 5.
+template <typename Class, typename FieldType, typename FieldMatcher>
+inline PolymorphicMatcher<
+ internal::FieldMatcher<Class, FieldType> > Field(
+ FieldType Class::*field, const FieldMatcher& matcher) {
+ return MakePolymorphicMatcher(
+ internal::FieldMatcher<Class, FieldType>(
+ field, MatcherCast<const FieldType&>(matcher)));
+ // The call to MatcherCast() is required for supporting inner
+ // matchers of compatible types. For example, it allows
+ // Field(&Foo::bar, m)
+ // to compile where bar is an int32 and m is a matcher for int64.
+}
+
+// Creates a matcher that matches an object whose given property
+// matches 'matcher'. For example,
+// Property(&Foo::str, StartsWith("hi"))
+// matches a Foo object x iff x.str() starts with "hi".
+template <typename Class, typename PropertyType, typename PropertyMatcher>
+inline PolymorphicMatcher<
+ internal::PropertyMatcher<Class, PropertyType> > Property(
+ PropertyType (Class::*property)() const, const PropertyMatcher& matcher) {
+ return MakePolymorphicMatcher(
+ internal::PropertyMatcher<Class, PropertyType>(
+ property,
+ MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
+ // The call to MatcherCast() is required for supporting inner
+ // matchers of compatible types. For example, it allows
+ // Property(&Foo::bar, m)
+ // to compile where bar() returns an int32 and m is a matcher for int64.
+}
+
+// Creates a matcher that matches an object iff the result of applying
+// a callable to x matches 'matcher'.
+// For example,
+// ResultOf(f, StartsWith("hi"))
+// matches a Foo object x iff f(x) starts with "hi".
+// callable parameter can be a function, function pointer, or a functor.
+// Callable has to satisfy the following conditions:
+// * It is required to keep no state affecting the results of
+// the calls on it and make no assumptions about how many calls
+// will be made. Any state it keeps must be protected from the
+// concurrent access.
+// * If it is a function object, it has to define type result_type.
+// We recommend deriving your functor classes from std::unary_function.
+template <typename Callable, typename ResultOfMatcher>
+internal::ResultOfMatcher<Callable> ResultOf(
+ Callable callable, const ResultOfMatcher& matcher) {
+ return internal::ResultOfMatcher<Callable>(
+ callable,
+ MatcherCast<typename internal::CallableTraits<Callable>::ResultType>(
+ matcher));
+ // The call to MatcherCast() is required for supporting inner
+ // matchers of compatible types. For example, it allows
+ // ResultOf(Function, m)
+ // to compile where Function() returns an int32 and m is a matcher for int64.
+}
+
+// String matchers.
+
+// Matches a string equal to str.
+inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >
+ StrEq(const internal::string& str) {
+ return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(
+ str, true, true));
+}
+
+// Matches a string not equal to str.
+inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >
+ StrNe(const internal::string& str) {
+ return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(
+ str, false, true));
+}
+
+// Matches a string equal to str, ignoring case.
+inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >
+ StrCaseEq(const internal::string& str) {
+ return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(
+ str, true, false));
+}
+
+// Matches a string not equal to str, ignoring case.
+inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >
+ StrCaseNe(const internal::string& str) {
+ return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(
+ str, false, false));
+}
+
+// Creates a matcher that matches any string, std::string, or C string
+// that contains the given substring.
+inline PolymorphicMatcher<internal::HasSubstrMatcher<internal::string> >
+ HasSubstr(const internal::string& substring) {
+ return MakePolymorphicMatcher(internal::HasSubstrMatcher<internal::string>(
+ substring));
+}
+
+// Matches a string that starts with 'prefix' (case-sensitive).
+inline PolymorphicMatcher<internal::StartsWithMatcher<internal::string> >
+ StartsWith(const internal::string& prefix) {
+ return MakePolymorphicMatcher(internal::StartsWithMatcher<internal::string>(
+ prefix));
+}
+
+// Matches a string that ends with 'suffix' (case-sensitive).
+inline PolymorphicMatcher<internal::EndsWithMatcher<internal::string> >
+ EndsWith(const internal::string& suffix) {
+ return MakePolymorphicMatcher(internal::EndsWithMatcher<internal::string>(
+ suffix));
+}
+
+// Matches a string that fully matches regular expression 'regex'.
+// The matcher takes ownership of 'regex'.
+inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
+ const internal::RE* regex) {
+ return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true));
+}
+inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
+ const internal::string& regex) {
+ return MatchesRegex(new internal::RE(regex));
+}
+
+// Matches a string that contains regular expression 'regex'.
+// The matcher takes ownership of 'regex'.
+inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
+ const internal::RE* regex) {
+ return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false));
+}
+inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
+ const internal::string& regex) {
+ return ContainsRegex(new internal::RE(regex));
+}
+
+#if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
+// Wide string matchers.
+
+// Matches a string equal to str.
+inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >
+ StrEq(const internal::wstring& str) {
+ return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(
+ str, true, true));
+}
+
+// Matches a string not equal to str.
+inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >
+ StrNe(const internal::wstring& str) {
+ return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(
+ str, false, true));
+}
+
+// Matches a string equal to str, ignoring case.
+inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >
+ StrCaseEq(const internal::wstring& str) {
+ return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(
+ str, true, false));
+}
+
+// Matches a string not equal to str, ignoring case.
+inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >
+ StrCaseNe(const internal::wstring& str) {
+ return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(
+ str, false, false));
+}
+
+// Creates a matcher that matches any wstring, std::wstring, or C wide string
+// that contains the given substring.
+inline PolymorphicMatcher<internal::HasSubstrMatcher<internal::wstring> >
+ HasSubstr(const internal::wstring& substring) {
+ return MakePolymorphicMatcher(internal::HasSubstrMatcher<internal::wstring>(
+ substring));
+}
+
+// Matches a string that starts with 'prefix' (case-sensitive).
+inline PolymorphicMatcher<internal::StartsWithMatcher<internal::wstring> >
+ StartsWith(const internal::wstring& prefix) {
+ return MakePolymorphicMatcher(internal::StartsWithMatcher<internal::wstring>(
+ prefix));
+}
+
+// Matches a string that ends with 'suffix' (case-sensitive).
+inline PolymorphicMatcher<internal::EndsWithMatcher<internal::wstring> >
+ EndsWith(const internal::wstring& suffix) {
+ return MakePolymorphicMatcher(internal::EndsWithMatcher<internal::wstring>(
+ suffix));
+}
+
+#endif // GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
+
+// Creates a polymorphic matcher that matches a 2-tuple where the
+// first field == the second field.
+inline internal::Eq2Matcher Eq() { return internal::Eq2Matcher(); }
+
+// Creates a polymorphic matcher that matches a 2-tuple where the
+// first field >= the second field.
+inline internal::Ge2Matcher Ge() { return internal::Ge2Matcher(); }
+
+// Creates a polymorphic matcher that matches a 2-tuple where the
+// first field > the second field.
+inline internal::Gt2Matcher Gt() { return internal::Gt2Matcher(); }
+
+// Creates a polymorphic matcher that matches a 2-tuple where the
+// first field <= the second field.
+inline internal::Le2Matcher Le() { return internal::Le2Matcher(); }
+
+// Creates a polymorphic matcher that matches a 2-tuple where the
+// first field < the second field.
+inline internal::Lt2Matcher Lt() { return internal::Lt2Matcher(); }
+
+// Creates a polymorphic matcher that matches a 2-tuple where the
+// first field != the second field.
+inline internal::Ne2Matcher Ne() { return internal::Ne2Matcher(); }
+
+// Creates a matcher that matches any value of type T that m doesn't
+// match.
+template <typename InnerMatcher>
+inline internal::NotMatcher<InnerMatcher> Not(InnerMatcher m) {
+ return internal::NotMatcher<InnerMatcher>(m);
+}
+
+// Returns a matcher that matches anything that satisfies the given
+// predicate. The predicate can be any unary function or functor
+// whose return type can be implicitly converted to bool.
+template <typename Predicate>
+inline PolymorphicMatcher<internal::TrulyMatcher<Predicate> >
+Truly(Predicate pred) {
+ return MakePolymorphicMatcher(internal::TrulyMatcher<Predicate>(pred));
+}
+
+// Returns a matcher that matches an equal container.
+// This matcher behaves like Eq(), but in the event of mismatch lists the
+// values that are included in one container but not the other. (Duplicate
+// values and order differences are not explained.)
+template <typename Container>
+inline PolymorphicMatcher<internal::ContainerEqMatcher< // NOLINT
+ GTEST_REMOVE_CONST_(Container)> >
+ ContainerEq(const Container& rhs) {
+ // This following line is for working around a bug in MSVC 8.0,
+ // which causes Container to be a const type sometimes.
+ typedef GTEST_REMOVE_CONST_(Container) RawContainer;
+ return MakePolymorphicMatcher(
+ internal::ContainerEqMatcher<RawContainer>(rhs));
+}
+
+// Matches an STL-style container or a native array that contains the
+// same number of elements as in rhs, where its i-th element and rhs's
+// i-th element (as a pair) satisfy the given pair matcher, for all i.
+// TupleMatcher must be able to be safely cast to Matcher<tuple<const
+// T1&, const T2&> >, where T1 and T2 are the types of elements in the
+// LHS container and the RHS container respectively.
+template <typename TupleMatcher, typename Container>
+inline internal::PointwiseMatcher<TupleMatcher,
+ GTEST_REMOVE_CONST_(Container)>
+Pointwise(const TupleMatcher& tuple_matcher, const Container& rhs) {
+ // This following line is for working around a bug in MSVC 8.0,
+ // which causes Container to be a const type sometimes.
+ typedef GTEST_REMOVE_CONST_(Container) RawContainer;
+ return internal::PointwiseMatcher<TupleMatcher, RawContainer>(
+ tuple_matcher, rhs);
+}
+
+// Matches an STL-style container or a native array that contains at
+// least one element matching the given value or matcher.
+//
+// Examples:
+// ::std::set<int> page_ids;
+// page_ids.insert(3);
+// page_ids.insert(1);
+// EXPECT_THAT(page_ids, Contains(1));
+// EXPECT_THAT(page_ids, Contains(Gt(2)));
+// EXPECT_THAT(page_ids, Not(Contains(4)));
+//
+// ::std::map<int, size_t> page_lengths;
+// page_lengths[1] = 100;
+// EXPECT_THAT(page_lengths,
+// Contains(::std::pair<const int, size_t>(1, 100)));
+//
+// const char* user_ids[] = { "joe", "mike", "tom" };
+// EXPECT_THAT(user_ids, Contains(Eq(::std::string("tom"))));
+template <typename M>
+inline internal::ContainsMatcher<M> Contains(M matcher) {
+ return internal::ContainsMatcher<M>(matcher);
+}
+
+// Matches an STL-style container or a native array that contains only
+// elements matching the given value or matcher.
+//
+// Each(m) is semantically equivalent to Not(Contains(Not(m))). Only
+// the messages are different.
+//
+// Examples:
+// ::std::set<int> page_ids;
+// // Each(m) matches an empty container, regardless of what m is.
+// EXPECT_THAT(page_ids, Each(Eq(1)));
+// EXPECT_THAT(page_ids, Each(Eq(77)));
+//
+// page_ids.insert(3);
+// EXPECT_THAT(page_ids, Each(Gt(0)));
+// EXPECT_THAT(page_ids, Not(Each(Gt(4))));
+// page_ids.insert(1);
+// EXPECT_THAT(page_ids, Not(Each(Lt(2))));
+//
+// ::std::map<int, size_t> page_lengths;
+// page_lengths[1] = 100;
+// page_lengths[2] = 200;
+// page_lengths[3] = 300;
+// EXPECT_THAT(page_lengths, Not(Each(Pair(1, 100))));
+// EXPECT_THAT(page_lengths, Each(Key(Le(3))));
+//
+// const char* user_ids[] = { "joe", "mike", "tom" };
+// EXPECT_THAT(user_ids, Not(Each(Eq(::std::string("tom")))));
+template <typename M>
+inline internal::EachMatcher<M> Each(M matcher) {
+ return internal::EachMatcher<M>(matcher);
+}
+
+// Key(inner_matcher) matches an std::pair whose 'first' field matches
+// inner_matcher. For example, Contains(Key(Ge(5))) can be used to match an
+// std::map that contains at least one element whose key is >= 5.
+template <typename M>
+inline internal::KeyMatcher<M> Key(M inner_matcher) {
+ return internal::KeyMatcher<M>(inner_matcher);
+}
+
+// Pair(first_matcher, second_matcher) matches a std::pair whose 'first' field
+// matches first_matcher and whose 'second' field matches second_matcher. For
+// example, EXPECT_THAT(map_type, ElementsAre(Pair(Ge(5), "foo"))) can be used
+// to match a std::map<int, string> that contains exactly one element whose key
+// is >= 5 and whose value equals "foo".
+template <typename FirstMatcher, typename SecondMatcher>
+inline internal::PairMatcher<FirstMatcher, SecondMatcher>
+Pair(FirstMatcher first_matcher, SecondMatcher second_matcher) {
+ return internal::PairMatcher<FirstMatcher, SecondMatcher>(
+ first_matcher, second_matcher);
+}
+
+// Returns a predicate that is satisfied by anything that matches the
+// given matcher.
+template <typename M>
+inline internal::MatcherAsPredicate<M> Matches(M matcher) {
+ return internal::MatcherAsPredicate<M>(matcher);
+}
+
+// Returns true iff the value matches the matcher.
+template <typename T, typename M>
+inline bool Value(const T& value, M matcher) {
+ return testing::Matches(matcher)(value);
+}
+
+// Matches the value against the given matcher and explains the match
+// result to listener.
+template <typename T, typename M>
+inline bool ExplainMatchResult(
+ M matcher, const T& value, MatchResultListener* listener) {
+ return SafeMatcherCast<const T&>(matcher).MatchAndExplain(value, listener);
+}
+
+// AllArgs(m) is a synonym of m. This is useful in
+//
+// EXPECT_CALL(foo, Bar(_, _)).With(AllArgs(Eq()));
+//
+// which is easier to read than
+//
+// EXPECT_CALL(foo, Bar(_, _)).With(Eq());
+template <typename InnerMatcher>
+inline InnerMatcher AllArgs(const InnerMatcher& matcher) { return matcher; }
+
+// These macros allow using matchers to check values in Google Test
+// tests. ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher)
+// succeed iff the value matches the matcher. If the assertion fails,
+// the value and the description of the matcher will be printed.
+#define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\
+ ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
+#define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\
+ ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
+
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
diff --git a/lib/gtest/include/gmock/gmock-more-actions.h b/lib/gtest/include/gmock/gmock-more-actions.h
new file mode 100644
index 0000000..fc5e5ca
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-more-actions.h
@@ -0,0 +1,233 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements some actions that depend on gmock-generated-actions.h.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
+
+#include <algorithm>
+
+#include "gmock/gmock-generated-actions.h"
+
+namespace testing {
+namespace internal {
+
+// Implements the Invoke(f) action. The template argument
+// FunctionImpl is the implementation type of f, which can be either a
+// function pointer or a functor. Invoke(f) can be used as an
+// Action<F> as long as f's type is compatible with F (i.e. f can be
+// assigned to a tr1::function<F>).
+template <typename FunctionImpl>
+class InvokeAction {
+ public:
+ // The c'tor makes a copy of function_impl (either a function
+ // pointer or a functor).
+ explicit InvokeAction(FunctionImpl function_impl)
+ : function_impl_(function_impl) {}
+
+ template <typename Result, typename ArgumentTuple>
+ Result Perform(const ArgumentTuple& args) {
+ return InvokeHelper<Result, ArgumentTuple>::Invoke(function_impl_, args);
+ }
+
+ private:
+ FunctionImpl function_impl_;
+
+ GTEST_DISALLOW_ASSIGN_(InvokeAction);
+};
+
+// Implements the Invoke(object_ptr, &Class::Method) action.
+template <class Class, typename MethodPtr>
+class InvokeMethodAction {
+ public:
+ InvokeMethodAction(Class* obj_ptr, MethodPtr method_ptr)
+ : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}
+
+ template <typename Result, typename ArgumentTuple>
+ Result Perform(const ArgumentTuple& args) const {
+ return InvokeHelper<Result, ArgumentTuple>::InvokeMethod(
+ obj_ptr_, method_ptr_, args);
+ }
+
+ private:
+ Class* const obj_ptr_;
+ const MethodPtr method_ptr_;
+
+ GTEST_DISALLOW_ASSIGN_(InvokeMethodAction);
+};
+
+} // namespace internal
+
+// Various overloads for Invoke().
+
+// Creates an action that invokes 'function_impl' with the mock
+// function's arguments.
+template <typename FunctionImpl>
+PolymorphicAction<internal::InvokeAction<FunctionImpl> > Invoke(
+ FunctionImpl function_impl) {
+ return MakePolymorphicAction(
+ internal::InvokeAction<FunctionImpl>(function_impl));
+}
+
+// Creates an action that invokes the given method on the given object
+// with the mock function's arguments.
+template <class Class, typename MethodPtr>
+PolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr> > Invoke(
+ Class* obj_ptr, MethodPtr method_ptr) {
+ return MakePolymorphicAction(
+ internal::InvokeMethodAction<Class, MethodPtr>(obj_ptr, method_ptr));
+}
+
+// WithoutArgs(inner_action) can be used in a mock function with a
+// non-empty argument list to perform inner_action, which takes no
+// argument. In other words, it adapts an action accepting no
+// argument to one that accepts (and ignores) arguments.
+template <typename InnerAction>
+inline internal::WithArgsAction<InnerAction>
+WithoutArgs(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction>(action);
+}
+
+// WithArg<k>(an_action) creates an action that passes the k-th
+// (0-based) argument of the mock function to an_action and performs
+// it. It adapts an action accepting one argument to one that accepts
+// multiple arguments. For convenience, we also provide
+// WithArgs<k>(an_action) (defined below) as a synonym.
+template <int k, typename InnerAction>
+inline internal::WithArgsAction<InnerAction, k>
+WithArg(const InnerAction& action) {
+ return internal::WithArgsAction<InnerAction, k>(action);
+}
+
+// The ACTION*() macros trigger warning C4100 (unreferenced formal
+// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
+// the macro definition, as the warnings are generated when the macro
+// is expanded and macro expansion cannot contain #pragma. Therefore
+// we suppress them here.
+#ifdef _MSC_VER
+# pragma warning(push)
+# pragma warning(disable:4100)
+#endif
+
+// Action ReturnArg<k>() returns the k-th argument of the mock function.
+ACTION_TEMPLATE(ReturnArg,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_0_VALUE_PARAMS()) {
+ return std::tr1::get<k>(args);
+}
+
+// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the
+// mock function to *pointer.
+ACTION_TEMPLATE(SaveArg,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_1_VALUE_PARAMS(pointer)) {
+ *pointer = ::std::tr1::get<k>(args);
+}
+
+// Action SaveArgPointee<k>(pointer) saves the value pointed to
+// by the k-th (0-based) argument of the mock function to *pointer.
+ACTION_TEMPLATE(SaveArgPointee,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_1_VALUE_PARAMS(pointer)) {
+ *pointer = *::std::tr1::get<k>(args);
+}
+
+// Action SetArgReferee<k>(value) assigns 'value' to the variable
+// referenced by the k-th (0-based) argument of the mock function.
+ACTION_TEMPLATE(SetArgReferee,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_1_VALUE_PARAMS(value)) {
+ typedef typename ::std::tr1::tuple_element<k, args_type>::type argk_type;
+ // Ensures that argument #k is a reference. If you get a compiler
+ // error on the next line, you are using SetArgReferee<k>(value) in
+ // a mock function whose k-th (0-based) argument is not a reference.
+ GTEST_COMPILE_ASSERT_(internal::is_reference<argk_type>::value,
+ SetArgReferee_must_be_used_with_a_reference_argument);
+ ::std::tr1::get<k>(args) = value;
+}
+
+// Action SetArrayArgument<k>(first, last) copies the elements in
+// source range [first, last) to the array pointed to by the k-th
+// (0-based) argument, which can be either a pointer or an
+// iterator. The action does not take ownership of the elements in the
+// source range.
+ACTION_TEMPLATE(SetArrayArgument,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_2_VALUE_PARAMS(first, last)) {
+ // Microsoft compiler deprecates ::std::copy, so we want to suppress warning
+ // 4996 (Function call with parameters that may be unsafe) there.
+#ifdef _MSC_VER
+# pragma warning(push) // Saves the current warning state.
+# pragma warning(disable:4996) // Temporarily disables warning 4996.
+#endif
+ ::std::copy(first, last, ::std::tr1::get<k>(args));
+#ifdef _MSC_VER
+# pragma warning(pop) // Restores the warning state.
+#endif
+}
+
+// Action DeleteArg<k>() deletes the k-th (0-based) argument of the mock
+// function.
+ACTION_TEMPLATE(DeleteArg,
+ HAS_1_TEMPLATE_PARAMS(int, k),
+ AND_0_VALUE_PARAMS()) {
+ delete ::std::tr1::get<k>(args);
+}
+
+// This action returns the value pointed to by 'pointer'.
+ACTION_P(ReturnPointee, pointer) { return *pointer; }
+
+// Action Throw(exception) can be used in a mock function of any type
+// to throw the given exception. Any copyable value can be thrown.
+#if GTEST_HAS_EXCEPTIONS
+
+// Suppresses the 'unreachable code' warning that VC generates in opt modes.
+# ifdef _MSC_VER
+# pragma warning(push) // Saves the current warning state.
+# pragma warning(disable:4702) // Temporarily disables warning 4702.
+# endif
+ACTION_P(Throw, exception) { throw exception; }
+# ifdef _MSC_VER
+# pragma warning(pop) // Restores the warning state.
+# endif
+
+#endif // GTEST_HAS_EXCEPTIONS
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
diff --git a/lib/gtest/include/gmock/gmock-spec-builders.h b/lib/gtest/include/gmock/gmock-spec-builders.h
new file mode 100644
index 0000000..400d4d7
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock-spec-builders.h
@@ -0,0 +1,1749 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements the ON_CALL() and EXPECT_CALL() macros.
+//
+// A user can use the ON_CALL() macro to specify the default action of
+// a mock method. The syntax is:
+//
+// ON_CALL(mock_object, Method(argument-matchers))
+// .With(multi-argument-matcher)
+// .WillByDefault(action);
+//
+// where the .With() clause is optional.
+//
+// A user can use the EXPECT_CALL() macro to specify an expectation on
+// a mock method. The syntax is:
+//
+// EXPECT_CALL(mock_object, Method(argument-matchers))
+// .With(multi-argument-matchers)
+// .Times(cardinality)
+// .InSequence(sequences)
+// .After(expectations)
+// .WillOnce(action)
+// .WillRepeatedly(action)
+// .RetiresOnSaturation();
+//
+// where all clauses are optional, and .InSequence()/.After()/
+// .WillOnce() can appear any number of times.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
+
+#include <map>
+#include <set>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "gmock/gmock-actions.h"
+#include "gmock/gmock-cardinalities.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/internal/gmock-internal-utils.h"
+#include "gmock/internal/gmock-port.h"
+#include "gtest/gtest.h"
+
+namespace testing {
+
+// An abstract handle of an expectation.
+class Expectation;
+
+// A set of expectation handles.
+class ExpectationSet;
+
+// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
+// and MUST NOT BE USED IN USER CODE!!!
+namespace internal {
+
+// Implements a mock function.
+template <typename F> class FunctionMocker;
+
+// Base class for expectations.
+class ExpectationBase;
+
+// Implements an expectation.
+template <typename F> class TypedExpectation;
+
+// Helper class for testing the Expectation class template.
+class ExpectationTester;
+
+// Base class for function mockers.
+template <typename F> class FunctionMockerBase;
+
+// Protects the mock object registry (in class Mock), all function
+// mockers, and all expectations.
+//
+// The reason we don't use more fine-grained protection is: when a
+// mock function Foo() is called, it needs to consult its expectations
+// to see which one should be picked. If another thread is allowed to
+// call a mock function (either Foo() or a different one) at the same
+// time, it could affect the "retired" attributes of Foo()'s
+// expectations when InSequence() is used, and thus affect which
+// expectation gets picked. Therefore, we sequence all mock function
+// calls to ensure the integrity of the mock objects' states.
+GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex);
+
+// Untyped base class for ActionResultHolder<R>.
+class UntypedActionResultHolderBase;
+
+// Abstract base class of FunctionMockerBase. This is the
+// type-agnostic part of the function mocker interface. Its pure
+// virtual methods are implemented by FunctionMockerBase.
+class UntypedFunctionMockerBase {
+ public:
+ UntypedFunctionMockerBase();
+ virtual ~UntypedFunctionMockerBase();
+
+ // Verifies that all expectations on this mock function have been
+ // satisfied. Reports one or more Google Test non-fatal failures
+ // and returns false if not.
+ // L >= g_gmock_mutex
+ bool VerifyAndClearExpectationsLocked();
+
+ // Clears the ON_CALL()s set on this mock function.
+ // L >= g_gmock_mutex
+ virtual void ClearDefaultActionsLocked() = 0;
+
+ // In all of the following Untyped* functions, it's the caller's
+ // responsibility to guarantee the correctness of the arguments'
+ // types.
+
+ // Performs the default action with the given arguments and returns
+ // the action's result. The call description string will be used in
+ // the error message to describe the call in the case the default
+ // action fails.
+ // L = *
+ virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(
+ const void* untyped_args,
+ const string& call_description) const = 0;
+
+ // Performs the given action with the given arguments and returns
+ // the action's result.
+ // L = *
+ virtual UntypedActionResultHolderBase* UntypedPerformAction(
+ const void* untyped_action,
+ const void* untyped_args) const = 0;
+
+ // Writes a message that the call is uninteresting (i.e. neither
+ // explicitly expected nor explicitly unexpected) to the given
+ // ostream.
+ // L < g_gmock_mutex
+ virtual void UntypedDescribeUninterestingCall(const void* untyped_args,
+ ::std::ostream* os) const = 0;
+
+ // Returns the expectation that matches the given function arguments
+ // (or NULL is there's no match); when a match is found,
+ // untyped_action is set to point to the action that should be
+ // performed (or NULL if the action is "do default"), and
+ // is_excessive is modified to indicate whether the call exceeds the
+ // expected number.
+ // L < g_gmock_mutex
+ virtual const ExpectationBase* UntypedFindMatchingExpectation(
+ const void* untyped_args,
+ const void** untyped_action, bool* is_excessive,
+ ::std::ostream* what, ::std::ostream* why) = 0;
+
+ // Prints the given function arguments to the ostream.
+ virtual void UntypedPrintArgs(const void* untyped_args,
+ ::std::ostream* os) const = 0;
+
+ // Sets the mock object this mock method belongs to, and registers
+ // this information in the global mock registry. Will be called
+ // whenever an EXPECT_CALL() or ON_CALL() is executed on this mock
+ // method.
+ // TODO(wan@google.com): rename to SetAndRegisterOwner().
+ // L < g_gmock_mutex
+ void RegisterOwner(const void* mock_obj);
+
+ // Sets the mock object this mock method belongs to, and sets the
+ // name of the mock function. Will be called upon each invocation
+ // of this mock function.
+ // L < g_gmock_mutex
+ void SetOwnerAndName(const void* mock_obj, const char* name);
+
+ // Returns the mock object this mock method belongs to. Must be
+ // called after RegisterOwner() or SetOwnerAndName() has been
+ // called.
+ // L < g_gmock_mutex
+ const void* MockObject() const;
+
+ // Returns the name of this mock method. Must be called after
+ // SetOwnerAndName() has been called.
+ // L < g_gmock_mutex
+ const char* Name() const;
+
+ // Returns the result of invoking this mock function with the given
+ // arguments. This function can be safely called from multiple
+ // threads concurrently. The caller is responsible for deleting the
+ // result.
+ // L < g_gmock_mutex
+ const UntypedActionResultHolderBase* UntypedInvokeWith(
+ const void* untyped_args);
+
+ protected:
+ typedef std::vector<const void*> UntypedOnCallSpecs;
+
+ typedef std::vector<internal::linked_ptr<ExpectationBase> >
+ UntypedExpectations;
+
+ // Returns an Expectation object that references and co-owns exp,
+ // which must be an expectation on this mock function.
+ Expectation GetHandleOf(ExpectationBase* exp);
+
+ // Address of the mock object this mock method belongs to. Only
+ // valid after this mock method has been called or
+ // ON_CALL/EXPECT_CALL has been invoked on it.
+ const void* mock_obj_; // Protected by g_gmock_mutex.
+
+ // Name of the function being mocked. Only valid after this mock
+ // method has been called.
+ const char* name_; // Protected by g_gmock_mutex.
+
+ // All default action specs for this function mocker.
+ UntypedOnCallSpecs untyped_on_call_specs_;
+
+ // All expectations for this function mocker.
+ UntypedExpectations untyped_expectations_;
+}; // class UntypedFunctionMockerBase
+
+// Untyped base class for OnCallSpec<F>.
+class UntypedOnCallSpecBase {
+ public:
+ // The arguments are the location of the ON_CALL() statement.
+ UntypedOnCallSpecBase(const char* a_file, int a_line)
+ : file_(a_file), line_(a_line), last_clause_(kNone) {}
+
+ // Where in the source file was the default action spec defined?
+ const char* file() const { return file_; }
+ int line() const { return line_; }
+
+ protected:
+ // Gives each clause in the ON_CALL() statement a name.
+ enum Clause {
+ // Do not change the order of the enum members! The run-time
+ // syntax checking relies on it.
+ kNone,
+ kWith,
+ kWillByDefault
+ };
+
+ // Asserts that the ON_CALL() statement has a certain property.
+ void AssertSpecProperty(bool property, const string& failure_message) const {
+ Assert(property, file_, line_, failure_message);
+ }
+
+ // Expects that the ON_CALL() statement has a certain property.
+ void ExpectSpecProperty(bool property, const string& failure_message) const {
+ Expect(property, file_, line_, failure_message);
+ }
+
+ const char* file_;
+ int line_;
+
+ // The last clause in the ON_CALL() statement as seen so far.
+ // Initially kNone and changes as the statement is parsed.
+ Clause last_clause_;
+}; // class UntypedOnCallSpecBase
+
+// This template class implements an ON_CALL spec.
+template <typename F>
+class OnCallSpec : public UntypedOnCallSpecBase {
+ public:
+ typedef typename Function<F>::ArgumentTuple ArgumentTuple;
+ typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
+
+ // Constructs an OnCallSpec object from the information inside
+ // the parenthesis of an ON_CALL() statement.
+ OnCallSpec(const char* a_file, int a_line,
+ const ArgumentMatcherTuple& matchers)
+ : UntypedOnCallSpecBase(a_file, a_line),
+ matchers_(matchers),
+ // By default, extra_matcher_ should match anything. However,
+ // we cannot initialize it with _ as that triggers a compiler
+ // bug in Symbian's C++ compiler (cannot decide between two
+ // overloaded constructors of Matcher<const ArgumentTuple&>).
+ extra_matcher_(A<const ArgumentTuple&>()) {
+ }
+
+ // Implements the .With() clause.
+ OnCallSpec& With(const Matcher<const ArgumentTuple&>& m) {
+ // Makes sure this is called at most once.
+ ExpectSpecProperty(last_clause_ < kWith,
+ ".With() cannot appear "
+ "more than once in an ON_CALL().");
+ last_clause_ = kWith;
+
+ extra_matcher_ = m;
+ return *this;
+ }
+
+ // Implements the .WillByDefault() clause.
+ OnCallSpec& WillByDefault(const Action<F>& action) {
+ ExpectSpecProperty(last_clause_ < kWillByDefault,
+ ".WillByDefault() must appear "
+ "exactly once in an ON_CALL().");
+ last_clause_ = kWillByDefault;
+
+ ExpectSpecProperty(!action.IsDoDefault(),
+ "DoDefault() cannot be used in ON_CALL().");
+ action_ = action;
+ return *this;
+ }
+
+ // Returns true iff the given arguments match the matchers.
+ bool Matches(const ArgumentTuple& args) const {
+ return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
+ }
+
+ // Returns the action specified by the user.
+ const Action<F>& GetAction() const {
+ AssertSpecProperty(last_clause_ == kWillByDefault,
+ ".WillByDefault() must appear exactly "
+ "once in an ON_CALL().");
+ return action_;
+ }
+
+ private:
+ // The information in statement
+ //
+ // ON_CALL(mock_object, Method(matchers))
+ // .With(multi-argument-matcher)
+ // .WillByDefault(action);
+ //
+ // is recorded in the data members like this:
+ //
+ // source file that contains the statement => file_
+ // line number of the statement => line_
+ // matchers => matchers_
+ // multi-argument-matcher => extra_matcher_
+ // action => action_
+ ArgumentMatcherTuple matchers_;
+ Matcher<const ArgumentTuple&> extra_matcher_;
+ Action<F> action_;
+}; // class OnCallSpec
+
+// Possible reactions on uninteresting calls. TODO(wan@google.com):
+// rename the enum values to the kFoo style.
+enum CallReaction {
+ ALLOW,
+ WARN,
+ FAIL
+};
+
+} // namespace internal
+
+// Utilities for manipulating mock objects.
+class Mock {
+ public:
+ // The following public methods can be called concurrently.
+
+ // Tells Google Mock to ignore mock_obj when checking for leaked
+ // mock objects.
+ static void AllowLeak(const void* mock_obj);
+
+ // Verifies and clears all expectations on the given mock object.
+ // If the expectations aren't satisfied, generates one or more
+ // Google Test non-fatal failures and returns false.
+ static bool VerifyAndClearExpectations(void* mock_obj);
+
+ // Verifies all expectations on the given mock object and clears its
+ // default actions and expectations. Returns true iff the
+ // verification was successful.
+ static bool VerifyAndClear(void* mock_obj);
+ private:
+ friend class internal::UntypedFunctionMockerBase;
+
+ // Needed for a function mocker to register itself (so that we know
+ // how to clear a mock object).
+ template <typename F>
+ friend class internal::FunctionMockerBase;
+
+ template <typename M>
+ friend class NiceMock;
+
+ template <typename M>
+ friend class StrictMock;
+
+ // Tells Google Mock to allow uninteresting calls on the given mock
+ // object.
+ // L < g_gmock_mutex
+ static void AllowUninterestingCalls(const void* mock_obj);
+
+ // Tells Google Mock to warn the user about uninteresting calls on
+ // the given mock object.
+ // L < g_gmock_mutex
+ static void WarnUninterestingCalls(const void* mock_obj);
+
+ // Tells Google Mock to fail uninteresting calls on the given mock
+ // object.
+ // L < g_gmock_mutex
+ static void FailUninterestingCalls(const void* mock_obj);
+
+ // Tells Google Mock the given mock object is being destroyed and
+ // its entry in the call-reaction table should be removed.
+ // L < g_gmock_mutex
+ static void UnregisterCallReaction(const void* mock_obj);
+
+ // Returns the reaction Google Mock will have on uninteresting calls
+ // made on the given mock object.
+ // L < g_gmock_mutex
+ static internal::CallReaction GetReactionOnUninterestingCalls(
+ const void* mock_obj);
+
+ // Verifies that all expectations on the given mock object have been
+ // satisfied. Reports one or more Google Test non-fatal failures
+ // and returns false if not.
+ // L >= g_gmock_mutex
+ static bool VerifyAndClearExpectationsLocked(void* mock_obj);
+
+ // Clears all ON_CALL()s set on the given mock object.
+ // L >= g_gmock_mutex
+ static void ClearDefaultActionsLocked(void* mock_obj);
+
+ // Registers a mock object and a mock method it owns.
+ // L < g_gmock_mutex
+ static void Register(const void* mock_obj,
+ internal::UntypedFunctionMockerBase* mocker);
+
+ // Tells Google Mock where in the source code mock_obj is used in an
+ // ON_CALL or EXPECT_CALL. In case mock_obj is leaked, this
+ // information helps the user identify which object it is.
+ // L < g_gmock_mutex
+ static void RegisterUseByOnCallOrExpectCall(
+ const void* mock_obj, const char* file, int line);
+
+ // Unregisters a mock method; removes the owning mock object from
+ // the registry when the last mock method associated with it has
+ // been unregistered. This is called only in the destructor of
+ // FunctionMockerBase.
+ // L >= g_gmock_mutex
+ static void UnregisterLocked(internal::UntypedFunctionMockerBase* mocker);
+}; // class Mock
+
+// An abstract handle of an expectation. Useful in the .After()
+// clause of EXPECT_CALL() for setting the (partial) order of
+// expectations. The syntax:
+//
+// Expectation e1 = EXPECT_CALL(...)...;
+// EXPECT_CALL(...).After(e1)...;
+//
+// sets two expectations where the latter can only be matched after
+// the former has been satisfied.
+//
+// Notes:
+// - This class is copyable and has value semantics.
+// - Constness is shallow: a const Expectation object itself cannot
+// be modified, but the mutable methods of the ExpectationBase
+// object it references can be called via expectation_base().
+// - The constructors and destructor are defined out-of-line because
+// the Symbian WINSCW compiler wants to otherwise instantiate them
+// when it sees this class definition, at which point it doesn't have
+// ExpectationBase available yet, leading to incorrect destruction
+// in the linked_ptr (or compilation errors if using a checking
+// linked_ptr).
+class Expectation {
+ public:
+ // Constructs a null object that doesn't reference any expectation.
+ Expectation();
+
+ ~Expectation();
+
+ // This single-argument ctor must not be explicit, in order to support the
+ // Expectation e = EXPECT_CALL(...);
+ // syntax.
+ //
+ // A TypedExpectation object stores its pre-requisites as
+ // Expectation objects, and needs to call the non-const Retire()
+ // method on the ExpectationBase objects they reference. Therefore
+ // Expectation must receive a *non-const* reference to the
+ // ExpectationBase object.
+ Expectation(internal::ExpectationBase& exp); // NOLINT
+
+ // The compiler-generated copy ctor and operator= work exactly as
+ // intended, so we don't need to define our own.
+
+ // Returns true iff rhs references the same expectation as this object does.
+ bool operator==(const Expectation& rhs) const {
+ return expectation_base_ == rhs.expectation_base_;
+ }
+
+ bool operator!=(const Expectation& rhs) const { return !(*this == rhs); }
+
+ private:
+ friend class ExpectationSet;
+ friend class Sequence;
+ friend class ::testing::internal::ExpectationBase;
+ friend class ::testing::internal::UntypedFunctionMockerBase;
+
+ template <typename F>
+ friend class ::testing::internal::FunctionMockerBase;
+
+ template <typename F>
+ friend class ::testing::internal::TypedExpectation;
+
+ // This comparator is needed for putting Expectation objects into a set.
+ class Less {
+ public:
+ bool operator()(const Expectation& lhs, const Expectation& rhs) const {
+ return lhs.expectation_base_.get() < rhs.expectation_base_.get();
+ }
+ };
+
+ typedef ::std::set<Expectation, Less> Set;
+
+ Expectation(
+ const internal::linked_ptr<internal::ExpectationBase>& expectation_base);
+
+ // Returns the expectation this object references.
+ const internal::linked_ptr<internal::ExpectationBase>&
+ expectation_base() const {
+ return expectation_base_;
+ }
+
+ // A linked_ptr that co-owns the expectation this handle references.
+ internal::linked_ptr<internal::ExpectationBase> expectation_base_;
+};
+
+// A set of expectation handles. Useful in the .After() clause of
+// EXPECT_CALL() for setting the (partial) order of expectations. The
+// syntax:
+//
+// ExpectationSet es;
+// es += EXPECT_CALL(...)...;
+// es += EXPECT_CALL(...)...;
+// EXPECT_CALL(...).After(es)...;
+//
+// sets three expectations where the last one can only be matched
+// after the first two have both been satisfied.
+//
+// This class is copyable and has value semantics.
+class ExpectationSet {
+ public:
+ // A bidirectional iterator that can read a const element in the set.
+ typedef Expectation::Set::const_iterator const_iterator;
+
+ // An object stored in the set. This is an alias of Expectation.
+ typedef Expectation::Set::value_type value_type;
+
+ // Constructs an empty set.
+ ExpectationSet() {}
+
+ // This single-argument ctor must not be explicit, in order to support the
+ // ExpectationSet es = EXPECT_CALL(...);
+ // syntax.
+ ExpectationSet(internal::ExpectationBase& exp) { // NOLINT
+ *this += Expectation(exp);
+ }
+
+ // This single-argument ctor implements implicit conversion from
+ // Expectation and thus must not be explicit. This allows either an
+ // Expectation or an ExpectationSet to be used in .After().
+ ExpectationSet(const Expectation& e) { // NOLINT
+ *this += e;
+ }
+
+ // The compiler-generator ctor and operator= works exactly as
+ // intended, so we don't need to define our own.
+
+ // Returns true iff rhs contains the same set of Expectation objects
+ // as this does.
+ bool operator==(const ExpectationSet& rhs) const {
+ return expectations_ == rhs.expectations_;
+ }
+
+ bool operator!=(const ExpectationSet& rhs) const { return !(*this == rhs); }
+
+ // Implements the syntax
+ // expectation_set += EXPECT_CALL(...);
+ ExpectationSet& operator+=(const Expectation& e) {
+ expectations_.insert(e);
+ return *this;
+ }
+
+ int size() const { return static_cast<int>(expectations_.size()); }
+
+ const_iterator begin() const { return expectations_.begin(); }
+ const_iterator end() const { return expectations_.end(); }
+
+ private:
+ Expectation::Set expectations_;
+};
+
+
+// Sequence objects are used by a user to specify the relative order
+// in which the expectations should match. They are copyable (we rely
+// on the compiler-defined copy constructor and assignment operator).
+class Sequence {
+ public:
+ // Constructs an empty sequence.
+ Sequence() : last_expectation_(new Expectation) {}
+
+ // Adds an expectation to this sequence. The caller must ensure
+ // that no other thread is accessing this Sequence object.
+ void AddExpectation(const Expectation& expectation) const;
+
+ private:
+ // The last expectation in this sequence. We use a linked_ptr here
+ // because Sequence objects are copyable and we want the copies to
+ // be aliases. The linked_ptr allows the copies to co-own and share
+ // the same Expectation object.
+ internal::linked_ptr<Expectation> last_expectation_;
+}; // class Sequence
+
+// An object of this type causes all EXPECT_CALL() statements
+// encountered in its scope to be put in an anonymous sequence. The
+// work is done in the constructor and destructor. You should only
+// create an InSequence object on the stack.
+//
+// The sole purpose for this class is to support easy definition of
+// sequential expectations, e.g.
+//
+// {
+// InSequence dummy; // The name of the object doesn't matter.
+//
+// // The following expectations must match in the order they appear.
+// EXPECT_CALL(a, Bar())...;
+// EXPECT_CALL(a, Baz())...;
+// ...
+// EXPECT_CALL(b, Xyz())...;
+// }
+//
+// You can create InSequence objects in multiple threads, as long as
+// they are used to affect different mock objects. The idea is that
+// each thread can create and set up its own mocks as if it's the only
+// thread. However, for clarity of your tests we recommend you to set
+// up mocks in the main thread unless you have a good reason not to do
+// so.
+class InSequence {
+ public:
+ InSequence();
+ ~InSequence();
+ private:
+ bool sequence_created_;
+
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(InSequence); // NOLINT
+} GTEST_ATTRIBUTE_UNUSED_;
+
+namespace internal {
+
+// Points to the implicit sequence introduced by a living InSequence
+// object (if any) in the current thread or NULL.
+extern ThreadLocal<Sequence*> g_gmock_implicit_sequence;
+
+// Base class for implementing expectations.
+//
+// There are two reasons for having a type-agnostic base class for
+// Expectation:
+//
+// 1. We need to store collections of expectations of different
+// types (e.g. all pre-requisites of a particular expectation, all
+// expectations in a sequence). Therefore these expectation objects
+// must share a common base class.
+//
+// 2. We can avoid binary code bloat by moving methods not depending
+// on the template argument of Expectation to the base class.
+//
+// This class is internal and mustn't be used by user code directly.
+class ExpectationBase {
+ public:
+ // source_text is the EXPECT_CALL(...) source that created this Expectation.
+ ExpectationBase(const char* file, int line, const string& source_text);
+
+ virtual ~ExpectationBase();
+
+ // Where in the source file was the expectation spec defined?
+ const char* file() const { return file_; }
+ int line() const { return line_; }
+ const char* source_text() const { return source_text_.c_str(); }
+ // Returns the cardinality specified in the expectation spec.
+ const Cardinality& cardinality() const { return cardinality_; }
+
+ // Describes the source file location of this expectation.
+ void DescribeLocationTo(::std::ostream* os) const {
+ *os << FormatFileLocation(file(), line()) << " ";
+ }
+
+ // Describes how many times a function call matching this
+ // expectation has occurred.
+ // L >= g_gmock_mutex
+ void DescribeCallCountTo(::std::ostream* os) const;
+
+ // If this mock method has an extra matcher (i.e. .With(matcher)),
+ // describes it to the ostream.
+ virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) = 0;
+
+ protected:
+ friend class ::testing::Expectation;
+ friend class UntypedFunctionMockerBase;
+
+ enum Clause {
+ // Don't change the order of the enum members!
+ kNone,
+ kWith,
+ kTimes,
+ kInSequence,
+ kAfter,
+ kWillOnce,
+ kWillRepeatedly,
+ kRetiresOnSaturation
+ };
+
+ typedef std::vector<const void*> UntypedActions;
+
+ // Returns an Expectation object that references and co-owns this
+ // expectation.
+ virtual Expectation GetHandle() = 0;
+
+ // Asserts that the EXPECT_CALL() statement has the given property.
+ void AssertSpecProperty(bool property, const string& failure_message) const {
+ Assert(property, file_, line_, failure_message);
+ }
+
+ // Expects that the EXPECT_CALL() statement has the given property.
+ void ExpectSpecProperty(bool property, const string& failure_message) const {
+ Expect(property, file_, line_, failure_message);
+ }
+
+ // Explicitly specifies the cardinality of this expectation. Used
+ // by the subclasses to implement the .Times() clause.
+ void SpecifyCardinality(const Cardinality& cardinality);
+
+ // Returns true iff the user specified the cardinality explicitly
+ // using a .Times().
+ bool cardinality_specified() const { return cardinality_specified_; }
+
+ // Sets the cardinality of this expectation spec.
+ void set_cardinality(const Cardinality& a_cardinality) {
+ cardinality_ = a_cardinality;
+ }
+
+ // The following group of methods should only be called after the
+ // EXPECT_CALL() statement, and only when g_gmock_mutex is held by
+ // the current thread.
+
+ // Retires all pre-requisites of this expectation.
+ // L >= g_gmock_mutex
+ void RetireAllPreRequisites();
+
+ // Returns true iff this expectation is retired.
+ // L >= g_gmock_mutex
+ bool is_retired() const {
+ g_gmock_mutex.AssertHeld();
+ return retired_;
+ }
+
+ // Retires this expectation.
+ // L >= g_gmock_mutex
+ void Retire() {
+ g_gmock_mutex.AssertHeld();
+ retired_ = true;
+ }
+
+ // Returns true iff this expectation is satisfied.
+ // L >= g_gmock_mutex
+ bool IsSatisfied() const {
+ g_gmock_mutex.AssertHeld();
+ return cardinality().IsSatisfiedByCallCount(call_count_);
+ }
+
+ // Returns true iff this expectation is saturated.
+ // L >= g_gmock_mutex
+ bool IsSaturated() const {
+ g_gmock_mutex.AssertHeld();
+ return cardinality().IsSaturatedByCallCount(call_count_);
+ }
+
+ // Returns true iff this expectation is over-saturated.
+ // L >= g_gmock_mutex
+ bool IsOverSaturated() const {
+ g_gmock_mutex.AssertHeld();
+ return cardinality().IsOverSaturatedByCallCount(call_count_);
+ }
+
+ // Returns true iff all pre-requisites of this expectation are satisfied.
+ // L >= g_gmock_mutex
+ bool AllPrerequisitesAreSatisfied() const;
+
+ // Adds unsatisfied pre-requisites of this expectation to 'result'.
+ // L >= g_gmock_mutex
+ void FindUnsatisfiedPrerequisites(ExpectationSet* result) const;
+
+ // Returns the number this expectation has been invoked.
+ // L >= g_gmock_mutex
+ int call_count() const {
+ g_gmock_mutex.AssertHeld();
+ return call_count_;
+ }
+
+ // Increments the number this expectation has been invoked.
+ // L >= g_gmock_mutex
+ void IncrementCallCount() {
+ g_gmock_mutex.AssertHeld();
+ call_count_++;
+ }
+
+ // Checks the action count (i.e. the number of WillOnce() and
+ // WillRepeatedly() clauses) against the cardinality if this hasn't
+ // been done before. Prints a warning if there are too many or too
+ // few actions.
+ // L < mutex_
+ void CheckActionCountIfNotDone() const;
+
+ friend class ::testing::Sequence;
+ friend class ::testing::internal::ExpectationTester;
+
+ template <typename Function>
+ friend class TypedExpectation;
+
+ // Implements the .Times() clause.
+ void UntypedTimes(const Cardinality& a_cardinality);
+
+ // This group of fields are part of the spec and won't change after
+ // an EXPECT_CALL() statement finishes.
+ const char* file_; // The file that contains the expectation.
+ int line_; // The line number of the expectation.
+ const string source_text_; // The EXPECT_CALL(...) source text.
+ // True iff the cardinality is specified explicitly.
+ bool cardinality_specified_;
+ Cardinality cardinality_; // The cardinality of the expectation.
+ // The immediate pre-requisites (i.e. expectations that must be
+ // satisfied before this expectation can be matched) of this
+ // expectation. We use linked_ptr in the set because we want an
+ // Expectation object to be co-owned by its FunctionMocker and its
+ // successors. This allows multiple mock objects to be deleted at
+ // different times.
+ ExpectationSet immediate_prerequisites_;
+
+ // This group of fields are the current state of the expectation,
+ // and can change as the mock function is called.
+ int call_count_; // How many times this expectation has been invoked.
+ bool retired_; // True iff this expectation has retired.
+ UntypedActions untyped_actions_;
+ bool extra_matcher_specified_;
+ bool repeated_action_specified_; // True if a WillRepeatedly() was specified.
+ bool retires_on_saturation_;
+ Clause last_clause_;
+ mutable bool action_count_checked_; // Under mutex_.
+ mutable Mutex mutex_; // Protects action_count_checked_.
+
+ GTEST_DISALLOW_ASSIGN_(ExpectationBase);
+}; // class ExpectationBase
+
+// Impements an expectation for the given function type.
+template <typename F>
+class TypedExpectation : public ExpectationBase {
+ public:
+ typedef typename Function<F>::ArgumentTuple ArgumentTuple;
+ typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
+ typedef typename Function<F>::Result Result;
+
+ TypedExpectation(FunctionMockerBase<F>* owner,
+ const char* a_file, int a_line, const string& a_source_text,
+ const ArgumentMatcherTuple& m)
+ : ExpectationBase(a_file, a_line, a_source_text),
+ owner_(owner),
+ matchers_(m),
+ // By default, extra_matcher_ should match anything. However,
+ // we cannot initialize it with _ as that triggers a compiler
+ // bug in Symbian's C++ compiler (cannot decide between two
+ // overloaded constructors of Matcher<const ArgumentTuple&>).
+ extra_matcher_(A<const ArgumentTuple&>()),
+ repeated_action_(DoDefault()) {}
+
+ virtual ~TypedExpectation() {
+ // Check the validity of the action count if it hasn't been done
+ // yet (for example, if the expectation was never used).
+ CheckActionCountIfNotDone();
+ for (UntypedActions::const_iterator it = untyped_actions_.begin();
+ it != untyped_actions_.end(); ++it) {
+ delete static_cast<const Action<F>*>(*it);
+ }
+ }
+
+ // Implements the .With() clause.
+ TypedExpectation& With(const Matcher<const ArgumentTuple&>& m) {
+ if (last_clause_ == kWith) {
+ ExpectSpecProperty(false,
+ ".With() cannot appear "
+ "more than once in an EXPECT_CALL().");
+ } else {
+ ExpectSpecProperty(last_clause_ < kWith,
+ ".With() must be the first "
+ "clause in an EXPECT_CALL().");
+ }
+ last_clause_ = kWith;
+
+ extra_matcher_ = m;
+ extra_matcher_specified_ = true;
+ return *this;
+ }
+
+ // Implements the .Times() clause.
+ TypedExpectation& Times(const Cardinality& a_cardinality) {
+ ExpectationBase::UntypedTimes(a_cardinality);
+ return *this;
+ }
+
+ // Implements the .Times() clause.
+ TypedExpectation& Times(int n) {
+ return Times(Exactly(n));
+ }
+
+ // Implements the .InSequence() clause.
+ TypedExpectation& InSequence(const Sequence& s) {
+ ExpectSpecProperty(last_clause_ <= kInSequence,
+ ".InSequence() cannot appear after .After(),"
+ " .WillOnce(), .WillRepeatedly(), or "
+ ".RetiresOnSaturation().");
+ last_clause_ = kInSequence;
+
+ s.AddExpectation(GetHandle());
+ return *this;
+ }
+ TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2) {
+ return InSequence(s1).InSequence(s2);
+ }
+ TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
+ const Sequence& s3) {
+ return InSequence(s1, s2).InSequence(s3);
+ }
+ TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
+ const Sequence& s3, const Sequence& s4) {
+ return InSequence(s1, s2, s3).InSequence(s4);
+ }
+ TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
+ const Sequence& s3, const Sequence& s4,
+ const Sequence& s5) {
+ return InSequence(s1, s2, s3, s4).InSequence(s5);
+ }
+
+ // Implements that .After() clause.
+ TypedExpectation& After(const ExpectationSet& s) {
+ ExpectSpecProperty(last_clause_ <= kAfter,
+ ".After() cannot appear after .WillOnce(),"
+ " .WillRepeatedly(), or "
+ ".RetiresOnSaturation().");
+ last_clause_ = kAfter;
+
+ for (ExpectationSet::const_iterator it = s.begin(); it != s.end(); ++it) {
+ immediate_prerequisites_ += *it;
+ }
+ return *this;
+ }
+ TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2) {
+ return After(s1).After(s2);
+ }
+ TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
+ const ExpectationSet& s3) {
+ return After(s1, s2).After(s3);
+ }
+ TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
+ const ExpectationSet& s3, const ExpectationSet& s4) {
+ return After(s1, s2, s3).After(s4);
+ }
+ TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
+ const ExpectationSet& s3, const ExpectationSet& s4,
+ const ExpectationSet& s5) {
+ return After(s1, s2, s3, s4).After(s5);
+ }
+
+ // Implements the .WillOnce() clause.
+ TypedExpectation& WillOnce(const Action<F>& action) {
+ ExpectSpecProperty(last_clause_ <= kWillOnce,
+ ".WillOnce() cannot appear after "
+ ".WillRepeatedly() or .RetiresOnSaturation().");
+ last_clause_ = kWillOnce;
+
+ untyped_actions_.push_back(new Action<F>(action));
+ if (!cardinality_specified()) {
+ set_cardinality(Exactly(static_cast<int>(untyped_actions_.size())));
+ }
+ return *this;
+ }
+
+ // Implements the .WillRepeatedly() clause.
+ TypedExpectation& WillRepeatedly(const Action<F>& action) {
+ if (last_clause_ == kWillRepeatedly) {
+ ExpectSpecProperty(false,
+ ".WillRepeatedly() cannot appear "
+ "more than once in an EXPECT_CALL().");
+ } else {
+ ExpectSpecProperty(last_clause_ < kWillRepeatedly,
+ ".WillRepeatedly() cannot appear "
+ "after .RetiresOnSaturation().");
+ }
+ last_clause_ = kWillRepeatedly;
+ repeated_action_specified_ = true;
+
+ repeated_action_ = action;
+ if (!cardinality_specified()) {
+ set_cardinality(AtLeast(static_cast<int>(untyped_actions_.size())));
+ }
+
+ // Now that no more action clauses can be specified, we check
+ // whether their count makes sense.
+ CheckActionCountIfNotDone();
+ return *this;
+ }
+
+ // Implements the .RetiresOnSaturation() clause.
+ TypedExpectation& RetiresOnSaturation() {
+ ExpectSpecProperty(last_clause_ < kRetiresOnSaturation,
+ ".RetiresOnSaturation() cannot appear "
+ "more than once.");
+ last_clause_ = kRetiresOnSaturation;
+ retires_on_saturation_ = true;
+
+ // Now that no more action clauses can be specified, we check
+ // whether their count makes sense.
+ CheckActionCountIfNotDone();
+ return *this;
+ }
+
+ // Returns the matchers for the arguments as specified inside the
+ // EXPECT_CALL() macro.
+ const ArgumentMatcherTuple& matchers() const {
+ return matchers_;
+ }
+
+ // Returns the matcher specified by the .With() clause.
+ const Matcher<const ArgumentTuple&>& extra_matcher() const {
+ return extra_matcher_;
+ }
+
+ // Returns the action specified by the .WillRepeatedly() clause.
+ const Action<F>& repeated_action() const { return repeated_action_; }
+
+ // If this mock method has an extra matcher (i.e. .With(matcher)),
+ // describes it to the ostream.
+ virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) {
+ if (extra_matcher_specified_) {
+ *os << " Expected args: ";
+ extra_matcher_.DescribeTo(os);
+ *os << "\n";
+ }
+ }
+
+ private:
+ template <typename Function>
+ friend class FunctionMockerBase;
+
+ // Returns an Expectation object that references and co-owns this
+ // expectation.
+ virtual Expectation GetHandle() {
+ return owner_->GetHandleOf(this);
+ }
+
+ // The following methods will be called only after the EXPECT_CALL()
+ // statement finishes and when the current thread holds
+ // g_gmock_mutex.
+
+ // Returns true iff this expectation matches the given arguments.
+ // L >= g_gmock_mutex
+ bool Matches(const ArgumentTuple& args) const {
+ g_gmock_mutex.AssertHeld();
+ return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
+ }
+
+ // Returns true iff this expectation should handle the given arguments.
+ // L >= g_gmock_mutex
+ bool ShouldHandleArguments(const ArgumentTuple& args) const {
+ g_gmock_mutex.AssertHeld();
+
+ // In case the action count wasn't checked when the expectation
+ // was defined (e.g. if this expectation has no WillRepeatedly()
+ // or RetiresOnSaturation() clause), we check it when the
+ // expectation is used for the first time.
+ CheckActionCountIfNotDone();
+ return !is_retired() && AllPrerequisitesAreSatisfied() && Matches(args);
+ }
+
+ // Describes the result of matching the arguments against this
+ // expectation to the given ostream.
+ // L >= g_gmock_mutex
+ void ExplainMatchResultTo(const ArgumentTuple& args,
+ ::std::ostream* os) const {
+ g_gmock_mutex.AssertHeld();
+
+ if (is_retired()) {
+ *os << " Expected: the expectation is active\n"
+ << " Actual: it is retired\n";
+ } else if (!Matches(args)) {
+ if (!TupleMatches(matchers_, args)) {
+ ExplainMatchFailureTupleTo(matchers_, args, os);
+ }
+ StringMatchResultListener listener;
+ if (!extra_matcher_.MatchAndExplain(args, &listener)) {
+ *os << " Expected args: ";
+ extra_matcher_.DescribeTo(os);
+ *os << "\n Actual: don't match";
+
+ internal::PrintIfNotEmpty(listener.str(), os);
+ *os << "\n";
+ }
+ } else if (!AllPrerequisitesAreSatisfied()) {
+ *os << " Expected: all pre-requisites are satisfied\n"
+ << " Actual: the following immediate pre-requisites "
+ << "are not satisfied:\n";
+ ExpectationSet unsatisfied_prereqs;
+ FindUnsatisfiedPrerequisites(&unsatisfied_prereqs);
+ int i = 0;
+ for (ExpectationSet::const_iterator it = unsatisfied_prereqs.begin();
+ it != unsatisfied_prereqs.end(); ++it) {
+ it->expectation_base()->DescribeLocationTo(os);
+ *os << "pre-requisite #" << i++ << "\n";
+ }
+ *os << " (end of pre-requisites)\n";
+ } else {
+ // This line is here just for completeness' sake. It will never
+ // be executed as currently the ExplainMatchResultTo() function
+ // is called only when the mock function call does NOT match the
+ // expectation.
+ *os << "The call matches the expectation.\n";
+ }
+ }
+
+ // Returns the action that should be taken for the current invocation.
+ // L >= g_gmock_mutex
+ const Action<F>& GetCurrentAction(const FunctionMockerBase<F>* mocker,
+ const ArgumentTuple& args) const {
+ g_gmock_mutex.AssertHeld();
+ const int count = call_count();
+ Assert(count >= 1, __FILE__, __LINE__,
+ "call_count() is <= 0 when GetCurrentAction() is "
+ "called - this should never happen.");
+
+ const int action_count = static_cast<int>(untyped_actions_.size());
+ if (action_count > 0 && !repeated_action_specified_ &&
+ count > action_count) {
+ // If there is at least one WillOnce() and no WillRepeatedly(),
+ // we warn the user when the WillOnce() clauses ran out.
+ ::std::stringstream ss;
+ DescribeLocationTo(&ss);
+ ss << "Actions ran out in " << source_text() << "...\n"
+ << "Called " << count << " times, but only "
+ << action_count << " WillOnce()"
+ << (action_count == 1 ? " is" : "s are") << " specified - ";
+ mocker->DescribeDefaultActionTo(args, &ss);
+ Log(WARNING, ss.str(), 1);
+ }
+
+ return count <= action_count ?
+ *static_cast<const Action<F>*>(untyped_actions_[count - 1]) :
+ repeated_action();
+ }
+
+ // Given the arguments of a mock function call, if the call will
+ // over-saturate this expectation, returns the default action;
+ // otherwise, returns the next action in this expectation. Also
+ // describes *what* happened to 'what', and explains *why* Google
+ // Mock does it to 'why'. This method is not const as it calls
+ // IncrementCallCount(). A return value of NULL means the default
+ // action.
+ // L >= g_gmock_mutex
+ const Action<F>* GetActionForArguments(const FunctionMockerBase<F>* mocker,
+ const ArgumentTuple& args,
+ ::std::ostream* what,
+ ::std::ostream* why) {
+ g_gmock_mutex.AssertHeld();
+ if (IsSaturated()) {
+ // We have an excessive call.
+ IncrementCallCount();
+ *what << "Mock function called more times than expected - ";
+ mocker->DescribeDefaultActionTo(args, what);
+ DescribeCallCountTo(why);
+
+ // TODO(wan@google.com): allow the user to control whether
+ // unexpected calls should fail immediately or continue using a
+ // flag --gmock_unexpected_calls_are_fatal.
+ return NULL;
+ }
+
+ IncrementCallCount();
+ RetireAllPreRequisites();
+
+ if (retires_on_saturation_ && IsSaturated()) {
+ Retire();
+ }
+
+ // Must be done after IncrementCount()!
+ *what << "Mock function call matches " << source_text() <<"...\n";
+ return &(GetCurrentAction(mocker, args));
+ }
+
+ // All the fields below won't change once the EXPECT_CALL()
+ // statement finishes.
+ FunctionMockerBase<F>* const owner_;
+ ArgumentMatcherTuple matchers_;
+ Matcher<const ArgumentTuple&> extra_matcher_;
+ Action<F> repeated_action_;
+
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(TypedExpectation);
+}; // class TypedExpectation
+
+// A MockSpec object is used by ON_CALL() or EXPECT_CALL() for
+// specifying the default behavior of, or expectation on, a mock
+// function.
+
+// Note: class MockSpec really belongs to the ::testing namespace.
+// However if we define it in ::testing, MSVC will complain when
+// classes in ::testing::internal declare it as a friend class
+// template. To workaround this compiler bug, we define MockSpec in
+// ::testing::internal and import it into ::testing.
+
+// Logs a message including file and line number information.
+void LogWithLocation(testing::internal::LogSeverity severity,
+ const char* file, int line,
+ const string& message);
+
+template <typename F>
+class MockSpec {
+ public:
+ typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
+ typedef typename internal::Function<F>::ArgumentMatcherTuple
+ ArgumentMatcherTuple;
+
+ // Constructs a MockSpec object, given the function mocker object
+ // that the spec is associated with.
+ explicit MockSpec(internal::FunctionMockerBase<F>* function_mocker)
+ : function_mocker_(function_mocker) {}
+
+ // Adds a new default action spec to the function mocker and returns
+ // the newly created spec.
+ internal::OnCallSpec<F>& InternalDefaultActionSetAt(
+ const char* file, int line, const char* obj, const char* call) {
+ LogWithLocation(internal::INFO, file, line,
+ string("ON_CALL(") + obj + ", " + call + ") invoked");
+ return function_mocker_->AddNewOnCallSpec(file, line, matchers_);
+ }
+
+ // Adds a new expectation spec to the function mocker and returns
+ // the newly created spec.
+ internal::TypedExpectation<F>& InternalExpectedAt(
+ const char* file, int line, const char* obj, const char* call) {
+ const string source_text(string("EXPECT_CALL(") + obj + ", " + call + ")");
+ LogWithLocation(internal::INFO, file, line, source_text + " invoked");
+ return function_mocker_->AddNewExpectation(
+ file, line, source_text, matchers_);
+ }
+
+ private:
+ template <typename Function>
+ friend class internal::FunctionMocker;
+
+ void SetMatchers(const ArgumentMatcherTuple& matchers) {
+ matchers_ = matchers;
+ }
+
+ // The function mocker that owns this spec.
+ internal::FunctionMockerBase<F>* const function_mocker_;
+ // The argument matchers specified in the spec.
+ ArgumentMatcherTuple matchers_;
+
+ GTEST_DISALLOW_ASSIGN_(MockSpec);
+}; // class MockSpec
+
+// MSVC warns about using 'this' in base member initializer list, so
+// we need to temporarily disable the warning. We have to do it for
+// the entire class to suppress the warning, even though it's about
+// the constructor only.
+
+#ifdef _MSC_VER
+# pragma warning(push) // Saves the current warning state.
+# pragma warning(disable:4355) // Temporarily disables warning 4355.
+#endif // _MSV_VER
+
+// C++ treats the void type specially. For example, you cannot define
+// a void-typed variable or pass a void value to a function.
+// ActionResultHolder<T> holds a value of type T, where T must be a
+// copyable type or void (T doesn't need to be default-constructable).
+// It hides the syntactic difference between void and other types, and
+// is used to unify the code for invoking both void-returning and
+// non-void-returning mock functions.
+
+// Untyped base class for ActionResultHolder<T>.
+class UntypedActionResultHolderBase {
+ public:
+ virtual ~UntypedActionResultHolderBase() {}
+
+ // Prints the held value as an action's result to os.
+ virtual void PrintAsActionResult(::std::ostream* os) const = 0;
+};
+
+// This generic definition is used when T is not void.
+template <typename T>
+class ActionResultHolder : public UntypedActionResultHolderBase {
+ public:
+ explicit ActionResultHolder(T a_value) : value_(a_value) {}
+
+ // The compiler-generated copy constructor and assignment operator
+ // are exactly what we need, so we don't need to define them.
+
+ // Returns the held value and deletes this object.
+ T GetValueAndDelete() const {
+ T retval(value_);
+ delete this;
+ return retval;
+ }
+
+ // Prints the held value as an action's result to os.
+ virtual void PrintAsActionResult(::std::ostream* os) const {
+ *os << "\n Returns: ";
+ // T may be a reference type, so we don't use UniversalPrint().
+ UniversalPrinter<T>::Print(value_, os);
+ }
+
+ // Performs the given mock function's default action and returns the
+ // result in a new-ed ActionResultHolder.
+ template <typename F>
+ static ActionResultHolder* PerformDefaultAction(
+ const FunctionMockerBase<F>* func_mocker,
+ const typename Function<F>::ArgumentTuple& args,
+ const string& call_description) {
+ return new ActionResultHolder(
+ func_mocker->PerformDefaultAction(args, call_description));
+ }
+
+ // Performs the given action and returns the result in a new-ed
+ // ActionResultHolder.
+ template <typename F>
+ static ActionResultHolder*
+ PerformAction(const Action<F>& action,
+ const typename Function<F>::ArgumentTuple& args) {
+ return new ActionResultHolder(action.Perform(args));
+ }
+
+ private:
+ T value_;
+
+ // T could be a reference type, so = isn't supported.
+ GTEST_DISALLOW_ASSIGN_(ActionResultHolder);
+};
+
+// Specialization for T = void.
+template <>
+class ActionResultHolder<void> : public UntypedActionResultHolderBase {
+ public:
+ void GetValueAndDelete() const { delete this; }
+
+ virtual void PrintAsActionResult(::std::ostream* /* os */) const {}
+
+ // Performs the given mock function's default action and returns NULL;
+ template <typename F>
+ static ActionResultHolder* PerformDefaultAction(
+ const FunctionMockerBase<F>* func_mocker,
+ const typename Function<F>::ArgumentTuple& args,
+ const string& call_description) {
+ func_mocker->PerformDefaultAction(args, call_description);
+ return NULL;
+ }
+
+ // Performs the given action and returns NULL.
+ template <typename F>
+ static ActionResultHolder* PerformAction(
+ const Action<F>& action,
+ const typename Function<F>::ArgumentTuple& args) {
+ action.Perform(args);
+ return NULL;
+ }
+};
+
+// The base of the function mocker class for the given function type.
+// We put the methods in this class instead of its child to avoid code
+// bloat.
+template <typename F>
+class FunctionMockerBase : public UntypedFunctionMockerBase {
+ public:
+ typedef typename Function<F>::Result Result;
+ typedef typename Function<F>::ArgumentTuple ArgumentTuple;
+ typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
+
+ FunctionMockerBase() : current_spec_(this) {}
+
+ // The destructor verifies that all expectations on this mock
+ // function have been satisfied. If not, it will report Google Test
+ // non-fatal failures for the violations.
+ // L < g_gmock_mutex
+ virtual ~FunctionMockerBase() {
+ MutexLock l(&g_gmock_mutex);
+ VerifyAndClearExpectationsLocked();
+ Mock::UnregisterLocked(this);
+ ClearDefaultActionsLocked();
+ }
+
+ // Returns the ON_CALL spec that matches this mock function with the
+ // given arguments; returns NULL if no matching ON_CALL is found.
+ // L = *
+ const OnCallSpec<F>* FindOnCallSpec(
+ const ArgumentTuple& args) const {
+ for (UntypedOnCallSpecs::const_reverse_iterator it
+ = untyped_on_call_specs_.rbegin();
+ it != untyped_on_call_specs_.rend(); ++it) {
+ const OnCallSpec<F>* spec = static_cast<const OnCallSpec<F>*>(*it);
+ if (spec->Matches(args))
+ return spec;
+ }
+
+ return NULL;
+ }
+
+ // Performs the default action of this mock function on the given arguments
+ // and returns the result. Asserts with a helpful call descrption if there is
+ // no valid return value. This method doesn't depend on the mutable state of
+ // this object, and thus can be called concurrently without locking.
+ // L = *
+ Result PerformDefaultAction(const ArgumentTuple& args,
+ const string& call_description) const {
+ const OnCallSpec<F>* const spec =
+ this->FindOnCallSpec(args);
+ if (spec != NULL) {
+ return spec->GetAction().Perform(args);
+ }
+ Assert(DefaultValue<Result>::Exists(), "", -1,
+ call_description + "\n The mock function has no default action "
+ "set, and its return type has no default value set.");
+ return DefaultValue<Result>::Get();
+ }
+
+ // Performs the default action with the given arguments and returns
+ // the action's result. The call description string will be used in
+ // the error message to describe the call in the case the default
+ // action fails. The caller is responsible for deleting the result.
+ // L = *
+ virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(
+ const void* untyped_args, // must point to an ArgumentTuple
+ const string& call_description) const {
+ const ArgumentTuple& args =
+ *static_cast<const ArgumentTuple*>(untyped_args);
+ return ResultHolder::PerformDefaultAction(this, args, call_description);
+ }
+
+ // Performs the given action with the given arguments and returns
+ // the action's result. The caller is responsible for deleting the
+ // result.
+ // L = *
+ virtual UntypedActionResultHolderBase* UntypedPerformAction(
+ const void* untyped_action, const void* untyped_args) const {
+ // Make a copy of the action before performing it, in case the
+ // action deletes the mock object (and thus deletes itself).
+ const Action<F> action = *static_cast<const Action<F>*>(untyped_action);
+ const ArgumentTuple& args =
+ *static_cast<const ArgumentTuple*>(untyped_args);
+ return ResultHolder::PerformAction(action, args);
+ }
+
+ // Implements UntypedFunctionMockerBase::ClearDefaultActionsLocked():
+ // clears the ON_CALL()s set on this mock function.
+ // L >= g_gmock_mutex
+ virtual void ClearDefaultActionsLocked() {
+ g_gmock_mutex.AssertHeld();
+ for (UntypedOnCallSpecs::const_iterator it =
+ untyped_on_call_specs_.begin();
+ it != untyped_on_call_specs_.end(); ++it) {
+ delete static_cast<const OnCallSpec<F>*>(*it);
+ }
+ untyped_on_call_specs_.clear();
+ }
+
+ protected:
+ template <typename Function>
+ friend class MockSpec;
+
+ typedef ActionResultHolder<Result> ResultHolder;
+
+ // Returns the result of invoking this mock function with the given
+ // arguments. This function can be safely called from multiple
+ // threads concurrently.
+ // L < g_gmock_mutex
+ Result InvokeWith(const ArgumentTuple& args) {
+ return static_cast<const ResultHolder*>(
+ this->UntypedInvokeWith(&args))->GetValueAndDelete();
+ }
+
+ // Adds and returns a default action spec for this mock function.
+ // L < g_gmock_mutex
+ OnCallSpec<F>& AddNewOnCallSpec(
+ const char* file, int line,
+ const ArgumentMatcherTuple& m) {
+ Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
+ OnCallSpec<F>* const on_call_spec = new OnCallSpec<F>(file, line, m);
+ untyped_on_call_specs_.push_back(on_call_spec);
+ return *on_call_spec;
+ }
+
+ // Adds and returns an expectation spec for this mock function.
+ // L < g_gmock_mutex
+ TypedExpectation<F>& AddNewExpectation(
+ const char* file,
+ int line,
+ const string& source_text,
+ const ArgumentMatcherTuple& m) {
+ Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
+ TypedExpectation<F>* const expectation =
+ new TypedExpectation<F>(this, file, line, source_text, m);
+ const linked_ptr<ExpectationBase> untyped_expectation(expectation);
+ untyped_expectations_.push_back(untyped_expectation);
+
+ // Adds this expectation into the implicit sequence if there is one.
+ Sequence* const implicit_sequence = g_gmock_implicit_sequence.get();
+ if (implicit_sequence != NULL) {
+ implicit_sequence->AddExpectation(Expectation(untyped_expectation));
+ }
+
+ return *expectation;
+ }
+
+ // The current spec (either default action spec or expectation spec)
+ // being described on this function mocker.
+ MockSpec<F>& current_spec() { return current_spec_; }
+
+ private:
+ template <typename Func> friend class TypedExpectation;
+
+ // Some utilities needed for implementing UntypedInvokeWith().
+
+ // Describes what default action will be performed for the given
+ // arguments.
+ // L = *
+ void DescribeDefaultActionTo(const ArgumentTuple& args,
+ ::std::ostream* os) const {
+ const OnCallSpec<F>* const spec = FindOnCallSpec(args);
+
+ if (spec == NULL) {
+ *os << (internal::type_equals<Result, void>::value ?
+ "returning directly.\n" :
+ "returning default value.\n");
+ } else {
+ *os << "taking default action specified at:\n"
+ << FormatFileLocation(spec->file(), spec->line()) << "\n";
+ }
+ }
+
+ // Writes a message that the call is uninteresting (i.e. neither
+ // explicitly expected nor explicitly unexpected) to the given
+ // ostream.
+ // L < g_gmock_mutex
+ virtual void UntypedDescribeUninterestingCall(const void* untyped_args,
+ ::std::ostream* os) const {
+ const ArgumentTuple& args =
+ *static_cast<const ArgumentTuple*>(untyped_args);
+ *os << "Uninteresting mock function call - ";
+ DescribeDefaultActionTo(args, os);
+ *os << " Function call: " << Name();
+ UniversalPrint(args, os);
+ }
+
+ // Returns the expectation that matches the given function arguments
+ // (or NULL is there's no match); when a match is found,
+ // untyped_action is set to point to the action that should be
+ // performed (or NULL if the action is "do default"), and
+ // is_excessive is modified to indicate whether the call exceeds the
+ // expected number.
+ //
+ // Critical section: We must find the matching expectation and the
+ // corresponding action that needs to be taken in an ATOMIC
+ // transaction. Otherwise another thread may call this mock
+ // method in the middle and mess up the state.
+ //
+ // However, performing the action has to be left out of the critical
+ // section. The reason is that we have no control on what the
+ // action does (it can invoke an arbitrary user function or even a
+ // mock function) and excessive locking could cause a dead lock.
+ // L < g_gmock_mutex
+ virtual const ExpectationBase* UntypedFindMatchingExpectation(
+ const void* untyped_args,
+ const void** untyped_action, bool* is_excessive,
+ ::std::ostream* what, ::std::ostream* why) {
+ const ArgumentTuple& args =
+ *static_cast<const ArgumentTuple*>(untyped_args);
+ MutexLock l(&g_gmock_mutex);
+ TypedExpectation<F>* exp = this->FindMatchingExpectationLocked(args);
+ if (exp == NULL) { // A match wasn't found.
+ this->FormatUnexpectedCallMessageLocked(args, what, why);
+ return NULL;
+ }
+
+ // This line must be done before calling GetActionForArguments(),
+ // which will increment the call count for *exp and thus affect
+ // its saturation status.
+ *is_excessive = exp->IsSaturated();
+ const Action<F>* action = exp->GetActionForArguments(this, args, what, why);
+ if (action != NULL && action->IsDoDefault())
+ action = NULL; // Normalize "do default" to NULL.
+ *untyped_action = action;
+ return exp;
+ }
+
+ // Prints the given function arguments to the ostream.
+ virtual void UntypedPrintArgs(const void* untyped_args,
+ ::std::ostream* os) const {
+ const ArgumentTuple& args =
+ *static_cast<const ArgumentTuple*>(untyped_args);
+ UniversalPrint(args, os);
+ }
+
+ // Returns the expectation that matches the arguments, or NULL if no
+ // expectation matches them.
+ // L >= g_gmock_mutex
+ TypedExpectation<F>* FindMatchingExpectationLocked(
+ const ArgumentTuple& args) const {
+ g_gmock_mutex.AssertHeld();
+ for (typename UntypedExpectations::const_reverse_iterator it =
+ untyped_expectations_.rbegin();
+ it != untyped_expectations_.rend(); ++it) {
+ TypedExpectation<F>* const exp =
+ static_cast<TypedExpectation<F>*>(it->get());
+ if (exp->ShouldHandleArguments(args)) {
+ return exp;
+ }
+ }
+ return NULL;
+ }
+
+ // Returns a message that the arguments don't match any expectation.
+ // L >= g_gmock_mutex
+ void FormatUnexpectedCallMessageLocked(const ArgumentTuple& args,
+ ::std::ostream* os,
+ ::std::ostream* why) const {
+ g_gmock_mutex.AssertHeld();
+ *os << "\nUnexpected mock function call - ";
+ DescribeDefaultActionTo(args, os);
+ PrintTriedExpectationsLocked(args, why);
+ }
+
+ // Prints a list of expectations that have been tried against the
+ // current mock function call.
+ // L >= g_gmock_mutex
+ void PrintTriedExpectationsLocked(const ArgumentTuple& args,
+ ::std::ostream* why) const {
+ g_gmock_mutex.AssertHeld();
+ const int count = static_cast<int>(untyped_expectations_.size());
+ *why << "Google Mock tried the following " << count << " "
+ << (count == 1 ? "expectation, but it didn't match" :
+ "expectations, but none matched")
+ << ":\n";
+ for (int i = 0; i < count; i++) {
+ TypedExpectation<F>* const expectation =
+ static_cast<TypedExpectation<F>*>(untyped_expectations_[i].get());
+ *why << "\n";
+ expectation->DescribeLocationTo(why);
+ if (count > 1) {
+ *why << "tried expectation #" << i << ": ";
+ }
+ *why << expectation->source_text() << "...\n";
+ expectation->ExplainMatchResultTo(args, why);
+ expectation->DescribeCallCountTo(why);
+ }
+ }
+
+ // The current spec (either default action spec or expectation spec)
+ // being described on this function mocker.
+ MockSpec<F> current_spec_;
+
+ // There is no generally useful and implementable semantics of
+ // copying a mock object, so copying a mock is usually a user error.
+ // Thus we disallow copying function mockers. If the user really
+ // wants to copy a mock object, he should implement his own copy
+ // operation, for example:
+ //
+ // class MockFoo : public Foo {
+ // public:
+ // // Defines a copy constructor explicitly.
+ // MockFoo(const MockFoo& src) {}
+ // ...
+ // };
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(FunctionMockerBase);
+}; // class FunctionMockerBase
+
+#ifdef _MSC_VER
+# pragma warning(pop) // Restores the warning state.
+#endif // _MSV_VER
+
+// Implements methods of FunctionMockerBase.
+
+// Verifies that all expectations on this mock function have been
+// satisfied. Reports one or more Google Test non-fatal failures and
+// returns false if not.
+// L >= g_gmock_mutex
+
+// Reports an uninteresting call (whose description is in msg) in the
+// manner specified by 'reaction'.
+void ReportUninterestingCall(CallReaction reaction, const string& msg);
+
+} // namespace internal
+
+// The style guide prohibits "using" statements in a namespace scope
+// inside a header file. However, the MockSpec class template is
+// meant to be defined in the ::testing namespace. The following line
+// is just a trick for working around a bug in MSVC 8.0, which cannot
+// handle it if we define MockSpec in ::testing.
+using internal::MockSpec;
+
+// Const(x) is a convenient function for obtaining a const reference
+// to x. This is useful for setting expectations on an overloaded
+// const mock method, e.g.
+//
+// class MockFoo : public FooInterface {
+// public:
+// MOCK_METHOD0(Bar, int());
+// MOCK_CONST_METHOD0(Bar, int&());
+// };
+//
+// MockFoo foo;
+// // Expects a call to non-const MockFoo::Bar().
+// EXPECT_CALL(foo, Bar());
+// // Expects a call to const MockFoo::Bar().
+// EXPECT_CALL(Const(foo), Bar());
+template <typename T>
+inline const T& Const(const T& x) { return x; }
+
+// Constructs an Expectation object that references and co-owns exp.
+inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
+ : expectation_base_(exp.GetHandle().expectation_base()) {}
+
+} // namespace testing
+
+// A separate macro is required to avoid compile errors when the name
+// of the method used in call is a result of macro expansion.
+// See CompilesWithMethodNameExpandedFromMacro tests in
+// internal/gmock-spec-builders_test.cc for more details.
+#define GMOCK_ON_CALL_IMPL_(obj, call) \
+ ((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \
+ #obj, #call)
+#define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call)
+
+#define GMOCK_EXPECT_CALL_IMPL_(obj, call) \
+ ((obj).gmock_##call).InternalExpectedAt(__FILE__, __LINE__, #obj, #call)
+#define EXPECT_CALL(obj, call) GMOCK_EXPECT_CALL_IMPL_(obj, call)
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
diff --git a/lib/gtest/include/gmock/gmock.h b/lib/gtest/include/gmock/gmock.h
new file mode 100644
index 0000000..ba9fa28
--- /dev/null
+++ b/lib/gtest/include/gmock/gmock.h
@@ -0,0 +1,93 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This is the main header file a user should include.
+
+#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_H_
+#define GMOCK_INCLUDE_GMOCK_GMOCK_H_
+
+// This file implements the following syntax:
+//
+// ON_CALL(mock_object.Method(...))
+// .With(...) ?
+// .WillByDefault(...);
+//
+// where With() is optional and WillByDefault() must appear exactly
+// once.
+//
+// EXPECT_CALL(mock_object.Method(...))
+// .With(...) ?
+// .Times(...) ?
+// .InSequence(...) *
+// .WillOnce(...) *
+// .WillRepeatedly(...) ?
+// .RetiresOnSaturation() ? ;
+//
+// where all clauses are optional and WillOnce() can be repeated.
+
+#include "gmock/gmock-actions.h"
+#include "gmock/gmock-cardinalities.h"
+#include "gmock/gmock-generated-actions.h"
+#include "gmock/gmock-generated-function-mockers.h"
+#include "gmock/gmock-generated-matchers.h"
+#include "gmock/gmock-more-actions.h"
+#include "gmock/gmock-generated-nice-strict.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/internal/gmock-internal-utils.h"
+
+namespace testing {
+
+// Declares Google Mock flags that we want a user to use programmatically.
+GMOCK_DECLARE_bool_(catch_leaked_mocks);
+GMOCK_DECLARE_string_(verbose);
+
+// Initializes Google Mock. This must be called before running the
+// tests. In particular, it parses the command line for the flags
+// that Google Mock recognizes. Whenever a Google Mock flag is seen,
+// it is removed from argv, and *argc is decremented.
+//
+// No value is returned. Instead, the Google Mock flag variables are
+// updated.
+//
+// Since Google Test is needed for Google Mock to work, this function
+// also initializes Google Test and parses its flags, if that hasn't
+// been done.
+void InitGoogleMock(int* argc, char** argv);
+
+// This overloaded version can be used in Windows programs compiled in
+// UNICODE mode.
+void InitGoogleMock(int* argc, wchar_t** argv);
+
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_GMOCK_H_
diff --git a/lib/gtest/include/gmock/internal/gmock-generated-internal-utils.h b/lib/gtest/include/gmock/internal/gmock-generated-internal-utils.h
new file mode 100644
index 0000000..1b52dce
--- /dev/null
+++ b/lib/gtest/include/gmock/internal/gmock-generated-internal-utils.h
@@ -0,0 +1,277 @@
+// This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
+
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file contains template meta-programming utility classes needed
+// for implementing Google Mock.
+
+#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
+#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
+
+#include "gmock/internal/gmock-port.h"
+
+namespace testing {
+
+template <typename T>
+class Matcher;
+
+namespace internal {
+
+// An IgnoredValue object can be implicitly constructed from ANY value.
+// This is used in implementing the IgnoreResult(a) action.
+class IgnoredValue {
+ public:
+ // This constructor template allows any value to be implicitly
+ // converted to IgnoredValue. The object has no data member and
+ // doesn't try to remember anything about the argument. We
+ // deliberately omit the 'explicit' keyword in order to allow the
+ // conversion to be implicit.
+ template <typename T>
+ IgnoredValue(const T&) {}
+};
+
+// MatcherTuple<T>::type is a tuple type where each field is a Matcher
+// for the corresponding field in tuple type T.
+template <typename Tuple>
+struct MatcherTuple;
+
+template <>
+struct MatcherTuple< ::std::tr1::tuple<> > {
+ typedef ::std::tr1::tuple< > type;
+};
+
+template <typename A1>
+struct MatcherTuple< ::std::tr1::tuple<A1> > {
+ typedef ::std::tr1::tuple<Matcher<A1> > type;
+};
+
+template <typename A1, typename A2>
+struct MatcherTuple< ::std::tr1::tuple<A1, A2> > {
+ typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2> > type;
+};
+
+template <typename A1, typename A2, typename A3>
+struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3> > {
+ typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
+};
+
+template <typename A1, typename A2, typename A3, typename A4>
+struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4> > {
+ typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>,
+ Matcher<A4> > type;
+};
+
+template <typename A1, typename A2, typename A3, typename A4, typename A5>
+struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5> > {
+ typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
+ Matcher<A5> > type;
+};
+
+template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6>
+struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> > {
+ typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
+ Matcher<A5>, Matcher<A6> > type;
+};
+
+template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6, typename A7>
+struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> > {
+ typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
+ Matcher<A5>, Matcher<A6>, Matcher<A7> > type;
+};
+
+template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6, typename A7, typename A8>
+struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
+ typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
+ Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8> > type;
+};
+
+template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6, typename A7, typename A8, typename A9>
+struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
+ typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
+ Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9> > type;
+};
+
+template <typename A1, typename A2, typename A3, typename A4, typename A5,
+ typename A6, typename A7, typename A8, typename A9, typename A10>
+struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
+ A10> > {
+ typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
+ Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9>,
+ Matcher<A10> > type;
+};
+
+// Template struct Function<F>, where F must be a function type, contains
+// the following typedefs:
+//
+// Result: the function's return type.
+// ArgumentN: the type of the N-th argument, where N starts with 1.
+// ArgumentTuple: the tuple type consisting of all parameters of F.
+// ArgumentMatcherTuple: the tuple type consisting of Matchers for all
+// parameters of F.
+// MakeResultVoid: the function type obtained by substituting void
+// for the return type of F.
+// MakeResultIgnoredValue:
+// the function type obtained by substituting Something
+// for the return type of F.
+template <typename F>
+struct Function;
+
+template <typename R>
+struct Function<R()> {
+ typedef R Result;
+ typedef ::std::tr1::tuple<> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid();
+ typedef IgnoredValue MakeResultIgnoredValue();
+};
+
+template <typename R, typename A1>
+struct Function<R(A1)>
+ : Function<R()> {
+ typedef A1 Argument1;
+ typedef ::std::tr1::tuple<A1> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid(A1);
+ typedef IgnoredValue MakeResultIgnoredValue(A1);
+};
+
+template <typename R, typename A1, typename A2>
+struct Function<R(A1, A2)>
+ : Function<R(A1)> {
+ typedef A2 Argument2;
+ typedef ::std::tr1::tuple<A1, A2> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid(A1, A2);
+ typedef IgnoredValue MakeResultIgnoredValue(A1, A2);
+};
+
+template <typename R, typename A1, typename A2, typename A3>
+struct Function<R(A1, A2, A3)>
+ : Function<R(A1, A2)> {
+ typedef A3 Argument3;
+ typedef ::std::tr1::tuple<A1, A2, A3> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid(A1, A2, A3);
+ typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3);
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4>
+struct Function<R(A1, A2, A3, A4)>
+ : Function<R(A1, A2, A3)> {
+ typedef A4 Argument4;
+ typedef ::std::tr1::tuple<A1, A2, A3, A4> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid(A1, A2, A3, A4);
+ typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4);
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5>
+struct Function<R(A1, A2, A3, A4, A5)>
+ : Function<R(A1, A2, A3, A4)> {
+ typedef A5 Argument5;
+ typedef ::std::tr1::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid(A1, A2, A3, A4, A5);
+ typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5);
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6>
+struct Function<R(A1, A2, A3, A4, A5, A6)>
+ : Function<R(A1, A2, A3, A4, A5)> {
+ typedef A6 Argument6;
+ typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6);
+ typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6);
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7>
+struct Function<R(A1, A2, A3, A4, A5, A6, A7)>
+ : Function<R(A1, A2, A3, A4, A5, A6)> {
+ typedef A7 Argument7;
+ typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7);
+ typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7);
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7, typename A8>
+struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>
+ : Function<R(A1, A2, A3, A4, A5, A6, A7)> {
+ typedef A8 Argument8;
+ typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8);
+ typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8);
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7, typename A8, typename A9>
+struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
+ : Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
+ typedef A9 Argument9;
+ typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9);
+ typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
+ A9);
+};
+
+template <typename R, typename A1, typename A2, typename A3, typename A4,
+ typename A5, typename A6, typename A7, typename A8, typename A9,
+ typename A10>
+struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
+ : Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
+ typedef A10 Argument10;
+ typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
+ A10> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
+ typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
+ A9, A10);
+};
+
+} // namespace internal
+
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
diff --git a/lib/gtest/include/gmock/internal/gmock-generated-internal-utils.h.pump b/lib/gtest/include/gmock/internal/gmock-generated-internal-utils.h.pump
new file mode 100644
index 0000000..821e474
--- /dev/null
+++ b/lib/gtest/include/gmock/internal/gmock-generated-internal-utils.h.pump
@@ -0,0 +1,136 @@
+$$ -*- mode: c++; -*-
+$$ This is a Pump source file. Please use Pump to convert it to
+$$ gmock-generated-function-mockers.h.
+$$
+$var n = 10 $$ The maximum arity we support.
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file contains template meta-programming utility classes needed
+// for implementing Google Mock.
+
+#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
+#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
+
+#include "gmock/internal/gmock-port.h"
+
+namespace testing {
+
+template <typename T>
+class Matcher;
+
+namespace internal {
+
+// An IgnoredValue object can be implicitly constructed from ANY value.
+// This is used in implementing the IgnoreResult(a) action.
+class IgnoredValue {
+ public:
+ // This constructor template allows any value to be implicitly
+ // converted to IgnoredValue. The object has no data member and
+ // doesn't try to remember anything about the argument. We
+ // deliberately omit the 'explicit' keyword in order to allow the
+ // conversion to be implicit.
+ template <typename T>
+ IgnoredValue(const T&) {}
+};
+
+// MatcherTuple<T>::type is a tuple type where each field is a Matcher
+// for the corresponding field in tuple type T.
+template <typename Tuple>
+struct MatcherTuple;
+
+
+$range i 0..n
+$for i [[
+$range j 1..i
+$var typename_As = [[$for j, [[typename A$j]]]]
+$var As = [[$for j, [[A$j]]]]
+$var matcher_As = [[$for j, [[Matcher<A$j>]]]]
+template <$typename_As>
+struct MatcherTuple< ::std::tr1::tuple<$As> > {
+ typedef ::std::tr1::tuple<$matcher_As > type;
+};
+
+
+]]
+// Template struct Function<F>, where F must be a function type, contains
+// the following typedefs:
+//
+// Result: the function's return type.
+// ArgumentN: the type of the N-th argument, where N starts with 1.
+// ArgumentTuple: the tuple type consisting of all parameters of F.
+// ArgumentMatcherTuple: the tuple type consisting of Matchers for all
+// parameters of F.
+// MakeResultVoid: the function type obtained by substituting void
+// for the return type of F.
+// MakeResultIgnoredValue:
+// the function type obtained by substituting Something
+// for the return type of F.
+template <typename F>
+struct Function;
+
+template <typename R>
+struct Function<R()> {
+ typedef R Result;
+ typedef ::std::tr1::tuple<> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid();
+ typedef IgnoredValue MakeResultIgnoredValue();
+};
+
+
+$range i 1..n
+$for i [[
+$range j 1..i
+$var typename_As = [[$for j [[, typename A$j]]]]
+$var As = [[$for j, [[A$j]]]]
+$var matcher_As = [[$for j, [[Matcher<A$j>]]]]
+$range k 1..i-1
+$var prev_As = [[$for k, [[A$k]]]]
+template <typename R$typename_As>
+struct Function<R($As)>
+ : Function<R($prev_As)> {
+ typedef A$i Argument$i;
+ typedef ::std::tr1::tuple<$As> ArgumentTuple;
+ typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
+ typedef void MakeResultVoid($As);
+ typedef IgnoredValue MakeResultIgnoredValue($As);
+};
+
+
+]]
+} // namespace internal
+
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
diff --git a/lib/gtest/include/gmock/internal/gmock-internal-utils.h b/lib/gtest/include/gmock/internal/gmock-internal-utils.h
new file mode 100644
index 0000000..f0fd868
--- /dev/null
+++ b/lib/gtest/include/gmock/internal/gmock-internal-utils.h
@@ -0,0 +1,463 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file defines some utilities useful for implementing Google
+// Mock. They are subject to change without notice, so please DO NOT
+// USE THEM IN USER CODE.
+
+#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
+#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
+
+#include <stdio.h>
+#include <ostream> // NOLINT
+#include <string>
+
+#include "gmock/internal/gmock-generated-internal-utils.h"
+#include "gmock/internal/gmock-port.h"
+#include "gtest/gtest.h"
+
+namespace testing {
+namespace internal {
+
+// Converts an identifier name to a space-separated list of lower-case
+// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
+// treated as one word. For example, both "FooBar123" and
+// "foo_bar_123" are converted to "foo bar 123".
+string ConvertIdentifierNameToWords(const char* id_name);
+
+// PointeeOf<Pointer>::type is the type of a value pointed to by a
+// Pointer, which can be either a smart pointer or a raw pointer. The
+// following default implementation is for the case where Pointer is a
+// smart pointer.
+template <typename Pointer>
+struct PointeeOf {
+ // Smart pointer classes define type element_type as the type of
+ // their pointees.
+ typedef typename Pointer::element_type type;
+};
+// This specialization is for the raw pointer case.
+template <typename T>
+struct PointeeOf<T*> { typedef T type; }; // NOLINT
+
+// GetRawPointer(p) returns the raw pointer underlying p when p is a
+// smart pointer, or returns p itself when p is already a raw pointer.
+// The following default implementation is for the smart pointer case.
+template <typename Pointer>
+inline typename Pointer::element_type* GetRawPointer(const Pointer& p) {
+ return p.get();
+}
+// This overloaded version is for the raw pointer case.
+template <typename Element>
+inline Element* GetRawPointer(Element* p) { return p; }
+
+// This comparator allows linked_ptr to be stored in sets.
+template <typename T>
+struct LinkedPtrLessThan {
+ bool operator()(const ::testing::internal::linked_ptr<T>& lhs,
+ const ::testing::internal::linked_ptr<T>& rhs) const {
+ return lhs.get() < rhs.get();
+ }
+};
+
+// Symbian compilation can be done with wchar_t being either a native
+// type or a typedef. Using Google Mock with OpenC without wchar_t
+// should require the definition of _STLP_NO_WCHAR_T.
+//
+// MSVC treats wchar_t as a native type usually, but treats it as the
+// same as unsigned short when the compiler option /Zc:wchar_t- is
+// specified. It defines _NATIVE_WCHAR_T_DEFINED symbol when wchar_t
+// is a native type.
+#if (GTEST_OS_SYMBIAN && defined(_STLP_NO_WCHAR_T)) || \
+ (defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED))
+// wchar_t is a typedef.
+#else
+# define GMOCK_WCHAR_T_IS_NATIVE_ 1
+#endif
+
+// signed wchar_t and unsigned wchar_t are NOT in the C++ standard.
+// Using them is a bad practice and not portable. So DON'T use them.
+//
+// Still, Google Mock is designed to work even if the user uses signed
+// wchar_t or unsigned wchar_t (obviously, assuming the compiler
+// supports them).
+//
+// To gcc,
+// wchar_t == signed wchar_t != unsigned wchar_t == unsigned int
+#ifdef __GNUC__
+// signed/unsigned wchar_t are valid types.
+# define GMOCK_HAS_SIGNED_WCHAR_T_ 1
+#endif
+
+// In what follows, we use the term "kind" to indicate whether a type
+// is bool, an integer type (excluding bool), a floating-point type,
+// or none of them. This categorization is useful for determining
+// when a matcher argument type can be safely converted to another
+// type in the implementation of SafeMatcherCast.
+enum TypeKind {
+ kBool, kInteger, kFloatingPoint, kOther
+};
+
+// KindOf<T>::value is the kind of type T.
+template <typename T> struct KindOf {
+ enum { value = kOther }; // The default kind.
+};
+
+// This macro declares that the kind of 'type' is 'kind'.
+#define GMOCK_DECLARE_KIND_(type, kind) \
+ template <> struct KindOf<type> { enum { value = kind }; }
+
+GMOCK_DECLARE_KIND_(bool, kBool);
+
+// All standard integer types.
+GMOCK_DECLARE_KIND_(char, kInteger);
+GMOCK_DECLARE_KIND_(signed char, kInteger);
+GMOCK_DECLARE_KIND_(unsigned char, kInteger);
+GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT
+GMOCK_DECLARE_KIND_(unsigned short, kInteger); // NOLINT
+GMOCK_DECLARE_KIND_(int, kInteger);
+GMOCK_DECLARE_KIND_(unsigned int, kInteger);
+GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT
+GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT
+
+#if GMOCK_WCHAR_T_IS_NATIVE_
+GMOCK_DECLARE_KIND_(wchar_t, kInteger);
+#endif
+
+// Non-standard integer types.
+GMOCK_DECLARE_KIND_(Int64, kInteger);
+GMOCK_DECLARE_KIND_(UInt64, kInteger);
+
+// All standard floating-point types.
+GMOCK_DECLARE_KIND_(float, kFloatingPoint);
+GMOCK_DECLARE_KIND_(double, kFloatingPoint);
+GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
+
+#undef GMOCK_DECLARE_KIND_
+
+// Evaluates to the kind of 'type'.
+#define GMOCK_KIND_OF_(type) \
+ static_cast< ::testing::internal::TypeKind>( \
+ ::testing::internal::KindOf<type>::value)
+
+// Evaluates to true iff integer type T is signed.
+#define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0)
+
+// LosslessArithmeticConvertibleImpl<kFromKind, From, kToKind, To>::value
+// is true iff arithmetic type From can be losslessly converted to
+// arithmetic type To.
+//
+// It's the user's responsibility to ensure that both From and To are
+// raw (i.e. has no CV modifier, is not a pointer, and is not a
+// reference) built-in arithmetic types, kFromKind is the kind of
+// From, and kToKind is the kind of To; the value is
+// implementation-defined when the above pre-condition is violated.
+template <TypeKind kFromKind, typename From, TypeKind kToKind, typename To>
+struct LosslessArithmeticConvertibleImpl : public false_type {};
+
+// Converting bool to bool is lossless.
+template <>
+struct LosslessArithmeticConvertibleImpl<kBool, bool, kBool, bool>
+ : public true_type {}; // NOLINT
+
+// Converting bool to any integer type is lossless.
+template <typename To>
+struct LosslessArithmeticConvertibleImpl<kBool, bool, kInteger, To>
+ : public true_type {}; // NOLINT
+
+// Converting bool to any floating-point type is lossless.
+template <typename To>
+struct LosslessArithmeticConvertibleImpl<kBool, bool, kFloatingPoint, To>
+ : public true_type {}; // NOLINT
+
+// Converting an integer to bool is lossy.
+template <typename From>
+struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool>
+ : public false_type {}; // NOLINT
+
+// Converting an integer to another non-bool integer is lossless iff
+// the target type's range encloses the source type's range.
+template <typename From, typename To>
+struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>
+ : public bool_constant<
+ // When converting from a smaller size to a larger size, we are
+ // fine as long as we are not converting from signed to unsigned.
+ ((sizeof(From) < sizeof(To)) &&
+ (!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
+ // When converting between the same size, the signedness must match.
+ ((sizeof(From) == sizeof(To)) &&
+ (GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {}; // NOLINT
+
+#undef GMOCK_IS_SIGNED_
+
+// Converting an integer to a floating-point type may be lossy, since
+// the format of a floating-point number is implementation-defined.
+template <typename From, typename To>
+struct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To>
+ : public false_type {}; // NOLINT
+
+// Converting a floating-point to bool is lossy.
+template <typename From>
+struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool>
+ : public false_type {}; // NOLINT
+
+// Converting a floating-point to an integer is lossy.
+template <typename From, typename To>
+struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
+ : public false_type {}; // NOLINT
+
+// Converting a floating-point to another floating-point is lossless
+// iff the target type is at least as big as the source type.
+template <typename From, typename To>
+struct LosslessArithmeticConvertibleImpl<
+ kFloatingPoint, From, kFloatingPoint, To>
+ : public bool_constant<sizeof(From) <= sizeof(To)> {}; // NOLINT
+
+// LosslessArithmeticConvertible<From, To>::value is true iff arithmetic
+// type From can be losslessly converted to arithmetic type To.
+//
+// It's the user's responsibility to ensure that both From and To are
+// raw (i.e. has no CV modifier, is not a pointer, and is not a
+// reference) built-in arithmetic types; the value is
+// implementation-defined when the above pre-condition is violated.
+template <typename From, typename To>
+struct LosslessArithmeticConvertible
+ : public LosslessArithmeticConvertibleImpl<
+ GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {}; // NOLINT
+
+// This interface knows how to report a Google Mock failure (either
+// non-fatal or fatal).
+class FailureReporterInterface {
+ public:
+ // The type of a failure (either non-fatal or fatal).
+ enum FailureType {
+ NONFATAL, FATAL
+ };
+
+ virtual ~FailureReporterInterface() {}
+
+ // Reports a failure that occurred at the given source file location.
+ virtual void ReportFailure(FailureType type, const char* file, int line,
+ const string& message) = 0;
+};
+
+// Returns the failure reporter used by Google Mock.
+FailureReporterInterface* GetFailureReporter();
+
+// Asserts that condition is true; aborts the process with the given
+// message if condition is false. We cannot use LOG(FATAL) or CHECK()
+// as Google Mock might be used to mock the log sink itself. We
+// inline this function to prevent it from showing up in the stack
+// trace.
+inline void Assert(bool condition, const char* file, int line,
+ const string& msg) {
+ if (!condition) {
+ GetFailureReporter()->ReportFailure(FailureReporterInterface::FATAL,
+ file, line, msg);
+ }
+}
+inline void Assert(bool condition, const char* file, int line) {
+ Assert(condition, file, line, "Assertion failed.");
+}
+
+// Verifies that condition is true; generates a non-fatal failure if
+// condition is false.
+inline void Expect(bool condition, const char* file, int line,
+ const string& msg) {
+ if (!condition) {
+ GetFailureReporter()->ReportFailure(FailureReporterInterface::NONFATAL,
+ file, line, msg);
+ }
+}
+inline void Expect(bool condition, const char* file, int line) {
+ Expect(condition, file, line, "Expectation failed.");
+}
+
+// Severity level of a log.
+enum LogSeverity {
+ INFO = 0,
+ WARNING = 1
+};
+
+// Valid values for the --gmock_verbose flag.
+
+// All logs (informational and warnings) are printed.
+const char kInfoVerbosity[] = "info";
+// Only warnings are printed.
+const char kWarningVerbosity[] = "warning";
+// No logs are printed.
+const char kErrorVerbosity[] = "error";
+
+// Returns true iff a log with the given severity is visible according
+// to the --gmock_verbose flag.
+bool LogIsVisible(LogSeverity severity);
+
+// Prints the given message to stdout iff 'severity' >= the level
+// specified by the --gmock_verbose flag. If stack_frames_to_skip >=
+// 0, also prints the stack trace excluding the top
+// stack_frames_to_skip frames. In opt mode, any positive
+// stack_frames_to_skip is treated as 0, since we don't know which
+// function calls will be inlined by the compiler and need to be
+// conservative.
+void Log(LogSeverity severity, const string& message, int stack_frames_to_skip);
+
+// TODO(wan@google.com): group all type utilities together.
+
+// Type traits.
+
+// is_reference<T>::value is non-zero iff T is a reference type.
+template <typename T> struct is_reference : public false_type {};
+template <typename T> struct is_reference<T&> : public true_type {};
+
+// type_equals<T1, T2>::value is non-zero iff T1 and T2 are the same type.
+template <typename T1, typename T2> struct type_equals : public false_type {};
+template <typename T> struct type_equals<T, T> : public true_type {};
+
+// remove_reference<T>::type removes the reference from type T, if any.
+template <typename T> struct remove_reference { typedef T type; }; // NOLINT
+template <typename T> struct remove_reference<T&> { typedef T type; }; // NOLINT
+
+// Invalid<T>() returns an invalid value of type T. This is useful
+// when a value of type T is needed for compilation, but the statement
+// will not really be executed (or we don't care if the statement
+// crashes).
+template <typename T>
+inline T Invalid() {
+ return *static_cast<typename remove_reference<T>::type*>(NULL);
+}
+template <>
+inline void Invalid<void>() {}
+
+// Given a raw type (i.e. having no top-level reference or const
+// modifier) RawContainer that's either an STL-style container or a
+// native array, class StlContainerView<RawContainer> has the
+// following members:
+//
+// - type is a type that provides an STL-style container view to
+// (i.e. implements the STL container concept for) RawContainer;
+// - const_reference is a type that provides a reference to a const
+// RawContainer;
+// - ConstReference(raw_container) returns a const reference to an STL-style
+// container view to raw_container, which is a RawContainer.
+// - Copy(raw_container) returns an STL-style container view of a
+// copy of raw_container, which is a RawContainer.
+//
+// This generic version is used when RawContainer itself is already an
+// STL-style container.
+template <class RawContainer>
+class StlContainerView {
+ public:
+ typedef RawContainer type;
+ typedef const type& const_reference;
+
+ static const_reference ConstReference(const RawContainer& container) {
+ // Ensures that RawContainer is not a const type.
+ testing::StaticAssertTypeEq<RawContainer,
+ GTEST_REMOVE_CONST_(RawContainer)>();
+ return container;
+ }
+ static type Copy(const RawContainer& container) { return container; }
+};
+
+// This specialization is used when RawContainer is a native array type.
+template <typename Element, size_t N>
+class StlContainerView<Element[N]> {
+ public:
+ typedef GTEST_REMOVE_CONST_(Element) RawElement;
+ typedef internal::NativeArray<RawElement> type;
+ // NativeArray<T> can represent a native array either by value or by
+ // reference (selected by a constructor argument), so 'const type'
+ // can be used to reference a const native array. We cannot
+ // 'typedef const type& const_reference' here, as that would mean
+ // ConstReference() has to return a reference to a local variable.
+ typedef const type const_reference;
+
+ static const_reference ConstReference(const Element (&array)[N]) {
+ // Ensures that Element is not a const type.
+ testing::StaticAssertTypeEq<Element, RawElement>();
+#if GTEST_OS_SYMBIAN
+ // The Nokia Symbian compiler confuses itself in template instantiation
+ // for this call without the cast to Element*:
+ // function call '[testing::internal::NativeArray<char *>].NativeArray(
+ // {lval} const char *[4], long, testing::internal::RelationToSource)'
+ // does not match
+ // 'testing::internal::NativeArray<char *>::NativeArray(
+ // char *const *, unsigned int, testing::internal::RelationToSource)'
+ // (instantiating: 'testing::internal::ContainsMatcherImpl
+ // <const char * (&)[4]>::Matches(const char * (&)[4]) const')
+ // (instantiating: 'testing::internal::StlContainerView<char *[4]>::
+ // ConstReference(const char * (&)[4])')
+ // (and though the N parameter type is mismatched in the above explicit
+ // conversion of it doesn't help - only the conversion of the array).
+ return type(const_cast<Element*>(&array[0]), N, kReference);
+#else
+ return type(array, N, kReference);
+#endif // GTEST_OS_SYMBIAN
+ }
+ static type Copy(const Element (&array)[N]) {
+#if GTEST_OS_SYMBIAN
+ return type(const_cast<Element*>(&array[0]), N, kCopy);
+#else
+ return type(array, N, kCopy);
+#endif // GTEST_OS_SYMBIAN
+ }
+};
+
+// This specialization is used when RawContainer is a native array
+// represented as a (pointer, size) tuple.
+template <typename ElementPointer, typename Size>
+class StlContainerView< ::std::tr1::tuple<ElementPointer, Size> > {
+ public:
+ typedef GTEST_REMOVE_CONST_(
+ typename internal::PointeeOf<ElementPointer>::type) RawElement;
+ typedef internal::NativeArray<RawElement> type;
+ typedef const type const_reference;
+
+ static const_reference ConstReference(
+ const ::std::tr1::tuple<ElementPointer, Size>& array) {
+ using ::std::tr1::get;
+ return type(get<0>(array), get<1>(array), kReference);
+ }
+ static type Copy(const ::std::tr1::tuple<ElementPointer, Size>& array) {
+ using ::std::tr1::get;
+ return type(get<0>(array), get<1>(array), kCopy);
+ }
+};
+
+// The following specialization prevents the user from instantiating
+// StlContainer with a reference type.
+template <typename T> class StlContainerView<T&>;
+
+} // namespace internal
+} // namespace testing
+
+#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
diff --git a/lib/gtest/include/gmock/internal/gmock-port.h b/lib/gtest/include/gmock/internal/gmock-port.h
new file mode 100644
index 0000000..3b9cc47
--- /dev/null
+++ b/lib/gtest/include/gmock/internal/gmock-port.h
@@ -0,0 +1,78 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: vadimb@google.com (Vadim Berman)
+//
+// Low-level types and utilities for porting Google Mock to various
+// platforms. They are subject to change without notice. DO NOT USE
+// THEM IN USER CODE.
+
+#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
+#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
+
+#include <assert.h>
+#include <stdlib.h>
+#include <iostream>
+
+// Most of the types needed for porting Google Mock are also required
+// for Google Test and are defined in gtest-port.h.
+#include "gtest/internal/gtest-linked_ptr.h"
+#include "gtest/internal/gtest-port.h"
+
+// To avoid conditional compilation everywhere, we make it
+// gmock-port.h's responsibility to #include the header implementing
+// tr1/tuple. gmock-port.h does this via gtest-port.h, which is
+// guaranteed to pull in the tuple header.
+
+// For MS Visual C++, check the compiler version. At least VS 2003 is
+// required to compile Google Mock.
+#if defined(_MSC_VER) && _MSC_VER < 1310
+# error "At least Visual C++ 2003 (7.1) is required to compile Google Mock."
+#endif
+
+// Macro for referencing flags. This is public as we want the user to
+// use this syntax to reference Google Mock flags.
+#define GMOCK_FLAG(name) FLAGS_gmock_##name
+
+// Macros for declaring flags.
+#define GMOCK_DECLARE_bool_(name) extern bool GMOCK_FLAG(name)
+#define GMOCK_DECLARE_int32_(name) \
+ extern ::testing::internal::Int32 GMOCK_FLAG(name)
+#define GMOCK_DECLARE_string_(name) \
+ extern ::testing::internal::String GMOCK_FLAG(name)
+
+// Macros for defining flags.
+#define GMOCK_DEFINE_bool_(name, default_val, doc) \
+ bool GMOCK_FLAG(name) = (default_val)
+#define GMOCK_DEFINE_int32_(name, default_val, doc) \
+ ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)
+#define GMOCK_DEFINE_string_(name, default_val, doc) \
+ ::testing::internal::String GMOCK_FLAG(name) = (default_val)
+
+#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
diff --git a/lib/gtest/src/gmock-all.cc b/lib/gtest/src/gmock-all.cc
new file mode 100644
index 0000000..7aebce7
--- /dev/null
+++ b/lib/gtest/src/gmock-all.cc
@@ -0,0 +1,47 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+//
+// Google C++ Mocking Framework (Google Mock)
+//
+// This file #includes all Google Mock implementation .cc files. The
+// purpose is to allow a user to build Google Mock by compiling this
+// file alone.
+
+// This line ensures that gmock.h can be compiled on its own, even
+// when it's fused.
+#include "gmock/gmock.h"
+
+// The following lines pull in the real gmock *.cc files.
+#include "src/gmock-cardinalities.cc"
+#include "src/gmock-internal-utils.cc"
+#include "src/gmock-matchers.cc"
+#include "src/gmock-spec-builders.cc"
+#include "src/gmock.cc"
diff --git a/lib/gtest/src/gmock-cardinalities.cc b/lib/gtest/src/gmock-cardinalities.cc
new file mode 100644
index 0000000..1a7902b
--- /dev/null
+++ b/lib/gtest/src/gmock-cardinalities.cc
@@ -0,0 +1,155 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements cardinalities.
+
+#include "gmock/gmock-cardinalities.h"
+
+#include <limits.h>
+#include <ostream> // NOLINT
+#include <sstream>
+#include <string>
+#include "gmock/internal/gmock-internal-utils.h"
+#include "gtest/gtest.h"
+
+namespace testing {
+
+namespace {
+
+// Implements the Between(m, n) cardinality.
+class BetweenCardinalityImpl : public CardinalityInterface {
+ public:
+ BetweenCardinalityImpl(int min, int max)
+ : min_(min >= 0 ? min : 0),
+ max_(max >= min_ ? max : min_) {
+ std::stringstream ss;
+ if (min < 0) {
+ ss << "The invocation lower bound must be >= 0, "
+ << "but is actually " << min << ".";
+ internal::Expect(false, __FILE__, __LINE__, ss.str());
+ } else if (max < 0) {
+ ss << "The invocation upper bound must be >= 0, "
+ << "but is actually " << max << ".";
+ internal::Expect(false, __FILE__, __LINE__, ss.str());
+ } else if (min > max) {
+ ss << "The invocation upper bound (" << max
+ << ") must be >= the invocation lower bound (" << min
+ << ").";
+ internal::Expect(false, __FILE__, __LINE__, ss.str());
+ }
+ }
+
+ // Conservative estimate on the lower/upper bound of the number of
+ // calls allowed.
+ virtual int ConservativeLowerBound() const { return min_; }
+ virtual int ConservativeUpperBound() const { return max_; }
+
+ virtual bool IsSatisfiedByCallCount(int call_count) const {
+ return min_ <= call_count && call_count <= max_ ;
+ }
+
+ virtual bool IsSaturatedByCallCount(int call_count) const {
+ return call_count >= max_;
+ }
+
+ virtual void DescribeTo(::std::ostream* os) const;
+ private:
+ const int min_;
+ const int max_;
+
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(BetweenCardinalityImpl);
+};
+
+// Formats "n times" in a human-friendly way.
+inline internal::string FormatTimes(int n) {
+ if (n == 1) {
+ return "once";
+ } else if (n == 2) {
+ return "twice";
+ } else {
+ std::stringstream ss;
+ ss << n << " times";
+ return ss.str();
+ }
+}
+
+// Describes the Between(m, n) cardinality in human-friendly text.
+void BetweenCardinalityImpl::DescribeTo(::std::ostream* os) const {
+ if (min_ == 0) {
+ if (max_ == 0) {
+ *os << "never called";
+ } else if (max_ == INT_MAX) {
+ *os << "called any number of times";
+ } else {
+ *os << "called at most " << FormatTimes(max_);
+ }
+ } else if (min_ == max_) {
+ *os << "called " << FormatTimes(min_);
+ } else if (max_ == INT_MAX) {
+ *os << "called at least " << FormatTimes(min_);
+ } else {
+ // 0 < min_ < max_ < INT_MAX
+ *os << "called between " << min_ << " and " << max_ << " times";
+ }
+}
+
+} // Unnamed namespace
+
+// Describes the given call count to an ostream.
+void Cardinality::DescribeActualCallCountTo(int actual_call_count,
+ ::std::ostream* os) {
+ if (actual_call_count > 0) {
+ *os << "called " << FormatTimes(actual_call_count);
+ } else {
+ *os << "never called";
+ }
+}
+
+// Creates a cardinality that allows at least n calls.
+Cardinality AtLeast(int n) { return Between(n, INT_MAX); }
+
+// Creates a cardinality that allows at most n calls.
+Cardinality AtMost(int n) { return Between(0, n); }
+
+// Creates a cardinality that allows any number of calls.
+Cardinality AnyNumber() { return AtLeast(0); }
+
+// Creates a cardinality that allows between min and max calls.
+Cardinality Between(int min, int max) {
+ return Cardinality(new BetweenCardinalityImpl(min, max));
+}
+
+// Creates a cardinality that allows exactly n calls.
+Cardinality Exactly(int n) { return Between(n, n); }
+
+} // namespace testing
diff --git a/lib/gtest/src/gmock-internal-utils.cc b/lib/gtest/src/gmock-internal-utils.cc
new file mode 100644
index 0000000..dd38132
--- /dev/null
+++ b/lib/gtest/src/gmock-internal-utils.cc
@@ -0,0 +1,173 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file defines some utilities useful for implementing Google
+// Mock. They are subject to change without notice, so please DO NOT
+// USE THEM IN USER CODE.
+
+#include "gmock/internal/gmock-internal-utils.h"
+
+#include <ctype.h>
+#include <ostream> // NOLINT
+#include <string>
+#include "gmock/gmock.h"
+#include "gmock/internal/gmock-port.h"
+#include "gtest/gtest.h"
+
+namespace testing {
+namespace internal {
+
+// Converts an identifier name to a space-separated list of lower-case
+// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
+// treated as one word. For example, both "FooBar123" and
+// "foo_bar_123" are converted to "foo bar 123".
+string ConvertIdentifierNameToWords(const char* id_name) {
+ string result;
+ char prev_char = '\0';
+ for (const char* p = id_name; *p != '\0'; prev_char = *(p++)) {
+ // We don't care about the current locale as the input is
+ // guaranteed to be a valid C++ identifier name.
+ const bool starts_new_word = IsUpper(*p) ||
+ (!IsAlpha(prev_char) && IsLower(*p)) ||
+ (!IsDigit(prev_char) && IsDigit(*p));
+
+ if (IsAlNum(*p)) {
+ if (starts_new_word && result != "")
+ result += ' ';
+ result += ToLower(*p);
+ }
+ }
+ return result;
+}
+
+// This class reports Google Mock failures as Google Test failures. A
+// user can define another class in a similar fashion if he intends to
+// use Google Mock with a testing framework other than Google Test.
+class GoogleTestFailureReporter : public FailureReporterInterface {
+ public:
+ virtual void ReportFailure(FailureType type, const char* file, int line,
+ const string& message) {
+ AssertHelper(type == FATAL ?
+ TestPartResult::kFatalFailure :
+ TestPartResult::kNonFatalFailure,
+ file,
+ line,
+ message.c_str()) = Message();
+ if (type == FATAL) {
+ posix::Abort();
+ }
+ }
+};
+
+// Returns the global failure reporter. Will create a
+// GoogleTestFailureReporter and return it the first time called.
+FailureReporterInterface* GetFailureReporter() {
+ // Points to the global failure reporter used by Google Mock. gcc
+ // guarantees that the following use of failure_reporter is
+ // thread-safe. We may need to add additional synchronization to
+ // protect failure_reporter if we port Google Mock to other
+ // compilers.
+ static FailureReporterInterface* const failure_reporter =
+ new GoogleTestFailureReporter();
+ return failure_reporter;
+}
+
+// Protects global resources (stdout in particular) used by Log().
+static GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex);
+
+// Returns true iff a log with the given severity is visible according
+// to the --gmock_verbose flag.
+bool LogIsVisible(LogSeverity severity) {
+ if (GMOCK_FLAG(verbose) == kInfoVerbosity) {
+ // Always show the log if --gmock_verbose=info.
+ return true;
+ } else if (GMOCK_FLAG(verbose) == kErrorVerbosity) {
+ // Always hide it if --gmock_verbose=error.
+ return false;
+ } else {
+ // If --gmock_verbose is neither "info" nor "error", we treat it
+ // as "warning" (its default value).
+ return severity == WARNING;
+ }
+}
+
+// Prints the given message to stdout iff 'severity' >= the level
+// specified by the --gmock_verbose flag. If stack_frames_to_skip >=
+// 0, also prints the stack trace excluding the top
+// stack_frames_to_skip frames. In opt mode, any positive
+// stack_frames_to_skip is treated as 0, since we don't know which
+// function calls will be inlined by the compiler and need to be
+// conservative.
+void Log(LogSeverity severity, const string& message,
+ int stack_frames_to_skip) {
+ if (!LogIsVisible(severity))
+ return;
+
+ // Ensures that logs from different threads don't interleave.
+ MutexLock l(&g_log_mutex);
+
+ // "using ::std::cout;" doesn't work with Symbian's STLport, where cout is a
+ // macro.
+
+ if (severity == WARNING) {
+ // Prints a GMOCK WARNING marker to make the warnings easily searchable.
+ std::cout << "\nGMOCK WARNING:";
+ }
+ // Pre-pends a new-line to message if it doesn't start with one.
+ if (message.empty() || message[0] != '\n') {
+ std::cout << "\n";
+ }
+ std::cout << message;
+ if (stack_frames_to_skip >= 0) {
+#ifdef NDEBUG
+ // In opt mode, we have to be conservative and skip no stack frame.
+ const int actual_to_skip = 0;
+#else
+ // In dbg mode, we can do what the caller tell us to do (plus one
+ // for skipping this function's stack frame).
+ const int actual_to_skip = stack_frames_to_skip + 1;
+#endif // NDEBUG
+
+ // Appends a new-line to message if it doesn't end with one.
+ if (!message.empty() && *message.rbegin() != '\n') {
+ std::cout << "\n";
+ }
+ std::cout << "Stack trace:\n"
+ << ::testing::internal::GetCurrentOsStackTraceExceptTop(
+ ::testing::UnitTest::GetInstance(), actual_to_skip);
+ }
+ std::cout << ::std::flush;
+}
+
+} // namespace internal
+} // namespace testing
diff --git a/lib/gtest/src/gmock-matchers.cc b/lib/gtest/src/gmock-matchers.cc
new file mode 100644
index 0000000..a5e6824
--- /dev/null
+++ b/lib/gtest/src/gmock-matchers.cc
@@ -0,0 +1,101 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements Matcher<const string&>, Matcher<string>, and
+// utilities for defining matchers.
+
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock-generated-matchers.h"
+
+#include <string.h>
+#include <sstream>
+#include <string>
+
+namespace testing {
+
+// Constructs a matcher that matches a const string& whose value is
+// equal to s.
+Matcher<const internal::string&>::Matcher(const internal::string& s) {
+ *this = Eq(s);
+}
+
+// Constructs a matcher that matches a const string& whose value is
+// equal to s.
+Matcher<const internal::string&>::Matcher(const char* s) {
+ *this = Eq(internal::string(s));
+}
+
+// Constructs a matcher that matches a string whose value is equal to s.
+Matcher<internal::string>::Matcher(const internal::string& s) { *this = Eq(s); }
+
+// Constructs a matcher that matches a string whose value is equal to s.
+Matcher<internal::string>::Matcher(const char* s) {
+ *this = Eq(internal::string(s));
+}
+
+namespace internal {
+
+// Joins a vector of strings as if they are fields of a tuple; returns
+// the joined string.
+string JoinAsTuple(const Strings& fields) {
+ switch (fields.size()) {
+ case 0:
+ return "";
+ case 1:
+ return fields[0];
+ default:
+ string result = "(" + fields[0];
+ for (size_t i = 1; i < fields.size(); i++) {
+ result += ", ";
+ result += fields[i];
+ }
+ result += ")";
+ return result;
+ }
+}
+
+// Returns the description for a matcher defined using the MATCHER*()
+// macro where the user-supplied description string is "", if
+// 'negation' is false; otherwise returns the description of the
+// negation of the matcher. 'param_values' contains a list of strings
+// that are the print-out of the matcher's parameters.
+string FormatMatcherDescription(bool negation, const char* matcher_name,
+ const Strings& param_values) {
+ string result = ConvertIdentifierNameToWords(matcher_name);
+ if (param_values.size() >= 1)
+ result += " " + JoinAsTuple(param_values);
+ return negation ? "not (" + result + ")" : result;
+}
+
+} // namespace internal
+} // namespace testing
diff --git a/lib/gtest/src/gmock-spec-builders.cc b/lib/gtest/src/gmock-spec-builders.cc
new file mode 100644
index 0000000..aa33cc4
--- /dev/null
+++ b/lib/gtest/src/gmock-spec-builders.cc
@@ -0,0 +1,797 @@
+// Copyright 2007, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+// Google Mock - a framework for writing C++ mock classes.
+//
+// This file implements the spec builder syntax (ON_CALL and
+// EXPECT_CALL).
+
+#include "gmock/gmock-spec-builders.h"
+
+#include <stdlib.h>
+#include <iostream> // NOLINT
+#include <map>
+#include <set>
+#include <string>
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC
+# include <unistd.h> // NOLINT
+#endif
+
+namespace testing {
+namespace internal {
+
+// Protects the mock object registry (in class Mock), all function
+// mockers, and all expectations.
+GTEST_DEFINE_STATIC_MUTEX_(g_gmock_mutex);
+
+// Logs a message including file and line number information.
+void LogWithLocation(testing::internal::LogSeverity severity,
+ const char* file, int line,
+ const string& message) {
+ ::std::ostringstream s;
+ s << file << ":" << line << ": " << message << ::std::endl;
+ Log(severity, s.str(), 0);
+}
+
+// Constructs an ExpectationBase object.
+ExpectationBase::ExpectationBase(const char* a_file,
+ int a_line,
+ const string& a_source_text)
+ : file_(a_file),
+ line_(a_line),
+ source_text_(a_source_text),
+ cardinality_specified_(false),
+ cardinality_(Exactly(1)),
+ call_count_(0),
+ retired_(false),
+ extra_matcher_specified_(false),
+ repeated_action_specified_(false),
+ retires_on_saturation_(false),
+ last_clause_(kNone),
+ action_count_checked_(false) {}
+
+// Destructs an ExpectationBase object.
+ExpectationBase::~ExpectationBase() {}
+
+// Explicitly specifies the cardinality of this expectation. Used by
+// the subclasses to implement the .Times() clause.
+void ExpectationBase::SpecifyCardinality(const Cardinality& a_cardinality) {
+ cardinality_specified_ = true;
+ cardinality_ = a_cardinality;
+}
+
+// Retires all pre-requisites of this expectation.
+void ExpectationBase::RetireAllPreRequisites() {
+ if (is_retired()) {
+ // We can take this short-cut as we never retire an expectation
+ // until we have retired all its pre-requisites.
+ return;
+ }
+
+ for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin();
+ it != immediate_prerequisites_.end(); ++it) {
+ ExpectationBase* const prerequisite = it->expectation_base().get();
+ if (!prerequisite->is_retired()) {
+ prerequisite->RetireAllPreRequisites();
+ prerequisite->Retire();
+ }
+ }
+}
+
+// Returns true iff all pre-requisites of this expectation have been
+// satisfied.
+// L >= g_gmock_mutex
+bool ExpectationBase::AllPrerequisitesAreSatisfied() const {
+ g_gmock_mutex.AssertHeld();
+ for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin();
+ it != immediate_prerequisites_.end(); ++it) {
+ if (!(it->expectation_base()->IsSatisfied()) ||
+ !(it->expectation_base()->AllPrerequisitesAreSatisfied()))
+ return false;
+ }
+ return true;
+}
+
+// Adds unsatisfied pre-requisites of this expectation to 'result'.
+// L >= g_gmock_mutex
+void ExpectationBase::FindUnsatisfiedPrerequisites(
+ ExpectationSet* result) const {
+ g_gmock_mutex.AssertHeld();
+ for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin();
+ it != immediate_prerequisites_.end(); ++it) {
+ if (it->expectation_base()->IsSatisfied()) {
+ // If *it is satisfied and has a call count of 0, some of its
+ // pre-requisites may not be satisfied yet.
+ if (it->expectation_base()->call_count_ == 0) {
+ it->expectation_base()->FindUnsatisfiedPrerequisites(result);
+ }
+ } else {
+ // Now that we know *it is unsatisfied, we are not so interested
+ // in whether its pre-requisites are satisfied. Therefore we
+ // don't recursively call FindUnsatisfiedPrerequisites() here.
+ *result += *it;
+ }
+ }
+}
+
+// Describes how many times a function call matching this
+// expectation has occurred.
+// L >= g_gmock_mutex
+void ExpectationBase::DescribeCallCountTo(::std::ostream* os) const {
+ g_gmock_mutex.AssertHeld();
+
+ // Describes how many times the function is expected to be called.
+ *os << " Expected: to be ";
+ cardinality().DescribeTo(os);
+ *os << "\n Actual: ";
+ Cardinality::DescribeActualCallCountTo(call_count(), os);
+
+ // Describes the state of the expectation (e.g. is it satisfied?
+ // is it active?).
+ *os << " - " << (IsOverSaturated() ? "over-saturated" :
+ IsSaturated() ? "saturated" :
+ IsSatisfied() ? "satisfied" : "unsatisfied")
+ << " and "
+ << (is_retired() ? "retired" : "active");
+}
+
+// Checks the action count (i.e. the number of WillOnce() and
+// WillRepeatedly() clauses) against the cardinality if this hasn't
+// been done before. Prints a warning if there are too many or too
+// few actions.
+// L < mutex_
+void ExpectationBase::CheckActionCountIfNotDone() const {
+ bool should_check = false;
+ {
+ MutexLock l(&mutex_);
+ if (!action_count_checked_) {
+ action_count_checked_ = true;
+ should_check = true;
+ }
+ }
+
+ if (should_check) {
+ if (!cardinality_specified_) {
+ // The cardinality was inferred - no need to check the action
+ // count against it.
+ return;
+ }
+
+ // The cardinality was explicitly specified.
+ const int action_count = static_cast<int>(untyped_actions_.size());
+ const int upper_bound = cardinality().ConservativeUpperBound();
+ const int lower_bound = cardinality().ConservativeLowerBound();
+ bool too_many; // True if there are too many actions, or false
+ // if there are too few.
+ if (action_count > upper_bound ||
+ (action_count == upper_bound && repeated_action_specified_)) {
+ too_many = true;
+ } else if (0 < action_count && action_count < lower_bound &&
+ !repeated_action_specified_) {
+ too_many = false;
+ } else {
+ return;
+ }
+
+ ::std::stringstream ss;
+ DescribeLocationTo(&ss);
+ ss << "Too " << (too_many ? "many" : "few")
+ << " actions specified in " << source_text() << "...\n"
+ << "Expected to be ";
+ cardinality().DescribeTo(&ss);
+ ss << ", but has " << (too_many ? "" : "only ")
+ << action_count << " WillOnce()"
+ << (action_count == 1 ? "" : "s");
+ if (repeated_action_specified_) {
+ ss << " and a WillRepeatedly()";
+ }
+ ss << ".";
+ Log(WARNING, ss.str(), -1); // -1 means "don't print stack trace".
+ }
+}
+
+// Implements the .Times() clause.
+void ExpectationBase::UntypedTimes(const Cardinality& a_cardinality) {
+ if (last_clause_ == kTimes) {
+ ExpectSpecProperty(false,
+ ".Times() cannot appear "
+ "more than once in an EXPECT_CALL().");
+ } else {
+ ExpectSpecProperty(last_clause_ < kTimes,
+ ".Times() cannot appear after "
+ ".InSequence(), .WillOnce(), .WillRepeatedly(), "
+ "or .RetiresOnSaturation().");
+ }
+ last_clause_ = kTimes;
+
+ SpecifyCardinality(a_cardinality);
+}
+
+// Points to the implicit sequence introduced by a living InSequence
+// object (if any) in the current thread or NULL.
+ThreadLocal<Sequence*> g_gmock_implicit_sequence;
+
+// Reports an uninteresting call (whose description is in msg) in the
+// manner specified by 'reaction'.
+void ReportUninterestingCall(CallReaction reaction, const string& msg) {
+ switch (reaction) {
+ case ALLOW:
+ Log(INFO, msg, 3);
+ break;
+ case WARN:
+ Log(WARNING, msg, 3);
+ break;
+ default: // FAIL
+ Expect(false, NULL, -1, msg);
+ }
+}
+
+UntypedFunctionMockerBase::UntypedFunctionMockerBase()
+ : mock_obj_(NULL), name_("") {}
+
+UntypedFunctionMockerBase::~UntypedFunctionMockerBase() {}
+
+// Sets the mock object this mock method belongs to, and registers
+// this information in the global mock registry. Will be called
+// whenever an EXPECT_CALL() or ON_CALL() is executed on this mock
+// method.
+// L < g_gmock_mutex
+void UntypedFunctionMockerBase::RegisterOwner(const void* mock_obj) {
+ {
+ MutexLock l(&g_gmock_mutex);
+ mock_obj_ = mock_obj;
+ }
+ Mock::Register(mock_obj, this);
+}
+
+// Sets the mock object this mock method belongs to, and sets the name
+// of the mock function. Will be called upon each invocation of this
+// mock function.
+// L < g_gmock_mutex
+void UntypedFunctionMockerBase::SetOwnerAndName(
+ const void* mock_obj, const char* name) {
+ // We protect name_ under g_gmock_mutex in case this mock function
+ // is called from two threads concurrently.
+ MutexLock l(&g_gmock_mutex);
+ mock_obj_ = mock_obj;
+ name_ = name;
+}
+
+// Returns the name of the function being mocked. Must be called
+// after RegisterOwner() or SetOwnerAndName() has been called.
+// L < g_gmock_mutex
+const void* UntypedFunctionMockerBase::MockObject() const {
+ const void* mock_obj;
+ {
+ // We protect mock_obj_ under g_gmock_mutex in case this mock
+ // function is called from two threads concurrently.
+ MutexLock l(&g_gmock_mutex);
+ Assert(mock_obj_ != NULL, __FILE__, __LINE__,
+ "MockObject() must not be called before RegisterOwner() or "
+ "SetOwnerAndName() has been called.");
+ mock_obj = mock_obj_;
+ }
+ return mock_obj;
+}
+
+// Returns the name of this mock method. Must be called after
+// SetOwnerAndName() has been called.
+// L < g_gmock_mutex
+const char* UntypedFunctionMockerBase::Name() const {
+ const char* name;
+ {
+ // We protect name_ under g_gmock_mutex in case this mock
+ // function is called from two threads concurrently.
+ MutexLock l(&g_gmock_mutex);
+ Assert(name_ != NULL, __FILE__, __LINE__,
+ "Name() must not be called before SetOwnerAndName() has "
+ "been called.");
+ name = name_;
+ }
+ return name;
+}
+
+// Calculates the result of invoking this mock function with the given
+// arguments, prints it, and returns it. The caller is responsible
+// for deleting the result.
+// L < g_gmock_mutex
+const UntypedActionResultHolderBase*
+UntypedFunctionMockerBase::UntypedInvokeWith(const void* const untyped_args) {
+ if (untyped_expectations_.size() == 0) {
+ // No expectation is set on this mock method - we have an
+ // uninteresting call.
+
+ // We must get Google Mock's reaction on uninteresting calls
+ // made on this mock object BEFORE performing the action,
+ // because the action may DELETE the mock object and make the
+ // following expression meaningless.
+ const CallReaction reaction =
+ Mock::GetReactionOnUninterestingCalls(MockObject());
+
+ // True iff we need to print this call's arguments and return
+ // value. This definition must be kept in sync with
+ // the behavior of ReportUninterestingCall().
+ const bool need_to_report_uninteresting_call =
+ // If the user allows this uninteresting call, we print it
+ // only when he wants informational messages.
+ reaction == ALLOW ? LogIsVisible(INFO) :
+ // If the user wants this to be a warning, we print it only
+ // when he wants to see warnings.
+ reaction == WARN ? LogIsVisible(WARNING) :
+ // Otherwise, the user wants this to be an error, and we
+ // should always print detailed information in the error.
+ true;
+
+ if (!need_to_report_uninteresting_call) {
+ // Perform the action without printing the call information.
+ return this->UntypedPerformDefaultAction(untyped_args, "");
+ }
+
+ // Warns about the uninteresting call.
+ ::std::stringstream ss;
+ this->UntypedDescribeUninterestingCall(untyped_args, &ss);
+
+ // Calculates the function result.
+ const UntypedActionResultHolderBase* const result =
+ this->UntypedPerformDefaultAction(untyped_args, ss.str());
+
+ // Prints the function result.
+ if (result != NULL)
+ result->PrintAsActionResult(&ss);
+
+ ReportUninterestingCall(reaction, ss.str());
+ return result;
+ }
+
+ bool is_excessive = false;
+ ::std::stringstream ss;
+ ::std::stringstream why;
+ ::std::stringstream loc;
+ const void* untyped_action = NULL;
+
+ // The UntypedFindMatchingExpectation() function acquires and
+ // releases g_gmock_mutex.
+ const ExpectationBase* const untyped_expectation =
+ this->UntypedFindMatchingExpectation(
+ untyped_args, &untyped_action, &is_excessive,
+ &ss, &why);
+ const bool found = untyped_expectation != NULL;
+
+ // True iff we need to print the call's arguments and return value.
+ // This definition must be kept in sync with the uses of Expect()
+ // and Log() in this function.
+ const bool need_to_report_call = !found || is_excessive || LogIsVisible(INFO);
+ if (!need_to_report_call) {
+ // Perform the action without printing the call information.
+ return
+ untyped_action == NULL ?
+ this->UntypedPerformDefaultAction(untyped_args, "") :
+ this->UntypedPerformAction(untyped_action, untyped_args);
+ }
+
+ ss << " Function call: " << Name();
+ this->UntypedPrintArgs(untyped_args, &ss);
+
+ // In case the action deletes a piece of the expectation, we
+ // generate the message beforehand.
+ if (found && !is_excessive) {
+ untyped_expectation->DescribeLocationTo(&loc);
+ }
+
+ const UntypedActionResultHolderBase* const result =
+ untyped_action == NULL ?
+ this->UntypedPerformDefaultAction(untyped_args, ss.str()) :
+ this->UntypedPerformAction(untyped_action, untyped_args);
+ if (result != NULL)
+ result->PrintAsActionResult(&ss);
+ ss << "\n" << why.str();
+
+ if (!found) {
+ // No expectation matches this call - reports a failure.
+ Expect(false, NULL, -1, ss.str());
+ } else if (is_excessive) {
+ // We had an upper-bound violation and the failure message is in ss.
+ Expect(false, untyped_expectation->file(),
+ untyped_expectation->line(), ss.str());
+ } else {
+ // We had an expected call and the matching expectation is
+ // described in ss.
+ Log(INFO, loc.str() + ss.str(), 2);
+ }
+
+ return result;
+}
+
+// Returns an Expectation object that references and co-owns exp,
+// which must be an expectation on this mock function.
+Expectation UntypedFunctionMockerBase::GetHandleOf(ExpectationBase* exp) {
+ for (UntypedExpectations::const_iterator it =
+ untyped_expectations_.begin();
+ it != untyped_expectations_.end(); ++it) {
+ if (it->get() == exp) {
+ return Expectation(*it);
+ }
+ }
+
+ Assert(false, __FILE__, __LINE__, "Cannot find expectation.");
+ return Expectation();
+ // The above statement is just to make the code compile, and will
+ // never be executed.
+}
+
+// Verifies that all expectations on this mock function have been
+// satisfied. Reports one or more Google Test non-fatal failures
+// and returns false if not.
+// L >= g_gmock_mutex
+bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked() {
+ g_gmock_mutex.AssertHeld();
+ bool expectations_met = true;
+ for (UntypedExpectations::const_iterator it =
+ untyped_expectations_.begin();
+ it != untyped_expectations_.end(); ++it) {
+ ExpectationBase* const untyped_expectation = it->get();
+ if (untyped_expectation->IsOverSaturated()) {
+ // There was an upper-bound violation. Since the error was
+ // already reported when it occurred, there is no need to do
+ // anything here.
+ expectations_met = false;
+ } else if (!untyped_expectation->IsSatisfied()) {
+ expectations_met = false;
+ ::std::stringstream ss;
+ ss << "Actual function call count doesn't match "
+ << untyped_expectation->source_text() << "...\n";
+ // No need to show the source file location of the expectation
+ // in the description, as the Expect() call that follows already
+ // takes care of it.
+ untyped_expectation->MaybeDescribeExtraMatcherTo(&ss);
+ untyped_expectation->DescribeCallCountTo(&ss);
+ Expect(false, untyped_expectation->file(),
+ untyped_expectation->line(), ss.str());
+ }
+ }
+ untyped_expectations_.clear();
+ return expectations_met;
+}
+
+} // namespace internal
+
+// Class Mock.
+
+namespace {
+
+typedef std::set<internal::UntypedFunctionMockerBase*> FunctionMockers;
+
+// The current state of a mock object. Such information is needed for
+// detecting leaked mock objects and explicitly verifying a mock's
+// expectations.
+struct MockObjectState {
+ MockObjectState()
+ : first_used_file(NULL), first_used_line(-1), leakable(false) {}
+
+ // Where in the source file an ON_CALL or EXPECT_CALL is first
+ // invoked on this mock object.
+ const char* first_used_file;
+ int first_used_line;
+ ::std::string first_used_test_case;
+ ::std::string first_used_test;
+ bool leakable; // true iff it's OK to leak the object.
+ FunctionMockers function_mockers; // All registered methods of the object.
+};
+
+// A global registry holding the state of all mock objects that are
+// alive. A mock object is added to this registry the first time
+// Mock::AllowLeak(), ON_CALL(), or EXPECT_CALL() is called on it. It
+// is removed from the registry in the mock object's destructor.
+class MockObjectRegistry {
+ public:
+ // Maps a mock object (identified by its address) to its state.
+ typedef std::map<const void*, MockObjectState> StateMap;
+
+ // This destructor will be called when a program exits, after all
+ // tests in it have been run. By then, there should be no mock
+ // object alive. Therefore we report any living object as test
+ // failure, unless the user explicitly asked us to ignore it.
+ ~MockObjectRegistry() {
+ // "using ::std::cout;" doesn't work with Symbian's STLport, where cout is
+ // a macro.
+
+ if (!GMOCK_FLAG(catch_leaked_mocks))
+ return;
+
+ int leaked_count = 0;
+ for (StateMap::const_iterator it = states_.begin(); it != states_.end();
+ ++it) {
+ if (it->second.leakable) // The user said it's fine to leak this object.
+ continue;
+
+ // TODO(wan@google.com): Print the type of the leaked object.
+ // This can help the user identify the leaked object.
+ std::cout << "\n";
+ const MockObjectState& state = it->second;
+ std::cout << internal::FormatFileLocation(state.first_used_file,
+ state.first_used_line);
+ std::cout << " ERROR: this mock object";
+ if (state.first_used_test != "") {
+ std::cout << " (used in test " << state.first_used_test_case << "."
+ << state.first_used_test << ")";
+ }
+ std::cout << " should be deleted but never is. Its address is @"
+ << it->first << ".";
+ leaked_count++;
+ }
+ if (leaked_count > 0) {
+ std::cout << "\nERROR: " << leaked_count
+ << " leaked mock " << (leaked_count == 1 ? "object" : "objects")
+ << " found at program exit.\n";
+ std::cout.flush();
+ ::std::cerr.flush();
+ // RUN_ALL_TESTS() has already returned when this destructor is
+ // called. Therefore we cannot use the normal Google Test
+ // failure reporting mechanism.
+ _exit(1); // We cannot call exit() as it is not reentrant and
+ // may already have been called.
+ }
+ }
+
+ StateMap& states() { return states_; }
+ private:
+ StateMap states_;
+};
+
+// Protected by g_gmock_mutex.
+MockObjectRegistry g_mock_object_registry;
+
+// Maps a mock object to the reaction Google Mock should have when an
+// uninteresting method is called. Protected by g_gmock_mutex.
+std::map<const void*, internal::CallReaction> g_uninteresting_call_reaction;
+
+// Sets the reaction Google Mock should have when an uninteresting
+// method of the given mock object is called.
+// L < g_gmock_mutex
+void SetReactionOnUninterestingCalls(const void* mock_obj,
+ internal::CallReaction reaction) {
+ internal::MutexLock l(&internal::g_gmock_mutex);
+ g_uninteresting_call_reaction[mock_obj] = reaction;
+}
+
+} // namespace
+
+// Tells Google Mock to allow uninteresting calls on the given mock
+// object.
+// L < g_gmock_mutex
+void Mock::AllowUninterestingCalls(const void* mock_obj) {
+ SetReactionOnUninterestingCalls(mock_obj, internal::ALLOW);
+}
+
+// Tells Google Mock to warn the user about uninteresting calls on the
+// given mock object.
+// L < g_gmock_mutex
+void Mock::WarnUninterestingCalls(const void* mock_obj) {
+ SetReactionOnUninterestingCalls(mock_obj, internal::WARN);
+}
+
+// Tells Google Mock to fail uninteresting calls on the given mock
+// object.
+// L < g_gmock_mutex
+void Mock::FailUninterestingCalls(const void* mock_obj) {
+ SetReactionOnUninterestingCalls(mock_obj, internal::FAIL);
+}
+
+// Tells Google Mock the given mock object is being destroyed and its
+// entry in the call-reaction table should be removed.
+// L < g_gmock_mutex
+void Mock::UnregisterCallReaction(const void* mock_obj) {
+ internal::MutexLock l(&internal::g_gmock_mutex);
+ g_uninteresting_call_reaction.erase(mock_obj);
+}
+
+// Returns the reaction Google Mock will have on uninteresting calls
+// made on the given mock object.
+// L < g_gmock_mutex
+internal::CallReaction Mock::GetReactionOnUninterestingCalls(
+ const void* mock_obj) {
+ internal::MutexLock l(&internal::g_gmock_mutex);
+ return (g_uninteresting_call_reaction.count(mock_obj) == 0) ?
+ internal::WARN : g_uninteresting_call_reaction[mock_obj];
+}
+
+// Tells Google Mock to ignore mock_obj when checking for leaked mock
+// objects.
+// L < g_gmock_mutex
+void Mock::AllowLeak(const void* mock_obj) {
+ internal::MutexLock l(&internal::g_gmock_mutex);
+ g_mock_object_registry.states()[mock_obj].leakable = true;
+}
+
+// Verifies and clears all expectations on the given mock object. If
+// the expectations aren't satisfied, generates one or more Google
+// Test non-fatal failures and returns false.
+// L < g_gmock_mutex
+bool Mock::VerifyAndClearExpectations(void* mock_obj) {
+ internal::MutexLock l(&internal::g_gmock_mutex);
+ return VerifyAndClearExpectationsLocked(mock_obj);
+}
+
+// Verifies all expectations on the given mock object and clears its
+// default actions and expectations. Returns true iff the
+// verification was successful.
+// L < g_gmock_mutex
+bool Mock::VerifyAndClear(void* mock_obj) {
+ internal::MutexLock l(&internal::g_gmock_mutex);
+ ClearDefaultActionsLocked(mock_obj);
+ return VerifyAndClearExpectationsLocked(mock_obj);
+}
+
+// Verifies and clears all expectations on the given mock object. If
+// the expectations aren't satisfied, generates one or more Google
+// Test non-fatal failures and returns false.
+// L >= g_gmock_mutex
+bool Mock::VerifyAndClearExpectationsLocked(void* mock_obj) {
+ internal::g_gmock_mutex.AssertHeld();
+ if (g_mock_object_registry.states().count(mock_obj) == 0) {
+ // No EXPECT_CALL() was set on the given mock object.
+ return true;
+ }
+
+ // Verifies and clears the expectations on each mock method in the
+ // given mock object.
+ bool expectations_met = true;
+ FunctionMockers& mockers =
+ g_mock_object_registry.states()[mock_obj].function_mockers;
+ for (FunctionMockers::const_iterator it = mockers.begin();
+ it != mockers.end(); ++it) {
+ if (!(*it)->VerifyAndClearExpectationsLocked()) {
+ expectations_met = false;
+ }
+ }
+
+ // We don't clear the content of mockers, as they may still be
+ // needed by ClearDefaultActionsLocked().
+ return expectations_met;
+}
+
+// Registers a mock object and a mock method it owns.
+// L < g_gmock_mutex
+void Mock::Register(const void* mock_obj,
+ internal::UntypedFunctionMockerBase* mocker) {
+ internal::MutexLock l(&internal::g_gmock_mutex);
+ g_mock_object_registry.states()[mock_obj].function_mockers.insert(mocker);
+}
+
+// Tells Google Mock where in the source code mock_obj is used in an
+// ON_CALL or EXPECT_CALL. In case mock_obj is leaked, this
+// information helps the user identify which object it is.
+// L < g_gmock_mutex
+void Mock::RegisterUseByOnCallOrExpectCall(
+ const void* mock_obj, const char* file, int line) {
+ internal::MutexLock l(&internal::g_gmock_mutex);
+ MockObjectState& state = g_mock_object_registry.states()[mock_obj];
+ if (state.first_used_file == NULL) {
+ state.first_used_file = file;
+ state.first_used_line = line;
+ const TestInfo* const test_info =
+ UnitTest::GetInstance()->current_test_info();
+ if (test_info != NULL) {
+ // TODO(wan@google.com): record the test case name when the
+ // ON_CALL or EXPECT_CALL is invoked from SetUpTestCase() or
+ // TearDownTestCase().
+ state.first_used_test_case = test_info->test_case_name();
+ state.first_used_test = test_info->name();
+ }
+ }
+}
+
+// Unregisters a mock method; removes the owning mock object from the
+// registry when the last mock method associated with it has been
+// unregistered. This is called only in the destructor of
+// FunctionMockerBase.
+// L >= g_gmock_mutex
+void Mock::UnregisterLocked(internal::UntypedFunctionMockerBase* mocker) {
+ internal::g_gmock_mutex.AssertHeld();
+ for (MockObjectRegistry::StateMap::iterator it =
+ g_mock_object_registry.states().begin();
+ it != g_mock_object_registry.states().end(); ++it) {
+ FunctionMockers& mockers = it->second.function_mockers;
+ if (mockers.erase(mocker) > 0) {
+ // mocker was in mockers and has been just removed.
+ if (mockers.empty()) {
+ g_mock_object_registry.states().erase(it);
+ }
+ return;
+ }
+ }
+}
+
+// Clears all ON_CALL()s set on the given mock object.
+// L >= g_gmock_mutex
+void Mock::ClearDefaultActionsLocked(void* mock_obj) {
+ internal::g_gmock_mutex.AssertHeld();
+
+ if (g_mock_object_registry.states().count(mock_obj) == 0) {
+ // No ON_CALL() was set on the given mock object.
+ return;
+ }
+
+ // Clears the default actions for each mock method in the given mock
+ // object.
+ FunctionMockers& mockers =
+ g_mock_object_registry.states()[mock_obj].function_mockers;
+ for (FunctionMockers::const_iterator it = mockers.begin();
+ it != mockers.end(); ++it) {
+ (*it)->ClearDefaultActionsLocked();
+ }
+
+ // We don't clear the content of mockers, as they may still be
+ // needed by VerifyAndClearExpectationsLocked().
+}
+
+Expectation::Expectation() {}
+
+Expectation::Expectation(
+ const internal::linked_ptr<internal::ExpectationBase>& an_expectation_base)
+ : expectation_base_(an_expectation_base) {}
+
+Expectation::~Expectation() {}
+
+// Adds an expectation to a sequence.
+void Sequence::AddExpectation(const Expectation& expectation) const {
+ if (*last_expectation_ != expectation) {
+ if (last_expectation_->expectation_base() != NULL) {
+ expectation.expectation_base()->immediate_prerequisites_
+ += *last_expectation_;
+ }
+ *last_expectation_ = expectation;
+ }
+}
+
+// Creates the implicit sequence if there isn't one.
+InSequence::InSequence() {
+ if (internal::g_gmock_implicit_sequence.get() == NULL) {
+ internal::g_gmock_implicit_sequence.set(new Sequence);
+ sequence_created_ = true;
+ } else {
+ sequence_created_ = false;
+ }
+}
+
+// Deletes the implicit sequence if it was created by the constructor
+// of this object.
+InSequence::~InSequence() {
+ if (sequence_created_) {
+ delete internal::g_gmock_implicit_sequence.get();
+ internal::g_gmock_implicit_sequence.set(NULL);
+ }
+}
+
+} // namespace testing
diff --git a/lib/gtest/src/gmock.cc b/lib/gtest/src/gmock.cc
new file mode 100644
index 0000000..700bcb2
--- /dev/null
+++ b/lib/gtest/src/gmock.cc
@@ -0,0 +1,182 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+#include "gmock/gmock.h"
+#include "gmock/internal/gmock-port.h"
+
+namespace testing {
+
+// TODO(wan@google.com): support using environment variables to
+// control the flag values, like what Google Test does.
+
+GMOCK_DEFINE_bool_(catch_leaked_mocks, true,
+ "true iff Google Mock should report leaked mock objects "
+ "as failures.");
+
+GMOCK_DEFINE_string_(verbose, internal::kWarningVerbosity,
+ "Controls how verbose Google Mock's output is."
+ " Valid values:\n"
+ " info - prints all messages.\n"
+ " warning - prints warnings and errors.\n"
+ " error - prints errors only.");
+
+namespace internal {
+
+// Parses a string as a command line flag. The string should have the
+// format "--gmock_flag=value". When def_optional is true, the
+// "=value" part can be omitted.
+//
+// Returns the value of the flag, or NULL if the parsing failed.
+static const char* ParseGoogleMockFlagValue(const char* str,
+ const char* flag,
+ bool def_optional) {
+ // str and flag must not be NULL.
+ if (str == NULL || flag == NULL) return NULL;
+
+ // The flag must start with "--gmock_".
+ const String flag_str = String::Format("--gmock_%s", flag);
+ const size_t flag_len = flag_str.length();
+ if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL;
+
+ // Skips the flag name.
+ const char* flag_end = str + flag_len;
+
+ // When def_optional is true, it's OK to not have a "=value" part.
+ if (def_optional && (flag_end[0] == '\0')) {
+ return flag_end;
+ }
+
+ // If def_optional is true and there are more characters after the
+ // flag name, or if def_optional is false, there must be a '=' after
+ // the flag name.
+ if (flag_end[0] != '=') return NULL;
+
+ // Returns the string after "=".
+ return flag_end + 1;
+}
+
+// Parses a string for a Google Mock bool flag, in the form of
+// "--gmock_flag=value".
+//
+// On success, stores the value of the flag in *value, and returns
+// true. On failure, returns false without changing *value.
+static bool ParseGoogleMockBoolFlag(const char* str, const char* flag,
+ bool* value) {
+ // Gets the value of the flag as a string.
+ const char* const value_str = ParseGoogleMockFlagValue(str, flag, true);
+
+ // Aborts if the parsing failed.
+ if (value_str == NULL) return false;
+
+ // Converts the string value to a bool.
+ *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');
+ return true;
+}
+
+// Parses a string for a Google Mock string flag, in the form of
+// "--gmock_flag=value".
+//
+// On success, stores the value of the flag in *value, and returns
+// true. On failure, returns false without changing *value.
+static bool ParseGoogleMockStringFlag(const char* str, const char* flag,
+ String* value) {
+ // Gets the value of the flag as a string.
+ const char* const value_str = ParseGoogleMockFlagValue(str, flag, false);
+
+ // Aborts if the parsing failed.
+ if (value_str == NULL) return false;
+
+ // Sets *value to the value of the flag.
+ *value = value_str;
+ return true;
+}
+
+// The internal implementation of InitGoogleMock().
+//
+// The type parameter CharType can be instantiated to either char or
+// wchar_t.
+template <typename CharType>
+void InitGoogleMockImpl(int* argc, CharType** argv) {
+ // Makes sure Google Test is initialized. InitGoogleTest() is
+ // idempotent, so it's fine if the user has already called it.
+ InitGoogleTest(argc, argv);
+ if (*argc <= 0) return;
+
+ for (int i = 1; i != *argc; i++) {
+ const String arg_string = StreamableToString(argv[i]);
+ const char* const arg = arg_string.c_str();
+
+ // Do we see a Google Mock flag?
+ if (ParseGoogleMockBoolFlag(arg, "catch_leaked_mocks",
+ &GMOCK_FLAG(catch_leaked_mocks)) ||
+ ParseGoogleMockStringFlag(arg, "verbose", &GMOCK_FLAG(verbose))) {
+ // Yes. Shift the remainder of the argv list left by one. Note
+ // that argv has (*argc + 1) elements, the last one always being
+ // NULL. The following loop moves the trailing NULL element as
+ // well.
+ for (int j = i; j != *argc; j++) {
+ argv[j] = argv[j + 1];
+ }
+
+ // Decrements the argument count.
+ (*argc)--;
+
+ // We also need to decrement the iterator as we just removed
+ // an element.
+ i--;
+ }
+ }
+}
+
+} // namespace internal
+
+// Initializes Google Mock. This must be called before running the
+// tests. In particular, it parses a command line for the flags that
+// Google Mock recognizes. Whenever a Google Mock flag is seen, it is
+// removed from argv, and *argc is decremented.
+//
+// No value is returned. Instead, the Google Mock flag variables are
+// updated.
+//
+// Since Google Test is needed for Google Mock to work, this function
+// also initializes Google Test and parses its flags, if that hasn't
+// been done.
+void InitGoogleMock(int* argc, char** argv) {
+ internal::InitGoogleMockImpl(argc, argv);
+}
+
+// This overloaded version can be used in Windows programs compiled in
+// UNICODE mode.
+void InitGoogleMock(int* argc, wchar_t** argv) {
+ internal::InitGoogleMockImpl(argc, argv);
+}
+
+} // namespace testing
diff --git a/lib/gtest/src/gmock_main.cc b/lib/gtest/src/gmock_main.cc
new file mode 100644
index 0000000..9d8aea2
--- /dev/null
+++ b/lib/gtest/src/gmock_main.cc
@@ -0,0 +1,54 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+
+#include <iostream>
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+// MS C++ compiler/linker has a bug on Windows (not on Windows CE), which
+// causes a link error when _tmain is defined in a static library and UNICODE
+// is enabled. For this reason instead of _tmain, main function is used on
+// Windows. See the following link to track the current status of this bug:
+// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=394464 // NOLINT
+#if GTEST_OS_WINDOWS_MOBILE
+# include <tchar.h> // NOLINT
+
+int _tmain(int argc, TCHAR** argv) {
+#else
+int main(int argc, char** argv) {
+#endif // GTEST_OS_WINDOWS_MOBILE
+ std::cout << "Running main() from gmock_main.cc\n";
+ // Since Google Mock depends on Google Test, InitGoogleMock() is
+ // also responsible for initializing Google Test. Therefore there's
+ // no need for calling testing::InitGoogleTest() separately.
+ testing::InitGoogleMock(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/src/CBot/resource.h b/src/CBot/resource.h
index 96a01ba..ed14240 100644
--- a/src/CBot/resource.h
+++ b/src/CBot/resource.h
@@ -15,8 +15,7 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
#pragma once
-#ifndef _RESOURCE_H_
-#define _RESOURCE_H_
+
enum EID
{
@@ -114,6 +113,9 @@ enum EID
TX_NAN,
ID_SUPER = 6000
};
+
+// TODO: refactor & change to enum!
+
#define TX_OPENPAR 5000
#define TX_CLOSEPAR 5001
#define TX_NOTBOOL 5002
@@ -174,4 +176,4 @@ enum EID
#define TX_ERRREAD 6014
#define TX_ERRWRITE 6015
-#endif //_RESOURCE_H_
+#define TX_MAX 6016
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f68a1d5..e836d95 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,6 +10,7 @@ add_subdirectory(po)
if(${TESTS})
add_subdirectory(common/test)
add_subdirectory(graphics/engine/test)
+ add_subdirectory(ui/test)
add_subdirectory(math/test)
endif()
@@ -54,7 +55,6 @@ common/logger.cpp
common/misc.cpp
common/profile.cpp
common/restext.cpp
-common/restext_strings.c
common/stringutils.cpp
graphics/core/color.cpp
graphics/engine/camera.cpp
diff --git a/src/app/app.h b/src/app/app.h
index e887a63..32f03f8 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -38,7 +38,7 @@
class CInstanceManager;
-class CEvent;
+class CEventQueue;
class CRobotMain;
class CSoundInterface;
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 7cd98b9..e621065 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -22,6 +22,7 @@
#include "app/app.h"
#include "app/system.h"
+
#include "common/logger.h"
#include "common/misc.h"
#include "common/restext.h"
@@ -73,6 +74,8 @@ int main(int argc, char *argv[])
{
CLogger logger; // Create the logger
+ InitializeRestext(); // Initialize translation strings
+
logger.Info("Colobot starting\n");
CApplication app; // single instance of the application
diff --git a/src/app/system.cpp b/src/app/system.cpp
index eb0321b..73614aa 100644
--- a/src/app/system.cpp
+++ b/src/app/system.cpp
@@ -15,7 +15,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// system.cpp
#include "app/system.h"
@@ -23,13 +22,13 @@
#if defined(PLATFORM_WINDOWS)
-#include "system_windows.h"
+#include "app/system_windows.h"
#elif defined(PLATFORM_LINUX)
-#include "system_linux.h"
+#include "app/system_linux.h"
#else
-#include "system_other.h"
+#include "app/system_other.h"
#endif
diff --git a/src/common/error_ids.h b/src/common/error_ids.h
deleted file mode 100644
index fc1f7d6..0000000
--- a/src/common/error_ids.h
+++ /dev/null
@@ -1,151 +0,0 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
-
-
-// TODO: move to global.h after restext rewrite
-
-#pragma once
-
-enum Error
-{
- ERR_OK = 0, // ok
- ERR_GENERIC = 1, // any error
- ERR_CONTINUE = 2, // continues
- ERR_STOP = 3, // stops
- ERR_CMD = 4, // unknown command
- ERR_MANIP_VEH = 100, // inappropriate vehicle
- ERR_MANIP_FLY = 101, // impossible in flight
- ERR_MANIP_BUSY = 102, // taking: hands already occupied
- ERR_MANIP_NIL = 103, // taking: nothing has to take
- ERR_MANIP_MOTOR = 105, // busy: impossible to move
- ERR_MANIP_OCC = 106, // busy: location already occupied
- ERR_MANIP_FRIEND = 107, // no other vehicle
- ERR_MANIP_RADIO = 108, // impossible because radioactive
- ERR_MANIP_WATER = 109, // not possible under water
- ERR_MANIP_EMPTY = 110, // nothing to deposit
- ERR_BUILD_FLY = 120, // not possible in flight
- ERR_BUILD_WATER = 121, // not possible under water
- ERR_BUILD_ENERGY = 122, // not enough energy
- ERR_BUILD_METALAWAY = 123, // lack of metal (too far)
- ERR_BUILD_METALNEAR = 124, // lack of metal (too close)
- ERR_BUILD_METALINEX = 125, // lack of metal
- ERR_BUILD_FLAT = 126, // not enough flat ground
- ERR_BUILD_FLATLIT = 127, // not enough flat ground space
- ERR_BUILD_BUSY = 128, // location occupied
- ERR_BUILD_BASE = 129, // too close to the rocket
- ERR_BUILD_NARROW = 130, // buildings too close
- ERR_BUILD_MOTOR = 131, // built: not possible in movement
- ERR_SEARCH_FLY = 140, // not possible in flight
- ERR_SEARCH_VEH = 141, // inappropriate vehicle
- ERR_SEARCH_MOTOR = 142, // impossible in movement
- ERR_TERRA_VEH = 150, // inappropriate vehicle
- ERR_TERRA_ENERGY = 151, // not enough energy
- ERR_TERRA_FLOOR = 152, // inappropriate ground
- ERR_TERRA_BUILDING = 153, // building too close
- ERR_TERRA_OBJECT = 154, // object too close
- ERR_FIRE_VEH = 160, // inappropriate vehicle
- ERR_FIRE_ENERGY = 161, // not enough energy
- ERR_FIRE_FLY = 162, // not possible in flight
- ERR_RECOVER_VEH = 170, // inappropriate vehicle
- ERR_RECOVER_ENERGY = 171, // not enough energy
- ERR_RECOVER_NULL = 172, // lack of ruin
- ERR_CONVERT_EMPTY = 180, // no stone was transformed
- ERR_SHIELD_VEH = 190, // inappropriate vehicle
- ERR_SHIELD_ENERGY = 191, // not enough energy
- ERR_MOVE_IMPOSSIBLE = 200, // move impossible
- ERR_FIND_IMPOSSIBLE = 201, // find impossible
- ERR_GOTO_IMPOSSIBLE = 210, // goto impossible
- ERR_GOTO_ITER = 211, // goto too complicated
- ERR_GOTO_BUSY = 212, // goto destination occupied
- ERR_DERRICK_NULL = 300, // no ore underground
- ERR_STATION_NULL = 301, // no energy underground
- ERR_TOWER_POWER = 310, // no battery
- ERR_TOWER_ENERGY = 311, // more energy
- ERR_RESEARCH_POWER = 320, // no battery
- ERR_RESEARCH_ENERGY = 321, // more energy
- ERR_RESEARCH_TYPE = 322, // the wrong type of battery
- ERR_RESEARCH_ALREADY = 323, // research already done
- ERR_ENERGY_NULL = 330, // no energy underground
- ERR_ENERGY_LOW = 331, // not enough energy
- ERR_ENERGY_EMPTY = 332, // lack of metal
- ERR_ENERGY_BAD = 333, // transforms only the metal
- ERR_BASE_DLOCK = 340, // doors locked
- ERR_BASE_DHUMAN = 341, // you must be on spaceship
- ERR_LABO_NULL = 350, // nothing to analyze
- ERR_LABO_BAD = 351, // analyzes only organic ball
- ERR_LABO_ALREADY = 352, // analysis already made
- ERR_NUCLEAR_NULL = 360, // no energy underground
- ERR_NUCLEAR_LOW = 361, // not enough energy
- ERR_NUCLEAR_EMPTY = 362, // lack of uranium
- ERR_NUCLEAR_BAD = 363, // transforms only uranium
- ERR_FACTORY_NULL = 370, // no metal
- ERR_FACTORY_NEAR = 371, // vehicle too close
- ERR_RESET_NEAR = 380, // vehicle too close
- ERR_INFO_NULL = 390, // no information terminal
- ERR_VEH_VIRUS = 400, // vehicle infected by a virus
- ERR_BAT_VIRUS = 401, // building infected by a virus
- ERR_VEH_POWER = 500, // no battery
- ERR_VEH_ENERGY = 501, // more energy
- ERR_FLAG_FLY = 510, // impossible in flight
- ERR_FLAG_WATER = 511, // impossible during swimming
- ERR_FLAG_MOTOR = 512, // impossible in movement
- ERR_FLAG_BUSY = 513, // taking: already creating flag
- ERR_FLAG_CREATE = 514, // too many flags
- ERR_FLAG_PROXY = 515, // too close
- ERR_FLAG_DELETE = 516, // nothing to remove
- ERR_MISSION_NOTERM = 600, // Mission not completed
- ERR_DELETEMOBILE = 700, // vehicle destroyed
- ERR_DELETEBUILDING = 701, // building destroyed
- ERR_TOOMANY = 702, // too many objects
- ERR_OBLIGATORYTOKEN = 800, // compulsory instruction missing
- ERR_PROHIBITEDTOKEN = 801, // instruction prohibited
-
- INFO_FIRST = 10000, // first information
- INFO_BUILD = 10001, // construction builded
- INFO_CONVERT = 10002, // metal available
- INFO_RESEARCH = 10003, // search ended
- INFO_FACTORY = 10004, // vehicle manufactured
- INFO_LABO = 10005, // analysis ended
- INFO_ENERGY = 10006, // battery available
- INFO_NUCLEAR = 10007, // nuclear battery available
- INFO_FINDING = 10008, // nuclear battery available
- INFO_MARKPOWER = 10020, // location for station found
- INFO_MARKURANIUM = 10021, // location for derrick found
- INFO_MARKSTONE = 10022, // location for derrick found
- INFO_MARKKEYa = 10023, // location for derrick found
- INFO_MARKKEYb = 10024, // location for derrick found
- INFO_MARKKEYc = 10025, // location for derrick found
- INFO_MARKKEYd = 10026, // location for derrick found
- INFO_RESEARCHTANK = 10030, // research ended
- INFO_RESEARCHFLY = 10031, // research ended
- INFO_RESEARCHTHUMP = 10032, // research ended
- INFO_RESEARCHCANON = 10033, // research ended
- INFO_RESEARCHTOWER = 10034, // research ended
- INFO_RESEARCHPHAZER = 10035, // research ended
- INFO_RESEARCHSHIELD = 10036, // research ended
- INFO_RESEARCHATOMIC = 10037, // research ended
- INFO_WIN = 10040, // win
- INFO_LOST = 10041, // lost
- INFO_LOSTq = 10042, // lost immediately
- INFO_WRITEOK = 10043, // record done
- INFO_DELETEPATH = 10050, // way mark deleted
- INFO_DELETEMOTHER = 10100, // insect killed
- INFO_DELETEANT = 10101, // insect killed
- INFO_DELETEBEE = 10102, // insect killed
- INFO_DELETEWORM = 10103, // insect killed
- INFO_DELETESPIDER = 10104, // insect killed
- INFO_BEGINSATCOM = 10105, // use your SatCom
-};
diff --git a/src/common/event.cpp b/src/common/event.cpp
index 4e5ec1a..b078dc5 100644
--- a/src/common/event.cpp
+++ b/src/common/event.cpp
@@ -16,6 +16,7 @@
#include "common/event.h"
+
#include "common/iman.h"
#include "common/logger.h"
diff --git a/src/common/event.h b/src/common/event.h
index ce2872a..169f0d0 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -23,7 +23,7 @@
#include "common/key.h"
-#include "common/event_ids.h"
+
#include "math/point.h"
#include "math/vector.h"
@@ -31,6 +31,530 @@ class CInstanceManager;
/**
+ \enum EventType
+ \brief Type of event message
+ */
+enum EventType
+{
+
+// TODO: document the meaning of each value
+
+ //! Invalid event / no event
+ EVENT_NULL = 0,
+
+ //! Event sent on user or system quit request
+ EVENT_QUIT = 1,
+
+ //! Frame update event
+ EVENT_FRAME = 2,
+
+ //! Event sent after pressing a mouse button
+ EVENT_MOUSE_BUTTON_DOWN = 3,
+ //! Event sent after releasing a mouse button
+ EVENT_MOUSE_BUTTON_UP = 4,
+ //! Event sent after moving mouse wheel up or down
+ EVENT_MOUSE_WHEEL = 5,
+ //! Event sent after moving the mouse
+ EVENT_MOUSE_MOVE = 7,
+ //! Event sent after pressing a key
+ EVENT_KEY_DOWN = 8,
+ //! Event sent after releasing a key
+ EVENT_KEY_UP = 9,
+
+ //! Event sent when application window loses/gains focus
+ EVENT_ACTIVE = 10,
+
+ //! Event sent after moving joystick axes
+ EVENT_JOY_AXIS = 12,
+ //! Event sent after pressing a joystick button
+ EVENT_JOY_BUTTON_DOWN = 13,
+ //! Event sent after releasing a joystick button
+ EVENT_JOY_BUTTON_UP = 14,
+
+
+ /* Events sent/received in game and user interface */
+
+ EVENT_UPDINTERFACE = 20,
+ EVENT_WIN = 30,
+ EVENT_LOST = 31,
+
+ //! CEdit focus
+ EVENT_FOCUS = 35,
+
+ EVENT_BUTTON_OK = 40,
+ EVENT_BUTTON_CANCEL = 41,
+ EVENT_BUTTON_NEXT = 42,
+ EVENT_BUTTON_PREV = 43,
+ EVENT_BUTTON_QUIT = 44,
+
+ EVENT_BUTTON0 = 50,
+ EVENT_BUTTON1 = 51,
+ EVENT_BUTTON2 = 52,
+ EVENT_BUTTON3 = 53,
+ EVENT_BUTTON4 = 54,
+ EVENT_BUTTON5 = 55,
+ EVENT_BUTTON6 = 56,
+ EVENT_BUTTON7 = 57,
+ EVENT_BUTTON8 = 58,
+ EVENT_BUTTON9 = 59,
+ EVENT_BUTTON10 = 60,
+ EVENT_BUTTON11 = 61,
+ EVENT_BUTTON12 = 62,
+ EVENT_BUTTON13 = 63,
+ EVENT_BUTTON14 = 64,
+ EVENT_BUTTON15 = 65,
+ EVENT_BUTTON16 = 66,
+ EVENT_BUTTON17 = 67,
+ EVENT_BUTTON18 = 68,
+ EVENT_BUTTON19 = 69,
+
+ EVENT_EDIT0 = 70,
+ EVENT_EDIT1 = 71,
+ EVENT_EDIT2 = 72,
+ EVENT_EDIT3 = 73,
+ EVENT_EDIT4 = 74,
+ EVENT_EDIT5 = 75,
+ EVENT_EDIT6 = 76,
+ EVENT_EDIT7 = 77,
+ EVENT_EDIT8 = 78,
+ EVENT_EDIT9 = 79,
+
+ EVENT_WINDOW0 = 80, // the bottom panel
+ EVENT_WINDOW1 = 81, // map
+ EVENT_WINDOW2 = 82, // CDisplayText
+ EVENT_WINDOW3 = 83, // CStudio
+ EVENT_WINDOW4 = 84, // DisplayInfo
+ EVENT_WINDOW5 = 85, // setup
+ EVENT_WINDOW6 = 86,
+ EVENT_WINDOW7 = 87,
+ EVENT_WINDOW8 = 88,
+ EVENT_WINDOW9 = 89, // dialogue
+
+ EVENT_LABEL0 = 90,
+ EVENT_LABEL1 = 91,
+ EVENT_LABEL2 = 92,
+ EVENT_LABEL3 = 93,
+ EVENT_LABEL4 = 94,
+ EVENT_LABEL5 = 95,
+ EVENT_LABEL6 = 96,
+ EVENT_LABEL7 = 97,
+ EVENT_LABEL8 = 98,
+ EVENT_LABEL9 = 99,
+ EVENT_LABEL10 = 100,
+ EVENT_LABEL11 = 101,
+ EVENT_LABEL12 = 102,
+ EVENT_LABEL13 = 103,
+ EVENT_LABEL14 = 104,
+ EVENT_LABEL15 = 105,
+ EVENT_LABEL16 = 106,
+ EVENT_LABEL17 = 107,
+ EVENT_LABEL18 = 108,
+ EVENT_LABEL19 = 109,
+
+ EVENT_LIST0 = 110,
+ EVENT_LIST1 = 111,
+ EVENT_LIST2 = 112,
+ EVENT_LIST3 = 113,
+ EVENT_LIST4 = 114,
+ EVENT_LIST5 = 115,
+ EVENT_LIST6 = 116,
+ EVENT_LIST7 = 117,
+ EVENT_LIST8 = 118,
+ EVENT_LIST9 = 119,
+
+ EVENT_TOOLTIP = 200,
+
+ EVENT_DIALOG_OK = 300,
+ EVENT_DIALOG_CANCEL = 301,
+ EVENT_DIALOG_LABEL = 302,
+ EVENT_DIALOG_LABEL1 = 303,
+ EVENT_DIALOG_LABEL2 = 304,
+ EVENT_DIALOG_LABEL3 = 305,
+ EVENT_DIALOG_LIST = 306,
+ EVENT_DIALOG_EDIT = 307,
+ EVENT_DIALOG_CHECK1 = 308,
+ EVENT_DIALOG_CHECK2 = 309,
+
+ EVENT_INTERFACE_TRAINER = 400,
+ EVENT_INTERFACE_DEFI = 401,
+ EVENT_INTERFACE_MISSION = 402,
+ EVENT_INTERFACE_FREE = 403,
+ EVENT_INTERFACE_PROTO = 404,
+ EVENT_INTERFACE_NAME = 405,
+ EVENT_INTERFACE_SETUP = 406,
+ EVENT_INTERFACE_QUIT = 407,
+ EVENT_INTERFACE_BACK = 408,
+ EVENT_INTERFACE_AGAIN = 409,
+ EVENT_INTERFACE_WRITE = 410,
+ EVENT_INTERFACE_READ = 411,
+ EVENT_INTERFACE_ABORT = 412,
+ EVENT_INTERFACE_USER = 413,
+ EVENT_INTERFACE_TEEN = 414,
+
+ EVENT_INTERFACE_CHAP = 420,
+ EVENT_INTERFACE_LIST = 421,
+ EVENT_INTERFACE_RESUME = 422,
+ EVENT_INTERFACE_PLAY = 423,
+
+ EVENT_INTERFACE_SETUPd = 430,
+ EVENT_INTERFACE_SETUPg = 431,
+ EVENT_INTERFACE_SETUPp = 432,
+ EVENT_INTERFACE_SETUPc = 433,
+ EVENT_INTERFACE_SETUPs = 434,
+
+ EVENT_INTERFACE_DEVICE = 440,
+ EVENT_INTERFACE_RESOL = 441,
+ EVENT_INTERFACE_FULL = 442,
+ EVENT_INTERFACE_APPLY = 443,
+
+ EVENT_INTERFACE_TOTO = 450,
+ EVENT_INTERFACE_SHADOW = 451,
+ EVENT_INTERFACE_DIRTY = 452,
+ EVENT_INTERFACE_LENS = 453,
+ EVENT_INTERFACE_SKY = 454,
+ EVENT_INTERFACE_PLANET = 456,
+ EVENT_INTERFACE_LIGHT = 457,
+ EVENT_INTERFACE_PARTI = 458,
+ EVENT_INTERFACE_CLIP = 459,
+ EVENT_INTERFACE_DETAIL = 460,
+ EVENT_INTERFACE_TEXTURE = 461,
+ EVENT_INTERFACE_RAIN = 462,
+ EVENT_INTERFACE_GLINT = 463,
+ EVENT_INTERFACE_TOOLTIP = 464,
+ EVENT_INTERFACE_MOVIES = 465,
+ EVENT_INTERFACE_NICERST = 466,
+ EVENT_INTERFACE_SCROLL = 467,
+ EVENT_INTERFACE_INVERTX = 468,
+ EVENT_INTERFACE_INVERTY = 469,
+ EVENT_INTERFACE_EFFECT = 470,
+ EVENT_INTERFACE_MOUSE = 471,
+ EVENT_INTERFACE_GROUND = 472,
+ EVENT_INTERFACE_GADGET = 473,
+ EVENT_INTERFACE_FOG = 474,
+ EVENT_INTERFACE_HIMSELF = 475,
+ EVENT_INTERFACE_EDITMODE= 476,
+ EVENT_INTERFACE_EDITVALUE= 477,
+ EVENT_INTERFACE_SOLUCE4 = 478,
+
+ EVENT_INTERFACE_KINFO1 = 500,
+ EVENT_INTERFACE_KINFO2 = 501,
+ EVENT_INTERFACE_KGROUP = 502,
+ EVENT_INTERFACE_KSCROLL = 503,
+ EVENT_INTERFACE_KDEF = 504,
+ EVENT_INTERFACE_KLEFT = 505,
+ EVENT_INTERFACE_KRIGHT = 506,
+ EVENT_INTERFACE_KUP = 507,
+ EVENT_INTERFACE_KDOWN = 508,
+ EVENT_INTERFACE_KGUP = 509,
+ EVENT_INTERFACE_KGDOWN = 510,
+ EVENT_INTERFACE_KCAMERA = 511,
+ EVENT_INTERFACE_KDESEL = 512,
+ EVENT_INTERFACE_KACTION = 513,
+ EVENT_INTERFACE_KNEAR = 514,
+ EVENT_INTERFACE_KAWAY = 515,
+ EVENT_INTERFACE_KNEXT = 516,
+ EVENT_INTERFACE_KHUMAN = 517,
+ EVENT_INTERFACE_KQUIT = 518,
+ EVENT_INTERFACE_KHELP = 519,
+ EVENT_INTERFACE_KPROG = 520,
+ EVENT_INTERFACE_KCBOT = 521,
+ EVENT_INTERFACE_KVISIT = 522,
+ EVENT_INTERFACE_KSPEED10= 523,
+ EVENT_INTERFACE_KSPEED15= 524,
+ EVENT_INTERFACE_KSPEED20= 525,
+ EVENT_INTERFACE_KSPEED30= 526,
+
+ EVENT_INTERFACE_VOLSOUND= 530,
+ EVENT_INTERFACE_VOLMUSIC= 531,
+ EVENT_INTERFACE_SOUND3D = 532,
+
+ EVENT_INTERFACE_MIN = 540,
+ EVENT_INTERFACE_NORM = 541,
+ EVENT_INTERFACE_MAX = 542,
+
+ EVENT_INTERFACE_SILENT = 550,
+ EVENT_INTERFACE_NOISY = 551,
+
+ EVENT_INTERFACE_JOYSTICK= 560,
+ EVENT_INTERFACE_SOLUCE = 561,
+
+ EVENT_INTERFACE_GLINTl = 570,
+ EVENT_INTERFACE_GLINTr = 571,
+ EVENT_INTERFACE_GLINTu = 572,
+ EVENT_INTERFACE_GLINTb = 573,
+
+ EVENT_INTERFACE_NEDIT = 580,
+ EVENT_INTERFACE_NLIST = 581,
+ EVENT_INTERFACE_NOK = 582,
+ EVENT_INTERFACE_NCANCEL = 583,
+ EVENT_INTERFACE_NDELETE = 584,
+ EVENT_INTERFACE_NLABEL = 585,
+
+ EVENT_INTERFACE_IOWRITE = 600,
+ EVENT_INTERFACE_IOREAD = 601,
+ EVENT_INTERFACE_IOLIST = 602,
+ EVENT_INTERFACE_IONAME = 603,
+ EVENT_INTERFACE_IOLABEL = 604,
+ EVENT_INTERFACE_IOIMAGE = 605,
+ EVENT_INTERFACE_IODELETE= 606,
+
+ EVENT_INTERFACE_PERSO = 620,
+ EVENT_INTERFACE_POK = 621,
+ EVENT_INTERFACE_PCANCEL = 622,
+ EVENT_INTERFACE_PDEF = 623,
+ EVENT_INTERFACE_PHEAD = 624,
+ EVENT_INTERFACE_PBODY = 625,
+ EVENT_INTERFACE_PLROT = 626,
+ EVENT_INTERFACE_PRROT = 627,
+ EVENT_INTERFACE_PC0a = 640,
+ EVENT_INTERFACE_PC1a = 641,
+ EVENT_INTERFACE_PC2a = 642,
+ EVENT_INTERFACE_PC3a = 643,
+ EVENT_INTERFACE_PC4a = 644,
+ EVENT_INTERFACE_PC5a = 645,
+ EVENT_INTERFACE_PC6a = 646,
+ EVENT_INTERFACE_PC7a = 647,
+ EVENT_INTERFACE_PC8a = 648,
+ EVENT_INTERFACE_PC9a = 649,
+ EVENT_INTERFACE_PCRa = 650,
+ EVENT_INTERFACE_PCGa = 651,
+ EVENT_INTERFACE_PCBa = 652,
+ EVENT_INTERFACE_PC0b = 660,
+ EVENT_INTERFACE_PC1b = 661,
+ EVENT_INTERFACE_PC2b = 662,
+ EVENT_INTERFACE_PC3b = 663,
+ EVENT_INTERFACE_PC4b = 664,
+ EVENT_INTERFACE_PC5b = 665,
+ EVENT_INTERFACE_PC6b = 666,
+ EVENT_INTERFACE_PC7b = 667,
+ EVENT_INTERFACE_PC8b = 668,
+ EVENT_INTERFACE_PC9b = 669,
+ EVENT_INTERFACE_PCRb = 670,
+ EVENT_INTERFACE_PCGb = 671,
+ EVENT_INTERFACE_PCBb = 672,
+ EVENT_INTERFACE_PFACE1 = 680,
+ EVENT_INTERFACE_PFACE2 = 681,
+ EVENT_INTERFACE_PFACE3 = 682,
+ EVENT_INTERFACE_PFACE4 = 683,
+ EVENT_INTERFACE_PGLASS0 = 690,
+ EVENT_INTERFACE_PGLASS1 = 691,
+ EVENT_INTERFACE_PGLASS2 = 692,
+ EVENT_INTERFACE_PGLASS3 = 693,
+ EVENT_INTERFACE_PGLASS4 = 694,
+ EVENT_INTERFACE_PGLASS5 = 695,
+ EVENT_INTERFACE_PGLASS6 = 696,
+ EVENT_INTERFACE_PGLASS7 = 697,
+ EVENT_INTERFACE_PGLASS8 = 698,
+ EVENT_INTERFACE_PGLASS9 = 699,
+
+ EVENT_DT_GROUP0 = 700,
+ EVENT_DT_GROUP1 = 701,
+ EVENT_DT_GROUP2 = 702,
+ EVENT_DT_GROUP3 = 703,
+ EVENT_DT_GROUP4 = 704,
+ EVENT_DT_LABEL0 = 710,
+ EVENT_DT_LABEL1 = 711,
+ EVENT_DT_LABEL2 = 712,
+ EVENT_DT_LABEL3 = 713,
+ EVENT_DT_LABEL4 = 714,
+ EVENT_DT_VISIT0 = 720,
+ EVENT_DT_VISIT1 = 721,
+ EVENT_DT_VISIT2 = 722,
+ EVENT_DT_VISIT3 = 723,
+ EVENT_DT_VISIT4 = 724,
+ EVENT_DT_END = 725,
+
+ EVENT_CMD = 800,
+ EVENT_SPEED = 801,
+
+ EVENT_HYPER_PREV = 900,
+ EVENT_HYPER_NEXT = 901,
+ EVENT_HYPER_HOME = 902,
+ EVENT_HYPER_COPY = 903,
+ EVENT_HYPER_SIZE1 = 904,
+ EVENT_HYPER_SIZE2 = 905,
+ EVENT_HYPER_SIZE3 = 906,
+ EVENT_HYPER_SIZE4 = 907,
+ EVENT_HYPER_SIZE5 = 908,
+
+ EVENT_SATCOM_HUSTON = 920,
+ EVENT_SATCOM_SAT = 921,
+ EVENT_SATCOM_LOADING = 922,
+ EVENT_SATCOM_OBJECT = 923,
+ EVENT_SATCOM_PROG = 924,
+ EVENT_SATCOM_SOLUCE = 925,
+
+ EVENT_OBJECT_DESELECT = 1000,
+ EVENT_OBJECT_LEFT = 1001,
+ EVENT_OBJECT_RIGHT = 1002,
+ EVENT_OBJECT_UP = 1003,
+ EVENT_OBJECT_DOWN = 1004,
+ EVENT_OBJECT_GASUP = 1005,
+ EVENT_OBJECT_GASDOWN = 1006,
+ EVENT_OBJECT_HTAKE = 1020,
+ EVENT_OBJECT_MTAKE = 1021,
+ EVENT_OBJECT_MFRONT = 1022,
+ EVENT_OBJECT_MBACK = 1023,
+ EVENT_OBJECT_MPOWER = 1024,
+ EVENT_OBJECT_BHELP = 1040,
+ EVENT_OBJECT_BTAKEOFF = 1041,
+ EVENT_OBJECT_BDERRICK = 1050,
+ EVENT_OBJECT_BSTATION = 1051,
+ EVENT_OBJECT_BFACTORY = 1052,
+ EVENT_OBJECT_BCONVERT = 1053,
+ EVENT_OBJECT_BTOWER = 1054,
+ EVENT_OBJECT_BREPAIR = 1055,
+ EVENT_OBJECT_BRESEARCH = 1056,
+ EVENT_OBJECT_BRADAR = 1057,
+ EVENT_OBJECT_BENERGY = 1058,
+ EVENT_OBJECT_BLABO = 1059,
+ EVENT_OBJECT_BNUCLEAR = 1060,
+ EVENT_OBJECT_BPARA = 1061,
+ EVENT_OBJECT_BINFO = 1062,
+ EVENT_OBJECT_BXXXX = 1063,
+ EVENT_OBJECT_GFLAT = 1070,
+ EVENT_OBJECT_FCREATE = 1071,
+ EVENT_OBJECT_FDELETE = 1072,
+ EVENT_OBJECT_FCOLORb = 1073,
+ EVENT_OBJECT_FCOLORr = 1074,
+ EVENT_OBJECT_FCOLORg = 1075,
+ EVENT_OBJECT_FCOLORy = 1076,
+ EVENT_OBJECT_FCOLORv = 1077,
+ EVENT_OBJECT_FACTORYwa = 1080,
+ EVENT_OBJECT_FACTORYta = 1081,
+ EVENT_OBJECT_FACTORYfa = 1082,
+ EVENT_OBJECT_FACTORYia = 1083,
+ EVENT_OBJECT_FACTORYwc = 1084,
+ EVENT_OBJECT_FACTORYtc = 1085,
+ EVENT_OBJECT_FACTORYfc = 1086,
+ EVENT_OBJECT_FACTORYic = 1087,
+ EVENT_OBJECT_FACTORYwi = 1088,
+ EVENT_OBJECT_FACTORYti = 1089,
+ EVENT_OBJECT_FACTORYfi = 1090,
+ EVENT_OBJECT_FACTORYii = 1091,
+ EVENT_OBJECT_FACTORYws = 1092,
+ EVENT_OBJECT_FACTORYts = 1093,
+ EVENT_OBJECT_FACTORYfs = 1094,
+ EVENT_OBJECT_FACTORYis = 1095,
+ EVENT_OBJECT_FACTORYrt = 1096,
+ EVENT_OBJECT_FACTORYrc = 1097,
+ EVENT_OBJECT_FACTORYrr = 1098,
+ EVENT_OBJECT_FACTORYrs = 1099,
+ EVENT_OBJECT_FACTORYsa = 1100,
+ EVENT_OBJECT_SEARCH = 1200,
+ EVENT_OBJECT_TERRAFORM = 1201,
+ EVENT_OBJECT_FIRE = 1202,
+ EVENT_OBJECT_FIREANT = 1203,
+ EVENT_OBJECT_RECOVER = 1220,
+ EVENT_OBJECT_BEGSHIELD = 1221,
+ EVENT_OBJECT_ENDSHIELD = 1222,
+ EVENT_OBJECT_RTANK = 1223,
+ EVENT_OBJECT_RFLY = 1224,
+ EVENT_OBJECT_RTHUMP = 1225,
+ EVENT_OBJECT_RCANON = 1226,
+ EVENT_OBJECT_RTOWER = 1227,
+ EVENT_OBJECT_RPHAZER = 1228,
+ EVENT_OBJECT_RSHIELD = 1229,
+ EVENT_OBJECT_RATOMIC = 1230,
+ EVENT_OBJECT_RiPAW = 1231,
+ EVENT_OBJECT_RiGUN = 1232,
+ EVENT_OBJECT_RESET = 1233,
+ EVENT_OBJECT_DIMSHIELD = 1234,
+ EVENT_OBJECT_TARGET = 1235,
+ EVENT_OBJECT_PROGLIST = 1310,
+ EVENT_OBJECT_PROGRUN = 1311,
+ EVENT_OBJECT_PROGEDIT = 1312,
+ EVENT_OBJECT_PROGSTART = 1313,
+ EVENT_OBJECT_PROGSTOP = 1314,
+ EVENT_OBJECT_INFOOK = 1340,
+ EVENT_OBJECT_DELETE = 1350,
+ EVENT_OBJECT_GENERGY = 1360,
+ EVENT_OBJECT_GSHIELD = 1361,
+ EVENT_OBJECT_GRANGE = 1362,
+ EVENT_OBJECT_COMPASS = 1363,
+ EVENT_OBJECT_MAP = 1364,
+ EVENT_OBJECT_MAPZOOM = 1365,
+ EVENT_OBJECT_GPROGRESS = 1366,
+ EVENT_OBJECT_GRADAR = 1367,
+ EVENT_OBJECT_GINFO = 1368,
+ EVENT_OBJECT_TYPE = 1369,
+ EVENT_OBJECT_CROSSHAIR = 1370,
+ EVENT_OBJECT_CORNERul = 1371,
+ EVENT_OBJECT_CORNERur = 1372,
+ EVENT_OBJECT_CORNERdl = 1373,
+ EVENT_OBJECT_CORNERdr = 1374,
+ EVENT_OBJECT_MAPi = 1375,
+ EVENT_OBJECT_MAPg = 1376,
+ EVENT_OBJECT_CAMERA = 1400,
+ EVENT_OBJECT_HELP = 1401,
+ EVENT_OBJECT_SOLUCE = 1402,
+ EVENT_OBJECT_CAMERAleft = 1403,
+ EVENT_OBJECT_CAMERAright= 1404,
+ EVENT_OBJECT_CAMERAnear = 1405,
+ EVENT_OBJECT_CAMERAaway = 1406,
+ EVENT_OBJECT_SHORTCUT00 = 1500,
+ EVENT_OBJECT_SHORTCUT01 = 1501,
+ EVENT_OBJECT_SHORTCUT02 = 1502,
+ EVENT_OBJECT_SHORTCUT03 = 1503,
+ EVENT_OBJECT_SHORTCUT04 = 1504,
+ EVENT_OBJECT_SHORTCUT05 = 1505,
+ EVENT_OBJECT_SHORTCUT06 = 1506,
+ EVENT_OBJECT_SHORTCUT07 = 1507,
+ EVENT_OBJECT_SHORTCUT08 = 1508,
+ EVENT_OBJECT_SHORTCUT09 = 1509,
+ EVENT_OBJECT_SHORTCUT10 = 1510,
+ EVENT_OBJECT_SHORTCUT11 = 1511,
+ EVENT_OBJECT_SHORTCUT12 = 1512,
+ EVENT_OBJECT_SHORTCUT13 = 1513,
+ EVENT_OBJECT_SHORTCUT14 = 1514,
+ EVENT_OBJECT_SHORTCUT15 = 1515,
+ EVENT_OBJECT_SHORTCUT16 = 1516,
+ EVENT_OBJECT_SHORTCUT17 = 1517,
+ EVENT_OBJECT_SHORTCUT18 = 1518,
+ EVENT_OBJECT_SHORTCUT19 = 1519,
+ EVENT_OBJECT_MOVIELOCK = 1550,
+ EVENT_OBJECT_EDITLOCK = 1551,
+ EVENT_OBJECT_LIMIT = 1560,
+
+ EVENT_OBJECT_PEN0 = 1570,
+ EVENT_OBJECT_PEN1 = 1571,
+ EVENT_OBJECT_PEN2 = 1572,
+ EVENT_OBJECT_PEN3 = 1573,
+ EVENT_OBJECT_PEN4 = 1574,
+ EVENT_OBJECT_PEN5 = 1575,
+ EVENT_OBJECT_PEN6 = 1576,
+ EVENT_OBJECT_PEN7 = 1577,
+ EVENT_OBJECT_PEN8 = 1578,
+ EVENT_OBJECT_REC = 1580,
+ EVENT_OBJECT_STOP = 1581,
+
+ EVENT_STUDIO_OK = 2000,
+ EVENT_STUDIO_CANCEL = 2001,
+ EVENT_STUDIO_EDIT = 2002,
+ EVENT_STUDIO_LIST = 2003,
+ EVENT_STUDIO_NEW = 2010,
+ EVENT_STUDIO_OPEN = 2011,
+ EVENT_STUDIO_SAVE = 2012,
+ EVENT_STUDIO_UNDO = 2013,
+ EVENT_STUDIO_CUT = 2014,
+ EVENT_STUDIO_COPY = 2015,
+ EVENT_STUDIO_PASTE = 2016,
+ EVENT_STUDIO_SIZE = 2017,
+ EVENT_STUDIO_TOOL = 2018,
+ EVENT_STUDIO_HELP = 2019,
+ EVENT_STUDIO_COMPILE = 2050,
+ EVENT_STUDIO_RUN = 2051,
+ EVENT_STUDIO_REALTIME = 2052,
+ EVENT_STUDIO_STEP = 2053,
+
+ EVENT_STD_MAX, //! < maximum value of standard events
+
+ EVENT_USER = 10000,
+ EVENT_FORCE_LONG = 0x7fffffff
+};
+
+
+/**
* \struct KeyEventData
* \brief Additional data for keyboard event
*/
diff --git a/src/common/event_ids.h b/src/common/event_ids.h
deleted file mode 100644
index b6c646c..0000000
--- a/src/common/event_ids.h
+++ /dev/null
@@ -1,541 +0,0 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
-
-
-// TODO: move to event.h after restext rewrite
-
-#pragma once
-
-/**
- \enum EventType
- \brief Type of event message
- */
-enum EventType
-{
-
-// TODO: document the meaning of each value
-
- //! Invalid event / no event
- EVENT_NULL = 0,
-
- //! Event sent on user or system quit request
- EVENT_QUIT = 1,
-
- //! Frame update event
- EVENT_FRAME = 2,
-
- //! Event sent after pressing a mouse button
- EVENT_MOUSE_BUTTON_DOWN = 3,
- //! Event sent after releasing a mouse button
- EVENT_MOUSE_BUTTON_UP = 4,
- //! Event sent after moving mouse wheel up or down
- EVENT_MOUSE_WHEEL = 5,
- //! Event sent after moving the mouse
- EVENT_MOUSE_MOVE = 7,
- //! Event sent after pressing a key
- EVENT_KEY_DOWN = 8,
- //! Event sent after releasing a key
- EVENT_KEY_UP = 9,
-
- //! Event sent when application window loses/gains focus
- EVENT_ACTIVE = 10,
-
- //! Event sent after moving joystick axes
- EVENT_JOY_AXIS = 12,
- //! Event sent after pressing a joystick button
- EVENT_JOY_BUTTON_DOWN = 13,
- //! Event sent after releasing a joystick button
- EVENT_JOY_BUTTON_UP = 14,
-
-
- /* Events sent/received in game and user interface */
-
- EVENT_UPDINTERFACE = 20,
- EVENT_WIN = 30,
- EVENT_LOST = 31,
-
- //! CEdit focus
- EVENT_FOCUS = 35,
-
- EVENT_BUTTON_OK = 40,
- EVENT_BUTTON_CANCEL = 41,
- EVENT_BUTTON_NEXT = 42,
- EVENT_BUTTON_PREV = 43,
- EVENT_BUTTON_QUIT = 44,
-
- EVENT_BUTTON0 = 50,
- EVENT_BUTTON1 = 51,
- EVENT_BUTTON2 = 52,
- EVENT_BUTTON3 = 53,
- EVENT_BUTTON4 = 54,
- EVENT_BUTTON5 = 55,
- EVENT_BUTTON6 = 56,
- EVENT_BUTTON7 = 57,
- EVENT_BUTTON8 = 58,
- EVENT_BUTTON9 = 59,
- EVENT_BUTTON10 = 60,
- EVENT_BUTTON11 = 61,
- EVENT_BUTTON12 = 62,
- EVENT_BUTTON13 = 63,
- EVENT_BUTTON14 = 64,
- EVENT_BUTTON15 = 65,
- EVENT_BUTTON16 = 66,
- EVENT_BUTTON17 = 67,
- EVENT_BUTTON18 = 68,
- EVENT_BUTTON19 = 69,
-
- EVENT_EDIT0 = 70,
- EVENT_EDIT1 = 71,
- EVENT_EDIT2 = 72,
- EVENT_EDIT3 = 73,
- EVENT_EDIT4 = 74,
- EVENT_EDIT5 = 75,
- EVENT_EDIT6 = 76,
- EVENT_EDIT7 = 77,
- EVENT_EDIT8 = 78,
- EVENT_EDIT9 = 79,
-
- EVENT_WINDOW0 = 80, // the bottom panel
- EVENT_WINDOW1 = 81, // map
- EVENT_WINDOW2 = 82, // CDisplayText
- EVENT_WINDOW3 = 83, // CStudio
- EVENT_WINDOW4 = 84, // DisplayInfo
- EVENT_WINDOW5 = 85, // setup
- EVENT_WINDOW6 = 86,
- EVENT_WINDOW7 = 87,
- EVENT_WINDOW8 = 88,
- EVENT_WINDOW9 = 89, // dialogue
-
- EVENT_LABEL0 = 90,
- EVENT_LABEL1 = 91,
- EVENT_LABEL2 = 92,
- EVENT_LABEL3 = 93,
- EVENT_LABEL4 = 94,
- EVENT_LABEL5 = 95,
- EVENT_LABEL6 = 96,
- EVENT_LABEL7 = 97,
- EVENT_LABEL8 = 98,
- EVENT_LABEL9 = 99,
- EVENT_LABEL10 = 100,
- EVENT_LABEL11 = 101,
- EVENT_LABEL12 = 102,
- EVENT_LABEL13 = 103,
- EVENT_LABEL14 = 104,
- EVENT_LABEL15 = 105,
- EVENT_LABEL16 = 106,
- EVENT_LABEL17 = 107,
- EVENT_LABEL18 = 108,
- EVENT_LABEL19 = 109,
-
- EVENT_LIST0 = 110,
- EVENT_LIST1 = 111,
- EVENT_LIST2 = 112,
- EVENT_LIST3 = 113,
- EVENT_LIST4 = 114,
- EVENT_LIST5 = 115,
- EVENT_LIST6 = 116,
- EVENT_LIST7 = 117,
- EVENT_LIST8 = 118,
- EVENT_LIST9 = 119,
-
- EVENT_TOOLTIP = 200,
-
- EVENT_DIALOG_OK = 300,
- EVENT_DIALOG_CANCEL = 301,
- EVENT_DIALOG_LABEL = 302,
- EVENT_DIALOG_LABEL1 = 303,
- EVENT_DIALOG_LABEL2 = 304,
- EVENT_DIALOG_LABEL3 = 305,
- EVENT_DIALOG_LIST = 306,
- EVENT_DIALOG_EDIT = 307,
- EVENT_DIALOG_CHECK1 = 308,
- EVENT_DIALOG_CHECK2 = 309,
-
- EVENT_INTERFACE_TRAINER = 400,
- EVENT_INTERFACE_DEFI = 401,
- EVENT_INTERFACE_MISSION = 402,
- EVENT_INTERFACE_FREE = 403,
- EVENT_INTERFACE_PROTO = 404,
- EVENT_INTERFACE_NAME = 405,
- EVENT_INTERFACE_SETUP = 406,
- EVENT_INTERFACE_QUIT = 407,
- EVENT_INTERFACE_BACK = 408,
- EVENT_INTERFACE_AGAIN = 409,
- EVENT_INTERFACE_WRITE = 410,
- EVENT_INTERFACE_READ = 411,
- EVENT_INTERFACE_ABORT = 412,
- EVENT_INTERFACE_USER = 413,
- EVENT_INTERFACE_TEEN = 414,
-
- EVENT_INTERFACE_CHAP = 420,
- EVENT_INTERFACE_LIST = 421,
- EVENT_INTERFACE_RESUME = 422,
- EVENT_INTERFACE_PLAY = 423,
-
- EVENT_INTERFACE_SETUPd = 430,
- EVENT_INTERFACE_SETUPg = 431,
- EVENT_INTERFACE_SETUPp = 432,
- EVENT_INTERFACE_SETUPc = 433,
- EVENT_INTERFACE_SETUPs = 434,
-
- EVENT_INTERFACE_DEVICE = 440,
- EVENT_INTERFACE_RESOL = 441,
- EVENT_INTERFACE_FULL = 442,
- EVENT_INTERFACE_APPLY = 443,
-
- EVENT_INTERFACE_TOTO = 450,
- EVENT_INTERFACE_SHADOW = 451,
- EVENT_INTERFACE_DIRTY = 452,
- EVENT_INTERFACE_LENS = 453,
- EVENT_INTERFACE_SKY = 454,
- EVENT_INTERFACE_PLANET = 456,
- EVENT_INTERFACE_LIGHT = 457,
- EVENT_INTERFACE_PARTI = 458,
- EVENT_INTERFACE_CLIP = 459,
- EVENT_INTERFACE_DETAIL = 460,
- EVENT_INTERFACE_TEXTURE = 461,
- EVENT_INTERFACE_RAIN = 462,
- EVENT_INTERFACE_GLINT = 463,
- EVENT_INTERFACE_TOOLTIP = 464,
- EVENT_INTERFACE_MOVIES = 465,
- EVENT_INTERFACE_NICERST = 466,
- EVENT_INTERFACE_SCROLL = 467,
- EVENT_INTERFACE_INVERTX = 468,
- EVENT_INTERFACE_INVERTY = 469,
- EVENT_INTERFACE_EFFECT = 470,
- EVENT_INTERFACE_MOUSE = 471,
- EVENT_INTERFACE_GROUND = 472,
- EVENT_INTERFACE_GADGET = 473,
- EVENT_INTERFACE_FOG = 474,
- EVENT_INTERFACE_HIMSELF = 475,
- EVENT_INTERFACE_EDITMODE= 476,
- EVENT_INTERFACE_EDITVALUE= 477,
- EVENT_INTERFACE_SOLUCE4 = 478,
-
- EVENT_INTERFACE_KINFO1 = 500,
- EVENT_INTERFACE_KINFO2 = 501,
- EVENT_INTERFACE_KGROUP = 502,
- EVENT_INTERFACE_KSCROLL = 503,
- EVENT_INTERFACE_KDEF = 504,
- EVENT_INTERFACE_KLEFT = 505,
- EVENT_INTERFACE_KRIGHT = 506,
- EVENT_INTERFACE_KUP = 507,
- EVENT_INTERFACE_KDOWN = 508,
- EVENT_INTERFACE_KGUP = 509,
- EVENT_INTERFACE_KGDOWN = 510,
- EVENT_INTERFACE_KCAMERA = 511,
- EVENT_INTERFACE_KDESEL = 512,
- EVENT_INTERFACE_KACTION = 513,
- EVENT_INTERFACE_KNEAR = 514,
- EVENT_INTERFACE_KAWAY = 515,
- EVENT_INTERFACE_KNEXT = 516,
- EVENT_INTERFACE_KHUMAN = 517,
- EVENT_INTERFACE_KQUIT = 518,
- EVENT_INTERFACE_KHELP = 519,
- EVENT_INTERFACE_KPROG = 520,
- EVENT_INTERFACE_KCBOT = 521,
- EVENT_INTERFACE_KVISIT = 522,
- EVENT_INTERFACE_KSPEED10= 523,
- EVENT_INTERFACE_KSPEED15= 524,
- EVENT_INTERFACE_KSPEED20= 525,
- EVENT_INTERFACE_KSPEED30= 526,
-
- EVENT_INTERFACE_VOLSOUND= 530,
- EVENT_INTERFACE_VOLMUSIC= 531,
- EVENT_INTERFACE_SOUND3D = 532,
-
- EVENT_INTERFACE_MIN = 540,
- EVENT_INTERFACE_NORM = 541,
- EVENT_INTERFACE_MAX = 542,
-
- EVENT_INTERFACE_SILENT = 550,
- EVENT_INTERFACE_NOISY = 551,
-
- EVENT_INTERFACE_JOYSTICK= 560,
- EVENT_INTERFACE_SOLUCE = 561,
-
- EVENT_INTERFACE_GLINTl = 570,
- EVENT_INTERFACE_GLINTr = 571,
- EVENT_INTERFACE_GLINTu = 572,
- EVENT_INTERFACE_GLINTb = 573,
-
- EVENT_INTERFACE_NEDIT = 580,
- EVENT_INTERFACE_NLIST = 581,
- EVENT_INTERFACE_NOK = 582,
- EVENT_INTERFACE_NCANCEL = 583,
- EVENT_INTERFACE_NDELETE = 584,
- EVENT_INTERFACE_NLABEL = 585,
-
- EVENT_INTERFACE_IOWRITE = 600,
- EVENT_INTERFACE_IOREAD = 601,
- EVENT_INTERFACE_IOLIST = 602,
- EVENT_INTERFACE_IONAME = 603,
- EVENT_INTERFACE_IOLABEL = 604,
- EVENT_INTERFACE_IOIMAGE = 605,
- EVENT_INTERFACE_IODELETE= 606,
-
- EVENT_INTERFACE_PERSO = 620,
- EVENT_INTERFACE_POK = 621,
- EVENT_INTERFACE_PCANCEL = 622,
- EVENT_INTERFACE_PDEF = 623,
- EVENT_INTERFACE_PHEAD = 624,
- EVENT_INTERFACE_PBODY = 625,
- EVENT_INTERFACE_PLROT = 626,
- EVENT_INTERFACE_PRROT = 627,
- EVENT_INTERFACE_PC0a = 640,
- EVENT_INTERFACE_PC1a = 641,
- EVENT_INTERFACE_PC2a = 642,
- EVENT_INTERFACE_PC3a = 643,
- EVENT_INTERFACE_PC4a = 644,
- EVENT_INTERFACE_PC5a = 645,
- EVENT_INTERFACE_PC6a = 646,
- EVENT_INTERFACE_PC7a = 647,
- EVENT_INTERFACE_PC8a = 648,
- EVENT_INTERFACE_PC9a = 649,
- EVENT_INTERFACE_PCRa = 650,
- EVENT_INTERFACE_PCGa = 651,
- EVENT_INTERFACE_PCBa = 652,
- EVENT_INTERFACE_PC0b = 660,
- EVENT_INTERFACE_PC1b = 661,
- EVENT_INTERFACE_PC2b = 662,
- EVENT_INTERFACE_PC3b = 663,
- EVENT_INTERFACE_PC4b = 664,
- EVENT_INTERFACE_PC5b = 665,
- EVENT_INTERFACE_PC6b = 666,
- EVENT_INTERFACE_PC7b = 667,
- EVENT_INTERFACE_PC8b = 668,
- EVENT_INTERFACE_PC9b = 669,
- EVENT_INTERFACE_PCRb = 670,
- EVENT_INTERFACE_PCGb = 671,
- EVENT_INTERFACE_PCBb = 672,
- EVENT_INTERFACE_PFACE1 = 680,
- EVENT_INTERFACE_PFACE2 = 681,
- EVENT_INTERFACE_PFACE3 = 682,
- EVENT_INTERFACE_PFACE4 = 683,
- EVENT_INTERFACE_PGLASS0 = 690,
- EVENT_INTERFACE_PGLASS1 = 691,
- EVENT_INTERFACE_PGLASS2 = 692,
- EVENT_INTERFACE_PGLASS3 = 693,
- EVENT_INTERFACE_PGLASS4 = 694,
- EVENT_INTERFACE_PGLASS5 = 695,
- EVENT_INTERFACE_PGLASS6 = 696,
- EVENT_INTERFACE_PGLASS7 = 697,
- EVENT_INTERFACE_PGLASS8 = 698,
- EVENT_INTERFACE_PGLASS9 = 699,
-
- EVENT_DT_GROUP0 = 700,
- EVENT_DT_GROUP1 = 701,
- EVENT_DT_GROUP2 = 702,
- EVENT_DT_GROUP3 = 703,
- EVENT_DT_GROUP4 = 704,
- EVENT_DT_LABEL0 = 710,
- EVENT_DT_LABEL1 = 711,
- EVENT_DT_LABEL2 = 712,
- EVENT_DT_LABEL3 = 713,
- EVENT_DT_LABEL4 = 714,
- EVENT_DT_VISIT0 = 720,
- EVENT_DT_VISIT1 = 721,
- EVENT_DT_VISIT2 = 722,
- EVENT_DT_VISIT3 = 723,
- EVENT_DT_VISIT4 = 724,
- EVENT_DT_END = 725,
-
- EVENT_CMD = 800,
- EVENT_SPEED = 801,
-
- EVENT_HYPER_PREV = 900,
- EVENT_HYPER_NEXT = 901,
- EVENT_HYPER_HOME = 902,
- EVENT_HYPER_COPY = 903,
- EVENT_HYPER_SIZE1 = 904,
- EVENT_HYPER_SIZE2 = 905,
- EVENT_HYPER_SIZE3 = 906,
- EVENT_HYPER_SIZE4 = 907,
- EVENT_HYPER_SIZE5 = 908,
-
- EVENT_SATCOM_HUSTON = 920,
- EVENT_SATCOM_SAT = 921,
- EVENT_SATCOM_LOADING = 922,
- EVENT_SATCOM_OBJECT = 923,
- EVENT_SATCOM_PROG = 924,
- EVENT_SATCOM_SOLUCE = 925,
-
- EVENT_OBJECT_DESELECT = 1000,
- EVENT_OBJECT_LEFT = 1001,
- EVENT_OBJECT_RIGHT = 1002,
- EVENT_OBJECT_UP = 1003,
- EVENT_OBJECT_DOWN = 1004,
- EVENT_OBJECT_GASUP = 1005,
- EVENT_OBJECT_GASDOWN = 1006,
- EVENT_OBJECT_HTAKE = 1020,
- EVENT_OBJECT_MTAKE = 1021,
- EVENT_OBJECT_MFRONT = 1022,
- EVENT_OBJECT_MBACK = 1023,
- EVENT_OBJECT_MPOWER = 1024,
- EVENT_OBJECT_BHELP = 1040,
- EVENT_OBJECT_BTAKEOFF = 1041,
- EVENT_OBJECT_BDERRICK = 1050,
- EVENT_OBJECT_BSTATION = 1051,
- EVENT_OBJECT_BFACTORY = 1052,
- EVENT_OBJECT_BCONVERT = 1053,
- EVENT_OBJECT_BTOWER = 1054,
- EVENT_OBJECT_BREPAIR = 1055,
- EVENT_OBJECT_BRESEARCH = 1056,
- EVENT_OBJECT_BRADAR = 1057,
- EVENT_OBJECT_BENERGY = 1058,
- EVENT_OBJECT_BLABO = 1059,
- EVENT_OBJECT_BNUCLEAR = 1060,
- EVENT_OBJECT_BPARA = 1061,
- EVENT_OBJECT_BINFO = 1062,
- EVENT_OBJECT_BXXXX = 1063,
- EVENT_OBJECT_GFLAT = 1070,
- EVENT_OBJECT_FCREATE = 1071,
- EVENT_OBJECT_FDELETE = 1072,
- EVENT_OBJECT_FCOLORb = 1073,
- EVENT_OBJECT_FCOLORr = 1074,
- EVENT_OBJECT_FCOLORg = 1075,
- EVENT_OBJECT_FCOLORy = 1076,
- EVENT_OBJECT_FCOLORv = 1077,
- EVENT_OBJECT_FACTORYwa = 1080,
- EVENT_OBJECT_FACTORYta = 1081,
- EVENT_OBJECT_FACTORYfa = 1082,
- EVENT_OBJECT_FACTORYia = 1083,
- EVENT_OBJECT_FACTORYwc = 1084,
- EVENT_OBJECT_FACTORYtc = 1085,
- EVENT_OBJECT_FACTORYfc = 1086,
- EVENT_OBJECT_FACTORYic = 1087,
- EVENT_OBJECT_FACTORYwi = 1088,
- EVENT_OBJECT_FACTORYti = 1089,
- EVENT_OBJECT_FACTORYfi = 1090,
- EVENT_OBJECT_FACTORYii = 1091,
- EVENT_OBJECT_FACTORYws = 1092,
- EVENT_OBJECT_FACTORYts = 1093,
- EVENT_OBJECT_FACTORYfs = 1094,
- EVENT_OBJECT_FACTORYis = 1095,
- EVENT_OBJECT_FACTORYrt = 1096,
- EVENT_OBJECT_FACTORYrc = 1097,
- EVENT_OBJECT_FACTORYrr = 1098,
- EVENT_OBJECT_FACTORYrs = 1099,
- EVENT_OBJECT_FACTORYsa = 1100,
- EVENT_OBJECT_SEARCH = 1200,
- EVENT_OBJECT_TERRAFORM = 1201,
- EVENT_OBJECT_FIRE = 1202,
- EVENT_OBJECT_FIREANT = 1203,
- EVENT_OBJECT_RECOVER = 1220,
- EVENT_OBJECT_BEGSHIELD = 1221,
- EVENT_OBJECT_ENDSHIELD = 1222,
- EVENT_OBJECT_RTANK = 1223,
- EVENT_OBJECT_RFLY = 1224,
- EVENT_OBJECT_RTHUMP = 1225,
- EVENT_OBJECT_RCANON = 1226,
- EVENT_OBJECT_RTOWER = 1227,
- EVENT_OBJECT_RPHAZER = 1228,
- EVENT_OBJECT_RSHIELD = 1229,
- EVENT_OBJECT_RATOMIC = 1230,
- EVENT_OBJECT_RiPAW = 1231,
- EVENT_OBJECT_RiGUN = 1232,
- EVENT_OBJECT_RESET = 1233,
- EVENT_OBJECT_DIMSHIELD = 1234,
- EVENT_OBJECT_TARGET = 1235,
- EVENT_OBJECT_PROGLIST = 1310,
- EVENT_OBJECT_PROGRUN = 1311,
- EVENT_OBJECT_PROGEDIT = 1312,
- EVENT_OBJECT_PROGSTART = 1313,
- EVENT_OBJECT_PROGSTOP = 1314,
- EVENT_OBJECT_INFOOK = 1340,
- EVENT_OBJECT_DELETE = 1350,
- EVENT_OBJECT_GENERGY = 1360,
- EVENT_OBJECT_GSHIELD = 1361,
- EVENT_OBJECT_GRANGE = 1362,
- EVENT_OBJECT_COMPASS = 1363,
- EVENT_OBJECT_MAP = 1364,
- EVENT_OBJECT_MAPZOOM = 1365,
- EVENT_OBJECT_GPROGRESS = 1366,
- EVENT_OBJECT_GRADAR = 1367,
- EVENT_OBJECT_GINFO = 1368,
- EVENT_OBJECT_TYPE = 1369,
- EVENT_OBJECT_CROSSHAIR = 1370,
- EVENT_OBJECT_CORNERul = 1371,
- EVENT_OBJECT_CORNERur = 1372,
- EVENT_OBJECT_CORNERdl = 1373,
- EVENT_OBJECT_CORNERdr = 1374,
- EVENT_OBJECT_MAPi = 1375,
- EVENT_OBJECT_MAPg = 1376,
- EVENT_OBJECT_CAMERA = 1400,
- EVENT_OBJECT_HELP = 1401,
- EVENT_OBJECT_SOLUCE = 1402,
- EVENT_OBJECT_CAMERAleft = 1403,
- EVENT_OBJECT_CAMERAright= 1404,
- EVENT_OBJECT_CAMERAnear = 1405,
- EVENT_OBJECT_CAMERAaway = 1406,
- EVENT_OBJECT_SHORTCUT00 = 1500,
- EVENT_OBJECT_SHORTCUT01 = 1501,
- EVENT_OBJECT_SHORTCUT02 = 1502,
- EVENT_OBJECT_SHORTCUT03 = 1503,
- EVENT_OBJECT_SHORTCUT04 = 1504,
- EVENT_OBJECT_SHORTCUT05 = 1505,
- EVENT_OBJECT_SHORTCUT06 = 1506,
- EVENT_OBJECT_SHORTCUT07 = 1507,
- EVENT_OBJECT_SHORTCUT08 = 1508,
- EVENT_OBJECT_SHORTCUT09 = 1509,
- EVENT_OBJECT_SHORTCUT10 = 1510,
- EVENT_OBJECT_SHORTCUT11 = 1511,
- EVENT_OBJECT_SHORTCUT12 = 1512,
- EVENT_OBJECT_SHORTCUT13 = 1513,
- EVENT_OBJECT_SHORTCUT14 = 1514,
- EVENT_OBJECT_SHORTCUT15 = 1515,
- EVENT_OBJECT_SHORTCUT16 = 1516,
- EVENT_OBJECT_SHORTCUT17 = 1517,
- EVENT_OBJECT_SHORTCUT18 = 1518,
- EVENT_OBJECT_SHORTCUT19 = 1519,
- EVENT_OBJECT_MOVIELOCK = 1550,
- EVENT_OBJECT_EDITLOCK = 1551,
- EVENT_OBJECT_LIMIT = 1560,
-
- EVENT_OBJECT_PEN0 = 1570,
- EVENT_OBJECT_PEN1 = 1571,
- EVENT_OBJECT_PEN2 = 1572,
- EVENT_OBJECT_PEN3 = 1573,
- EVENT_OBJECT_PEN4 = 1574,
- EVENT_OBJECT_PEN5 = 1575,
- EVENT_OBJECT_PEN6 = 1576,
- EVENT_OBJECT_PEN7 = 1577,
- EVENT_OBJECT_PEN8 = 1578,
- EVENT_OBJECT_REC = 1580,
- EVENT_OBJECT_STOP = 1581,
-
- EVENT_STUDIO_OK = 2000,
- EVENT_STUDIO_CANCEL = 2001,
- EVENT_STUDIO_EDIT = 2002,
- EVENT_STUDIO_LIST = 2003,
- EVENT_STUDIO_NEW = 2010,
- EVENT_STUDIO_OPEN = 2011,
- EVENT_STUDIO_SAVE = 2012,
- EVENT_STUDIO_UNDO = 2013,
- EVENT_STUDIO_CUT = 2014,
- EVENT_STUDIO_COPY = 2015,
- EVENT_STUDIO_PASTE = 2016,
- EVENT_STUDIO_SIZE = 2017,
- EVENT_STUDIO_TOOL = 2018,
- EVENT_STUDIO_HELP = 2019,
- EVENT_STUDIO_COMPILE = 2050,
- EVENT_STUDIO_RUN = 2051,
- EVENT_STUDIO_REALTIME = 2052,
- EVENT_STUDIO_STEP = 2053,
-
- EVENT_USER = 10000,
- EVENT_FORCE_LONG = 0x7fffffff
-};
diff --git a/src/common/global.h b/src/common/global.h
index 579db7d..2d57ee0 100644
--- a/src/common/global.h
+++ b/src/common/global.h
@@ -21,7 +21,143 @@
#pragma once
-#include "error_ids.h"
+
+/**
+ * \enum Error
+ * \brief Type of error or info message
+ */
+enum Error
+{
+ ERR_OK = 0, //! < ok
+ ERR_GENERIC = 1, //! < any error
+ ERR_CONTINUE = 2, //! < continues
+ ERR_STOP = 3, //! < stops
+ ERR_CMD = 4, //! < unknown command
+ ERR_MANIP_VEH = 100, //! < inappropriate vehicle
+ ERR_MANIP_FLY = 101, //! < impossible in flight
+ ERR_MANIP_BUSY = 102, //! < taking: hands already occupied
+ ERR_MANIP_NIL = 103, //! < taking: nothing has to take
+ ERR_MANIP_MOTOR = 105, //! < busy: impossible to move
+ ERR_MANIP_OCC = 106, //! < busy: location already occupied
+ ERR_MANIP_FRIEND = 107, //! < no other vehicle
+ ERR_MANIP_RADIO = 108, //! < impossible because radioactive
+ ERR_MANIP_WATER = 109, //! < not possible under water
+ ERR_MANIP_EMPTY = 110, //! < nothing to deposit
+ ERR_BUILD_FLY = 120, //! < not possible in flight
+ ERR_BUILD_WATER = 121, //! < not possible under water
+ ERR_BUILD_ENERGY = 122, //! < not enough energy
+ ERR_BUILD_METALAWAY = 123, //! < lack of metal (too far)
+ ERR_BUILD_METALNEAR = 124, //! < lack of metal (too close)
+ ERR_BUILD_METALINEX = 125, //! < lack of metal
+ ERR_BUILD_FLAT = 126, //! < not enough flat ground
+ ERR_BUILD_FLATLIT = 127, //! < not enough flat ground space
+ ERR_BUILD_BUSY = 128, //! < location occupied
+ ERR_BUILD_BASE = 129, //! < too close to the rocket
+ ERR_BUILD_NARROW = 130, //! < buildings too close
+ ERR_BUILD_MOTOR = 131, //! < built: not possible in movement
+ ERR_SEARCH_FLY = 140, //! < not possible in flight
+ ERR_SEARCH_VEH = 141, //! < inappropriate vehicle
+ ERR_SEARCH_MOTOR = 142, //! < impossible in movement
+ ERR_TERRA_VEH = 150, //! < inappropriate vehicle
+ ERR_TERRA_ENERGY = 151, //! < not enough energy
+ ERR_TERRA_FLOOR = 152, //! < inappropriate ground
+ ERR_TERRA_BUILDING = 153, //! < building too close
+ ERR_TERRA_OBJECT = 154, //! < object too close
+ ERR_FIRE_VEH = 160, //! < inappropriate vehicle
+ ERR_FIRE_ENERGY = 161, //! < not enough energy
+ ERR_FIRE_FLY = 162, //! < not possible in flight
+ ERR_RECOVER_VEH = 170, //! < inappropriate vehicle
+ ERR_RECOVER_ENERGY = 171, //! < not enough energy
+ ERR_RECOVER_NULL = 172, //! < lack of ruin
+ ERR_CONVERT_EMPTY = 180, //! < no stone was transformed
+ ERR_SHIELD_VEH = 190, //! < inappropriate vehicle
+ ERR_SHIELD_ENERGY = 191, //! < not enough energy
+ ERR_MOVE_IMPOSSIBLE = 200, //! < move impossible
+ ERR_FIND_IMPOSSIBLE = 201, //! < find impossible
+ ERR_GOTO_IMPOSSIBLE = 210, //! < goto impossible
+ ERR_GOTO_ITER = 211, //! < goto too complicated
+ ERR_GOTO_BUSY = 212, //! < goto destination occupied
+ ERR_DERRICK_NULL = 300, //! < no ore underground
+ ERR_STATION_NULL = 301, //! < no energy underground
+ ERR_TOWER_POWER = 310, //! < no battery
+ ERR_TOWER_ENERGY = 311, //! < more energy
+ ERR_RESEARCH_POWER = 320, //! < no battery
+ ERR_RESEARCH_ENERGY = 321, //! < more energy
+ ERR_RESEARCH_TYPE = 322, //! < the wrong type of battery
+ ERR_RESEARCH_ALREADY = 323, //! < research already done
+ ERR_ENERGY_NULL = 330, //! < no energy underground
+ ERR_ENERGY_LOW = 331, //! < not enough energy
+ ERR_ENERGY_EMPTY = 332, //! < lack of metal
+ ERR_ENERGY_BAD = 333, //! < transforms only the metal
+ ERR_BASE_DLOCK = 340, //! < doors locked
+ ERR_BASE_DHUMAN = 341, //! < you must be on spaceship
+ ERR_LABO_NULL = 350, //! < nothing to analyze
+ ERR_LABO_BAD = 351, //! < analyzes only organic ball
+ ERR_LABO_ALREADY = 352, //! < analysis already made
+ ERR_NUCLEAR_NULL = 360, //! < no energy underground
+ ERR_NUCLEAR_LOW = 361, //! < not enough energy
+ ERR_NUCLEAR_EMPTY = 362, //! < lack of uranium
+ ERR_NUCLEAR_BAD = 363, //! < transforms only uranium
+ ERR_FACTORY_NULL = 370, //! < no metal
+ ERR_FACTORY_NEAR = 371, //! < vehicle too close
+ ERR_RESET_NEAR = 380, //! < vehicle too close
+ ERR_INFO_NULL = 390, //! < no information terminal
+ ERR_VEH_VIRUS = 400, //! < vehicle infected by a virus
+ ERR_BAT_VIRUS = 401, //! < building infected by a virus
+ ERR_VEH_POWER = 500, //! < no battery
+ ERR_VEH_ENERGY = 501, //! < more energy
+ ERR_FLAG_FLY = 510, //! < impossible in flight
+ ERR_FLAG_WATER = 511, //! < impossible during swimming
+ ERR_FLAG_MOTOR = 512, //! < impossible in movement
+ ERR_FLAG_BUSY = 513, //! < taking: already creating flag
+ ERR_FLAG_CREATE = 514, //! < too many flags
+ ERR_FLAG_PROXY = 515, //! < too close
+ ERR_FLAG_DELETE = 516, //! < nothing to remove
+ ERR_MISSION_NOTERM = 600, //! < Mission not completed
+ ERR_DELETEMOBILE = 700, //! < vehicle destroyed
+ ERR_DELETEBUILDING = 701, //! < building destroyed
+ ERR_TOOMANY = 702, //! < too many objects
+ ERR_OBLIGATORYTOKEN = 800, //! < compulsory instruction missing
+ ERR_PROHIBITEDTOKEN = 801, //! < instruction prohibited
+
+ INFO_FIRST = 10000, //! < first information
+ INFO_BUILD = 10001, //! < construction builded
+ INFO_CONVERT = 10002, //! < metal available
+ INFO_RESEARCH = 10003, //! < search ended
+ INFO_FACTORY = 10004, //! < vehicle manufactured
+ INFO_LABO = 10005, //! < analysis ended
+ INFO_ENERGY = 10006, //! < battery available
+ INFO_NUCLEAR = 10007, //! < nuclear battery available
+ INFO_FINDING = 10008, //! < nuclear battery available
+ INFO_MARKPOWER = 10020, //! < location for station found
+ INFO_MARKURANIUM = 10021, //! < location for derrick found
+ INFO_MARKSTONE = 10022, //! < location for derrick found
+ INFO_MARKKEYa = 10023, //! < location for derrick found
+ INFO_MARKKEYb = 10024, //! < location for derrick found
+ INFO_MARKKEYc = 10025, //! < location for derrick found
+ INFO_MARKKEYd = 10026, //! < location for derrick found
+ INFO_RESEARCHTANK = 10030, //! < research ended
+ INFO_RESEARCHFLY = 10031, //! < research ended
+ INFO_RESEARCHTHUMP = 10032, //! < research ended
+ INFO_RESEARCHCANON = 10033, //! < research ended
+ INFO_RESEARCHTOWER = 10034, //! < research ended
+ INFO_RESEARCHPHAZER = 10035, //! < research ended
+ INFO_RESEARCHSHIELD = 10036, //! < research ended
+ INFO_RESEARCHATOMIC = 10037, //! < research ended
+ INFO_WIN = 10040, //! < win
+ INFO_LOST = 10041, //! < lost
+ INFO_LOSTq = 10042, //! < lost immediately
+ INFO_WRITEOK = 10043, //! < record done
+ INFO_DELETEPATH = 10050, //! < way mark deleted
+ INFO_DELETEMOTHER = 10100, //! < insect killed
+ INFO_DELETEANT = 10101, //! < insect killed
+ INFO_DELETEBEE = 10102, //! < insect killed
+ INFO_DELETEWORM = 10103, //! < insect killed
+ INFO_DELETESPIDER = 10104, //! < insect killed
+ INFO_BEGINSATCOM = 10105, //! < use your SatCom
+
+ ERR_MAX //! < number of values
+};
/**
* \enum Language
@@ -56,6 +192,7 @@ enum DataDir
DIR_MAX //! < number of dirs
};
+
/**
* \enum BuildType
* \brief Construction actions (buildings, etc.) available to user
diff --git a/src/common/image.cpp b/src/common/image.cpp
index adb8ce7..f3cfa34 100644
--- a/src/common/image.cpp
+++ b/src/common/image.cpp
@@ -14,9 +14,8 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// image.cpp
-#include "image.h"
+#include "common/image.h"
#include <stdlib.h>
#include <stdio.h>
diff --git a/src/common/image.h b/src/common/image.h
index 54bbd3d..d23a6fa 100644
--- a/src/common/image.h
+++ b/src/common/image.h
@@ -21,7 +21,9 @@
#pragma once
+
#include "graphics/core/color.h"
+
#include "math/intpoint.h"
#include <stddef.h>
diff --git a/src/common/iman.cpp b/src/common/iman.cpp
index e59afb1..6a0a9eb 100644
--- a/src/common/iman.cpp
+++ b/src/common/iman.cpp
@@ -14,7 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// iman.cpp
#include "common/iman.h"
diff --git a/src/common/iman.h b/src/common/iman.h
index 75655aa..53caed7 100644
--- a/src/common/iman.h
+++ b/src/common/iman.h
@@ -15,14 +15,14 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
/**
- * \file iman.h
+ * \file common/iman.h
* \brief Instance manager for managed classes
*/
#pragma once
-#include <common/singleton.h>
-#include <common/misc.h>
+
+#include "common/singleton.h"
/**
diff --git a/src/common/ioutils.h b/src/common/ioutils.h
index e7668eb..9a94617 100644
--- a/src/common/ioutils.h
+++ b/src/common/ioutils.h
@@ -15,7 +15,7 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
/**
- * \file ioutils.h
+ * \file common/ioutils.h
* \brief Functions for binary I/O
*/
diff --git a/src/common/key.h b/src/common/key.h
index 11076a3..196f66d 100644
--- a/src/common/key.h
+++ b/src/common/key.h
@@ -14,7 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// key.h
+/**
+ * \file common/key.h
+ * \brief Key-related macros and enums
+ */
#pragma once
diff --git a/src/common/logger.cpp b/src/common/logger.cpp
index ed8df8c..5a78433 100644
--- a/src/common/logger.cpp
+++ b/src/common/logger.cpp
@@ -14,9 +14,8 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// logger.cpp
-#include <common/logger.h>
+#include "common/logger.h"
#include <stdio.h>
diff --git a/src/common/logger.h b/src/common/logger.h
index dfeeb98..198e5e5 100644
--- a/src/common/logger.h
+++ b/src/common/logger.h
@@ -19,9 +19,9 @@
* \brief Class for logging information to file or console
*/
-
#pragma once
+
#include "common/singleton.h"
#include <string>
@@ -58,48 +58,48 @@ class CLogger : public CSingleton<CLogger>
~CLogger();
/** Write message to console or file
- * @param str - message to write
- * @param ... - additional arguments
+ * \param str - message to write
+ * \param ... - additional arguments
*/
void Message(const char *str, ...);
/** Write message to console or file with LOG_TRACE level
- * @param str - message to write
- * @param ... - additional arguments
+ * \param str - message to write
+ * \param ... - additional arguments
*/
void Trace(const char *str, ...);
/** Write message to console or file with LOG_DEBUG level
- * @param str - message to write
- * @param ... - additional arguments
+ * \param str - message to write
+ * \param ... - additional arguments
*/
void Debug(const char *str, ...);
/** Write message to console or file with LOG_INFO level
- * @param str - message to write
- * @param ... - additional arguments
+ * \param str - message to write
+ * \param ... - additional arguments
*/
void Info(const char *str, ...);
/** Write message to console or file with LOG_WARN level
- * @param str - message to write
- * @param ... - additional arguments
+ * \param str - message to write
+ * \param ... - additional arguments
*/
void Warn(const char *str, ...);
/** Write message to console or file with LOG_ERROR level
- * @param str - message to write
- * @param ... - additional arguments
+ * \param str - message to write
+ * \param ... - additional arguments
*/
void Error(const char *str, ...);
/** Set output file to write logs to
- * @param filename - output file to write to
+ * \param filename - output file to write to
*/
void SetOutputFile(std::string filename);
/** Set log level. Logs with level below will not be shown
- * @param level - minimum log level to write
+ * \param level - minimum log level to write
*/
void SetLogLevel(LogType level);
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index 2ed6e2c..2bce3b8 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -14,8 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// misc.cpp
-
#include "common/misc.h"
diff --git a/src/common/misc.h b/src/common/misc.h
index f6fd609..f210706 100644
--- a/src/common/misc.h
+++ b/src/common/misc.h
@@ -14,7 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// misc.h
#pragma once
@@ -22,20 +21,6 @@
#include <time.h>
-// TODO: to be removed (replaced by TrackedKey enum and mouse states in app.h)
-const int KS_PAGEUP = (1<<4);
-const int KS_PAGEDOWN = (1<<5);
-const int KS_SHIFT = (1<<6);
-const int KS_CONTROL = (1<<7);
-const int KS_MLEFT = (1<<8);
-const int KS_MRIGHT = (1<<9);
-const int KS_NUMUP = (1<<10);
-const int KS_NUMDOWN = (1<<11);
-const int KS_NUMLEFT = (1<<12);
-const int KS_NUMRIGHT = (1<<13);
-const int KS_NUMPLUS = (1<<14);
-const int KS_NUMMINUS = (1<<15);
-
// TODO: rewrite/refactor or remove
extern char GetNoAccent(char letter);
diff --git a/src/common/profile.cpp b/src/common/profile.cpp
index 2c78f9f..5432489 100644
--- a/src/common/profile.cpp
+++ b/src/common/profile.cpp
@@ -14,10 +14,9 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// profile.cpp
-
#include "common/profile.h"
+
#include "common/logger.h"
#include <utility>
diff --git a/src/common/profile.h b/src/common/profile.h
index facb414..9bc6c37 100644
--- a/src/common/profile.h
+++ b/src/common/profile.h
@@ -21,18 +21,19 @@
#pragma once
-#include <boost/property_tree/ptree.hpp>
#include "common/singleton.h"
+#include <boost/property_tree/ptree.hpp>
+
#include <string>
#include <vector>
/**
-* @class CProfile
+* \class CProfile
*
-* @brief Class for loading profile (currently for loading ini config file)
+* \brief Class for loading profile (currently for loading ini config file)
*
*/
class CProfile : public CSingleton<CProfile>
@@ -42,62 +43,62 @@ class CProfile : public CSingleton<CProfile>
~CProfile();
/** Loads colobot.ini from current directory
- * @return return true on success
+ * \return return true on success
*/
bool InitCurrentDirectory();
/** Sets string value in section under specified key
- * @param std::string section
- * @param std::string key
- * @param std::string value
- * @return return true on success
+ * \param section
+ * \param key
+ * \param value
+ * \return return true on success
*/
bool SetLocalProfileString(std::string section, std::string key, std::string value);
/** Gets string value in section under specified key
- * @param std::string section
- * @param std::string key
- * @param std::string& buffer
- * @return return true on success
+ * \param section
+ * \param key
+ * \param buffer
+ * \return return true on success
*/
bool GetLocalProfileString(std::string section, std::string key, std::string& buffer);
/** Sets int value in section under specified key
- * @param std::string section
- * @param std::string key
- * @param int value
- * @return return true on success
+ * \param section
+ * \param key
+ * \param value
+ * \return return true on success
*/
bool SetLocalProfileInt(std::string section, std::string key, int value);
/** Gets int value in section under specified key
- * @param std::string section
- * @param std::string key
- * @param int& value
- * @return return true on success
+ * \param section
+ * \param key
+ * \param value
+ * \return return true on success
*/
bool GetLocalProfileInt(std::string section, std::string key, int &value);
/** Sets float value in section under specified key
- * @param std::string section
- * @param std::string key
- * @param float value
- * @return return true on success
+ * \param section
+ * \param key
+ * \param value
+ * \return return true on success
*/
bool SetLocalProfileFloat(std::string section, std::string key, float value);
/** Gets float value in section under specified key
- * @param std::string section
- * @param std::string key
- * @param float& value
- * @return return true on success
+ * \param section
+ * \param key
+ * \param value
+ * \return return true on success
*/
bool GetLocalProfileFloat(std::string section, std::string key, float &value);
/** Gets all values in section under specified key
- * @param std::string section
- * @param std::string key
- * @return vector of values
+ * \param section
+ * \param key
+ * \return vector of values
*/
std::vector< std::string > GetLocalProfileSection(std::string section, std::string key);
diff --git a/src/common/restext.cpp b/src/common/restext.cpp
index 0f33f52..da06131 100644
--- a/src/common/restext.cpp
+++ b/src/common/restext.cpp
@@ -12,7 +12,8 @@
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.// restext.cpp
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
#include "common/restext.h"
@@ -20,13 +21,707 @@
#include "common/event.h"
#include "common/logger.h"
#include "common/stringutils.h"
+
#include "CBot/resource.h"
+
#include "object/object.h"
#include "object/robotmain.h"
#include <libintl.h>
#include <SDL/SDL_keyboard.h>
+const char* stringsText[RT_MAX] = { nullptr };
+const char* stringsEvent[EVENT_STD_MAX] = { nullptr };
+const char* stringsObject[OBJECT_MAX] = { nullptr };
+const char* stringsErr[ERR_MAX] = { nullptr };
+const char* stringsCbot[TX_MAX] = { nullptr };
+
+
+void InitializeRestext()
+{
+ stringsText[RT_VERSION_ID] = "Colobot Gold";
+
+ stringsText[RT_DISINFO_TITLE] = "SatCom";
+ stringsText[RT_WINDOW_MAXIMIZED] = "Maximize";
+ stringsText[RT_WINDOW_MINIMIZED] = "Minimize";
+ stringsText[RT_WINDOW_STANDARD] = "Normal size";
+ stringsText[RT_WINDOW_CLOSE] = "Close";
+
+ stringsText[RT_STUDIO_TITLE] = "Program editor";
+ stringsText[RT_SCRIPT_NEW] = "New";
+ stringsText[RT_NAME_DEFAULT] = "Player";
+ stringsText[RT_IO_NEW] = "New ...";
+ stringsText[RT_KEY_OR] = " or ";
+
+ stringsText[RT_TITLE_BASE] = "COLOBOT";
+ stringsText[RT_TITLE_INIT] = "COLOBOT";
+ stringsText[RT_TITLE_TRAINER] = "Programming exercises";
+ stringsText[RT_TITLE_DEFI] = "Challenges";
+ stringsText[RT_TITLE_MISSION] = "Missions";
+ stringsText[RT_TITLE_FREE] = "Free game";
+ stringsText[RT_TITLE_TEEN] = "Free game";
+ stringsText[RT_TITLE_USER] = "User levels";
+ stringsText[RT_TITLE_PROTO] = "Prototypes";
+ stringsText[RT_TITLE_SETUP] = "Options";
+ stringsText[RT_TITLE_NAME] = "Player's name";
+ stringsText[RT_TITLE_PERSO] = "Customize your appearance";
+ stringsText[RT_TITLE_WRITE] = "Save the current mission";
+ stringsText[RT_TITLE_READ] = "Load a saved mission";
+
+ stringsText[RT_PLAY_CHAPt] = " Chapters:";
+ stringsText[RT_PLAY_CHAPd] = " Chapters:";
+ stringsText[RT_PLAY_CHAPm] = " Planets:";
+ stringsText[RT_PLAY_CHAPf] = " Planets:";
+ stringsText[RT_PLAY_CHAPu] = " User levels:";
+ stringsText[RT_PLAY_CHAPp] = " Planets:";
+ stringsText[RT_PLAY_CHAPte] = " Chapters:";
+ stringsText[RT_PLAY_LISTt] = " Exercises in the chapter:";
+ stringsText[RT_PLAY_LISTd] = " Challenges in the chapter:";
+ stringsText[RT_PLAY_LISTm] = " Missions on this planet:";
+ stringsText[RT_PLAY_LISTf] = " Free game on this planet:";
+ stringsText[RT_PLAY_LISTu] = " Missions on this level:";
+ stringsText[RT_PLAY_LISTp] = " Prototypes on this planet:";
+ stringsText[RT_PLAY_LISTk] = " Free game on this chapter:";
+ stringsText[RT_PLAY_RESUME] = " Summary:";
+
+ stringsText[RT_SETUP_DEVICE] = " Drivers:";
+ stringsText[RT_SETUP_MODE] = " Resolution:";
+ stringsText[RT_SETUP_KEY1] = "1) First click on the key you want to redefine.";
+ stringsText[RT_SETUP_KEY2] = "2) Then press the key you want to use instead.";
+
+ stringsText[RT_PERSO_FACE] = "Face type:";
+ stringsText[RT_PERSO_GLASSES] = "Eyeglasses:";
+ stringsText[RT_PERSO_HAIR] = "Hair color:";
+ stringsText[RT_PERSO_COMBI] = "Suit color:";
+ stringsText[RT_PERSO_BAND] = "Strip color:";
+
+ stringsText[RT_DIALOG_QUIT] = "Do you want to quit COLOBOT ?";
+ stringsText[RT_DIALOG_TITLE] = "COLOBOT";
+ stringsText[RT_DIALOG_YESQUIT] = "Quit\\Quit COLOBOT";
+ stringsText[RT_DIALOG_ABORT] = "Quit the mission?";
+ stringsText[RT_DIALOG_YES] = "Abort\\Abort the current mission";
+ stringsText[RT_DIALOG_NO] = "Continue\\Continue the current mission";
+ stringsText[RT_DIALOG_NOQUIT] = "Continue\\Continue the game";
+ stringsText[RT_DIALOG_DELOBJ] = "Do you really want to destroy the selected building?";
+ stringsText[RT_DIALOG_DELGAME] = "Do you want to delete %s's saved games? ";
+ stringsText[RT_DIALOG_YESDEL] = "Delete";
+ stringsText[RT_DIALOG_NODEL] = "Cancel";
+ stringsText[RT_DIALOG_LOADING] = "LOADING";
+
+ stringsText[RT_STUDIO_LISTTT] = "Keyword help(\\key cbot;)";
+ stringsText[RT_STUDIO_COMPOK] = "Compilation ok (0 errors)";
+ stringsText[RT_STUDIO_PROGSTOP] = "Program finished";
+
+ stringsText[RT_SATCOM_LIST] = "\\b;List of objects\n";
+ stringsText[RT_SATCOM_BOT] = "\\b;Robots\n";
+ stringsText[RT_SATCOM_BUILDING] = "\\b;Buildings\n";
+ stringsText[RT_SATCOM_FRET] = "\\b;Moveable objects\n";
+ stringsText[RT_SATCOM_ALIEN] = "\\b;Aliens\n";
+ stringsText[RT_SATCOM_NULL] = "\\c; (none)\\n;\n";
+ stringsText[RT_SATCOM_ERROR1] = "\\b;Error\n";
+ stringsText[RT_SATCOM_ERROR2] = "The list is only available if a \\l;radar station\\u object\\radar; is working.\n";
+
+ stringsText[RT_IO_OPEN] = "Open";
+ stringsText[RT_IO_SAVE] = "Save";
+ stringsText[RT_IO_LIST] = "Folder: %s";
+ stringsText[RT_IO_NAME] = "Name:";
+ stringsText[RT_IO_DIR] = "Folder:";
+ stringsText[RT_IO_PRIVATE] = "Private\\Private folder";
+ stringsText[RT_IO_PUBLIC] = "Public\\Common folder";
+
+ stringsText[RT_GENERIC_DEV1] = "Developed by :";
+ stringsText[RT_GENERIC_DEV2] = "www.epsitec.com";
+ stringsText[RT_GENERIC_EDIT1] = " ";
+ stringsText[RT_GENERIC_EDIT2] = " ";
+
+ stringsText[RT_INTERFACE_REC] = "Recorder";
+
+
+
+ stringsEvent[EVENT_BUTTON_OK] = "OK";
+ stringsEvent[EVENT_BUTTON_CANCEL] = "Cancel";
+ stringsEvent[EVENT_BUTTON_NEXT] = "Next";
+ stringsEvent[EVENT_BUTTON_PREV] = "Previous";
+ stringsEvent[EVENT_BUTTON_QUIT] = "Menu (\\key quit;)";
+
+ stringsEvent[EVENT_DIALOG_OK] = "OK";
+ stringsEvent[EVENT_DIALOG_CANCEL] = "Cancel";
+
+ stringsEvent[EVENT_INTERFACE_TRAINER] = "Exercises\\Programming exercises";
+ stringsEvent[EVENT_INTERFACE_DEFI] = "Challenges\\Programming challenges";
+ stringsEvent[EVENT_INTERFACE_MISSION] = "Missions\\Select mission";
+ stringsEvent[EVENT_INTERFACE_FREE] = "Free game\\Free game without a specific goal";
+ stringsEvent[EVENT_INTERFACE_TEEN] = "Free game\\Free game without a specific goal";
+ stringsEvent[EVENT_INTERFACE_USER] = "User\\User levels";
+ stringsEvent[EVENT_INTERFACE_PROTO] = "Proto\\Prototypes under development";
+ stringsEvent[EVENT_INTERFACE_NAME] = "New player\\Choose player's name";
+ stringsEvent[EVENT_INTERFACE_SETUP] = "Options\\Preferences";
+ stringsEvent[EVENT_INTERFACE_AGAIN] = "Restart\\Restart the mission from the beginning";
+ stringsEvent[EVENT_INTERFACE_WRITE] = "Save\\Save the current mission ";
+ stringsEvent[EVENT_INTERFACE_READ] = "Load\\Load a saved mission";
+ stringsEvent[EVENT_INTERFACE_ABORT] = "\\Return to COLOBOT";
+ stringsEvent[EVENT_INTERFACE_QUIT] = "Quit\\Quit COLOBOT";
+ stringsEvent[EVENT_INTERFACE_BACK] = "<< Back \\Back to the previous screen";
+ stringsEvent[EVENT_INTERFACE_PLAY] = "Play\\Start mission!";
+ stringsEvent[EVENT_INTERFACE_SETUPd] = "Device\\Driver and resolution settings";
+ stringsEvent[EVENT_INTERFACE_SETUPg] = "Graphics\\Graphics settings";
+ stringsEvent[EVENT_INTERFACE_SETUPp] = "Game\\Game settings";
+ stringsEvent[EVENT_INTERFACE_SETUPc] = "Controls\\Keyboard, joystick and mouse settings";
+ stringsEvent[EVENT_INTERFACE_SETUPs] = "Sound\\Music and game sound volume";
+ stringsEvent[EVENT_INTERFACE_DEVICE] = "Unit";
+ stringsEvent[EVENT_INTERFACE_RESOL] = "Resolution";
+ stringsEvent[EVENT_INTERFACE_FULL] = "Full screen\\Full screen or window mode";
+ stringsEvent[EVENT_INTERFACE_APPLY] = "Apply changes\\Activates the changed settings";
+
+ stringsEvent[EVENT_INTERFACE_TOTO] = "Robbie\\Your assistant";
+ stringsEvent[EVENT_INTERFACE_SHADOW] = "Shadows\\Shadows on the ground";
+ stringsEvent[EVENT_INTERFACE_GROUND] = "Marks on the ground\\Marks on the ground";
+ stringsEvent[EVENT_INTERFACE_DIRTY] = "Dust\\Dust and dirt on bots and buildings";
+ stringsEvent[EVENT_INTERFACE_FOG] = "Fog\\Fog";
+ stringsEvent[EVENT_INTERFACE_LENS] = "Sunbeams\\Sunbeams in the sky";
+ stringsEvent[EVENT_INTERFACE_SKY] = "Sky\\Clouds and nebulae";
+ stringsEvent[EVENT_INTERFACE_PLANET] = "Planets and stars\\Astronomical objects in the sky";
+ stringsEvent[EVENT_INTERFACE_LIGHT] = "Dynamic lighting\\Mobile light sources";
+ stringsEvent[EVENT_INTERFACE_PARTI] = "Number of particles\\Explosions, dust, reflections, etc.";
+ stringsEvent[EVENT_INTERFACE_CLIP] = "Depth of field\\Maximum visibility";
+ stringsEvent[EVENT_INTERFACE_DETAIL] = "Details\\Visual quality of 3D objects";
+ stringsEvent[EVENT_INTERFACE_TEXTURE] = "Textures\\Quality of textures ";
+ stringsEvent[EVENT_INTERFACE_GADGET] = "Num of decorative objects\\Number of purely ornamental objects";
+ stringsEvent[EVENT_INTERFACE_RAIN] = "Particles in the interface\\Steam clouds and sparks in the interface";
+ stringsEvent[EVENT_INTERFACE_GLINT] = "Reflections on the buttons \\Shiny buttons";
+ stringsEvent[EVENT_INTERFACE_TOOLTIP] = "Help balloons\\Explain the function of the buttons";
+ stringsEvent[EVENT_INTERFACE_MOVIES] = "Film sequences\\Films before and after the missions";
+ stringsEvent[EVENT_INTERFACE_NICERST] = "Exit film\\Film at the exit of exercises";
+ stringsEvent[EVENT_INTERFACE_HIMSELF] = "Friendly fire\\Your shooting can damage your own objects ";
+ stringsEvent[EVENT_INTERFACE_SCROLL] = "Scrolling\\Scrolling when the mouse touches right or left border";
+ stringsEvent[EVENT_INTERFACE_INVERTX] = "Mouse inversion X\\Inversion of the scrolling direction on the X axis";
+ stringsEvent[EVENT_INTERFACE_INVERTY] = "Mouse inversion Y\\Inversion of the scrolling direction on the Y axis";
+ stringsEvent[EVENT_INTERFACE_EFFECT] = "Quake at explosions\\The screen shakes at explosions";
+ stringsEvent[EVENT_INTERFACE_MOUSE] = "Mouse shadow\\Gives the mouse a shadow";
+ stringsEvent[EVENT_INTERFACE_EDITMODE] = "Automatic indent\\When program editing";
+ stringsEvent[EVENT_INTERFACE_EDITVALUE] = "Big indent\\Indent 2 or 4 spaces per level defined by braces";
+ stringsEvent[EVENT_INTERFACE_SOLUCE4] = "Access to solutions\\Show program \"4: Solution\" in the exercises";
+
+ stringsEvent[EVENT_INTERFACE_KDEF] = "Standard controls\\Standard key functions";
+ stringsEvent[EVENT_INTERFACE_KLEFT] = "Turn left\\turns the bot to the left";
+ stringsEvent[EVENT_INTERFACE_KRIGHT] = "Turn right\\turns the bot to the right";
+ stringsEvent[EVENT_INTERFACE_KUP] = "Forward\\Moves forward";
+ stringsEvent[EVENT_INTERFACE_KDOWN] = "Backward\\Moves backward";
+ stringsEvent[EVENT_INTERFACE_KGUP] = "Climb\\Increases the power of the jet";
+ stringsEvent[EVENT_INTERFACE_KGDOWN] = "Descend\\Reduces the power of the jet";
+ stringsEvent[EVENT_INTERFACE_KCAMERA] = "Change camera\\Switches between onboard camera and following camera";
+ stringsEvent[EVENT_INTERFACE_KDESEL] = "Previous object\\Selects the previous object";
+ stringsEvent[EVENT_INTERFACE_KACTION] = "Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)";
+ stringsEvent[EVENT_INTERFACE_KNEAR] = "Camera closer\\Moves the camera forward";
+ stringsEvent[EVENT_INTERFACE_KAWAY] = "Camera back\\Moves the camera backward";
+ stringsEvent[EVENT_INTERFACE_KNEXT] = "Next object\\Selects the next object";
+ stringsEvent[EVENT_INTERFACE_KHUMAN] = "Select the astronaut\\Selects the astronaut";
+ stringsEvent[EVENT_INTERFACE_KQUIT] = "Quit\\Quit the current mission or exercise";
+ stringsEvent[EVENT_INTERFACE_KHELP] = "Instructions\\Shows the instructions for the current mission";
+ stringsEvent[EVENT_INTERFACE_KPROG] = "Programming help\\Gives more detailed help with programming";
+ stringsEvent[EVENT_INTERFACE_KCBOT] = "Key word help\\More detailed help about key words";
+ stringsEvent[EVENT_INTERFACE_KVISIT] = "Origin of last message\\Shows where the last message was sent from";
+ stringsEvent[EVENT_INTERFACE_KSPEED10] = "Speed 1.0x\\Normal speed";
+ stringsEvent[EVENT_INTERFACE_KSPEED15] = "Speed 1.5x\\1.5 times faster";
+ stringsEvent[EVENT_INTERFACE_KSPEED20] = "Speed 2.0x\\Double speed";
+ stringsEvent[EVENT_INTERFACE_KSPEED30] = "Speed 3.0x\\Three times faster";
+
+ stringsEvent[EVENT_INTERFACE_VOLSOUND] = "Sound effects:\\Volume of engines, voice, shooting, etc.";
+ stringsEvent[EVENT_INTERFACE_VOLMUSIC] = "Background sound :\\Volume of audio tracks on the CD";
+ stringsEvent[EVENT_INTERFACE_SOUND3D] = "3D sound\\3D positioning of the sound";
+
+ stringsEvent[EVENT_INTERFACE_MIN] = "Lowest\\Minimum graphic quality (highest frame rate)";
+ stringsEvent[EVENT_INTERFACE_NORM] = "Normal\\Normal graphic quality";
+ stringsEvent[EVENT_INTERFACE_MAX] = "Highest\\Highest graphic quality (lowest frame rate)";
+
+ stringsEvent[EVENT_INTERFACE_SILENT] = "Mute\\No sound";
+ stringsEvent[EVENT_INTERFACE_NOISY] = "Normal\\Normal sound volume";
+
+ stringsEvent[EVENT_INTERFACE_JOYSTICK] = "Use a joystick\\Joystick or keyboard";
+ stringsEvent[EVENT_INTERFACE_SOLUCE] = "Access to solution\\Shows the solution (detailed instructions for missions)";
+
+ stringsEvent[EVENT_INTERFACE_NEDIT] = "\\New player name";
+ stringsEvent[EVENT_INTERFACE_NOK] = "OK\\Choose the selected player";
+ stringsEvent[EVENT_INTERFACE_NCANCEL] = "Cancel\\Keep current player name";
+ stringsEvent[EVENT_INTERFACE_NDELETE] = "Delete player\\Deletes the player from the list";
+ stringsEvent[EVENT_INTERFACE_NLABEL] = "Player name";
+
+ stringsEvent[EVENT_INTERFACE_IOWRITE] = "Save\\Saves the current mission";
+ stringsEvent[EVENT_INTERFACE_IOREAD] = "Load\\Loads the selected mission";
+ stringsEvent[EVENT_INTERFACE_IOLIST] = "List of saved missions";
+ stringsEvent[EVENT_INTERFACE_IOLABEL] = "Filename:";
+ stringsEvent[EVENT_INTERFACE_IONAME] = "Mission name";
+ stringsEvent[EVENT_INTERFACE_IOIMAGE] = "Photography";
+ stringsEvent[EVENT_INTERFACE_IODELETE] = "Delete\\Deletes the selected file";
+
+ stringsEvent[EVENT_INTERFACE_PERSO] = "Appearance\\Choose your appearance";
+ stringsEvent[EVENT_INTERFACE_POK] = "OK";
+ stringsEvent[EVENT_INTERFACE_PCANCEL] = "Cancel";
+ stringsEvent[EVENT_INTERFACE_PDEF] = "Standard\\Standard appearance settings";
+ stringsEvent[EVENT_INTERFACE_PHEAD] = "Head\\Face and hair";
+ stringsEvent[EVENT_INTERFACE_PBODY] = "Suit\\Astronaut suit";
+ stringsEvent[EVENT_INTERFACE_PLROT] = "\\Turn left";
+ stringsEvent[EVENT_INTERFACE_PRROT] = "\\Turn right";
+ stringsEvent[EVENT_INTERFACE_PCRa] = "Red";
+ stringsEvent[EVENT_INTERFACE_PCGa] = "Green";
+ stringsEvent[EVENT_INTERFACE_PCBa] = "Blue";
+ stringsEvent[EVENT_INTERFACE_PCRb] = "Red";
+ stringsEvent[EVENT_INTERFACE_PCGb] = "Green";
+ stringsEvent[EVENT_INTERFACE_PCBb] = "Blue";
+ stringsEvent[EVENT_INTERFACE_PFACE1] = "\\Face 1";
+ stringsEvent[EVENT_INTERFACE_PFACE2] = "\\Face 4";
+ stringsEvent[EVENT_INTERFACE_PFACE3] = "\\Face 3";
+ stringsEvent[EVENT_INTERFACE_PFACE4] = "\\Face 2";
+ stringsEvent[EVENT_INTERFACE_PGLASS0] = "\\No eyeglasses";
+ stringsEvent[EVENT_INTERFACE_PGLASS1] = "\\Eyeglasses 1";
+ stringsEvent[EVENT_INTERFACE_PGLASS2] = "\\Eyeglasses 2";
+ stringsEvent[EVENT_INTERFACE_PGLASS3] = "\\Eyeglasses 3";
+ stringsEvent[EVENT_INTERFACE_PGLASS4] = "\\Eyeglasses 4";
+ stringsEvent[EVENT_INTERFACE_PGLASS5] = "\\Eyeglasses 5";
+
+ stringsEvent[EVENT_OBJECT_DESELECT] = "Previous selection (\\key desel;)";
+ stringsEvent[EVENT_OBJECT_LEFT] = "Turn left (\\key left;)";
+ stringsEvent[EVENT_OBJECT_RIGHT] = "Turn right (\\key right;)";
+ stringsEvent[EVENT_OBJECT_UP] = "Forward (\\key up;)";
+ stringsEvent[EVENT_OBJECT_DOWN] = "Backward (\\key down;)";
+ stringsEvent[EVENT_OBJECT_GASUP] = "Up (\\key gup;)";
+ stringsEvent[EVENT_OBJECT_GASDOWN] = "Down (\\key gdown;)";
+ stringsEvent[EVENT_OBJECT_HTAKE] = "Grab or drop (\\key action;)";
+ stringsEvent[EVENT_OBJECT_MTAKE] = "Grab or drop (\\key action;)";
+ stringsEvent[EVENT_OBJECT_MFRONT] = "..in front";
+ stringsEvent[EVENT_OBJECT_MBACK] = "..behind";
+ stringsEvent[EVENT_OBJECT_MPOWER] = "..power cell";
+ stringsEvent[EVENT_OBJECT_BHELP] = "Instructions for the mission (\\key help;)";
+ stringsEvent[EVENT_OBJECT_BTAKEOFF] = "Take off to finish the mission";
+ stringsEvent[EVENT_OBJECT_BDERRICK] = "Build a derrick";
+ stringsEvent[EVENT_OBJECT_BSTATION] = "Build a power station";
+ stringsEvent[EVENT_OBJECT_BFACTORY] = "Build a bot factory";
+ stringsEvent[EVENT_OBJECT_BREPAIR] = "Build a repair center";
+ stringsEvent[EVENT_OBJECT_BCONVERT] = "Build a converter";
+ stringsEvent[EVENT_OBJECT_BTOWER] = "Build a defense tower";
+ stringsEvent[EVENT_OBJECT_BRESEARCH] = "Build a research center";
+ stringsEvent[EVENT_OBJECT_BRADAR] = "Build a radar station";
+ stringsEvent[EVENT_OBJECT_BENERGY] = "Build a power cell factory";
+ stringsEvent[EVENT_OBJECT_BLABO] = "Build an autolab";
+ stringsEvent[EVENT_OBJECT_BNUCLEAR] = "Build a nuclear power plant";
+ stringsEvent[EVENT_OBJECT_BPARA] = "Build a lightning conductor";
+ stringsEvent[EVENT_OBJECT_BINFO] = "Build a exchange post";
+ stringsEvent[EVENT_OBJECT_GFLAT] = "Show if the ground is flat";
+ stringsEvent[EVENT_OBJECT_FCREATE] = "Plant a flag";
+ stringsEvent[EVENT_OBJECT_FDELETE] = "Remove a flag";
+ stringsEvent[EVENT_OBJECT_FCOLORb] = "\\Blue flags";
+ stringsEvent[EVENT_OBJECT_FCOLORr] = "\\Red flags";
+ stringsEvent[EVENT_OBJECT_FCOLORg] = "\\Green flags";
+ stringsEvent[EVENT_OBJECT_FCOLORy] = "\\Yellow flags";
+ stringsEvent[EVENT_OBJECT_FCOLORv] = "\\Violet flags";
+ stringsEvent[EVENT_OBJECT_FACTORYfa] = "Build a winged grabber";
+ stringsEvent[EVENT_OBJECT_FACTORYta] = "Build a tracked grabber";
+ stringsEvent[EVENT_OBJECT_FACTORYwa] = "Build a wheeled grabber";
+ stringsEvent[EVENT_OBJECT_FACTORYia] = "Build a legged grabber";
+ stringsEvent[EVENT_OBJECT_FACTORYfc] = "Build a winged shooter";
+ stringsEvent[EVENT_OBJECT_FACTORYtc] = "Build a tracked shooter";
+ stringsEvent[EVENT_OBJECT_FACTORYwc] = "Build a wheeled shooter";
+ stringsEvent[EVENT_OBJECT_FACTORYic] = "Build a legged shooter";
+ stringsEvent[EVENT_OBJECT_FACTORYfi] = "Build a winged orga shooter";
+ stringsEvent[EVENT_OBJECT_FACTORYti] = "Build a tracked orga shooter";
+ stringsEvent[EVENT_OBJECT_FACTORYwi] = "Build a wheeled orga shooter";
+ stringsEvent[EVENT_OBJECT_FACTORYii] = "Build a legged orga shooter";
+ stringsEvent[EVENT_OBJECT_FACTORYfs] = "Build a winged sniffer";
+ stringsEvent[EVENT_OBJECT_FACTORYts] = "Build a tracked sniffer";
+ stringsEvent[EVENT_OBJECT_FACTORYws] = "Build a wheeled sniffer";
+ stringsEvent[EVENT_OBJECT_FACTORYis] = "Build a legged sniffer";
+ stringsEvent[EVENT_OBJECT_FACTORYrt] = "Build a thumper";
+ stringsEvent[EVENT_OBJECT_FACTORYrc] = "Build a phazer shooter";
+ stringsEvent[EVENT_OBJECT_FACTORYrr] = "Build a recycler";
+ stringsEvent[EVENT_OBJECT_FACTORYrs] = "Build a shielder";
+ stringsEvent[EVENT_OBJECT_FACTORYsa] = "Build a subber";
+ stringsEvent[EVENT_OBJECT_RTANK] = "Run research program for tracked bots";
+ stringsEvent[EVENT_OBJECT_RFLY] = "Run research program for winged bots";
+ stringsEvent[EVENT_OBJECT_RTHUMP] = "Run research program for thumper";
+ stringsEvent[EVENT_OBJECT_RCANON] = "Run research program for shooter";
+ stringsEvent[EVENT_OBJECT_RTOWER] = "Run research program for defense tower";
+ stringsEvent[EVENT_OBJECT_RPHAZER] = "Run research program for phazer shooter";
+ stringsEvent[EVENT_OBJECT_RSHIELD] = "Run research program for shielder";
+ stringsEvent[EVENT_OBJECT_RATOMIC] = "Run research program for nuclear power";
+ stringsEvent[EVENT_OBJECT_RiPAW] = "Run research program for legged bots";
+ stringsEvent[EVENT_OBJECT_RiGUN] = "Run research program for orga shooter";
+ stringsEvent[EVENT_OBJECT_RESET] = "Return to start";
+ stringsEvent[EVENT_OBJECT_SEARCH] = "Sniff (\\key action;)";
+ stringsEvent[EVENT_OBJECT_TERRAFORM] = "Thump (\\key action;)";
+ stringsEvent[EVENT_OBJECT_FIRE] = "Shoot (\\key action;)";
+ stringsEvent[EVENT_OBJECT_RECOVER] = "Recycle (\\key action;)";
+ stringsEvent[EVENT_OBJECT_BEGSHIELD] = "Extend shield (\\key action;)";
+ stringsEvent[EVENT_OBJECT_ENDSHIELD] = "Withdraw shield (\\key action;)";
+ stringsEvent[EVENT_OBJECT_DIMSHIELD] = "Shield radius";
+ stringsEvent[EVENT_OBJECT_PROGRUN] = "Execute the selected program";
+ stringsEvent[EVENT_OBJECT_PROGEDIT] = "Edit the selected program";
+ stringsEvent[EVENT_OBJECT_INFOOK] = "\\SatCom on standby";
+ stringsEvent[EVENT_OBJECT_DELETE] = "Destroy the building";
+ stringsEvent[EVENT_OBJECT_GENERGY] = "Energy level";
+ stringsEvent[EVENT_OBJECT_GSHIELD] = "Shield level";
+ stringsEvent[EVENT_OBJECT_GRANGE] = "Jet temperature";
+ stringsEvent[EVENT_OBJECT_GPROGRESS] = "Still working ...";
+ stringsEvent[EVENT_OBJECT_GRADAR] = "Number of insects detected";
+ stringsEvent[EVENT_OBJECT_GINFO] = "Transmitted information";
+ stringsEvent[EVENT_OBJECT_COMPASS] = "Compass";
+ stringsEvent[EVENT_OBJECT_MAPZOOM] = "Zoom mini-map";
+ stringsEvent[EVENT_OBJECT_CAMERA] = "Camera (\\key camera;)";
+ stringsEvent[EVENT_OBJECT_CAMERAleft] = "Camera to left";
+ stringsEvent[EVENT_OBJECT_CAMERAright] = "Camera to right";
+ stringsEvent[EVENT_OBJECT_CAMERAnear] = "Camera nearest";
+ stringsEvent[EVENT_OBJECT_CAMERAaway] = "Camera awayest";
+ stringsEvent[EVENT_OBJECT_HELP] = "Help about selected object";
+ stringsEvent[EVENT_OBJECT_SOLUCE] = "Show the solution";
+ stringsEvent[EVENT_OBJECT_SHORTCUT00] = "Switch bots <-> buildings";
+ stringsEvent[EVENT_OBJECT_LIMIT] = "Show the range";
+ stringsEvent[EVENT_OBJECT_PEN0] = "\\Raise the pencil";
+ stringsEvent[EVENT_OBJECT_PEN1] = "\\Use the black pencil";
+ stringsEvent[EVENT_OBJECT_PEN2] = "\\Use the yellow pencil";
+ stringsEvent[EVENT_OBJECT_PEN3] = "\\Use the orange pencil";
+ stringsEvent[EVENT_OBJECT_PEN4] = "\\Use the red pencil";
+ stringsEvent[EVENT_OBJECT_PEN5] = "\\Use the purple pencil";
+ stringsEvent[EVENT_OBJECT_PEN6] = "\\Use the blue pencil";
+ stringsEvent[EVENT_OBJECT_PEN7] = "\\Use the green pencil";
+ stringsEvent[EVENT_OBJECT_PEN8] = "\\Use the brown pencil";
+ stringsEvent[EVENT_OBJECT_REC] = "\\Start recording";
+ stringsEvent[EVENT_OBJECT_STOP] = "\\Stop recording";
+ stringsEvent[EVENT_DT_VISIT0] = "Show the place";
+ stringsEvent[EVENT_DT_VISIT1] = "Show the place";
+ stringsEvent[EVENT_DT_VISIT2] = "Show the place";
+ stringsEvent[EVENT_DT_VISIT3] = "Show the place";
+ stringsEvent[EVENT_DT_VISIT4] = "Show the place";
+ stringsEvent[EVENT_DT_END] = "Continue";
+ stringsEvent[EVENT_CMD] = "Command line";
+ stringsEvent[EVENT_SPEED] = "Game speed";
+
+ stringsEvent[EVENT_HYPER_PREV] = "Back";
+ stringsEvent[EVENT_HYPER_NEXT] = "Forward";
+ stringsEvent[EVENT_HYPER_HOME] = "Home";
+ stringsEvent[EVENT_HYPER_COPY] = "Copy";
+ stringsEvent[EVENT_HYPER_SIZE1] = "Size 1";
+ stringsEvent[EVENT_HYPER_SIZE2] = "Size 2";
+ stringsEvent[EVENT_HYPER_SIZE3] = "Size 3";
+ stringsEvent[EVENT_HYPER_SIZE4] = "Size 4";
+ stringsEvent[EVENT_HYPER_SIZE5] = "Size 5";
+ stringsEvent[EVENT_SATCOM_HUSTON] = "Instructions from Houston";
+ stringsEvent[EVENT_SATCOM_SAT] = "Satellite report";
+ stringsEvent[EVENT_SATCOM_LOADING] = "Programs dispatched by Houston";
+ stringsEvent[EVENT_SATCOM_OBJECT] = "List of objects";
+ stringsEvent[EVENT_SATCOM_PROG] = "Programming help";
+ stringsEvent[EVENT_SATCOM_SOLUCE] = "Solution";
+
+ stringsEvent[EVENT_STUDIO_OK] = "OK\\Close program editor and return to game";
+ stringsEvent[EVENT_STUDIO_CANCEL] = "Cancel\\Cancel all changes";
+ stringsEvent[EVENT_STUDIO_NEW] = "New";
+ stringsEvent[EVENT_STUDIO_OPEN] = "Open (Ctrl+o)";
+ stringsEvent[EVENT_STUDIO_SAVE] = "Save (Ctrl+s)";
+ stringsEvent[EVENT_STUDIO_UNDO] = "Undo (Ctrl+z)";
+ stringsEvent[EVENT_STUDIO_CUT] = "Cut (Ctrl+x)";
+ stringsEvent[EVENT_STUDIO_COPY] = "Copy (Ctrl+c)";
+ stringsEvent[EVENT_STUDIO_PASTE] = "Paste (Ctrl+v)";
+ stringsEvent[EVENT_STUDIO_SIZE] = "Font size";
+ stringsEvent[EVENT_STUDIO_TOOL] = "Instructions (\\key help;)";
+ stringsEvent[EVENT_STUDIO_HELP] = "Programming help (\\key prog;)";
+ stringsEvent[EVENT_STUDIO_COMPILE] = "Compile";
+ stringsEvent[EVENT_STUDIO_RUN] = "Execute/stop";
+ stringsEvent[EVENT_STUDIO_REALTIME] = "Pause/continue";
+ stringsEvent[EVENT_STUDIO_STEP] = "One step";
+
+
+
+ stringsObject[OBJECT_PORTICO] = "Gantry crane";
+ stringsObject[OBJECT_BASE] = "Spaceship";
+ stringsObject[OBJECT_DERRICK] = "Derrick";
+ stringsObject[OBJECT_FACTORY] = "Bot factory";
+ stringsObject[OBJECT_REPAIR] = "Repair center";
+ stringsObject[OBJECT_DESTROYER] = "Destroyer";
+ stringsObject[OBJECT_STATION] = "Power station";
+ stringsObject[OBJECT_CONVERT] = "Converts ore to titanium";
+ stringsObject[OBJECT_TOWER] = "Defense tower";
+ stringsObject[OBJECT_NEST] = "Nest";
+ stringsObject[OBJECT_RESEARCH] = "Research center";
+ stringsObject[OBJECT_RADAR] = "Radar station";
+ stringsObject[OBJECT_INFO] = "Information exchange post";
+ stringsObject[OBJECT_ENERGY] = "Power cell factory";
+ stringsObject[OBJECT_LABO] = "Autolab";
+ stringsObject[OBJECT_NUCLEAR] = "Nuclear power station";
+ stringsObject[OBJECT_PARA] = "Lightning conductor";
+ stringsObject[OBJECT_SAFE] = "Vault";
+ stringsObject[OBJECT_HUSTON] = "Houston Mission Control";
+ stringsObject[OBJECT_TARGET1] = "Target";
+ stringsObject[OBJECT_TARGET2] = "Target";
+ stringsObject[OBJECT_START] = "Start";
+ stringsObject[OBJECT_END] = "Finish";
+ stringsObject[OBJECT_STONE] = "Titanium ore";
+ stringsObject[OBJECT_URANIUM] = "Uranium ore";
+ stringsObject[OBJECT_BULLET] = "Organic matter";
+ stringsObject[OBJECT_METAL] = "Titanium";
+ stringsObject[OBJECT_POWER] = "Power cell";
+ stringsObject[OBJECT_ATOMIC] = "Nuclear power cell";
+ stringsObject[OBJECT_BBOX] = "Black box";
+ stringsObject[OBJECT_KEYa] = "Key A";
+ stringsObject[OBJECT_KEYb] = "Key B";
+ stringsObject[OBJECT_KEYc] = "Key C";
+ stringsObject[OBJECT_KEYd] = "Key D";
+ stringsObject[OBJECT_TNT] = "Explosive";
+ stringsObject[OBJECT_BOMB] = "Fixed mine";
+ stringsObject[OBJECT_BAG] = "Survival kit";
+ stringsObject[OBJECT_WAYPOINT] = "Checkpoint";
+ stringsObject[OBJECT_FLAGb] = "Blue flag";
+ stringsObject[OBJECT_FLAGr] = "Red flag";
+ stringsObject[OBJECT_FLAGg] = "Green flag";
+ stringsObject[OBJECT_FLAGy] = "Yellow flag";
+ stringsObject[OBJECT_FLAGv] = "Violet flag";
+ stringsObject[OBJECT_MARKPOWER] = "Energy deposit (site for power station)";
+ stringsObject[OBJECT_MARKURANIUM] = "Uranium deposit (site for derrick)";
+ stringsObject[OBJECT_MARKKEYa] = "Found key A (site for derrick)";
+ stringsObject[OBJECT_MARKKEYb] = "Found key B (site for derrick)";
+ stringsObject[OBJECT_MARKKEYc] = "Found key C (site for derrick)";
+ stringsObject[OBJECT_MARKKEYd] = "Found key D (site for derrick)";
+ stringsObject[OBJECT_MARKSTONE] = "Titanium deposit (site for derrick)";
+ stringsObject[OBJECT_MOBILEft] = "Practice bot";
+ stringsObject[OBJECT_MOBILEtt] = "Practice bot";
+ stringsObject[OBJECT_MOBILEwt] = "Practice bot";
+ stringsObject[OBJECT_MOBILEit] = "Practice bot";
+ stringsObject[OBJECT_MOBILEfa] = "Winged grabber";
+ stringsObject[OBJECT_MOBILEta] = "Tracked grabber";
+ stringsObject[OBJECT_MOBILEwa] = "Wheeled grabber";
+ stringsObject[OBJECT_MOBILEia] = "Legged grabber";
+ stringsObject[OBJECT_MOBILEfc] = "Winged shooter";
+ stringsObject[OBJECT_MOBILEtc] = "Tracked shooter";
+ stringsObject[OBJECT_MOBILEwc] = "Wheeled shooter";
+ stringsObject[OBJECT_MOBILEic] = "Legged shooter";
+ stringsObject[OBJECT_MOBILEfi] = "Winged orga shooter";
+ stringsObject[OBJECT_MOBILEti] = "Tracked orga shooter";
+ stringsObject[OBJECT_MOBILEwi] = "Wheeled orga shooter";
+ stringsObject[OBJECT_MOBILEii] = "Legged orga shooter";
+ stringsObject[OBJECT_MOBILEfs] = "Winged sniffer";
+ stringsObject[OBJECT_MOBILEts] = "Tracked sniffer";
+ stringsObject[OBJECT_MOBILEws] = "Wheeled sniffer";
+ stringsObject[OBJECT_MOBILEis] = "Legged sniffer";
+ stringsObject[OBJECT_MOBILErt] = "Thumper";
+ stringsObject[OBJECT_MOBILErc] = "Phazer shooter";
+ stringsObject[OBJECT_MOBILErr] = "Recycler";
+ stringsObject[OBJECT_MOBILErs] = "Shielder";
+ stringsObject[OBJECT_MOBILEsa] = "Subber";
+ stringsObject[OBJECT_MOBILEtg] = "Target bot";
+ stringsObject[OBJECT_MOBILEdr] = "Drawer bot";
+ stringsObject[OBJECT_TECH] = "Engineer";
+ stringsObject[OBJECT_TOTO] = "Robbie";
+ stringsObject[OBJECT_MOTHER] = "Alien Queen";
+ stringsObject[OBJECT_ANT] = "Ant";
+ stringsObject[OBJECT_SPIDER] = "Spider";
+ stringsObject[OBJECT_BEE] = "Wasp";
+ stringsObject[OBJECT_WORM] = "Worm";
+ stringsObject[OBJECT_EGG] = "Egg";
+ stringsObject[OBJECT_RUINmobilew1] = "Wreckage";
+ stringsObject[OBJECT_RUINmobilew2] = "Wreckage";
+ stringsObject[OBJECT_RUINmobilet1] = "Wreckage";
+ stringsObject[OBJECT_RUINmobilet2] = "Wreckage";
+ stringsObject[OBJECT_RUINmobiler1] = "Wreckage";
+ stringsObject[OBJECT_RUINmobiler2] = "Wreckage";
+ stringsObject[OBJECT_RUINfactory] = "Ruin";
+ stringsObject[OBJECT_RUINdoor] = "Ruin";
+ stringsObject[OBJECT_RUINsupport] = "Waste";
+ stringsObject[OBJECT_RUINradar] = "Ruin";
+ stringsObject[OBJECT_RUINconvert] = "Ruin";
+ stringsObject[OBJECT_RUINbase] = "Spaceship ruin";
+ stringsObject[OBJECT_RUINhead] = "Spaceship ruin";
+ stringsObject[OBJECT_APOLLO1] = "Remains of Apollo mission";
+ stringsObject[OBJECT_APOLLO3] = "Remains of Apollo mission";
+ stringsObject[OBJECT_APOLLO4] = "Remains of Apollo mission";
+ stringsObject[OBJECT_APOLLO5] = "Remains of Apollo mission";
+ stringsObject[OBJECT_APOLLO2] = "Lunar Roving Vehicle";
+
+
+
+ stringsErr[ERR_CMD] = "Unknown command";
+ stringsErr[ERR_MANIP_VEH] = "Inappropriate bot";
+ stringsErr[ERR_MANIP_FLY] = "Impossible when flying";
+ stringsErr[ERR_MANIP_BUSY] = "Already carrying something";
+ stringsErr[ERR_MANIP_NIL] = "Nothing to grab";
+ stringsErr[ERR_MANIP_MOTOR] = "Impossible when moving";
+ stringsErr[ERR_MANIP_OCC] = "Place occupied";
+ stringsErr[ERR_MANIP_FRIEND] = "No other robot";
+ stringsErr[ERR_MANIP_RADIO] = "You can not carry a radioactive object";
+ stringsErr[ERR_MANIP_WATER] = "You can not carry an object under water";
+ stringsErr[ERR_MANIP_EMPTY] = "Nothing to drop";
+ stringsErr[ERR_BUILD_FLY] = "Impossible when flying";
+ stringsErr[ERR_BUILD_WATER] = "Impossible under water";
+ stringsErr[ERR_BUILD_ENERGY] = "Not enough energy";
+ stringsErr[ERR_BUILD_METALAWAY] = "Titanium too far away";
+ stringsErr[ERR_BUILD_METALNEAR] = "Titanium too close";
+ stringsErr[ERR_BUILD_METALINEX] = "No titanium around";
+ stringsErr[ERR_BUILD_FLAT] = "Ground not flat enough";
+ stringsErr[ERR_BUILD_FLATLIT] = "Flat ground not large enough";
+ stringsErr[ERR_BUILD_BUSY] = "Place occupied";
+ stringsErr[ERR_BUILD_BASE] = "Too close to space ship";
+ stringsErr[ERR_BUILD_NARROW] = "Too close to a building";
+ stringsErr[ERR_BUILD_MOTOR] = "Impossible when moving";
+ stringsErr[ERR_SEARCH_FLY] = "Impossible when flying";
+ stringsErr[ERR_SEARCH_VEH] = "Inappropriate bot";
+ stringsErr[ERR_SEARCH_MOTOR] = "Impossible when moving";
+ stringsErr[ERR_TERRA_VEH] = "Inappropriate bot";
+ stringsErr[ERR_TERRA_ENERGY] = "Not enough energy";
+ stringsErr[ERR_TERRA_FLOOR] = "Ground inappropriate";
+ stringsErr[ERR_TERRA_BUILDING] = "Building too close";
+ stringsErr[ERR_TERRA_OBJECT] = "Object too close";
+ stringsErr[ERR_RECOVER_VEH] = "Inappropriate bot";
+ stringsErr[ERR_RECOVER_ENERGY] = "Not enough energy";
+ stringsErr[ERR_RECOVER_NULL] = "Nothing to recycle";
+ stringsErr[ERR_SHIELD_VEH] = "Inappropriate bot";
+ stringsErr[ERR_SHIELD_ENERGY] = "No more energy";
+ stringsErr[ERR_MOVE_IMPOSSIBLE] = "Error in instruction move";
+ stringsErr[ERR_FIND_IMPOSSIBLE] = "Object not found";
+ stringsErr[ERR_GOTO_IMPOSSIBLE] = "Goto: inaccessible destination";
+ stringsErr[ERR_GOTO_ITER] = "Goto: inaccessible destination";
+ stringsErr[ERR_GOTO_BUSY] = "Goto: destination occupied";
+ stringsErr[ERR_FIRE_VEH] = "Inappropriate bot";
+ stringsErr[ERR_FIRE_ENERGY] = "Not enough energy";
+ stringsErr[ERR_FIRE_FLY] = "Impossible when flying";
+ stringsErr[ERR_CONVERT_EMPTY] = "No titanium ore to convert";
+ stringsErr[ERR_DERRICK_NULL] = "No ore in the subsoil";
+ stringsErr[ERR_STATION_NULL] = "No energy in the subsoil";
+ stringsErr[ERR_TOWER_POWER] = "No power cell";
+ stringsErr[ERR_TOWER_ENERGY] = "No more energy";
+ stringsErr[ERR_RESEARCH_POWER] = "No power cell";
+ stringsErr[ERR_RESEARCH_ENERGY] = "Not enough energy";
+ stringsErr[ERR_RESEARCH_TYPE] = "Inappropriate cell type";
+ stringsErr[ERR_RESEARCH_ALREADY]= "Research program already performed";
+ stringsErr[ERR_ENERGY_NULL] = "No energy in the subsoil";
+ stringsErr[ERR_ENERGY_LOW] = "Not enough energy yet";
+ stringsErr[ERR_ENERGY_EMPTY] = "No titanium to transform";
+ stringsErr[ERR_ENERGY_BAD] = "Transforms only titanium";
+ stringsErr[ERR_BASE_DLOCK] = "Doors blocked by a robot or another object ";
+ stringsErr[ERR_BASE_DHUMAN] = "You must get on the spaceship to take off ";
+ stringsErr[ERR_LABO_NULL] = "Nothing to analyze";
+ stringsErr[ERR_LABO_BAD] = "Analyzes only organic matter";
+ stringsErr[ERR_LABO_ALREADY] = "Analysis already performed";
+ stringsErr[ERR_NUCLEAR_NULL] = "No energy in the subsoil";
+ stringsErr[ERR_NUCLEAR_LOW] = "Not yet enough energy";
+ stringsErr[ERR_NUCLEAR_EMPTY] = "No uranium to transform";
+ stringsErr[ERR_NUCLEAR_BAD] = "Transforms only uranium";
+ stringsErr[ERR_FACTORY_NULL] = "No titanium";
+ stringsErr[ERR_FACTORY_NEAR] = "Object too close";
+ stringsErr[ERR_RESET_NEAR] = "Place occupied";
+ stringsErr[ERR_INFO_NULL] = "No information exchange post within range";
+ stringsErr[ERR_VEH_VIRUS] = "Program infected by a virus";
+ stringsErr[ERR_BAT_VIRUS] = "Infected by a virus; temporarily out of order";
+ stringsErr[ERR_VEH_POWER] = "No power cell";
+ stringsErr[ERR_VEH_ENERGY] = "No more energy";
+ stringsErr[ERR_FLAG_FLY] = "Impossible when flying";
+ stringsErr[ERR_FLAG_WATER] = "Impossible when swimming";
+ stringsErr[ERR_FLAG_MOTOR] = "Impossible when moving";
+ stringsErr[ERR_FLAG_BUSY] = "Impossible when carrying an object";
+ stringsErr[ERR_FLAG_CREATE] = "Too many flags of this color (maximum 5)";
+ stringsErr[ERR_FLAG_PROXY] = "Too close to an existing flag";
+ stringsErr[ERR_FLAG_DELETE] = "No flag nearby";
+ stringsErr[ERR_MISSION_NOTERM] = "The mission is not accomplished yet (press \\key help; for more details)";
+ stringsErr[ERR_DELETEMOBILE] = "Bot destroyed";
+ stringsErr[ERR_DELETEBUILDING] = "Building destroyed";
+ stringsErr[ERR_TOOMANY] = "Can not create this; there are too many objects";
+ stringsErr[ERR_OBLIGATORYTOKEN] = "\"%s\" missing in this exercise";
+ stringsErr[ERR_PROHIBITEDTOKEN] = "Do not use in this exercise";
+
+ stringsErr[INFO_BUILD] = "Building completed";
+ stringsErr[INFO_CONVERT] = "Titanium available";
+ stringsErr[INFO_RESEARCH] = "Research program completed";
+ stringsErr[INFO_RESEARCHTANK] = "Plans for tracked robots available ";
+ stringsErr[INFO_RESEARCHFLY] = "You can fly with the keys (\\key gup;) and (\\key gdown;)";
+ stringsErr[INFO_RESEARCHTHUMP] = "Plans for thumper available";
+ stringsErr[INFO_RESEARCHCANON] = "Plans for shooter available";
+ stringsErr[INFO_RESEARCHTOWER] = "Plans for defense tower available";
+ stringsErr[INFO_RESEARCHPHAZER] = "Plans for phazer shooter available";
+ stringsErr[INFO_RESEARCHSHIELD] = "Plans for shielder available";
+ stringsErr[INFO_RESEARCHATOMIC] = "Plans for nuclear power plant available";
+ stringsErr[INFO_FACTORY] = "New bot available";
+ stringsErr[INFO_LABO] = "Analysis performed";
+ stringsErr[INFO_ENERGY] = "Power cell available";
+ stringsErr[INFO_NUCLEAR] = "Nuclear power cell available";
+ stringsErr[INFO_FINDING] = "You found a usable object";
+ stringsErr[INFO_MARKPOWER] = "Found a site for power station";
+ stringsErr[INFO_MARKURANIUM] = "Found a site for a derrick";
+ stringsErr[INFO_MARKSTONE] = "Found a site for a derrick";
+ stringsErr[INFO_MARKKEYa] = "Found a site for a derrick";
+ stringsErr[INFO_MARKKEYb] = "Found a site for a derrick";
+ stringsErr[INFO_MARKKEYc] = "Found a site for a derrick";
+ stringsErr[INFO_MARKKEYd] = "Found a site for a derrick";
+ stringsErr[INFO_WIN] = "<<< Well done; mission accomplished >>>";
+ stringsErr[INFO_LOST] = "<<< Sorry; mission failed >>>";
+ stringsErr[INFO_LOSTq] = "<<< Sorry; mission failed >>>";
+ stringsErr[INFO_WRITEOK] = "Current mission saved";
+ stringsErr[INFO_DELETEPATH] = "Checkpoint crossed";
+ stringsErr[INFO_DELETEMOTHER] = "Alien Queen killed";
+ stringsErr[INFO_DELETEANT] = "Ant fatally wounded";
+ stringsErr[INFO_DELETEBEE] = "Wasp fatally wounded";
+ stringsErr[INFO_DELETEWORM] = "Worm fatally wounded";
+ stringsErr[INFO_DELETESPIDER] = "Spider fatally wounded";
+ stringsErr[INFO_BEGINSATCOM] = "Press \\key help; to read instructions on your SatCom";
+
+
+
+ stringsCbot[TX_OPENPAR] = "Opening bracket missing";
+ stringsCbot[TX_CLOSEPAR] = "Closing bracket missing ";
+ stringsCbot[TX_NOTBOOL] = "The expression must return a boolean value";
+ stringsCbot[TX_UNDEFVAR] = "Variable not declared";
+ stringsCbot[TX_BADLEFT] = "Assignment impossible";
+ stringsCbot[TX_ENDOF] = "Semicolon terminator missing";
+ stringsCbot[TX_OUTCASE] = "Instruction \"case\" outside a block \"switch\"";
+ stringsCbot[TX_NOTERM] = "Instructions after the final closing brace";
+ stringsCbot[TX_CLOSEBLK] = "End of block missing";
+ stringsCbot[TX_ELSEWITHOUTIF] = "Instruction \"else\" without corresponding \"if\" ";
+ stringsCbot[TX_OPENBLK] = "Opening brace missing ";
+ stringsCbot[TX_BADTYPE] = "Wrong type for the assignment";
+ stringsCbot[TX_REDEFVAR] = "A variable can not be declared twice";
+ stringsCbot[TX_BAD2TYPE] = "The types of the two operands are incompatible ";
+ stringsCbot[TX_UNDEFCALL] = "Unknown function";
+ stringsCbot[TX_MISDOTS] = "Sign \" : \" missing";
+ stringsCbot[TX_WHILE] = "Keyword \"while\" missing";
+ stringsCbot[TX_BREAK] = "Instruction \"break\" outside a loop";
+ stringsCbot[TX_LABEL] = "A label must be followed by \"for\"; \"while\"; \"do\" or \"switch\"";
+ stringsCbot[TX_NOLABEL] = "This label does not exist";
+ stringsCbot[TX_NOCASE] = "Instruction \"case\" missing";
+ stringsCbot[TX_BADNUM] = "Number missing";
+ stringsCbot[TX_VOID] = "Void parameter";
+ stringsCbot[TX_NOTYP] = "Type declaration missing";
+ stringsCbot[TX_NOVAR] = "Variable name missing";
+ stringsCbot[TX_NOFONC] = "Function name missing";
+ stringsCbot[TX_OVERPARAM] = "Too many parameters";
+ stringsCbot[TX_REDEF] = "Function already exists";
+ stringsCbot[TX_LOWPARAM] = "Parameters missing ";
+ stringsCbot[TX_BADPARAM] = "No function with this name accepts this kind of parameter";
+ stringsCbot[TX_NUMPARAM] = "No function with this name accepts this number of parameters";
+ stringsCbot[TX_NOITEM] = "This is not a member of this class";
+ stringsCbot[TX_DOT] = "This object is not a member of a class";
+ stringsCbot[TX_NOCONST] = "Appropriate constructor missing";
+ stringsCbot[TX_REDEFCLASS] = "This class already exists";
+ stringsCbot[TX_CLBRK] = "\" ] \" missing";
+ stringsCbot[TX_RESERVED] = "Reserved keyword of CBOT language";
+ stringsCbot[TX_BADNEW] = "Bad argument for \"new\"";
+ stringsCbot[TX_OPBRK] = "\" [ \" expected";
+ stringsCbot[TX_BADSTRING] = "String missing";
+ stringsCbot[TX_BADINDEX] = "Incorrect index type";
+ stringsCbot[TX_PRIVATE] = "Private element";
+ stringsCbot[TX_NOPUBLIC] = "Public required";
+ stringsCbot[TX_DIVZERO] = "Dividing by zero";
+ stringsCbot[TX_NOTINIT] = "Variable not initialized";
+ stringsCbot[TX_BADTHROW] = "Negative value rejected by \"throw\"";
+ stringsCbot[TX_NORETVAL] = "The function returned no value ";
+ stringsCbot[TX_NORUN] = "No function running";
+ stringsCbot[TX_NOCALL] = "Calling an unknown function";
+ stringsCbot[TX_NOCLASS] = "This class does not exist";
+ stringsCbot[TX_NULLPT] = "Unknown Object";
+ stringsCbot[TX_OPNAN] = "Operation impossible with value \"nan\"";
+ stringsCbot[TX_OUTARRAY] = "Access beyond array limit";
+ stringsCbot[TX_STACKOVER] = "Stack overflow";
+ stringsCbot[TX_DELETEDPT] = "Illegal object";
+ stringsCbot[TX_FILEOPEN] = "Can't open file";
+ stringsCbot[TX_NOTOPEN] = "File not open";
+ stringsCbot[TX_ERRREAD] = "Read error";
+ stringsCbot[TX_ERRWRITE] = "Write error";
+}
+
+
static char g_gamerName[100];
@@ -36,7 +731,6 @@ void SetGlobalGamerName(char *name)
}
-
struct KeyDesc
{
InputSlot key;
@@ -105,7 +799,7 @@ static void PutKeyName(char* dst, const char* src)
{
if ( SearchKey(src+s+5, key) )
{
- res = CRobotMain::GetInstancePointer()->GetInputBinding(key).key;
+ res = CRobotMain::GetInstancePointer()->GetInputBinding(key).primary;
if (res != KEY_INVALID)
{
if ( GetResource(RES_KEY, res, name) )
@@ -138,41 +832,42 @@ static const char* GetResourceBase(ResType type, int num)
switch (type)
{
case RES_TEXT:
- assert(num < strings_text_len);
- str = strings_text[num];
+ assert(num < RT_MAX);
+ str = stringsText[num];
break;
- case RES_EVENT:
- // assert(num < strings_event_len);
- if (num >= strings_event_len)
+ case RES_EVENT:
+ if (num >= EVENT_STD_MAX)
{
GetLogger()->Trace("GetResource event num out of range: %d\n", num); // TODO: fix later
return "";
}
- str = strings_event[num];
+ str = stringsEvent[num];
break;
case RES_OBJECT:
- assert(num < strings_object_len);
+ assert(num < OBJECT_MAX);
if (num == OBJECT_HUMAN)
return g_gamerName;
- str = strings_object[num];
+ str = stringsObject[num];
break;
case RES_ERR:
- assert(num < strings_err_len);
- str = strings_err[num];
+ assert(num < ERR_MAX);
+ str = stringsErr[num];
break;
case RES_CBOT:
- assert(num < strings_cbot_len);
- str = strings_cbot[num];
+ assert(num < TX_MAX);
+ str = stringsCbot[num];
break;
case RES_KEY:
- if (num == VIRTUAL_KMOD_CTRL)
+ if (static_cast<unsigned int>(num) == KEY_INVALID)
+ return "";
+ else if (num == VIRTUAL_KMOD_CTRL)
return "Ctrl";
else if (num == VIRTUAL_KMOD_SHIFT)
return "Shift";
@@ -185,7 +880,7 @@ static const char* GetResourceBase(ResType type, int num)
// TODO: temporary fix
static std::string sstr;
sstr = gettext("Button %1");
- StrUtils::Replace(sstr, "%1", StrUtils::ToString<int>(1 + num - VIRTUAL_JOY(0)));
+ sstr = StrUtils::Replace(sstr, "%1", StrUtils::ToString<int>(1 + num - VIRTUAL_JOY(0)));
return sstr.c_str();
}
else
diff --git a/src/common/restext.h b/src/common/restext.h
index 6abb7f5..8199f9f 100644
--- a/src/common/restext.h
+++ b/src/common/restext.h
@@ -21,8 +21,8 @@
#pragma once
+
#include "common/global.h"
-#include "common/restext_ids.h"
/**
@@ -39,21 +39,120 @@ enum ResType
RES_CBOT = 5, //! < TX_* (CBot)
};
+/**
+ * \enum ResTextType
+ * \brief Text resources available for translation
+ */
+enum ResTextType
+{
+ RT_VERSION_ID = 1,
+ RT_DISINFO_TITLE = 2,
+ RT_WINDOW_MAXIMIZED = 3,
+ RT_WINDOW_MINIMIZED = 4,
+ RT_WINDOW_STANDARD = 5,
+ RT_WINDOW_CLOSE = 6,
+
+ RT_STUDIO_TITLE = 10,
+ RT_SCRIPT_NEW = 20,
+ RT_NAME_DEFAULT = 21,
+ RT_IO_NEW = 22,
+ RT_KEY_OR = 23,
+
+ RT_TITLE_BASE = 40,
+ RT_TITLE_INIT = 41,
+ RT_TITLE_TRAINER = 42,
+ RT_TITLE_DEFI = 43,
+ RT_TITLE_MISSION = 44,
+ RT_TITLE_FREE = 45,
+ RT_TITLE_PROTO = 46,
+ RT_TITLE_SETUP = 47,
+ RT_TITLE_NAME = 48,
+ RT_TITLE_PERSO = 49,
+ RT_TITLE_WRITE = 50,
+ RT_TITLE_READ = 51,
+ RT_TITLE_USER = 52,
+ RT_TITLE_TEEN = 53,
+
+ RT_PLAY_CHAPt = 60,
+ RT_PLAY_CHAPd = 61,
+ RT_PLAY_CHAPm = 62,
+ RT_PLAY_CHAPf = 63,
+ RT_PLAY_CHAPp = 64,
+ RT_PLAY_LISTt = 65,
+ RT_PLAY_LISTd = 66,
+ RT_PLAY_LISTm = 67,
+ RT_PLAY_LISTf = 68,
+ RT_PLAY_LISTp = 69,
+ RT_PLAY_RESUME = 70,
+ RT_PLAY_CHAPu = 71,
+ RT_PLAY_LISTu = 72,
+ RT_PLAY_CHAPte = 73,
+ RT_PLAY_LISTk = 74,
+
+ RT_SETUP_DEVICE = 80,
+ RT_SETUP_MODE = 81,
+ RT_SETUP_KEY1 = 82,
+ RT_SETUP_KEY2 = 83,
+
+ RT_PERSO_FACE = 90,
+ RT_PERSO_GLASSES = 91,
+ RT_PERSO_HAIR = 92,
+ RT_PERSO_COMBI = 93,
+ RT_PERSO_BAND = 94,
+
+ RT_DIALOG_TITLE = 100,
+ RT_DIALOG_ABORT = 101,
+ RT_DIALOG_QUIT = 102,
+ RT_DIALOG_YES = 103,
+ RT_DIALOG_NO = 104,
+ RT_DIALOG_DELOBJ = 105,
+ RT_DIALOG_DELGAME = 106,
+ RT_DIALOG_YESDEL = 107,
+ RT_DIALOG_NODEL = 108,
+ RT_DIALOG_LOADING = 109,
+ RT_DIALOG_YESQUIT = 110,
+ RT_DIALOG_NOQUIT = 111,
+
+ RT_STUDIO_LISTTT = 120,
+ RT_STUDIO_COMPOK = 121,
+ RT_STUDIO_PROGSTOP = 122,
+
+ RT_SATCOM_LIST = 140,
+ RT_SATCOM_BOT = 141,
+ RT_SATCOM_BUILDING = 142,
+ RT_SATCOM_FRET = 143,
+ RT_SATCOM_ALIEN = 144,
+ RT_SATCOM_NULL = 145,
+ RT_SATCOM_ERROR1 = 146,
+ RT_SATCOM_ERROR2 = 147,
+
+ RT_IO_OPEN = 150,
+ RT_IO_SAVE = 151,
+ RT_IO_LIST = 152,
+ RT_IO_NAME = 153,
+ RT_IO_DIR = 154,
+ RT_IO_PRIVATE = 155,
+ RT_IO_PUBLIC = 156,
+
+ RT_GENERIC_DEV1 = 170,
+ RT_GENERIC_DEV2 = 171,
+ RT_GENERIC_EDIT1 = 172,
+ RT_GENERIC_EDIT2 = 173,
+
+ RT_INTERFACE_REC = 180,
+
+ RT_MESSAGE_WIN = 200,
+ RT_MESSAGE_LOST = 201,
+
+
+ RT_MAX //! < number of values
+};
+
// TODO: move to CRobotMain
-extern void SetGlobalGamerName(char *name);
-extern bool SearchKey(const char *cmd, InputSlot& slot);
-extern bool GetResource(ResType type, int num, char* text);
-
-extern const char * const strings_text[];
-extern const char * const strings_event[];
-extern const char * const strings_object[];
-extern const char * const strings_err[];
-extern const char * const strings_cbot[];
-
-extern const int strings_text_len;
-extern const int strings_event_len;
-extern const int strings_object_len;
-extern const int strings_err_len;
-extern const int strings_cbot_len;
+void InitializeRestext();
+
+void SetGlobalGamerName(char *name);
+bool SearchKey(const char *cmd, InputSlot& slot);
+bool GetResource(ResType type, int num, char* text);
diff --git a/src/common/restext_ids.h b/src/common/restext_ids.h
deleted file mode 100644
index 4223a1c..0000000
--- a/src/common/restext_ids.h
+++ /dev/null
@@ -1,122 +0,0 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
-
-
-// TODO: move to restext.h after restext rewrite
-
-#pragma once
-
-enum ResTextType
-{
- RT_VERSION_ID = 1,
- RT_DISINFO_TITLE = 2,
- RT_WINDOW_MAXIMIZED = 3,
- RT_WINDOW_MINIMIZED = 4,
- RT_WINDOW_STANDARD = 5,
- RT_WINDOW_CLOSE = 6,
-
- RT_STUDIO_TITLE = 10,
- RT_SCRIPT_NEW = 20,
- RT_NAME_DEFAULT = 21,
- RT_IO_NEW = 22,
- RT_KEY_OR = 23,
-
- RT_TITLE_BASE = 40,
- RT_TITLE_INIT = 41,
- RT_TITLE_TRAINER = 42,
- RT_TITLE_DEFI = 43,
- RT_TITLE_MISSION = 44,
- RT_TITLE_FREE = 45,
- RT_TITLE_PROTO = 46,
- RT_TITLE_SETUP = 47,
- RT_TITLE_NAME = 48,
- RT_TITLE_PERSO = 49,
- RT_TITLE_WRITE = 50,
- RT_TITLE_READ = 51,
- RT_TITLE_USER = 52,
- RT_TITLE_TEEN = 53,
-
- RT_PLAY_CHAPt = 60,
- RT_PLAY_CHAPd = 61,
- RT_PLAY_CHAPm = 62,
- RT_PLAY_CHAPf = 63,
- RT_PLAY_CHAPp = 64,
- RT_PLAY_LISTt = 65,
- RT_PLAY_LISTd = 66,
- RT_PLAY_LISTm = 67,
- RT_PLAY_LISTf = 68,
- RT_PLAY_LISTp = 69,
- RT_PLAY_RESUME = 70,
- RT_PLAY_CHAPu = 71,
- RT_PLAY_LISTu = 72,
- RT_PLAY_CHAPte = 73,
- RT_PLAY_LISTk = 74,
-
- RT_SETUP_DEVICE = 80,
- RT_SETUP_MODE = 81,
- RT_SETUP_KEY1 = 82,
- RT_SETUP_KEY2 = 83,
-
- RT_PERSO_FACE = 90,
- RT_PERSO_GLASSES = 91,
- RT_PERSO_HAIR = 92,
- RT_PERSO_COMBI = 93,
- RT_PERSO_BAND = 94,
-
- RT_DIALOG_TITLE = 100,
- RT_DIALOG_ABORT = 101,
- RT_DIALOG_QUIT = 102,
- RT_DIALOG_YES = 103,
- RT_DIALOG_NO = 104,
- RT_DIALOG_DELOBJ = 105,
- RT_DIALOG_DELGAME = 106,
- RT_DIALOG_YESDEL = 107,
- RT_DIALOG_NODEL = 108,
- RT_DIALOG_LOADING = 109,
- RT_DIALOG_YESQUIT = 110,
- RT_DIALOG_NOQUIT = 111,
-
- RT_STUDIO_LISTTT = 120,
- RT_STUDIO_COMPOK = 121,
- RT_STUDIO_PROGSTOP = 122,
-
- RT_SATCOM_LIST = 140,
- RT_SATCOM_BOT = 141,
- RT_SATCOM_BUILDING = 142,
- RT_SATCOM_FRET = 143,
- RT_SATCOM_ALIEN = 144,
- RT_SATCOM_NULL = 145,
- RT_SATCOM_ERROR1 = 146,
- RT_SATCOM_ERROR2 = 147,
-
- RT_IO_OPEN = 150,
- RT_IO_SAVE = 151,
- RT_IO_LIST = 152,
- RT_IO_NAME = 153,
- RT_IO_DIR = 154,
- RT_IO_PRIVATE = 155,
- RT_IO_PUBLIC = 156,
-
- RT_GENERIC_DEV1 = 170,
- RT_GENERIC_DEV2 = 171,
- RT_GENERIC_EDIT1 = 172,
- RT_GENERIC_EDIT2 = 173,
-
- RT_INTERFACE_REC = 180,
-
- RT_MESSAGE_WIN = 200,
- RT_MESSAGE_LOST = 201,
-};
diff --git a/src/common/restext_strings.c b/src/common/restext_strings.c
deleted file mode 100644
index d041a28..0000000
--- a/src/common/restext_strings.c
+++ /dev/null
@@ -1,717 +0,0 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
-
-#include "common/restext_ids.h"
-#include "common/event_ids.h"
-#include "object/object_ids.h"
-#include "common/error_ids.h"
-#include "CBot/resource.h"
-
-const char * const strings_text[] =
-{
- [RT_VERSION_ID] = "Colobot Gold",
-
- [RT_DISINFO_TITLE] = "SatCom",
- [RT_WINDOW_MAXIMIZED] = "Maximize",
- [RT_WINDOW_MINIMIZED] = "Minimize",
- [RT_WINDOW_STANDARD] = "Normal size",
- [RT_WINDOW_CLOSE] = "Close",
-
- [RT_STUDIO_TITLE] = "Program editor",
- [RT_SCRIPT_NEW] = "New",
- [RT_NAME_DEFAULT] = "Player",
- [RT_IO_NEW] = "New ...",
- [RT_KEY_OR] = " or ",
-
- [RT_TITLE_BASE] = "COLOBOT",
- [RT_TITLE_INIT] = "COLOBOT",
- [RT_TITLE_TRAINER] = "Programming exercises",
- [RT_TITLE_DEFI] = "Challenges",
- [RT_TITLE_MISSION] = "Missions",
- [RT_TITLE_FREE] = "Free game",
- [RT_TITLE_TEEN] = "Free game",
- [RT_TITLE_USER] = "User levels",
- [RT_TITLE_PROTO] = "Prototypes",
- [RT_TITLE_SETUP] = "Options",
- [RT_TITLE_NAME] = "Player's name",
- [RT_TITLE_PERSO] = "Customize your appearance",
- [RT_TITLE_WRITE] = "Save the current mission",
- [RT_TITLE_READ] = "Load a saved mission",
-
- [RT_PLAY_CHAPt] = " Chapters:",
- [RT_PLAY_CHAPd] = " Chapters:",
- [RT_PLAY_CHAPm] = " Planets:",
- [RT_PLAY_CHAPf] = " Planets:",
- [RT_PLAY_CHAPu] = " User levels:",
- [RT_PLAY_CHAPp] = " Planets:",
- [RT_PLAY_CHAPte] = " Chapters:",
- [RT_PLAY_LISTt] = " Exercises in the chapter:",
- [RT_PLAY_LISTd] = " Challenges in the chapter:",
- [RT_PLAY_LISTm] = " Missions on this planet:",
- [RT_PLAY_LISTf] = " Free game on this planet:",
- [RT_PLAY_LISTu] = " Missions on this level:",
- [RT_PLAY_LISTp] = " Prototypes on this planet:",
- [RT_PLAY_LISTk] = " Free game on this chapter:",
- [RT_PLAY_RESUME] = " Summary:",
-
- [RT_SETUP_DEVICE] = " Drivers:",
- [RT_SETUP_MODE] = " Resolution:",
- [RT_SETUP_KEY1] = "1) First click on the key you want to redefine.",
- [RT_SETUP_KEY2] = "2) Then press the key you want to use instead.",
-
- [RT_PERSO_FACE] = "Face type:",
- [RT_PERSO_GLASSES] = "Eyeglasses:",
- [RT_PERSO_HAIR] = "Hair color:",
- [RT_PERSO_COMBI] = "Suit color:",
- [RT_PERSO_BAND] = "Strip color:",
-
- [RT_DIALOG_QUIT] = "Do you want to quit COLOBOT ?",
- [RT_DIALOG_TITLE] = "COLOBOT",
- [RT_DIALOG_YESQUIT] = "Quit\\Quit COLOBOT",
- [RT_DIALOG_ABORT] = "Quit the mission?",
- [RT_DIALOG_YES] = "Abort\\Abort the current mission",
- [RT_DIALOG_NO] = "Continue\\Continue the current mission",
- [RT_DIALOG_NOQUIT] = "Continue\\Continue the game",
- [RT_DIALOG_DELOBJ] = "Do you really want to destroy the selected building?",
- [RT_DIALOG_DELGAME] = "Do you want to delete %s's saved games? ",
- [RT_DIALOG_YESDEL] = "Delete",
- [RT_DIALOG_NODEL] = "Cancel",
- [RT_DIALOG_LOADING] = "LOADING",
-
- [RT_STUDIO_LISTTT] = "Keyword help(\\key cbot;)",
- [RT_STUDIO_COMPOK] = "Compilation ok (0 errors)",
- [RT_STUDIO_PROGSTOP] = "Program finished",
-
- [RT_SATCOM_LIST] = "\\b;List of objects\n",
- [RT_SATCOM_BOT] = "\\b;Robots\n",
- [RT_SATCOM_BUILDING] = "\\b;Buildings\n",
- [RT_SATCOM_FRET] = "\\b;Moveable objects\n",
- [RT_SATCOM_ALIEN] = "\\b;Aliens\n",
- [RT_SATCOM_NULL] = "\\c; (none)\\n;\n",
- [RT_SATCOM_ERROR1] = "\\b;Error\n",
- [RT_SATCOM_ERROR2] = "The list is only available if a \\l;radar station\\u object\\radar; is working.\n",
-
- [RT_IO_OPEN] = "Open",
- [RT_IO_SAVE] = "Save",
- [RT_IO_LIST] = "Folder: %s",
- [RT_IO_NAME] = "Name:",
- [RT_IO_DIR] = "Folder:",
- [RT_IO_PRIVATE] = "Private\\Private folder",
- [RT_IO_PUBLIC] = "Public\\Common folder",
-
- [RT_GENERIC_DEV1] = "Developed by :",
- [RT_GENERIC_DEV2] = "www.epsitec.com",
- [RT_GENERIC_EDIT1] = " ",
- [RT_GENERIC_EDIT2] = " ",
-
- [RT_INTERFACE_REC] = "Recorder"
-};
-
-const char * const strings_event[] =
-{
- [EVENT_BUTTON_OK] = "OK",
- [EVENT_BUTTON_CANCEL] = "Cancel",
- [EVENT_BUTTON_NEXT] = "Next",
- [EVENT_BUTTON_PREV] = "Previous",
- [EVENT_BUTTON_QUIT] = "Menu (\\key quit;)",
-
- [EVENT_DIALOG_OK] = "OK",
- [EVENT_DIALOG_CANCEL] = "Cancel",
-
- [EVENT_INTERFACE_TRAINER] = "Exercises\\Programming exercises",
- [EVENT_INTERFACE_DEFI] = "Challenges\\Programming challenges",
- [EVENT_INTERFACE_MISSION] = "Missions\\Select mission",
- [EVENT_INTERFACE_FREE] = "Free game\\Free game without a specific goal",
- [EVENT_INTERFACE_TEEN] = "Free game\\Free game without a specific goal",
- [EVENT_INTERFACE_USER] = "User\\User levels",
- [EVENT_INTERFACE_PROTO] = "Proto\\Prototypes under development",
- [EVENT_INTERFACE_NAME] = "New player\\Choose player's name",
- [EVENT_INTERFACE_SETUP] = "Options\\Preferences",
- [EVENT_INTERFACE_AGAIN] = "Restart\\Restart the mission from the beginning",
- [EVENT_INTERFACE_WRITE] = "Save\\Save the current mission ",
- [EVENT_INTERFACE_READ] = "Load\\Load a saved mission",
- [EVENT_INTERFACE_ABORT] = "\\Return to COLOBOT",
- [EVENT_INTERFACE_QUIT] = "Quit\\Quit COLOBOT",
- [EVENT_INTERFACE_BACK] = "<< Back \\Back to the previous screen",
- [EVENT_INTERFACE_PLAY] = "Play\\Start mission!",
- [EVENT_INTERFACE_SETUPd] = "Device\\Driver and resolution settings",
- [EVENT_INTERFACE_SETUPg] = "Graphics\\Graphics settings",
- [EVENT_INTERFACE_SETUPp] = "Game\\Game settings",
- [EVENT_INTERFACE_SETUPc] = "Controls\\Keyboard, joystick and mouse settings",
- [EVENT_INTERFACE_SETUPs] = "Sound\\Music and game sound volume",
- [EVENT_INTERFACE_DEVICE] = "Unit",
- [EVENT_INTERFACE_RESOL] = "Resolution",
- [EVENT_INTERFACE_FULL] = "Full screen\\Full screen or window mode",
- [EVENT_INTERFACE_APPLY] = "Apply changes\\Activates the changed settings",
-
- [EVENT_INTERFACE_TOTO] = "Robbie\\Your assistant",
- [EVENT_INTERFACE_SHADOW] = "Shadows\\Shadows on the ground",
- [EVENT_INTERFACE_GROUND] = "Marks on the ground\\Marks on the ground",
- [EVENT_INTERFACE_DIRTY] = "Dust\\Dust and dirt on bots and buildings",
- [EVENT_INTERFACE_FOG] = "Fog\\Fog",
- [EVENT_INTERFACE_LENS] = "Sunbeams\\Sunbeams in the sky",
- [EVENT_INTERFACE_SKY] = "Sky\\Clouds and nebulae",
- [EVENT_INTERFACE_PLANET] = "Planets and stars\\Astronomical objects in the sky",
- [EVENT_INTERFACE_LIGHT] = "Dynamic lighting\\Mobile light sources",
- [EVENT_INTERFACE_PARTI] = "Number of particles\\Explosions, dust, reflections, etc.",
- [EVENT_INTERFACE_CLIP] = "Depth of field\\Maximum visibility",
- [EVENT_INTERFACE_DETAIL] = "Details\\Visual quality of 3D objects",
- [EVENT_INTERFACE_TEXTURE] = "Textures\\Quality of textures ",
- [EVENT_INTERFACE_GADGET] = "Num of decorative objects\\Number of purely ornamental objects",
- [EVENT_INTERFACE_RAIN] = "Particles in the interface\\Steam clouds and sparks in the interface",
- [EVENT_INTERFACE_GLINT] = "Reflections on the buttons \\Shiny buttons",
- [EVENT_INTERFACE_TOOLTIP] = "Help balloons\\Explain the function of the buttons",
- [EVENT_INTERFACE_MOVIES] = "Film sequences\\Films before and after the missions",
- [EVENT_INTERFACE_NICERST] = "Exit film\\Film at the exit of exercises",
- [EVENT_INTERFACE_HIMSELF] = "Friendly fire\\Your shooting can damage your own objects ",
- [EVENT_INTERFACE_SCROLL] = "Scrolling\\Scrolling when the mouse touches right or left border",
- [EVENT_INTERFACE_INVERTX] = "Mouse inversion X\\Inversion of the scrolling direction on the X axis",
- [EVENT_INTERFACE_INVERTY] = "Mouse inversion Y\\Inversion of the scrolling direction on the Y axis",
- [EVENT_INTERFACE_EFFECT] = "Quake at explosions\\The screen shakes at explosions",
- [EVENT_INTERFACE_MOUSE] = "Mouse shadow\\Gives the mouse a shadow",
- [EVENT_INTERFACE_EDITMODE] = "Automatic indent\\When program editing",
- [EVENT_INTERFACE_EDITVALUE] = "Big indent\\Indent 2 or 4 spaces per level defined by braces",
- [EVENT_INTERFACE_SOLUCE4] = "Access to solutions\\Show program \"4: Solution\" in the exercises",
-
- [EVENT_INTERFACE_KDEF] = "Standard controls\\Standard key functions",
- [EVENT_INTERFACE_KLEFT] = "Turn left\\turns the bot to the left",
- [EVENT_INTERFACE_KRIGHT] = "Turn right\\turns the bot to the right",
- [EVENT_INTERFACE_KUP] = "Forward\\Moves forward",
- [EVENT_INTERFACE_KDOWN] = "Backward\\Moves backward",
- [EVENT_INTERFACE_KGUP] = "Climb\\Increases the power of the jet",
- [EVENT_INTERFACE_KGDOWN] = "Descend\\Reduces the power of the jet",
- [EVENT_INTERFACE_KCAMERA] = "Change camera\\Switches between onboard camera and following camera",
- [EVENT_INTERFACE_KDESEL] = "Previous object\\Selects the previous object",
- [EVENT_INTERFACE_KACTION] = "Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)",
- [EVENT_INTERFACE_KNEAR] = "Camera closer\\Moves the camera forward",
- [EVENT_INTERFACE_KAWAY] = "Camera back\\Moves the camera backward",
- [EVENT_INTERFACE_KNEXT] = "Next object\\Selects the next object",
- [EVENT_INTERFACE_KHUMAN] = "Select the astronaut\\Selects the astronaut",
- [EVENT_INTERFACE_KQUIT] = "Quit\\Quit the current mission or exercise",
- [EVENT_INTERFACE_KHELP] = "Instructions\\Shows the instructions for the current mission",
- [EVENT_INTERFACE_KPROG] = "Programming help\\Gives more detailed help with programming",
- [EVENT_INTERFACE_KCBOT] = "Key word help\\More detailed help about key words",
- [EVENT_INTERFACE_KVISIT] = "Origin of last message\\Shows where the last message was sent from",
- [EVENT_INTERFACE_KSPEED10] = "Speed 1.0x\\Normal speed",
- [EVENT_INTERFACE_KSPEED15] = "Speed 1.5x\\1.5 times faster",
- [EVENT_INTERFACE_KSPEED20] = "Speed 2.0x\\Double speed",
- [EVENT_INTERFACE_KSPEED30] = "Speed 3.0x\\Three times faster",
-
- [EVENT_INTERFACE_VOLSOUND] = "Sound effects:\\Volume of engines, voice, shooting, etc.",
- [EVENT_INTERFACE_VOLMUSIC] = "Background sound :\\Volume of audio tracks on the CD",
- [EVENT_INTERFACE_SOUND3D] = "3D sound\\3D positioning of the sound",
-
- [EVENT_INTERFACE_MIN] = "Lowest\\Minimum graphic quality (highest frame rate)",
- [EVENT_INTERFACE_NORM] = "Normal\\Normal graphic quality",
- [EVENT_INTERFACE_MAX] = "Highest\\Highest graphic quality (lowest frame rate)",
-
- [EVENT_INTERFACE_SILENT] = "Mute\\No sound",
- [EVENT_INTERFACE_NOISY] = "Normal\\Normal sound volume",
-
- [EVENT_INTERFACE_JOYSTICK] = "Use a joystick\\Joystick or keyboard",
- [EVENT_INTERFACE_SOLUCE] = "Access to solution\\Shows the solution (detailed instructions for missions)",
-
- [EVENT_INTERFACE_NEDIT] = "\\New player name",
- [EVENT_INTERFACE_NOK] = "OK\\Choose the selected player",
- [EVENT_INTERFACE_NCANCEL] = "Cancel\\Keep current player name",
- [EVENT_INTERFACE_NDELETE] = "Delete player\\Deletes the player from the list",
- [EVENT_INTERFACE_NLABEL] = "Player name",
-
- [EVENT_INTERFACE_IOWRITE] = "Save\\Saves the current mission",
- [EVENT_INTERFACE_IOREAD] = "Load\\Loads the selected mission",
- [EVENT_INTERFACE_IOLIST] = "List of saved missions",
- [EVENT_INTERFACE_IOLABEL] = "Filename:",
- [EVENT_INTERFACE_IONAME] = "Mission name",
- [EVENT_INTERFACE_IOIMAGE] = "Photography",
- [EVENT_INTERFACE_IODELETE] = "Delete\\Deletes the selected file",
-
- [EVENT_INTERFACE_PERSO] = "Appearance\\Choose your appearance",
- [EVENT_INTERFACE_POK] = "OK",
- [EVENT_INTERFACE_PCANCEL] = "Cancel",
- [EVENT_INTERFACE_PDEF] = "Standard\\Standard appearance settings",
- [EVENT_INTERFACE_PHEAD] = "Head\\Face and hair",
- [EVENT_INTERFACE_PBODY] = "Suit\\Astronaut suit",
- [EVENT_INTERFACE_PLROT] = "\\Turn left",
- [EVENT_INTERFACE_PRROT] = "\\Turn right",
- [EVENT_INTERFACE_PCRa] = "Red",
- [EVENT_INTERFACE_PCGa] = "Green",
- [EVENT_INTERFACE_PCBa] = "Blue",
- [EVENT_INTERFACE_PCRb] = "Red",
- [EVENT_INTERFACE_PCGb] = "Green",
- [EVENT_INTERFACE_PCBb] = "Blue",
- [EVENT_INTERFACE_PFACE1] = "\\Face 1",
- [EVENT_INTERFACE_PFACE2] = "\\Face 4",
- [EVENT_INTERFACE_PFACE3] = "\\Face 3",
- [EVENT_INTERFACE_PFACE4] = "\\Face 2",
- [EVENT_INTERFACE_PGLASS0] = "\\No eyeglasses",
- [EVENT_INTERFACE_PGLASS1] = "\\Eyeglasses 1",
- [EVENT_INTERFACE_PGLASS2] = "\\Eyeglasses 2",
- [EVENT_INTERFACE_PGLASS3] = "\\Eyeglasses 3",
- [EVENT_INTERFACE_PGLASS4] = "\\Eyeglasses 4",
- [EVENT_INTERFACE_PGLASS5] = "\\Eyeglasses 5",
-
- [EVENT_OBJECT_DESELECT] = "Previous selection (\\key desel;)",
- [EVENT_OBJECT_LEFT] = "Turn left (\\key left;)",
- [EVENT_OBJECT_RIGHT] = "Turn right (\\key right;)",
- [EVENT_OBJECT_UP] = "Forward (\\key up;)",
- [EVENT_OBJECT_DOWN] = "Backward (\\key down;)",
- [EVENT_OBJECT_GASUP] = "Up (\\key gup;)",
- [EVENT_OBJECT_GASDOWN] = "Down (\\key gdown;)",
- [EVENT_OBJECT_HTAKE] = "Grab or drop (\\key action;)",
- [EVENT_OBJECT_MTAKE] = "Grab or drop (\\key action;)",
- [EVENT_OBJECT_MFRONT] = "..in front",
- [EVENT_OBJECT_MBACK] = "..behind",
- [EVENT_OBJECT_MPOWER] = "..power cell",
- [EVENT_OBJECT_BHELP] = "Instructions for the mission (\\key help;)",
- [EVENT_OBJECT_BTAKEOFF] = "Take off to finish the mission",
- [EVENT_OBJECT_BDERRICK] = "Build a derrick",
- [EVENT_OBJECT_BSTATION] = "Build a power station",
- [EVENT_OBJECT_BFACTORY] = "Build a bot factory",
- [EVENT_OBJECT_BREPAIR] = "Build a repair center",
- [EVENT_OBJECT_BCONVERT] = "Build a converter",
- [EVENT_OBJECT_BTOWER] = "Build a defense tower",
- [EVENT_OBJECT_BRESEARCH] = "Build a research center",
- [EVENT_OBJECT_BRADAR] = "Build a radar station",
- [EVENT_OBJECT_BENERGY] = "Build a power cell factory",
- [EVENT_OBJECT_BLABO] = "Build an autolab",
- [EVENT_OBJECT_BNUCLEAR] = "Build a nuclear power plant",
- [EVENT_OBJECT_BPARA] = "Build a lightning conductor",
- [EVENT_OBJECT_BINFO] = "Build a exchange post",
- [EVENT_OBJECT_GFLAT] = "Show if the ground is flat",
- [EVENT_OBJECT_FCREATE] = "Plant a flag",
- [EVENT_OBJECT_FDELETE] = "Remove a flag",
- [EVENT_OBJECT_FCOLORb] = "\\Blue flags",
- [EVENT_OBJECT_FCOLORr] = "\\Red flags",
- [EVENT_OBJECT_FCOLORg] = "\\Green flags",
- [EVENT_OBJECT_FCOLORy] = "\\Yellow flags",
- [EVENT_OBJECT_FCOLORv] = "\\Violet flags",
- [EVENT_OBJECT_FACTORYfa] = "Build a winged grabber",
- [EVENT_OBJECT_FACTORYta] = "Build a tracked grabber",
- [EVENT_OBJECT_FACTORYwa] = "Build a wheeled grabber",
- [EVENT_OBJECT_FACTORYia] = "Build a legged grabber",
- [EVENT_OBJECT_FACTORYfc] = "Build a winged shooter",
- [EVENT_OBJECT_FACTORYtc] = "Build a tracked shooter",
- [EVENT_OBJECT_FACTORYwc] = "Build a wheeled shooter",
- [EVENT_OBJECT_FACTORYic] = "Build a legged shooter",
- [EVENT_OBJECT_FACTORYfi] = "Build a winged orga shooter",
- [EVENT_OBJECT_FACTORYti] = "Build a tracked orga shooter",
- [EVENT_OBJECT_FACTORYwi] = "Build a wheeled orga shooter",
- [EVENT_OBJECT_FACTORYii] = "Build a legged orga shooter",
- [EVENT_OBJECT_FACTORYfs] = "Build a winged sniffer",
- [EVENT_OBJECT_FACTORYts] = "Build a tracked sniffer",
- [EVENT_OBJECT_FACTORYws] = "Build a wheeled sniffer",
- [EVENT_OBJECT_FACTORYis] = "Build a legged sniffer",
- [EVENT_OBJECT_FACTORYrt] = "Build a thumper",
- [EVENT_OBJECT_FACTORYrc] = "Build a phazer shooter",
- [EVENT_OBJECT_FACTORYrr] = "Build a recycler",
- [EVENT_OBJECT_FACTORYrs] = "Build a shielder",
- [EVENT_OBJECT_FACTORYsa] = "Build a subber",
- [EVENT_OBJECT_RTANK] = "Run research program for tracked bots",
- [EVENT_OBJECT_RFLY] = "Run research program for winged bots",
- [EVENT_OBJECT_RTHUMP] = "Run research program for thumper",
- [EVENT_OBJECT_RCANON] = "Run research program for shooter",
- [EVENT_OBJECT_RTOWER] = "Run research program for defense tower",
- [EVENT_OBJECT_RPHAZER] = "Run research program for phazer shooter",
- [EVENT_OBJECT_RSHIELD] = "Run research program for shielder",
- [EVENT_OBJECT_RATOMIC] = "Run research program for nuclear power",
- [EVENT_OBJECT_RiPAW] = "Run research program for legged bots",
- [EVENT_OBJECT_RiGUN] = "Run research program for orga shooter",
- [EVENT_OBJECT_RESET] = "Return to start",
- [EVENT_OBJECT_SEARCH] = "Sniff (\\key action;)",
- [EVENT_OBJECT_TERRAFORM] = "Thump (\\key action;)",
- [EVENT_OBJECT_FIRE] = "Shoot (\\key action;)",
- [EVENT_OBJECT_RECOVER] = "Recycle (\\key action;)",
- [EVENT_OBJECT_BEGSHIELD] = "Extend shield (\\key action;)",
- [EVENT_OBJECT_ENDSHIELD] = "Withdraw shield (\\key action;)",
- [EVENT_OBJECT_DIMSHIELD] = "Shield radius",
- [EVENT_OBJECT_PROGRUN] = "Execute the selected program",
- [EVENT_OBJECT_PROGEDIT] = "Edit the selected program",
- [EVENT_OBJECT_INFOOK] = "\\SatCom on standby",
- [EVENT_OBJECT_DELETE] = "Destroy the building",
- [EVENT_OBJECT_GENERGY] = "Energy level",
- [EVENT_OBJECT_GSHIELD] = "Shield level",
- [EVENT_OBJECT_GRANGE] = "Jet temperature",
- [EVENT_OBJECT_GPROGRESS] = "Still working ...",
- [EVENT_OBJECT_GRADAR] = "Number of insects detected",
- [EVENT_OBJECT_GINFO] = "Transmitted information",
- [EVENT_OBJECT_COMPASS] = "Compass",
- [EVENT_OBJECT_MAPZOOM] = "Zoom mini-map",
- [EVENT_OBJECT_CAMERA] = "Camera (\\key camera;)",
- [EVENT_OBJECT_CAMERAleft] = "Camera to left",
- [EVENT_OBJECT_CAMERAright] = "Camera to right",
- [EVENT_OBJECT_CAMERAnear] = "Camera nearest",
- [EVENT_OBJECT_CAMERAaway] = "Camera awayest",
- [EVENT_OBJECT_HELP] = "Help about selected object",
- [EVENT_OBJECT_SOLUCE] = "Show the solution",
- [EVENT_OBJECT_SHORTCUT00] = "Switch bots <-> buildings",
- [EVENT_OBJECT_LIMIT] = "Show the range",
- [EVENT_OBJECT_PEN0] = "\\Raise the pencil",
- [EVENT_OBJECT_PEN1] = "\\Use the black pencil",
- [EVENT_OBJECT_PEN2] = "\\Use the yellow pencil",
- [EVENT_OBJECT_PEN3] = "\\Use the orange pencil",
- [EVENT_OBJECT_PEN4] = "\\Use the red pencil",
- [EVENT_OBJECT_PEN5] = "\\Use the purple pencil",
- [EVENT_OBJECT_PEN6] = "\\Use the blue pencil",
- [EVENT_OBJECT_PEN7] = "\\Use the green pencil",
- [EVENT_OBJECT_PEN8] = "\\Use the brown pencil",
- [EVENT_OBJECT_REC] = "\\Start recording",
- [EVENT_OBJECT_STOP] = "\\Stop recording",
- [EVENT_DT_VISIT0] = "Show the place",
- [EVENT_DT_VISIT1] = "Show the place",
- [EVENT_DT_VISIT2] = "Show the place",
- [EVENT_DT_VISIT3] = "Show the place",
- [EVENT_DT_VISIT4] = "Show the place",
- [EVENT_DT_END] = "Continue",
- [EVENT_CMD] = "Command line",
- [EVENT_SPEED] = "Game speed",
-
- [EVENT_HYPER_PREV] = "Back",
- [EVENT_HYPER_NEXT] = "Forward",
- [EVENT_HYPER_HOME] = "Home",
- [EVENT_HYPER_COPY] = "Copy",
- [EVENT_HYPER_SIZE1] = "Size 1",
- [EVENT_HYPER_SIZE2] = "Size 2",
- [EVENT_HYPER_SIZE3] = "Size 3",
- [EVENT_HYPER_SIZE4] = "Size 4",
- [EVENT_HYPER_SIZE5] = "Size 5",
- [EVENT_SATCOM_HUSTON] = "Instructions from Houston",
- [EVENT_SATCOM_SAT] = "Satellite report",
- [EVENT_SATCOM_LOADING] = "Programs dispatched by Houston",
- [EVENT_SATCOM_OBJECT] = "List of objects",
- [EVENT_SATCOM_PROG] = "Programming help",
- [EVENT_SATCOM_SOLUCE] = "Solution",
-
- [EVENT_STUDIO_OK] = "OK\\Close program editor and return to game",
- [EVENT_STUDIO_CANCEL] = "Cancel\\Cancel all changes",
- [EVENT_STUDIO_NEW] = "New",
- [EVENT_STUDIO_OPEN] = "Open (Ctrl+o)",
- [EVENT_STUDIO_SAVE] = "Save (Ctrl+s)",
- [EVENT_STUDIO_UNDO] = "Undo (Ctrl+z)",
- [EVENT_STUDIO_CUT] = "Cut (Ctrl+x)",
- [EVENT_STUDIO_COPY] = "Copy (Ctrl+c)",
- [EVENT_STUDIO_PASTE] = "Paste (Ctrl+v)",
- [EVENT_STUDIO_SIZE] = "Font size",
- [EVENT_STUDIO_TOOL] = "Instructions (\\key help;)",
- [EVENT_STUDIO_HELP] = "Programming help (\\key prog;)",
- [EVENT_STUDIO_COMPILE] = "Compile",
- [EVENT_STUDIO_RUN] = "Execute/stop",
- [EVENT_STUDIO_REALTIME] = "Pause/continue",
- [EVENT_STUDIO_STEP] = "One step"
-};
-
-const char * const strings_object[] =
-{
- [OBJECT_PORTICO] = "Gantry crane",
- [OBJECT_BASE] = "Spaceship",
- [OBJECT_DERRICK] = "Derrick",
- [OBJECT_FACTORY] = "Bot factory",
- [OBJECT_REPAIR] = "Repair center",
- [OBJECT_DESTROYER] = "Destroyer",
- [OBJECT_STATION] = "Power station",
- [OBJECT_CONVERT] = "Converts ore to titanium",
- [OBJECT_TOWER] = "Defense tower",
- [OBJECT_NEST] = "Nest",
- [OBJECT_RESEARCH] = "Research center",
- [OBJECT_RADAR] = "Radar station",
- [OBJECT_INFO] = "Information exchange post",
- [OBJECT_ENERGY] = "Power cell factory",
- [OBJECT_LABO] = "Autolab",
- [OBJECT_NUCLEAR] = "Nuclear power station",
- [OBJECT_PARA] = "Lightning conductor",
- [OBJECT_SAFE] = "Vault",
- [OBJECT_HUSTON] = "Houston Mission Control",
- [OBJECT_TARGET1] = "Target",
- [OBJECT_TARGET2] = "Target",
- [OBJECT_START] = "Start",
- [OBJECT_END] = "Finish",
- [OBJECT_STONE] = "Titanium ore",
- [OBJECT_URANIUM] = "Uranium ore",
- [OBJECT_BULLET] = "Organic matter",
- [OBJECT_METAL] = "Titanium",
- [OBJECT_POWER] = "Power cell",
- [OBJECT_ATOMIC] = "Nuclear power cell",
- [OBJECT_BBOX] = "Black box",
- [OBJECT_KEYa] = "Key A",
- [OBJECT_KEYb] = "Key B",
- [OBJECT_KEYc] = "Key C",
- [OBJECT_KEYd] = "Key D",
- [OBJECT_TNT] = "Explosive",
- [OBJECT_BOMB] = "Fixed mine",
- [OBJECT_BAG] = "Survival kit",
- [OBJECT_WAYPOINT] = "Checkpoint",
- [OBJECT_FLAGb] = "Blue flag",
- [OBJECT_FLAGr] = "Red flag",
- [OBJECT_FLAGg] = "Green flag",
- [OBJECT_FLAGy] = "Yellow flag",
- [OBJECT_FLAGv] = "Violet flag",
- [OBJECT_MARKPOWER] = "Energy deposit (site for power station)",
- [OBJECT_MARKURANIUM] = "Uranium deposit (site for derrick)",
- [OBJECT_MARKKEYa] = "Found key A (site for derrick)",
- [OBJECT_MARKKEYb] = "Found key B (site for derrick)",
- [OBJECT_MARKKEYc] = "Found key C (site for derrick)",
- [OBJECT_MARKKEYd] = "Found key D (site for derrick)",
- [OBJECT_MARKSTONE] = "Titanium deposit (site for derrick)",
- [OBJECT_MOBILEft] = "Practice bot",
- [OBJECT_MOBILEtt] = "Practice bot",
- [OBJECT_MOBILEwt] = "Practice bot",
- [OBJECT_MOBILEit] = "Practice bot",
- [OBJECT_MOBILEfa] = "Winged grabber",
- [OBJECT_MOBILEta] = "Tracked grabber",
- [OBJECT_MOBILEwa] = "Wheeled grabber",
- [OBJECT_MOBILEia] = "Legged grabber",
- [OBJECT_MOBILEfc] = "Winged shooter",
- [OBJECT_MOBILEtc] = "Tracked shooter",
- [OBJECT_MOBILEwc] = "Wheeled shooter",
- [OBJECT_MOBILEic] = "Legged shooter",
- [OBJECT_MOBILEfi] = "Winged orga shooter",
- [OBJECT_MOBILEti] = "Tracked orga shooter",
- [OBJECT_MOBILEwi] = "Wheeled orga shooter",
- [OBJECT_MOBILEii] = "Legged orga shooter",
- [OBJECT_MOBILEfs] = "Winged sniffer",
- [OBJECT_MOBILEts] = "Tracked sniffer",
- [OBJECT_MOBILEws] = "Wheeled sniffer",
- [OBJECT_MOBILEis] = "Legged sniffer",
- [OBJECT_MOBILErt] = "Thumper",
- [OBJECT_MOBILErc] = "Phazer shooter",
- [OBJECT_MOBILErr] = "Recycler",
- [OBJECT_MOBILErs] = "Shielder",
- [OBJECT_MOBILEsa] = "Subber",
- [OBJECT_MOBILEtg] = "Target bot",
- [OBJECT_MOBILEdr] = "Drawer bot",
- [OBJECT_TECH] = "Engineer",
- [OBJECT_TOTO] = "Robbie",
- [OBJECT_MOTHER] = "Alien Queen",
- [OBJECT_ANT] = "Ant",
- [OBJECT_SPIDER] = "Spider",
- [OBJECT_BEE] = "Wasp",
- [OBJECT_WORM] = "Worm",
- [OBJECT_EGG] = "Egg",
- [OBJECT_RUINmobilew1] = "Wreckage",
- [OBJECT_RUINmobilew2] = "Wreckage",
- [OBJECT_RUINmobilet1] = "Wreckage",
- [OBJECT_RUINmobilet2] = "Wreckage",
- [OBJECT_RUINmobiler1] = "Wreckage",
- [OBJECT_RUINmobiler2] = "Wreckage",
- [OBJECT_RUINfactory] = "Ruin",
- [OBJECT_RUINdoor] = "Ruin",
- [OBJECT_RUINsupport] = "Waste",
- [OBJECT_RUINradar] = "Ruin",
- [OBJECT_RUINconvert] = "Ruin",
- [OBJECT_RUINbase] = "Spaceship ruin",
- [OBJECT_RUINhead] = "Spaceship ruin",
- [OBJECT_APOLLO1] = "Remains of Apollo mission",
- [OBJECT_APOLLO3] = "Remains of Apollo mission",
- [OBJECT_APOLLO4] = "Remains of Apollo mission",
- [OBJECT_APOLLO5] = "Remains of Apollo mission",
- [OBJECT_APOLLO2] = "Lunar Roving Vehicle"
-};
-
-const char * const strings_err[] =
-{
- [ERR_CMD] = "Unknown command",
- [ERR_MANIP_VEH] = "Inappropriate bot",
- [ERR_MANIP_FLY] = "Impossible when flying",
- [ERR_MANIP_BUSY] = "Already carrying something",
- [ERR_MANIP_NIL] = "Nothing to grab",
- [ERR_MANIP_MOTOR] = "Impossible when moving",
- [ERR_MANIP_OCC] = "Place occupied",
- [ERR_MANIP_FRIEND] = "No other robot",
- [ERR_MANIP_RADIO] = "You can not carry a radioactive object",
- [ERR_MANIP_WATER] = "You can not carry an object under water",
- [ERR_MANIP_EMPTY] = "Nothing to drop",
- [ERR_BUILD_FLY] = "Impossible when flying",
- [ERR_BUILD_WATER] = "Impossible under water",
- [ERR_BUILD_ENERGY] = "Not enough energy",
- [ERR_BUILD_METALAWAY] = "Titanium too far away",
- [ERR_BUILD_METALNEAR] = "Titanium too close",
- [ERR_BUILD_METALINEX] = "No titanium around",
- [ERR_BUILD_FLAT] = "Ground not flat enough",
- [ERR_BUILD_FLATLIT] = "Flat ground not large enough",
- [ERR_BUILD_BUSY] = "Place occupied",
- [ERR_BUILD_BASE] = "Too close to space ship",
- [ERR_BUILD_NARROW] = "Too close to a building",
- [ERR_BUILD_MOTOR] = "Impossible when moving",
- [ERR_SEARCH_FLY] = "Impossible when flying",
- [ERR_SEARCH_VEH] = "Inappropriate bot",
- [ERR_SEARCH_MOTOR] = "Impossible when moving",
- [ERR_TERRA_VEH] = "Inappropriate bot",
- [ERR_TERRA_ENERGY] = "Not enough energy",
- [ERR_TERRA_FLOOR] = "Ground inappropriate",
- [ERR_TERRA_BUILDING] = "Building too close",
- [ERR_TERRA_OBJECT] = "Object too close",
- [ERR_RECOVER_VEH] = "Inappropriate bot",
- [ERR_RECOVER_ENERGY] = "Not enough energy",
- [ERR_RECOVER_NULL] = "Nothing to recycle",
- [ERR_SHIELD_VEH] = "Inappropriate bot",
- [ERR_SHIELD_ENERGY] = "No more energy",
- [ERR_MOVE_IMPOSSIBLE] = "Error in instruction move",
- [ERR_FIND_IMPOSSIBLE] = "Object not found",
- [ERR_GOTO_IMPOSSIBLE] = "Goto: inaccessible destination",
- [ERR_GOTO_ITER] = "Goto: inaccessible destination",
- [ERR_GOTO_BUSY] = "Goto: destination occupied",
- [ERR_FIRE_VEH] = "Inappropriate bot",
- [ERR_FIRE_ENERGY] = "Not enough energy",
- [ERR_FIRE_FLY] = "Impossible when flying",
- [ERR_CONVERT_EMPTY] = "No titanium ore to convert",
- [ERR_DERRICK_NULL] = "No ore in the subsoil",
- [ERR_STATION_NULL] = "No energy in the subsoil",
- [ERR_TOWER_POWER] = "No power cell",
- [ERR_TOWER_ENERGY] = "No more energy",
- [ERR_RESEARCH_POWER] = "No power cell",
- [ERR_RESEARCH_ENERGY] = "Not enough energy",
- [ERR_RESEARCH_TYPE] = "Inappropriate cell type",
- [ERR_RESEARCH_ALREADY]= "Research program already performed",
- [ERR_ENERGY_NULL] = "No energy in the subsoil",
- [ERR_ENERGY_LOW] = "Not enough energy yet",
- [ERR_ENERGY_EMPTY] = "No titanium to transform",
- [ERR_ENERGY_BAD] = "Transforms only titanium",
- [ERR_BASE_DLOCK] = "Doors blocked by a robot or another object ",
- [ERR_BASE_DHUMAN] = "You must get on the spaceship to take off ",
- [ERR_LABO_NULL] = "Nothing to analyze",
- [ERR_LABO_BAD] = "Analyzes only organic matter",
- [ERR_LABO_ALREADY] = "Analysis already performed",
- [ERR_NUCLEAR_NULL] = "No energy in the subsoil",
- [ERR_NUCLEAR_LOW] = "Not yet enough energy",
- [ERR_NUCLEAR_EMPTY] = "No uranium to transform",
- [ERR_NUCLEAR_BAD] = "Transforms only uranium",
- [ERR_FACTORY_NULL] = "No titanium",
- [ERR_FACTORY_NEAR] = "Object too close",
- [ERR_RESET_NEAR] = "Place occupied",
- [ERR_INFO_NULL] = "No information exchange post within range",
- [ERR_VEH_VIRUS] = "Program infected by a virus",
- [ERR_BAT_VIRUS] = "Infected by a virus, temporarily out of order",
- [ERR_VEH_POWER] = "No power cell",
- [ERR_VEH_ENERGY] = "No more energy",
- [ERR_FLAG_FLY] = "Impossible when flying",
- [ERR_FLAG_WATER] = "Impossible when swimming",
- [ERR_FLAG_MOTOR] = "Impossible when moving",
- [ERR_FLAG_BUSY] = "Impossible when carrying an object",
- [ERR_FLAG_CREATE] = "Too many flags of this color (maximum 5)",
- [ERR_FLAG_PROXY] = "Too close to an existing flag",
- [ERR_FLAG_DELETE] = "No flag nearby",
- [ERR_MISSION_NOTERM] = "The mission is not accomplished yet (press \\key help; for more details)",
- [ERR_DELETEMOBILE] = "Bot destroyed",
- [ERR_DELETEBUILDING] = "Building destroyed",
- [ERR_TOOMANY] = "Can not create this, there are too many objects",
- [ERR_OBLIGATORYTOKEN] = "\"%s\" missing in this exercise",
- [ERR_PROHIBITEDTOKEN] = "Do not use in this exercise",
-
- [INFO_BUILD] = "Building completed",
- [INFO_CONVERT] = "Titanium available",
- [INFO_RESEARCH] = "Research program completed",
- [INFO_RESEARCHTANK] = "Plans for tracked robots available ",
- [INFO_RESEARCHFLY] = "You can fly with the keys (\\key gup;) and (\\key gdown;)",
- [INFO_RESEARCHTHUMP] = "Plans for thumper available",
- [INFO_RESEARCHCANON] = "Plans for shooter available",
- [INFO_RESEARCHTOWER] = "Plans for defense tower available",
- [INFO_RESEARCHPHAZER] = "Plans for phazer shooter available",
- [INFO_RESEARCHSHIELD] = "Plans for shielder available",
- [INFO_RESEARCHATOMIC] = "Plans for nuclear power plant available",
- [INFO_FACTORY] = "New bot available",
- [INFO_LABO] = "Analysis performed",
- [INFO_ENERGY] = "Power cell available",
- [INFO_NUCLEAR] = "Nuclear power cell available",
- [INFO_FINDING] = "You found a usable object",
- [INFO_MARKPOWER] = "Found a site for power station",
- [INFO_MARKURANIUM] = "Found a site for a derrick",
- [INFO_MARKSTONE] = "Found a site for a derrick",
- [INFO_MARKKEYa] = "Found a site for a derrick",
- [INFO_MARKKEYb] = "Found a site for a derrick",
- [INFO_MARKKEYc] = "Found a site for a derrick",
- [INFO_MARKKEYd] = "Found a site for a derrick",
- [INFO_WIN] = "<<< Well done, mission accomplished >>>",
- [INFO_LOST] = "<<< Sorry, mission failed >>>",
- [INFO_LOSTq] = "<<< Sorry, mission failed >>>",
- [INFO_WRITEOK] = "Current mission saved",
- [INFO_DELETEPATH] = "Checkpoint crossed",
- [INFO_DELETEMOTHER] = "Alien Queen killed",
- [INFO_DELETEANT] = "Ant fatally wounded",
- [INFO_DELETEBEE] = "Wasp fatally wounded",
- [INFO_DELETEWORM] = "Worm fatally wounded",
- [INFO_DELETESPIDER] = "Spider fatally wounded",
- [INFO_BEGINSATCOM] = "Press \\key help; to read instructions on your SatCom"
-};
-
-const char * const strings_cbot[] =
-{
- [TX_OPENPAR] = "Opening bracket missing",
- [TX_CLOSEPAR] = "Closing bracket missing ",
- [TX_NOTBOOL] = "The expression must return a boolean value",
- [TX_UNDEFVAR] = "Variable not declared",
- [TX_BADLEFT] = "Assignment impossible",
- [TX_ENDOF] = "Semicolon terminator missing",
- [TX_OUTCASE] = "Instruction \"case\" outside a block \"switch\"",
- [TX_NOTERM] = "Instructions after the final closing brace",
- [TX_CLOSEBLK] = "End of block missing",
- [TX_ELSEWITHOUTIF] = "Instruction \"else\" without corresponding \"if\" ",
- [TX_OPENBLK] = "Opening brace missing ",
- [TX_BADTYPE] = "Wrong type for the assignment",
- [TX_REDEFVAR] = "A variable can not be declared twice",
- [TX_BAD2TYPE] = "The types of the two operands are incompatible ",
- [TX_UNDEFCALL] = "Unknown function",
- [TX_MISDOTS] = "Sign \" : \" missing",
- [TX_WHILE] = "Keyword \"while\" missing",
- [TX_BREAK] = "Instruction \"break\" outside a loop",
- [TX_LABEL] = "A label must be followed by \"for\", \"while\", \"do\" or \"switch\"",
- [TX_NOLABEL] = "This label does not exist",
- [TX_NOCASE] = "Instruction \"case\" missing",
- [TX_BADNUM] = "Number missing",
- [TX_VOID] = "Void parameter",
- [TX_NOTYP] = "Type declaration missing",
- [TX_NOVAR] = "Variable name missing",
- [TX_NOFONC] = "Function name missing",
- [TX_OVERPARAM] = "Too many parameters",
- [TX_REDEF] = "Function already exists",
- [TX_LOWPARAM] = "Parameters missing ",
- [TX_BADPARAM] = "No function with this name accepts this kind of parameter",
- [TX_NUMPARAM] = "No function with this name accepts this number of parameters",
- [TX_NOITEM] = "This is not a member of this class",
- [TX_DOT] = "This object is not a member of a class",
- [TX_NOCONST] = "Appropriate constructor missing",
- [TX_REDEFCLASS] = "This class already exists",
- [TX_CLBRK] = "\" ] \" missing",
- [TX_RESERVED] = "Reserved keyword of CBOT language",
- [TX_BADNEW] = "Bad argument for \"new\"",
- [TX_OPBRK] = "\" [ \" expected",
- [TX_BADSTRING] = "String missing",
- [TX_BADINDEX] = "Incorrect index type",
- [TX_PRIVATE] = "Private element",
- [TX_NOPUBLIC] = "Public required",
- [TX_DIVZERO] = "Dividing by zero",
- [TX_NOTINIT] = "Variable not initialized",
- [TX_BADTHROW] = "Negative value rejected by \"throw\"",
- [TX_NORETVAL] = "The function returned no value ",
- [TX_NORUN] = "No function running",
- [TX_NOCALL] = "Calling an unknown function",
- [TX_NOCLASS] = "This class does not exist",
- [TX_NULLPT] = "Unknown Object",
- [TX_OPNAN] = "Operation impossible with value \"nan\"",
- [TX_OUTARRAY] = "Access beyond array limit",
- [TX_STACKOVER] = "Stack overflow",
- [TX_DELETEDPT] = "Illegal object",
- [TX_FILEOPEN] = "Can't open file",
- [TX_NOTOPEN] = "File not open",
- [TX_ERRREAD] = "Read error",
- [TX_ERRWRITE] = "Write error"
-};
-
-#define N_ELTS(Array) (sizeof(Array) / sizeof(Array[0]))
-
-const int strings_text_len = N_ELTS(strings_text);
-const int strings_event_len = N_ELTS(strings_event);
-const int strings_object_len = N_ELTS(strings_object);
-const int strings_err_len = N_ELTS(strings_err);
-const int strings_cbot_len = N_ELTS(strings_cbot);
diff --git a/src/common/singleton.h b/src/common/singleton.h
index 7407504..c1b28d9 100644
--- a/src/common/singleton.h
+++ b/src/common/singleton.h
@@ -19,7 +19,6 @@
* \brief CSingleton base class for singletons
*/
-
#pragma once
#include <cassert>
diff --git a/src/common/stringutils.cpp b/src/common/stringutils.cpp
index 12a3179..db486f0 100644
--- a/src/common/stringutils.cpp
+++ b/src/common/stringutils.cpp
@@ -14,9 +14,8 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// stringutils.cpp
-#include "stringutils.h"
+#include "common/stringutils.h"
std::string StrUtils::Replace(const std::string &str, const std::string &oldStr, const std::string &newStr)
diff --git a/src/graphics/engine/lightning.cpp b/src/graphics/engine/lightning.cpp
index 337d578..d256599 100644
--- a/src/graphics/engine/lightning.cpp
+++ b/src/graphics/engine/lightning.cpp
@@ -108,7 +108,7 @@ bool CLightning::EventFrame(const Event &event)
}
else if (type == OBJECT_PARA)
{
- CAutoPara* automat = dynamic_cast<CAutoPara*>(obj->GetAuto());
+ CAutoPara* automat = static_cast<CAutoPara*>(obj->GetAuto());
if (automat != nullptr)
automat->StartLightning();
diff --git a/src/graphics/engine/particle.h b/src/graphics/engine/particle.h
index d03b3fc..90aec55 100644
--- a/src/graphics/engine/particle.h
+++ b/src/graphics/engine/particle.h
@@ -23,7 +23,7 @@
#pragma once
-#include "engine.h"
+#include "graphics/engine/engine.h"
#include "sound/sound.h"
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index 6355aed..66c73a9 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -407,10 +407,10 @@ int CText::Justify(const std::string &text, FontType font, float size, float wid
if (len >= 3)
ch.c3 = text[index+2];
- index += len;
-
if (ch.c1 == '\n')
+ {
return index+1;
+ }
if (ch.c1 == ' ' )
cut = index+1;
@@ -421,6 +421,7 @@ int CText::Justify(const std::string &text, FontType font, float size, float wid
if (cut == 0) return index;
else return cut;
}
+ index += len;
}
return index;
diff --git a/src/graphics/engine/text.h b/src/graphics/engine/text.h
index 4575c37..57fad43 100644
--- a/src/graphics/engine/text.h
+++ b/src/graphics/engine/text.h
@@ -227,7 +227,7 @@ class CText
{
public:
CText(CInstanceManager *iMan, CEngine* engine);
- ~CText();
+ virtual ~CText();
//! Sets the device to be used
void SetDevice(CDevice *device);
@@ -269,12 +269,12 @@ public:
float GetHeight(FontType font, float size);
//! Returns width of string (multi-format)
- float GetStringWidth(const std::string &text,
+ TEST_VIRTUAL float GetStringWidth(const std::string &text,
std::map<unsigned int, FontMetaChar> &format, float size);
//! Returns width of string (single font)
- float GetStringWidth(const std::string &text, FontType font, float size);
+ TEST_VIRTUAL float GetStringWidth(const std::string &text, FontType font, float size);
//! Returns width of single character
- float GetCharWidth(UTF8Char ch, FontType font, float size, float offset);
+ TEST_VIRTUAL float GetCharWidth(UTF8Char ch, FontType font, float size, float offset);
//! Justifies a line of text (multi-format)
int Justify(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index 7bfd843..94b0dbc 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -48,6 +48,10 @@
// Graphics module namespace
namespace Gfx {
+GLDeviceConfig::GLDeviceConfig()
+{
+ LoadDefault();
+}
void GLDeviceConfig::LoadDefault()
{
diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h
index cda7b02..87c1247 100644
--- a/src/graphics/opengl/gldevice.h
+++ b/src/graphics/opengl/gldevice.h
@@ -52,7 +52,7 @@ struct GLDeviceConfig : public DeviceConfig
bool hardwareAccel;
//! Constructor calls LoadDefaults()
- GLDeviceConfig() { LoadDefault(); }
+ GLDeviceConfig();
//! Loads the default values
void LoadDefault();
diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp
index 711497d..4003193 100644
--- a/src/object/auto/auto.cpp
+++ b/src/object/auto/auto.cpp
@@ -352,7 +352,7 @@ void CAuto::UpdateInterface(float rTime)
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAuto::GetError()
{
@@ -421,7 +421,7 @@ bool CAuto::Write(char *line)
return false;
}
-// Geturn all settings to the controller.
+// Return all settings to the controller.
bool CAuto::Read(char *line)
{
diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp
index d7b3ca1..8370517 100644
--- a/src/object/auto/autobase.cpp
+++ b/src/object/auto/autobase.cpp
@@ -1198,7 +1198,7 @@ bool CAutoBase::Abort()
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoBase::GetError()
{
diff --git a/src/object/auto/autoconvert.cpp b/src/object/auto/autoconvert.cpp
index ec4392b..a550697 100644
--- a/src/object/auto/autoconvert.cpp
+++ b/src/object/auto/autoconvert.cpp
@@ -285,7 +285,7 @@ bool CAutoConvert::EventProcess(const Event &event)
return true;
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoConvert::GetError()
{
diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp
index 740f600..ecf7c94 100644
--- a/src/object/auto/autodestroyer.cpp
+++ b/src/object/auto/autodestroyer.cpp
@@ -316,7 +316,7 @@ bool CAutoDestroyer::SearchVehicle()
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoDestroyer::GetError()
{
diff --git a/src/object/auto/autoegg.cpp b/src/object/auto/autoegg.cpp
index 35a6add..5b90ef9 100644
--- a/src/object/auto/autoegg.cpp
+++ b/src/object/auto/autoegg.cpp
@@ -258,7 +258,7 @@ Error CAutoEgg::IsEnded()
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoEgg::GetError()
{
diff --git a/src/object/auto/autoenergy.cpp b/src/object/auto/autoenergy.cpp
index 18a21ab..c63dede 100644
--- a/src/object/auto/autoenergy.cpp
+++ b/src/object/auto/autoenergy.cpp
@@ -508,7 +508,7 @@ CObject* CAutoEnergy::SearchPower()
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoEnergy::GetError()
{
diff --git a/src/object/auto/autoflag.cpp b/src/object/auto/autoflag.cpp
index e88ee3a..c2dec5c 100644
--- a/src/object/auto/autoflag.cpp
+++ b/src/object/auto/autoflag.cpp
@@ -153,7 +153,7 @@ bool CAutoFlag::EventProcess(const Event &event)
}
-// Geturns an error due the state of the automation
+// Returns an error due the state of the automation
Error CAutoFlag::GetError()
{
diff --git a/src/object/auto/autohuston.cpp b/src/object/auto/autohuston.cpp
index 1e81a65..1b6778d 100644
--- a/src/object/auto/autohuston.cpp
+++ b/src/object/auto/autohuston.cpp
@@ -286,7 +286,7 @@ bool CAutoHuston::CreateInterface(bool bSelect)
}
-// Geturns an error due to state of the automation.
+// Returns an error due to state of the automation.
Error CAutoHuston::GetError()
{
diff --git a/src/object/auto/autoinfo.cpp b/src/object/auto/autoinfo.cpp
index 78cc249..1245034 100644
--- a/src/object/auto/autoinfo.cpp
+++ b/src/object/auto/autoinfo.cpp
@@ -339,7 +339,7 @@ bool CAutoInfo::EventProcess(const Event &event)
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoInfo::GetError()
{
diff --git a/src/object/auto/autokid.cpp b/src/object/auto/autokid.cpp
index 7004e6b..64cd39a 100644
--- a/src/object/auto/autokid.cpp
+++ b/src/object/auto/autokid.cpp
@@ -191,7 +191,7 @@ bool CAutoKid::EventProcess(const Event &event)
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoKid::GetError()
{
diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp
index af780e0..70bcc5e 100644
--- a/src/object/auto/autolabo.cpp
+++ b/src/object/auto/autolabo.cpp
@@ -423,7 +423,7 @@ bool CAutoLabo::EventProcess(const Event &event)
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoLabo::GetError()
{
diff --git a/src/object/auto/automush.cpp b/src/object/auto/automush.cpp
index d7aa98e..cb94590 100644
--- a/src/object/auto/automush.cpp
+++ b/src/object/auto/automush.cpp
@@ -289,7 +289,7 @@ bool CAutoMush::SearchTarget()
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoMush::GetError()
{
diff --git a/src/object/auto/autonest.cpp b/src/object/auto/autonest.cpp
index 4a8132a..99927bd 100644
--- a/src/object/auto/autonest.cpp
+++ b/src/object/auto/autonest.cpp
@@ -219,7 +219,7 @@ CObject* CAutoNest::SearchFret()
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoNest::GetError()
{
diff --git a/src/object/auto/autonuclear.cpp b/src/object/auto/autonuclear.cpp
index bb20dde..375acf0 100644
--- a/src/object/auto/autonuclear.cpp
+++ b/src/object/auto/autonuclear.cpp
@@ -410,7 +410,7 @@ void CAutoNuclear::CreatePower()
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoNuclear::GetError()
{
diff --git a/src/object/auto/autopara.cpp b/src/object/auto/autopara.cpp
index b52344f..a3082f5 100644
--- a/src/object/auto/autopara.cpp
+++ b/src/object/auto/autopara.cpp
@@ -221,7 +221,7 @@ bool CAutoPara::CreateInterface(bool bSelect)
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoPara::GetError()
{
diff --git a/src/object/auto/autoportico.cpp b/src/object/auto/autoportico.cpp
index 9d04982..3b3bf84 100644
--- a/src/object/auto/autoportico.cpp
+++ b/src/object/auto/autoportico.cpp
@@ -385,7 +385,7 @@ bool CAutoPortico::Abort()
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoPortico::GetError()
{
diff --git a/src/object/auto/autoradar.cpp b/src/object/auto/autoradar.cpp
index b586521..4214d17 100644
--- a/src/object/auto/autoradar.cpp
+++ b/src/object/auto/autoradar.cpp
@@ -183,7 +183,7 @@ bool CAutoRadar::EventProcess(const Event &event)
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoRadar::GetError()
{
diff --git a/src/object/auto/autorepair.cpp b/src/object/auto/autorepair.cpp
index 4662699..cf4f33e 100644
--- a/src/object/auto/autorepair.cpp
+++ b/src/object/auto/autorepair.cpp
@@ -283,7 +283,7 @@ CObject* CAutoRepair::SearchVehicle()
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoRepair::GetError()
{
diff --git a/src/object/auto/autoresearch.cpp b/src/object/auto/autoresearch.cpp
index a3ce464..9f423ec 100644
--- a/src/object/auto/autoresearch.cpp
+++ b/src/object/auto/autoresearch.cpp
@@ -263,7 +263,7 @@ bool CAutoResearch::EventProcess(const Event &event)
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoResearch::GetError()
{
diff --git a/src/object/auto/autoroot.cpp b/src/object/auto/autoroot.cpp
index 4413d56..196ed5d 100644
--- a/src/object/auto/autoroot.cpp
+++ b/src/object/auto/autoroot.cpp
@@ -108,7 +108,7 @@ bool CAutoRoot::EventProcess(const Event &event)
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoRoot::GetError()
{
diff --git a/src/object/auto/autosafe.cpp b/src/object/auto/autosafe.cpp
index ea0c183..e89acea 100644
--- a/src/object/auto/autosafe.cpp
+++ b/src/object/auto/autosafe.cpp
@@ -334,7 +334,7 @@ bool CAutoSafe::CreateInterface(bool bSelect)
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoSafe::GetError()
{
diff --git a/src/object/auto/autostation.cpp b/src/object/auto/autostation.cpp
index 1dbcf26..e99ae4b 100644
--- a/src/object/auto/autostation.cpp
+++ b/src/object/auto/autostation.cpp
@@ -288,7 +288,7 @@ CObject* CAutoStation::SearchVehicle()
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoStation::GetError()
{
diff --git a/src/object/auto/autotower.cpp b/src/object/auto/autotower.cpp
index 7674794..84dcd85 100644
--- a/src/object/auto/autotower.cpp
+++ b/src/object/auto/autotower.cpp
@@ -313,7 +313,7 @@ CObject* CAutoTower::SearchTarget(Math::Vector &impact)
}
-// Geturns an error due the state of the automation.
+// Returns an error due the state of the automation.
Error CAutoTower::GetError()
{
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index 7b580d7..4ce1bf8 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -19,14 +19,20 @@
#include "common/misc.h"
#include "common/iman.h"
+
#include "graphics/core/color.h"
#include "graphics/engine/terrain.h"
+
#include "object/motion/motion.h"
#include "object/task/taskmanager.h"
+
#include "physics/physics.h"
+
#include "script/cmdtoken.h"
#include "script/script.h"
+
#include "sound/sound.h"
+
#include "ui/displaytext.h"
#include "ui/interface.h"
#include "ui/slider.h"
@@ -203,8 +209,8 @@ bool CBrain::EventProcess(const Event &event)
action = EVENT_NULL;
if ( event.type == EVENT_KEY_DOWN &&
- (event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).key ||
- event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).joy ) &&
+ (event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).primary ||
+ event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).secondary ) &&
!m_main->GetEditLock() )
{
pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
@@ -803,7 +809,7 @@ void CBrain::StopTask()
// Introduces a virus into a program.
-// Geturns true if it was inserted.
+// Returns true if it was inserted.
bool CBrain::IntroduceVirus()
{
@@ -2450,7 +2456,7 @@ void CBrain::UpdateScript(Ui::CWindow *pw)
pl->ShowSelect(true);
}
-// Geturns the rank of selected script.
+// Returns the rank of selected script.
int CBrain::GetSelScript()
{
@@ -2590,7 +2596,7 @@ void CBrain::RunProgram(int rank)
}
}
-// Geturns the first free program.
+// Returns the first free program.
int CBrain::FreeProgram()
{
@@ -2604,7 +2610,7 @@ int CBrain::FreeProgram()
}
-// Geturns the current program.
+// Returns the current program.
int CBrain::GetProgram()
{
diff --git a/src/object/brain.h b/src/object/brain.h
index 008fb67..ce7116e 100644
--- a/src/object/brain.h
+++ b/src/object/brain.h
@@ -14,10 +14,14 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// brain.h
+/**
+ * \file object/brain.h
+ * \brief CBrain - dispatches commands to objects
+ */
#pragma once
+
#include "common/event.h"
#include "common/misc.h"
diff --git a/src/object/mainmovie.cpp b/src/object/mainmovie.cpp
index 346f370..9aaf345 100644
--- a/src/object/mainmovie.cpp
+++ b/src/object/mainmovie.cpp
@@ -14,20 +14,18 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// mainmovie.cpp
-
-
-#include <stdio.h>
-
#include "object/mainmovie.h"
-#include "math/geometry.h"
#include "common/iman.h"
+
+#include "math/geometry.h"
+
#include "object/motion/motionhuman.h"
#include "object/robotmain.h"
+#include <stdio.h>
// Constructor of the application card.
@@ -219,14 +217,14 @@ bool CMainMovie::EventProcess(const Event &event)
}
-// Geturns the type of the current movie.
+// Returns the type of the current movie.
MainMovieType CMainMovie::GetType()
{
return m_type;
}
-// Geturns the type of movie stop.
+// Returns the type of movie stop.
MainMovieType CMainMovie::GetStopType()
{
diff --git a/src/object/mainmovie.h b/src/object/mainmovie.h
index 27e4df3..eba21eb 100644
--- a/src/object/mainmovie.h
+++ b/src/object/mainmovie.h
@@ -14,7 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// mainmovie.h
+/**
+ * \file object/mainmovie.h
+ * \brief CMainMovie - control over movie sequences
+ */
#pragma once
diff --git a/src/object/motion/motion.cpp b/src/object/motion/motion.cpp
index ff038ae..605091f 100644
--- a/src/object/motion/motion.cpp
+++ b/src/object/motion/motion.cpp
@@ -150,7 +150,7 @@ Error CMotion::SetAction(int action, float time)
return ERR_OK;
}
-// Geturns the current action.
+// Returns the current action.
int CMotion::GetAction()
{
diff --git a/src/object/object.cpp b/src/object/object.cpp
index 5a1631f..2eade93 100644
--- a/src/object/object.cpp
+++ b/src/object/object.cpp
@@ -17,7 +17,6 @@
#include "object/object.h"
-
#include "CBot/CBotDll.h"
#include "app/app.h"
@@ -830,7 +829,7 @@ void CObject::InitPart(int part)
}
// Creates a new part, and returns its number.
-// Geturns -1 on error.
+// Returns -1 on error.
int CObject::CreatePart()
{
@@ -891,7 +890,7 @@ void CObject::SetObjectRank(int part, int objRank)
m_objectPart[part].object = objRank;
}
-// Geturns the number of part.
+// Returns the number of part.
int CObject::GetObjectRank(int part)
{
@@ -1164,7 +1163,7 @@ bool CObject::Write(char *line)
return true;
}
-// Geturns all parameters of the object.
+// Returns all parameters of the object.
bool CObject::Read(char *line)
{
@@ -1299,14 +1298,14 @@ int CObject::CreateCrashSphere(Math::Vector pos, float radius, Sound sound,
return m_crashSphereUsed++;
}
-// Geturns the number of spheres.
+// Returns the number of spheres.
int CObject::GetCrashSphereTotal()
{
return m_crashSphereUsed;
}
-// Geturns a sphere for collisions.
+// Returns a sphere for collisions.
// The position is absolute in the world.
bool CObject::GetCrashSphere(int rank, Math::Vector &pos, float &radius)
@@ -1318,7 +1317,7 @@ bool CObject::GetCrashSphere(int rank, Math::Vector &pos, float &radius)
return false;
}
- // Geturns to the sphere collisions,
+ // Returns to the sphere collisions,
// which ignores the inclination of the vehicle.
// This is necessary to collisions with vehicles,
// so as not to reflect SetInclinaison, for example.
@@ -1342,14 +1341,14 @@ bool CObject::GetCrashSphere(int rank, Math::Vector &pos, float &radius)
return true;
}
-// Geturns the hardness of a sphere.
+// Returns the hardness of a sphere.
Sound CObject::GetCrashSphereSound(int rank)
{
return m_crashSphereSound[rank];
}
-// Geturns the hardness of a sphere.
+// Returns the hardness of a sphere.
float CObject::GetCrashSphereHardness(int rank)
{
@@ -1383,7 +1382,7 @@ void CObject::SetGlobalSphere(Math::Vector pos, float radius)
m_globalSphereRadius = radius*zoom;
}
-// Geturns the global sphere, in the world.
+// Returns the global sphere, in the world.
void CObject::GetGlobalSphere(Math::Vector &pos, float &radius)
{
@@ -1416,7 +1415,7 @@ void CObject::SetShieldRadius(float radius)
m_shieldRadius = radius;
}
-// Geturns the radius of the shield.
+// Returns the radius of the shield.
float CObject::GetShieldRadius()
{
@@ -1787,7 +1786,7 @@ float CObject::GetZoomZ(int part)
}
-// Geturns the water level.
+// Returns the water level.
float CObject::GetWaterLevel()
{
@@ -2023,7 +2022,7 @@ float CObject::GetCmdLine(int rank)
}
-// Geturns matrices of an object portion.
+// Returns matrices of an object portion.
Math::Matrix* CObject::GetRotateMatrix(int part)
{
@@ -2277,7 +2276,7 @@ bool CObject::CreateShadowLight(float height, Gfx::Color color)
return true;
}
-// Geturns the number of negative light shade.
+// Returns the number of negative light shade.
int CObject::GetShadowLight()
{
@@ -2318,7 +2317,7 @@ bool CObject::CreateEffectLight(float height, Gfx::Color color)
return true;
}
-// Geturns the number of light effects.
+// Returns the number of light effects.
int CObject::GetEffectLight()
{
@@ -5808,7 +5807,7 @@ bool CObject::RunProgram(int rank)
// Calculates the matrix for transforming the object.
-// Geturns true if the matrix has changed.
+// Returns true if the matrix has changed.
// The rotations occur in the order Y, Z and X.
bool CObject::UpdateTransformObject(int part, bool bForceUpdate)
@@ -6452,7 +6451,7 @@ Character* CObject::GetCharacter()
}
-// Geturns the absolute time.
+// Returns the absolute time.
float CObject::GetAbsTime()
{
@@ -7406,35 +7405,35 @@ CScript* CObject::GetRunScript()
return m_runScript;
}
-// Geturns the variables of "this" for CBOT.
+// Returns the variables of "this" for CBOT.
CBotVar* CObject::GetBotVar()
{
return m_botVar;
}
-// Geturns the physics associated to the object.
+// Returns the physics associated to the object.
CPhysics* CObject::GetPhysics()
{
return m_physics;
}
-// Geturns the brain associated to the object.
+// Returns the brain associated to the object.
CBrain* CObject::GetBrain()
{
return m_brain;
}
-// Geturns the movement associated to the object.
+// Returns the movement associated to the object.
CMotion* CObject::GetMotion()
{
return m_motion;
}
-// Geturns the controller associated to the object.
+// Returns the controller associated to the object.
CAuto* CObject::GetAuto()
{
diff --git a/src/object/object.h b/src/object/object.h
index b555856..8d8baca 100644
--- a/src/object/object.h
+++ b/src/object/object.h
@@ -14,7 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// object.h
+/**
+ * \file object/object.h
+ * \brief CObject - base class for all game objects
+ */
#pragma once
@@ -22,8 +25,6 @@
#include "graphics/engine/engine.h"
#include "graphics/engine/camera.h"
-#include "object/object_ids.h"
-
#include "sound/sound.h"
@@ -44,6 +45,258 @@ class CDisplayText;
}
+/**
+ * \enum ObjectType
+ * \brief Type of game object
+ */
+enum ObjectType
+{
+ OBJECT_NULL = 0, //! < object destroyed
+ OBJECT_FIX = 1, //! < stationary scenery
+ OBJECT_PORTICO = 2, //! < gantry
+ OBJECT_BASE = 3, //! < great main base
+ OBJECT_DERRICK = 4, //! < derrick set
+ OBJECT_FACTORY = 5, //! < factory set
+ OBJECT_STATION = 6, //! < recharging station
+ OBJECT_CONVERT = 7, //! < converter station
+ OBJECT_REPAIR = 8, //! < reparation
+ OBJECT_TOWER = 9, //! < defense tower
+ OBJECT_NEST = 10, //! < nest
+ OBJECT_RESEARCH = 11, //! < research center
+ OBJECT_RADAR = 12, //! < radar
+ OBJECT_ENERGY = 13, //! < energy factory
+ OBJECT_LABO = 14, //! < analytical laboratory for insect
+ OBJECT_NUCLEAR = 15, //! < nuclear power plant
+ OBJECT_START = 16, //! < starting
+ OBJECT_END = 17, //! < finish
+ OBJECT_INFO = 18, //! < information terminal
+ OBJECT_PARA = 19, //! < lightning conductor
+ OBJECT_TARGET1 = 20, //! < gate target
+ OBJECT_TARGET2 = 21, //! < center target
+ OBJECT_SAFE = 22, //! < safe
+ OBJECT_HUSTON = 23, //! < control centre
+ OBJECT_DESTROYER = 24, //! < destroyer
+ OBJECT_FRET = 30, //! < transportable
+ OBJECT_STONE = 31, //! < stone
+ OBJECT_URANIUM = 32, //! < uranium
+ OBJECT_METAL = 33, //! < metal
+ OBJECT_POWER = 34, //! < normal battery
+ OBJECT_ATOMIC = 35, //! < atomic battery
+ OBJECT_BULLET = 36, //! < bullet
+ OBJECT_BBOX = 37, //! < black-box
+ OBJECT_TNT = 38, //! < box of TNT
+ OBJECT_SCRAP1 = 40, //! < metal waste
+ OBJECT_SCRAP2 = 41, //! < metal waste
+ OBJECT_SCRAP3 = 42, //! < metal waste
+ OBJECT_SCRAP4 = 43, //! < plastic waste
+ OBJECT_SCRAP5 = 44, //! < plastic waste
+ OBJECT_MARKPOWER = 50, //! < mark underground energy source
+ OBJECT_MARKSTONE = 51, //! < mark underground ore
+ OBJECT_MARKURANIUM = 52, //! < mark underground uranium
+ OBJECT_MARKKEYa = 53, //! < mark underground key
+ OBJECT_MARKKEYb = 54, //! < mark underground key
+ OBJECT_MARKKEYc = 55, //! < mark underground key
+ OBJECT_MARKKEYd = 56, //! < mark underground key
+ OBJECT_BOMB = 60, //! < bomb
+ OBJECT_WINFIRE = 61, //! < fireworks
+ OBJECT_SHOW = 62, //! < shows a place
+ OBJECT_BAG = 63, //! < survival bag
+ OBJECT_PLANT0 = 70, //! < plant 0
+ OBJECT_PLANT1 = 71, //! < plant 1
+ OBJECT_PLANT2 = 72, //! < plant 2
+ OBJECT_PLANT3 = 73, //! < plant 3
+ OBJECT_PLANT4 = 74, //! < plant 4
+ OBJECT_PLANT5 = 75, //! < plant 5
+ OBJECT_PLANT6 = 76, //! < plant 6
+ OBJECT_PLANT7 = 77, //! < plant 7
+ OBJECT_PLANT8 = 78, //! < plant 8
+ OBJECT_PLANT9 = 79, //! < plant 9
+ OBJECT_PLANT10 = 80, //! < plant 10
+ OBJECT_PLANT11 = 81, //! < plant 11
+ OBJECT_PLANT12 = 82, //! < plant 12
+ OBJECT_PLANT13 = 83, //! < plant 13
+ OBJECT_PLANT14 = 84, //! < plant 14
+ OBJECT_PLANT15 = 85, //! < plant 15
+ OBJECT_PLANT16 = 86, //! < plant 16
+ OBJECT_PLANT17 = 87, //! < plant 17
+ OBJECT_PLANT18 = 88, //! < plant 18
+ OBJECT_PLANT19 = 89, //! < plant 19
+ OBJECT_TREE0 = 90, //! < tree 0
+ OBJECT_TREE1 = 91, //! < tree 1
+ OBJECT_TREE2 = 92, //! < tree 2
+ OBJECT_TREE3 = 93, //! < tree 3
+ OBJECT_TREE4 = 94, //! < tree 4
+ OBJECT_TREE5 = 95, //! < tree 5
+ OBJECT_TREE6 = 96, //! < tree 6
+ OBJECT_TREE7 = 97, //! < tree 7
+ OBJECT_TREE8 = 98, //! < tree 8
+ OBJECT_TREE9 = 99, //! < tree 9
+ OBJECT_MOBILEwt = 100, //! < wheel-trainer
+ OBJECT_MOBILEtt = 101, //! < track-trainer
+ OBJECT_MOBILEft = 102, //! < fly-trainer
+ OBJECT_MOBILEit = 103, //! < insect-trainer
+ OBJECT_MOBILEwa = 110, //! < wheel-arm
+ OBJECT_MOBILEta = 111, //! < track-arm
+ OBJECT_MOBILEfa = 112, //! < fly-arm
+ OBJECT_MOBILEia = 113, //! < insect-arm
+ OBJECT_MOBILEwc = 120, //! < wheel-cannon
+ OBJECT_MOBILEtc = 121, //! < track-cannon
+ OBJECT_MOBILEfc = 122, //! < fly-cannon
+ OBJECT_MOBILEic = 123, //! < insect-cannon
+ OBJECT_MOBILEwi = 130, //! < wheel-insect-cannon
+ OBJECT_MOBILEti = 131, //! < track-insect-cannon
+ OBJECT_MOBILEfi = 132, //! < fly-insect-cannon
+ OBJECT_MOBILEii = 133, //! < insect-insect-cannon
+ OBJECT_MOBILEws = 140, //! < wheel-search
+ OBJECT_MOBILEts = 141, //! < track-search
+ OBJECT_MOBILEfs = 142, //! < fly-search
+ OBJECT_MOBILEis = 143, //! < insect-search
+ OBJECT_MOBILErt = 200, //! < roller-terraform
+ OBJECT_MOBILErc = 201, //! < roller-canon
+ OBJECT_MOBILErr = 202, //! < roller-recover
+ OBJECT_MOBILErs = 203, //! < roller-shield
+ OBJECT_MOBILEsa = 210, //! < submarine
+ OBJECT_MOBILEtg = 211, //! < training target
+ OBJECT_MOBILEdr = 212, //! < robot drawing
+ OBJECT_WAYPOINT = 250, //! < waypoint
+ OBJECT_FLAGb = 260, //! < blue flag
+ OBJECT_FLAGr = 261, //! < red flag
+ OBJECT_FLAGg = 262, //! < green flag
+ OBJECT_FLAGy = 263, //! < yellow flag
+ OBJECT_FLAGv = 264, //! < violet flag
+ OBJECT_KEYa = 270, //! < key a
+ OBJECT_KEYb = 271, //! < key b
+ OBJECT_KEYc = 272, //! < key c
+ OBJECT_KEYd = 273, //! < key d
+ OBJECT_HUMAN = 300, //! < human
+ OBJECT_TOTO = 301, //! < toto
+ OBJECT_TECH = 302, //! < technician
+ OBJECT_BARRIER0 = 400, //! < barrier
+ OBJECT_BARRIER1 = 401, //! < barrier
+ OBJECT_BARRIER2 = 402, //! < barrier
+ OBJECT_BARRIER3 = 403, //! < barrier
+ OBJECT_BARRIER4 = 404, //! < barrier
+ OBJECT_MOTHER = 500, //! < insect queen
+ OBJECT_EGG = 501, //! < egg
+ OBJECT_ANT = 502, //! < ant
+ OBJECT_SPIDER = 503, //! < spider
+ OBJECT_BEE = 504, //! < bee
+ OBJECT_WORM = 505, //! < worm
+ OBJECT_RUINmobilew1 = 600, //! < ruin 1
+ OBJECT_RUINmobilew2 = 601, //! < ruin 1
+ OBJECT_RUINmobilet1 = 602, //! < ruin 2
+ OBJECT_RUINmobilet2 = 603, //! < ruin 2
+ OBJECT_RUINmobiler1 = 604, //! < ruin 3
+ OBJECT_RUINmobiler2 = 605, //! < ruin 3
+ OBJECT_RUINfactory = 606, //! < ruin 4
+ OBJECT_RUINdoor = 607, //! < ruin 5
+ OBJECT_RUINsupport = 608, //! < ruin 6
+ OBJECT_RUINradar = 609, //! < ruin 7
+ OBJECT_RUINconvert = 610, //! < ruin 8
+ OBJECT_RUINbase = 611, //! < ruin 9
+ OBJECT_RUINhead = 612, //! < ruin 10
+ OBJECT_TEEN0 = 620, //! < toy
+ OBJECT_TEEN1 = 621, //! < toy
+ OBJECT_TEEN2 = 622, //! < toy
+ OBJECT_TEEN3 = 623, //! < toy
+ OBJECT_TEEN4 = 624, //! < toy
+ OBJECT_TEEN5 = 625, //! < toy
+ OBJECT_TEEN6 = 626, //! < toy
+ OBJECT_TEEN7 = 627, //! < toy
+ OBJECT_TEEN8 = 628, //! < toy
+ OBJECT_TEEN9 = 629, //! < toy
+ OBJECT_TEEN10 = 630, //! < toy
+ OBJECT_TEEN11 = 631, //! < toy
+ OBJECT_TEEN12 = 632, //! < toy
+ OBJECT_TEEN13 = 633, //! < toy
+ OBJECT_TEEN14 = 634, //! < toy
+ OBJECT_TEEN15 = 635, //! < toy
+ OBJECT_TEEN16 = 636, //! < toy
+ OBJECT_TEEN17 = 637, //! < toy
+ OBJECT_TEEN18 = 638, //! < toy
+ OBJECT_TEEN19 = 639, //! < toy
+ OBJECT_TEEN20 = 640, //! < toy
+ OBJECT_TEEN21 = 641, //! < toy
+ OBJECT_TEEN22 = 642, //! < toy
+ OBJECT_TEEN23 = 643, //! < toy
+ OBJECT_TEEN24 = 644, //! < toy
+ OBJECT_TEEN25 = 645, //! < toy
+ OBJECT_TEEN26 = 646, //! < toy
+ OBJECT_TEEN27 = 647, //! < toy
+ OBJECT_TEEN28 = 648, //! < toy
+ OBJECT_TEEN29 = 649, //! < toy
+ OBJECT_TEEN30 = 650, //! < toy
+ OBJECT_TEEN31 = 651, //! < toy
+ OBJECT_TEEN32 = 652, //! < toy
+ OBJECT_TEEN33 = 653, //! < toy
+ OBJECT_TEEN34 = 654, //! < toy
+ OBJECT_TEEN35 = 655, //! < toy
+ OBJECT_TEEN36 = 656, //! < toy
+ OBJECT_TEEN37 = 657, //! < toy
+ OBJECT_TEEN38 = 658, //! < toy
+ OBJECT_TEEN39 = 659, //! < toy
+ OBJECT_TEEN40 = 660, //! < toy
+ OBJECT_TEEN41 = 661, //! < toy
+ OBJECT_TEEN42 = 662, //! < toy
+ OBJECT_TEEN43 = 663, //! < toy
+ OBJECT_TEEN44 = 664, //! < toy
+ OBJECT_TEEN45 = 665, //! < toy
+ OBJECT_TEEN46 = 666, //! < toy
+ OBJECT_TEEN47 = 667, //! < toy
+ OBJECT_TEEN48 = 668, //! < toy
+ OBJECT_TEEN49 = 669, //! < toy
+ OBJECT_QUARTZ0 = 700, //! < crystal 0
+ OBJECT_QUARTZ1 = 701, //! < crystal 1
+ OBJECT_QUARTZ2 = 702, //! < crystal 2
+ OBJECT_QUARTZ3 = 703, //! < crystal 3
+ OBJECT_QUARTZ4 = 704, //! < crystal 4
+ OBJECT_QUARTZ5 = 705, //! < crystal 5
+ OBJECT_QUARTZ6 = 706, //! < crystal 6
+ OBJECT_QUARTZ7 = 707, //! < crystal 7
+ OBJECT_QUARTZ8 = 708, //! < crystal 8
+ OBJECT_QUARTZ9 = 709, //! < crystal 9
+ OBJECT_ROOT0 = 710, //! < root 0
+ OBJECT_ROOT1 = 711, //! < root 1
+ OBJECT_ROOT2 = 712, //! < root 2
+ OBJECT_ROOT3 = 713, //! < root 3
+ OBJECT_ROOT4 = 714, //! < root 4
+ OBJECT_ROOT5 = 715, //! < root 5
+ OBJECT_ROOT6 = 716, //! < root 6
+ OBJECT_ROOT7 = 717, //! < root 7
+ OBJECT_ROOT8 = 718, //! < root 8
+ OBJECT_ROOT9 = 719, //! < root 9
+ OBJECT_SEAWEED0 = 720, //! < seaweed 0
+ OBJECT_SEAWEED1 = 721, //! < seaweed 1
+ OBJECT_SEAWEED2 = 722, //! < seaweed 2
+ OBJECT_SEAWEED3 = 723, //! < seaweed 3
+ OBJECT_SEAWEED4 = 724, //! < seaweed 4
+ OBJECT_SEAWEED5 = 725, //! < seaweed 5
+ OBJECT_SEAWEED6 = 726, //! < seaweed 6
+ OBJECT_SEAWEED7 = 727, //! < seaweed 7
+ OBJECT_SEAWEED8 = 728, //! < seaweed 8
+ OBJECT_SEAWEED9 = 729, //! < seaweed 9
+ OBJECT_MUSHROOM0 = 730, //! < mushroom 0
+ OBJECT_MUSHROOM1 = 731, //! < mushroom 1
+ OBJECT_MUSHROOM2 = 732, //! < mushroom 2
+ OBJECT_MUSHROOM3 = 733, //! < mushroom 3
+ OBJECT_MUSHROOM4 = 734, //! < mushroom 4
+ OBJECT_MUSHROOM5 = 735, //! < mushroom 5
+ OBJECT_MUSHROOM6 = 736, //! < mushroom 6
+ OBJECT_MUSHROOM7 = 737, //! < mushroom 7
+ OBJECT_MUSHROOM8 = 738, //! < mushroom 8
+ OBJECT_MUSHROOM9 = 739, //! < mushroom 9
+ OBJECT_APOLLO1 = 900, //! < apollo lem
+ OBJECT_APOLLO2 = 901, //! < apollo jeep
+ OBJECT_APOLLO3 = 902, //! < apollo flag
+ OBJECT_APOLLO4 = 903, //! < apollo module
+ OBJECT_APOLLO5 = 904, //! < apollo antenna
+ OBJECT_HOME1 = 910, //! < home 1
+
+ OBJECT_MAX = 1000 //! < number of values
+};
+
+
+
// The father of all parts must always be the part number zero!
const int OBJECTMAXPART = 40;
diff --git a/src/object/object_ids.h b/src/object/object_ids.h
deleted file mode 100644
index 2d9c1a8..0000000
--- a/src/object/object_ids.h
+++ /dev/null
@@ -1,262 +0,0 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
-
-#pragma once
-
-enum ObjectType
-{
- OBJECT_NULL = 0, // object destroyed
- OBJECT_FIX = 1, // stationary scenery
- OBJECT_PORTICO = 2, // gantry
- OBJECT_BASE = 3, // great main base
- OBJECT_DERRICK = 4, // derrick set
- OBJECT_FACTORY = 5, // factory set
- OBJECT_STATION = 6, // recharging station
- OBJECT_CONVERT = 7, // converter station
- OBJECT_REPAIR = 8, // reparation
- OBJECT_TOWER = 9, // defense tower
- OBJECT_NEST = 10, // nest
- OBJECT_RESEARCH = 11, // research center
- OBJECT_RADAR = 12, // radar
- OBJECT_ENERGY = 13, // energy factory
- OBJECT_LABO = 14, // analytical laboratory for insect
- OBJECT_NUCLEAR = 15, // nuclear power plant
- OBJECT_START = 16, // starting
- OBJECT_END = 17, // finish
- OBJECT_INFO = 18, // information terminal
- OBJECT_PARA = 19, // lightning conductor
- OBJECT_TARGET1 = 20, // gate target
- OBJECT_TARGET2 = 21, // center target
- OBJECT_SAFE = 22, // safe
- OBJECT_HUSTON = 23, // control centre
- OBJECT_DESTROYER = 24, // destroyer
- OBJECT_FRET = 30, // transportable
- OBJECT_STONE = 31, // stone
- OBJECT_URANIUM = 32, // uranium
- OBJECT_METAL = 33, // metal
- OBJECT_POWER = 34, // normal battery
- OBJECT_ATOMIC = 35, // atomic battery
- OBJECT_BULLET = 36, // bullet
- OBJECT_BBOX = 37, // black-box
- OBJECT_TNT = 38, // box of TNT
- OBJECT_SCRAP1 = 40, // metal waste
- OBJECT_SCRAP2 = 41, // metal waste
- OBJECT_SCRAP3 = 42, // metal waste
- OBJECT_SCRAP4 = 43, // plastic waste
- OBJECT_SCRAP5 = 44, // plastic waste
- OBJECT_MARKPOWER = 50, // mark underground energy source
- OBJECT_MARKSTONE = 51, // mark underground ore
- OBJECT_MARKURANIUM = 52, // mark underground uranium
- OBJECT_MARKKEYa = 53, // mark underground key
- OBJECT_MARKKEYb = 54, // mark underground key
- OBJECT_MARKKEYc = 55, // mark underground key
- OBJECT_MARKKEYd = 56, // mark underground key
- OBJECT_BOMB = 60, // bomb
- OBJECT_WINFIRE = 61, // fireworks
- OBJECT_SHOW = 62, // shows a place
- OBJECT_BAG = 63, // survival bag
- OBJECT_PLANT0 = 70, // plant 0
- OBJECT_PLANT1 = 71, // plant 1
- OBJECT_PLANT2 = 72, // plant 2
- OBJECT_PLANT3 = 73, // plant 3
- OBJECT_PLANT4 = 74, // plant 4
- OBJECT_PLANT5 = 75, // plant 5
- OBJECT_PLANT6 = 76, // plant 6
- OBJECT_PLANT7 = 77, // plant 7
- OBJECT_PLANT8 = 78, // plant 8
- OBJECT_PLANT9 = 79, // plant 9
- OBJECT_PLANT10 = 80, // plant 10
- OBJECT_PLANT11 = 81, // plant 11
- OBJECT_PLANT12 = 82, // plant 12
- OBJECT_PLANT13 = 83, // plant 13
- OBJECT_PLANT14 = 84, // plant 14
- OBJECT_PLANT15 = 85, // plant 15
- OBJECT_PLANT16 = 86, // plant 16
- OBJECT_PLANT17 = 87, // plant 17
- OBJECT_PLANT18 = 88, // plant 18
- OBJECT_PLANT19 = 89, // plant 19
- OBJECT_TREE0 = 90, // tree 0
- OBJECT_TREE1 = 91, // tree 1
- OBJECT_TREE2 = 92, // tree 2
- OBJECT_TREE3 = 93, // tree 3
- OBJECT_TREE4 = 94, // tree 4
- OBJECT_TREE5 = 95, // tree 5
- OBJECT_TREE6 = 96, // tree 6
- OBJECT_TREE7 = 97, // tree 7
- OBJECT_TREE8 = 98, // tree 8
- OBJECT_TREE9 = 99, // tree 9
- OBJECT_MOBILEwt = 100, // wheel-trainer
- OBJECT_MOBILEtt = 101, // track-trainer
- OBJECT_MOBILEft = 102, // fly-trainer
- OBJECT_MOBILEit = 103, // insect-trainer
- OBJECT_MOBILEwa = 110, // wheel-arm
- OBJECT_MOBILEta = 111, // track-arm
- OBJECT_MOBILEfa = 112, // fly-arm
- OBJECT_MOBILEia = 113, // insect-arm
- OBJECT_MOBILEwc = 120, // wheel-cannon
- OBJECT_MOBILEtc = 121, // track-cannon
- OBJECT_MOBILEfc = 122, // fly-cannon
- OBJECT_MOBILEic = 123, // insect-cannon
- OBJECT_MOBILEwi = 130, // wheel-insect-cannon
- OBJECT_MOBILEti = 131, // track-insect-cannon
- OBJECT_MOBILEfi = 132, // fly-insect-cannon
- OBJECT_MOBILEii = 133, // insect-insect-cannon
- OBJECT_MOBILEws = 140, // wheel-search
- OBJECT_MOBILEts = 141, // track-search
- OBJECT_MOBILEfs = 142, // fly-search
- OBJECT_MOBILEis = 143, // insect-search
- OBJECT_MOBILErt = 200, // roller-terraform
- OBJECT_MOBILErc = 201, // roller-canon
- OBJECT_MOBILErr = 202, // roller-recover
- OBJECT_MOBILErs = 203, // roller-shield
- OBJECT_MOBILEsa = 210, // submarine
- OBJECT_MOBILEtg = 211, // training target
- OBJECT_MOBILEdr = 212, // robot drawing
- OBJECT_WAYPOINT = 250, // waypoint
- OBJECT_FLAGb = 260, // blue flag
- OBJECT_FLAGr = 261, // red flag
- OBJECT_FLAGg = 262, // green flag
- OBJECT_FLAGy = 263, // yellow flag
- OBJECT_FLAGv = 264, // violet flag
- OBJECT_KEYa = 270, // key a
- OBJECT_KEYb = 271, // key b
- OBJECT_KEYc = 272, // key c
- OBJECT_KEYd = 273, // key d
- OBJECT_HUMAN = 300, // human
- OBJECT_TOTO = 301, // toto
- OBJECT_TECH = 302, // technician
- OBJECT_BARRIER0 = 400, // barrier
- OBJECT_BARRIER1 = 401, // barrier
- OBJECT_BARRIER2 = 402, // barrier
- OBJECT_BARRIER3 = 403, // barrier
- OBJECT_BARRIER4 = 404, // barrier
- OBJECT_MOTHER = 500, // insect queen
- OBJECT_EGG = 501, // egg
- OBJECT_ANT = 502, // ant
- OBJECT_SPIDER = 503, // spider
- OBJECT_BEE = 504, // bee
- OBJECT_WORM = 505, // worm
- OBJECT_RUINmobilew1 = 600, // ruin 1
- OBJECT_RUINmobilew2 = 601, // ruin 1
- OBJECT_RUINmobilet1 = 602, // ruin 2
- OBJECT_RUINmobilet2 = 603, // ruin 2
- OBJECT_RUINmobiler1 = 604, // ruin 3
- OBJECT_RUINmobiler2 = 605, // ruin 3
- OBJECT_RUINfactory = 606, // ruin 4
- OBJECT_RUINdoor = 607, // ruin 5
- OBJECT_RUINsupport = 608, // ruin 6
- OBJECT_RUINradar = 609, // ruin 7
- OBJECT_RUINconvert = 610, // ruin 8
- OBJECT_RUINbase = 611, // ruin 9
- OBJECT_RUINhead = 612, // ruin 10
- OBJECT_TEEN0 = 620, // toy
- OBJECT_TEEN1 = 621, // toy
- OBJECT_TEEN2 = 622, // toy
- OBJECT_TEEN3 = 623, // toy
- OBJECT_TEEN4 = 624, // toy
- OBJECT_TEEN5 = 625, // toy
- OBJECT_TEEN6 = 626, // toy
- OBJECT_TEEN7 = 627, // toy
- OBJECT_TEEN8 = 628, // toy
- OBJECT_TEEN9 = 629, // toy
- OBJECT_TEEN10 = 630, // toy
- OBJECT_TEEN11 = 631, // toy
- OBJECT_TEEN12 = 632, // toy
- OBJECT_TEEN13 = 633, // toy
- OBJECT_TEEN14 = 634, // toy
- OBJECT_TEEN15 = 635, // toy
- OBJECT_TEEN16 = 636, // toy
- OBJECT_TEEN17 = 637, // toy
- OBJECT_TEEN18 = 638, // toy
- OBJECT_TEEN19 = 639, // toy
- OBJECT_TEEN20 = 640, // toy
- OBJECT_TEEN21 = 641, // toy
- OBJECT_TEEN22 = 642, // toy
- OBJECT_TEEN23 = 643, // toy
- OBJECT_TEEN24 = 644, // toy
- OBJECT_TEEN25 = 645, // toy
- OBJECT_TEEN26 = 646, // toy
- OBJECT_TEEN27 = 647, // toy
- OBJECT_TEEN28 = 648, // toy
- OBJECT_TEEN29 = 649, // toy
- OBJECT_TEEN30 = 650, // toy
- OBJECT_TEEN31 = 651, // toy
- OBJECT_TEEN32 = 652, // toy
- OBJECT_TEEN33 = 653, // toy
- OBJECT_TEEN34 = 654, // toy
- OBJECT_TEEN35 = 655, // toy
- OBJECT_TEEN36 = 656, // toy
- OBJECT_TEEN37 = 657, // toy
- OBJECT_TEEN38 = 658, // toy
- OBJECT_TEEN39 = 659, // toy
- OBJECT_TEEN40 = 660, // toy
- OBJECT_TEEN41 = 661, // toy
- OBJECT_TEEN42 = 662, // toy
- OBJECT_TEEN43 = 663, // toy
- OBJECT_TEEN44 = 664, // toy
- OBJECT_TEEN45 = 665, // toy
- OBJECT_TEEN46 = 666, // toy
- OBJECT_TEEN47 = 667, // toy
- OBJECT_TEEN48 = 668, // toy
- OBJECT_TEEN49 = 669, // toy
- OBJECT_QUARTZ0 = 700, // crystal 0
- OBJECT_QUARTZ1 = 701, // crystal 1
- OBJECT_QUARTZ2 = 702, // crystal 2
- OBJECT_QUARTZ3 = 703, // crystal 3
- OBJECT_QUARTZ4 = 704, // crystal 4
- OBJECT_QUARTZ5 = 705, // crystal 5
- OBJECT_QUARTZ6 = 706, // crystal 6
- OBJECT_QUARTZ7 = 707, // crystal 7
- OBJECT_QUARTZ8 = 708, // crystal 8
- OBJECT_QUARTZ9 = 709, // crystal 9
- OBJECT_ROOT0 = 710, // root 0
- OBJECT_ROOT1 = 711, // root 1
- OBJECT_ROOT2 = 712, // root 2
- OBJECT_ROOT3 = 713, // root 3
- OBJECT_ROOT4 = 714, // root 4
- OBJECT_ROOT5 = 715, // root 5
- OBJECT_ROOT6 = 716, // root 6
- OBJECT_ROOT7 = 717, // root 7
- OBJECT_ROOT8 = 718, // root 8
- OBJECT_ROOT9 = 719, // root 9
- OBJECT_SEAWEED0 = 720, // seaweed 0
- OBJECT_SEAWEED1 = 721, // seaweed 1
- OBJECT_SEAWEED2 = 722, // seaweed 2
- OBJECT_SEAWEED3 = 723, // seaweed 3
- OBJECT_SEAWEED4 = 724, // seaweed 4
- OBJECT_SEAWEED5 = 725, // seaweed 5
- OBJECT_SEAWEED6 = 726, // seaweed 6
- OBJECT_SEAWEED7 = 727, // seaweed 7
- OBJECT_SEAWEED8 = 728, // seaweed 8
- OBJECT_SEAWEED9 = 729, // seaweed 9
- OBJECT_MUSHROOM0 = 730, // mushroom 0
- OBJECT_MUSHROOM1 = 731, // mushroom 1
- OBJECT_MUSHROOM2 = 732, // mushroom 2
- OBJECT_MUSHROOM3 = 733, // mushroom 3
- OBJECT_MUSHROOM4 = 734, // mushroom 4
- OBJECT_MUSHROOM5 = 735, // mushroom 5
- OBJECT_MUSHROOM6 = 736, // mushroom 6
- OBJECT_MUSHROOM7 = 737, // mushroom 7
- OBJECT_MUSHROOM8 = 738, // mushroom 8
- OBJECT_MUSHROOM9 = 739, // mushroom 9
- OBJECT_APOLLO1 = 900, // apollo lem
- OBJECT_APOLLO2 = 901, // apollo jeep
- OBJECT_APOLLO3 = 902, // apollo flag
- OBJECT_APOLLO4 = 903, // apollo module
- OBJECT_APOLLO5 = 904, // apollo antenna
- OBJECT_HOME1 = 910, // home 1
- OBJECT_MAX = 1000,
-};
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 82eac2b..1da4587 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -14,8 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// robotmain.cpp
-
#include "object/robotmain.h"
@@ -878,7 +876,7 @@ void CRobotMain::SetDefaultInputBindings()
{
for (int i = 0; i < INPUT_SLOT_MAX; i++)
{
- m_inputBindings[i].key = m_inputBindings[i].joy = KEY_INVALID;
+ m_inputBindings[i].primary = m_inputBindings[i].secondary = KEY_INVALID;
}
for (int i = 0; i < JOY_AXIS_SLOT_MAX; i++)
@@ -887,34 +885,34 @@ void CRobotMain::SetDefaultInputBindings()
m_joyAxisBindings[i].invert = false;
}
- m_inputBindings[INPUT_SLOT_LEFT ].key = KEY(LEFT);
- m_inputBindings[INPUT_SLOT_RIGHT ].key = KEY(RIGHT);
- m_inputBindings[INPUT_SLOT_UP ].key = KEY(UP);
- m_inputBindings[INPUT_SLOT_DOWN ].key = KEY(DOWN);
- m_inputBindings[INPUT_SLOT_GUP ].key = VIRTUAL_KMOD(SHIFT);
- m_inputBindings[INPUT_SLOT_GDOWN ].key = VIRTUAL_KMOD(CTRL);
- m_inputBindings[INPUT_SLOT_CAMERA ].key = KEY(SPACE);
- m_inputBindings[INPUT_SLOT_CAMERA ].joy = VIRTUAL_JOY(2);
- m_inputBindings[INPUT_SLOT_DESEL ].key = KEY(KP0);
- m_inputBindings[INPUT_SLOT_DESEL ].joy = VIRTUAL_JOY(6);
- m_inputBindings[INPUT_SLOT_ACTION ].key = KEY(RETURN);
- m_inputBindings[INPUT_SLOT_ACTION ].joy = VIRTUAL_JOY(1);
- m_inputBindings[INPUT_SLOT_NEAR ].key = KEY(KP_PLUS);
- m_inputBindings[INPUT_SLOT_NEAR ].joy = VIRTUAL_JOY(5);
- m_inputBindings[INPUT_SLOT_AWAY ].key = KEY(KP_MINUS);
- m_inputBindings[INPUT_SLOT_AWAY ].joy = VIRTUAL_JOY(4);
- m_inputBindings[INPUT_SLOT_NEXT ].key = KEY(TAB);
- m_inputBindings[INPUT_SLOT_NEXT ].joy = VIRTUAL_JOY(3);
- m_inputBindings[INPUT_SLOT_HUMAN ].key = KEY(HOME);
- m_inputBindings[INPUT_SLOT_HUMAN ].joy = VIRTUAL_JOY(7);
- m_inputBindings[INPUT_SLOT_QUIT ].key = KEY(ESCAPE);
- m_inputBindings[INPUT_SLOT_HELP ].key = KEY(F1);
- m_inputBindings[INPUT_SLOT_PROG ].key = KEY(F2);
- m_inputBindings[INPUT_SLOT_CBOT ].key = KEY(F3);
- m_inputBindings[INPUT_SLOT_VISIT ].key = KEY(KP_PERIOD);
- m_inputBindings[INPUT_SLOT_SPEED10].key = KEY(F4);
- m_inputBindings[INPUT_SLOT_SPEED15].key = KEY(F5);
- m_inputBindings[INPUT_SLOT_SPEED20].key = KEY(F6);
+ m_inputBindings[INPUT_SLOT_LEFT ].primary = KEY(LEFT);
+ m_inputBindings[INPUT_SLOT_RIGHT ].primary = KEY(RIGHT);
+ m_inputBindings[INPUT_SLOT_UP ].primary = KEY(UP);
+ m_inputBindings[INPUT_SLOT_DOWN ].primary = KEY(DOWN);
+ m_inputBindings[INPUT_SLOT_GUP ].primary = VIRTUAL_KMOD(SHIFT);
+ m_inputBindings[INPUT_SLOT_GDOWN ].primary = VIRTUAL_KMOD(CTRL);
+ m_inputBindings[INPUT_SLOT_CAMERA ].primary = KEY(SPACE);
+ m_inputBindings[INPUT_SLOT_CAMERA ].secondary = VIRTUAL_JOY(2);
+ m_inputBindings[INPUT_SLOT_DESEL ].primary = KEY(KP0);
+ m_inputBindings[INPUT_SLOT_DESEL ].secondary = VIRTUAL_JOY(6);
+ m_inputBindings[INPUT_SLOT_ACTION ].primary = KEY(RETURN);
+ m_inputBindings[INPUT_SLOT_ACTION ].secondary = VIRTUAL_JOY(1);
+ m_inputBindings[INPUT_SLOT_NEAR ].primary = KEY(KP_PLUS);
+ m_inputBindings[INPUT_SLOT_NEAR ].secondary = VIRTUAL_JOY(5);
+ m_inputBindings[INPUT_SLOT_AWAY ].primary = KEY(KP_MINUS);
+ m_inputBindings[INPUT_SLOT_AWAY ].secondary = VIRTUAL_JOY(4);
+ m_inputBindings[INPUT_SLOT_NEXT ].primary = KEY(TAB);
+ m_inputBindings[INPUT_SLOT_NEXT ].secondary = VIRTUAL_JOY(3);
+ m_inputBindings[INPUT_SLOT_HUMAN ].primary = KEY(HOME);
+ m_inputBindings[INPUT_SLOT_HUMAN ].secondary = VIRTUAL_JOY(7);
+ m_inputBindings[INPUT_SLOT_QUIT ].primary = KEY(ESCAPE);
+ m_inputBindings[INPUT_SLOT_HELP ].primary = KEY(F1);
+ m_inputBindings[INPUT_SLOT_PROG ].primary = KEY(F2);
+ m_inputBindings[INPUT_SLOT_CBOT ].primary = KEY(F3);
+ m_inputBindings[INPUT_SLOT_VISIT ].primary = KEY(KP_PERIOD);
+ m_inputBindings[INPUT_SLOT_SPEED10].primary = KEY(F4);
+ m_inputBindings[INPUT_SLOT_SPEED15].primary = KEY(F5);
+ m_inputBindings[INPUT_SLOT_SPEED20].primary = KEY(F6);
m_joyAxisBindings[JOY_AXIS_SLOT_X].axis = 0;
m_joyAxisBindings[JOY_AXIS_SLOT_Y].axis = 1;
@@ -1051,7 +1049,7 @@ void CRobotMain::ChangePhase(Phase phase)
dim.y = 18.0f/480.0f;
pos.x = 50.0f/640.0f;
pos.y = 452.0f/480.0f;
- Ui::CEdit* pe = dynamic_cast<Ui::CEdit*>(m_interface->CreateEdit(pos, dim, 0, EVENT_CMD));
+ Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->CreateEdit(pos, dim, 0, EVENT_CMD));
if (pe == nullptr) return;
pe->ClearState(Ui::STATE_VISIBLE);
m_cmdEdit = false; // hidden for now
@@ -1214,33 +1212,33 @@ bool CRobotMain::EventProcess(Event &event)
if (event.type == EVENT_KEY_DOWN)
{
- if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).key) m_keyMotion.y = 1.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).joy) m_keyMotion.y = 1.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).key) m_keyMotion.y = -1.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).joy) m_keyMotion.y = -1.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).key) m_keyMotion.x = -1.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).joy) m_keyMotion.x = -1.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).key) m_keyMotion.x = 1.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).joy) m_keyMotion.x = 1.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).key) m_keyMotion.z = 1.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).joy) m_keyMotion.z = 1.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).key) m_keyMotion.z = -1.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).joy) m_keyMotion.z = -1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).primary) m_keyMotion.y = 1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).secondary) m_keyMotion.y = 1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).primary) m_keyMotion.y = -1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).secondary) m_keyMotion.y = -1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).primary) m_keyMotion.x = -1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).secondary) m_keyMotion.x = -1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).primary) m_keyMotion.x = 1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).secondary) m_keyMotion.x = 1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).primary) m_keyMotion.z = 1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).secondary) m_keyMotion.z = 1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).primary) m_keyMotion.z = -1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).secondary) m_keyMotion.z = -1.0f;
}
else if (event.type == EVENT_KEY_UP)
{
- if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).key) m_keyMotion.y = 0.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).joy) m_keyMotion.y = 0.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).key) m_keyMotion.y = 0.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).joy) m_keyMotion.y = 0.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).key) m_keyMotion.x = 0.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).joy) m_keyMotion.x = 0.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).key) m_keyMotion.x = 0.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).joy) m_keyMotion.x = 0.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).key) m_keyMotion.z = 0.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).joy) m_keyMotion.z = 0.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).key) m_keyMotion.z = 0.0f;
- if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).joy) m_keyMotion.z = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).primary) m_keyMotion.y = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).secondary) m_keyMotion.y = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).primary) m_keyMotion.y = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).secondary) m_keyMotion.y = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).primary) m_keyMotion.x = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).secondary) m_keyMotion.x = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).primary) m_keyMotion.x = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).secondary) m_keyMotion.x = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).primary) m_keyMotion.z = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).secondary) m_keyMotion.z = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).primary) m_keyMotion.z = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).secondary) m_keyMotion.z = 0.0f;
}
else if (event.type == EVENT_JOY_AXIS)
{
@@ -1304,7 +1302,7 @@ bool CRobotMain::EventProcess(Event &event)
event.type == EVENT_KEY_DOWN &&
event.key.key == KEY(PAUSE)) // Pause ?
{
- Ui::CEdit* pe = dynamic_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
+ Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
if (pe == nullptr) return false;
pe->SetState(Ui::STATE_VISIBLE);
pe->SetFocus(true);
@@ -1316,7 +1314,7 @@ bool CRobotMain::EventProcess(Event &event)
event.key.key == KEY(RETURN) && m_cmdEdit)
{
char cmd[50];
- Ui::CEdit* pe = dynamic_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
+ Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
if (pe == nullptr) return false;
pe->GetText(cmd, 50);
pe->SetText("");
@@ -1356,10 +1354,10 @@ bool CRobotMain::EventProcess(Event &event)
if (event.type == EVENT_KEY_DOWN)
{
- if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy ||
- event.key.key == GetInputBinding(INPUT_SLOT_PROG).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy ||
+ if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_HELP).secondary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_PROG).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_PROG).secondary ||
event.key.key == KEY(ESCAPE))
{
StopDisplayInfo();
@@ -1394,14 +1392,14 @@ bool CRobotMain::EventProcess(Event &event)
}
if (m_editLock) // current edition?
{
- if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_HELP).secondary)
{
StartDisplayInfo(SATCOM_HUSTON, false);
return false;
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_PROG).secondary)
{
StartDisplayInfo(SATCOM_PROG, false);
return false;
@@ -1410,8 +1408,8 @@ bool CRobotMain::EventProcess(Event &event)
}
if (m_movieLock) // current movie?
{
- if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy ||
+ if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_QUIT).secondary ||
event.key.key == KEY(ESCAPE))
{
AbortMovie();
@@ -1420,21 +1418,21 @@ bool CRobotMain::EventProcess(Event &event)
}
if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT)
{
- if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_VISIT).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_VISIT).secondary)
{
StartDisplayVisit(EVENT_NULL);
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy ||
+ if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_QUIT).secondary ||
event.key.key == KEY(ESCAPE))
{
StopDisplayVisit();
}
return false;
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_QUIT).secondary)
{
if (m_movie->IsExist())
StartDisplayInfo(SATCOM_HUSTON, false);
@@ -1454,55 +1452,55 @@ bool CRobotMain::EventProcess(Event &event)
ChangePause(!m_engine->GetPause());
}
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).secondary)
{
ChangeCamera();
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_DESEL).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_DESEL).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_DESEL).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_DESEL).secondary)
{
if (m_shortCut)
DeselectObject();
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).secondary)
{
SelectHuman();
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_NEXT).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_NEXT).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_NEXT).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_NEXT).secondary)
{
if (m_shortCut)
m_short->SelectNext();
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_HELP).secondary)
{
StartDisplayInfo(SATCOM_HUSTON, true);
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_PROG).secondary)
{
StartDisplayInfo(SATCOM_PROG, true);
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_VISIT).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_VISIT).secondary)
{
StartDisplayVisit(EVENT_NULL);
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).secondary)
{
SetSpeed(1.0f);
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).secondary)
{
SetSpeed(1.5f);
}
- if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).key ||
- event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).joy)
+ if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).primary ||
+ event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).secondary)
{
SetSpeed(2.0f);
}
@@ -1956,6 +1954,17 @@ void CRobotMain::ExecuteCmd(char *cmd)
return;
}
+ if (strcmp(cmd, "speed4") == 0) {
+ SetSpeed(4.0f);
+ UpdateSpeedLabel();
+ return;
+ }
+ if (strcmp(cmd, "speed8") == 0) {
+ SetSpeed(8.0f);
+ UpdateSpeedLabel();
+ return;
+ }
+
if (m_phase == PHASE_SIMUL)
m_displayText->DisplayError(ERR_CMD, Math::Vector(0.0f,0.0f,0.0f));
}
@@ -2030,7 +2039,7 @@ void CRobotMain::StartDisplayInfo(const char *filename, int index)
m_sound->MuteAll(true);
}
- Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
+ Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
if (pb != nullptr)
{
pb->ClearState(Ui::STATE_VISIBLE);
@@ -2062,7 +2071,7 @@ void CRobotMain::StopDisplayInfo()
if (!m_editLock)
{
- Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
+ Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
if (pb != nullptr)
pb->SetState(Ui::STATE_VISIBLE);
@@ -2103,7 +2112,7 @@ void CRobotMain::StartSuspend()
m_infoObject = DeselectAll(); // removes the control buttons
m_displayText->HideText(true);
- Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
+ Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
if (pb != nullptr)
pb->ClearState(Ui::STATE_VISIBLE);
@@ -2113,7 +2122,7 @@ void CRobotMain::StartSuspend()
//! End of dialogue during the game
void CRobotMain::StopSuspend()
{
- Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
+ Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
if (pb != nullptr)
pb->SetState(Ui::STATE_VISIBLE);
@@ -2220,7 +2229,7 @@ void CRobotMain::StartDisplayVisit(EventType event)
{
if (m_editLock) return;
- Ui::CWindow* pw = dynamic_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
+ Ui::CWindow* pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if (pw == nullptr) return;
if (event == EVENT_NULL) // visit by keyboard shortcut?
@@ -2237,10 +2246,10 @@ void CRobotMain::StartDisplayVisit(EventType event)
i --;
if (i < 0) i = Ui::MAXDTLINE-1;
- Ui::CButton* button = dynamic_cast<Ui::CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_VISIT0+i)));
+ Ui::CButton* button = static_cast<Ui::CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_VISIT0+i)));
if (button == nullptr || !button->TestState(Ui::STATE_ENABLE)) continue;
- Ui::CGroup* group = dynamic_cast<Ui::CGroup*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_GROUP0+i)));
+ Ui::CGroup* group = static_cast<Ui::CGroup*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_GROUP0+i)));
if (group != nullptr)
{
event = static_cast<EventType>(EVENT_DT_VISIT0+i);
@@ -2442,7 +2451,7 @@ void CRobotMain::SelectOneObject(CObject* obj, bool displayError)
CObject* toto = SearchToto();
if (toto != nullptr)
{
- CMotionToto* mt = dynamic_cast<CMotionToto*>(toto->GetMotion());
+ CMotionToto* mt = static_cast<CMotionToto*>(toto->GetMotion());
if (mt != nullptr)
mt->SetLinkType(type);
}
@@ -2992,7 +3001,7 @@ void CRobotMain::CreateTooltip(Math::Point pos, const char* text)
m_interface->CreateWindows(pos, dim, 1, EVENT_TOOLTIP);
- Ui::CWindow* pw = dynamic_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_TOOLTIP));
+ Ui::CWindow* pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_TOOLTIP));
if (pw != nullptr)
{
pw->SetState(Ui::STATE_SHADOW);
@@ -3098,26 +3107,26 @@ void CRobotMain::KeyCamera(EventType type, unsigned int key)
if (type == EVENT_KEY_UP)
{
- if (key == GetInputBinding(INPUT_SLOT_LEFT).key ||
- key == GetInputBinding(INPUT_SLOT_LEFT).joy)
+ if (key == GetInputBinding(INPUT_SLOT_LEFT).primary ||
+ key == GetInputBinding(INPUT_SLOT_LEFT).secondary)
{
m_cameraPan = 0.0f;
}
- if (key == GetInputBinding(INPUT_SLOT_RIGHT).key ||
- key == GetInputBinding(INPUT_SLOT_RIGHT).joy)
+ if (key == GetInputBinding(INPUT_SLOT_RIGHT).primary ||
+ key == GetInputBinding(INPUT_SLOT_RIGHT).secondary)
{
m_cameraPan = 0.0f;
}
- if (key == GetInputBinding(INPUT_SLOT_UP).key ||
- key == GetInputBinding(INPUT_SLOT_UP).joy)
+ if (key == GetInputBinding(INPUT_SLOT_UP).primary ||
+ key == GetInputBinding(INPUT_SLOT_UP).secondary)
{
m_cameraZoom = 0.0f;
}
- if (key == GetInputBinding(INPUT_SLOT_DOWN).key ||
- key == GetInputBinding(INPUT_SLOT_DOWN).joy)
+ if (key == GetInputBinding(INPUT_SLOT_DOWN).primary ||
+ key == GetInputBinding(INPUT_SLOT_DOWN).secondary)
{
m_cameraZoom = 0.0f;
}
@@ -3133,26 +3142,26 @@ void CRobotMain::KeyCamera(EventType type, unsigned int key)
if (type == EVENT_KEY_DOWN)
{
- if (key == GetInputBinding(INPUT_SLOT_LEFT).key ||
- key == GetInputBinding(INPUT_SLOT_LEFT).joy)
+ if (key == GetInputBinding(INPUT_SLOT_LEFT).primary ||
+ key == GetInputBinding(INPUT_SLOT_LEFT).secondary)
{
m_cameraPan = -1.0f;
}
- if (key == GetInputBinding(INPUT_SLOT_RIGHT).key ||
- key == GetInputBinding(INPUT_SLOT_RIGHT).joy)
+ if (key == GetInputBinding(INPUT_SLOT_RIGHT).primary ||
+ key == GetInputBinding(INPUT_SLOT_RIGHT).secondary)
{
m_cameraPan = 1.0f;
}
- if (key == GetInputBinding(INPUT_SLOT_UP).key ||
- key == GetInputBinding(INPUT_SLOT_UP).joy)
+ if (key == GetInputBinding(INPUT_SLOT_UP).primary ||
+ key == GetInputBinding(INPUT_SLOT_UP).secondary)
{
m_cameraZoom = -1.0f;
}
- if (key == GetInputBinding(INPUT_SLOT_DOWN).key ||
- key == GetInputBinding(INPUT_SLOT_DOWN).joy)
+ if (key == GetInputBinding(INPUT_SLOT_DOWN).primary ||
+ key == GetInputBinding(INPUT_SLOT_DOWN).secondary)
{
m_cameraZoom = 1.0f;
}
@@ -3241,14 +3250,14 @@ bool CRobotMain::EventFrame(const Event &event)
m_planet->EventProcess(event);
Ui::CMap* pm = nullptr;
- Ui::CWindow* pw = dynamic_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ Ui::CWindow* pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if (pw == nullptr)
{
pm = nullptr;
}
else
{
- pm = dynamic_cast<Ui::CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ pm = static_cast<Ui::CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
if (pm != nullptr) pm->FlushObject();
}
@@ -5406,7 +5415,7 @@ void CRobotMain::FrameShowLimit(float rTime)
-//! Returns a pointer to the last backslash in a filename.
+//! Returns a pointer to the last slash in a filename.
char* SearchLastDir(char *filename)
{
char* p = filename;
@@ -6615,9 +6624,20 @@ void CRobotMain::ChangePause(bool pause)
//! Changes game speed
void CRobotMain::SetSpeed(float speed)
{
- // TODO: m_app->SetSimulationSpeed(speed);
+ m_app->SetSimulationSpeed(speed);
+ UpdateSpeedLabel();
+}
+
+float CRobotMain::GetSpeed()
+{
+ return m_app->GetSimulationSpeed();
+}
+
+void CRobotMain::UpdateSpeedLabel()
+{
+ Ui::CButton* pb = static_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_SPEED));
+ float speed = m_app->GetSimulationSpeed();
- Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_SPEED));
if (pb != nullptr)
{
if (speed == 1.0f)
@@ -6632,11 +6652,7 @@ void CRobotMain::SetSpeed(float speed)
pb->SetState(Ui::STATE_VISIBLE);
}
}
-}
-float CRobotMain::GetSpeed()
-{
- return m_app->GetSimulationSpeed();
}
diff --git a/src/object/robotmain.h b/src/object/robotmain.h
index 70fbc8d..cb0cd7f 100644
--- a/src/object/robotmain.h
+++ b/src/object/robotmain.h
@@ -14,10 +14,14 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// robotmain.h
+/**
+ * \file object/robotmain.h
+ * \brief CRobotMain - main class of Colobot game engine
+ */
#pragma once
+
#include "common/global.h"
#include "common/singleton.h"
@@ -148,12 +152,12 @@ const int SATCOM_MAX = 6;
*/
struct InputBinding
{
- //! Keyboard binding code (can be regular or virtual)
- unsigned int key;
- //! Joystick binding code (virtual)
- unsigned int joy;
+ //! Primary and secondary bindings
+ //! Can be regular key, virtual key or virtual joystick button
+ unsigned int primary, secondary;
- InputBinding() : key(KEY_INVALID), joy(KEY_INVALID) {}
+ InputBinding(unsigned int p = KEY_INVALID, unsigned int s = KEY_INVALID)
+ : primary(p), secondary(s) {}
};
/**
@@ -383,6 +387,7 @@ protected:
void StopDisplayVisit();
void ExecuteCmd(char *cmd);
bool TestGadgetQuantity(int rank);
+ void UpdateSpeedLabel();
protected:
CInstanceManager* m_iMan;
diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp
index a3c680b..f56f81d 100644
--- a/src/physics/physics.cpp
+++ b/src/physics/physics.cpp
@@ -14,29 +14,32 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// physics.cpp
+#include "physics/physics.h"
-#include <cstring>
-#include <cstdio>
-
-#include "math/geometry.h"
-#include "graphics/engine/engine.h"
-#include "common/global.h"
#include "common/event.h"
+#include "common/global.h"
#include "common/iman.h"
+
+#include "graphics/engine/camera.h"
+#include "graphics/engine/engine.h"
#include "graphics/engine/lightman.h"
+#include "graphics/engine/pyro.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
-#include "graphics/engine/camera.h"
-#include "graphics/engine/pyro.h"
-#include "script/cmdtoken.h"
-#include "physics/physics.h"
+
+#include "math/geometry.h"
+
#include "object/brain.h"
#include "object/motion/motion.h"
#include "object/motion/motionhuman.h"
#include "object/task/task.h"
+#include "script/cmdtoken.h"
+
+#include <cstring>
+#include <cstdio>
+
const float LANDING_SPEED = 3.0f;
diff --git a/src/physics/physics.h b/src/physics/physics.h
index e8a1f84..db88e8c 100644
--- a/src/physics/physics.h
+++ b/src/physics/physics.h
@@ -15,17 +15,18 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#pragma once
-
/**
* \file physics/physics.h
* \brief Responsible for physics "and more" in game
*/
+#pragma once
#include "common/global.h"
+
#include "object/object.h"
+
#include "math/vector.h"
diff --git a/src/plugins/plugininterface.h b/src/plugins/plugininterface.h
index 6554b44..838dbfd 100644
--- a/src/plugins/plugininterface.h
+++ b/src/plugins/plugininterface.h
@@ -14,17 +14,17 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// plugininterface.h
-
/**
- * @file plugin/plugininterface.h
- * @brief Generic plugin interface
+ * \file plugins/plugininterface.h
+ * \brief Generic plugin interface
*/
#pragma once
+
#include <string>
+
#define PLUGIN_INTERFACE(class_type) \
static class_type* Plugin##class_type; \
extern "C" void InstallPluginEntry() { Plugin##class_type = new class_type(); Plugin##class_type->InstallPlugin(); } \
@@ -37,29 +37,29 @@
/**
-* @class CPluginInterface
-*
-* @brief Generic plugin interface. All plugins that will be managed by plugin manager have to derive from this class.
-*
-*/
+ * \class CPluginInterface
+ *
+ * \brief Generic plugin interface. All plugins that will be managed by plugin manager have to derive from this class.
+ *
+ */
class CPluginInterface {
public:
/** Function to get plugin name or description
- * @return returns plugin name
+ * \return returns plugin name
*/
- inline virtual std::string PluginName() { return "abc"; };
+ inline virtual std::string PluginName() { return "abc"; }
/** Function to get plugin version. 1 means version 0.01, 2 means 0.02 etc.
- * @return number indicating plugin version
+ * \return number indicating plugin version
*/
- inline virtual int PluginVersion() { return 0; };
+ inline virtual int PluginVersion() { return 0; }
/** Function to initialize plugin
*/
- inline virtual void InstallPlugin() {};
+ inline virtual void InstallPlugin() {}
/** Function called before removing plugin
*/
- inline virtual bool UninstallPlugin(std::string &) { return true; };
+ inline virtual bool UninstallPlugin(std::string &) { return true; }
};
diff --git a/src/plugins/pluginloader.cpp b/src/plugins/pluginloader.cpp
index fd8ce74..bd0c8be 100644
--- a/src/plugins/pluginloader.cpp
+++ b/src/plugins/pluginloader.cpp
@@ -14,10 +14,8 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// pluginloader.cpp
-
-#include "pluginloader.h"
+#include "plugins/pluginloader.h"
CPluginLoader::CPluginLoader(std::string filename)
@@ -57,7 +55,7 @@ bool CPluginLoader::UnloadPlugin()
return true;
}
- bool (*uninstall)(std::string &) = (bool (*)(std::string &)) lt_dlsym(mHandle, "UninstallPluginEntry");
+ bool (*uninstall)(std::string &) = reinterpret_cast<bool (*)(std::string &)>( lt_dlsym(mHandle, "UninstallPluginEntry") );
if (!uninstall) {
GetLogger()->Error("Error getting UninstallPluginEntry for plugin %s: %s\n", mFilename.c_str(), lt_dlerror());
return false;
@@ -88,13 +86,13 @@ bool CPluginLoader::LoadPlugin()
return false;
}
- void (*install)() = (void (*)()) lt_dlsym(mHandle, "InstallPluginEntry");
+ void (*install)() = reinterpret_cast<void (*)()>( lt_dlsym(mHandle, "InstallPluginEntry") );
if (!install) {
GetLogger()->Error("Error getting InstallPluginEntry for plugin %s: %s\n", mFilename.c_str(), lt_dlerror());
return false;
}
- CPluginInterface* (*getInterface)() = (CPluginInterface* (*)()) lt_dlsym(mHandle, "GetPluginInterfaceEntry");
+ CPluginInterface* (*getInterface)() = reinterpret_cast<CPluginInterface* (*)()>( lt_dlsym(mHandle, "GetPluginInterfaceEntry") );
if (!getInterface) {
GetLogger()->Error("Error getting GetPluginInterfaceEntry for plugin %s: %s\n", mFilename.c_str(), lt_dlerror());
diff --git a/src/plugins/pluginloader.h b/src/plugins/pluginloader.h
index 3dfa20b..e8c2c73 100644
--- a/src/plugins/pluginloader.h
+++ b/src/plugins/pluginloader.h
@@ -14,68 +14,67 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// pluginloader.h
-
/**
- * @file plugin/pluginloader.h
- * @brief Plugin loader interface
+ * \file plugins/pluginloader.h
+ * \brief Plugin loader interface
*/
#pragma once
-#include <ltdl.h>
-#include <string>
#include "common/logger.h"
-#include "plugininterface.h"
+#include "plugins/plugininterface.h"
+
+#include <ltdl.h>
+#include <string>
/**
-* @class CPluginLoader
-*
-* @brief Plugin loader interface. Plugin manager uses this class to load plugins.
-*
-*/
+ * \class CPluginLoader
+ *
+ * \brief Plugin loader interface. Plugin manager uses this class to load plugins.
+ *
+ */
class CPluginLoader {
public:
/** Class contructor
- * @param std::string plugin filename
+ * \param filename plugin filename
*/
- CPluginLoader(std::string);
+ CPluginLoader(std::string filename);
/** Function to get plugin name or description
- * @return returns plugin name
+ * \return returns plugin name
*/
std::string GetName();
/** Function to get plugin version
- * @return returns plugin version
+ * \return returns plugin version
*/
int GetVersion();
/** Function to unload plugin
- * @return returns true on success
+ * \return returns true on success
*/
bool UnloadPlugin();
/** Function to load plugin
- * @return returns true on success
+ * \return returns true on success
*/
bool LoadPlugin();
/** Function to check if plugin is loaded
- * @return returns true if plugin is loaded
+ * \return returns true if plugin is loaded
*/
bool IsLoaded();
/** Function to set plugin filename
- * @return returns true on success. Action can fail if plugin was loaded and cannot be unloaded
+ * \return returns true on success. Action can fail if plugin was loaded and cannot be unloaded
*/
bool SetFilename(std::string);
/** Function to get plugin filename
- * @return returns plugin filename
+ * \return returns plugin filename
*/
std::string GetFilename();
diff --git a/src/plugins/pluginmanager.cpp b/src/plugins/pluginmanager.cpp
index 39d1d17..f4dbcdb 100644
--- a/src/plugins/pluginmanager.cpp
+++ b/src/plugins/pluginmanager.cpp
@@ -14,10 +14,8 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// pluginmanager.cpp
-
-#include "pluginmanager.h"
+#include "plugins/pluginmanager.h"
template<> CPluginManager* CSingleton<CPluginManager>::mInstance = nullptr;
diff --git a/src/plugins/pluginmanager.h b/src/plugins/pluginmanager.h
index 7a69820..2798483 100644
--- a/src/plugins/pluginmanager.h
+++ b/src/plugins/pluginmanager.h
@@ -14,33 +14,32 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// pluginmanager.h
-
/**
- * @file plugin/pluginmanager.h
- * @brief Plugin manager class.
+ * \file plugins/pluginmanager.h
+ * \brief Plugin manager class.
*/
#pragma once
-#include <string>
-#include <set>
-#include <vector>
#include "common/logger.h"
#include "common/profile.h"
#include "common/singleton.h"
-#include "pluginloader.h"
+#include "plugins/pluginloader.h"
+
+#include <string>
+#include <set>
+#include <vector>
/**
-* @class CPluginManager
-*
-* @brief Plugin manager class. Plugin manager can load plugins from colobot.ini or manually specified files.
-*
-*/
+ * \class CPluginManager
+ *
+ * \brief Plugin manager class. Plugin manager can load plugins from colobot.ini or manually specified files.
+ *
+ */
class CPluginManager : public CSingleton<CPluginManager> {
public:
CPluginManager();
@@ -51,31 +50,31 @@ class CPluginManager : public CSingleton<CPluginManager> {
void LoadFromProfile();
/** Function loads specified plugin
- * @param std::string plugin filename
- * @return returns true on success
+ * \param filename plugin filename
+ * \return returns true on success
*/
- bool LoadPlugin(std::string);
+ bool LoadPlugin(std::string filename);
/** Function unloads specified plugin
- * @param std::string plugin filename
- * @return returns true on success
+ * \param filename plugin filename
+ * \return returns true on success
*/
- bool UnloadPlugin(std::string);
+ bool UnloadPlugin(std::string filename);
/** Function adds path to be checked when searching for plugin file. If path was already added it will be ignored
- * @param std::string plugin search path
- * @return returns true on success
+ * \param dir plugin search path
+ * \return returns true on success
*/
- bool AddSearchDirectory(std::string);
+ bool AddSearchDirectory(std::string dir);
/** Function removes path from list
- * @param std::string plugin search path
- * @return returns true on success
+ * \param dir plugin search path
+ * \return returns true on success
*/
- bool RemoveSearchDirectory(std::string);
+ bool RemoveSearchDirectory(std::string dir);
/** Function tries to unload all plugins
- * @return returns true on success
+ * \return returns true on success
*/
bool UnloadAllPlugins();
diff --git a/src/script/cbottoken.h b/src/script/cbottoken.h
index 1f2d6e7..f5b7b70 100644
--- a/src/script/cbottoken.h
+++ b/src/script/cbottoken.h
@@ -14,7 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// cbottoken.h
+/**
+ * \file script/cbottoken.h
+ * \brief Functions to parse some CBot-related tokens
+ */
#pragma once
diff --git a/src/script/cmdtoken.h b/src/script/cmdtoken.h
index 812cec7..fe831f1 100644
--- a/src/script/cmdtoken.h
+++ b/src/script/cmdtoken.h
@@ -14,10 +14,14 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// cmdtoken.h
+/**
+ * \file script/cmdtoken.h
+ * \brief Functions to parse commands from level files
+ */
#pragma once
+
#include "graphics/engine/water.h"
#include "graphics/engine/engine.h"
#include "graphics/engine/pyro.h"
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 2d76ad3..8471df5 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -14,24 +14,30 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// script.cpp
-
#include "script/script.h"
+#include "app/app.h"
+
#include "common/global.h"
#include "common/iman.h"
#include "common/restext.h"
+
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
#include "graphics/engine/text.h"
+
#include "math/geometry.h"
#include "math/vector.h"
+
#include "object/object.h"
#include "object/robotmain.h"
#include "object/task/taskmanager.h"
+
#include "physics/physics.h"
+
#include "script/cbottoken.h"
+
#include "ui/interface.h"
#include "ui/edit.h"
#include "ui/list.h"
@@ -3646,20 +3652,18 @@ bool CScript::ReadScript(const char* filename)
{
FILE* file;
Ui::CEdit* edit;
+ std::string name;
- // TODO: local user dir
- std::string name = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, filename);
-
- /*if ( strchr(filename, '\\') == 0 )
+ if ( strchr(filename, '/') == 0 ) //we're reading non user script
{
- strcpy(name, "script\\");
- strcat(name, filename);
+ name = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, filename);
}
else
{
-//? strcpy(name, filename);
- UserDir(name, filename, "");
- }*/
+ name = filename;
+ //TODO: is this needed?
+ // UserDir(name, filename, "");
+ }
file = fopen(name.c_str(), "rb");
if ( file == NULL ) return false;
@@ -3682,22 +3686,20 @@ bool CScript::ReadScript(const char* filename)
bool CScript::WriteScript(const char* filename)
{
Ui::CEdit* edit;
+ std::string name;
- std::string name = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, filename);
- // TODO: local user dir
- /*if ( strchr(filename, '\\') == 0 )
+ if ( strchr(filename, '/') == 0 ) //we're writing non user script
{
- strcpy(name, "script\\");
- strcat(name, filename);
+ name = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, filename);
}
else
{
- strcpy(name, filename);
- }*/
+ name = filename;
+ }
if ( m_script == 0 )
{
- // TODO: ? remove(filename);
+ remove(filename);
return false;
}
diff --git a/src/script/script.h b/src/script/script.h
index 5c1118f..dbd66a2 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -14,16 +14,20 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// script.h
+/**
+ * \file script/script.h
+ * \brief CBot script runner
+ */
#pragma once
-#include <stdio.h>
-
#include "common/event.h"
+
#include "CBot/CBotDll.h"
+#include <stdio.h>
+
class CInstanceManager;
class CObject;
diff --git a/src/sound/sound.h b/src/sound/sound.h
index 1f3fea9..c2b890f 100644
--- a/src/sound/sound.h
+++ b/src/sound/sound.h
@@ -15,15 +15,14 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// sound.h
-
/**
- * @file sound/sound.h
- * @brief Sound plugin interface
+ * \file sound/sound.h
+ * \brief Sound plugin interface
*/
#pragma once
+
#include "math/vector.h"
#include "common/iman.h"
@@ -136,8 +135,7 @@ enum Sound
/**
- * \public
- * \enum SoundNext sound/sound.h
+ * \enum SoundNext
* \brief Enum representing operation that will be performend on a sound at given time
**/
enum SoundNext
@@ -149,9 +147,9 @@ enum SoundNext
/**
-* @class CSoundInterface
+* \class CSoundInterface
*
-* @brief Sound plugin interface
+* \brief Sound plugin interface
*
*/
class CSoundInterface : public CPluginInterface
@@ -164,7 +162,7 @@ class CSoundInterface : public CPluginInterface
inline virtual ~CSoundInterface() {};
/** Function to initialize sound device
- * @param bool b3D - enable support for 3D sound
+ * \param b3D - enable support for 3D sound
*/
inline virtual bool Create(bool b3D) { return true; };
@@ -182,133 +180,133 @@ class CSoundInterface : public CPluginInterface
/** Function called to cache sound effect file.
* This function is called by plugin interface for each file.
- * @param Sound bSound - id of a file, will be used to identify sound files
- * @param std::string bFile - file to load
- * @return return true on success
+ * \param bSound - id of a file, will be used to identify sound files
+ * \param bFile - file to load
+ * \return return true on success
*/
inline virtual bool Cache(Sound bSound, std::string bFile) { return true; };
- /** Geturn if plugin is enabled
- * @return return true if plugin is enabled
+ /** Return if plugin is enabled
+ * \return return true if plugin is enabled
*/
inline virtual bool GetEnable() {return true;};
/** Change sound mode to 2D/3D
- * @param bool bMode - true to enable 3D sound
+ * \param bMode - true to enable 3D sound
*/
inline virtual void SetSound3D(bool bMode) {};
- /** Geturn if we use 3D sound
- * @return true if we have 3D sound enabled
+ /** Return if we use 3D sound
+ * \return true if we have 3D sound enabled
*/
inline virtual bool GetSound3D() {return true;};
- /** Geturn if we have 3D sound capable card
- * @return true for 3D sound support
+ /** Return if we have 3D sound capable card
+ * \return true for 3D sound support
*/
inline virtual bool GetSound3DCap() {return true;};
/** Change global sound volume
- * @param int volume - range from 0 to MAXVOLUME
+ * \param volume - range from 0 to MAXVOLUME
*/
inline virtual void SetAudioVolume(int volume) {};
- /** Geturn global sound volume
- * @return global volume as int in range from 0 to MAXVOLUME
+ /** Return global sound volume
+ * \return global volume as int in range from 0 to MAXVOLUME
*/
inline virtual int GetAudioVolume() {return 0;};
/** Set music volume
- * @param int volume - range from 0 to MAXVOLUME
+ * \param volume - range from 0 to MAXVOLUME
*/
inline virtual void SetMusicVolume(int volume) {};
- /** Geturn music volume
- * @return music volume as int in range from 0 to MAXVOLUME
+ /** Return music volume
+ * \return music volume as int in range from 0 to MAXVOLUME
*/
inline virtual int GetMusicVolume() {return 0;};
/** Set listener position
- * @param Math::Vector eye - position of listener
- * @param Math::Vector lookat - direction listener is looking at
+ * \param eye - position of listener
+ * \param lookat - direction listener is looking at
*/
inline virtual void SetListener(Math::Vector eye, Math::Vector lookat) {};
/** Update data each frame
- * @param float rTime - time since last update
+ * \param rTime - time since last update
*/
inline virtual void FrameMove(float rTime) {};
/** Play specific sound
- * @param Sound sound - sound to play
- * @param float amplitude - change amplitude of sound before playing
- * @param float frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
- * @param bool bLoop - loop sound
- * @return identifier of channel that sound will be played on
+ * \param sound - sound to play
+ * \param amplitude - change amplitude of sound before playing
+ * \param frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
+ * \param bLoop - loop sound
+ * \return identifier of channel that sound will be played on
*/
inline virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) {return 0;};
/** Play specific sound
- * @param Sound sound - sound to play
- * @param Math:Vector pos - position of sound in space
- * @param float amplitude - change amplitude of sound before playing
- * @param float frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
- * @param bool bLoop - loop sound
- * @return identifier of channel that sound will be played on
+ * \param sound - sound to play
+ * \param pos - position of sound in space
+ * \param amplitude - change amplitude of sound before playing
+ * \param frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
+ * \param bLoop - loop sound
+ * \return identifier of channel that sound will be played on
*/
inline virtual int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) {return 0;};
/** Remove all operations that would be made on sound in channel.
- * @param int channel - channel to work on
- * @return return true on success
+ * \param channel - channel to work on
+ * \return return true on success
*/
inline virtual bool FlushEnvelope(int channel) {return true;};
/** Add envelope to sound. Envelope is a operatino that will be performend on sound in future like changing frequency
- * @param int channel - channel to work on
- * @param float amplitude - change amplitude
- * @param float frequency - change frequency
- * @param float time - when to change (sample time)
- * @param SoundNext oper - operation to perform
- * @return return true on success
+ * \param channel - channel to work on
+ * \param amplitude - change amplitude
+ * \param frequency - change frequency
+ * \param time - when to change (sample time)
+ * \param oper - operation to perform
+ * \return return true on success
*/
inline virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) {return true;};
/** Set sound position in space
- * @param int channel - channel to work on
- * @param Math::Vector pos - new positino of a sound
- * @return return true on success
+ * \param channel - channel to work on
+ * \param pos - new positino of a sound
+ * \return return true on success
*/
inline virtual bool Position(int channel, Math::Vector pos) {return true;};
/** Set sound frequency
- * @param int channel - channel to work on
- * @param float frequency - change sound frequency
- * @return return true on success
+ * \param channel - channel to work on
+ * \param frequency - change sound frequency
+ * \return return true on success
*/
inline virtual bool Frequency(int channel, float frequency) {return true;};
/** Stop playing sound
- * @param int channel - channel to work on
- * @return return true on success
+ * \param channel - channel to work on
+ * \return return true on success
*/
inline virtual bool Stop(int channel) {return true;};
/** Stop playing all sounds
- * @return return true on success
+ * \return return true on success
*/
inline virtual bool StopAll() {return true;};
/** Mute/unmute all sounds
- * @param bool bMute
- * @return return true on success
+ * \param bMute
+ * \return return true on success
*/
inline virtual bool MuteAll(bool bMute) {return true;};
/** Start playing music
- * @param int rank - track number
- * @param bool bRepeat - repeat playing
- * @return return true on success
+ * \param rank - track number
+ * \param bRepeat - repeat playing
+ * \return return true on success
*/
inline virtual bool PlayMusic(int rank, bool bRepeat) {return true;};
@@ -318,17 +316,17 @@ class CSoundInterface : public CPluginInterface
inline virtual bool RestartMusic() {return true;};
/** Susspend paying music
- * @return return true on success
+ * \return return true on success
*/
inline virtual void SuspendMusic() {};
/** Stop playing music
- * @return return true on success
+ * \return return true on success
*/
inline virtual void StopMusic() {};
/** Check if music if playing
- * @return return true if music is playing
+ * \return return true if music is playing
*/
inline virtual bool IsPlayingMusic() {return true;};
};
diff --git a/src/ui/control.cpp b/src/ui/control.cpp
index 16769d1..718ad3b 100644
--- a/src/ui/control.cpp
+++ b/src/ui/control.cpp
@@ -21,7 +21,6 @@
namespace Ui {
// Object's constructor.
-
CControl::CControl()
{
m_iMan = CInstanceManager::GetInstancePointer();
diff --git a/src/ui/control.h b/src/ui/control.h
index e08c34d..635ae12 100644
--- a/src/ui/control.h
+++ b/src/ui/control.h
@@ -1,4 +1,4 @@
-// * This file is part of the COLOBOT source code
+// * This file is part of the COLOBOT source code;
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
@@ -65,8 +65,7 @@ namespace Ui {
class CControl
{
public:
- // CControl(CInstanceManager* iMan);
- CControl ();
+ CControl();
virtual ~CControl();
virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
@@ -117,9 +116,9 @@ namespace Ui {
protected:
CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
+ Gfx::CParticle* m_particle;
CEventQueue* m_event;
CRobotMain* m_main;
- Gfx::CParticle* m_particle;
CSoundInterface* m_sound;
Math::Point m_pos; // corner upper / left
diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp
index 9b49f68..29499bd 100644
--- a/src/ui/displayinfo.cpp
+++ b/src/ui/displayinfo.cpp
@@ -232,7 +232,7 @@ bool CDisplayInfo::EventProcess(const Event &event)
m_bInfoMaximized = false;
}
//? m_main->SetEditFull(m_bInfoMaximized);
- pw = dynamic_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw != 0 )
{
pw->SetMaximized(m_bInfoMaximized);
@@ -834,7 +834,7 @@ void CDisplayInfo::StopDisplayInfo()
if ( m_bEditLock ) // editing running program?
{
- pw = dynamic_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW3));
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW3));
if ( pw != 0 )
{
pw->SetState(STATE_ENABLE); // CStudio operating
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index ca53a7a..e14b19d 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -71,8 +71,6 @@ bool IsSep(int character)
//! Object's constructor.
-
-//CEdit::CEdit(CInstanceManager* iMan) : CControl(iMan)
CEdit::CEdit () : CControl ()
{
Math::Point pos;
@@ -1796,7 +1794,7 @@ bool CEdit::ReadText(const char *filename, int addSize)
if ( SearchKey(buffer+i+5, slot) )
{
CRobotMain* main = CRobotMain::GetInstancePointer();
- res = main->GetInputBinding(slot).key;
+ res = main->GetInputBinding(slot).primary;
if ( res != 0 )
{
if ( GetResource(RES_KEY, res, iName) )
@@ -1815,7 +1813,7 @@ bool CEdit::ReadText(const char *filename, int addSize)
m_format[j] = font;
j ++;
- res = main->GetInputBinding(slot).joy;
+ res = main->GetInputBinding(slot).secondary;
if ( res != 0 )
{
if ( GetResource(RES_KEY, res, iName) )
@@ -3081,7 +3079,7 @@ void CEdit::Justif()
if ( m_format.size() == 0 )
{
// TODO check if good
-
+
i += m_engine->GetText()->Justify(m_text+i, m_fontType,
m_fontSize, width);
}
@@ -3137,6 +3135,7 @@ void CEdit::Justif()
}
if ( m_lineTotal >= EDITLINEMAX-2 ) break;
}
+
if ( m_len > 0 && m_text[m_len-1] == '\n' )
{
m_lineOffset[m_lineTotal] = m_len;
diff --git a/src/ui/edit.h b/src/ui/edit.h
index 7414372..35d8b2c 100644
--- a/src/ui/edit.h
+++ b/src/ui/edit.h
@@ -124,8 +124,8 @@ struct HyperHistory
class CEdit : public CControl
{
public:
-// CEdit(CInstanceManager* iMan);
CEdit ();
+
virtual ~CEdit();
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
diff --git a/src/ui/key.cpp b/src/ui/key.cpp
index 26d99ac..9a76127 100644
--- a/src/ui/key.cpp
+++ b/src/ui/key.cpp
@@ -15,65 +15,48 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// key.cpp
-
-
#include "ui/key.h"
-#include <string.h>
+#include "common/global.h"
+
+#include <cstring>
namespace Ui {
-void GetKeyName(char *name, int key)
+
+void GetKeyName(char* name, unsigned int key)
{
- if ( !GetResource(RES_KEY, key, name) ) {
- if (isalnum(key)) {
- name[0] = key;
- name[1] = 0;
- }
- else {
- sprintf(name, "Code %d", key);
- }
- }
+ if (!GetResource(RES_KEY, key, name))
+ sprintf(name, "Code %d", key);
}
-// Object's constructor.
-
CKey::CKey() : CControl()
{
- m_key[0] = 0;
- m_key[1] = 0;
- m_bCatch = false;
+ m_catch = false;
- m_app = CApplication::GetInstancePointer();
+ m_robotMain = CRobotMain::GetInstancePointer();
}
-// Object's destructor.
-
CKey::~CKey()
{
+ m_robotMain = nullptr;
}
-
-// Creates a new button.
-
bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- char name[100];
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
+
+ char name[100];
GetResource(RES_EVENT, eventMsg, name);
SetName(std::string(name));
return true;
}
-
-// Management of an event.
-
bool CKey::EventProcess(const Event &event)
{
if (m_state & STATE_DEAD)
@@ -81,24 +64,31 @@ bool CKey::EventProcess(const Event &event)
CControl::EventProcess(event);
- if (event.type == EVENT_MOUSE_BUTTON_DOWN) {
+ if (event.type == EVENT_MOUSE_BUTTON_DOWN)
+ {
if (event.mouseButton.button == MOUSE_BUTTON_LEFT) // left
- m_bCatch = Detect(event.mousePos);
+ m_catch = Detect(event.mousePos);
}
- if (event.type == EVENT_KEY_DOWN && m_bCatch) {
- m_bCatch = false;
+ if (event.type == EVENT_KEY_DOWN && m_catch)
+ {
+ m_catch = false;
- if ( TestKey(event.key.key) ) { // impossible ?
+ if (TestKey(event.key.key)) // impossible ?
+ {
m_sound->Play(SOUND_TZOING);
- } else {
- // TODO: test for virtual, joystick, etc.
- if ( event.key.key == m_key[0] || event.key.key == m_key[1] ) {
- m_key[0] = event.key.key;
- m_key[1] = 0;
- } else {
- m_key[1] = m_key[0];
- m_key[0] = event.key.key;
+ }
+ else
+ {
+ if (event.key.key == m_binding.primary || event.key.key == m_binding.secondary)
+ {
+ m_binding.secondary = KEY_INVALID;
+ m_binding.primary = event.key.key;
+ }
+ else
+ {
+ m_binding.secondary = m_binding.primary;
+ m_binding.primary = event.key.key;
}
m_sound->Play(SOUND_CLICK);
@@ -112,96 +102,88 @@ bool CKey::EventProcess(const Event &event)
return true;
}
-
-// Seeks when a key is already used.
-
-bool CKey::TestKey(int key)
+bool CKey::TestKey(unsigned int key)
{
- if ( key == KEY(PAUSE) || key == KEY(PRINT) ) return true; // blocked key
+ if (key == KEY(PAUSE) || key == KEY(PRINT)) return true; // blocked key
- /* TODO: input bindings
- for (int i = 0; i < 20; i++) {
- for (int j = 0; j < 2; j++) {
- if (key == m_app->GetKey(i, j) ) // key used?
- m_app->SetKey(i, j, 0); // nothing!
- }
+ for (int i = 0; i < INPUT_SLOT_MAX; i++)
+ {
+ InputSlot slot = static_cast<InputSlot>(i);
+ InputBinding b = m_robotMain->GetInputBinding(slot);
+ if (key == b.primary || key == b.secondary)
+ m_robotMain->SetInputBinding(slot, InputBinding()); // nothing!
- if ( m_app->GetKey(i, 0) == 0 ) { // first free option?
- m_app->SetKey(i, 0, m_app->GetKey(i, 1)); // shift
- m_app->SetKey(i, 1, 0);
- }
- } */
+ if (b.primary == KEY_INVALID) // first free option?
+ m_robotMain->SetInputBinding(slot, InputBinding(b.secondary, b.primary)); // shift
+ }
return false; // not used
}
-
-// Draws button.
-
void CKey::Draw()
{
- Math::Point iDim, pos;
- float zoomExt, zoomInt, h;
- int icon;
- char text[100];
-
- if ( (m_state & STATE_VISIBLE) == 0 )
+ if ((m_state & STATE_VISIBLE) == 0)
return;
- iDim = m_dim;
+ Math::Point iDim = m_dim;
m_dim.x = 200.0f/640.0f;
- if ( m_state & STATE_SHADOW )
+ if (m_state & STATE_SHADOW)
DrawShadow(m_pos, m_dim);
m_engine->SetTexture("button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); // was D3DSTATENORMAL
- zoomExt = 1.00f;
- zoomInt = 0.95f;
+ float zoomExt = 1.00f;
+ float zoomInt = 0.95f;
- icon = 2;
- if ( m_key[0] == 0 && m_key[1] == 0 ) // no shortcut?
+ int icon = 2;
+ if (m_binding.primary == KEY_INVALID && m_binding.secondary == KEY_INVALID) // no shortcut?
icon = 3;
- if ( m_state & STATE_DEFAULT ) {
+ if (m_state & STATE_DEFAULT)
+ {
DrawPart(23, 1.3f, 0.0f);
zoomExt *= 1.15f;
zoomInt *= 1.15f;
}
- if ( m_state & STATE_HILIGHT )
+ if (m_state & STATE_HILIGHT)
icon = 1;
- if ( m_state & STATE_CHECK )
+ if (m_state & STATE_CHECK)
icon = 0;
- if ( m_state & STATE_PRESS ) {
+ if (m_state & STATE_PRESS)
+ {
icon = 3;
zoomInt *= 0.9f;
}
- if ( (m_state & STATE_ENABLE) == 0 )
+ if ((m_state & STATE_ENABLE) == 0)
icon = 7;
- if ( m_state & STATE_DEAD )
+ if (m_state & STATE_DEAD)
icon = 17;
- if ( m_bCatch )
+ if (m_catch)
icon = 23;
DrawPart(icon, zoomExt, 8.0f / 256.0f); // draws the button
- h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f;
+ float h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f;
- GetKeyName(text, m_key[0]);
- if ( m_key[1] != 0 ) {
+ char text[100];
+ GetKeyName(text, m_binding.primary);
+ if (m_binding.secondary != KEY_INVALID)
+ {
GetResource(RES_TEXT, RT_KEY_OR, text+strlen(text));
- GetKeyName(text+strlen(text), m_key[1]);
+ GetKeyName(text+strlen(text), m_binding.secondary);
}
+ Math::Point pos;
pos.x = m_pos.x + m_dim.x * 0.5f;
pos.y = m_pos.y + m_dim.y * 0.5f;
pos.y -= h;
@@ -209,7 +191,7 @@ void CKey::Draw()
m_dim = iDim;
- if ( m_state & STATE_DEAD )
+ if (m_state & STATE_DEAD)
return;
// Draws the name.
@@ -219,20 +201,15 @@ void CKey::Draw()
m_engine->GetText()->DrawText(std::string(m_name), m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, 0);
}
-
-
-void CKey::SetKey(int option, int key)
+void CKey::SetBinding(InputBinding b)
{
- if ( option < 0 || option > 1 ) return;
-
- m_key[option] = key;
+ m_binding = b;
}
-int CKey::GetKey(int option)
+InputBinding CKey::GetBinding()
{
- if ( option < 0 || option > 1 ) return 0;
-
- return m_key[option];
+ return m_binding;
}
-}
+
+} // namespace Ui
diff --git a/src/ui/key.h b/src/ui/key.h
index 1943f61..2332c9b 100644
--- a/src/ui/key.h
+++ b/src/ui/key.h
@@ -15,13 +15,13 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// key.h
+/**
+ * \file ui/key.h
+ * \brief Key slot control
+ */
#pragma once
-#include <cctype>
-#include <string>
-
#include "ui/control.h"
#include "common/iman.h"
@@ -29,33 +29,40 @@
#include "common/restext.h"
#include "common/key.h"
-#include "app/app.h"
namespace Ui {
class CKey : public CControl
{
- public:
- CKey();
- virtual ~CKey();
+public:
+ CKey();
+ virtual ~CKey();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
- bool EventProcess(const Event &event);
+ //! Creates a new key slot button
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ //! Management of an event
+ bool EventProcess(const Event &event);
- void Draw();
+ //! Draws button
+ void Draw();
- void SetKey(int option, int key);
- int GetKey(int option);
+ //! Management of binding
+ //@{
+ void SetBinding(InputBinding b);
+ InputBinding GetBinding();
+ //@}
- protected:
- bool TestKey(int key);
+protected:
+ //! Checks if a key is already used
+ bool TestKey(unsigned int key);
- unsigned int m_key[2];
- bool m_bCatch;
+protected:
+ CRobotMain* m_robotMain;
- CApplication *m_app;
+ InputBinding m_binding;
+ bool m_catch;
};
-}
+} // namespace Ui
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index d7295eb..5136a41 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -8,7 +8,7 @@
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A Gfx::PARTICULAR PURPOSE. See the
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
@@ -5476,7 +5476,6 @@ void CMainDialog::SetupMemorize()
{
float fValue;
int iValue, i, j;
- char key[500];
char num[10];
GetProfile().SetLocalProfileString("Directory", "scene", m_sceneDir);
@@ -5518,21 +5517,16 @@ void CMainDialog::SetupMemorize()
// GetProfile()->SetLocalProfileInt("Setup", "UseJoystick", m_engine->GetJoystick());
// GetProfile()->SetLocalProfileInt("Setup", "MidiVolume", m_sound->GetMidiVolume());
- // key[0] = 0;
- // for ( i=0 ; i<100 ; i++ )
- // {
- // if ( m_engine->GetKey(i, 0) == 0 ) break;
-
- // for ( j=0 ; j<2 ; j++ )
- // {
- // iValue = m_engine->GetKey(i, j);
- // sprintf(num, "%d%c", iValue, j==0?'+':' ');
- // strcat(key, num);
- // }
- // }
+ std::stringstream key;
+ for (int i = 0; i < INPUT_SLOT_MAX; i++)
+ {
+ InputBinding b = m_main->GetInputBinding(static_cast<InputSlot>(i));
- /* TODO: profile
- SetLocalProfileString("Setup", "KeyMap", key); */
+ key << b.primary << " ";
+ key << b.secondary << " ";
+ }
+
+ GetProfile().SetLocalProfileString("Setup", "KeyMap", key.str());
#if _NET
if ( m_accessEnable )
@@ -5556,9 +5550,8 @@ void CMainDialog::SetupMemorize()
void CMainDialog::SetupRecall()
{
float fValue;
- int iValue, i, j;
+ int iValue;
std::string key;
- char* p;
if ( GetProfile().GetLocalProfileString("Directory", "scene", key) )
{
@@ -5747,22 +5740,18 @@ void CMainDialog::SetupRecall()
m_engine->SetEditIndentValue(iValue);
}
- // if ( GetLocalProfileString("Setup", "KeyMap", key, 500) )
- // {
- // p = key;
- // for ( i=0 ; i<100 ; i++ )
- // {
- // if ( p[0] == 0 ) break;
-
- // for ( j=0 ; j<2 ; j++ )
- // {
- // sscanf(p, "%d", &iValue);
- // m_engine->SetKey(i, j, iValue);
- // while ( *p >= '0' && *p <= '9' ) p++;
- // while ( *p == ' ' || *p == '+' ) p++;
- // }
- // }
- // }
+ if (GetProfile().GetLocalProfileString("Setup", "KeyMap", key))
+ {
+ std::stringstream skey;
+ skey.str(key);
+ for (int i = 0; i < INPUT_SLOT_MAX; i++)
+ {
+ InputBinding b;
+ skey >> b.primary;
+ skey >> b.secondary;
+ m_main->SetInputBinding(static_cast<InputSlot>(i), b);
+ }
+ }
#if _NET
if ( m_accessEnable )
@@ -5837,7 +5826,7 @@ void CMainDialog::ChangeSetupQuality(int quality)
// Redefinable keys:
-static int key_table[KEY_TOTAL] =
+static InputSlot key_table[KEY_TOTAL] =
{
INPUT_SLOT_LEFT,
INPUT_SLOT_RIGHT,
@@ -5891,37 +5880,30 @@ static EventType key_event[KEY_TOTAL] =
void CMainDialog::UpdateKey()
{
- CWindow* pw;
- CScroll* ps;
- CKey* pk;
- Math::Point pos, dim;
- int first, i;
+ CWindow* pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
+ if (pw == nullptr) return;
- pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
- if ( pw == 0 ) return;
-
- ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
- if ( ps == 0 ) return;
+ CScroll* ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
+ if (ps == nullptr) return;
- first = static_cast<int>(ps->GetVisibleValue()*(KEY_TOTAL-KEY_VISIBLE));
+ int first = static_cast<int>(ps->GetVisibleValue()*(KEY_TOTAL-KEY_VISIBLE));
- for ( i=0 ; i<KEY_TOTAL ; i++ )
- {
+ for (int i = 0; i < KEY_TOTAL; i++)
pw->DeleteControl(key_event[i]);
- }
+ Math::Point dim;
dim.x = 400.0f/640.0f;
dim.y = 20.0f/480.0f;
+ Math::Point pos;
pos.x = 110.0f/640.0f;
pos.y = 168.0f/480.0f + dim.y*(KEY_VISIBLE-1);
- for ( i=0 ; i<KEY_VISIBLE ; i++ )
+ for (int i = 0; i < KEY_VISIBLE; i++)
{
pw->CreateKey(pos, dim, -1, key_event[first+i]);
- pk = static_cast<CKey*>(pw->SearchControl(key_event[first+i]));
- if ( pk == 0 ) break;
- /* TODO: set input bindings
- pk->SetKey(0, m_engine->GetKey(key_table[first+i], 0));
- pk->SetKey(1, m_engine->GetKey(key_table[first+i], 1)); */
+ CKey* pk = static_cast<CKey*>(pw->SearchControl(key_event[first+i]));
+ if (pk == nullptr) break;
+
+ pk->SetBinding(m_main->GetInputBinding(key_table[first+i]));
pos.y -= dim.y;
}
}
@@ -5930,26 +5912,20 @@ void CMainDialog::UpdateKey()
void CMainDialog::ChangeKey(EventType event)
{
- CWindow* pw;
- CScroll* ps;
- CKey* pk;
- int i;
-
- pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
- if ( pw == 0 ) return;
+ CWindow* pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
+ if (pw == nullptr) return;
- ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
- if ( ps == 0 ) return;
+ CScroll* ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
+ if (ps == nullptr) return;
- for ( i=0 ; i<KEY_TOTAL ; i++ )
+ for (int i = 0; i < KEY_TOTAL; i++)
{
if ( key_event[i] == event )
{
- pk = static_cast<CKey*>(pw->SearchControl(key_event[i]));
- if ( pk == 0 ) break;
- /* TODO: set key binding
- m_engine->SetKey(key_table[i], 0, pk->GetKey(0));
- m_engine->SetKey(key_table[i], 1, pk->GetKey(1)); */
+ CKey* pk = static_cast<CKey*>(pw->SearchControl(key_event[i]));
+ if (pk == nullptr) break;
+
+ m_main->SetInputBinding(key_table[i], pk->GetBinding());
}
}
}
@@ -6803,4 +6779,3 @@ bool CMainDialog::NextMission()
} // namespace Ui
-
diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp
index ac6d7fc..55b9612 100644
--- a/src/ui/mainshort.cpp
+++ b/src/ui/mainshort.cpp
@@ -30,7 +30,7 @@ CMainShort::CMainShort()
m_iMan->AddInstance(CLASS_SHORT, this);
m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_event = static_cast<CEvent*>(m_iMan->SearchInstance(CLASS_EVENT));
+ m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
diff --git a/src/ui/mainshort.h b/src/ui/mainshort.h
index e97bdcc..0912e68 100644
--- a/src/ui/mainshort.h
+++ b/src/ui/mainshort.h
@@ -47,7 +47,7 @@ class CMainShort
protected:
CInstanceManager* m_iMan;
- CEvent* m_event;
+ CEventQueue* m_event;
Gfx::CEngine* m_engine;
CInterface* m_interface;
CRobotMain* m_main;
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index a581baa..2f58c95 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -241,8 +241,8 @@ bool CStudio::EventProcess(const Event &event)
if ( event.type == EVENT_KEY_DOWN )
{
- if ( event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).key ||
- event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).joy )
+ if ( event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).primary ||
+ event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).secondary )
{
if ( m_helpFilename.length() > 0 )
{
diff --git a/src/ui/test/CMakeLists.txt b/src/ui/test/CMakeLists.txt
new file mode 100644
index 0000000..9e11e14
--- /dev/null
+++ b/src/ui/test/CMakeLists.txt
@@ -0,0 +1,33 @@
+cmake_minimum_required(VERSION 2.8)
+
+set(CMAKE_BUILD_TYPE debug)
+set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x")
+
+include_directories(
+.
+../..
+../../..
+${GTEST_DIR}/include
+)
+
+
+add_executable(edit_test
+ ../../common/event.cpp
+ ../../common/logger.cpp
+ ../../common/misc.cpp
+ ../../common/iman.cpp
+ ../../common/stringutils.cpp
+ ../../graphics/engine/text.cpp
+ ../button.cpp
+ ../control.cpp
+ ../edit.cpp
+ ../scroll.cpp
+ stubs/app_stub.cpp
+ stubs/engine_stub.cpp
+ stubs/particle_stub.cpp
+ stubs/restext_stub.cpp
+ stubs/robotmain_stub.cpp
+ edit_test.cpp)
+target_link_libraries(edit_test gtest gmock ${SDL_LIBRARY} ${SDLTTF_LIBRARY})
+
+add_test(edit_test ./edit_test)
diff --git a/src/ui/test/edit_test.cpp b/src/ui/test/edit_test.cpp
new file mode 100644
index 0000000..489b873
--- /dev/null
+++ b/src/ui/test/edit_test.cpp
@@ -0,0 +1,73 @@
+#include "../edit.h"
+#include "../../app/app.h"
+#include "mocks/text_mock.h"
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <fstream>
+
+class CEditTest : public testing::Test
+{
+public:
+ CEditTest(){};
+
+ virtual void SetUp()
+ {
+ m_engine = new Gfx::CEngine(&m_iMan, NULL);
+
+ m_iMan.AddInstance(CLASS_ENGINE, m_engine);
+ m_edit = new Ui::CEdit;
+ }
+
+ virtual void TearDown()
+ {
+ m_iMan.DeleteInstance(CLASS_ENGINE, m_engine);
+ delete m_engine;
+ m_engine = NULL;
+ delete m_edit;
+ m_edit = NULL;
+
+ }
+ virtual ~CEditTest()
+ {
+
+ };
+
+protected:
+ CInstanceManager m_iMan;
+ CApplication m_app;
+ Gfx::CEngine * m_engine;
+ Ui::CEdit * m_edit;
+ CLogger m_logger;
+};
+
+using ::testing::_;
+using ::testing::Return;
+
+TEST_F(CEditTest, WriteTest)
+{
+ ASSERT_TRUE(true);
+ CTextMock * text = dynamic_cast<CTextMock *>(m_engine->GetText());
+ EXPECT_CALL(*text, GetCharWidth(_, _, _, _)).WillRepeatedly(Return(1.0f));
+ EXPECT_CALL(*text, GetStringWidth(_, _, _)).WillOnce(Return(1.0f));
+ std::string filename = "test.file";
+ m_edit->SetMaxChar(Ui::EDITSTUDIOMAX);
+ m_edit->SetAutoIndent(true);
+ std::string inputScript = "{\ntext1\ntext2\n\ntext3\n{\ntext4\n}\n}";
+ std::string expectedScript = "{\r\n\ttext1\r\n\ttext2\r\n\t\r\n\ttext3\r\n\t{\r\n\t\ttext4\r\n\t}\r\n}";
+ m_edit->SetText(inputScript.c_str(), true);
+ GetLogger()->Info("Writing text \n");
+ m_edit->WriteText("script.txt");
+
+ std::fstream scriptFile;
+
+ scriptFile.open("script.txt", std::ios_base::binary | std::ios_base::in);
+ std::string outputScript((std::istreambuf_iterator<char>(scriptFile)), std::istreambuf_iterator<char>());
+ ASSERT_STREQ(expectedScript.c_str(), outputScript.c_str());
+}
+
+int main(int argc, char *argv[])
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
+
diff --git a/src/ui/test/mocks/text_mock.h b/src/ui/test/mocks/text_mock.h
new file mode 100644
index 0000000..59a6c48
--- /dev/null
+++ b/src/ui/test/mocks/text_mock.h
@@ -0,0 +1,21 @@
+#include "../../graphics/engine/text.h"
+#include <gmock/gmock.h>
+#include "../../common/logger.h"
+
+
+class CTextMock : public Gfx::CText
+{
+public:
+ CTextMock(CInstanceManager *iMan, Gfx::CEngine* engine) : CText(iMan, engine)
+ {
+ }
+
+ virtual ~CTextMock()
+ {
+ };
+
+ MOCK_METHOD4(GetCharWidth, float(Gfx::UTF8Char, Gfx::FontType, float, float));
+ MOCK_METHOD3(GetStringWidth, float(const std::string &, Gfx::FontType, float));
+
+};
+
diff --git a/src/ui/test/stubs/app_stub.cpp b/src/ui/test/stubs/app_stub.cpp
new file mode 100644
index 0000000..5dd79e4
--- /dev/null
+++ b/src/ui/test/stubs/app_stub.cpp
@@ -0,0 +1,26 @@
+#include "../../app/app.h"
+#include "../../graphics/opengl/gldevice.h"
+
+template<> CApplication* CSingleton<CApplication>::mInstance = nullptr;
+
+namespace Gfx {
+
+GLDeviceConfig::GLDeviceConfig()
+{
+}
+
+} /* Gfx */
+CApplication::CApplication()
+{
+}
+
+CApplication::~CApplication()
+{
+}
+
+std::string CApplication::GetDataFilePath(DataDir /* dataDir */, const std::string& subpath)
+{
+ return subpath;
+}
+
+
diff --git a/src/ui/test/stubs/engine_stub.cpp b/src/ui/test/stubs/engine_stub.cpp
new file mode 100644
index 0000000..6ec6006
--- /dev/null
+++ b/src/ui/test/stubs/engine_stub.cpp
@@ -0,0 +1,79 @@
+#include "../../graphics/engine/engine.h"
+#include "../../graphics/engine/text.h"
+#include "../mocks/text_mock.h"
+
+namespace Gfx {
+
+CEngine::CEngine(CInstanceManager* iMan, CApplication* app) :
+ m_iMan(iMan), m_app(app)
+{
+ m_text = new CTextMock(m_iMan, this);
+ m_text->Create();
+}
+
+CEngine::~CEngine()
+{
+ delete m_text;
+ m_text = NULL;
+}
+
+Math::Point CEngine::WindowToInterfaceSize(Math::IntPoint size)
+{
+ return Math::Point(size.x, size.y);
+}
+
+void CEngine::SetState(int state, const Color& color)
+{
+ if (state == m_lastState && color == m_lastColor)
+ return;
+
+ m_lastState = state;
+ m_lastColor = color;
+}
+
+Math::IntPoint CEngine::GetWindowSize()
+{
+ return m_size;
+}
+
+void CEngine::AddStatisticTriangle(int count)
+{
+ m_statisticTriangle += count;
+}
+
+void CEngine::SetMouseType(EngineMouseType type)
+{
+ m_mouseType = type;
+}
+
+bool CEngine::SetTexture(const std::string& /* name */, int /* stage */)
+{
+ return true;
+}
+
+CText* CEngine::GetText()
+{
+ return m_text;
+}
+
+CDevice* CEngine::GetDevice()
+{
+ return m_device;
+}
+
+int CEngine::GetEditIndentValue()
+{
+ return m_editIndentValue;
+}
+
+void CEngine::DeleteTexture(const std::string& /* texName */)
+{
+}
+Texture CEngine::LoadTexture(const std::string& /* name */)
+{
+ Texture texture;
+ return texture;
+}
+
+} /* Gfx */
+
diff --git a/src/ui/test/stubs/particle_stub.cpp b/src/ui/test/stubs/particle_stub.cpp
new file mode 100644
index 0000000..41f07cc
--- /dev/null
+++ b/src/ui/test/stubs/particle_stub.cpp
@@ -0,0 +1,291 @@
+#include "graphics/engine/particle.h"
+
+#include "common/logger.h"
+
+
+// Graphics module namespace
+namespace Gfx {
+
+
+CParticle::CParticle(CInstanceManager* iMan, CEngine* engine)
+{
+ GetLogger()->Trace("CParticle::CParticle() stub!\n");
+ // TODO!
+}
+
+CParticle::~CParticle()
+{
+ GetLogger()->Trace("CParticle::~CParticle() stub!\n");
+ // TODO!
+}
+
+void CParticle::SetDevice(CDevice* device)
+{
+ GetLogger()->Trace("CParticle::SetDevice() stub!\n");
+ // TODO!
+}
+
+void CParticle::FlushParticle()
+{
+ GetLogger()->Trace("CParticle::FlushParticle() stub!\n");
+ // TODO!
+}
+
+void CParticle::FlushParticle(int sheet)
+{
+ GetLogger()->Trace("CParticle::FlushParticle() stub!\n");
+ // TODO!
+}
+
+int CParticle::CreateParticle(Math::Vector pos, Math::Vector speed, Math::Point dim,
+ ParticleType type, float duration, float mass,
+ float windSensitivity, int sheet)
+{
+ GetLogger()->Trace("CParticle::CreateParticle() stub!\n");
+ // TODO!
+ return 0;
+}
+
+int CParticle::CreateFrag(Math::Vector pos, Math::Vector speed, EngineTriangle *triangle,
+ ParticleType type, float duration, float mass,
+ float windSensitivity, int sheet)
+{
+ GetLogger()->Trace("CParticle::CreateFrag() stub!\n");
+ // TODO!
+ return 0;
+}
+
+int CParticle::CreatePart(Math::Vector pos, Math::Vector speed, ParticleType type,
+ float duration, float mass, float weight,
+ float windSensitivity, int sheet)
+{
+ GetLogger()->Trace("CParticle::CreatePart() stub!\n");
+ // TODO!
+ return 0;
+}
+
+int CParticle::CreateRay(Math::Vector pos, Math::Vector goal, ParticleType type, Math::Point dim,
+ float duration, int sheet)
+{
+ GetLogger()->Trace("CParticle::CreateRay() stub!\n");
+ // TODO!
+ return 0;
+}
+
+int CParticle::CreateTrack(Math::Vector pos, Math::Vector speed, Math::Point dim, ParticleType type,
+ float duration, float mass, float length, float width)
+{
+ GetLogger()->Trace("CParticle::CreateTrack() stub!\n");
+ // TODO!
+ return 0;
+}
+
+void CParticle::CreateWheelTrace(const Math::Vector &p1, const Math::Vector &p2, const Math::Vector &p3,
+ const Math::Vector &p4, ParticleType type)
+{
+ GetLogger()->Trace("CParticle::CreateWheelTrace() stub!\n");
+ // TODO!
+}
+
+void CParticle::DeleteParticle(ParticleType type)
+{
+ GetLogger()->Trace("CParticle::DeleteParticle() stub!\n");
+ // TODO!
+}
+
+void CParticle::DeleteParticle(int channel)
+{
+ GetLogger()->Trace("CParticle::DeleteParticle() stub!\n");
+ // TODO!
+}
+
+void CParticle::SetObjectLink(int channel, CObject *object)
+{
+ GetLogger()->Trace("CParticle::SetObjectLink() stub!\n");
+ // TODO!
+}
+
+void CParticle::SetObjectFather(int channel, CObject *object)
+{
+ GetLogger()->Trace("CParticle::SetObjectFather() stub!\n");
+ // TODO!
+}
+
+void CParticle::SetPosition(int channel, Math::Vector pos)
+{
+ GetLogger()->Trace("CParticle::SetPosition() stub!\n");
+ // TODO!
+}
+
+void CParticle::SetDimension(int channel, Math::Point dim)
+{
+ GetLogger()->Trace("CParticle::SetDimension() stub!\n");
+ // TODO!
+}
+
+void CParticle::SetZoom(int channel, float zoom)
+{
+ GetLogger()->Trace("CParticle::SetZoom() stub!\n");
+ // TODO!
+}
+
+void CParticle::SetAngle(int channel, float angle)
+{
+ GetLogger()->Trace("CParticle::SetAngle() stub!\n");
+ // TODO!
+}
+
+void CParticle::SetIntensity(int channel, float intensity)
+{
+ GetLogger()->Trace("CParticle::SetIntensity() stub!\n");
+ // TODO!
+}
+
+void CParticle::SetParam(int channel, Math::Vector pos, Math::Point dim, float zoom, float angle, float intensity)
+{
+ GetLogger()->Trace("CParticle::SetParam() stub!\n");
+ // TODO!
+}
+
+void CParticle::SetPhase(int channel, ParticlePhase phase, float duration)
+{
+ GetLogger()->Trace("CParticle::SetPhase() stub!\n");
+ // TODO!
+}
+
+bool CParticle::GetPosition(int channel, Math::Vector &pos)
+{
+ GetLogger()->Trace("CParticle::GetPosition() stub!\n");
+ // TODO!
+ return true;
+}
+
+Color CParticle::GetFogColor(Math::Vector pos)
+{
+ GetLogger()->Trace("CParticle::GetFogColor() stub!\n");
+ // TODO!
+ return Color();
+}
+
+void CParticle::SetFrameUpdate(int sheet, bool update)
+{
+ GetLogger()->Trace("CParticle::SetFrameUpdate() stub!\n");
+ // TODO!
+}
+
+void CParticle::FrameParticle(float rTime)
+{
+ GetLogger()->Trace("CParticle::FrameParticle() stub!\n");
+ // TODO!
+}
+
+void CParticle::DrawParticle(int sheet)
+{
+ GetLogger()->Trace("CParticle::DrawParticle() stub!\n");
+ // TODO!
+}
+
+bool CParticle::WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur)
+{
+ GetLogger()->Trace("CParticle::WriteWheelTrace() stub!\n");
+ // TODO!
+ return true;
+}
+
+void CParticle::DeleteRank(int rank)
+{
+ GetLogger()->Trace("CParticle::DeleteRank() stub!\n");
+ // TODO!
+}
+
+bool CParticle::CheckChannel(int &channel)
+{
+ GetLogger()->Trace("CParticle::CheckChannel() stub!\n");
+ // TODO!
+ return true;
+}
+
+void CParticle::DrawParticleTriangle(int i)
+{
+ GetLogger()->Trace("CParticle::DrawParticleTriangle() stub!\n");
+ // TODO!
+}
+
+void CParticle::DrawParticleNorm(int i)
+{
+ GetLogger()->Trace("CParticle::DrawParticleNorm() stub!\n");
+ // TODO!
+}
+
+void CParticle::DrawParticleFlat(int i)
+{
+ GetLogger()->Trace("CParticle::DrawParticleFlat() stub!\n");
+ // TODO!
+}
+
+void CParticle::DrawParticleFog(int i)
+{
+ GetLogger()->Trace("CParticle::DrawParticleFog() stub!\n");
+ // TODO!
+}
+
+void CParticle::DrawParticleRay(int i)
+{
+ GetLogger()->Trace("CParticle::DrawParticleRay() stub!\n");
+ // TODO!
+}
+
+void CParticle::DrawParticleSphere(int i)
+{
+ GetLogger()->Trace("CParticle::DrawParticleSphere() stub!\n");
+ // TODO!
+}
+
+void CParticle::DrawParticleCylinder(int i)
+{
+ GetLogger()->Trace("CParticle::DrawParticleCylinder() stub!\n");
+ // TODO!
+}
+
+void CParticle::DrawParticleWheel(int i)
+{
+ GetLogger()->Trace("CParticle::DrawParticleWheel() stub!\n");
+ // TODO!
+}
+
+CObject* CParticle::SearchObjectGun(Math::Vector old, Math::Vector pos, ParticleType type, CObject *father)
+{
+ GetLogger()->Trace("CParticle::SearchObjectGun() stub!\n");
+ // TODO!
+ return nullptr;
+}
+
+CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticleType type, CObject *father)
+{
+ GetLogger()->Trace("CParticle::SearchObjectRay() stub!\n");
+ // TODO!
+ return nullptr;
+}
+
+void CParticle::Play(Sound sound, Math::Vector pos, float amplitude)
+{
+ GetLogger()->Trace("CParticle::Play() stub!\n");
+ // TODO!
+}
+
+bool CParticle::TrackMove(int i, Math::Vector pos, float progress)
+{
+ GetLogger()->Trace("CParticle::TrackMove() stub!\n");
+ // TODO!
+ return true;
+}
+
+void CParticle::TrackDraw(int i, ParticleType type)
+{
+ GetLogger()->Trace("CParticle::TrackDraw() stub!\n");
+ // TODO!
+}
+
+
+} // namespace Gfx
+
diff --git a/src/ui/test/stubs/restext_stub.cpp b/src/ui/test/stubs/restext_stub.cpp
new file mode 100644
index 0000000..c1986ca
--- /dev/null
+++ b/src/ui/test/stubs/restext_stub.cpp
@@ -0,0 +1,11 @@
+#include "../../common/restext.h"
+bool GetResource(ResType /* type */, int /* num */, char* /* text */)
+{
+ return true;
+}
+
+bool SearchKey(const char * /* cmd */, InputSlot & /* key */)
+{
+ return true;
+}
+
diff --git a/src/ui/test/stubs/robotmain_stub.cpp b/src/ui/test/stubs/robotmain_stub.cpp
new file mode 100644
index 0000000..93e0e82
--- /dev/null
+++ b/src/ui/test/stubs/robotmain_stub.cpp
@@ -0,0 +1,17 @@
+#include "../../object/robotmain.h"
+
+
+template<> CRobotMain* CSingleton<CRobotMain>::mInstance = nullptr;
+
+bool CRobotMain::GetGlint()
+{
+ return false;
+}
+
+const InputBinding& CRobotMain::GetInputBinding(InputSlot slot)
+{
+ unsigned int index = static_cast<unsigned int>(slot);
+ assert(index >= 0 && index < INPUT_SLOT_MAX);
+ return m_inputBindings[index];
+}
+