Modified for BG96
Fork of mbed-dev by
Diff: platform/Callback.h
- Revision:
- 187:0387e8f68319
- Parent:
- 184:08ed48f1de7f
--- a/platform/Callback.h Fri Jun 22 16:45:37 2018 +0100 +++ b/platform/Callback.h Thu Sep 06 13:40:20 2018 +0100 @@ -47,18 +47,20 @@ // massive and misleading error messages when confronted with an // invalid type (or worse, runtime failures) namespace detail { - struct nil {}; - - template <bool B, typename R = nil> - struct enable_if { typedef R type; }; - - template <typename R> - struct enable_if<false, R> {}; - - template <typename M, M> - struct is_type { - static const bool value = true; - }; +struct nil {}; + +template <bool B, typename R = nil> +struct enable_if { + typedef R type; +}; + +template <typename R> +struct enable_if<false, R> {}; + +template <typename M, M> +struct is_type { + static const bool value = true; +}; } #define MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, M) \ @@ -77,7 +79,8 @@ /** Create a Callback with a static function * @param func Static function to attach */ - Callback(R (*func)() = 0) { + Callback(R(*func)() = 0) + { if (!func) { memset(this, 0, sizeof(Callback)); } else { @@ -88,7 +91,8 @@ /** Attach a Callback * @param func The Callback to attach */ - Callback(const Callback<R()> &func) { + Callback(const Callback<R()> &func) + { if (func._ops) { func._ops->move(this, &func); } @@ -100,8 +104,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(U *obj, R (T::*method)()) { - generate(method_context<T, R (T::*)()>(obj, method)); + Callback(U *obj, R(T::*method)()) + { + generate(method_context<T, R(T::*)()>(obj, method)); } /** Create a Callback with a member function @@ -109,8 +114,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(const U *obj, R (T::*method)() const) { - generate(method_context<const T, R (T::*)() const>(obj, method)); + Callback(const U *obj, R(T::*method)() const) + { + generate(method_context<const T, R(T::*)() const>(obj, method)); } /** Create a Callback with a member function @@ -118,8 +124,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(volatile U *obj, R (T::*method)() volatile) { - generate(method_context<volatile T, R (T::*)() volatile>(obj, method)); + Callback(volatile U *obj, R(T::*method)() volatile) + { + generate(method_context<volatile T, R(T::*)() volatile>(obj, method)); } /** Create a Callback with a member function @@ -127,44 +134,49 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(const volatile U *obj, R (T::*method)() const volatile) { - generate(method_context<const volatile T, R (T::*)() const volatile>(obj, method)); + Callback(const volatile U *obj, R(T::*method)() const volatile) + { + generate(method_context<const volatile T, R(T::*)() const volatile>(obj, method)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(T*), U *arg) { - generate(function_context<R (*)(T*), T>(func, arg)); + Callback(R(*func)(T *), U *arg) + { + generate(function_context<R(*)(T *), T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(const T*), const U *arg) { - generate(function_context<R (*)(const T*), const T>(func, arg)); + Callback(R(*func)(const T *), const U *arg) + { + generate(function_context<R(*)(const T *), const T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(volatile T*), volatile U *arg) { - generate(function_context<R (*)(volatile T*), volatile T>(func, arg)); + Callback(R(*func)(volatile T *), volatile U *arg) + { + generate(function_context<R(*)(volatile T *), volatile T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(const volatile T*), const volatile U *arg) { - generate(function_context<R (*)(const volatile T*), const volatile T>(func, arg)); + Callback(R(*func)(const volatile T *), const volatile U *arg) + { + generate(function_context<R(*)(const volatile T *), const volatile T>(func, arg)); } /** Create a Callback with a function object @@ -172,7 +184,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)())) { + Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)())) + { generate(f); } @@ -181,7 +194,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)() const)) { + Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)() const)) + { generate(f); } @@ -190,7 +204,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)() volatile)) { + Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)() volatile)) + { generate(f); } @@ -199,7 +214,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)() const volatile)) { + Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)() const volatile)) + { generate(f); } @@ -211,8 +227,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(U *obj, R (*func)(T*)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(U *obj, R(*func)(T *)) + { new (this) Callback(func, obj); } @@ -224,8 +241,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(const U *obj, R (*func)(const T*)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(const U *obj, R(*func)(const T *)) + { new (this) Callback(func, obj); } @@ -237,8 +255,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(volatile U *obj, R (*func)(volatile T*)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(volatile U *obj, R(*func)(volatile T *)) + { new (this) Callback(func, obj); } @@ -250,14 +269,16 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(const volatile U *obj, R (*func)(const volatile T*)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(const volatile U *obj, R(*func)(const volatile T *)) + { new (this) Callback(func, obj); } /** Destroy a callback */ - ~Callback() { + ~Callback() + { if (_ops) { _ops->dtor(this); } @@ -269,8 +290,9 @@ * Replaced by simple assignment 'Callback cb = func' */ MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)()) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)()) + { this->~Callback(); new (this) Callback(func); } @@ -281,8 +303,9 @@ * Replaced by simple assignment 'Callback cb = func' */ MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const Callback<R()> &func) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const Callback<R()> &func) + { this->~Callback(); new (this) Callback(func); } @@ -295,8 +318,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(U *obj, R (T::*method)()) { + "Replaced by simple assignment 'Callback cb = func") + void attach(U *obj, R(T::*method)()) + { this->~Callback(); new (this) Callback(obj, method); } @@ -309,8 +333,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const U *obj, R (T::*method)() const) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const U *obj, R(T::*method)() const) + { this->~Callback(); new (this) Callback(obj, method); } @@ -323,8 +348,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(volatile U *obj, R (T::*method)() volatile) { + "Replaced by simple assignment 'Callback cb = func") + void attach(volatile U *obj, R(T::*method)() volatile) + { this->~Callback(); new (this) Callback(obj, method); } @@ -337,8 +363,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile U *obj, R (T::*method)() const volatile) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const volatile U *obj, R(T::*method)() const volatile) + { this->~Callback(); new (this) Callback(obj, method); } @@ -351,8 +378,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(T*), U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(T *), U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -365,8 +393,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(const T*), const U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(const T *), const U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -379,8 +408,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(volatile T*), volatile U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(volatile T *), volatile U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -393,8 +423,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(const volatile T*), const volatile U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(const volatile T *), const volatile U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -407,8 +438,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)())) { + "Replaced by simple assignment 'Callback cb = func") + void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)())) + { this->~Callback(); new (this) Callback(f); } @@ -421,8 +453,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)() const)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)() const)) + { this->~Callback(); new (this) Callback(f); } @@ -435,8 +468,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)() volatile)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)() volatile)) + { this->~Callback(); new (this) Callback(f); } @@ -449,8 +483,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)() const volatile)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)() const volatile)) + { this->~Callback(); new (this) Callback(f); } @@ -463,8 +498,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(U *obj, R (*func)(T*)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(U *obj, R(*func)(T *)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -477,8 +513,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(const U *obj, R (*func)(const T*)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(const U *obj, R(*func)(const T *)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -491,8 +528,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(volatile U *obj, R (*func)(volatile T*)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(volatile U *obj, R(*func)(volatile T *)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -505,15 +543,17 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(const volatile U *obj, R (*func)(const volatile T*)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(const volatile U *obj, R(*func)(const volatile T *)) + { this->~Callback(); new (this) Callback(func, obj); } /** Assign a callback */ - Callback &operator=(const Callback &that) { + Callback &operator=(const Callback &that) + { if (this != &that) { this->~Callback(); new (this) Callback(that); @@ -524,42 +564,48 @@ /** Call the attached function */ - R call() const { + R call() const + { MBED_ASSERT(_ops); return _ops->call(this); } /** Call the attached function */ - R operator()() const { + R operator()() const + { return call(); } /** Test if function has been attached */ - operator bool() const { + operator bool() const + { return _ops; } /** Test for equality */ - friend bool operator==(const Callback &l, const Callback &r) { + friend bool operator==(const Callback &l, const Callback &r) + { return memcmp(&l, &r, sizeof(Callback)) == 0; } /** Test for inequality */ - friend bool operator!=(const Callback &l, const Callback &r) { + friend bool operator!=(const Callback &l, const Callback &r) + { return !(l == r); } /** Static thunk for passing as C-style function * @param func Callback to call passed as void pointer - * @return the value as determined by func which is of + * @return the value as determined by func which is of * type and determined by the signiture of func */ - static R thunk(void *func) { - return static_cast<Callback*>(func)->call(); + static R thunk(void *func) + { + return static_cast<Callback *>(func)->call(); } private: @@ -569,21 +615,22 @@ struct _class; union { void (*_staticfunc)(); - void (*_boundfunc)(_class*); + void (*_boundfunc)(_class *); void (_class::*_methodfunc)(); } _func; void *_obj; // Dynamically dispatched operations const struct ops { - R (*call)(const void*); - void (*move)(void*, const void*); - void (*dtor)(void*); + R(*call)(const void *); + void (*move)(void *, const void *); + void (*dtor)(void *); } *_ops; // Generate operations for function object template <typename F> - void generate(const F &f) { + void generate(const F &f) + { static const ops ops = { &Callback::function_call<F>, &Callback::function_move<F>, @@ -591,7 +638,7 @@ }; MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F), - "Type F must not exceed the size of the Callback class"); + "Type F must not exceed the size of the Callback class"); memset(this, 0, sizeof(Callback)); new (this) F(f); _ops = &ops; @@ -599,18 +646,21 @@ // Function attributes template <typename F> - static R function_call(const void *p) { - return (*(F*)p)(); + static R function_call(const void *p) + { + return (*(F *)p)(); } template <typename F> - static void function_move(void *d, const void *p) { - new (d) F(*(F*)p); + static void function_move(void *d, const void *p) + { + new (d) F(*(F *)p); } template <typename F> - static void function_dtor(void *p) { - ((F*)p)->~F(); + static void function_dtor(void *p) + { + ((F *)p)->~F(); } // Wrappers for functions with context @@ -622,7 +672,8 @@ method_context(O *obj, M method) : method(method), obj(obj) {} - R operator()() const { + R operator()() const + { return (obj->*method)(); } }; @@ -635,7 +686,8 @@ function_context(F func, A *arg) : func(func), arg(arg) {} - R operator()() const { + R operator()() const + { return func(arg); } }; @@ -651,7 +703,8 @@ /** Create a Callback with a static function * @param func Static function to attach */ - Callback(R (*func)(A0) = 0) { + Callback(R(*func)(A0) = 0) + { if (!func) { memset(this, 0, sizeof(Callback)); } else { @@ -662,7 +715,8 @@ /** Attach a Callback * @param func The Callback to attach */ - Callback(const Callback<R(A0)> &func) { + Callback(const Callback<R(A0)> &func) + { if (func._ops) { func._ops->move(this, &func); } @@ -674,8 +728,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(U *obj, R (T::*method)(A0)) { - generate(method_context<T, R (T::*)(A0)>(obj, method)); + Callback(U *obj, R(T::*method)(A0)) + { + generate(method_context<T, R(T::*)(A0)>(obj, method)); } /** Create a Callback with a member function @@ -683,8 +738,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(const U *obj, R (T::*method)(A0) const) { - generate(method_context<const T, R (T::*)(A0) const>(obj, method)); + Callback(const U *obj, R(T::*method)(A0) const) + { + generate(method_context<const T, R(T::*)(A0) const>(obj, method)); } /** Create a Callback with a member function @@ -692,8 +748,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(volatile U *obj, R (T::*method)(A0) volatile) { - generate(method_context<volatile T, R (T::*)(A0) volatile>(obj, method)); + Callback(volatile U *obj, R(T::*method)(A0) volatile) + { + generate(method_context<volatile T, R(T::*)(A0) volatile>(obj, method)); } /** Create a Callback with a member function @@ -701,44 +758,49 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(const volatile U *obj, R (T::*method)(A0) const volatile) { - generate(method_context<const volatile T, R (T::*)(A0) const volatile>(obj, method)); + Callback(const volatile U *obj, R(T::*method)(A0) const volatile) + { + generate(method_context<const volatile T, R(T::*)(A0) const volatile>(obj, method)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(T*, A0), U *arg) { - generate(function_context<R (*)(T*, A0), T>(func, arg)); + Callback(R(*func)(T *, A0), U *arg) + { + generate(function_context<R(*)(T *, A0), T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(const T*, A0), const U *arg) { - generate(function_context<R (*)(const T*, A0), const T>(func, arg)); + Callback(R(*func)(const T *, A0), const U *arg) + { + generate(function_context<R(*)(const T *, A0), const T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(volatile T*, A0), volatile U *arg) { - generate(function_context<R (*)(volatile T*, A0), volatile T>(func, arg)); + Callback(R(*func)(volatile T *, A0), volatile U *arg) + { + generate(function_context<R(*)(volatile T *, A0), volatile T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(const volatile T*, A0), const volatile U *arg) { - generate(function_context<R (*)(const volatile T*, A0), const volatile T>(func, arg)); + Callback(R(*func)(const volatile T *, A0), const volatile U *arg) + { + generate(function_context<R(*)(const volatile T *, A0), const volatile T>(func, arg)); } /** Create a Callback with a function object @@ -746,7 +808,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0))) { + Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0))) + { generate(f); } @@ -755,7 +818,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0) const)) { + Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0) const)) + { generate(f); } @@ -764,7 +828,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0) volatile)) { + Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0) volatile)) + { generate(f); } @@ -773,7 +838,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0) const volatile)) { + Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0) const volatile)) + { generate(f); } @@ -785,8 +851,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(U *obj, R (*func)(T*, A0)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(U *obj, R(*func)(T *, A0)) + { new (this) Callback(func, obj); } @@ -798,8 +865,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(const U *obj, R (*func)(const T*, A0)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(const U *obj, R(*func)(const T *, A0)) + { new (this) Callback(func, obj); } @@ -811,8 +879,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(volatile U *obj, R (*func)(volatile T*, A0)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(volatile U *obj, R(*func)(volatile T *, A0)) + { new (this) Callback(func, obj); } @@ -824,14 +893,16 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(const volatile U *obj, R (*func)(const volatile T*, A0)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(const volatile U *obj, R(*func)(const volatile T *, A0)) + { new (this) Callback(func, obj); } /** Destroy a callback */ - ~Callback() { + ~Callback() + { if (_ops) { _ops->dtor(this); } @@ -843,8 +914,9 @@ * Replaced by simple assignment 'Callback cb = func' */ MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(A0)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(A0)) + { this->~Callback(); new (this) Callback(func); } @@ -855,8 +927,9 @@ * Replaced by simple assignment 'Callback cb = func' */ MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const Callback<R(A0)> &func) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const Callback<R(A0)> &func) + { this->~Callback(); new (this) Callback(func); } @@ -869,8 +942,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(U *obj, R (T::*method)(A0)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(U *obj, R(T::*method)(A0)) + { this->~Callback(); new (this) Callback(obj, method); } @@ -883,8 +957,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const U *obj, R (T::*method)(A0) const) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const U *obj, R(T::*method)(A0) const) + { this->~Callback(); new (this) Callback(obj, method); } @@ -897,8 +972,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(volatile U *obj, R (T::*method)(A0) volatile) { + "Replaced by simple assignment 'Callback cb = func") + void attach(volatile U *obj, R(T::*method)(A0) volatile) + { this->~Callback(); new (this) Callback(obj, method); } @@ -911,8 +987,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile U *obj, R (T::*method)(A0) const volatile) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const volatile U *obj, R(T::*method)(A0) const volatile) + { this->~Callback(); new (this) Callback(obj, method); } @@ -925,8 +1002,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(T*, A0), U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(T *, A0), U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -939,8 +1017,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(const T*, A0), const U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(const T *, A0), const U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -953,8 +1032,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(volatile T*, A0), volatile U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(volatile T *, A0), volatile U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -967,8 +1047,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(const volatile T*, A0), const volatile U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(const volatile T *, A0), const volatile U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -981,8 +1062,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0))) { + "Replaced by simple assignment 'Callback cb = func") + void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0))) + { this->~Callback(); new (this) Callback(f); } @@ -995,8 +1077,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0) const)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0) const)) + { this->~Callback(); new (this) Callback(f); } @@ -1009,8 +1092,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0) volatile)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0) volatile)) + { this->~Callback(); new (this) Callback(f); } @@ -1023,8 +1107,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0) const volatile)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0) const volatile)) + { this->~Callback(); new (this) Callback(f); } @@ -1037,8 +1122,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(U *obj, R (*func)(T*, A0)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(U *obj, R(*func)(T *, A0)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -1051,8 +1137,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(const U *obj, R (*func)(const T*, A0)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(const U *obj, R(*func)(const T *, A0)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -1065,8 +1152,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(volatile U *obj, R (*func)(volatile T*, A0)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(volatile U *obj, R(*func)(volatile T *, A0)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -1079,15 +1167,17 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(const volatile U *obj, R (*func)(const volatile T*, A0)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(const volatile U *obj, R(*func)(const volatile T *, A0)) + { this->~Callback(); new (this) Callback(func, obj); } /** Assign a callback */ - Callback &operator=(const Callback &that) { + Callback &operator=(const Callback &that) + { if (this != &that) { this->~Callback(); new (this) Callback(that); @@ -1098,43 +1188,49 @@ /** Call the attached function */ - R call(A0 a0) const { + R call(A0 a0) const + { MBED_ASSERT(_ops); return _ops->call(this, a0); } /** Call the attached function */ - R operator()(A0 a0) const { + R operator()(A0 a0) const + { return call(a0); } /** Test if function has been attached */ - operator bool() const { + operator bool() const + { return _ops; } /** Test for equality */ - friend bool operator==(const Callback &l, const Callback &r) { + friend bool operator==(const Callback &l, const Callback &r) + { return memcmp(&l, &r, sizeof(Callback)) == 0; } /** Test for inequality */ - friend bool operator!=(const Callback &l, const Callback &r) { + friend bool operator!=(const Callback &l, const Callback &r) + { return !(l == r); } /** Static thunk for passing as C-style function * @param func Callback to call passed as void pointer * @param a0 An argument to be called with function func - * @return the value as determined by func which is of + * @return the value as determined by func which is of * type and determined by the signiture of func */ - static R thunk(void *func, A0 a0) { - return static_cast<Callback*>(func)->call(a0); + static R thunk(void *func, A0 a0) + { + return static_cast<Callback *>(func)->call(a0); } private: @@ -1144,21 +1240,22 @@ struct _class; union { void (*_staticfunc)(A0); - void (*_boundfunc)(_class*, A0); + void (*_boundfunc)(_class *, A0); void (_class::*_methodfunc)(A0); } _func; void *_obj; // Dynamically dispatched operations const struct ops { - R (*call)(const void*, A0); - void (*move)(void*, const void*); - void (*dtor)(void*); + R(*call)(const void *, A0); + void (*move)(void *, const void *); + void (*dtor)(void *); } *_ops; // Generate operations for function object template <typename F> - void generate(const F &f) { + void generate(const F &f) + { static const ops ops = { &Callback::function_call<F>, &Callback::function_move<F>, @@ -1166,7 +1263,7 @@ }; MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F), - "Type F must not exceed the size of the Callback class"); + "Type F must not exceed the size of the Callback class"); memset(this, 0, sizeof(Callback)); new (this) F(f); _ops = &ops; @@ -1174,18 +1271,21 @@ // Function attributes template <typename F> - static R function_call(const void *p, A0 a0) { - return (*(F*)p)(a0); + static R function_call(const void *p, A0 a0) + { + return (*(F *)p)(a0); } template <typename F> - static void function_move(void *d, const void *p) { - new (d) F(*(F*)p); + static void function_move(void *d, const void *p) + { + new (d) F(*(F *)p); } template <typename F> - static void function_dtor(void *p) { - ((F*)p)->~F(); + static void function_dtor(void *p) + { + ((F *)p)->~F(); } // Wrappers for functions with context @@ -1197,7 +1297,8 @@ method_context(O *obj, M method) : method(method), obj(obj) {} - R operator()(A0 a0) const { + R operator()(A0 a0) const + { return (obj->*method)(a0); } }; @@ -1210,7 +1311,8 @@ function_context(F func, A *arg) : func(func), arg(arg) {} - R operator()(A0 a0) const { + R operator()(A0 a0) const + { return func(arg, a0); } }; @@ -1226,7 +1328,8 @@ /** Create a Callback with a static function * @param func Static function to attach */ - Callback(R (*func)(A0, A1) = 0) { + Callback(R(*func)(A0, A1) = 0) + { if (!func) { memset(this, 0, sizeof(Callback)); } else { @@ -1237,7 +1340,8 @@ /** Attach a Callback * @param func The Callback to attach */ - Callback(const Callback<R(A0, A1)> &func) { + Callback(const Callback<R(A0, A1)> &func) + { if (func._ops) { func._ops->move(this, &func); } @@ -1249,8 +1353,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(U *obj, R (T::*method)(A0, A1)) { - generate(method_context<T, R (T::*)(A0, A1)>(obj, method)); + Callback(U *obj, R(T::*method)(A0, A1)) + { + generate(method_context<T, R(T::*)(A0, A1)>(obj, method)); } /** Create a Callback with a member function @@ -1258,8 +1363,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(const U *obj, R (T::*method)(A0, A1) const) { - generate(method_context<const T, R (T::*)(A0, A1) const>(obj, method)); + Callback(const U *obj, R(T::*method)(A0, A1) const) + { + generate(method_context<const T, R(T::*)(A0, A1) const>(obj, method)); } /** Create a Callback with a member function @@ -1267,8 +1373,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(volatile U *obj, R (T::*method)(A0, A1) volatile) { - generate(method_context<volatile T, R (T::*)(A0, A1) volatile>(obj, method)); + Callback(volatile U *obj, R(T::*method)(A0, A1) volatile) + { + generate(method_context<volatile T, R(T::*)(A0, A1) volatile>(obj, method)); } /** Create a Callback with a member function @@ -1276,44 +1383,49 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(const volatile U *obj, R (T::*method)(A0, A1) const volatile) { - generate(method_context<const volatile T, R (T::*)(A0, A1) const volatile>(obj, method)); + Callback(const volatile U *obj, R(T::*method)(A0, A1) const volatile) + { + generate(method_context<const volatile T, R(T::*)(A0, A1) const volatile>(obj, method)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(T*, A0, A1), U *arg) { - generate(function_context<R (*)(T*, A0, A1), T>(func, arg)); + Callback(R(*func)(T *, A0, A1), U *arg) + { + generate(function_context<R(*)(T *, A0, A1), T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(const T*, A0, A1), const U *arg) { - generate(function_context<R (*)(const T*, A0, A1), const T>(func, arg)); + Callback(R(*func)(const T *, A0, A1), const U *arg) + { + generate(function_context<R(*)(const T *, A0, A1), const T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(volatile T*, A0, A1), volatile U *arg) { - generate(function_context<R (*)(volatile T*, A0, A1), volatile T>(func, arg)); + Callback(R(*func)(volatile T *, A0, A1), volatile U *arg) + { + generate(function_context<R(*)(volatile T *, A0, A1), volatile T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(const volatile T*, A0, A1), const volatile U *arg) { - generate(function_context<R (*)(const volatile T*, A0, A1), const volatile T>(func, arg)); + Callback(R(*func)(const volatile T *, A0, A1), const volatile U *arg) + { + generate(function_context<R(*)(const volatile T *, A0, A1), const volatile T>(func, arg)); } /** Create a Callback with a function object @@ -1321,7 +1433,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1))) { + Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1))) + { generate(f); } @@ -1330,7 +1443,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1) const)) { + Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1) const)) + { generate(f); } @@ -1339,7 +1453,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1) volatile)) { + Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1) volatile)) + { generate(f); } @@ -1348,7 +1463,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1) const volatile)) { + Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1) const volatile)) + { generate(f); } @@ -1360,8 +1476,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(U *obj, R (*func)(T*, A0, A1)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(U *obj, R(*func)(T *, A0, A1)) + { new (this) Callback(func, obj); } @@ -1373,8 +1490,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(const U *obj, R (*func)(const T*, A0, A1)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(const U *obj, R(*func)(const T *, A0, A1)) + { new (this) Callback(func, obj); } @@ -1386,8 +1504,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(volatile U *obj, R (*func)(volatile T*, A0, A1)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(volatile U *obj, R(*func)(volatile T *, A0, A1)) + { new (this) Callback(func, obj); } @@ -1399,14 +1518,16 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(const volatile U *obj, R(*func)(const volatile T *, A0, A1)) + { new (this) Callback(func, obj); } /** Destroy a callback */ - ~Callback() { + ~Callback() + { if (_ops) { _ops->dtor(this); } @@ -1418,8 +1539,9 @@ * Replaced by simple assignment 'Callback cb = func' */ MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(A0, A1)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(A0, A1)) + { this->~Callback(); new (this) Callback(func); } @@ -1430,8 +1552,9 @@ * Replaced by simple assignment 'Callback cb = func' */ MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const Callback<R(A0, A1)> &func) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const Callback<R(A0, A1)> &func) + { this->~Callback(); new (this) Callback(func); } @@ -1444,8 +1567,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(U *obj, R (T::*method)(A0, A1)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(U *obj, R(T::*method)(A0, A1)) + { this->~Callback(); new (this) Callback(obj, method); } @@ -1458,8 +1582,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const U *obj, R (T::*method)(A0, A1) const) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const U *obj, R(T::*method)(A0, A1) const) + { this->~Callback(); new (this) Callback(obj, method); } @@ -1472,8 +1597,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(volatile U *obj, R (T::*method)(A0, A1) volatile) { + "Replaced by simple assignment 'Callback cb = func") + void attach(volatile U *obj, R(T::*method)(A0, A1) volatile) + { this->~Callback(); new (this) Callback(obj, method); } @@ -1486,8 +1612,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile U *obj, R (T::*method)(A0, A1) const volatile) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const volatile U *obj, R(T::*method)(A0, A1) const volatile) + { this->~Callback(); new (this) Callback(obj, method); } @@ -1500,8 +1627,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(T*, A0, A1), U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(T *, A0, A1), U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -1514,8 +1642,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(const T*, A0, A1), const U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(const T *, A0, A1), const U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -1528,8 +1657,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(volatile T*, A0, A1), volatile U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(volatile T *, A0, A1), volatile U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -1542,8 +1672,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(const volatile T*, A0, A1), const volatile U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(const volatile T *, A0, A1), const volatile U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -1556,8 +1687,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1))) { + "Replaced by simple assignment 'Callback cb = func") + void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1))) + { this->~Callback(); new (this) Callback(f); } @@ -1570,8 +1702,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1) const)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1) const)) + { this->~Callback(); new (this) Callback(f); } @@ -1584,8 +1717,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1) volatile)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1) volatile)) + { this->~Callback(); new (this) Callback(f); } @@ -1598,8 +1732,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1) const volatile)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1) const volatile)) + { this->~Callback(); new (this) Callback(f); } @@ -1612,8 +1747,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(U *obj, R (*func)(T*, A0, A1)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(U *obj, R(*func)(T *, A0, A1)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -1626,8 +1762,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(const U *obj, R (*func)(const T*, A0, A1)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(const U *obj, R(*func)(const T *, A0, A1)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -1640,8 +1777,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(volatile U *obj, R (*func)(volatile T*, A0, A1)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(volatile U *obj, R(*func)(volatile T *, A0, A1)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -1654,15 +1792,17 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(const volatile U *obj, R (*func)(const volatile T*, A0, A1)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(const volatile U *obj, R(*func)(const volatile T *, A0, A1)) + { this->~Callback(); new (this) Callback(func, obj); } /** Assign a callback */ - Callback &operator=(const Callback &that) { + Callback &operator=(const Callback &that) + { if (this != &that) { this->~Callback(); new (this) Callback(that); @@ -1673,32 +1813,37 @@ /** Call the attached function */ - R call(A0 a0, A1 a1) const { + R call(A0 a0, A1 a1) const + { MBED_ASSERT(_ops); return _ops->call(this, a0, a1); } /** Call the attached function */ - R operator()(A0 a0, A1 a1) const { + R operator()(A0 a0, A1 a1) const + { return call(a0, a1); } /** Test if function has been attached */ - operator bool() const { + operator bool() const + { return _ops; } /** Test for equality */ - friend bool operator==(const Callback &l, const Callback &r) { + friend bool operator==(const Callback &l, const Callback &r) + { return memcmp(&l, &r, sizeof(Callback)) == 0; } /** Test for inequality */ - friend bool operator!=(const Callback &l, const Callback &r) { + friend bool operator!=(const Callback &l, const Callback &r) + { return !(l == r); } @@ -1706,11 +1851,12 @@ * @param func Callback to call passed as void pointer * @param a0 An argument to be called with function func * @param a1 An argument to be called with function func - * @return the value as determined by func which is of + * @return the value as determined by func which is of * type and determined by the signiture of func */ - static R thunk(void *func, A0 a0, A1 a1) { - return static_cast<Callback*>(func)->call(a0, a1); + static R thunk(void *func, A0 a0, A1 a1) + { + return static_cast<Callback *>(func)->call(a0, a1); } private: @@ -1720,21 +1866,22 @@ struct _class; union { void (*_staticfunc)(A0, A1); - void (*_boundfunc)(_class*, A0, A1); + void (*_boundfunc)(_class *, A0, A1); void (_class::*_methodfunc)(A0, A1); } _func; void *_obj; // Dynamically dispatched operations const struct ops { - R (*call)(const void*, A0, A1); - void (*move)(void*, const void*); - void (*dtor)(void*); + R(*call)(const void *, A0, A1); + void (*move)(void *, const void *); + void (*dtor)(void *); } *_ops; // Generate operations for function object template <typename F> - void generate(const F &f) { + void generate(const F &f) + { static const ops ops = { &Callback::function_call<F>, &Callback::function_move<F>, @@ -1742,7 +1889,7 @@ }; MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F), - "Type F must not exceed the size of the Callback class"); + "Type F must not exceed the size of the Callback class"); memset(this, 0, sizeof(Callback)); new (this) F(f); _ops = &ops; @@ -1750,18 +1897,21 @@ // Function attributes template <typename F> - static R function_call(const void *p, A0 a0, A1 a1) { - return (*(F*)p)(a0, a1); + static R function_call(const void *p, A0 a0, A1 a1) + { + return (*(F *)p)(a0, a1); } template <typename F> - static void function_move(void *d, const void *p) { - new (d) F(*(F*)p); + static void function_move(void *d, const void *p) + { + new (d) F(*(F *)p); } template <typename F> - static void function_dtor(void *p) { - ((F*)p)->~F(); + static void function_dtor(void *p) + { + ((F *)p)->~F(); } // Wrappers for functions with context @@ -1773,7 +1923,8 @@ method_context(O *obj, M method) : method(method), obj(obj) {} - R operator()(A0 a0, A1 a1) const { + R operator()(A0 a0, A1 a1) const + { return (obj->*method)(a0, a1); } }; @@ -1786,7 +1937,8 @@ function_context(F func, A *arg) : func(func), arg(arg) {} - R operator()(A0 a0, A1 a1) const { + R operator()(A0 a0, A1 a1) const + { return func(arg, a0, a1); } }; @@ -1802,7 +1954,8 @@ /** Create a Callback with a static function * @param func Static function to attach */ - Callback(R (*func)(A0, A1, A2) = 0) { + Callback(R(*func)(A0, A1, A2) = 0) + { if (!func) { memset(this, 0, sizeof(Callback)); } else { @@ -1813,7 +1966,8 @@ /** Attach a Callback * @param func The Callback to attach */ - Callback(const Callback<R(A0, A1, A2)> &func) { + Callback(const Callback<R(A0, A1, A2)> &func) + { if (func._ops) { func._ops->move(this, &func); } @@ -1825,8 +1979,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(U *obj, R (T::*method)(A0, A1, A2)) { - generate(method_context<T, R (T::*)(A0, A1, A2)>(obj, method)); + Callback(U *obj, R(T::*method)(A0, A1, A2)) + { + generate(method_context<T, R(T::*)(A0, A1, A2)>(obj, method)); } /** Create a Callback with a member function @@ -1834,8 +1989,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(const U *obj, R (T::*method)(A0, A1, A2) const) { - generate(method_context<const T, R (T::*)(A0, A1, A2) const>(obj, method)); + Callback(const U *obj, R(T::*method)(A0, A1, A2) const) + { + generate(method_context<const T, R(T::*)(A0, A1, A2) const>(obj, method)); } /** Create a Callback with a member function @@ -1843,8 +1999,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(volatile U *obj, R (T::*method)(A0, A1, A2) volatile) { - generate(method_context<volatile T, R (T::*)(A0, A1, A2) volatile>(obj, method)); + Callback(volatile U *obj, R(T::*method)(A0, A1, A2) volatile) + { + generate(method_context<volatile T, R(T::*)(A0, A1, A2) volatile>(obj, method)); } /** Create a Callback with a member function @@ -1852,44 +2009,49 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(const volatile U *obj, R (T::*method)(A0, A1, A2) const volatile) { - generate(method_context<const volatile T, R (T::*)(A0, A1, A2) const volatile>(obj, method)); + Callback(const volatile U *obj, R(T::*method)(A0, A1, A2) const volatile) + { + generate(method_context<const volatile T, R(T::*)(A0, A1, A2) const volatile>(obj, method)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(T*, A0, A1, A2), U *arg) { - generate(function_context<R (*)(T*, A0, A1, A2), T>(func, arg)); + Callback(R(*func)(T *, A0, A1, A2), U *arg) + { + generate(function_context<R(*)(T *, A0, A1, A2), T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(const T*, A0, A1, A2), const U *arg) { - generate(function_context<R (*)(const T*, A0, A1, A2), const T>(func, arg)); + Callback(R(*func)(const T *, A0, A1, A2), const U *arg) + { + generate(function_context<R(*)(const T *, A0, A1, A2), const T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(volatile T*, A0, A1, A2), volatile U *arg) { - generate(function_context<R (*)(volatile T*, A0, A1, A2), volatile T>(func, arg)); + Callback(R(*func)(volatile T *, A0, A1, A2), volatile U *arg) + { + generate(function_context<R(*)(volatile T *, A0, A1, A2), volatile T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(const volatile T*, A0, A1, A2), const volatile U *arg) { - generate(function_context<R (*)(const volatile T*, A0, A1, A2), const volatile T>(func, arg)); + Callback(R(*func)(const volatile T *, A0, A1, A2), const volatile U *arg) + { + generate(function_context<R(*)(const volatile T *, A0, A1, A2), const volatile T>(func, arg)); } /** Create a Callback with a function object @@ -1897,7 +2059,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2))) { + Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2))) + { generate(f); } @@ -1906,7 +2069,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2) const)) { + Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2) const)) + { generate(f); } @@ -1915,7 +2079,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2) volatile)) { + Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2) volatile)) + { generate(f); } @@ -1924,7 +2089,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2) const volatile)) { + Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2) const volatile)) + { generate(f); } @@ -1936,8 +2102,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(U *obj, R (*func)(T*, A0, A1, A2)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(U *obj, R(*func)(T *, A0, A1, A2)) + { new (this) Callback(func, obj); } @@ -1949,8 +2116,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(const U *obj, R (*func)(const T*, A0, A1, A2)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(const U *obj, R(*func)(const T *, A0, A1, A2)) + { new (this) Callback(func, obj); } @@ -1962,8 +2130,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(volatile U *obj, R(*func)(volatile T *, A0, A1, A2)) + { new (this) Callback(func, obj); } @@ -1975,14 +2144,16 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(const volatile U *obj, R(*func)(const volatile T *, A0, A1, A2)) + { new (this) Callback(func, obj); } /** Destroy a callback */ - ~Callback() { + ~Callback() + { if (_ops) { _ops->dtor(this); } @@ -1994,8 +2165,9 @@ * Replaced by simple assignment 'Callback cb = func' */ MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(A0, A1, A2)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(A0, A1, A2)) + { this->~Callback(); new (this) Callback(func); } @@ -2006,8 +2178,9 @@ * Replaced by simple assignment 'Callback cb = func' */ MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const Callback<R(A0, A1, A2)> &func) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const Callback<R(A0, A1, A2)> &func) + { this->~Callback(); new (this) Callback(func); } @@ -2020,8 +2193,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(U *obj, R (T::*method)(A0, A1, A2)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(U *obj, R(T::*method)(A0, A1, A2)) + { this->~Callback(); new (this) Callback(obj, method); } @@ -2034,8 +2208,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const U *obj, R (T::*method)(A0, A1, A2) const) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const U *obj, R(T::*method)(A0, A1, A2) const) + { this->~Callback(); new (this) Callback(obj, method); } @@ -2048,8 +2223,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(volatile U *obj, R (T::*method)(A0, A1, A2) volatile) { + "Replaced by simple assignment 'Callback cb = func") + void attach(volatile U *obj, R(T::*method)(A0, A1, A2) volatile) + { this->~Callback(); new (this) Callback(obj, method); } @@ -2062,8 +2238,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile U *obj, R (T::*method)(A0, A1, A2) const volatile) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const volatile U *obj, R(T::*method)(A0, A1, A2) const volatile) + { this->~Callback(); new (this) Callback(obj, method); } @@ -2076,8 +2253,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(T*, A0, A1, A2), U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(T *, A0, A1, A2), U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -2090,8 +2268,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(const T*, A0, A1, A2), const U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(const T *, A0, A1, A2), const U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -2104,8 +2283,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(volatile T*, A0, A1, A2), volatile U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(volatile T *, A0, A1, A2), volatile U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -2118,8 +2298,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(const volatile T*, A0, A1, A2), const volatile U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(const volatile T *, A0, A1, A2), const volatile U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -2132,8 +2313,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2))) { + "Replaced by simple assignment 'Callback cb = func") + void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2))) + { this->~Callback(); new (this) Callback(f); } @@ -2146,8 +2328,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2) const)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2) const)) + { this->~Callback(); new (this) Callback(f); } @@ -2160,8 +2343,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2) volatile)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2) volatile)) + { this->~Callback(); new (this) Callback(f); } @@ -2174,8 +2358,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2) const volatile)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2) const volatile)) + { this->~Callback(); new (this) Callback(f); } @@ -2188,8 +2373,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(U *obj, R (*func)(T*, A0, A1, A2)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(U *obj, R(*func)(T *, A0, A1, A2)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -2202,8 +2388,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(const U *obj, R (*func)(const T*, A0, A1, A2)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(const U *obj, R(*func)(const T *, A0, A1, A2)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -2216,8 +2403,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(volatile U *obj, R (*func)(volatile T*, A0, A1, A2)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(volatile U *obj, R(*func)(volatile T *, A0, A1, A2)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -2230,15 +2418,17 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(const volatile U *obj, R(*func)(const volatile T *, A0, A1, A2)) + { this->~Callback(); new (this) Callback(func, obj); } /** Assign a callback */ - Callback &operator=(const Callback &that) { + Callback &operator=(const Callback &that) + { if (this != &that) { this->~Callback(); new (this) Callback(that); @@ -2249,32 +2439,37 @@ /** Call the attached function */ - R call(A0 a0, A1 a1, A2 a2) const { + R call(A0 a0, A1 a1, A2 a2) const + { MBED_ASSERT(_ops); return _ops->call(this, a0, a1, a2); } /** Call the attached function */ - R operator()(A0 a0, A1 a1, A2 a2) const { + R operator()(A0 a0, A1 a1, A2 a2) const + { return call(a0, a1, a2); } /** Test if function has been attached */ - operator bool() const { + operator bool() const + { return _ops; } /** Test for equality */ - friend bool operator==(const Callback &l, const Callback &r) { + friend bool operator==(const Callback &l, const Callback &r) + { return memcmp(&l, &r, sizeof(Callback)) == 0; } /** Test for inequality */ - friend bool operator!=(const Callback &l, const Callback &r) { + friend bool operator!=(const Callback &l, const Callback &r) + { return !(l == r); } @@ -2283,11 +2478,12 @@ * @param a0 An argument to be called with function func * @param a1 An argument to be called with function func * @param a2 An argument to be called with function func - * @return the value as determined by func which is of + * @return the value as determined by func which is of * type and determined by the signiture of func */ - static R thunk(void *func, A0 a0, A1 a1, A2 a2) { - return static_cast<Callback*>(func)->call(a0, a1, a2); + static R thunk(void *func, A0 a0, A1 a1, A2 a2) + { + return static_cast<Callback *>(func)->call(a0, a1, a2); } private: @@ -2297,21 +2493,22 @@ struct _class; union { void (*_staticfunc)(A0, A1, A2); - void (*_boundfunc)(_class*, A0, A1, A2); + void (*_boundfunc)(_class *, A0, A1, A2); void (_class::*_methodfunc)(A0, A1, A2); } _func; void *_obj; // Dynamically dispatched operations const struct ops { - R (*call)(const void*, A0, A1, A2); - void (*move)(void*, const void*); - void (*dtor)(void*); + R(*call)(const void *, A0, A1, A2); + void (*move)(void *, const void *); + void (*dtor)(void *); } *_ops; // Generate operations for function object template <typename F> - void generate(const F &f) { + void generate(const F &f) + { static const ops ops = { &Callback::function_call<F>, &Callback::function_move<F>, @@ -2319,7 +2516,7 @@ }; MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F), - "Type F must not exceed the size of the Callback class"); + "Type F must not exceed the size of the Callback class"); memset(this, 0, sizeof(Callback)); new (this) F(f); _ops = &ops; @@ -2327,18 +2524,21 @@ // Function attributes template <typename F> - static R function_call(const void *p, A0 a0, A1 a1, A2 a2) { - return (*(F*)p)(a0, a1, a2); + static R function_call(const void *p, A0 a0, A1 a1, A2 a2) + { + return (*(F *)p)(a0, a1, a2); } template <typename F> - static void function_move(void *d, const void *p) { - new (d) F(*(F*)p); + static void function_move(void *d, const void *p) + { + new (d) F(*(F *)p); } template <typename F> - static void function_dtor(void *p) { - ((F*)p)->~F(); + static void function_dtor(void *p) + { + ((F *)p)->~F(); } // Wrappers for functions with context @@ -2350,7 +2550,8 @@ method_context(O *obj, M method) : method(method), obj(obj) {} - R operator()(A0 a0, A1 a1, A2 a2) const { + R operator()(A0 a0, A1 a1, A2 a2) const + { return (obj->*method)(a0, a1, a2); } }; @@ -2363,7 +2564,8 @@ function_context(F func, A *arg) : func(func), arg(arg) {} - R operator()(A0 a0, A1 a1, A2 a2) const { + R operator()(A0 a0, A1 a1, A2 a2) const + { return func(arg, a0, a1, a2); } }; @@ -2379,7 +2581,8 @@ /** Create a Callback with a static function * @param func Static function to attach */ - Callback(R (*func)(A0, A1, A2, A3) = 0) { + Callback(R(*func)(A0, A1, A2, A3) = 0) + { if (!func) { memset(this, 0, sizeof(Callback)); } else { @@ -2390,7 +2593,8 @@ /** Attach a Callback * @param func The Callback to attach */ - Callback(const Callback<R(A0, A1, A2, A3)> &func) { + Callback(const Callback<R(A0, A1, A2, A3)> &func) + { if (func._ops) { func._ops->move(this, &func); } @@ -2402,8 +2606,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(U *obj, R (T::*method)(A0, A1, A2, A3)) { - generate(method_context<T, R (T::*)(A0, A1, A2, A3)>(obj, method)); + Callback(U *obj, R(T::*method)(A0, A1, A2, A3)) + { + generate(method_context<T, R(T::*)(A0, A1, A2, A3)>(obj, method)); } /** Create a Callback with a member function @@ -2411,8 +2616,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(const U *obj, R (T::*method)(A0, A1, A2, A3) const) { - generate(method_context<const T, R (T::*)(A0, A1, A2, A3) const>(obj, method)); + Callback(const U *obj, R(T::*method)(A0, A1, A2, A3) const) + { + generate(method_context<const T, R(T::*)(A0, A1, A2, A3) const>(obj, method)); } /** Create a Callback with a member function @@ -2420,8 +2626,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(volatile U *obj, R (T::*method)(A0, A1, A2, A3) volatile) { - generate(method_context<volatile T, R (T::*)(A0, A1, A2, A3) volatile>(obj, method)); + Callback(volatile U *obj, R(T::*method)(A0, A1, A2, A3) volatile) + { + generate(method_context<volatile T, R(T::*)(A0, A1, A2, A3) volatile>(obj, method)); } /** Create a Callback with a member function @@ -2429,44 +2636,49 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(const volatile U *obj, R (T::*method)(A0, A1, A2, A3) const volatile) { - generate(method_context<const volatile T, R (T::*)(A0, A1, A2, A3) const volatile>(obj, method)); + Callback(const volatile U *obj, R(T::*method)(A0, A1, A2, A3) const volatile) + { + generate(method_context<const volatile T, R(T::*)(A0, A1, A2, A3) const volatile>(obj, method)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(T*, A0, A1, A2, A3), U *arg) { - generate(function_context<R (*)(T*, A0, A1, A2, A3), T>(func, arg)); + Callback(R(*func)(T *, A0, A1, A2, A3), U *arg) + { + generate(function_context<R(*)(T *, A0, A1, A2, A3), T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(const T*, A0, A1, A2, A3), const U *arg) { - generate(function_context<R (*)(const T*, A0, A1, A2, A3), const T>(func, arg)); + Callback(R(*func)(const T *, A0, A1, A2, A3), const U *arg) + { + generate(function_context<R(*)(const T *, A0, A1, A2, A3), const T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(volatile T*, A0, A1, A2, A3), volatile U *arg) { - generate(function_context<R (*)(volatile T*, A0, A1, A2, A3), volatile T>(func, arg)); + Callback(R(*func)(volatile T *, A0, A1, A2, A3), volatile U *arg) + { + generate(function_context<R(*)(volatile T *, A0, A1, A2, A3), volatile T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile U *arg) { - generate(function_context<R (*)(const volatile T*, A0, A1, A2, A3), const volatile T>(func, arg)); + Callback(R(*func)(const volatile T *, A0, A1, A2, A3), const volatile U *arg) + { + generate(function_context<R(*)(const volatile T *, A0, A1, A2, A3), const volatile T>(func, arg)); } /** Create a Callback with a function object @@ -2474,7 +2686,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3))) { + Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3))) + { generate(f); } @@ -2483,7 +2696,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3) const)) { + Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3) const)) + { generate(f); } @@ -2492,7 +2706,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3) volatile)) { + Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3) volatile)) + { generate(f); } @@ -2501,7 +2716,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3) const volatile)) { + Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3) const volatile)) + { generate(f); } @@ -2513,8 +2729,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(U *obj, R (*func)(T*, A0, A1, A2, A3)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(U *obj, R(*func)(T *, A0, A1, A2, A3)) + { new (this) Callback(func, obj); } @@ -2526,8 +2743,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(const U *obj, R (*func)(const T*, A0, A1, A2, A3)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(const U *obj, R(*func)(const T *, A0, A1, A2, A3)) + { new (this) Callback(func, obj); } @@ -2539,8 +2757,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(volatile U *obj, R(*func)(volatile T *, A0, A1, A2, A3)) + { new (this) Callback(func, obj); } @@ -2552,14 +2771,16 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(const volatile U *obj, R(*func)(const volatile T *, A0, A1, A2, A3)) + { new (this) Callback(func, obj); } /** Destroy a callback */ - ~Callback() { + ~Callback() + { if (_ops) { _ops->dtor(this); } @@ -2571,8 +2792,9 @@ * Replaced by simple assignment 'Callback cb = func' */ MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(A0, A1, A2, A3)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(A0, A1, A2, A3)) + { this->~Callback(); new (this) Callback(func); } @@ -2583,8 +2805,9 @@ * Replaced by simple assignment 'Callback cb = func' */ MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const Callback<R(A0, A1, A2, A3)> &func) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const Callback<R(A0, A1, A2, A3)> &func) + { this->~Callback(); new (this) Callback(func); } @@ -2597,8 +2820,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(U *obj, R (T::*method)(A0, A1, A2, A3)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(U *obj, R(T::*method)(A0, A1, A2, A3)) + { this->~Callback(); new (this) Callback(obj, method); } @@ -2611,8 +2835,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const U *obj, R (T::*method)(A0, A1, A2, A3) const) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const U *obj, R(T::*method)(A0, A1, A2, A3) const) + { this->~Callback(); new (this) Callback(obj, method); } @@ -2625,8 +2850,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(volatile U *obj, R (T::*method)(A0, A1, A2, A3) volatile) { + "Replaced by simple assignment 'Callback cb = func") + void attach(volatile U *obj, R(T::*method)(A0, A1, A2, A3) volatile) + { this->~Callback(); new (this) Callback(obj, method); } @@ -2639,8 +2865,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile U *obj, R (T::*method)(A0, A1, A2, A3) const volatile) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const volatile U *obj, R(T::*method)(A0, A1, A2, A3) const volatile) + { this->~Callback(); new (this) Callback(obj, method); } @@ -2653,8 +2880,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(T*, A0, A1, A2, A3), U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(T *, A0, A1, A2, A3), U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -2667,8 +2895,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(const T*, A0, A1, A2, A3), const U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(const T *, A0, A1, A2, A3), const U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -2681,8 +2910,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(volatile T*, A0, A1, A2, A3), volatile U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(volatile T *, A0, A1, A2, A3), volatile U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -2695,8 +2925,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(const volatile T *, A0, A1, A2, A3), const volatile U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -2709,8 +2940,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3))) { + "Replaced by simple assignment 'Callback cb = func") + void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3))) + { this->~Callback(); new (this) Callback(f); } @@ -2723,8 +2955,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3) const)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3) const)) + { this->~Callback(); new (this) Callback(f); } @@ -2737,8 +2970,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3) volatile)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3) volatile)) + { this->~Callback(); new (this) Callback(f); } @@ -2751,8 +2985,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3) const volatile)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3) const volatile)) + { this->~Callback(); new (this) Callback(f); } @@ -2765,8 +3000,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(U *obj, R (*func)(T*, A0, A1, A2, A3)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(U *obj, R(*func)(T *, A0, A1, A2, A3)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -2779,8 +3015,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(const U *obj, R (*func)(const T*, A0, A1, A2, A3)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(const U *obj, R(*func)(const T *, A0, A1, A2, A3)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -2793,8 +3030,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(volatile U *obj, R(*func)(volatile T *, A0, A1, A2, A3)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -2807,15 +3045,17 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(const volatile U *obj, R(*func)(const volatile T *, A0, A1, A2, A3)) + { this->~Callback(); new (this) Callback(func, obj); } /** Assign a callback */ - Callback &operator=(const Callback &that) { + Callback &operator=(const Callback &that) + { if (this != &that) { this->~Callback(); new (this) Callback(that); @@ -2826,32 +3066,37 @@ /** Call the attached function */ - R call(A0 a0, A1 a1, A2 a2, A3 a3) const { + R call(A0 a0, A1 a1, A2 a2, A3 a3) const + { MBED_ASSERT(_ops); return _ops->call(this, a0, a1, a2, a3); } /** Call the attached function */ - R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const { + R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const + { return call(a0, a1, a2, a3); } /** Test if function has been attached */ - operator bool() const { + operator bool() const + { return _ops; } /** Test for equality */ - friend bool operator==(const Callback &l, const Callback &r) { + friend bool operator==(const Callback &l, const Callback &r) + { return memcmp(&l, &r, sizeof(Callback)) == 0; } /** Test for inequality */ - friend bool operator!=(const Callback &l, const Callback &r) { + friend bool operator!=(const Callback &l, const Callback &r) + { return !(l == r); } @@ -2861,11 +3106,12 @@ * @param a1 An argument to be called with function func * @param a2 An argument to be called with function func * @param a3 An argument to be called with function func - * @return the value as determined by func which is of + * @return the value as determined by func which is of * type and determined by the signiture of func */ - static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3) { - return static_cast<Callback*>(func)->call(a0, a1, a2, a3); + static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3) + { + return static_cast<Callback *>(func)->call(a0, a1, a2, a3); } private: @@ -2875,21 +3121,22 @@ struct _class; union { void (*_staticfunc)(A0, A1, A2, A3); - void (*_boundfunc)(_class*, A0, A1, A2, A3); + void (*_boundfunc)(_class *, A0, A1, A2, A3); void (_class::*_methodfunc)(A0, A1, A2, A3); } _func; void *_obj; // Dynamically dispatched operations const struct ops { - R (*call)(const void*, A0, A1, A2, A3); - void (*move)(void*, const void*); - void (*dtor)(void*); + R(*call)(const void *, A0, A1, A2, A3); + void (*move)(void *, const void *); + void (*dtor)(void *); } *_ops; // Generate operations for function object template <typename F> - void generate(const F &f) { + void generate(const F &f) + { static const ops ops = { &Callback::function_call<F>, &Callback::function_move<F>, @@ -2897,7 +3144,7 @@ }; MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F), - "Type F must not exceed the size of the Callback class"); + "Type F must not exceed the size of the Callback class"); memset(this, 0, sizeof(Callback)); new (this) F(f); _ops = &ops; @@ -2905,18 +3152,21 @@ // Function attributes template <typename F> - static R function_call(const void *p, A0 a0, A1 a1, A2 a2, A3 a3) { - return (*(F*)p)(a0, a1, a2, a3); + static R function_call(const void *p, A0 a0, A1 a1, A2 a2, A3 a3) + { + return (*(F *)p)(a0, a1, a2, a3); } template <typename F> - static void function_move(void *d, const void *p) { - new (d) F(*(F*)p); + static void function_move(void *d, const void *p) + { + new (d) F(*(F *)p); } template <typename F> - static void function_dtor(void *p) { - ((F*)p)->~F(); + static void function_dtor(void *p) + { + ((F *)p)->~F(); } // Wrappers for functions with context @@ -2928,7 +3178,8 @@ method_context(O *obj, M method) : method(method), obj(obj) {} - R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const { + R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const + { return (obj->*method)(a0, a1, a2, a3); } }; @@ -2941,7 +3192,8 @@ function_context(F func, A *arg) : func(func), arg(arg) {} - R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const { + R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const + { return func(arg, a0, a1, a2, a3); } }; @@ -2957,7 +3209,8 @@ /** Create a Callback with a static function * @param func Static function to attach */ - Callback(R (*func)(A0, A1, A2, A3, A4) = 0) { + Callback(R(*func)(A0, A1, A2, A3, A4) = 0) + { if (!func) { memset(this, 0, sizeof(Callback)); } else { @@ -2968,7 +3221,8 @@ /** Attach a Callback * @param func The Callback to attach */ - Callback(const Callback<R(A0, A1, A2, A3, A4)> &func) { + Callback(const Callback<R(A0, A1, A2, A3, A4)> &func) + { if (func._ops) { func._ops->move(this, &func); } @@ -2980,8 +3234,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(U *obj, R (T::*method)(A0, A1, A2, A3, A4)) { - generate(method_context<T, R (T::*)(A0, A1, A2, A3, A4)>(obj, method)); + Callback(U *obj, R(T::*method)(A0, A1, A2, A3, A4)) + { + generate(method_context<T, R(T::*)(A0, A1, A2, A3, A4)>(obj, method)); } /** Create a Callback with a member function @@ -2989,8 +3244,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(const U *obj, R (T::*method)(A0, A1, A2, A3, A4) const) { - generate(method_context<const T, R (T::*)(A0, A1, A2, A3, A4) const>(obj, method)); + Callback(const U *obj, R(T::*method)(A0, A1, A2, A3, A4) const) + { + generate(method_context<const T, R(T::*)(A0, A1, A2, A3, A4) const>(obj, method)); } /** Create a Callback with a member function @@ -2998,8 +3254,9 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) { - generate(method_context<volatile T, R (T::*)(A0, A1, A2, A3, A4) volatile>(obj, method)); + Callback(volatile U *obj, R(T::*method)(A0, A1, A2, A3, A4) volatile) + { + generate(method_context<volatile T, R(T::*)(A0, A1, A2, A3, A4) volatile>(obj, method)); } /** Create a Callback with a member function @@ -3007,44 +3264,49 @@ * @param method Member function to attach */ template<typename T, typename U> - Callback(const volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) { - generate(method_context<const volatile T, R (T::*)(A0, A1, A2, A3, A4) const volatile>(obj, method)); + Callback(const volatile U *obj, R(T::*method)(A0, A1, A2, A3, A4) const volatile) + { + generate(method_context<const volatile T, R(T::*)(A0, A1, A2, A3, A4) const volatile>(obj, method)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(T*, A0, A1, A2, A3, A4), U *arg) { - generate(function_context<R (*)(T*, A0, A1, A2, A3, A4), T>(func, arg)); + Callback(R(*func)(T *, A0, A1, A2, A3, A4), U *arg) + { + generate(function_context<R(*)(T *, A0, A1, A2, A3, A4), T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(const T*, A0, A1, A2, A3, A4), const U *arg) { - generate(function_context<R (*)(const T*, A0, A1, A2, A3, A4), const T>(func, arg)); + Callback(R(*func)(const T *, A0, A1, A2, A3, A4), const U *arg) + { + generate(function_context<R(*)(const T *, A0, A1, A2, A3, A4), const T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile U *arg) { - generate(function_context<R (*)(volatile T*, A0, A1, A2, A3, A4), volatile T>(func, arg)); + Callback(R(*func)(volatile T *, A0, A1, A2, A3, A4), volatile U *arg) + { + generate(function_context<R(*)(volatile T *, A0, A1, A2, A3, A4), volatile T>(func, arg)); } /** Create a Callback with a static function and bound pointer * @param func Static function to attach - * @param arg Pointer argument to function + * @param arg Pointer argument to function */ template<typename T, typename U> - Callback(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile U *arg) { - generate(function_context<R (*)(const volatile T*, A0, A1, A2, A3, A4), const volatile T>(func, arg)); + Callback(R(*func)(const volatile T *, A0, A1, A2, A3, A4), const volatile U *arg) + { + generate(function_context<R(*)(const volatile T *, A0, A1, A2, A3, A4), const volatile T>(func, arg)); } /** Create a Callback with a function object @@ -3052,7 +3314,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4))) { + Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3, A4))) + { generate(f); } @@ -3061,7 +3324,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4) const)) { + Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3, A4) const)) + { generate(f); } @@ -3070,7 +3334,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4) volatile)) { + Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3, A4) volatile)) + { generate(f); } @@ -3079,7 +3344,8 @@ * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4) const volatile)) { + Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3, A4) const volatile)) + { generate(f); } @@ -3091,8 +3357,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(U *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(U *obj, R(*func)(T *, A0, A1, A2, A3, A4)) + { new (this) Callback(func, obj); } @@ -3104,8 +3371,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(const U *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(const U *obj, R(*func)(const T *, A0, A1, A2, A3, A4)) + { new (this) Callback(func, obj); } @@ -3117,8 +3385,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(volatile U *obj, R(*func)(volatile T *, A0, A1, A2, A3, A4)) + { new (this) Callback(func, obj); } @@ -3130,14 +3399,16 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to Callback(func, arg)") - Callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { + "Arguments to callback have been reordered to Callback(func, arg)") + Callback(const volatile U *obj, R(*func)(const volatile T *, A0, A1, A2, A3, A4)) + { new (this) Callback(func, obj); } /** Destroy a callback */ - ~Callback() { + ~Callback() + { if (_ops) { _ops->dtor(this); } @@ -3149,8 +3420,9 @@ * Replaced by simple assignment 'Callback cb = func' */ MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(A0, A1, A2, A3, A4)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(A0, A1, A2, A3, A4)) + { this->~Callback(); new (this) Callback(func); } @@ -3161,8 +3433,9 @@ * Replaced by simple assignment 'Callback cb = func' */ MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const Callback<R(A0, A1, A2, A3, A4)> &func) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const Callback<R(A0, A1, A2, A3, A4)> &func) + { this->~Callback(); new (this) Callback(func); } @@ -3175,8 +3448,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(U *obj, R (T::*method)(A0, A1, A2, A3, A4)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(U *obj, R(T::*method)(A0, A1, A2, A3, A4)) + { this->~Callback(); new (this) Callback(obj, method); } @@ -3189,8 +3463,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const U *obj, R (T::*method)(A0, A1, A2, A3, A4) const) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const U *obj, R(T::*method)(A0, A1, A2, A3, A4) const) + { this->~Callback(); new (this) Callback(obj, method); } @@ -3203,8 +3478,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) { + "Replaced by simple assignment 'Callback cb = func") + void attach(volatile U *obj, R(T::*method)(A0, A1, A2, A3, A4) volatile) + { this->~Callback(); new (this) Callback(obj, method); } @@ -3217,8 +3493,9 @@ */ template<typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const volatile U *obj, R(T::*method)(A0, A1, A2, A3, A4) const volatile) + { this->~Callback(); new (this) Callback(obj, method); } @@ -3231,8 +3508,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(T*, A0, A1, A2, A3, A4), U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(T *, A0, A1, A2, A3, A4), U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -3245,8 +3523,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(const T*, A0, A1, A2, A3, A4), const U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(const T *, A0, A1, A2, A3, A4), const U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -3259,8 +3538,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(volatile T *, A0, A1, A2, A3, A4), volatile U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -3273,8 +3553,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile U *arg) { + "Replaced by simple assignment 'Callback cb = func") + void attach(R(*func)(const volatile T *, A0, A1, A2, A3, A4), const volatile U *arg) + { this->~Callback(); new (this) Callback(func, arg); } @@ -3287,8 +3568,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4))) { + "Replaced by simple assignment 'Callback cb = func") + void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3, A4))) + { this->~Callback(); new (this) Callback(f); } @@ -3301,8 +3583,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4) const)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3, A4) const)) + { this->~Callback(); new (this) Callback(f); } @@ -3315,8 +3598,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4) volatile)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3, A4) volatile)) + { this->~Callback(); new (this) Callback(f); } @@ -3329,8 +3613,9 @@ */ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", - "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4) const volatile)) { + "Replaced by simple assignment 'Callback cb = func") + void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R(F::*)(A0, A1, A2, A3, A4) const volatile)) + { this->~Callback(); new (this) Callback(f); } @@ -3343,8 +3628,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(U *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(U *obj, R(*func)(T *, A0, A1, A2, A3, A4)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -3357,8 +3643,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(const U *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(const U *obj, R(*func)(const T *, A0, A1, A2, A3, A4)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -3371,8 +3658,9 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(volatile U *obj, R(*func)(volatile T *, A0, A1, A2, A3, A4)) + { this->~Callback(); new (this) Callback(func, obj); } @@ -3385,15 +3673,17 @@ */ template <typename T, typename U> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to attach(func, arg)") - void attach(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { + "Arguments to callback have been reordered to attach(func, arg)") + void attach(const volatile U *obj, R(*func)(const volatile T *, A0, A1, A2, A3, A4)) + { this->~Callback(); new (this) Callback(func, obj); } /** Assign a callback */ - Callback &operator=(const Callback &that) { + Callback &operator=(const Callback &that) + { if (this != &that) { this->~Callback(); new (this) Callback(that); @@ -3404,32 +3694,37 @@ /** Call the attached function */ - R call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { + R call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const + { MBED_ASSERT(_ops); return _ops->call(this, a0, a1, a2, a3, a4); } /** Call the attached function */ - R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { + R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const + { return call(a0, a1, a2, a3, a4); } /** Test if function has been attached */ - operator bool() const { + operator bool() const + { return _ops; } /** Test for equality */ - friend bool operator==(const Callback &l, const Callback &r) { + friend bool operator==(const Callback &l, const Callback &r) + { return memcmp(&l, &r, sizeof(Callback)) == 0; } /** Test for inequality */ - friend bool operator!=(const Callback &l, const Callback &r) { + friend bool operator!=(const Callback &l, const Callback &r) + { return !(l == r); } @@ -3440,11 +3735,12 @@ * @param a2 An argument to be called with function func * @param a3 An argument to be called with function func * @param a4 An argument to be called with function func - * @return the value as determined by func which is of + * @return the value as determined by func which is of * type and determined by the signiture of func */ - static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { - return static_cast<Callback*>(func)->call(a0, a1, a2, a3, a4); + static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) + { + return static_cast<Callback *>(func)->call(a0, a1, a2, a3, a4); } private: @@ -3454,21 +3750,22 @@ struct _class; union { void (*_staticfunc)(A0, A1, A2, A3, A4); - void (*_boundfunc)(_class*, A0, A1, A2, A3, A4); + void (*_boundfunc)(_class *, A0, A1, A2, A3, A4); void (_class::*_methodfunc)(A0, A1, A2, A3, A4); } _func; void *_obj; // Dynamically dispatched operations const struct ops { - R (*call)(const void*, A0, A1, A2, A3, A4); - void (*move)(void*, const void*); - void (*dtor)(void*); + R(*call)(const void *, A0, A1, A2, A3, A4); + void (*move)(void *, const void *); + void (*dtor)(void *); } *_ops; // Generate operations for function object template <typename F> - void generate(const F &f) { + void generate(const F &f) + { static const ops ops = { &Callback::function_call<F>, &Callback::function_move<F>, @@ -3476,7 +3773,7 @@ }; MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F), - "Type F must not exceed the size of the Callback class"); + "Type F must not exceed the size of the Callback class"); memset(this, 0, sizeof(Callback)); new (this) F(f); _ops = &ops; @@ -3484,18 +3781,21 @@ // Function attributes template <typename F> - static R function_call(const void *p, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { - return (*(F*)p)(a0, a1, a2, a3, a4); + static R function_call(const void *p, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) + { + return (*(F *)p)(a0, a1, a2, a3, a4); } template <typename F> - static void function_move(void *d, const void *p) { - new (d) F(*(F*)p); + static void function_move(void *d, const void *p) + { + new (d) F(*(F *)p); } template <typename F> - static void function_dtor(void *p) { - ((F*)p)->~F(); + static void function_dtor(void *p) + { + ((F *)p)->~F(); } // Wrappers for functions with context @@ -3507,7 +3807,8 @@ method_context(O *obj, M method) : method(method), obj(obj) {} - R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { + R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const + { return (obj->*method)(a0, a1, a2, a3, a4); } }; @@ -3520,7 +3821,8 @@ function_context(F func, A *arg) : func(func), arg(arg) {} - R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { + R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const + { return func(arg, a0, a1, a2, a3, a4); } }; @@ -3536,7 +3838,8 @@ * @return Callback with infered type */ template <typename R> -Callback<R()> callback(R (*func)() = 0) { +Callback<R()> callback(R(*func)() = 0) +{ return Callback<R()>(func); } @@ -3546,7 +3849,8 @@ * @return Callback with infered type */ template <typename R> -Callback<R()> callback(const Callback<R()> &func) { +Callback<R()> callback(const Callback<R()> &func) +{ return Callback<R()>(func); } @@ -3557,7 +3861,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R> -Callback<R()> callback(U *obj, R (T::*method)()) { +Callback<R()> callback(U *obj, R(T::*method)()) +{ return Callback<R()>(obj, method); } @@ -3568,7 +3873,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R> -Callback<R()> callback(const U *obj, R (T::*method)() const) { +Callback<R()> callback(const U *obj, R(T::*method)() const) +{ return Callback<R()>(obj, method); } @@ -3579,7 +3885,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R> -Callback<R()> callback(volatile U *obj, R (T::*method)() volatile) { +Callback<R()> callback(volatile U *obj, R(T::*method)() volatile) +{ return Callback<R()>(obj, method); } @@ -3590,7 +3897,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R> -Callback<R()> callback(const volatile U *obj, R (T::*method)() const volatile) { +Callback<R()> callback(const volatile U *obj, R(T::*method)() const volatile) +{ return Callback<R()>(obj, method); } @@ -3601,7 +3909,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R> -Callback<R()> callback(R (*func)(T*), U *arg) { +Callback<R()> callback(R(*func)(T *), U *arg) +{ return Callback<R()>(func, arg); } @@ -3612,7 +3921,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R> -Callback<R()> callback(R (*func)(const T*), const U *arg) { +Callback<R()> callback(R(*func)(const T *), const U *arg) +{ return Callback<R()>(func, arg); } @@ -3623,7 +3933,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R> -Callback<R()> callback(R (*func)(volatile T*), volatile U *arg) { +Callback<R()> callback(R(*func)(volatile T *), volatile U *arg) +{ return Callback<R()>(func, arg); } @@ -3634,7 +3945,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R> -Callback<R()> callback(R (*func)(const volatile T*), const volatile U *arg) { +Callback<R()> callback(R(*func)(const volatile T *), const volatile U *arg) +{ return Callback<R()>(func, arg); } @@ -3648,8 +3960,9 @@ */ template <typename T, typename U, typename R> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R()> callback(U *obj, R (*func)(T*)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R()> callback(U *obj, R(*func)(T *)) +{ return Callback<R()>(func, obj); } @@ -3663,8 +3976,9 @@ */ template <typename T, typename U, typename R> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R()> callback(const U *obj, R (*func)(const T*)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R()> callback(const U *obj, R(*func)(const T *)) +{ return Callback<R()>(func, obj); } @@ -3678,8 +3992,9 @@ */ template <typename T, typename U, typename R> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R()> callback(volatile U *obj, R (*func)(volatile T*)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R()> callback(volatile U *obj, R(*func)(volatile T *)) +{ return Callback<R()>(func, obj); } @@ -3693,8 +4008,9 @@ */ template <typename T, typename U, typename R> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R()> callback(const volatile U *obj, R (*func)(const volatile T*)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R()> callback(const volatile U *obj, R(*func)(const volatile T *)) +{ return Callback<R()>(func, obj); } @@ -3705,7 +4021,8 @@ * @return Callback with infered type */ template <typename R, typename A0> -Callback<R(A0)> callback(R (*func)(A0) = 0) { +Callback<R(A0)> callback(R(*func)(A0) = 0) +{ return Callback<R(A0)>(func); } @@ -3715,7 +4032,8 @@ * @return Callback with infered type */ template <typename R, typename A0> -Callback<R(A0)> callback(const Callback<R(A0)> &func) { +Callback<R(A0)> callback(const Callback<R(A0)> &func) +{ return Callback<R(A0)>(func); } @@ -3726,7 +4044,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0> -Callback<R(A0)> callback(U *obj, R (T::*method)(A0)) { +Callback<R(A0)> callback(U *obj, R(T::*method)(A0)) +{ return Callback<R(A0)>(obj, method); } @@ -3737,7 +4056,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0> -Callback<R(A0)> callback(const U *obj, R (T::*method)(A0) const) { +Callback<R(A0)> callback(const U *obj, R(T::*method)(A0) const) +{ return Callback<R(A0)>(obj, method); } @@ -3748,7 +4068,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0> -Callback<R(A0)> callback(volatile U *obj, R (T::*method)(A0) volatile) { +Callback<R(A0)> callback(volatile U *obj, R(T::*method)(A0) volatile) +{ return Callback<R(A0)>(obj, method); } @@ -3759,7 +4080,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0> -Callback<R(A0)> callback(const volatile U *obj, R (T::*method)(A0) const volatile) { +Callback<R(A0)> callback(const volatile U *obj, R(T::*method)(A0) const volatile) +{ return Callback<R(A0)>(obj, method); } @@ -3770,7 +4092,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0> -Callback<R(A0)> callback(R (*func)(T*, A0), U *arg) { +Callback<R(A0)> callback(R(*func)(T *, A0), U *arg) +{ return Callback<R(A0)>(func, arg); } @@ -3781,7 +4104,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0> -Callback<R(A0)> callback(R (*func)(const T*, A0), const U *arg) { +Callback<R(A0)> callback(R(*func)(const T *, A0), const U *arg) +{ return Callback<R(A0)>(func, arg); } @@ -3792,7 +4116,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0> -Callback<R(A0)> callback(R (*func)(volatile T*, A0), volatile U *arg) { +Callback<R(A0)> callback(R(*func)(volatile T *, A0), volatile U *arg) +{ return Callback<R(A0)>(func, arg); } @@ -3803,7 +4128,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0> -Callback<R(A0)> callback(R (*func)(const volatile T*, A0), const volatile U *arg) { +Callback<R(A0)> callback(R(*func)(const volatile T *, A0), const volatile U *arg) +{ return Callback<R(A0)>(func, arg); } @@ -3817,8 +4143,9 @@ */ template <typename T, typename U, typename R, typename A0> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0)> callback(U *obj, R (*func)(T*, A0)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0)> callback(U *obj, R(*func)(T *, A0)) +{ return Callback<R(A0)>(func, obj); } @@ -3832,8 +4159,9 @@ */ template <typename T, typename U, typename R, typename A0> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0)> callback(const U *obj, R (*func)(const T*, A0)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0)> callback(const U *obj, R(*func)(const T *, A0)) +{ return Callback<R(A0)>(func, obj); } @@ -3847,8 +4175,9 @@ */ template <typename T, typename U, typename R, typename A0> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0)> callback(volatile U *obj, R (*func)(volatile T*, A0)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0)> callback(volatile U *obj, R(*func)(volatile T *, A0)) +{ return Callback<R(A0)>(func, obj); } @@ -3862,8 +4191,9 @@ */ template <typename T, typename U, typename R, typename A0> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0)> callback(const volatile U *obj, R (*func)(const volatile T*, A0)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0)> callback(const volatile U *obj, R(*func)(const volatile T *, A0)) +{ return Callback<R(A0)>(func, obj); } @@ -3874,7 +4204,8 @@ * @return Callback with infered type */ template <typename R, typename A0, typename A1> -Callback<R(A0, A1)> callback(R (*func)(A0, A1) = 0) { +Callback<R(A0, A1)> callback(R(*func)(A0, A1) = 0) +{ return Callback<R(A0, A1)>(func); } @@ -3884,7 +4215,8 @@ * @return Callback with infered type */ template <typename R, typename A0, typename A1> -Callback<R(A0, A1)> callback(const Callback<R(A0, A1)> &func) { +Callback<R(A0, A1)> callback(const Callback<R(A0, A1)> &func) +{ return Callback<R(A0, A1)>(func); } @@ -3895,7 +4227,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1> -Callback<R(A0, A1)> callback(U *obj, R (T::*method)(A0, A1)) { +Callback<R(A0, A1)> callback(U *obj, R(T::*method)(A0, A1)) +{ return Callback<R(A0, A1)>(obj, method); } @@ -3906,7 +4239,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1> -Callback<R(A0, A1)> callback(const U *obj, R (T::*method)(A0, A1) const) { +Callback<R(A0, A1)> callback(const U *obj, R(T::*method)(A0, A1) const) +{ return Callback<R(A0, A1)>(obj, method); } @@ -3917,7 +4251,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1> -Callback<R(A0, A1)> callback(volatile U *obj, R (T::*method)(A0, A1) volatile) { +Callback<R(A0, A1)> callback(volatile U *obj, R(T::*method)(A0, A1) volatile) +{ return Callback<R(A0, A1)>(obj, method); } @@ -3928,7 +4263,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1> -Callback<R(A0, A1)> callback(const volatile U *obj, R (T::*method)(A0, A1) const volatile) { +Callback<R(A0, A1)> callback(const volatile U *obj, R(T::*method)(A0, A1) const volatile) +{ return Callback<R(A0, A1)>(obj, method); } @@ -3939,7 +4275,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1> -Callback<R(A0, A1)> callback(R (*func)(T*, A0, A1), U *arg) { +Callback<R(A0, A1)> callback(R(*func)(T *, A0, A1), U *arg) +{ return Callback<R(A0, A1)>(func, arg); } @@ -3950,7 +4287,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1> -Callback<R(A0, A1)> callback(R (*func)(const T*, A0, A1), const U *arg) { +Callback<R(A0, A1)> callback(R(*func)(const T *, A0, A1), const U *arg) +{ return Callback<R(A0, A1)>(func, arg); } @@ -3961,7 +4299,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1> -Callback<R(A0, A1)> callback(R (*func)(volatile T*, A0, A1), volatile U *arg) { +Callback<R(A0, A1)> callback(R(*func)(volatile T *, A0, A1), volatile U *arg) +{ return Callback<R(A0, A1)>(func, arg); } @@ -3972,7 +4311,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1> -Callback<R(A0, A1)> callback(R (*func)(const volatile T*, A0, A1), const volatile U *arg) { +Callback<R(A0, A1)> callback(R(*func)(const volatile T *, A0, A1), const volatile U *arg) +{ return Callback<R(A0, A1)>(func, arg); } @@ -3986,8 +4326,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1)> callback(U *obj, R (*func)(T*, A0, A1)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1)> callback(U *obj, R(*func)(T *, A0, A1)) +{ return Callback<R(A0, A1)>(func, obj); } @@ -4001,8 +4342,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1)> callback(const U *obj, R (*func)(const T*, A0, A1)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1)> callback(const U *obj, R(*func)(const T *, A0, A1)) +{ return Callback<R(A0, A1)>(func, obj); } @@ -4016,8 +4358,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1)> callback(volatile U *obj, R (*func)(volatile T*, A0, A1)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1)> callback(volatile U *obj, R(*func)(volatile T *, A0, A1)) +{ return Callback<R(A0, A1)>(func, obj); } @@ -4031,8 +4374,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1)> callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1)> callback(const volatile U *obj, R(*func)(const volatile T *, A0, A1)) +{ return Callback<R(A0, A1)>(func, obj); } @@ -4043,7 +4387,8 @@ * @return Callback with infered type */ template <typename R, typename A0, typename A1, typename A2> -Callback<R(A0, A1, A2)> callback(R (*func)(A0, A1, A2) = 0) { +Callback<R(A0, A1, A2)> callback(R(*func)(A0, A1, A2) = 0) +{ return Callback<R(A0, A1, A2)>(func); } @@ -4053,7 +4398,8 @@ * @return Callback with infered type */ template <typename R, typename A0, typename A1, typename A2> -Callback<R(A0, A1, A2)> callback(const Callback<R(A0, A1, A2)> &func) { +Callback<R(A0, A1, A2)> callback(const Callback<R(A0, A1, A2)> &func) +{ return Callback<R(A0, A1, A2)>(func); } @@ -4064,7 +4410,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1, typename A2> -Callback<R(A0, A1, A2)> callback(U *obj, R (T::*method)(A0, A1, A2)) { +Callback<R(A0, A1, A2)> callback(U *obj, R(T::*method)(A0, A1, A2)) +{ return Callback<R(A0, A1, A2)>(obj, method); } @@ -4075,7 +4422,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1, typename A2> -Callback<R(A0, A1, A2)> callback(const U *obj, R (T::*method)(A0, A1, A2) const) { +Callback<R(A0, A1, A2)> callback(const U *obj, R(T::*method)(A0, A1, A2) const) +{ return Callback<R(A0, A1, A2)>(obj, method); } @@ -4086,7 +4434,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1, typename A2> -Callback<R(A0, A1, A2)> callback(volatile U *obj, R (T::*method)(A0, A1, A2) volatile) { +Callback<R(A0, A1, A2)> callback(volatile U *obj, R(T::*method)(A0, A1, A2) volatile) +{ return Callback<R(A0, A1, A2)>(obj, method); } @@ -4097,7 +4446,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1, typename A2> -Callback<R(A0, A1, A2)> callback(const volatile U *obj, R (T::*method)(A0, A1, A2) const volatile) { +Callback<R(A0, A1, A2)> callback(const volatile U *obj, R(T::*method)(A0, A1, A2) const volatile) +{ return Callback<R(A0, A1, A2)>(obj, method); } @@ -4108,7 +4458,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2> -Callback<R(A0, A1, A2)> callback(R (*func)(T*, A0, A1, A2), U *arg) { +Callback<R(A0, A1, A2)> callback(R(*func)(T *, A0, A1, A2), U *arg) +{ return Callback<R(A0, A1, A2)>(func, arg); } @@ -4119,7 +4470,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2> -Callback<R(A0, A1, A2)> callback(R (*func)(const T*, A0, A1, A2), const U *arg) { +Callback<R(A0, A1, A2)> callback(R(*func)(const T *, A0, A1, A2), const U *arg) +{ return Callback<R(A0, A1, A2)>(func, arg); } @@ -4130,7 +4482,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2> -Callback<R(A0, A1, A2)> callback(R (*func)(volatile T*, A0, A1, A2), volatile U *arg) { +Callback<R(A0, A1, A2)> callback(R(*func)(volatile T *, A0, A1, A2), volatile U *arg) +{ return Callback<R(A0, A1, A2)>(func, arg); } @@ -4141,7 +4494,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2> -Callback<R(A0, A1, A2)> callback(R (*func)(const volatile T*, A0, A1, A2), const volatile U *arg) { +Callback<R(A0, A1, A2)> callback(R(*func)(const volatile T *, A0, A1, A2), const volatile U *arg) +{ return Callback<R(A0, A1, A2)>(func, arg); } @@ -4155,8 +4509,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1, A2)> callback(U *obj, R (*func)(T*, A0, A1, A2)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1, A2)> callback(U *obj, R(*func)(T *, A0, A1, A2)) +{ return Callback<R(A0, A1, A2)>(func, obj); } @@ -4170,8 +4525,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1, A2)> callback(const U *obj, R (*func)(const T*, A0, A1, A2)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1, A2)> callback(const U *obj, R(*func)(const T *, A0, A1, A2)) +{ return Callback<R(A0, A1, A2)>(func, obj); } @@ -4185,8 +4541,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1, A2)> callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1, A2)> callback(volatile U *obj, R(*func)(volatile T *, A0, A1, A2)) +{ return Callback<R(A0, A1, A2)>(func, obj); } @@ -4200,8 +4557,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1, A2)> callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1, A2)> callback(const volatile U *obj, R(*func)(const volatile T *, A0, A1, A2)) +{ return Callback<R(A0, A1, A2)>(func, obj); } @@ -4212,7 +4570,8 @@ * @return Callback with infered type */ template <typename R, typename A0, typename A1, typename A2, typename A3> -Callback<R(A0, A1, A2, A3)> callback(R (*func)(A0, A1, A2, A3) = 0) { +Callback<R(A0, A1, A2, A3)> callback(R(*func)(A0, A1, A2, A3) = 0) +{ return Callback<R(A0, A1, A2, A3)>(func); } @@ -4222,7 +4581,8 @@ * @return Callback with infered type */ template <typename R, typename A0, typename A1, typename A2, typename A3> -Callback<R(A0, A1, A2, A3)> callback(const Callback<R(A0, A1, A2, A3)> &func) { +Callback<R(A0, A1, A2, A3)> callback(const Callback<R(A0, A1, A2, A3)> &func) +{ return Callback<R(A0, A1, A2, A3)>(func); } @@ -4233,7 +4593,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> -Callback<R(A0, A1, A2, A3)> callback(U *obj, R (T::*method)(A0, A1, A2, A3)) { +Callback<R(A0, A1, A2, A3)> callback(U *obj, R(T::*method)(A0, A1, A2, A3)) +{ return Callback<R(A0, A1, A2, A3)>(obj, method); } @@ -4244,7 +4605,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> -Callback<R(A0, A1, A2, A3)> callback(const U *obj, R (T::*method)(A0, A1, A2, A3) const) { +Callback<R(A0, A1, A2, A3)> callback(const U *obj, R(T::*method)(A0, A1, A2, A3) const) +{ return Callback<R(A0, A1, A2, A3)>(obj, method); } @@ -4255,7 +4617,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> -Callback<R(A0, A1, A2, A3)> callback(volatile U *obj, R (T::*method)(A0, A1, A2, A3) volatile) { +Callback<R(A0, A1, A2, A3)> callback(volatile U *obj, R(T::*method)(A0, A1, A2, A3) volatile) +{ return Callback<R(A0, A1, A2, A3)>(obj, method); } @@ -4266,7 +4629,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> -Callback<R(A0, A1, A2, A3)> callback(const volatile U *obj, R (T::*method)(A0, A1, A2, A3) const volatile) { +Callback<R(A0, A1, A2, A3)> callback(const volatile U *obj, R(T::*method)(A0, A1, A2, A3) const volatile) +{ return Callback<R(A0, A1, A2, A3)>(obj, method); } @@ -4277,7 +4641,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> -Callback<R(A0, A1, A2, A3)> callback(R (*func)(T*, A0, A1, A2, A3), U *arg) { +Callback<R(A0, A1, A2, A3)> callback(R(*func)(T *, A0, A1, A2, A3), U *arg) +{ return Callback<R(A0, A1, A2, A3)>(func, arg); } @@ -4288,7 +4653,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> -Callback<R(A0, A1, A2, A3)> callback(R (*func)(const T*, A0, A1, A2, A3), const U *arg) { +Callback<R(A0, A1, A2, A3)> callback(R(*func)(const T *, A0, A1, A2, A3), const U *arg) +{ return Callback<R(A0, A1, A2, A3)>(func, arg); } @@ -4299,7 +4665,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> -Callback<R(A0, A1, A2, A3)> callback(R (*func)(volatile T*, A0, A1, A2, A3), volatile U *arg) { +Callback<R(A0, A1, A2, A3)> callback(R(*func)(volatile T *, A0, A1, A2, A3), volatile U *arg) +{ return Callback<R(A0, A1, A2, A3)>(func, arg); } @@ -4310,7 +4677,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> -Callback<R(A0, A1, A2, A3)> callback(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile U *arg) { +Callback<R(A0, A1, A2, A3)> callback(R(*func)(const volatile T *, A0, A1, A2, A3), const volatile U *arg) +{ return Callback<R(A0, A1, A2, A3)>(func, arg); } @@ -4324,8 +4692,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1, A2, A3)> callback(U *obj, R (*func)(T*, A0, A1, A2, A3)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1, A2, A3)> callback(U *obj, R(*func)(T *, A0, A1, A2, A3)) +{ return Callback<R(A0, A1, A2, A3)>(func, obj); } @@ -4339,8 +4708,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1, A2, A3)> callback(const U *obj, R (*func)(const T*, A0, A1, A2, A3)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1, A2, A3)> callback(const U *obj, R(*func)(const T *, A0, A1, A2, A3)) +{ return Callback<R(A0, A1, A2, A3)>(func, obj); } @@ -4354,8 +4724,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1, A2, A3)> callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1, A2, A3)> callback(volatile U *obj, R(*func)(volatile T *, A0, A1, A2, A3)) +{ return Callback<R(A0, A1, A2, A3)>(func, obj); } @@ -4369,8 +4740,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1, A2, A3)> callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1, A2, A3)> callback(const volatile U *obj, R(*func)(const volatile T *, A0, A1, A2, A3)) +{ return Callback<R(A0, A1, A2, A3)>(func, obj); } @@ -4381,7 +4753,8 @@ * @return Callback with infered type */ template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> -Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(A0, A1, A2, A3, A4) = 0) { +Callback<R(A0, A1, A2, A3, A4)> callback(R(*func)(A0, A1, A2, A3, A4) = 0) +{ return Callback<R(A0, A1, A2, A3, A4)>(func); } @@ -4391,7 +4764,8 @@ * @return Callback with infered type */ template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> -Callback<R(A0, A1, A2, A3, A4)> callback(const Callback<R(A0, A1, A2, A3, A4)> &func) { +Callback<R(A0, A1, A2, A3, A4)> callback(const Callback<R(A0, A1, A2, A3, A4)> &func) +{ return Callback<R(A0, A1, A2, A3, A4)>(func); } @@ -4402,7 +4776,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> -Callback<R(A0, A1, A2, A3, A4)> callback(U *obj, R (T::*method)(A0, A1, A2, A3, A4)) { +Callback<R(A0, A1, A2, A3, A4)> callback(U *obj, R(T::*method)(A0, A1, A2, A3, A4)) +{ return Callback<R(A0, A1, A2, A3, A4)>(obj, method); } @@ -4413,7 +4788,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> -Callback<R(A0, A1, A2, A3, A4)> callback(const U *obj, R (T::*method)(A0, A1, A2, A3, A4) const) { +Callback<R(A0, A1, A2, A3, A4)> callback(const U *obj, R(T::*method)(A0, A1, A2, A3, A4) const) +{ return Callback<R(A0, A1, A2, A3, A4)>(obj, method); } @@ -4424,7 +4800,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> -Callback<R(A0, A1, A2, A3, A4)> callback(volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) { +Callback<R(A0, A1, A2, A3, A4)> callback(volatile U *obj, R(T::*method)(A0, A1, A2, A3, A4) volatile) +{ return Callback<R(A0, A1, A2, A3, A4)>(obj, method); } @@ -4435,7 +4812,8 @@ * @return Callback with infered type */ template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> -Callback<R(A0, A1, A2, A3, A4)> callback(const volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) { +Callback<R(A0, A1, A2, A3, A4)> callback(const volatile U *obj, R(T::*method)(A0, A1, A2, A3, A4) const volatile) +{ return Callback<R(A0, A1, A2, A3, A4)>(obj, method); } @@ -4446,7 +4824,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> -Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(T*, A0, A1, A2, A3, A4), U *arg) { +Callback<R(A0, A1, A2, A3, A4)> callback(R(*func)(T *, A0, A1, A2, A3, A4), U *arg) +{ return Callback<R(A0, A1, A2, A3, A4)>(func, arg); } @@ -4457,7 +4836,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> -Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const T*, A0, A1, A2, A3, A4), const U *arg) { +Callback<R(A0, A1, A2, A3, A4)> callback(R(*func)(const T *, A0, A1, A2, A3, A4), const U *arg) +{ return Callback<R(A0, A1, A2, A3, A4)>(func, arg); } @@ -4468,7 +4848,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> -Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile U *arg) { +Callback<R(A0, A1, A2, A3, A4)> callback(R(*func)(volatile T *, A0, A1, A2, A3, A4), volatile U *arg) +{ return Callback<R(A0, A1, A2, A3, A4)>(func, arg); } @@ -4479,7 +4860,8 @@ * @return Callback with infered type */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> -Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile U *arg) { +Callback<R(A0, A1, A2, A3, A4)> callback(R(*func)(const volatile T *, A0, A1, A2, A3, A4), const volatile U *arg) +{ return Callback<R(A0, A1, A2, A3, A4)>(func, arg); } @@ -4493,8 +4875,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1, A2, A3, A4)> callback(U *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1, A2, A3, A4)> callback(U *obj, R(*func)(T *, A0, A1, A2, A3, A4)) +{ return Callback<R(A0, A1, A2, A3, A4)>(func, obj); } @@ -4508,8 +4891,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1, A2, A3, A4)> callback(const U *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1, A2, A3, A4)> callback(const U *obj, R(*func)(const T *, A0, A1, A2, A3, A4)) +{ return Callback<R(A0, A1, A2, A3, A4)>(func, obj); } @@ -4523,8 +4907,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1, A2, A3, A4)> callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1, A2, A3, A4)> callback(volatile U *obj, R(*func)(volatile T *, A0, A1, A2, A3, A4)) +{ return Callback<R(A0, A1, A2, A3, A4)>(func, obj); } @@ -4538,8 +4923,9 @@ */ template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> MBED_DEPRECATED_SINCE("mbed-os-5.1", - "Arguments to callback have been reordered to callback(func, arg)") -Callback<R(A0, A1, A2, A3, A4)> callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { + "Arguments to callback have been reordered to callback(func, arg)") +Callback<R(A0, A1, A2, A3, A4)> callback(const volatile U *obj, R(*func)(const volatile T *, A0, A1, A2, A3, A4)) +{ return Callback<R(A0, A1, A2, A3, A4)>(func, obj); }