Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove problematic templated overloads on callback-based functions #2395

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions features/net/network-socket/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,13 @@ class Socket {
* @param obj Pointer to object to call method on
* @param method Method to call on state change
*/
template <typename T, typename M>
void attach(T *obj, M method) {
template <typename T>
void attach(T *obj, void (T::*method)()) {
attach(mbed::Callback<void()>(obj, method));
}

template <typename T>
void attach(T *obj, void (*method)(T*)) {
attach(mbed::Callback<void()>(obj, method));
}

Expand Down
18 changes: 14 additions & 4 deletions hal/api/CallChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,13 @@ class CallChain {
* @returns
* The function object created for 'obj' and 'method'
*/
template<typename T, typename M>
pFunctionPointer_t add(T *obj, M method) {
template <typename T>
pFunctionPointer_t add(T *obj, void (T::*method)()) {
return add(Callback<void()>(obj, method));
}

template <typename T>
pFunctionPointer_t add(T *obj, void (*method)(T*)) {
return add(Callback<void()>(obj, method));
}

Expand All @@ -110,8 +115,13 @@ class CallChain {
* @returns
* The function object created for 'tptr' and 'mptr'
*/
template<typename T, typename M>
pFunctionPointer_t add_front(T *obj, M method) {
template <typename T>
pFunctionPointer_t add_front(T *obj, void (T::*method)()) {
return add_front(Callback<void()>(obj, method));
}

template <typename T>
pFunctionPointer_t add_front(T *obj, void (*method)(T*)) {
return add_front(Callback<void()>(obj, method));
}

Expand Down
22 changes: 18 additions & 4 deletions hal/api/InterruptIn.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,15 @@ class InterruptIn {
* @param obj pointer to the object to call the member function on
* @param method pointer to the member function to be called
*/
template<typename T, typename M>
void rise(T *obj, M method) {
template<typename T>
void rise(T *obj, void (T::*method)()) {
core_util_critical_section_enter();
rise(Callback<void()>(obj, method));
core_util_critical_section_exit();
}

template<typename T>
void rise(T *obj, void (*method)(T*)) {
core_util_critical_section_enter();
rise(Callback<void()>(obj, method));
core_util_critical_section_exit();
Expand All @@ -107,8 +114,15 @@ class InterruptIn {
* @param obj pointer to the object to call the member function on
* @param method pointer to the member function to be called
*/
template<typename T, typename M>
void fall(T *obj, M method) {
template<typename T>
void fall(T *obj, void (T::*method)()) {
core_util_critical_section_enter();
fall(Callback<void()>(obj, method));
core_util_critical_section_exit();
}

template<typename T>
void fall(T *obj, void (*method)(T*)) {
core_util_critical_section_enter();
fall(Callback<void()>(obj, method));
core_util_critical_section_exit();
Expand Down
18 changes: 14 additions & 4 deletions hal/api/Ticker.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,13 @@ class Ticker : public TimerEvent {
* @param method pointer to the member function to be called
* @param t the time between calls in seconds
*/
template<typename T, typename M>
void attach(T *obj, M method, float t) {
template<typename T>
void attach(T *obj, void (T::*method)(), float t) {
attach(Callback<void()>(obj, method), t);
}

template<typename T>
void attach(T *obj, void (*method)(T*), float t) {
attach(Callback<void()>(obj, method), t);
}

Expand All @@ -101,8 +106,13 @@ class Ticker : public TimerEvent {
* @param mptr pointer to the member function to be called
* @param t the time between calls in micro-seconds
*/
template<typename T, typename M>
void attach_us(T *obj, M method, timestamp_t t) {
template<typename T>
void attach_us(T *obj, void (T::*method)(), float t) {
attach_us(Callback<void()>(obj, method), t);
}

template<typename T>
void attach_us(T *obj, void (*method)(T*), float t) {
attach_us(Callback<void()>(obj, method), t);
}

Expand Down
9 changes: 7 additions & 2 deletions rtos/rtos/RtosTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ class RtosTimer {
@param method member function to be executed by this timer.
@param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic)
*/
template <typename T, typename M>
RtosTimer(T *obj, M method, os_timer_type type=osTimerPeriodic) {
template <typename T>
RtosTimer(T *obj, void (T::*method)(), os_timer_type type=osTimerPeriodic) {
constructor(mbed::Callback<void()>(obj, method), type);
}

template <typename T>
RtosTimer(T *obj, void (*method)(T*), os_timer_type type=osTimerPeriodic) {
constructor(mbed::Callback<void()>(obj, method), type);
}

Expand Down
9 changes: 7 additions & 2 deletions rtos/rtos/Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,13 @@ class Thread {
@param method function to be executed by this thread.
@return status code that indicates the execution status of the function.
*/
template <typename T, typename M>
osStatus start(T *obj, M method) {
template <typename T>
osStatus start(T *obj, void (T::*method)()) {
return start(mbed::Callback<void()>(obj, method));
}

template <typename T>
osStatus start(T *obj, void (*method)(T*)) {
return start(mbed::Callback<void()>(obj, method));
}

Expand Down