|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r49593 - in sandbox/thread_safe_signals/trunk: boost/signals2/detail libs/signals2/test
From: fmhess_at_[hidden]
Date: 2008-11-04 16:03:16
Author: fmhess
Date: 2008-11-04 16:03:16 EST (Tue, 04 Nov 2008)
New Revision: 49593
URL: http://svn.boost.org/trac/boost/changeset/49593
Log:
Fixed bug in default ExtendedSlotFunction template type parameter
for preferred syntax signals2::signal. Added test code for
extended slots to signal_test.
Text files modified:
sandbox/thread_safe_signals/trunk/boost/signals2/detail/signal_template.hpp | 2 +
sandbox/thread_safe_signals/trunk/libs/signals2/test/signal_test.cpp | 46 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 0 deletions(-)
Modified: sandbox/thread_safe_signals/trunk/boost/signals2/detail/signal_template.hpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/boost/signals2/detail/signal_template.hpp (original)
+++ sandbox/thread_safe_signals/trunk/boost/signals2/detail/signal_template.hpp 2008-11-04 16:03:16 EST (Tue, 04 Nov 2008)
@@ -688,12 +688,14 @@
{
public:
// typename function_traits<Signature>::result_type (
+// const boost::signals2::connection &,
// typename function_traits<Signature>::arg1_type,
// typename function_traits<Signature>::arg2_type,
// ...,
// typename function_traits<Signature>::argn_type)
#define BOOST_SIGNALS2_EXT_SIGNATURE(arity, Signature) \
typename function_traits<Signature>::result_type ( \
+ const boost::signals2::connection & BOOST_PP_COMMA_IF(BOOST_SIGNALS_NUM_ARGS) \
BOOST_PP_ENUM(arity, BOOST_SIGNAL_SIGNATURE_TO_ARGN_TYPE, Signature) )
typedef function<BOOST_SIGNALS2_EXT_SIGNATURE(BOOST_SIGNALS_NUM_ARGS, Signature)> function_type;
#undef BOOST_SIGNALS2_EXT_SIGNATURE
Modified: sandbox/thread_safe_signals/trunk/libs/signals2/test/signal_test.cpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/libs/signals2/test/signal_test.cpp (original)
+++ sandbox/thread_safe_signals/trunk/libs/signals2/test/signal_test.cpp 2008-11-04 16:03:16 EST (Tue, 04 Nov 2008)
@@ -157,11 +157,57 @@
BOOST_CHECK(s1(3) == -3);
}
+template<typename ResultType>
+ ResultType disconnecting_slot(const boost::signals2::connection &conn, int)
+{
+ conn.disconnect();
+ return ResultType();
+}
+
+template<typename ResultType>
+ void test_extended_slot()
+{
+ {
+ typedef boost::signals2::signal<ResultType (int)> signal_type;
+ typedef typename signal_type::extended_slot_type slot_type;
+ signal_type sig;
+ slot_type myslot(&disconnecting_slot<ResultType>);
+ sig.connect_extended(myslot);
+ BOOST_CHECK(sig.num_slots() == 1);
+ sig(0);
+ BOOST_CHECK(sig.num_slots() == 0);
+ }
+ { // test 0 arg signal
+ typedef boost::signals2::signal<ResultType ()> signal_type;
+ typedef typename signal_type::extended_slot_type slot_type;
+ signal_type sig;
+ slot_type myslot(&disconnecting_slot<ResultType>, _1, 0);
+ sig.connect_extended(myslot);
+ BOOST_CHECK(sig.num_slots() == 1);
+ sig();
+ BOOST_CHECK(sig.num_slots() == 0);
+ }
+ // test disconnection by slot
+ {
+ typedef boost::signals2::signal<ResultType (int)> signal_type;
+ typedef typename signal_type::extended_slot_type slot_type;
+ signal_type sig;
+ slot_type myslot(&disconnecting_slot<ResultType>);
+ sig.connect_extended(myslot);
+ BOOST_CHECK(sig.num_slots() == 1);
+ sig.disconnect(&disconnecting_slot<ResultType>);
+ BOOST_CHECK(sig.num_slots() == 0);
+ }
+}
+
int
test_main(int, char* [])
{
test_zero_args();
test_one_arg();
test_signal_signal_connect();
+ test_extended_slot<void>();
+ test_extended_slot<int>();
+
return 0;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk