From b371eb52691a2ecbffcc14afc258840766d708dd Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 23 Sep 2016 03:29:14 -0500 Subject: [PATCH] callback - Reordered optional argument to static C function Before: Callback a = callback(obj, member) Callback b = callback(context, function) After: Callback a = callback(obj, member) Callback b = callback(function, context) This ordering is more intuitive based on feedback from users. This order was initially considered but proved problematic when integrated with other variable arguments in attach functions. With `callback` as a separate convenience function, this style no longer presents a problem. --- hal/api/Callback.h | 5155 ++++++++++++++++++++++++++++++----------- rtos/rtos/RtosTimer.h | 2 +- rtos/rtos/Thread.h | 24 +- 3 files changed, 3791 insertions(+), 1390 deletions(-) diff --git a/hal/api/Callback.h b/hal/api/Callback.h index c1a294bc4f..00f06368f6 100644 --- a/hal/api/Callback.h +++ b/hal/api/Callback.h @@ -19,6 +19,7 @@ #include #include #include "mbed_assert.h" +#include "toolchain.h" namespace mbed { @@ -38,118 +39,218 @@ template class Callback { public: /** Create a Callback with a static function - * @param func Static function to attach + * @param func Static function to attach */ Callback(R (*func)() = 0) { attach(func); } + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(T *obj, R (T::*method)()) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(const T *obj, R (T::*method)() const) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(volatile T *obj, R (T::*method)() volatile) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(const volatile T *obj, R (T::*method)() const volatile) { + attach(obj, method); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(void*), void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(const void*), const void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(volatile void*), volatile void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(const volatile void*), const volatile void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(T*), T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(const T*), const T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(volatile T*), volatile T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(const volatile T*), const volatile T *arg) { + attach(func, arg); + } + /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(void *obj, R (*func)(void*)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const void *obj, R (*func)(const void*)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(volatile void *obj, R (*func)(volatile void*)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const volatile void *obj, R (*func)(const volatile void*)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(T *obj, R (*func)(T*)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const T *obj, R (*func)(const T*)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(volatile T *obj, R (*func)(volatile T*)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const volatile T *obj, R (*func)(const volatile T*)) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(T *obj, R (T::*func)()) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(const T *obj, R (T::*func)() const) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(volatile T *obj, R (T::*func)() volatile) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(const volatile T *obj, R (T::*func)() const volatile) { - attach(obj, func); + attach(func, obj); } /** Attach a static function - * @param func Static function to attach + * @param func Static function to attach */ void attach(R (*func)()) { struct local { @@ -166,7 +267,7 @@ public: } /** Attach a Callback - * @param func The Callback to attach + * @param func The Callback to attach */ void attach(const Callback &func) { memset(&_func, 0, sizeof _func); @@ -175,10 +276,242 @@ public: _thunk = func._thunk; } + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(T *obj, R (T::*method)()) { + struct local { + static R _thunk(void *obj, const void *method) { + return (((T*)obj)->* + (*static_cast(method)))( + ); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(const T *obj, R (T::*method)() const) { + struct local { + static R _thunk(void *obj, const void *method) { + return (((const T*)obj)->* + (*static_cast(method)))( + ); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(volatile T *obj, R (T::*method)() volatile) { + struct local { + static R _thunk(void *obj, const void *method) { + return (((volatile T*)obj)->* + (*static_cast(method)))( + ); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(const volatile T *obj, R (T::*method)() const volatile) { + struct local { + static R _thunk(void *obj, const void *method) { + return (((const volatile T*)obj)->* + (*static_cast(method)))( + ); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(void*), void *arg) { + struct local { + static R _thunk(void *arg, const void *func) { + return (*static_cast(func))( + (void*)arg); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(const void*), const void *arg) { + struct local { + static R _thunk(void *arg, const void *func) { + return (*static_cast(func))( + (const void*)arg); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(volatile void*), volatile void *arg) { + struct local { + static R _thunk(void *arg, const void *func) { + return (*static_cast(func))( + (volatile void*)arg); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(const volatile void*), const volatile void *arg) { + struct local { + static R _thunk(void *arg, const void *func) { + return (*static_cast(func))( + (const volatile void*)arg); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(T*), T *arg) { + struct local { + static R _thunk(void *arg, const void *func) { + return (*static_cast(func))( + (T*)arg); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(const T*), const T *arg) { + struct local { + static R _thunk(void *arg, const void *func) { + return (*static_cast(func))( + (const T*)arg); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(volatile T*), volatile T *arg) { + struct local { + static R _thunk(void *arg, const void *func) { + return (*static_cast(func))( + (volatile T*)arg); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(const volatile T*), const volatile T *arg) { + struct local { + static R _thunk(void *arg, const void *func) { + return (*static_cast(func))( + (const volatile T*)arg); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(void *obj, R (*func)(void*)) { struct local { static R _thunk(void *obj, const void *func) { @@ -196,7 +529,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const void *obj, R (*func)(const void*)) { struct local { static R _thunk(void *obj, const void *func) { @@ -214,7 +551,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(volatile void *obj, R (*func)(volatile void*)) { struct local { static R _thunk(void *obj, const void *func) { @@ -232,7 +573,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const volatile void *obj, R (*func)(const volatile void*)) { struct local { static R _thunk(void *obj, const void *func) { @@ -250,8 +595,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(T *obj, R (*func)(T*)) { struct local { static R _thunk(void *obj, const void *func) { @@ -269,8 +618,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const T *obj, R (*func)(const T*)) { struct local { static R _thunk(void *obj, const void *func) { @@ -288,8 +641,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(volatile T *obj, R (*func)(volatile T*)) { struct local { static R _thunk(void *obj, const void *func) { @@ -307,8 +664,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const volatile T *obj, R (*func)(const volatile T*)) { struct local { static R _thunk(void *obj, const void *func) { @@ -323,86 +684,6 @@ public: _thunk = &local::_thunk; } - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(T *obj, R (T::*func)()) { - struct local { - static R _thunk(void *obj, const void *func) { - return (((T*)obj)->* - (*static_cast(func)))( - ); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(const T *obj, R (T::*func)() const) { - struct local { - static R _thunk(void *obj, const void *func) { - return (((const T*)obj)->* - (*static_cast(func)))( - ); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(volatile T *obj, R (T::*func)() volatile) { - struct local { - static R _thunk(void *obj, const void *func) { - return (((volatile T*)obj)->* - (*static_cast(func)))( - ); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(const volatile T *obj, R (T::*func)() const volatile) { - struct local { - static R _thunk(void *obj, const void *func) { - return (((const volatile T*)obj)->* - (*static_cast(func)))( - ); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - /** Call the attached function */ R call() const { @@ -467,118 +748,218 @@ template class Callback { public: /** Create a Callback with a static function - * @param func Static function to attach + * @param func Static function to attach */ Callback(R (*func)(A0) = 0) { attach(func); } + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(T *obj, R (T::*method)(A0)) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(const T *obj, R (T::*method)(A0) const) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(volatile T *obj, R (T::*method)(A0) volatile) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(const volatile T *obj, R (T::*method)(A0) const volatile) { + attach(obj, method); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(void*, A0), void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(const void*, A0), const void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(volatile void*, A0), volatile void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(const volatile void*, A0), const volatile void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(T*, A0), T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(const T*, A0), const T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(volatile T*, A0), volatile T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(const volatile T*, A0), const volatile T *arg) { + attach(func, arg); + } + /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(void *obj, R (*func)(void*, A0)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const void *obj, R (*func)(const void*, A0)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(volatile void *obj, R (*func)(volatile void*, A0)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const volatile void *obj, R (*func)(const volatile void*, A0)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(T *obj, R (*func)(T*, A0)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const T *obj, R (*func)(const T*, A0)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(volatile T *obj, R (*func)(volatile T*, A0)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const volatile T *obj, R (*func)(const volatile T*, A0)) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(T *obj, R (T::*func)(A0)) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(const T *obj, R (T::*func)(A0) const) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(volatile T *obj, R (T::*func)(A0) volatile) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(const volatile T *obj, R (T::*func)(A0) const volatile) { - attach(obj, func); + attach(func, obj); } /** Attach a static function - * @param func Static function to attach + * @param func Static function to attach */ void attach(R (*func)(A0)) { struct local { @@ -595,7 +976,7 @@ public: } /** Attach a Callback - * @param func The Callback to attach + * @param func The Callback to attach */ void attach(const Callback &func) { memset(&_func, 0, sizeof _func); @@ -604,10 +985,242 @@ public: _thunk = func._thunk; } + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(T *obj, R (T::*method)(A0)) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0) { + return (((T*)obj)->* + (*static_cast(method)))( + a0); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(const T *obj, R (T::*method)(A0) const) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0) { + return (((const T*)obj)->* + (*static_cast(method)))( + a0); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(volatile T *obj, R (T::*method)(A0) volatile) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0) { + return (((volatile T*)obj)->* + (*static_cast(method)))( + a0); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(const volatile T *obj, R (T::*method)(A0) const volatile) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0) { + return (((const volatile T*)obj)->* + (*static_cast(method)))( + a0); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(void*, A0), void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0) { + return (*static_cast(func))( + (void*)arg, a0); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(const void*, A0), const void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0) { + return (*static_cast(func))( + (const void*)arg, a0); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(volatile void*, A0), volatile void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0) { + return (*static_cast(func))( + (volatile void*)arg, a0); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(const volatile void*, A0), const volatile void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0) { + return (*static_cast(func))( + (const volatile void*)arg, a0); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(T*, A0), T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0) { + return (*static_cast(func))( + (T*)arg, a0); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(const T*, A0), const T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0) { + return (*static_cast(func))( + (const T*)arg, a0); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(volatile T*, A0), volatile T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0) { + return (*static_cast(func))( + (volatile T*)arg, a0); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(const volatile T*, A0), const volatile T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0) { + return (*static_cast(func))( + (const volatile T*)arg, a0); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(void *obj, R (*func)(void*, A0)) { struct local { static R _thunk(void *obj, const void *func, A0 a0) { @@ -625,7 +1238,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const void *obj, R (*func)(const void*, A0)) { struct local { static R _thunk(void *obj, const void *func, A0 a0) { @@ -643,7 +1260,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(volatile void *obj, R (*func)(volatile void*, A0)) { struct local { static R _thunk(void *obj, const void *func, A0 a0) { @@ -661,7 +1282,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const volatile void *obj, R (*func)(const volatile void*, A0)) { struct local { static R _thunk(void *obj, const void *func, A0 a0) { @@ -679,8 +1304,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(T *obj, R (*func)(T*, A0)) { struct local { static R _thunk(void *obj, const void *func, A0 a0) { @@ -698,8 +1327,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const T *obj, R (*func)(const T*, A0)) { struct local { static R _thunk(void *obj, const void *func, A0 a0) { @@ -717,8 +1350,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(volatile T *obj, R (*func)(volatile T*, A0)) { struct local { static R _thunk(void *obj, const void *func, A0 a0) { @@ -736,8 +1373,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const volatile T *obj, R (*func)(const volatile T*, A0)) { struct local { static R _thunk(void *obj, const void *func, A0 a0) { @@ -752,86 +1393,6 @@ public: _thunk = &local::_thunk; } - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(T *obj, R (T::*func)(A0)) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0) { - return (((T*)obj)->* - (*static_cast(func)))( - a0); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(const T *obj, R (T::*func)(A0) const) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0) { - return (((const T*)obj)->* - (*static_cast(func)))( - a0); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(volatile T *obj, R (T::*func)(A0) volatile) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0) { - return (((volatile T*)obj)->* - (*static_cast(func)))( - a0); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(const volatile T *obj, R (T::*func)(A0) const volatile) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0) { - return (((const volatile T*)obj)->* - (*static_cast(func)))( - a0); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - /** Call the attached function */ R call(A0 a0) const { @@ -896,118 +1457,218 @@ template class Callback { public: /** Create a Callback with a static function - * @param func Static function to attach + * @param func Static function to attach */ Callback(R (*func)(A0, A1) = 0) { attach(func); } + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(T *obj, R (T::*method)(A0, A1)) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(const T *obj, R (T::*method)(A0, A1) const) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(volatile T *obj, R (T::*method)(A0, A1) volatile) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(const volatile T *obj, R (T::*method)(A0, A1) const volatile) { + attach(obj, method); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(void*, A0, A1), void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(const void*, A0, A1), const void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(volatile void*, A0, A1), volatile void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(const volatile void*, A0, A1), const volatile void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(T*, A0, A1), T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(const T*, A0, A1), const T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(volatile T*, A0, A1), volatile T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(const volatile T*, A0, A1), const volatile T *arg) { + attach(func, arg); + } + /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(void *obj, R (*func)(void*, A0, A1)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const void *obj, R (*func)(const void*, A0, A1)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(volatile void *obj, R (*func)(volatile void*, A0, A1)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(T *obj, R (*func)(T*, A0, A1)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const T *obj, R (*func)(const T*, A0, A1)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(volatile T *obj, R (*func)(volatile T*, A0, A1)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1)) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(T *obj, R (T::*func)(A0, A1)) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(const T *obj, R (T::*func)(A0, A1) const) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(volatile T *obj, R (T::*func)(A0, A1) volatile) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(const volatile T *obj, R (T::*func)(A0, A1) const volatile) { - attach(obj, func); + attach(func, obj); } /** Attach a static function - * @param func Static function to attach + * @param func Static function to attach */ void attach(R (*func)(A0, A1)) { struct local { @@ -1024,7 +1685,7 @@ public: } /** Attach a Callback - * @param func The Callback to attach + * @param func The Callback to attach */ void attach(const Callback &func) { memset(&_func, 0, sizeof _func); @@ -1033,10 +1694,242 @@ public: _thunk = func._thunk; } + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(T *obj, R (T::*method)(A0, A1)) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1) { + return (((T*)obj)->* + (*static_cast(method)))( + a0, a1); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(const T *obj, R (T::*method)(A0, A1) const) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1) { + return (((const T*)obj)->* + (*static_cast(method)))( + a0, a1); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(volatile T *obj, R (T::*method)(A0, A1) volatile) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1) { + return (((volatile T*)obj)->* + (*static_cast(method)))( + a0, a1); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(const volatile T *obj, R (T::*method)(A0, A1) const volatile) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1) { + return (((const volatile T*)obj)->* + (*static_cast(method)))( + a0, a1); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(void*, A0, A1), void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1) { + return (*static_cast(func))( + (void*)arg, a0, a1); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(const void*, A0, A1), const void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1) { + return (*static_cast(func))( + (const void*)arg, a0, a1); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(volatile void*, A0, A1), volatile void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1) { + return (*static_cast(func))( + (volatile void*)arg, a0, a1); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(const volatile void*, A0, A1), const volatile void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1) { + return (*static_cast(func))( + (const volatile void*)arg, a0, a1); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(T*, A0, A1), T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1) { + return (*static_cast(func))( + (T*)arg, a0, a1); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(const T*, A0, A1), const T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1) { + return (*static_cast(func))( + (const T*)arg, a0, a1); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(volatile T*, A0, A1), volatile T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1) { + return (*static_cast(func))( + (volatile T*)arg, a0, a1); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(const volatile T*, A0, A1), const volatile T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1) { + return (*static_cast(func))( + (const volatile T*)arg, a0, a1); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(void *obj, R (*func)(void*, A0, A1)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1) { @@ -1054,7 +1947,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const void *obj, R (*func)(const void*, A0, A1)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1) { @@ -1072,7 +1969,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(volatile void *obj, R (*func)(volatile void*, A0, A1)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1) { @@ -1090,7 +1991,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1) { @@ -1108,8 +2013,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(T *obj, R (*func)(T*, A0, A1)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1) { @@ -1127,8 +2036,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const T *obj, R (*func)(const T*, A0, A1)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1) { @@ -1146,8 +2059,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(volatile T *obj, R (*func)(volatile T*, A0, A1)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1) { @@ -1165,8 +2082,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const volatile T *obj, R (*func)(const volatile T*, A0, A1)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1) { @@ -1181,86 +2102,6 @@ public: _thunk = &local::_thunk; } - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(T *obj, R (T::*func)(A0, A1)) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1) { - return (((T*)obj)->* - (*static_cast(func)))( - a0, a1); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(const T *obj, R (T::*func)(A0, A1) const) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1) { - return (((const T*)obj)->* - (*static_cast(func)))( - a0, a1); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(volatile T *obj, R (T::*func)(A0, A1) volatile) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1) { - return (((volatile T*)obj)->* - (*static_cast(func)))( - a0, a1); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(const volatile T *obj, R (T::*func)(A0, A1) const volatile) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1) { - return (((const volatile T*)obj)->* - (*static_cast(func)))( - a0, a1); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - /** Call the attached function */ R call(A0 a0, A1 a1) const { @@ -1325,118 +2166,218 @@ template class Callback { public: /** Create a Callback with a static function - * @param func Static function to attach + * @param func Static function to attach */ Callback(R (*func)(A0, A1, A2) = 0) { attach(func); } + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(T *obj, R (T::*method)(A0, A1, A2)) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(const T *obj, R (T::*method)(A0, A1, A2) const) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(volatile T *obj, R (T::*method)(A0, A1, A2) volatile) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(const volatile T *obj, R (T::*method)(A0, A1, A2) const volatile) { + attach(obj, method); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(void*, A0, A1, A2), void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(const void*, A0, A1, A2), const void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(volatile void*, A0, A1, A2), volatile void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(const volatile void*, A0, A1, A2), const volatile void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(T*, A0, A1, A2), T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(const T*, A0, A1, A2), const T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(volatile T*, A0, A1, A2), volatile T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(const volatile T*, A0, A1, A2), const volatile T *arg) { + attach(func, arg); + } + /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(void *obj, R (*func)(void*, A0, A1, A2)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const void *obj, R (*func)(const void*, A0, A1, A2)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(T *obj, R (*func)(T*, A0, A1, A2)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const T *obj, R (*func)(const T*, A0, A1, A2)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2)) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(T *obj, R (T::*func)(A0, A1, A2)) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(const T *obj, R (T::*func)(A0, A1, A2) const) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(volatile T *obj, R (T::*func)(A0, A1, A2) volatile) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(const volatile T *obj, R (T::*func)(A0, A1, A2) const volatile) { - attach(obj, func); + attach(func, obj); } /** Attach a static function - * @param func Static function to attach + * @param func Static function to attach */ void attach(R (*func)(A0, A1, A2)) { struct local { @@ -1453,7 +2394,7 @@ public: } /** Attach a Callback - * @param func The Callback to attach + * @param func The Callback to attach */ void attach(const Callback &func) { memset(&_func, 0, sizeof _func); @@ -1462,10 +2403,242 @@ public: _thunk = func._thunk; } + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(T *obj, R (T::*method)(A0, A1, A2)) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1, A2 a2) { + return (((T*)obj)->* + (*static_cast(method)))( + a0, a1, a2); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(const T *obj, R (T::*method)(A0, A1, A2) const) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1, A2 a2) { + return (((const T*)obj)->* + (*static_cast(method)))( + a0, a1, a2); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(volatile T *obj, R (T::*method)(A0, A1, A2) volatile) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1, A2 a2) { + return (((volatile T*)obj)->* + (*static_cast(method)))( + a0, a1, a2); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(const volatile T *obj, R (T::*method)(A0, A1, A2) const volatile) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1, A2 a2) { + return (((const volatile T*)obj)->* + (*static_cast(method)))( + a0, a1, a2); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(void*, A0, A1, A2), void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2) { + return (*static_cast(func))( + (void*)arg, a0, a1, a2); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(const void*, A0, A1, A2), const void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2) { + return (*static_cast(func))( + (const void*)arg, a0, a1, a2); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(volatile void*, A0, A1, A2), volatile void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2) { + return (*static_cast(func))( + (volatile void*)arg, a0, a1, a2); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(const volatile void*, A0, A1, A2), const volatile void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2) { + return (*static_cast(func))( + (const volatile void*)arg, a0, a1, a2); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(T*, A0, A1, A2), T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2) { + return (*static_cast(func))( + (T*)arg, a0, a1, a2); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(const T*, A0, A1, A2), const T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2) { + return (*static_cast(func))( + (const T*)arg, a0, a1, a2); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(volatile T*, A0, A1, A2), volatile T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2) { + return (*static_cast(func))( + (volatile T*)arg, a0, a1, a2); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(const volatile T*, A0, A1, A2), const volatile T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2) { + return (*static_cast(func))( + (const volatile T*)arg, a0, a1, a2); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(void *obj, R (*func)(void*, A0, A1, A2)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) { @@ -1483,7 +2656,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const void *obj, R (*func)(const void*, A0, A1, A2)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) { @@ -1501,7 +2678,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) { @@ -1519,7 +2700,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) { @@ -1537,8 +2722,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(T *obj, R (*func)(T*, A0, A1, A2)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) { @@ -1556,8 +2745,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const T *obj, R (*func)(const T*, A0, A1, A2)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) { @@ -1575,8 +2768,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(volatile T *obj, R (*func)(volatile T*, A0, A1, A2)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) { @@ -1594,8 +2791,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) { @@ -1610,86 +2811,6 @@ public: _thunk = &local::_thunk; } - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(T *obj, R (T::*func)(A0, A1, A2)) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) { - return (((T*)obj)->* - (*static_cast(func)))( - a0, a1, a2); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(const T *obj, R (T::*func)(A0, A1, A2) const) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) { - return (((const T*)obj)->* - (*static_cast(func)))( - a0, a1, a2); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(volatile T *obj, R (T::*func)(A0, A1, A2) volatile) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) { - return (((volatile T*)obj)->* - (*static_cast(func)))( - a0, a1, a2); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(const volatile T *obj, R (T::*func)(A0, A1, A2) const volatile) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) { - return (((const volatile T*)obj)->* - (*static_cast(func)))( - a0, a1, a2); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - /** Call the attached function */ R call(A0 a0, A1 a1, A2 a2) const { @@ -1754,118 +2875,218 @@ template class Callback { public: /** Create a Callback with a static function - * @param func Static function to attach + * @param func Static function to attach */ Callback(R (*func)(A0, A1, A2, A3) = 0) { attach(func); } + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(T *obj, R (T::*method)(A0, A1, A2, A3)) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(const T *obj, R (T::*method)(A0, A1, A2, A3) const) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(volatile T *obj, R (T::*method)(A0, A1, A2, A3) volatile) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(const volatile T *obj, R (T::*method)(A0, A1, A2, A3) const volatile) { + attach(obj, method); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(void*, A0, A1, A2, A3), void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(const void*, A0, A1, A2, A3), const void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(volatile void*, A0, A1, A2, A3), volatile void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(const volatile void*, A0, A1, A2, A3), const volatile void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(T*, A0, A1, A2, A3), T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(const T*, A0, A1, A2, A3), const T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(volatile T*, A0, A1, A2, A3), volatile T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile T *arg) { + attach(func, arg); + } + /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(void *obj, R (*func)(void*, A0, A1, A2, A3)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(T *obj, R (*func)(T*, A0, A1, A2, A3)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(T *obj, R (T::*func)(A0, A1, A2, A3)) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(const T *obj, R (T::*func)(A0, A1, A2, A3) const) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(volatile T *obj, R (T::*func)(A0, A1, A2, A3) volatile) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(const volatile T *obj, R (T::*func)(A0, A1, A2, A3) const volatile) { - attach(obj, func); + attach(func, obj); } /** Attach a static function - * @param func Static function to attach + * @param func Static function to attach */ void attach(R (*func)(A0, A1, A2, A3)) { struct local { @@ -1882,7 +3103,7 @@ public: } /** Attach a Callback - * @param func The Callback to attach + * @param func The Callback to attach */ void attach(const Callback &func) { memset(&_func, 0, sizeof _func); @@ -1891,10 +3112,242 @@ public: _thunk = func._thunk; } + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(T *obj, R (T::*method)(A0, A1, A2, A3)) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1, A2 a2, A3 a3) { + return (((T*)obj)->* + (*static_cast(method)))( + a0, a1, a2, a3); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(const T *obj, R (T::*method)(A0, A1, A2, A3) const) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1, A2 a2, A3 a3) { + return (((const T*)obj)->* + (*static_cast(method)))( + a0, a1, a2, a3); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(volatile T *obj, R (T::*method)(A0, A1, A2, A3) volatile) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1, A2 a2, A3 a3) { + return (((volatile T*)obj)->* + (*static_cast(method)))( + a0, a1, a2, a3); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(const volatile T *obj, R (T::*method)(A0, A1, A2, A3) const volatile) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1, A2 a2, A3 a3) { + return (((const volatile T*)obj)->* + (*static_cast(method)))( + a0, a1, a2, a3); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(void*, A0, A1, A2, A3), void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { + return (*static_cast(func))( + (void*)arg, a0, a1, a2, a3); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(const void*, A0, A1, A2, A3), const void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { + return (*static_cast(func))( + (const void*)arg, a0, a1, a2, a3); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(volatile void*, A0, A1, A2, A3), volatile void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { + return (*static_cast(func))( + (volatile void*)arg, a0, a1, a2, a3); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(const volatile void*, A0, A1, A2, A3), const volatile void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { + return (*static_cast(func))( + (const volatile void*)arg, a0, a1, a2, a3); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(T*, A0, A1, A2, A3), T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { + return (*static_cast(func))( + (T*)arg, a0, a1, a2, a3); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(const T*, A0, A1, A2, A3), const T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { + return (*static_cast(func))( + (const T*)arg, a0, a1, a2, a3); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(volatile T*, A0, A1, A2, A3), volatile T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { + return (*static_cast(func))( + (volatile T*)arg, a0, a1, a2, a3); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { + return (*static_cast(func))( + (const volatile T*)arg, a0, a1, a2, a3); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(void *obj, R (*func)(void*, A0, A1, A2, A3)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { @@ -1912,7 +3365,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { @@ -1930,7 +3387,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { @@ -1948,7 +3409,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { @@ -1966,8 +3431,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(T *obj, R (*func)(T*, A0, A1, A2, A3)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { @@ -1985,8 +3454,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const T *obj, R (*func)(const T*, A0, A1, A2, A3)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { @@ -2004,8 +3477,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { @@ -2023,8 +3500,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { @@ -2039,86 +3520,6 @@ public: _thunk = &local::_thunk; } - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(T *obj, R (T::*func)(A0, A1, A2, A3)) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { - return (((T*)obj)->* - (*static_cast(func)))( - a0, a1, a2, a3); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(const T *obj, R (T::*func)(A0, A1, A2, A3) const) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { - return (((const T*)obj)->* - (*static_cast(func)))( - a0, a1, a2, a3); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(volatile T *obj, R (T::*func)(A0, A1, A2, A3) volatile) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { - return (((volatile T*)obj)->* - (*static_cast(func)))( - a0, a1, a2, a3); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(const volatile T *obj, R (T::*func)(A0, A1, A2, A3) const volatile) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) { - return (((const volatile T*)obj)->* - (*static_cast(func)))( - a0, a1, a2, a3); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - /** Call the attached function */ R call(A0 a0, A1 a1, A2 a2, A3 a3) const { @@ -2183,118 +3584,218 @@ template { public: /** Create a Callback with a static function - * @param func Static function to attach + * @param func Static function to attach */ Callback(R (*func)(A0, A1, A2, A3, A4) = 0) { attach(func); } + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(T *obj, R (T::*method)(A0, A1, A2, A3, A4)) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(const T *obj, R (T::*method)(A0, A1, A2, A3, A4) const) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) { + attach(obj, method); + } + + /** Create a Callback with a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + Callback(const volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) { + attach(obj, method); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(void*, A0, A1, A2, A3, A4), void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(const void*, A0, A1, A2, A3, A4), const void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(volatile void*, A0, A1, A2, A3, A4), volatile void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + Callback(R (*func)(const volatile void*, A0, A1, A2, A3, A4), const volatile void *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(T*, A0, A1, A2, A3, A4), T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(const T*, A0, A1, A2, A3, A4), const T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile T *arg) { + attach(func, arg); + } + + /** Create a Callback with a static function and bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + Callback(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile T *arg) { + attach(func, arg); + } + /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(T *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { - attach(obj, func); + attach(func, obj); } /** Create a Callback with a static function and bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to Callback(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to Callback(func, arg)") Callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(T *obj, R (T::*func)(A0, A1, A2, A3, A4)) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(const T *obj, R (T::*func)(A0, A1, A2, A3, A4) const) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(volatile T *obj, R (T::*func)(A0, A1, A2, A3, A4) volatile) { - attach(obj, func); - } - - /** Create a Callback with a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - Callback(const volatile T *obj, R (T::*func)(A0, A1, A2, A3, A4) const volatile) { - attach(obj, func); + attach(func, obj); } /** Attach a static function - * @param func Static function to attach + * @param func Static function to attach */ void attach(R (*func)(A0, A1, A2, A3, A4)) { struct local { @@ -2311,7 +3812,7 @@ public: } /** Attach a Callback - * @param func The Callback to attach + * @param func The Callback to attach */ void attach(const Callback &func) { memset(&_func, 0, sizeof _func); @@ -2320,10 +3821,242 @@ public: _thunk = func._thunk; } + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(T *obj, R (T::*method)(A0, A1, A2, A3, A4)) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { + return (((T*)obj)->* + (*static_cast(method)))( + a0, a1, a2, a3, a4); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(const T *obj, R (T::*method)(A0, A1, A2, A3, A4) const) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { + return (((const T*)obj)->* + (*static_cast(method)))( + a0, a1, a2, a3, a4); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { + return (((volatile T*)obj)->* + (*static_cast(method)))( + a0, a1, a2, a3, a4); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a member function + * @param obj Pointer to object to invoke member function on + * @param method Member function to attach + */ + template + void attach(const volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) { + struct local { + static R _thunk(void *obj, const void *method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { + return (((const volatile T*)obj)->* + (*static_cast(method)))( + a0, a1, a2, a3, a4); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &obj, sizeof obj); + _obj = (void*)obj; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(void*, A0, A1, A2, A3, A4), void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { + return (*static_cast(func))( + (void*)arg, a0, a1, a2, a3, a4); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(const void*, A0, A1, A2, A3, A4), const void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { + return (*static_cast(func))( + (const void*)arg, a0, a1, a2, a3, a4); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(volatile void*, A0, A1, A2, A3, A4), volatile void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { + return (*static_cast(func))( + (volatile void*)arg, a0, a1, a2, a3, a4); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + void attach(R (*func)(const volatile void*, A0, A1, A2, A3, A4), const volatile void *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { + return (*static_cast(func))( + (const volatile void*)arg, a0, a1, a2, a3, a4); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(T*, A0, A1, A2, A3, A4), T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { + return (*static_cast(func))( + (T*)arg, a0, a1, a2, a3, a4); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(const T*, A0, A1, A2, A3, A4), const T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { + return (*static_cast(func))( + (const T*)arg, a0, a1, a2, a3, a4); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { + return (*static_cast(func))( + (volatile T*)arg, a0, a1, a2, a3, a4); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + + /** Attach a static function with a bound pointer + * @param func Static function to attach + * @param arg Pointer argument to function + */ + template + void attach(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile T *arg) { + struct local { + static R _thunk(void *arg, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { + return (*static_cast(func))( + (const volatile T*)arg, a0, a1, a2, a3, a4); + } + }; + + memset(&_func, 0, sizeof _func); + memcpy(&_func, &func, sizeof func); + _obj = (void*)arg; + _thunk = &local::_thunk; + } + /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { @@ -2341,7 +4074,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { @@ -2359,7 +4096,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { @@ -2377,7 +4118,11 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { @@ -2395,8 +4140,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(T *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { @@ -2414,8 +4163,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const T *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { @@ -2433,8 +4186,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { @@ -2452,8 +4209,12 @@ public: /** Attach a static function with a bound pointer * @param obj Pointer to object to bind to function * @param func Static function to attach + * @deprecated + * Arguments to callback have been reordered to attach(func, arg) */ template + MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to attach(func, arg)") void attach(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { struct local { static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { @@ -2468,86 +4229,6 @@ public: _thunk = &local::_thunk; } - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(T *obj, R (T::*func)(A0, A1, A2, A3, A4)) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { - return (((T*)obj)->* - (*static_cast(func)))( - a0, a1, a2, a3, a4); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(const T *obj, R (T::*func)(A0, A1, A2, A3, A4) const) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { - return (((const T*)obj)->* - (*static_cast(func)))( - a0, a1, a2, a3, a4); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(volatile T *obj, R (T::*func)(A0, A1, A2, A3, A4) volatile) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { - return (((volatile T*)obj)->* - (*static_cast(func)))( - a0, a1, a2, a3, a4); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - - /** Attach a member function - * @param obj Pointer to object to invoke member function on - * @param func Member function to attach - */ - template - void attach(const volatile T *obj, R (T::*func)(A0, A1, A2, A3, A4) const volatile) { - struct local { - static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { - return (((const volatile T*)obj)->* - (*static_cast(func)))( - a0, a1, a2, a3, a4); - } - }; - - memset(&_func, 0, sizeof _func); - memcpy(&_func, &func, sizeof func); - _obj = (void*)obj; - _thunk = &local::_thunk; - } - /** Call the attached function */ R call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { @@ -2610,8 +4291,8 @@ typedef Callback event_callback_t; /** Create a callback class with type infered from the arguments * - * @param func Static function to attach - * @return Callback with infered type + * @param func Static function to attach + * @return Callback with infered type */ template Callback callback(R (*func)() = 0) { @@ -2620,8 +4301,8 @@ Callback callback(R (*func)() = 0) { /** Create a callback class with type infered from the arguments * - * @param func Static function to attach - * @return Callback with infered type + * @param func Static function to attach + * @return Callback with infered type */ template Callback callback(const Callback &func) { @@ -2630,97 +4311,9 @@ Callback callback(const Callback &func) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(void *obj, R (*func)(void*)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const void *obj, R (*func)(const void*)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(volatile void *obj, R (*func)(volatile void*)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const volatile void *obj, R (*func)(const volatile void*)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(T *obj, R (*func)(T*)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const T *obj, R (*func)(const T*)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(volatile T *obj, R (*func)(volatile T*)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const volatile T *obj, R (*func)(const volatile T*)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(T *obj, R (T::*func)()) { @@ -2729,9 +4322,9 @@ Callback callback(T *obj, R (T::*func)()) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(const T *obj, R (T::*func)() const) { @@ -2740,9 +4333,9 @@ Callback callback(const T *obj, R (T::*func)() const) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(volatile T *obj, R (T::*func)() volatile) { @@ -2751,20 +4344,228 @@ Callback callback(volatile T *obj, R (T::*func)() volatile) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(const volatile T *obj, R (T::*func)() const volatile) { return Callback(obj, func); } +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(void*), void *arg) { + return Callback(func, arg); +} /** Create a callback class with type infered from the arguments * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const void*), const void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(volatile void*), volatile void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const volatile void*), const volatile void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(T*), T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const T*), const T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(volatile T*), volatile T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const volatile T*), const volatile T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function * @param func Static function to attach * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(void *obj, R (*func)(void*)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const void *obj, R (*func)(const void*)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(volatile void *obj, R (*func)(volatile void*)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const volatile void *obj, R (*func)(const volatile void*)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(T *obj, R (*func)(T*)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const T *obj, R (*func)(const T*)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(volatile T *obj, R (*func)(volatile T*)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const volatile T *obj, R (*func)(const volatile T*)) { + return Callback(func, obj); +} + + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @return Callback with infered type */ template Callback callback(R (*func)(A0) = 0) { @@ -2773,8 +4574,8 @@ Callback callback(R (*func)(A0) = 0) { /** Create a callback class with type infered from the arguments * - * @param func Static function to attach - * @return Callback with infered type + * @param func Static function to attach + * @return Callback with infered type */ template Callback callback(const Callback &func) { @@ -2783,97 +4584,9 @@ Callback callback(const Callback &func) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(void *obj, R (*func)(void*, A0)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const void *obj, R (*func)(const void*, A0)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(volatile void *obj, R (*func)(volatile void*, A0)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const volatile void *obj, R (*func)(const volatile void*, A0)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(T *obj, R (*func)(T*, A0)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const T *obj, R (*func)(const T*, A0)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(volatile T *obj, R (*func)(volatile T*, A0)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const volatile T *obj, R (*func)(const volatile T*, A0)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(T *obj, R (T::*func)(A0)) { @@ -2882,9 +4595,9 @@ Callback callback(T *obj, R (T::*func)(A0)) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(const T *obj, R (T::*func)(A0) const) { @@ -2893,9 +4606,9 @@ Callback callback(const T *obj, R (T::*func)(A0) const) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(volatile T *obj, R (T::*func)(A0) volatile) { @@ -2904,20 +4617,228 @@ Callback callback(volatile T *obj, R (T::*func)(A0) volatile) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(const volatile T *obj, R (T::*func)(A0) const volatile) { return Callback(obj, func); } +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(void*, A0), void *arg) { + return Callback(func, arg); +} /** Create a callback class with type infered from the arguments * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const void*, A0), const void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(volatile void*, A0), volatile void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const volatile void*, A0), const volatile void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(T*, A0), T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const T*, A0), const T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(volatile T*, A0), volatile T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const volatile T*, A0), const volatile T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function * @param func Static function to attach * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(void *obj, R (*func)(void*, A0)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const void *obj, R (*func)(const void*, A0)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(volatile void *obj, R (*func)(volatile void*, A0)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const volatile void *obj, R (*func)(const volatile void*, A0)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(T *obj, R (*func)(T*, A0)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const T *obj, R (*func)(const T*, A0)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(volatile T *obj, R (*func)(volatile T*, A0)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const volatile T *obj, R (*func)(const volatile T*, A0)) { + return Callback(func, obj); +} + + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @return Callback with infered type */ template Callback callback(R (*func)(A0, A1) = 0) { @@ -2926,8 +4847,8 @@ Callback callback(R (*func)(A0, A1) = 0) { /** Create a callback class with type infered from the arguments * - * @param func Static function to attach - * @return Callback with infered type + * @param func Static function to attach + * @return Callback with infered type */ template Callback callback(const Callback &func) { @@ -2936,97 +4857,9 @@ Callback callback(const Callback &func) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(void *obj, R (*func)(void*, A0, A1)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const void *obj, R (*func)(const void*, A0, A1)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(volatile void *obj, R (*func)(volatile void*, A0, A1)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(T *obj, R (*func)(T*, A0, A1)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const T *obj, R (*func)(const T*, A0, A1)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(volatile T *obj, R (*func)(volatile T*, A0, A1)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(T *obj, R (T::*func)(A0, A1)) { @@ -3035,9 +4868,9 @@ Callback callback(T *obj, R (T::*func)(A0, A1)) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(const T *obj, R (T::*func)(A0, A1) const) { @@ -3046,9 +4879,9 @@ Callback callback(const T *obj, R (T::*func)(A0, A1) const) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(volatile T *obj, R (T::*func)(A0, A1) volatile) { @@ -3057,20 +4890,228 @@ Callback callback(volatile T *obj, R (T::*func)(A0, A1) volatile) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(const volatile T *obj, R (T::*func)(A0, A1) const volatile) { return Callback(obj, func); } +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(void*, A0, A1), void *arg) { + return Callback(func, arg); +} /** Create a callback class with type infered from the arguments * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const void*, A0, A1), const void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(volatile void*, A0, A1), volatile void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const volatile void*, A0, A1), const volatile void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(T*, A0, A1), T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const T*, A0, A1), const T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(volatile T*, A0, A1), volatile T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const volatile T*, A0, A1), const volatile T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function * @param func Static function to attach * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(void *obj, R (*func)(void*, A0, A1)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const void *obj, R (*func)(const void*, A0, A1)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(volatile void *obj, R (*func)(volatile void*, A0, A1)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(T *obj, R (*func)(T*, A0, A1)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const T *obj, R (*func)(const T*, A0, A1)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(volatile T *obj, R (*func)(volatile T*, A0, A1)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1)) { + return Callback(func, obj); +} + + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @return Callback with infered type */ template Callback callback(R (*func)(A0, A1, A2) = 0) { @@ -3079,8 +5120,8 @@ Callback callback(R (*func)(A0, A1, A2) = 0) { /** Create a callback class with type infered from the arguments * - * @param func Static function to attach - * @return Callback with infered type + * @param func Static function to attach + * @return Callback with infered type */ template Callback callback(const Callback &func) { @@ -3089,97 +5130,9 @@ Callback callback(const Callback &func) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(void *obj, R (*func)(void*, A0, A1, A2)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const void *obj, R (*func)(const void*, A0, A1, A2)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(T *obj, R (*func)(T*, A0, A1, A2)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const T *obj, R (*func)(const T*, A0, A1, A2)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(T *obj, R (T::*func)(A0, A1, A2)) { @@ -3188,9 +5141,9 @@ Callback callback(T *obj, R (T::*func)(A0, A1, A2)) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(const T *obj, R (T::*func)(A0, A1, A2) const) { @@ -3199,9 +5152,9 @@ Callback callback(const T *obj, R (T::*func)(A0, A1, A2) const) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(volatile T *obj, R (T::*func)(A0, A1, A2) volatile) { @@ -3210,20 +5163,228 @@ Callback callback(volatile T *obj, R (T::*func)(A0, A1, A2) volat /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(const volatile T *obj, R (T::*func)(A0, A1, A2) const volatile) { return Callback(obj, func); } +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(void*, A0, A1, A2), void *arg) { + return Callback(func, arg); +} /** Create a callback class with type infered from the arguments * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const void*, A0, A1, A2), const void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(volatile void*, A0, A1, A2), volatile void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const volatile void*, A0, A1, A2), const volatile void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(T*, A0, A1, A2), T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const T*, A0, A1, A2), const T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(volatile T*, A0, A1, A2), volatile T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const volatile T*, A0, A1, A2), const volatile T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function * @param func Static function to attach * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(void *obj, R (*func)(void*, A0, A1, A2)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const void *obj, R (*func)(const void*, A0, A1, A2)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(T *obj, R (*func)(T*, A0, A1, A2)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const T *obj, R (*func)(const T*, A0, A1, A2)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2)) { + return Callback(func, obj); +} + + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @return Callback with infered type */ template Callback callback(R (*func)(A0, A1, A2, A3) = 0) { @@ -3232,8 +5393,8 @@ Callback callback(R (*func)(A0, A1, A2, A3) = 0) { /** Create a callback class with type infered from the arguments * - * @param func Static function to attach - * @return Callback with infered type + * @param func Static function to attach + * @return Callback with infered type */ template Callback callback(const Callback &func) { @@ -3242,97 +5403,9 @@ Callback callback(const Callback &func) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(void *obj, R (*func)(void*, A0, A1, A2, A3)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(T *obj, R (*func)(T*, A0, A1, A2, A3)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(T *obj, R (T::*func)(A0, A1, A2, A3)) { @@ -3341,9 +5414,9 @@ Callback callback(T *obj, R (T::*func)(A0, A1, A2, A3)) { /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(const T *obj, R (T::*func)(A0, A1, A2, A3) const) { @@ -3352,9 +5425,9 @@ Callback callback(const T *obj, R (T::*func)(A0, A1, A2, A3) /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(volatile T *obj, R (T::*func)(A0, A1, A2, A3) volatile) { @@ -3363,20 +5436,228 @@ Callback callback(volatile T *obj, R (T::*func)(A0, A1, A2, A /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(const volatile T *obj, R (T::*func)(A0, A1, A2, A3) const volatile) { return Callback(obj, func); } +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(void*, A0, A1, A2, A3), void *arg) { + return Callback(func, arg); +} /** Create a callback class with type infered from the arguments * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const void*, A0, A1, A2, A3), const void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(volatile void*, A0, A1, A2, A3), volatile void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const volatile void*, A0, A1, A2, A3), const volatile void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(T*, A0, A1, A2, A3), T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const T*, A0, A1, A2, A3), const T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(volatile T*, A0, A1, A2, A3), volatile T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function * @param func Static function to attach * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(void *obj, R (*func)(void*, A0, A1, A2, A3)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(T *obj, R (*func)(T*, A0, A1, A2, A3)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { + return Callback(func, obj); +} + + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @return Callback with infered type */ template Callback callback(R (*func)(A0, A1, A2, A3, A4) = 0) { @@ -3385,8 +5666,8 @@ Callback callback(R (*func)(A0, A1, A2, A3, A4) = 0) { /** Create a callback class with type infered from the arguments * - * @param func Static function to attach - * @return Callback with infered type + * @param func Static function to attach + * @return Callback with infered type */ template Callback callback(const Callback &func) { @@ -3395,97 +5676,9 @@ Callback callback(const Callback & /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(T *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type - */ -template -Callback callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { - return Callback(obj, func); -} - -/** Create a callback class with type infered from the arguments - * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(T *obj, R (T::*func)(A0, A1, A2, A3, A4)) { @@ -3494,9 +5687,9 @@ Callback callback(T *obj, R (T::*func)(A0, A1, A2, A3, A4 /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(const T *obj, R (T::*func)(A0, A1, A2, A3, A4) const) { @@ -3505,9 +5698,9 @@ Callback callback(const T *obj, R (T::*func)(A0, A1, A2, /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(volatile T *obj, R (T::*func)(A0, A1, A2, A3, A4) volatile) { @@ -3516,16 +5709,224 @@ Callback callback(volatile T *obj, R (T::*func)(A0, A1, A /** Create a callback class with type infered from the arguments * - * @param obj Optional pointer to object to bind to function - * @param func Static function to attach - * @return Callback with infered type + * @param obj Optional pointer to object to bind to function + * @param method Member function to attach + * @return Callback with infered type */ template Callback callback(const volatile T *obj, R (T::*func)(A0, A1, A2, A3, A4) const volatile) { return Callback(obj, func); } +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(void*, A0, A1, A2, A3, A4), void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const void*, A0, A1, A2, A3, A4), const void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(volatile void*, A0, A1, A2, A3, A4), volatile void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const volatile void*, A0, A1, A2, A3, A4), const volatile void *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(T*, A0, A1, A2, A3, A4), T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const T*, A0, A1, A2, A3, A4), const T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param func Static function to attach + * @param arg Pointer argument to function + * @return Callback with infered type + */ +template +Callback callback(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile T *arg) { + return Callback(func, arg); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(T *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { + return Callback(func, obj); +} + +/** Create a callback class with type infered from the arguments + * + * @param obj Optional pointer to object to bind to function + * @param func Static function to attach + * @return Callback with infered type + * @deprecated + * Arguments to callback have been reordered to callback(func, arg) + */ +template +MBED_DEPRECATED_SINCE("mbed-os-5.1", + "Arguments to callback have been reordered to callback(func, arg)") +Callback callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { + return Callback(func, obj); +} + } // namespace mbed -#endif +#endif \ No newline at end of file diff --git a/rtos/rtos/RtosTimer.h b/rtos/rtos/RtosTimer.h index 3f39a3999a..b2f5c3d4c0 100644 --- a/rtos/rtos/RtosTimer.h +++ b/rtos/rtos/RtosTimer.h @@ -47,7 +47,7 @@ public: MBED_DEPRECATED_SINCE("mbed-os-5.1", "Replaced with RtosTimer(Callback, os_timer_type)") RtosTimer(void (*func)(void const *argument), os_timer_type type=osTimerPeriodic, void *argument=NULL) { - constructor(mbed::callback(argument, (void (*)(void *))func), type); + constructor(mbed::callback((void (*)(void *))func, argument), type); } /** Create timer. diff --git a/rtos/rtos/Thread.h b/rtos/rtos/Thread.h index 5c6114f355..00ef016ea7 100644 --- a/rtos/rtos/Thread.h +++ b/rtos/rtos/Thread.h @@ -108,12 +108,12 @@ public: @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE). @param stack_pointer pointer to the stack area to be used by this thread (default: NULL). @deprecated - Thread-spawning constructors hide errors. Replaced by thread.start(callback(argument, task)). + Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)). @code Thread thread(priority, stack_size, stack_pointer); - osStatus status = thread.start(callback(argument, task)); + osStatus status = thread.start(callback(task, argument)); if (status != osOK) { error("oh no!"); } @@ -122,12 +122,12 @@ public: template MBED_DEPRECATED_SINCE("mbed-os-5.1", "Thread-spawning constructors hide errors. " - "Replaced by thread.start(callback(argument, task)).") + "Replaced by thread.start(callback(task, argument)).") Thread(T *argument, void (T::*task)(), osPriority priority=osPriorityNormal, uint32_t stack_size=DEFAULT_STACK_SIZE, unsigned char *stack_pointer=NULL) { - constructor(mbed::callback(argument, task), + constructor(mbed::callback(task, argument), priority, stack_size, stack_pointer); } @@ -139,12 +139,12 @@ public: @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE). @param stack_pointer pointer to the stack area to be used by this thread (default: NULL). @deprecated - Thread-spawning constructors hide errors. Replaced by thread.start(callback(argument, task)). + Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)). @code Thread thread(priority, stack_size, stack_pointer); - osStatus status = thread.start(callback(argument, task)); + osStatus status = thread.start(callback(task, argument)); if (status != osOK) { error("oh no!"); } @@ -153,12 +153,12 @@ public: template MBED_DEPRECATED_SINCE("mbed-os-5.1", "Thread-spawning constructors hide errors. " - "Replaced by thread.start(callback(argument, task)).") + "Replaced by thread.start(callback(task, argument)).") Thread(T *argument, void (*task)(T *), osPriority priority=osPriorityNormal, uint32_t stack_size=DEFAULT_STACK_SIZE, unsigned char *stack_pointer=NULL) { - constructor(mbed::callback(argument, task), + constructor(mbed::callback(task, argument), priority, stack_size, stack_pointer); } @@ -170,12 +170,12 @@ public: @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE). @param stack_pointer pointer to the stack area to be used by this thread (default: NULL). @deprecated - Thread-spawning constructors hide errors. Replaced by thread.start(callback(argument, task)). + Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)). @code Thread thread(priority, stack_size, stack_pointer); - osStatus status = thread.start(callback(argument, task)); + osStatus status = thread.start(callback(task, argument)); if (status != osOK) { error("oh no!"); } @@ -183,12 +183,12 @@ public: */ MBED_DEPRECATED_SINCE("mbed-os-5.1", "Thread-spawning constructors hide errors. " - "Replaced by thread.start(callback(argument, task)).") + "Replaced by thread.start(callback(task, argument)).") Thread(void (*task)(void const *argument), void *argument=NULL, osPriority priority=osPriorityNormal, uint32_t stack_size=DEFAULT_STACK_SIZE, unsigned char *stack_pointer=NULL) { - constructor(mbed::callback(argument, (void (*)(void *))task), + constructor(mbed::callback((void (*)(void *))task, argument), priority, stack_size, stack_pointer); }