[libsigc++2] Deprecate libsigc++ lambdas, sigc::group(), sigc::var().



commit ec27025f0ec5718c94427ea1fb51e968fba15d9e
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Tue Mar 19 15:04:55 2013 +0100

    Deprecate libsigc++ lambdas, sigc::group(), sigc::var().
    
    * configure.ac: Add MM_ARG_DISABLE_DEPRECATED_API(SIGCXX).
    * sigc++/adaptors/lambda/macros/base.h.m4:
    * sigc++/adaptors/lambda/macros/group.h.m4:
    * sigc++/adaptors/lambda/macros/lambda.cc.m4:
    * sigc++/adaptors/lambda/macros/operator.h.m4:
    * sigc++/adaptors/lambda/macros/select.h.m4: Deprecate everything.
    * sigc++/macros/template.macros.m4: Add deprecation macros.
    * sigc++config.h.in: Add #undef SIGCXX_DISABLE_DEPRECATED.
    * tests/test_lambda.cc: Skip test if SIGCXX_DISABLE_DEPRECATED is defined.
    Bug #672555.

 ChangeLog                                   |   15 +++++
 configure.ac                                |    4 ++
 sigc++/adaptors/lambda/macros/base.h.m4     |   78 ++++++++++++++++++++++++---
 sigc++/adaptors/lambda/macros/group.h.m4    |   23 +++++++-
 sigc++/adaptors/lambda/macros/lambda.cc.m4  |    4 ++
 sigc++/adaptors/lambda/macros/operator.h.m4 |    9 +++-
 sigc++/adaptors/lambda/macros/select.h.m4   |   20 ++++++--
 sigc++/macros/template.macros.m4            |    7 +++
 sigc++config.h.in                           |    3 +
 tests/test_lambda.cc                        |   11 ++++
 10 files changed, 160 insertions(+), 14 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a572270..4a293b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2013-03-19  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
+       Deprecate libsigc++ lambdas, sigc::group(), sigc::var().
+
+       * configure.ac: Add MM_ARG_DISABLE_DEPRECATED_API(SIGCXX).
+       * sigc++/adaptors/lambda/macros/base.h.m4:
+       * sigc++/adaptors/lambda/macros/group.h.m4:
+       * sigc++/adaptors/lambda/macros/lambda.cc.m4:
+       * sigc++/adaptors/lambda/macros/operator.h.m4:
+       * sigc++/adaptors/lambda/macros/select.h.m4: Deprecate everything.
+       * sigc++/macros/template.macros.m4: Add deprecation macros.
+       * sigc++config.h.in: Add #undef SIGCXX_DISABLE_DEPRECATED.
+       * tests/test_lambda.cc: Skip test if SIGCXX_DISABLE_DEPRECATED is defined.
+       Bug #672555.
+
 2013-02-26  Kjell Ahlstedt  <kjell ahlstedt bredband net>
 
        Add track_obj() and test_track_obj.
diff --git a/configure.ac b/configure.ac
index 57d9a31..5c65eb0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,10 +57,14 @@ SIGC_CXX_HAS_SUN_REVERSE_ITERATOR
 AS_IF([test "x$config_error" = xyes],
       [AC_MSG_FAILURE([[One or more of the required C++ compiler features is missing.]])])
 
+# Evaluate the --enable-warnings=level option.
 MM_ARG_ENABLE_WARNINGS([SIGC_WXXFLAGS],
                        [-Wall],
                        [-pedantic -Wall -Wextra])
 
+# Offer the ability to omit some API from the library.
+MM_ARG_DISABLE_DEPRECATED_API([SIGCXX])
+
 AC_CONFIG_FILES([Makefile
                  ${SIGCXX_MODULE_NAME}.pc:sigc++.pc.in
                  ${SIGCXX_MODULE_NAME}-uninstalled.pc:sigc++-uninstalled.pc.in
diff --git a/sigc++/adaptors/lambda/macros/base.h.m4 b/sigc++/adaptors/lambda/macros/base.h.m4
index 0223968..16ced03 100644
--- a/sigc++/adaptors/lambda/macros/base.h.m4
+++ b/sigc++/adaptors/lambda/macros/base.h.m4
@@ -54,14 +54,16 @@ divert(0)dnl
 #include <sigc++/adaptors/adaptor_trait.h>
 #include <sigc++/reference_wrapper.h>
 
+_DEPRECATE_IFDEF_START
+
 namespace sigc {
 
 /** @defgroup lambdas Lambdas
  * libsigc++ ships with basic lambda functionality and the sigc::group adaptor,
  * which uses lambdas to transform a functor's parameter list.
  *
- * The lambda selectors sigc::_1, sigc::_2, ..., sigc::_9 are used to select the
- * first, second, ..., nineth argument from a list.
+ * The lambda selectors sigc::_1, sigc::_2, ..., sigc::_7 are used to select the
+ * first, second, ..., seventh argument from a list.
  *
  * @par Examples:
  * @code
@@ -87,11 +89,15 @@ namespace sigc {
  * [[]] (int x) -> int { return x + 5; }(3); // returns (3 + 5)
  * [[]] (int x, int y) -> int { return x * y; }(7,10); // returns (7 * 10)
  * @endcode
+ *
+ * @deprecated Use C++11 lambda expressions or std::bind() instead.
  */
 
 /** A hint to the compiler.
  * All lambda types publically inherit from this hint.
  *
+ * @deprecated Use C++11 lambda expressions instead.
+ *
  * @ingroup lambdas
  */
 struct lambda_base : public adaptor_base {};
@@ -106,10 +112,19 @@ namespace internal {
  * Objects of this type store a value that may be of type lambda itself.
  * In this case, operator()() executes the lambda (a lambda is always a functor at the same time).
  * Otherwise, operator()() simply returns the stored value.
+ *
+ * @deprecated Use C++11 lambda expressions instead.
+ *
+ * @ingroup lambdas
  */
 template <class T_type, bool I_islambda = is_base_and_derived<lambda_base, T_type>::value> struct 
lambda_core;
 
-/// Abstracts lambda functionality (template specialization for lambda values).
+/** Abstracts lambda functionality (template specialization for lambda values).
+ *
+ * @deprecated Use C++11 lambda expressions instead.
+ *
+ * @ingroup lambdas
+ */
 template <class T_type>
 struct lambda_core<T_type, true> : public lambda_base
 {
@@ -131,13 +146,19 @@ FOR(1,CALL_SIZE,[[LAMBDA_DO(%1)]])dnl
   T_type value_;
 };
 
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
 template <class T_type>
 typename lambda_core<T_type, true>::result_type
 lambda_core<T_type, true>::operator()() const
   { return value_(); }
+#endif // DOXYGEN_SHOULD_SKIP_THIS
 
-
-/// Abstracts lambda functionality (template specialization for other value types).
+/** Abstracts lambda functionality (template specialization for other value types).
+ *
+ * @deprecated Use C++11 lambda expressions instead.
+ *
+ * @ingroup lambdas
+ */
 template <class T_type>
 struct lambda_core<T_type, false> : public lambda_base
 {
@@ -156,13 +177,16 @@ FOR(1,CALL_SIZE,[[LAMBDA_DO_VALUE(%1)]])dnl
   T_type value_;
 };
 
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
 template <class T_type>
 typename lambda_core<T_type, false>::result_type lambda_core<T_type, false>::operator()() const
   { return value_; }
+#endif // DOXYGEN_SHOULD_SKIP_THIS
 
 } /* namespace internal */
 
 
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
 //template specialization of visit_each<>(action, functor):
 template <class T_action, class T_functor, bool I_islambda>
 void visit_each(const T_action& _A_action,
@@ -170,7 +194,7 @@ void visit_each(const T_action& _A_action,
 {
   visit_each(_A_action, _A_target.value_);
 }
-
+#endif // DOXYGEN_SHOULD_SKIP_THIS
 
 // forward declarations for lambda operators other<subscript> and other<assign>
 template <class T_type>
@@ -187,15 +211,32 @@ struct unwrap_lambda_type;
 
 /** Gets the object stored inside a lambda object.
  * Returns the object passed as argument, if it is not of type lambda.
+ *
+ * @deprecated Use C++11 lambda expressions instead of libsigc++ lambdas.
+ *
+ * @ingroup lambdas
  */
 template <class T_type>
 T_type& unwrap_lambda_value(T_type& a)
 { return a; }
 
+/** Gets the object stored inside a lambda object.
+ * Returns the object passed as argument, if it is not of type lambda.
+ *
+ * @deprecated Use C++11 lambda expressions instead of libsigc++ lambdas.
+ *
+ * @ingroup lambdas
+ */
 template <class T_type>
 const T_type& unwrap_lambda_value(const T_type& a)
 { return a; }
 
+/** Gets the object stored inside a lambda object.
+ *
+ * @deprecated Use C++11 lambda expressions instead of libsigc++ lambdas.
+ *
+ * @ingroup lambdas
+ */
 template <class T_type>
 const T_type& unwrap_lambda_value(const lambda<T_type>& a)
 { return a.value_; }
@@ -207,6 +248,8 @@ const T_type& unwrap_lambda_value(const lambda<T_type>& a)
  * Otherwise, operator()() simply returns the stored value.
  * The assign and subscript operators are defined to return a lambda operator.
  *
+ * @deprecated Use C++11 lambda expressions instead.
+ *
  * @ingroup lambdas
  */
 template <class T_type>
@@ -236,7 +279,7 @@ struct lambda : public internal::lambda_core<T_type>
       return lambda<lambda_operator_type>(lambda_operator_type(this->value_, unwrap_lambda_value(a))); }
 };
 
-
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
 //template specialization of visit_each<>(action, functor):
 template <class T_action, class T_type>
 void visit_each(const T_action& _A_action,
@@ -244,6 +287,7 @@ void visit_each(const T_action& _A_action,
 {
   visit_each(_A_action, _A_target.value_);
 }
+#endif // DOXYGEN_SHOULD_SKIP_THIS
 
 dnl /* With the Sun FORTE and the Compaq C++ compiler,
 dnl  * sigc::var() doesn't work with string constants.
@@ -308,12 +352,20 @@ dnl { return lambda<typename internal::convert_array<const T_type>::type>(v); }
  * @code
  * readValue.connect([[&data]] () -> int { return data; });
  * @endcode
+ *
+ * @deprecated Use C++11 lambda expressions instead of libsigc++ lambdas.
+ *
+ * @ingroup lambdas
  */
 template <class T_type>
 lambda<T_type&> var(T_type& v)
 { return lambda<T_type&>(v); }
 
 /** Converts a constant reference into a lambda object.
+ *
+ * @deprecated Use C++11 lambda expressions instead of libsigc++ lambdas.
+ *
+ * @ingroup lambdas
  */
 template <class T_type>
 lambda<const T_type&> var(const T_type& v)
@@ -323,15 +375,27 @@ lambda<const T_type&> var(const T_type& v)
 /** Deduces the type of the object stored in an object of the passed lambda type.
  * If the type passed as template argument is not of lambda type,
  * type is defined to unwrap_reference<T_type>::type.
+ *
+ * @deprecated Use C++11 lambda expressions instead of libsigc++ lambdas.
+ *
+ * @ingroup lambdas
  */
 template <class T_type>
 struct unwrap_lambda_type
 { typedef typename unwrap_reference<T_type>::type type; };
 
+/** Deduces the type of the object stored in an object of the passed lambda type.
+ *
+ * @deprecated Use C++11 lambda expressions instead of libsigc++ lambdas.
+ *
+ * @ingroup lambdas
+ */
 template <class T_type>
 struct unwrap_lambda_type<lambda<T_type> >
 { typedef T_type type; };
 
 } /* namespace sigc */
 
+_DEPRECATE_IFDEF_END
+
 #endif /* _SIGC_LAMBDA_BASE_HPP_ */
diff --git a/sigc++/adaptors/lambda/macros/group.h.m4 b/sigc++/adaptors/lambda/macros/group.h.m4
index f3b6cb8..868f0ce 100644
--- a/sigc++/adaptors/lambda/macros/group.h.m4
+++ b/sigc++/adaptors/lambda/macros/group.h.m4
@@ -20,6 +20,12 @@ include(template.macros.m4)
 dnl
 dnl  How to call the darn thing!
 define([LAMBDA_GROUP_FACTORY],[dnl
+/** Alters an arbitrary functor by rebuilding its arguments from $1 lambda expressions.
+ *
+ * @deprecated Use C++11 lambda expressions or std::bind() instead.
+ *
+ * @ingroup lambdas
+ */
 template <class T_functor, LOOP(class T_type%1, $1)>
 lambda<lambda_group$1<T_functor, LOOP(typename unwrap_reference<T_type%1>::type, $1)> >
 group(const T_functor& _A_func, LOOP(T_type%1 _A_%1, $1))
@@ -58,6 +64,13 @@ dnl
 dnl This really doesn't have much to do with lambda other than
 dnl holding lambdas with in itself.
 define([LAMBDA_GROUP],[dnl
+/** lambda_group$1 wraps a functor and rebuilds its arguments from $1 lambda expressions.
+ * Use the convenience function group() to create an instance of lambda_group$1.
+ *
+ * @deprecated Use C++11 lambda expressions or std::bind() instead.
+ *
+ * @ingroup lambdas
+ */
 template <class T_functor, LOOP(class T_type%1, $1)>
 struct lambda_group$1 : public lambda_base
 {
@@ -85,12 +98,12 @@ FOR(1, $1,[
   mutable functor_type func_;
 };
 
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
 template <class T_functor, LOOP(class T_type%1, $1)>
 typename lambda_group$1<T_functor, LOOP(T_type%1, $1)>::result_type
 lambda_group$1<T_functor, LOOP(T_type%1, $1)>::operator ()() const
   { return func_(LOOP(value%1_(), $1)); }
 
-
 //template specialization of visit_each<>(action, functor):
 template <class T_action, class T_functor, LOOP(class T_type%1, $1)>
 void visit_each(const T_action& _A_action,
@@ -100,13 +113,15 @@ FOR(1, $1,[
   visit_each(_A_action, _A_target.value%1_);])
   visit_each(_A_action, _A_target.func_);
 }
-
+#endif // DOXYGEN_SHOULD_SKIP_THIS
 
 ])
 divert(0)dnl
 __FIREWALL__
 #include <sigc++/adaptors/lambda/base.h>
 
+_DEPRECATE_IFDEF_START
+
 /** @defgroup group_ group()
  * sigc::group() alters an arbitrary functor by rebuilding its arguments from one or more lambda expressions.
  * For each parameter that should be passed to the wrapped functor, one lambda expression
@@ -186,6 +201,8 @@ __FIREWALL__
  *   // disconnected automatically if some_bar goes out of scope
  * @endcode
  *
+ * @deprecated Use C++11 lambda expressions or std::bind() instead.
+ *
  * @ingroup adaptors lambdas
  */
 
@@ -195,3 +212,5 @@ FOR(1,3,[[LAMBDA_GROUP(%1, CALL_SIZE)]])
 FOR(1,3,[[LAMBDA_GROUP_FACTORY(%1)]])
 
 } /* namespace sigc */
+
+_DEPRECATE_IFDEF_END
diff --git a/sigc++/adaptors/lambda/macros/lambda.cc.m4 b/sigc++/adaptors/lambda/macros/lambda.cc.m4
index c7aed57..463bb82 100644
--- a/sigc++/adaptors/lambda/macros/lambda.cc.m4
+++ b/sigc++/adaptors/lambda/macros/lambda.cc.m4
@@ -19,8 +19,12 @@ include(template.macros.m4)
 divert(0)dnl
 #include <sigc++/adaptors/lambda/select.h>
 
+_DEPRECATE_IFDEF_START
+
 namespace sigc {
 
 FOR(1,CALL_SIZE,[[const lambda<internal::lambda_select%1> _%1;
 ]])
 } /* namespace sigc */
+
+_DEPRECATE_IFDEF_END
diff --git a/sigc++/adaptors/lambda/macros/operator.h.m4 b/sigc++/adaptors/lambda/macros/operator.h.m4
index 593afeb..3979662 100644
--- a/sigc++/adaptors/lambda/macros/operator.h.m4
+++ b/sigc++/adaptors/lambda/macros/operator.h.m4
@@ -195,6 +195,10 @@ divert(0)dnl
 #define _SIGC_LAMBDA_OPERATOR_HPP_
 #include <sigc++/adaptors/lambda/base.h>
 
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+_DEPRECATE_IFDEF_START
+
 namespace sigc {
 
 /** Deduces the base type of a reference or a pointer.
@@ -537,9 +541,12 @@ void visit_each(const T_action& _A_action,
   visit_each(_A_action, _A_target.arg_);
 }
 
-
 undivert(2)dnl
 
 } /* namespace sigc */
 
+_DEPRECATE_IFDEF_END
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
 #endif /* _SIGC_LAMBDA_OPERATOR_HPP_ */
diff --git a/sigc++/adaptors/lambda/macros/select.h.m4 b/sigc++/adaptors/lambda/macros/select.h.m4
index 8417bc6..7fa3993 100644
--- a/sigc++/adaptors/lambda/macros/select.h.m4
+++ b/sigc++/adaptors/lambda/macros/select.h.m4
@@ -44,21 +44,33 @@ FOR($1, $2,[[LAMBDA_SELECT_DO($1,%1)]])dnl
 };
 
 ])
+define([LAMBDA_SELECTOR],[dnl
+/** Lambda selector.
+ *
+ * @deprecated Use C++11 lambda expressions or std::bind() instead of libsigc++ lambdas and sigc::group().
+ *
+ * @ingroup lambdas
+ */
+extern SIGC_API const lambda<internal::lambda_select$1> _$1;
+
+])
 
 divert(0)dnl
 #ifndef _SIGC_LAMBDA_SELECT_HPP_
 #define _SIGC_LAMBDA_SELECT_HPP_
 #include <sigc++/adaptors/lambda/base.h>
 
+_DEPRECATE_IFDEF_START
+
 namespace sigc {
 
 namespace internal {
-FOR(1,CALL_SIZE,[[LAMBDA_SELECT(%1,CALL_SIZE)]])
+FOR(1,CALL_SIZE,[[LAMBDA_SELECT(%1,CALL_SIZE)]])dnl
 } /* namespace internal */
 
-FOR(1,CALL_SIZE,[[extern SIGC_API const lambda<internal::lambda_select%1> _%1;
-]])
-
+FOR(1,CALL_SIZE,[[LAMBDA_SELECTOR(%1)]])dnl
 } /* namespace sigc */
 
+_DEPRECATE_IFDEF_END
+
 #endif /* _SIGC_LAMBDA_SELECT_HPP_ */
diff --git a/sigc++/macros/template.macros.m4 b/sigc++/macros/template.macros.m4
index 964d29d..dc1259e 100644
--- a/sigc++/macros/template.macros.m4
+++ b/sigc++/macros/template.macros.m4
@@ -45,6 +45,13 @@ divert(0)dnl
 define([_R_],[typename type_trait<$1>::take])
 define([_P_],[typename type_trait<$1>::pass])
 
+define([__DEPRECATION_GUARD__],[SIGCXX_DISABLE_DEPRECATED])dnl
+dnl Start deprecation
+define([_DEPRECATE_IFDEF_START],[dnl
+#ifndef __DEPRECATION_GUARD__])dnl
+dnl End deprecation
+define([_DEPRECATE_IFDEF_END],[dnl
+#endif // __DEPRECATION_GUARD__])dnl
 
 dnl
 dnl General macros
diff --git a/sigc++config.h.in b/sigc++config.h.in
index 05e4840..087370c 100644
--- a/sigc++config.h.in
+++ b/sigc++config.h.in
@@ -1,4 +1,7 @@
 
+/* Define to omit deprecated API from the library. */
+#undef SIGCXX_DISABLE_DEPRECATED
+
 /* Major version number of sigc++. */
 #undef SIGCXX_MAJOR_VERSION
 
diff --git a/tests/test_lambda.cc b/tests/test_lambda.cc
index f155c4c..c56d202 100644
--- a/tests/test_lambda.cc
+++ b/tests/test_lambda.cc
@@ -4,12 +4,15 @@
  */
 
 #include "testutilities.h"
+#include <iostream>
 #include <sstream>
 #include <string>
 #include <cstdlib>
 #include <sigc++/functors/functors.h>
 #include <sigc++/adaptors/lambda/lambda.h>
 
+#ifndef SIGCXX_DISABLE_DEPRECATED
+
 using sigc::_1;
 using sigc::_2;
 using sigc::_3;
@@ -87,6 +90,8 @@ inline std::ostringstream& operator << (std::ostringstream& s, const book& b)
 
 } // end anonymous namespace
 
+#endif // SIGCXX_DISABLE_DEPRECATED
+
 int main(int argc, char* argv[])
 {
   TestUtilities* util = TestUtilities::get_instance();
@@ -94,6 +99,8 @@ int main(int argc, char* argv[])
   if (!util->check_command_args(argc, argv))
     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
+#ifndef SIGCXX_DISABLE_DEPRECATED
+
   // test lambda operators
   int a = 1;
   result_stream << "(_1 + _2) (3,4):    " << (_1 + _2) (3,4);
@@ -249,5 +256,9 @@ int main(int argc, char* argv[])
   result_stream << (sigc::group(&foo, sigc::static_cast_<int>(_1), 2)) (1.234);
   util->check_result(result_stream, "foo(int 1, int 2) 6");
 
+#else // SIGCXX_DISABLE_DEPRECATED
+  std::cout << "libsigc++ lambdas are deprecated. They are not tested." << std::endl;
+#endif
+
   return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]