Skip to content

Commit 45d25ed

Browse files
committed
Added support for cv-qualifiers in Callback class
Additionally, the following changes were don to avoid combinatorial explosion in function overloads as a result of adding cv-qualifiers: - Added convenience function for inferred type - Deprecated callback overloads qhere cv-qualifiers are not scalable Supported overloads: callback(void (*f)(A...)); callback(const Callback<R(A...)> &); callback(T *t, void (*f)(T*, A...)); callback(const T *t, void (*f)(const T*, A...)); callback(volatile T *t, void (*f)(volatile T*, A...)); callback(const volatile T *t, void (*f)(const volatile T*, A...)); callback(T *t, void (T::*f)(A...)); callback(const T *t, void (T::*f)(A...) const); callback(volatile T *t, void (T::*f)(A...) volatile); callback(const volatile T *t, void (T::*f)(A...) const volatile);
1 parent 030261f commit 45d25ed

File tree

9 files changed

+1652
-488
lines changed

9 files changed

+1652
-488
lines changed

TESTS/mbed_drivers/callback/main.cpp

Lines changed: 256 additions & 163 deletions
Large diffs are not rendered by default.

features/net/network-socket/Socket.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "network-socket/NetworkStack.h"
2222
#include "rtos/Mutex.h"
2323
#include "Callback.h"
24+
#include "toolchain.h"
2425

2526

2627
/** Abstract socket class
@@ -168,10 +169,17 @@ class Socket {
168169
*
169170
* @param obj Pointer to object to call method on
170171
* @param method Method to call on state change
172+
*
173+
* @deprecated
174+
* The attach function does not support cv-qualifiers. Replaced by
175+
* attach(callback(obj, method)).
171176
*/
172177
template <typename T, typename M>
178+
MBED_DEPRECATED_SINCE("mbed-os-5.1",
179+
"The attach function does not support cv-qualifiers. Replaced by "
180+
"attach(callback(obj, method)).")
173181
void attach(T *obj, M method) {
174-
attach(mbed::Callback<void()>(obj, method));
182+
attach(mbed::callback(obj, method));
175183
}
176184

177185
protected:

hal/api/CallChain.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define MBED_CALLCHAIN_H
1818

1919
#include "Callback.h"
20+
#include "toolchain.h"
2021
#include <string.h>
2122

2223
namespace mbed {
@@ -87,10 +88,17 @@ class CallChain {
8788
*
8889
* @returns
8990
* The function object created for 'obj' and 'method'
91+
*
92+
* @deprecated
93+
* The add function does not support cv-qualifiers. Replaced by
94+
* add(callback(obj, method)).
9095
*/
9196
template<typename T, typename M>
97+
MBED_DEPRECATED_SINCE("mbed-os-5.1",
98+
"The add function does not support cv-qualifiers. Replaced by "
99+
"add(callback(obj, method)).")
92100
pFunctionPointer_t add(T *obj, M method) {
93-
return add(Callback<void()>(obj, method));
101+
return add(callback(obj, method));
94102
}
95103

96104
/** Add a function at the beginning of the chain
@@ -109,10 +117,17 @@ class CallChain {
109117
*
110118
* @returns
111119
* The function object created for 'tptr' and 'mptr'
120+
*
121+
* @deprecated
122+
* The add_front function does not support cv-qualifiers. Replaced by
123+
* add_front(callback(obj, method)).
112124
*/
113125
template<typename T, typename M>
126+
MBED_DEPRECATED_SINCE("mbed-os-5.1",
127+
"The add_front function does not support cv-qualifiers. Replaced by "
128+
"add_front(callback(obj, method)).")
114129
pFunctionPointer_t add_front(T *obj, M method) {
115-
return add_front(Callback<void()>(obj, method));
130+
return add_front(callback(obj, method));
116131
}
117132

118133
/** Get the number of functions in the chain

0 commit comments

Comments
 (0)