ads1115 only

Fork of mbed by mbed official

Committer:
<>
Date:
Thu Nov 24 11:01:25 2016 +0000
Revision:
130:d75b3fe1f5cb
Parent:
128:9bcdf88f62b0
Release 130 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3127: Fixed the issue about push/pop of VFP register. https://github.com/ARMmbed/mbed-os/pull/3127
3176: Modifying micro:bit pin names to mirror micro:bit edge connector https://github.com/ARMmbed/mbed-os/pull/3176
3160: Fix wrong index at LPC43xx tx end ring assignment https://github.com/ARMmbed/mbed-os/pull/3160
3217: Add I2C_ASYNCH capability for DISCO_F469NI https://github.com/ARMmbed/mbed-os/pull/3217
3211: [NUC472/M453] Support single UART shared by multiple serial objects and other updates https://github.com/ARMmbed/mbed-os/pull/3211
3198: NUCLEO_F410RB: Add I2C_ASYNCH capability https://github.com/ARMmbed/mbed-os/pull/3198
3194: Update K64 sdk drivers https://github.com/ARMmbed/mbed-os/pull/3194
3159: User trim values for NCS36510 https://github.com/ARMmbed/mbed-os/pull/3159
3243: Fix make exporters compilation https://github.com/ARMmbed/mbed-os/pull/3243
3231: STM32F3: DISCO_F303VC - Add missing UART and ADC pin muxing options https://github.com/ARMmbed/mbed-os/pull/3231
3233: K20xx Calculate PWM clock relative to bus clock https://github.com/ARMmbed/mbed-os/pull/3233
3237: Added back USART 6 pins https://github.com/ARMmbed/mbed-os/pull/3237
3253: Fix default polarity on LPC43XX PWM driver https://github.com/ARMmbed/mbed-os/pull/3253
3238: Dev i2c stm32f4hal https://github.com/ARMmbed/mbed-os/pull/3238
3251: Dev stm32l0 cube v1.7.0 https://github.com/ARMmbed/mbed-os/pull/3251
3252: [NORDIC - NRF51 - MBED 2] Fix non handled RTC IRQ https://github.com/ARMmbed/mbed-os/pull/3252

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 128:9bcdf88f62b0 1 /* mbed Microcontroller Library
<> 128:9bcdf88f62b0 2 * Copyright (c) 2006-2015 ARM Limited
<> 128:9bcdf88f62b0 3 *
<> 128:9bcdf88f62b0 4 * Licensed under the Apache License, Version 2.0 (the "License");
<> 128:9bcdf88f62b0 5 * you may not use this file except in compliance with the License.
<> 128:9bcdf88f62b0 6 * You may obtain a copy of the License at
<> 128:9bcdf88f62b0 7 *
<> 128:9bcdf88f62b0 8 * http://www.apache.org/licenses/LICENSE-2.0
<> 128:9bcdf88f62b0 9 *
<> 128:9bcdf88f62b0 10 * Unless required by applicable law or agreed to in writing, software
<> 128:9bcdf88f62b0 11 * distributed under the License is distributed on an "AS IS" BASIS,
<> 128:9bcdf88f62b0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 128:9bcdf88f62b0 13 * See the License for the specific language governing permissions and
<> 128:9bcdf88f62b0 14 * limitations under the License.
<> 128:9bcdf88f62b0 15 */
<> 128:9bcdf88f62b0 16 #ifndef MBED_CALLBACK_H
<> 128:9bcdf88f62b0 17 #define MBED_CALLBACK_H
<> 128:9bcdf88f62b0 18
<> 128:9bcdf88f62b0 19 #include <string.h>
<> 128:9bcdf88f62b0 20 #include <stdint.h>
<> 128:9bcdf88f62b0 21 #include <new>
<> 128:9bcdf88f62b0 22 #include "platform/mbed_assert.h"
<> 128:9bcdf88f62b0 23 #include "platform/toolchain.h"
<> 128:9bcdf88f62b0 24
<> 128:9bcdf88f62b0 25 namespace mbed {
<> 128:9bcdf88f62b0 26 /** \addtogroup platform */
<> 128:9bcdf88f62b0 27 /** @{*/
<> 128:9bcdf88f62b0 28
<> 128:9bcdf88f62b0 29
<> 128:9bcdf88f62b0 30 /** Callback class based on template specialization
<> 128:9bcdf88f62b0 31 *
<> 128:9bcdf88f62b0 32 * @Note Synchronization level: Not protected
<> 128:9bcdf88f62b0 33 */
<> 128:9bcdf88f62b0 34 template <typename F>
<> 128:9bcdf88f62b0 35 class Callback;
<> 128:9bcdf88f62b0 36
<> 128:9bcdf88f62b0 37 // Internal sfinae declarations
<> 128:9bcdf88f62b0 38 //
<> 128:9bcdf88f62b0 39 // These are used to eliminate overloads based on type attributes
<> 128:9bcdf88f62b0 40 // 1. Does a function object have a call operator
<> 128:9bcdf88f62b0 41 // 2. Does a function object fit in the available storage
<> 128:9bcdf88f62b0 42 //
<> 128:9bcdf88f62b0 43 // These eliminations are handled cleanly by the compiler and avoid
<> 128:9bcdf88f62b0 44 // massive and misleading error messages when confronted with an
<> 128:9bcdf88f62b0 45 // invalid type (or worse, runtime failures)
<> 128:9bcdf88f62b0 46 namespace detail {
<> 128:9bcdf88f62b0 47 struct nil {};
<> 128:9bcdf88f62b0 48
<> 128:9bcdf88f62b0 49 template <bool B, typename R = nil>
<> 128:9bcdf88f62b0 50 struct enable_if { typedef R type; };
<> 128:9bcdf88f62b0 51
<> 128:9bcdf88f62b0 52 template <typename R>
<> 128:9bcdf88f62b0 53 struct enable_if<false, R> {};
<> 128:9bcdf88f62b0 54
<> 128:9bcdf88f62b0 55 template <typename M, M>
<> 128:9bcdf88f62b0 56 struct is_type {
<> 128:9bcdf88f62b0 57 static const bool value = true;
<> 128:9bcdf88f62b0 58 };
<> 128:9bcdf88f62b0 59 }
<> 128:9bcdf88f62b0 60
<> 128:9bcdf88f62b0 61 /** Callback class based on template specialization
<> 128:9bcdf88f62b0 62 *
<> 128:9bcdf88f62b0 63 * @Note Synchronization level: Not protected
<> 128:9bcdf88f62b0 64 */
<> 128:9bcdf88f62b0 65 template <typename R>
<> 128:9bcdf88f62b0 66 class Callback<R()> {
<> 128:9bcdf88f62b0 67 public:
<> 128:9bcdf88f62b0 68 /** Create a Callback with a static function
<> 128:9bcdf88f62b0 69 * @param func Static function to attach
<> 128:9bcdf88f62b0 70 */
<> 128:9bcdf88f62b0 71 Callback(R (*func)() = 0) {
<> 128:9bcdf88f62b0 72 if (!func) {
<> 128:9bcdf88f62b0 73 _ops = 0;
<> 128:9bcdf88f62b0 74 } else {
<> 128:9bcdf88f62b0 75 generate(func);
<> 128:9bcdf88f62b0 76 }
<> 128:9bcdf88f62b0 77 }
<> 128:9bcdf88f62b0 78
<> 128:9bcdf88f62b0 79 /** Attach a Callback
<> 128:9bcdf88f62b0 80 * @param func The Callback to attach
<> 128:9bcdf88f62b0 81 */
<> 128:9bcdf88f62b0 82 Callback(const Callback<R()> &func) {
<> 128:9bcdf88f62b0 83 if (func._ops) {
<> 128:9bcdf88f62b0 84 func._ops->move(this, &func);
<> 128:9bcdf88f62b0 85 }
<> 128:9bcdf88f62b0 86 _ops = func._ops;
<> 128:9bcdf88f62b0 87 }
<> 128:9bcdf88f62b0 88
<> 128:9bcdf88f62b0 89 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 90 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 91 * @param method Member function to attach
<> 128:9bcdf88f62b0 92 */
<> 130:d75b3fe1f5cb 93 template<typename T, typename U>
<> 130:d75b3fe1f5cb 94 Callback(U *obj, R (T::*method)()) {
<> 128:9bcdf88f62b0 95 generate(method_context<T, R (T::*)()>(obj, method));
<> 128:9bcdf88f62b0 96 }
<> 128:9bcdf88f62b0 97
<> 128:9bcdf88f62b0 98 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 99 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 100 * @param method Member function to attach
<> 128:9bcdf88f62b0 101 */
<> 130:d75b3fe1f5cb 102 template<typename T, typename U>
<> 130:d75b3fe1f5cb 103 Callback(const U *obj, R (T::*method)() const) {
<> 128:9bcdf88f62b0 104 generate(method_context<const T, R (T::*)() const>(obj, method));
<> 128:9bcdf88f62b0 105 }
<> 128:9bcdf88f62b0 106
<> 128:9bcdf88f62b0 107 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 108 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 109 * @param method Member function to attach
<> 128:9bcdf88f62b0 110 */
<> 130:d75b3fe1f5cb 111 template<typename T, typename U>
<> 130:d75b3fe1f5cb 112 Callback(volatile U *obj, R (T::*method)() volatile) {
<> 128:9bcdf88f62b0 113 generate(method_context<volatile T, R (T::*)() volatile>(obj, method));
<> 128:9bcdf88f62b0 114 }
<> 128:9bcdf88f62b0 115
<> 128:9bcdf88f62b0 116 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 117 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 118 * @param method Member function to attach
<> 128:9bcdf88f62b0 119 */
<> 130:d75b3fe1f5cb 120 template<typename T, typename U>
<> 130:d75b3fe1f5cb 121 Callback(const volatile U *obj, R (T::*method)() const volatile) {
<> 128:9bcdf88f62b0 122 generate(method_context<const volatile T, R (T::*)() const volatile>(obj, method));
<> 128:9bcdf88f62b0 123 }
<> 128:9bcdf88f62b0 124
<> 128:9bcdf88f62b0 125 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 126 * @param func Static function to attach
<> 128:9bcdf88f62b0 127 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 128 */
<> 130:d75b3fe1f5cb 129 template<typename T, typename U>
<> 130:d75b3fe1f5cb 130 Callback(R (*func)(T*), U *arg) {
<> 128:9bcdf88f62b0 131 generate(function_context<R (*)(T*), T>(func, arg));
<> 128:9bcdf88f62b0 132 }
<> 128:9bcdf88f62b0 133
<> 128:9bcdf88f62b0 134 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 135 * @param func Static function to attach
<> 128:9bcdf88f62b0 136 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 137 */
<> 130:d75b3fe1f5cb 138 template<typename T, typename U>
<> 130:d75b3fe1f5cb 139 Callback(R (*func)(const T*), const U *arg) {
<> 128:9bcdf88f62b0 140 generate(function_context<R (*)(const T*), const T>(func, arg));
<> 128:9bcdf88f62b0 141 }
<> 128:9bcdf88f62b0 142
<> 128:9bcdf88f62b0 143 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 144 * @param func Static function to attach
<> 128:9bcdf88f62b0 145 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 146 */
<> 130:d75b3fe1f5cb 147 template<typename T, typename U>
<> 130:d75b3fe1f5cb 148 Callback(R (*func)(volatile T*), volatile U *arg) {
<> 128:9bcdf88f62b0 149 generate(function_context<R (*)(volatile T*), volatile T>(func, arg));
<> 128:9bcdf88f62b0 150 }
<> 128:9bcdf88f62b0 151
<> 128:9bcdf88f62b0 152 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 153 * @param func Static function to attach
<> 128:9bcdf88f62b0 154 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 155 */
<> 130:d75b3fe1f5cb 156 template<typename T, typename U>
<> 130:d75b3fe1f5cb 157 Callback(R (*func)(const volatile T*), const volatile U *arg) {
<> 128:9bcdf88f62b0 158 generate(function_context<R (*)(const volatile T*), const volatile T>(func, arg));
<> 128:9bcdf88f62b0 159 }
<> 128:9bcdf88f62b0 160
<> 128:9bcdf88f62b0 161 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 162 * @param func Function object to attach
<> 128:9bcdf88f62b0 163 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 164 */
<> 128:9bcdf88f62b0 165 template <typename F>
<> 128:9bcdf88f62b0 166 Callback(F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 167 detail::is_type<R (F::*)(), &F::operator()>::value &&
<> 128:9bcdf88f62b0 168 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 169 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 170 generate(f);
<> 128:9bcdf88f62b0 171 }
<> 128:9bcdf88f62b0 172
<> 128:9bcdf88f62b0 173 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 174 * @param func Function object to attach
<> 128:9bcdf88f62b0 175 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 176 */
<> 128:9bcdf88f62b0 177 template <typename F>
<> 128:9bcdf88f62b0 178 Callback(const F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 179 detail::is_type<R (F::*)() const, &F::operator()>::value &&
<> 128:9bcdf88f62b0 180 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 181 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 182 generate(f);
<> 128:9bcdf88f62b0 183 }
<> 128:9bcdf88f62b0 184
<> 128:9bcdf88f62b0 185 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 186 * @param func Function object to attach
<> 128:9bcdf88f62b0 187 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 188 */
<> 128:9bcdf88f62b0 189 template <typename F>
<> 128:9bcdf88f62b0 190 Callback(volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 191 detail::is_type<R (F::*)() volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 192 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 193 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 194 generate(f);
<> 128:9bcdf88f62b0 195 }
<> 128:9bcdf88f62b0 196
<> 128:9bcdf88f62b0 197 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 198 * @param func Function object to attach
<> 128:9bcdf88f62b0 199 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 200 */
<> 128:9bcdf88f62b0 201 template <typename F>
<> 128:9bcdf88f62b0 202 Callback(const volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 203 detail::is_type<R (F::*)() const volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 204 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 205 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 206 generate(f);
<> 128:9bcdf88f62b0 207 }
<> 128:9bcdf88f62b0 208
<> 128:9bcdf88f62b0 209 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 210 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 211 * @param func Static function to attach
<> 128:9bcdf88f62b0 212 * @deprecated
<> 128:9bcdf88f62b0 213 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 214 */
<> 130:d75b3fe1f5cb 215 template<typename T, typename U>
<> 128:9bcdf88f62b0 216 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 217 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 218 Callback(U *obj, R (*func)(T*)) {
<> 128:9bcdf88f62b0 219 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 220 }
<> 128:9bcdf88f62b0 221
<> 128:9bcdf88f62b0 222 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 223 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 224 * @param func Static function to attach
<> 128:9bcdf88f62b0 225 * @deprecated
<> 128:9bcdf88f62b0 226 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 227 */
<> 130:d75b3fe1f5cb 228 template<typename T, typename U>
<> 128:9bcdf88f62b0 229 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 230 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 231 Callback(const U *obj, R (*func)(const T*)) {
<> 128:9bcdf88f62b0 232 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 233 }
<> 128:9bcdf88f62b0 234
<> 128:9bcdf88f62b0 235 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 236 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 237 * @param func Static function to attach
<> 128:9bcdf88f62b0 238 * @deprecated
<> 128:9bcdf88f62b0 239 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 240 */
<> 130:d75b3fe1f5cb 241 template<typename T, typename U>
<> 128:9bcdf88f62b0 242 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 243 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 244 Callback(volatile U *obj, R (*func)(volatile T*)) {
<> 128:9bcdf88f62b0 245 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 246 }
<> 128:9bcdf88f62b0 247
<> 128:9bcdf88f62b0 248 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 249 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 250 * @param func Static function to attach
<> 128:9bcdf88f62b0 251 * @deprecated
<> 128:9bcdf88f62b0 252 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 253 */
<> 130:d75b3fe1f5cb 254 template<typename T, typename U>
<> 128:9bcdf88f62b0 255 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 256 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 257 Callback(const volatile U *obj, R (*func)(const volatile T*)) {
<> 128:9bcdf88f62b0 258 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 259 }
<> 128:9bcdf88f62b0 260
<> 128:9bcdf88f62b0 261 /** Destroy a callback
<> 128:9bcdf88f62b0 262 */
<> 128:9bcdf88f62b0 263 ~Callback() {
<> 128:9bcdf88f62b0 264 if (_ops) {
<> 128:9bcdf88f62b0 265 _ops->dtor(this);
<> 128:9bcdf88f62b0 266 }
<> 128:9bcdf88f62b0 267 }
<> 128:9bcdf88f62b0 268
<> 128:9bcdf88f62b0 269 /** Attach a static function
<> 128:9bcdf88f62b0 270 * @param func Static function to attach
<> 128:9bcdf88f62b0 271 */
<> 128:9bcdf88f62b0 272 void attach(R (*func)()) {
<> 128:9bcdf88f62b0 273 this->~Callback();
<> 128:9bcdf88f62b0 274 new (this) Callback(func);
<> 128:9bcdf88f62b0 275 }
<> 128:9bcdf88f62b0 276
<> 128:9bcdf88f62b0 277 /** Attach a Callback
<> 128:9bcdf88f62b0 278 * @param func The Callback to attach
<> 128:9bcdf88f62b0 279 */
<> 128:9bcdf88f62b0 280 void attach(const Callback<R()> &func) {
<> 128:9bcdf88f62b0 281 this->~Callback();
<> 128:9bcdf88f62b0 282 new (this) Callback(func);
<> 128:9bcdf88f62b0 283 }
<> 128:9bcdf88f62b0 284
<> 128:9bcdf88f62b0 285 /** Attach a member function
<> 128:9bcdf88f62b0 286 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 287 * @param method Member function to attach
<> 128:9bcdf88f62b0 288 */
<> 130:d75b3fe1f5cb 289 template<typename T, typename U>
<> 130:d75b3fe1f5cb 290 void attach(U *obj, R (T::*method)()) {
<> 128:9bcdf88f62b0 291 this->~Callback();
<> 128:9bcdf88f62b0 292 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 293 }
<> 128:9bcdf88f62b0 294
<> 128:9bcdf88f62b0 295 /** Attach a member function
<> 128:9bcdf88f62b0 296 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 297 * @param method Member function to attach
<> 128:9bcdf88f62b0 298 */
<> 130:d75b3fe1f5cb 299 template<typename T, typename U>
<> 130:d75b3fe1f5cb 300 void attach(const U *obj, R (T::*method)() const) {
<> 128:9bcdf88f62b0 301 this->~Callback();
<> 128:9bcdf88f62b0 302 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 303 }
<> 128:9bcdf88f62b0 304
<> 128:9bcdf88f62b0 305 /** Attach a member function
<> 128:9bcdf88f62b0 306 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 307 * @param method Member function to attach
<> 128:9bcdf88f62b0 308 */
<> 130:d75b3fe1f5cb 309 template<typename T, typename U>
<> 130:d75b3fe1f5cb 310 void attach(volatile U *obj, R (T::*method)() volatile) {
<> 128:9bcdf88f62b0 311 this->~Callback();
<> 128:9bcdf88f62b0 312 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 313 }
<> 128:9bcdf88f62b0 314
<> 128:9bcdf88f62b0 315 /** Attach a member function
<> 128:9bcdf88f62b0 316 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 317 * @param method Member function to attach
<> 128:9bcdf88f62b0 318 */
<> 130:d75b3fe1f5cb 319 template<typename T, typename U>
<> 130:d75b3fe1f5cb 320 void attach(const volatile U *obj, R (T::*method)() const volatile) {
<> 128:9bcdf88f62b0 321 this->~Callback();
<> 128:9bcdf88f62b0 322 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 323 }
<> 128:9bcdf88f62b0 324
<> 128:9bcdf88f62b0 325 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 326 * @param func Static function to attach
<> 128:9bcdf88f62b0 327 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 328 */
<> 130:d75b3fe1f5cb 329 template <typename T, typename U>
<> 130:d75b3fe1f5cb 330 void attach(R (*func)(T*), U *arg) {
<> 128:9bcdf88f62b0 331 this->~Callback();
<> 128:9bcdf88f62b0 332 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 333 }
<> 128:9bcdf88f62b0 334
<> 128:9bcdf88f62b0 335 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 336 * @param func Static function to attach
<> 128:9bcdf88f62b0 337 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 338 */
<> 130:d75b3fe1f5cb 339 template <typename T, typename U>
<> 130:d75b3fe1f5cb 340 void attach(R (*func)(const T*), const U *arg) {
<> 128:9bcdf88f62b0 341 this->~Callback();
<> 128:9bcdf88f62b0 342 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 343 }
<> 128:9bcdf88f62b0 344
<> 128:9bcdf88f62b0 345 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 346 * @param func Static function to attach
<> 128:9bcdf88f62b0 347 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 348 */
<> 130:d75b3fe1f5cb 349 template <typename T, typename U>
<> 130:d75b3fe1f5cb 350 void attach(R (*func)(volatile T*), volatile U *arg) {
<> 128:9bcdf88f62b0 351 this->~Callback();
<> 128:9bcdf88f62b0 352 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 353 }
<> 128:9bcdf88f62b0 354
<> 128:9bcdf88f62b0 355 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 356 * @param func Static function to attach
<> 128:9bcdf88f62b0 357 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 358 */
<> 130:d75b3fe1f5cb 359 template <typename T, typename U>
<> 130:d75b3fe1f5cb 360 void attach(R (*func)(const volatile T*), const volatile U *arg) {
<> 128:9bcdf88f62b0 361 this->~Callback();
<> 128:9bcdf88f62b0 362 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 363 }
<> 128:9bcdf88f62b0 364
<> 128:9bcdf88f62b0 365 /** Attach a function object
<> 128:9bcdf88f62b0 366 * @param func Function object to attach
<> 128:9bcdf88f62b0 367 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 368 */
<> 128:9bcdf88f62b0 369 template <typename F>
<> 128:9bcdf88f62b0 370 void attach(F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 371 detail::is_type<R (F::*)(), &F::operator()>::value &&
<> 128:9bcdf88f62b0 372 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 373 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 374 this->~Callback();
<> 128:9bcdf88f62b0 375 new (this) Callback(f);
<> 128:9bcdf88f62b0 376 }
<> 128:9bcdf88f62b0 377
<> 128:9bcdf88f62b0 378 /** Attach a function object
<> 128:9bcdf88f62b0 379 * @param func Function object to attach
<> 128:9bcdf88f62b0 380 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 381 */
<> 128:9bcdf88f62b0 382 template <typename F>
<> 128:9bcdf88f62b0 383 void attach(const F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 384 detail::is_type<R (F::*)() const, &F::operator()>::value &&
<> 128:9bcdf88f62b0 385 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 386 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 387 this->~Callback();
<> 128:9bcdf88f62b0 388 new (this) Callback(f);
<> 128:9bcdf88f62b0 389 }
<> 128:9bcdf88f62b0 390
<> 128:9bcdf88f62b0 391 /** Attach a function object
<> 128:9bcdf88f62b0 392 * @param func Function object to attach
<> 128:9bcdf88f62b0 393 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 394 */
<> 128:9bcdf88f62b0 395 template <typename F>
<> 128:9bcdf88f62b0 396 void attach(volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 397 detail::is_type<R (F::*)() volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 398 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 399 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 400 this->~Callback();
<> 128:9bcdf88f62b0 401 new (this) Callback(f);
<> 128:9bcdf88f62b0 402 }
<> 128:9bcdf88f62b0 403
<> 128:9bcdf88f62b0 404 /** Attach a function object
<> 128:9bcdf88f62b0 405 * @param func Function object to attach
<> 128:9bcdf88f62b0 406 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 407 */
<> 128:9bcdf88f62b0 408 template <typename F>
<> 128:9bcdf88f62b0 409 void attach(const volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 410 detail::is_type<R (F::*)() const volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 411 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 412 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 413 this->~Callback();
<> 128:9bcdf88f62b0 414 new (this) Callback(f);
<> 128:9bcdf88f62b0 415 }
<> 128:9bcdf88f62b0 416
<> 128:9bcdf88f62b0 417 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 418 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 419 * @param func Static function to attach
<> 128:9bcdf88f62b0 420 * @deprecated
<> 128:9bcdf88f62b0 421 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 422 */
<> 130:d75b3fe1f5cb 423 template <typename T, typename U>
<> 128:9bcdf88f62b0 424 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 425 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 426 void attach(U *obj, R (*func)(T*)) {
<> 128:9bcdf88f62b0 427 this->~Callback();
<> 128:9bcdf88f62b0 428 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 429 }
<> 128:9bcdf88f62b0 430
<> 128:9bcdf88f62b0 431 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 432 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 433 * @param func Static function to attach
<> 128:9bcdf88f62b0 434 * @deprecated
<> 128:9bcdf88f62b0 435 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 436 */
<> 130:d75b3fe1f5cb 437 template <typename T, typename U>
<> 128:9bcdf88f62b0 438 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 439 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 440 void attach(const U *obj, R (*func)(const T*)) {
<> 128:9bcdf88f62b0 441 this->~Callback();
<> 128:9bcdf88f62b0 442 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 443 }
<> 128:9bcdf88f62b0 444
<> 128:9bcdf88f62b0 445 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 446 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 447 * @param func Static function to attach
<> 128:9bcdf88f62b0 448 * @deprecated
<> 128:9bcdf88f62b0 449 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 450 */
<> 130:d75b3fe1f5cb 451 template <typename T, typename U>
<> 128:9bcdf88f62b0 452 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 453 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 454 void attach(volatile U *obj, R (*func)(volatile T*)) {
<> 128:9bcdf88f62b0 455 this->~Callback();
<> 128:9bcdf88f62b0 456 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 457 }
<> 128:9bcdf88f62b0 458
<> 128:9bcdf88f62b0 459 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 460 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 461 * @param func Static function to attach
<> 128:9bcdf88f62b0 462 * @deprecated
<> 128:9bcdf88f62b0 463 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 464 */
<> 130:d75b3fe1f5cb 465 template <typename T, typename U>
<> 128:9bcdf88f62b0 466 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 467 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 468 void attach(const volatile U *obj, R (*func)(const volatile T*)) {
<> 128:9bcdf88f62b0 469 this->~Callback();
<> 128:9bcdf88f62b0 470 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 471 }
<> 128:9bcdf88f62b0 472
<> 128:9bcdf88f62b0 473 /** Assign a callback
<> 128:9bcdf88f62b0 474 */
<> 128:9bcdf88f62b0 475 Callback &operator=(const Callback &that) {
<> 128:9bcdf88f62b0 476 if (this != &that) {
<> 128:9bcdf88f62b0 477 this->~Callback();
<> 128:9bcdf88f62b0 478 new (this) Callback(that);
<> 128:9bcdf88f62b0 479 }
<> 128:9bcdf88f62b0 480
<> 128:9bcdf88f62b0 481 return *this;
<> 128:9bcdf88f62b0 482 }
<> 128:9bcdf88f62b0 483
<> 128:9bcdf88f62b0 484 /** Call the attached function
<> 128:9bcdf88f62b0 485 */
<> 128:9bcdf88f62b0 486 R call() const {
<> 128:9bcdf88f62b0 487 MBED_ASSERT(_ops);
<> 128:9bcdf88f62b0 488 return _ops->call(this);
<> 128:9bcdf88f62b0 489 }
<> 128:9bcdf88f62b0 490
<> 128:9bcdf88f62b0 491 /** Call the attached function
<> 128:9bcdf88f62b0 492 */
<> 128:9bcdf88f62b0 493 R operator()() const {
<> 128:9bcdf88f62b0 494 return call();
<> 128:9bcdf88f62b0 495 }
<> 128:9bcdf88f62b0 496
<> 128:9bcdf88f62b0 497 /** Test if function has been attached
<> 128:9bcdf88f62b0 498 */
<> 128:9bcdf88f62b0 499 operator bool() const {
<> 128:9bcdf88f62b0 500 return _ops;
<> 128:9bcdf88f62b0 501 }
<> 128:9bcdf88f62b0 502
<> 128:9bcdf88f62b0 503 /** Test for equality
<> 128:9bcdf88f62b0 504 */
<> 128:9bcdf88f62b0 505 friend bool operator==(const Callback &l, const Callback &r) {
<> 128:9bcdf88f62b0 506 return memcmp(&l, &r, sizeof(Callback)) == 0;
<> 128:9bcdf88f62b0 507 }
<> 128:9bcdf88f62b0 508
<> 128:9bcdf88f62b0 509 /** Test for inequality
<> 128:9bcdf88f62b0 510 */
<> 128:9bcdf88f62b0 511 friend bool operator!=(const Callback &l, const Callback &r) {
<> 128:9bcdf88f62b0 512 return !(l == r);
<> 128:9bcdf88f62b0 513 }
<> 128:9bcdf88f62b0 514
<> 128:9bcdf88f62b0 515 /** Static thunk for passing as C-style function
<> 128:9bcdf88f62b0 516 * @param func Callback to call passed as void pointer
<> 128:9bcdf88f62b0 517 */
<> 128:9bcdf88f62b0 518 static R thunk(void *func) {
<> 128:9bcdf88f62b0 519 return static_cast<Callback*>(func)->call();
<> 128:9bcdf88f62b0 520 }
<> 128:9bcdf88f62b0 521
<> 128:9bcdf88f62b0 522 private:
<> 128:9bcdf88f62b0 523 // Stored as pointer to function and pointer to optional object
<> 128:9bcdf88f62b0 524 // Function pointer is stored as union of possible function types
<> 128:9bcdf88f62b0 525 // to garuntee proper size and alignment
<> 128:9bcdf88f62b0 526 struct _class;
<> 128:9bcdf88f62b0 527 union {
<> 128:9bcdf88f62b0 528 void (*_staticfunc)();
<> 128:9bcdf88f62b0 529 void (*_boundfunc)(_class*);
<> 128:9bcdf88f62b0 530 void (_class::*_methodfunc)();
<> 128:9bcdf88f62b0 531 } _func;
<> 128:9bcdf88f62b0 532 void *_obj;
<> 128:9bcdf88f62b0 533
<> 128:9bcdf88f62b0 534 // Dynamically dispatched operations
<> 128:9bcdf88f62b0 535 const struct ops {
<> 128:9bcdf88f62b0 536 R (*call)(const void*);
<> 128:9bcdf88f62b0 537 void (*move)(void*, const void*);
<> 128:9bcdf88f62b0 538 void (*dtor)(void*);
<> 128:9bcdf88f62b0 539 } *_ops;
<> 128:9bcdf88f62b0 540
<> 128:9bcdf88f62b0 541 // Generate operations for function object
<> 128:9bcdf88f62b0 542 template <typename F>
<> 128:9bcdf88f62b0 543 void generate(const F &f) {
<> 128:9bcdf88f62b0 544 static const ops ops = {
<> 128:9bcdf88f62b0 545 &Callback::function_call<F>,
<> 128:9bcdf88f62b0 546 &Callback::function_move<F>,
<> 128:9bcdf88f62b0 547 &Callback::function_dtor<F>,
<> 128:9bcdf88f62b0 548 };
<> 128:9bcdf88f62b0 549
<> 130:d75b3fe1f5cb 550 MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F),
<> 130:d75b3fe1f5cb 551 "Type F must not exceed the size of the Callback class");
<> 128:9bcdf88f62b0 552 new (this) F(f);
<> 128:9bcdf88f62b0 553 _ops = &ops;
<> 128:9bcdf88f62b0 554 }
<> 128:9bcdf88f62b0 555
<> 128:9bcdf88f62b0 556 // Function attributes
<> 128:9bcdf88f62b0 557 template <typename F>
<> 128:9bcdf88f62b0 558 static R function_call(const void *p) {
<> 128:9bcdf88f62b0 559 return (*(F*)p)();
<> 128:9bcdf88f62b0 560 }
<> 128:9bcdf88f62b0 561
<> 128:9bcdf88f62b0 562 template <typename F>
<> 128:9bcdf88f62b0 563 static void function_move(void *d, const void *p) {
<> 128:9bcdf88f62b0 564 new (d) F(*(F*)p);
<> 128:9bcdf88f62b0 565 }
<> 128:9bcdf88f62b0 566
<> 128:9bcdf88f62b0 567 template <typename F>
<> 128:9bcdf88f62b0 568 static void function_dtor(void *p) {
<> 128:9bcdf88f62b0 569 ((F*)p)->~F();
<> 128:9bcdf88f62b0 570 }
<> 128:9bcdf88f62b0 571
<> 128:9bcdf88f62b0 572 // Wrappers for functions with context
<> 128:9bcdf88f62b0 573 template <typename O, typename M>
<> 128:9bcdf88f62b0 574 struct method_context {
<> 128:9bcdf88f62b0 575 M method;
<> 128:9bcdf88f62b0 576 O *obj;
<> 128:9bcdf88f62b0 577
<> 128:9bcdf88f62b0 578 method_context(O *obj, M method)
<> 128:9bcdf88f62b0 579 : method(method), obj(obj) {}
<> 128:9bcdf88f62b0 580
<> 128:9bcdf88f62b0 581 R operator()() const {
<> 128:9bcdf88f62b0 582 return (obj->*method)();
<> 128:9bcdf88f62b0 583 }
<> 128:9bcdf88f62b0 584 };
<> 128:9bcdf88f62b0 585
<> 128:9bcdf88f62b0 586 template <typename F, typename A>
<> 128:9bcdf88f62b0 587 struct function_context {
<> 128:9bcdf88f62b0 588 F func;
<> 128:9bcdf88f62b0 589 A *arg;
<> 128:9bcdf88f62b0 590
<> 128:9bcdf88f62b0 591 function_context(F func, A *arg)
<> 128:9bcdf88f62b0 592 : func(func), arg(arg) {}
<> 128:9bcdf88f62b0 593
<> 128:9bcdf88f62b0 594 R operator()() const {
<> 128:9bcdf88f62b0 595 return func(arg);
<> 128:9bcdf88f62b0 596 }
<> 128:9bcdf88f62b0 597 };
<> 128:9bcdf88f62b0 598 };
<> 128:9bcdf88f62b0 599
<> 128:9bcdf88f62b0 600 /** Callback class based on template specialization
<> 128:9bcdf88f62b0 601 *
<> 128:9bcdf88f62b0 602 * @Note Synchronization level: Not protected
<> 128:9bcdf88f62b0 603 */
<> 128:9bcdf88f62b0 604 template <typename R, typename A0>
<> 128:9bcdf88f62b0 605 class Callback<R(A0)> {
<> 128:9bcdf88f62b0 606 public:
<> 128:9bcdf88f62b0 607 /** Create a Callback with a static function
<> 128:9bcdf88f62b0 608 * @param func Static function to attach
<> 128:9bcdf88f62b0 609 */
<> 128:9bcdf88f62b0 610 Callback(R (*func)(A0) = 0) {
<> 128:9bcdf88f62b0 611 if (!func) {
<> 128:9bcdf88f62b0 612 _ops = 0;
<> 128:9bcdf88f62b0 613 } else {
<> 128:9bcdf88f62b0 614 generate(func);
<> 128:9bcdf88f62b0 615 }
<> 128:9bcdf88f62b0 616 }
<> 128:9bcdf88f62b0 617
<> 128:9bcdf88f62b0 618 /** Attach a Callback
<> 128:9bcdf88f62b0 619 * @param func The Callback to attach
<> 128:9bcdf88f62b0 620 */
<> 128:9bcdf88f62b0 621 Callback(const Callback<R(A0)> &func) {
<> 128:9bcdf88f62b0 622 if (func._ops) {
<> 128:9bcdf88f62b0 623 func._ops->move(this, &func);
<> 128:9bcdf88f62b0 624 }
<> 128:9bcdf88f62b0 625 _ops = func._ops;
<> 128:9bcdf88f62b0 626 }
<> 128:9bcdf88f62b0 627
<> 128:9bcdf88f62b0 628 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 629 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 630 * @param method Member function to attach
<> 128:9bcdf88f62b0 631 */
<> 130:d75b3fe1f5cb 632 template<typename T, typename U>
<> 130:d75b3fe1f5cb 633 Callback(U *obj, R (T::*method)(A0)) {
<> 128:9bcdf88f62b0 634 generate(method_context<T, R (T::*)(A0)>(obj, method));
<> 128:9bcdf88f62b0 635 }
<> 128:9bcdf88f62b0 636
<> 128:9bcdf88f62b0 637 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 638 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 639 * @param method Member function to attach
<> 128:9bcdf88f62b0 640 */
<> 130:d75b3fe1f5cb 641 template<typename T, typename U>
<> 130:d75b3fe1f5cb 642 Callback(const U *obj, R (T::*method)(A0) const) {
<> 128:9bcdf88f62b0 643 generate(method_context<const T, R (T::*)(A0) const>(obj, method));
<> 128:9bcdf88f62b0 644 }
<> 128:9bcdf88f62b0 645
<> 128:9bcdf88f62b0 646 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 647 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 648 * @param method Member function to attach
<> 128:9bcdf88f62b0 649 */
<> 130:d75b3fe1f5cb 650 template<typename T, typename U>
<> 130:d75b3fe1f5cb 651 Callback(volatile U *obj, R (T::*method)(A0) volatile) {
<> 128:9bcdf88f62b0 652 generate(method_context<volatile T, R (T::*)(A0) volatile>(obj, method));
<> 128:9bcdf88f62b0 653 }
<> 128:9bcdf88f62b0 654
<> 128:9bcdf88f62b0 655 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 656 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 657 * @param method Member function to attach
<> 128:9bcdf88f62b0 658 */
<> 130:d75b3fe1f5cb 659 template<typename T, typename U>
<> 130:d75b3fe1f5cb 660 Callback(const volatile U *obj, R (T::*method)(A0) const volatile) {
<> 128:9bcdf88f62b0 661 generate(method_context<const volatile T, R (T::*)(A0) const volatile>(obj, method));
<> 128:9bcdf88f62b0 662 }
<> 128:9bcdf88f62b0 663
<> 128:9bcdf88f62b0 664 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 665 * @param func Static function to attach
<> 128:9bcdf88f62b0 666 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 667 */
<> 130:d75b3fe1f5cb 668 template<typename T, typename U>
<> 130:d75b3fe1f5cb 669 Callback(R (*func)(T*, A0), U *arg) {
<> 128:9bcdf88f62b0 670 generate(function_context<R (*)(T*, A0), T>(func, arg));
<> 128:9bcdf88f62b0 671 }
<> 128:9bcdf88f62b0 672
<> 128:9bcdf88f62b0 673 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 674 * @param func Static function to attach
<> 128:9bcdf88f62b0 675 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 676 */
<> 130:d75b3fe1f5cb 677 template<typename T, typename U>
<> 130:d75b3fe1f5cb 678 Callback(R (*func)(const T*, A0), const U *arg) {
<> 128:9bcdf88f62b0 679 generate(function_context<R (*)(const T*, A0), const T>(func, arg));
<> 128:9bcdf88f62b0 680 }
<> 128:9bcdf88f62b0 681
<> 128:9bcdf88f62b0 682 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 683 * @param func Static function to attach
<> 128:9bcdf88f62b0 684 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 685 */
<> 130:d75b3fe1f5cb 686 template<typename T, typename U>
<> 130:d75b3fe1f5cb 687 Callback(R (*func)(volatile T*, A0), volatile U *arg) {
<> 128:9bcdf88f62b0 688 generate(function_context<R (*)(volatile T*, A0), volatile T>(func, arg));
<> 128:9bcdf88f62b0 689 }
<> 128:9bcdf88f62b0 690
<> 128:9bcdf88f62b0 691 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 692 * @param func Static function to attach
<> 128:9bcdf88f62b0 693 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 694 */
<> 130:d75b3fe1f5cb 695 template<typename T, typename U>
<> 130:d75b3fe1f5cb 696 Callback(R (*func)(const volatile T*, A0), const volatile U *arg) {
<> 128:9bcdf88f62b0 697 generate(function_context<R (*)(const volatile T*, A0), const volatile T>(func, arg));
<> 128:9bcdf88f62b0 698 }
<> 128:9bcdf88f62b0 699
<> 128:9bcdf88f62b0 700 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 701 * @param func Function object to attach
<> 128:9bcdf88f62b0 702 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 703 */
<> 128:9bcdf88f62b0 704 template <typename F>
<> 128:9bcdf88f62b0 705 Callback(F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 706 detail::is_type<R (F::*)(A0), &F::operator()>::value &&
<> 128:9bcdf88f62b0 707 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 708 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 709 generate(f);
<> 128:9bcdf88f62b0 710 }
<> 128:9bcdf88f62b0 711
<> 128:9bcdf88f62b0 712 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 713 * @param func Function object to attach
<> 128:9bcdf88f62b0 714 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 715 */
<> 128:9bcdf88f62b0 716 template <typename F>
<> 128:9bcdf88f62b0 717 Callback(const F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 718 detail::is_type<R (F::*)(A0) const, &F::operator()>::value &&
<> 128:9bcdf88f62b0 719 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 720 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 721 generate(f);
<> 128:9bcdf88f62b0 722 }
<> 128:9bcdf88f62b0 723
<> 128:9bcdf88f62b0 724 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 725 * @param func Function object to attach
<> 128:9bcdf88f62b0 726 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 727 */
<> 128:9bcdf88f62b0 728 template <typename F>
<> 128:9bcdf88f62b0 729 Callback(volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 730 detail::is_type<R (F::*)(A0) volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 731 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 732 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 733 generate(f);
<> 128:9bcdf88f62b0 734 }
<> 128:9bcdf88f62b0 735
<> 128:9bcdf88f62b0 736 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 737 * @param func Function object to attach
<> 128:9bcdf88f62b0 738 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 739 */
<> 128:9bcdf88f62b0 740 template <typename F>
<> 128:9bcdf88f62b0 741 Callback(const volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 742 detail::is_type<R (F::*)(A0) const volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 743 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 744 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 745 generate(f);
<> 128:9bcdf88f62b0 746 }
<> 128:9bcdf88f62b0 747
<> 128:9bcdf88f62b0 748 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 749 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 750 * @param func Static function to attach
<> 128:9bcdf88f62b0 751 * @deprecated
<> 128:9bcdf88f62b0 752 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 753 */
<> 130:d75b3fe1f5cb 754 template<typename T, typename U>
<> 128:9bcdf88f62b0 755 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 756 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 757 Callback(U *obj, R (*func)(T*, A0)) {
<> 128:9bcdf88f62b0 758 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 759 }
<> 128:9bcdf88f62b0 760
<> 128:9bcdf88f62b0 761 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 762 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 763 * @param func Static function to attach
<> 128:9bcdf88f62b0 764 * @deprecated
<> 128:9bcdf88f62b0 765 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 766 */
<> 130:d75b3fe1f5cb 767 template<typename T, typename U>
<> 128:9bcdf88f62b0 768 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 769 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 770 Callback(const U *obj, R (*func)(const T*, A0)) {
<> 128:9bcdf88f62b0 771 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 772 }
<> 128:9bcdf88f62b0 773
<> 128:9bcdf88f62b0 774 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 775 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 776 * @param func Static function to attach
<> 128:9bcdf88f62b0 777 * @deprecated
<> 128:9bcdf88f62b0 778 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 779 */
<> 130:d75b3fe1f5cb 780 template<typename T, typename U>
<> 128:9bcdf88f62b0 781 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 782 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 783 Callback(volatile U *obj, R (*func)(volatile T*, A0)) {
<> 128:9bcdf88f62b0 784 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 785 }
<> 128:9bcdf88f62b0 786
<> 128:9bcdf88f62b0 787 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 788 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 789 * @param func Static function to attach
<> 128:9bcdf88f62b0 790 * @deprecated
<> 128:9bcdf88f62b0 791 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 792 */
<> 130:d75b3fe1f5cb 793 template<typename T, typename U>
<> 128:9bcdf88f62b0 794 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 795 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 796 Callback(const volatile U *obj, R (*func)(const volatile T*, A0)) {
<> 128:9bcdf88f62b0 797 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 798 }
<> 128:9bcdf88f62b0 799
<> 128:9bcdf88f62b0 800 /** Destroy a callback
<> 128:9bcdf88f62b0 801 */
<> 128:9bcdf88f62b0 802 ~Callback() {
<> 128:9bcdf88f62b0 803 if (_ops) {
<> 128:9bcdf88f62b0 804 _ops->dtor(this);
<> 128:9bcdf88f62b0 805 }
<> 128:9bcdf88f62b0 806 }
<> 128:9bcdf88f62b0 807
<> 128:9bcdf88f62b0 808 /** Attach a static function
<> 128:9bcdf88f62b0 809 * @param func Static function to attach
<> 128:9bcdf88f62b0 810 */
<> 128:9bcdf88f62b0 811 void attach(R (*func)(A0)) {
<> 128:9bcdf88f62b0 812 this->~Callback();
<> 128:9bcdf88f62b0 813 new (this) Callback(func);
<> 128:9bcdf88f62b0 814 }
<> 128:9bcdf88f62b0 815
<> 128:9bcdf88f62b0 816 /** Attach a Callback
<> 128:9bcdf88f62b0 817 * @param func The Callback to attach
<> 128:9bcdf88f62b0 818 */
<> 128:9bcdf88f62b0 819 void attach(const Callback<R(A0)> &func) {
<> 128:9bcdf88f62b0 820 this->~Callback();
<> 128:9bcdf88f62b0 821 new (this) Callback(func);
<> 128:9bcdf88f62b0 822 }
<> 128:9bcdf88f62b0 823
<> 128:9bcdf88f62b0 824 /** Attach a member function
<> 128:9bcdf88f62b0 825 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 826 * @param method Member function to attach
<> 128:9bcdf88f62b0 827 */
<> 130:d75b3fe1f5cb 828 template<typename T, typename U>
<> 130:d75b3fe1f5cb 829 void attach(U *obj, R (T::*method)(A0)) {
<> 128:9bcdf88f62b0 830 this->~Callback();
<> 128:9bcdf88f62b0 831 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 832 }
<> 128:9bcdf88f62b0 833
<> 128:9bcdf88f62b0 834 /** Attach a member function
<> 128:9bcdf88f62b0 835 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 836 * @param method Member function to attach
<> 128:9bcdf88f62b0 837 */
<> 130:d75b3fe1f5cb 838 template<typename T, typename U>
<> 130:d75b3fe1f5cb 839 void attach(const U *obj, R (T::*method)(A0) const) {
<> 128:9bcdf88f62b0 840 this->~Callback();
<> 128:9bcdf88f62b0 841 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 842 }
<> 128:9bcdf88f62b0 843
<> 128:9bcdf88f62b0 844 /** Attach a member function
<> 128:9bcdf88f62b0 845 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 846 * @param method Member function to attach
<> 128:9bcdf88f62b0 847 */
<> 130:d75b3fe1f5cb 848 template<typename T, typename U>
<> 130:d75b3fe1f5cb 849 void attach(volatile U *obj, R (T::*method)(A0) volatile) {
<> 128:9bcdf88f62b0 850 this->~Callback();
<> 128:9bcdf88f62b0 851 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 852 }
<> 128:9bcdf88f62b0 853
<> 128:9bcdf88f62b0 854 /** Attach a member function
<> 128:9bcdf88f62b0 855 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 856 * @param method Member function to attach
<> 128:9bcdf88f62b0 857 */
<> 130:d75b3fe1f5cb 858 template<typename T, typename U>
<> 130:d75b3fe1f5cb 859 void attach(const volatile U *obj, R (T::*method)(A0) const volatile) {
<> 128:9bcdf88f62b0 860 this->~Callback();
<> 128:9bcdf88f62b0 861 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 862 }
<> 128:9bcdf88f62b0 863
<> 128:9bcdf88f62b0 864 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 865 * @param func Static function to attach
<> 128:9bcdf88f62b0 866 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 867 */
<> 130:d75b3fe1f5cb 868 template <typename T, typename U>
<> 130:d75b3fe1f5cb 869 void attach(R (*func)(T*, A0), U *arg) {
<> 128:9bcdf88f62b0 870 this->~Callback();
<> 128:9bcdf88f62b0 871 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 872 }
<> 128:9bcdf88f62b0 873
<> 128:9bcdf88f62b0 874 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 875 * @param func Static function to attach
<> 128:9bcdf88f62b0 876 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 877 */
<> 130:d75b3fe1f5cb 878 template <typename T, typename U>
<> 130:d75b3fe1f5cb 879 void attach(R (*func)(const T*, A0), const U *arg) {
<> 128:9bcdf88f62b0 880 this->~Callback();
<> 128:9bcdf88f62b0 881 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 882 }
<> 128:9bcdf88f62b0 883
<> 128:9bcdf88f62b0 884 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 885 * @param func Static function to attach
<> 128:9bcdf88f62b0 886 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 887 */
<> 130:d75b3fe1f5cb 888 template <typename T, typename U>
<> 130:d75b3fe1f5cb 889 void attach(R (*func)(volatile T*, A0), volatile U *arg) {
<> 128:9bcdf88f62b0 890 this->~Callback();
<> 128:9bcdf88f62b0 891 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 892 }
<> 128:9bcdf88f62b0 893
<> 128:9bcdf88f62b0 894 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 895 * @param func Static function to attach
<> 128:9bcdf88f62b0 896 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 897 */
<> 130:d75b3fe1f5cb 898 template <typename T, typename U>
<> 130:d75b3fe1f5cb 899 void attach(R (*func)(const volatile T*, A0), const volatile U *arg) {
<> 128:9bcdf88f62b0 900 this->~Callback();
<> 128:9bcdf88f62b0 901 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 902 }
<> 128:9bcdf88f62b0 903
<> 128:9bcdf88f62b0 904 /** Attach a function object
<> 128:9bcdf88f62b0 905 * @param func Function object to attach
<> 128:9bcdf88f62b0 906 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 907 */
<> 128:9bcdf88f62b0 908 template <typename F>
<> 128:9bcdf88f62b0 909 void attach(F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 910 detail::is_type<R (F::*)(A0), &F::operator()>::value &&
<> 128:9bcdf88f62b0 911 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 912 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 913 this->~Callback();
<> 128:9bcdf88f62b0 914 new (this) Callback(f);
<> 128:9bcdf88f62b0 915 }
<> 128:9bcdf88f62b0 916
<> 128:9bcdf88f62b0 917 /** Attach a function object
<> 128:9bcdf88f62b0 918 * @param func Function object to attach
<> 128:9bcdf88f62b0 919 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 920 */
<> 128:9bcdf88f62b0 921 template <typename F>
<> 128:9bcdf88f62b0 922 void attach(const F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 923 detail::is_type<R (F::*)(A0) const, &F::operator()>::value &&
<> 128:9bcdf88f62b0 924 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 925 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 926 this->~Callback();
<> 128:9bcdf88f62b0 927 new (this) Callback(f);
<> 128:9bcdf88f62b0 928 }
<> 128:9bcdf88f62b0 929
<> 128:9bcdf88f62b0 930 /** Attach a function object
<> 128:9bcdf88f62b0 931 * @param func Function object to attach
<> 128:9bcdf88f62b0 932 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 933 */
<> 128:9bcdf88f62b0 934 template <typename F>
<> 128:9bcdf88f62b0 935 void attach(volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 936 detail::is_type<R (F::*)(A0) volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 937 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 938 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 939 this->~Callback();
<> 128:9bcdf88f62b0 940 new (this) Callback(f);
<> 128:9bcdf88f62b0 941 }
<> 128:9bcdf88f62b0 942
<> 128:9bcdf88f62b0 943 /** Attach a function object
<> 128:9bcdf88f62b0 944 * @param func Function object to attach
<> 128:9bcdf88f62b0 945 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 946 */
<> 128:9bcdf88f62b0 947 template <typename F>
<> 128:9bcdf88f62b0 948 void attach(const volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 949 detail::is_type<R (F::*)(A0) const volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 950 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 951 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 952 this->~Callback();
<> 128:9bcdf88f62b0 953 new (this) Callback(f);
<> 128:9bcdf88f62b0 954 }
<> 128:9bcdf88f62b0 955
<> 128:9bcdf88f62b0 956 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 957 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 958 * @param func Static function to attach
<> 128:9bcdf88f62b0 959 * @deprecated
<> 128:9bcdf88f62b0 960 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 961 */
<> 130:d75b3fe1f5cb 962 template <typename T, typename U>
<> 128:9bcdf88f62b0 963 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 964 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 965 void attach(U *obj, R (*func)(T*, A0)) {
<> 128:9bcdf88f62b0 966 this->~Callback();
<> 128:9bcdf88f62b0 967 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 968 }
<> 128:9bcdf88f62b0 969
<> 128:9bcdf88f62b0 970 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 971 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 972 * @param func Static function to attach
<> 128:9bcdf88f62b0 973 * @deprecated
<> 128:9bcdf88f62b0 974 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 975 */
<> 130:d75b3fe1f5cb 976 template <typename T, typename U>
<> 128:9bcdf88f62b0 977 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 978 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 979 void attach(const U *obj, R (*func)(const T*, A0)) {
<> 128:9bcdf88f62b0 980 this->~Callback();
<> 128:9bcdf88f62b0 981 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 982 }
<> 128:9bcdf88f62b0 983
<> 128:9bcdf88f62b0 984 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 985 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 986 * @param func Static function to attach
<> 128:9bcdf88f62b0 987 * @deprecated
<> 128:9bcdf88f62b0 988 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 989 */
<> 130:d75b3fe1f5cb 990 template <typename T, typename U>
<> 128:9bcdf88f62b0 991 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 992 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 993 void attach(volatile U *obj, R (*func)(volatile T*, A0)) {
<> 128:9bcdf88f62b0 994 this->~Callback();
<> 128:9bcdf88f62b0 995 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 996 }
<> 128:9bcdf88f62b0 997
<> 128:9bcdf88f62b0 998 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 999 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1000 * @param func Static function to attach
<> 128:9bcdf88f62b0 1001 * @deprecated
<> 128:9bcdf88f62b0 1002 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 1003 */
<> 130:d75b3fe1f5cb 1004 template <typename T, typename U>
<> 128:9bcdf88f62b0 1005 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1006 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 1007 void attach(const volatile U *obj, R (*func)(const volatile T*, A0)) {
<> 128:9bcdf88f62b0 1008 this->~Callback();
<> 128:9bcdf88f62b0 1009 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1010 }
<> 128:9bcdf88f62b0 1011
<> 128:9bcdf88f62b0 1012 /** Assign a callback
<> 128:9bcdf88f62b0 1013 */
<> 128:9bcdf88f62b0 1014 Callback &operator=(const Callback &that) {
<> 128:9bcdf88f62b0 1015 if (this != &that) {
<> 128:9bcdf88f62b0 1016 this->~Callback();
<> 128:9bcdf88f62b0 1017 new (this) Callback(that);
<> 128:9bcdf88f62b0 1018 }
<> 128:9bcdf88f62b0 1019
<> 128:9bcdf88f62b0 1020 return *this;
<> 128:9bcdf88f62b0 1021 }
<> 128:9bcdf88f62b0 1022
<> 128:9bcdf88f62b0 1023 /** Call the attached function
<> 128:9bcdf88f62b0 1024 */
<> 128:9bcdf88f62b0 1025 R call(A0 a0) const {
<> 128:9bcdf88f62b0 1026 MBED_ASSERT(_ops);
<> 128:9bcdf88f62b0 1027 return _ops->call(this, a0);
<> 128:9bcdf88f62b0 1028 }
<> 128:9bcdf88f62b0 1029
<> 128:9bcdf88f62b0 1030 /** Call the attached function
<> 128:9bcdf88f62b0 1031 */
<> 128:9bcdf88f62b0 1032 R operator()(A0 a0) const {
<> 128:9bcdf88f62b0 1033 return call(a0);
<> 128:9bcdf88f62b0 1034 }
<> 128:9bcdf88f62b0 1035
<> 128:9bcdf88f62b0 1036 /** Test if function has been attached
<> 128:9bcdf88f62b0 1037 */
<> 128:9bcdf88f62b0 1038 operator bool() const {
<> 128:9bcdf88f62b0 1039 return _ops;
<> 128:9bcdf88f62b0 1040 }
<> 128:9bcdf88f62b0 1041
<> 128:9bcdf88f62b0 1042 /** Test for equality
<> 128:9bcdf88f62b0 1043 */
<> 128:9bcdf88f62b0 1044 friend bool operator==(const Callback &l, const Callback &r) {
<> 128:9bcdf88f62b0 1045 return memcmp(&l, &r, sizeof(Callback)) == 0;
<> 128:9bcdf88f62b0 1046 }
<> 128:9bcdf88f62b0 1047
<> 128:9bcdf88f62b0 1048 /** Test for inequality
<> 128:9bcdf88f62b0 1049 */
<> 128:9bcdf88f62b0 1050 friend bool operator!=(const Callback &l, const Callback &r) {
<> 128:9bcdf88f62b0 1051 return !(l == r);
<> 128:9bcdf88f62b0 1052 }
<> 128:9bcdf88f62b0 1053
<> 128:9bcdf88f62b0 1054 /** Static thunk for passing as C-style function
<> 128:9bcdf88f62b0 1055 * @param func Callback to call passed as void pointer
<> 128:9bcdf88f62b0 1056 */
<> 128:9bcdf88f62b0 1057 static R thunk(void *func, A0 a0) {
<> 128:9bcdf88f62b0 1058 return static_cast<Callback*>(func)->call(a0);
<> 128:9bcdf88f62b0 1059 }
<> 128:9bcdf88f62b0 1060
<> 128:9bcdf88f62b0 1061 private:
<> 128:9bcdf88f62b0 1062 // Stored as pointer to function and pointer to optional object
<> 128:9bcdf88f62b0 1063 // Function pointer is stored as union of possible function types
<> 128:9bcdf88f62b0 1064 // to garuntee proper size and alignment
<> 128:9bcdf88f62b0 1065 struct _class;
<> 128:9bcdf88f62b0 1066 union {
<> 128:9bcdf88f62b0 1067 void (*_staticfunc)(A0);
<> 128:9bcdf88f62b0 1068 void (*_boundfunc)(_class*, A0);
<> 128:9bcdf88f62b0 1069 void (_class::*_methodfunc)(A0);
<> 128:9bcdf88f62b0 1070 } _func;
<> 128:9bcdf88f62b0 1071 void *_obj;
<> 128:9bcdf88f62b0 1072
<> 128:9bcdf88f62b0 1073 // Dynamically dispatched operations
<> 128:9bcdf88f62b0 1074 const struct ops {
<> 128:9bcdf88f62b0 1075 R (*call)(const void*, A0);
<> 128:9bcdf88f62b0 1076 void (*move)(void*, const void*);
<> 128:9bcdf88f62b0 1077 void (*dtor)(void*);
<> 128:9bcdf88f62b0 1078 } *_ops;
<> 128:9bcdf88f62b0 1079
<> 128:9bcdf88f62b0 1080 // Generate operations for function object
<> 128:9bcdf88f62b0 1081 template <typename F>
<> 128:9bcdf88f62b0 1082 void generate(const F &f) {
<> 128:9bcdf88f62b0 1083 static const ops ops = {
<> 128:9bcdf88f62b0 1084 &Callback::function_call<F>,
<> 128:9bcdf88f62b0 1085 &Callback::function_move<F>,
<> 128:9bcdf88f62b0 1086 &Callback::function_dtor<F>,
<> 128:9bcdf88f62b0 1087 };
<> 128:9bcdf88f62b0 1088
<> 130:d75b3fe1f5cb 1089 MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F),
<> 130:d75b3fe1f5cb 1090 "Type F must not exceed the size of the Callback class");
<> 128:9bcdf88f62b0 1091 new (this) F(f);
<> 128:9bcdf88f62b0 1092 _ops = &ops;
<> 128:9bcdf88f62b0 1093 }
<> 128:9bcdf88f62b0 1094
<> 128:9bcdf88f62b0 1095 // Function attributes
<> 128:9bcdf88f62b0 1096 template <typename F>
<> 128:9bcdf88f62b0 1097 static R function_call(const void *p, A0 a0) {
<> 128:9bcdf88f62b0 1098 return (*(F*)p)(a0);
<> 128:9bcdf88f62b0 1099 }
<> 128:9bcdf88f62b0 1100
<> 128:9bcdf88f62b0 1101 template <typename F>
<> 128:9bcdf88f62b0 1102 static void function_move(void *d, const void *p) {
<> 128:9bcdf88f62b0 1103 new (d) F(*(F*)p);
<> 128:9bcdf88f62b0 1104 }
<> 128:9bcdf88f62b0 1105
<> 128:9bcdf88f62b0 1106 template <typename F>
<> 128:9bcdf88f62b0 1107 static void function_dtor(void *p) {
<> 128:9bcdf88f62b0 1108 ((F*)p)->~F();
<> 128:9bcdf88f62b0 1109 }
<> 128:9bcdf88f62b0 1110
<> 128:9bcdf88f62b0 1111 // Wrappers for functions with context
<> 128:9bcdf88f62b0 1112 template <typename O, typename M>
<> 128:9bcdf88f62b0 1113 struct method_context {
<> 128:9bcdf88f62b0 1114 M method;
<> 128:9bcdf88f62b0 1115 O *obj;
<> 128:9bcdf88f62b0 1116
<> 128:9bcdf88f62b0 1117 method_context(O *obj, M method)
<> 128:9bcdf88f62b0 1118 : method(method), obj(obj) {}
<> 128:9bcdf88f62b0 1119
<> 128:9bcdf88f62b0 1120 R operator()(A0 a0) const {
<> 128:9bcdf88f62b0 1121 return (obj->*method)(a0);
<> 128:9bcdf88f62b0 1122 }
<> 128:9bcdf88f62b0 1123 };
<> 128:9bcdf88f62b0 1124
<> 128:9bcdf88f62b0 1125 template <typename F, typename A>
<> 128:9bcdf88f62b0 1126 struct function_context {
<> 128:9bcdf88f62b0 1127 F func;
<> 128:9bcdf88f62b0 1128 A *arg;
<> 128:9bcdf88f62b0 1129
<> 128:9bcdf88f62b0 1130 function_context(F func, A *arg)
<> 128:9bcdf88f62b0 1131 : func(func), arg(arg) {}
<> 128:9bcdf88f62b0 1132
<> 128:9bcdf88f62b0 1133 R operator()(A0 a0) const {
<> 128:9bcdf88f62b0 1134 return func(arg, a0);
<> 128:9bcdf88f62b0 1135 }
<> 128:9bcdf88f62b0 1136 };
<> 128:9bcdf88f62b0 1137 };
<> 128:9bcdf88f62b0 1138
<> 128:9bcdf88f62b0 1139 /** Callback class based on template specialization
<> 128:9bcdf88f62b0 1140 *
<> 128:9bcdf88f62b0 1141 * @Note Synchronization level: Not protected
<> 128:9bcdf88f62b0 1142 */
<> 128:9bcdf88f62b0 1143 template <typename R, typename A0, typename A1>
<> 128:9bcdf88f62b0 1144 class Callback<R(A0, A1)> {
<> 128:9bcdf88f62b0 1145 public:
<> 128:9bcdf88f62b0 1146 /** Create a Callback with a static function
<> 128:9bcdf88f62b0 1147 * @param func Static function to attach
<> 128:9bcdf88f62b0 1148 */
<> 128:9bcdf88f62b0 1149 Callback(R (*func)(A0, A1) = 0) {
<> 128:9bcdf88f62b0 1150 if (!func) {
<> 128:9bcdf88f62b0 1151 _ops = 0;
<> 128:9bcdf88f62b0 1152 } else {
<> 128:9bcdf88f62b0 1153 generate(func);
<> 128:9bcdf88f62b0 1154 }
<> 128:9bcdf88f62b0 1155 }
<> 128:9bcdf88f62b0 1156
<> 128:9bcdf88f62b0 1157 /** Attach a Callback
<> 128:9bcdf88f62b0 1158 * @param func The Callback to attach
<> 128:9bcdf88f62b0 1159 */
<> 128:9bcdf88f62b0 1160 Callback(const Callback<R(A0, A1)> &func) {
<> 128:9bcdf88f62b0 1161 if (func._ops) {
<> 128:9bcdf88f62b0 1162 func._ops->move(this, &func);
<> 128:9bcdf88f62b0 1163 }
<> 128:9bcdf88f62b0 1164 _ops = func._ops;
<> 128:9bcdf88f62b0 1165 }
<> 128:9bcdf88f62b0 1166
<> 128:9bcdf88f62b0 1167 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 1168 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1169 * @param method Member function to attach
<> 128:9bcdf88f62b0 1170 */
<> 130:d75b3fe1f5cb 1171 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1172 Callback(U *obj, R (T::*method)(A0, A1)) {
<> 128:9bcdf88f62b0 1173 generate(method_context<T, R (T::*)(A0, A1)>(obj, method));
<> 128:9bcdf88f62b0 1174 }
<> 128:9bcdf88f62b0 1175
<> 128:9bcdf88f62b0 1176 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 1177 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1178 * @param method Member function to attach
<> 128:9bcdf88f62b0 1179 */
<> 130:d75b3fe1f5cb 1180 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1181 Callback(const U *obj, R (T::*method)(A0, A1) const) {
<> 128:9bcdf88f62b0 1182 generate(method_context<const T, R (T::*)(A0, A1) const>(obj, method));
<> 128:9bcdf88f62b0 1183 }
<> 128:9bcdf88f62b0 1184
<> 128:9bcdf88f62b0 1185 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 1186 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1187 * @param method Member function to attach
<> 128:9bcdf88f62b0 1188 */
<> 130:d75b3fe1f5cb 1189 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1190 Callback(volatile U *obj, R (T::*method)(A0, A1) volatile) {
<> 128:9bcdf88f62b0 1191 generate(method_context<volatile T, R (T::*)(A0, A1) volatile>(obj, method));
<> 128:9bcdf88f62b0 1192 }
<> 128:9bcdf88f62b0 1193
<> 128:9bcdf88f62b0 1194 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 1195 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1196 * @param method Member function to attach
<> 128:9bcdf88f62b0 1197 */
<> 130:d75b3fe1f5cb 1198 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1199 Callback(const volatile U *obj, R (T::*method)(A0, A1) const volatile) {
<> 128:9bcdf88f62b0 1200 generate(method_context<const volatile T, R (T::*)(A0, A1) const volatile>(obj, method));
<> 128:9bcdf88f62b0 1201 }
<> 128:9bcdf88f62b0 1202
<> 128:9bcdf88f62b0 1203 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1204 * @param func Static function to attach
<> 128:9bcdf88f62b0 1205 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1206 */
<> 130:d75b3fe1f5cb 1207 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1208 Callback(R (*func)(T*, A0, A1), U *arg) {
<> 128:9bcdf88f62b0 1209 generate(function_context<R (*)(T*, A0, A1), T>(func, arg));
<> 128:9bcdf88f62b0 1210 }
<> 128:9bcdf88f62b0 1211
<> 128:9bcdf88f62b0 1212 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1213 * @param func Static function to attach
<> 128:9bcdf88f62b0 1214 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1215 */
<> 130:d75b3fe1f5cb 1216 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1217 Callback(R (*func)(const T*, A0, A1), const U *arg) {
<> 128:9bcdf88f62b0 1218 generate(function_context<R (*)(const T*, A0, A1), const T>(func, arg));
<> 128:9bcdf88f62b0 1219 }
<> 128:9bcdf88f62b0 1220
<> 128:9bcdf88f62b0 1221 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1222 * @param func Static function to attach
<> 128:9bcdf88f62b0 1223 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1224 */
<> 130:d75b3fe1f5cb 1225 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1226 Callback(R (*func)(volatile T*, A0, A1), volatile U *arg) {
<> 128:9bcdf88f62b0 1227 generate(function_context<R (*)(volatile T*, A0, A1), volatile T>(func, arg));
<> 128:9bcdf88f62b0 1228 }
<> 128:9bcdf88f62b0 1229
<> 128:9bcdf88f62b0 1230 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1231 * @param func Static function to attach
<> 128:9bcdf88f62b0 1232 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1233 */
<> 130:d75b3fe1f5cb 1234 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1235 Callback(R (*func)(const volatile T*, A0, A1), const volatile U *arg) {
<> 128:9bcdf88f62b0 1236 generate(function_context<R (*)(const volatile T*, A0, A1), const volatile T>(func, arg));
<> 128:9bcdf88f62b0 1237 }
<> 128:9bcdf88f62b0 1238
<> 128:9bcdf88f62b0 1239 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 1240 * @param func Function object to attach
<> 128:9bcdf88f62b0 1241 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1242 */
<> 128:9bcdf88f62b0 1243 template <typename F>
<> 128:9bcdf88f62b0 1244 Callback(F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1245 detail::is_type<R (F::*)(A0, A1), &F::operator()>::value &&
<> 128:9bcdf88f62b0 1246 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1247 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1248 generate(f);
<> 128:9bcdf88f62b0 1249 }
<> 128:9bcdf88f62b0 1250
<> 128:9bcdf88f62b0 1251 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 1252 * @param func Function object to attach
<> 128:9bcdf88f62b0 1253 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1254 */
<> 128:9bcdf88f62b0 1255 template <typename F>
<> 128:9bcdf88f62b0 1256 Callback(const F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1257 detail::is_type<R (F::*)(A0, A1) const, &F::operator()>::value &&
<> 128:9bcdf88f62b0 1258 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1259 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1260 generate(f);
<> 128:9bcdf88f62b0 1261 }
<> 128:9bcdf88f62b0 1262
<> 128:9bcdf88f62b0 1263 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 1264 * @param func Function object to attach
<> 128:9bcdf88f62b0 1265 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1266 */
<> 128:9bcdf88f62b0 1267 template <typename F>
<> 128:9bcdf88f62b0 1268 Callback(volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1269 detail::is_type<R (F::*)(A0, A1) volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 1270 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1271 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1272 generate(f);
<> 128:9bcdf88f62b0 1273 }
<> 128:9bcdf88f62b0 1274
<> 128:9bcdf88f62b0 1275 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 1276 * @param func Function object to attach
<> 128:9bcdf88f62b0 1277 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1278 */
<> 128:9bcdf88f62b0 1279 template <typename F>
<> 128:9bcdf88f62b0 1280 Callback(const volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1281 detail::is_type<R (F::*)(A0, A1) const volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 1282 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1283 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1284 generate(f);
<> 128:9bcdf88f62b0 1285 }
<> 128:9bcdf88f62b0 1286
<> 128:9bcdf88f62b0 1287 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1288 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1289 * @param func Static function to attach
<> 128:9bcdf88f62b0 1290 * @deprecated
<> 128:9bcdf88f62b0 1291 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 1292 */
<> 130:d75b3fe1f5cb 1293 template<typename T, typename U>
<> 128:9bcdf88f62b0 1294 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1295 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 1296 Callback(U *obj, R (*func)(T*, A0, A1)) {
<> 128:9bcdf88f62b0 1297 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1298 }
<> 128:9bcdf88f62b0 1299
<> 128:9bcdf88f62b0 1300 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1301 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1302 * @param func Static function to attach
<> 128:9bcdf88f62b0 1303 * @deprecated
<> 128:9bcdf88f62b0 1304 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 1305 */
<> 130:d75b3fe1f5cb 1306 template<typename T, typename U>
<> 128:9bcdf88f62b0 1307 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1308 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 1309 Callback(const U *obj, R (*func)(const T*, A0, A1)) {
<> 128:9bcdf88f62b0 1310 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1311 }
<> 128:9bcdf88f62b0 1312
<> 128:9bcdf88f62b0 1313 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1314 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1315 * @param func Static function to attach
<> 128:9bcdf88f62b0 1316 * @deprecated
<> 128:9bcdf88f62b0 1317 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 1318 */
<> 130:d75b3fe1f5cb 1319 template<typename T, typename U>
<> 128:9bcdf88f62b0 1320 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1321 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 1322 Callback(volatile U *obj, R (*func)(volatile T*, A0, A1)) {
<> 128:9bcdf88f62b0 1323 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1324 }
<> 128:9bcdf88f62b0 1325
<> 128:9bcdf88f62b0 1326 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1327 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1328 * @param func Static function to attach
<> 128:9bcdf88f62b0 1329 * @deprecated
<> 128:9bcdf88f62b0 1330 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 1331 */
<> 130:d75b3fe1f5cb 1332 template<typename T, typename U>
<> 128:9bcdf88f62b0 1333 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1334 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 1335 Callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1)) {
<> 128:9bcdf88f62b0 1336 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1337 }
<> 128:9bcdf88f62b0 1338
<> 128:9bcdf88f62b0 1339 /** Destroy a callback
<> 128:9bcdf88f62b0 1340 */
<> 128:9bcdf88f62b0 1341 ~Callback() {
<> 128:9bcdf88f62b0 1342 if (_ops) {
<> 128:9bcdf88f62b0 1343 _ops->dtor(this);
<> 128:9bcdf88f62b0 1344 }
<> 128:9bcdf88f62b0 1345 }
<> 128:9bcdf88f62b0 1346
<> 128:9bcdf88f62b0 1347 /** Attach a static function
<> 128:9bcdf88f62b0 1348 * @param func Static function to attach
<> 128:9bcdf88f62b0 1349 */
<> 128:9bcdf88f62b0 1350 void attach(R (*func)(A0, A1)) {
<> 128:9bcdf88f62b0 1351 this->~Callback();
<> 128:9bcdf88f62b0 1352 new (this) Callback(func);
<> 128:9bcdf88f62b0 1353 }
<> 128:9bcdf88f62b0 1354
<> 128:9bcdf88f62b0 1355 /** Attach a Callback
<> 128:9bcdf88f62b0 1356 * @param func The Callback to attach
<> 128:9bcdf88f62b0 1357 */
<> 128:9bcdf88f62b0 1358 void attach(const Callback<R(A0, A1)> &func) {
<> 128:9bcdf88f62b0 1359 this->~Callback();
<> 128:9bcdf88f62b0 1360 new (this) Callback(func);
<> 128:9bcdf88f62b0 1361 }
<> 128:9bcdf88f62b0 1362
<> 128:9bcdf88f62b0 1363 /** Attach a member function
<> 128:9bcdf88f62b0 1364 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1365 * @param method Member function to attach
<> 128:9bcdf88f62b0 1366 */
<> 130:d75b3fe1f5cb 1367 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1368 void attach(U *obj, R (T::*method)(A0, A1)) {
<> 128:9bcdf88f62b0 1369 this->~Callback();
<> 128:9bcdf88f62b0 1370 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 1371 }
<> 128:9bcdf88f62b0 1372
<> 128:9bcdf88f62b0 1373 /** Attach a member function
<> 128:9bcdf88f62b0 1374 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1375 * @param method Member function to attach
<> 128:9bcdf88f62b0 1376 */
<> 130:d75b3fe1f5cb 1377 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1378 void attach(const U *obj, R (T::*method)(A0, A1) const) {
<> 128:9bcdf88f62b0 1379 this->~Callback();
<> 128:9bcdf88f62b0 1380 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 1381 }
<> 128:9bcdf88f62b0 1382
<> 128:9bcdf88f62b0 1383 /** Attach a member function
<> 128:9bcdf88f62b0 1384 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1385 * @param method Member function to attach
<> 128:9bcdf88f62b0 1386 */
<> 130:d75b3fe1f5cb 1387 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1388 void attach(volatile U *obj, R (T::*method)(A0, A1) volatile) {
<> 128:9bcdf88f62b0 1389 this->~Callback();
<> 128:9bcdf88f62b0 1390 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 1391 }
<> 128:9bcdf88f62b0 1392
<> 128:9bcdf88f62b0 1393 /** Attach a member function
<> 128:9bcdf88f62b0 1394 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1395 * @param method Member function to attach
<> 128:9bcdf88f62b0 1396 */
<> 130:d75b3fe1f5cb 1397 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1398 void attach(const volatile U *obj, R (T::*method)(A0, A1) const volatile) {
<> 128:9bcdf88f62b0 1399 this->~Callback();
<> 128:9bcdf88f62b0 1400 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 1401 }
<> 128:9bcdf88f62b0 1402
<> 128:9bcdf88f62b0 1403 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 1404 * @param func Static function to attach
<> 128:9bcdf88f62b0 1405 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1406 */
<> 130:d75b3fe1f5cb 1407 template <typename T, typename U>
<> 130:d75b3fe1f5cb 1408 void attach(R (*func)(T*, A0, A1), U *arg) {
<> 128:9bcdf88f62b0 1409 this->~Callback();
<> 128:9bcdf88f62b0 1410 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 1411 }
<> 128:9bcdf88f62b0 1412
<> 128:9bcdf88f62b0 1413 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 1414 * @param func Static function to attach
<> 128:9bcdf88f62b0 1415 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1416 */
<> 130:d75b3fe1f5cb 1417 template <typename T, typename U>
<> 130:d75b3fe1f5cb 1418 void attach(R (*func)(const T*, A0, A1), const U *arg) {
<> 128:9bcdf88f62b0 1419 this->~Callback();
<> 128:9bcdf88f62b0 1420 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 1421 }
<> 128:9bcdf88f62b0 1422
<> 128:9bcdf88f62b0 1423 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 1424 * @param func Static function to attach
<> 128:9bcdf88f62b0 1425 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1426 */
<> 130:d75b3fe1f5cb 1427 template <typename T, typename U>
<> 130:d75b3fe1f5cb 1428 void attach(R (*func)(volatile T*, A0, A1), volatile U *arg) {
<> 128:9bcdf88f62b0 1429 this->~Callback();
<> 128:9bcdf88f62b0 1430 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 1431 }
<> 128:9bcdf88f62b0 1432
<> 128:9bcdf88f62b0 1433 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 1434 * @param func Static function to attach
<> 128:9bcdf88f62b0 1435 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1436 */
<> 130:d75b3fe1f5cb 1437 template <typename T, typename U>
<> 130:d75b3fe1f5cb 1438 void attach(R (*func)(const volatile T*, A0, A1), const volatile U *arg) {
<> 128:9bcdf88f62b0 1439 this->~Callback();
<> 128:9bcdf88f62b0 1440 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 1441 }
<> 128:9bcdf88f62b0 1442
<> 128:9bcdf88f62b0 1443 /** Attach a function object
<> 128:9bcdf88f62b0 1444 * @param func Function object to attach
<> 128:9bcdf88f62b0 1445 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1446 */
<> 128:9bcdf88f62b0 1447 template <typename F>
<> 128:9bcdf88f62b0 1448 void attach(F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1449 detail::is_type<R (F::*)(A0, A1), &F::operator()>::value &&
<> 128:9bcdf88f62b0 1450 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1451 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1452 this->~Callback();
<> 128:9bcdf88f62b0 1453 new (this) Callback(f);
<> 128:9bcdf88f62b0 1454 }
<> 128:9bcdf88f62b0 1455
<> 128:9bcdf88f62b0 1456 /** Attach a function object
<> 128:9bcdf88f62b0 1457 * @param func Function object to attach
<> 128:9bcdf88f62b0 1458 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1459 */
<> 128:9bcdf88f62b0 1460 template <typename F>
<> 128:9bcdf88f62b0 1461 void attach(const F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1462 detail::is_type<R (F::*)(A0, A1) const, &F::operator()>::value &&
<> 128:9bcdf88f62b0 1463 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1464 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1465 this->~Callback();
<> 128:9bcdf88f62b0 1466 new (this) Callback(f);
<> 128:9bcdf88f62b0 1467 }
<> 128:9bcdf88f62b0 1468
<> 128:9bcdf88f62b0 1469 /** Attach a function object
<> 128:9bcdf88f62b0 1470 * @param func Function object to attach
<> 128:9bcdf88f62b0 1471 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1472 */
<> 128:9bcdf88f62b0 1473 template <typename F>
<> 128:9bcdf88f62b0 1474 void attach(volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1475 detail::is_type<R (F::*)(A0, A1) volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 1476 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1477 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1478 this->~Callback();
<> 128:9bcdf88f62b0 1479 new (this) Callback(f);
<> 128:9bcdf88f62b0 1480 }
<> 128:9bcdf88f62b0 1481
<> 128:9bcdf88f62b0 1482 /** Attach a function object
<> 128:9bcdf88f62b0 1483 * @param func Function object to attach
<> 128:9bcdf88f62b0 1484 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1485 */
<> 128:9bcdf88f62b0 1486 template <typename F>
<> 128:9bcdf88f62b0 1487 void attach(const volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1488 detail::is_type<R (F::*)(A0, A1) const volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 1489 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1490 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1491 this->~Callback();
<> 128:9bcdf88f62b0 1492 new (this) Callback(f);
<> 128:9bcdf88f62b0 1493 }
<> 128:9bcdf88f62b0 1494
<> 128:9bcdf88f62b0 1495 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 1496 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1497 * @param func Static function to attach
<> 128:9bcdf88f62b0 1498 * @deprecated
<> 128:9bcdf88f62b0 1499 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 1500 */
<> 130:d75b3fe1f5cb 1501 template <typename T, typename U>
<> 128:9bcdf88f62b0 1502 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1503 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 1504 void attach(U *obj, R (*func)(T*, A0, A1)) {
<> 128:9bcdf88f62b0 1505 this->~Callback();
<> 128:9bcdf88f62b0 1506 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1507 }
<> 128:9bcdf88f62b0 1508
<> 128:9bcdf88f62b0 1509 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 1510 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1511 * @param func Static function to attach
<> 128:9bcdf88f62b0 1512 * @deprecated
<> 128:9bcdf88f62b0 1513 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 1514 */
<> 130:d75b3fe1f5cb 1515 template <typename T, typename U>
<> 128:9bcdf88f62b0 1516 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1517 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 1518 void attach(const U *obj, R (*func)(const T*, A0, A1)) {
<> 128:9bcdf88f62b0 1519 this->~Callback();
<> 128:9bcdf88f62b0 1520 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1521 }
<> 128:9bcdf88f62b0 1522
<> 128:9bcdf88f62b0 1523 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 1524 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1525 * @param func Static function to attach
<> 128:9bcdf88f62b0 1526 * @deprecated
<> 128:9bcdf88f62b0 1527 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 1528 */
<> 130:d75b3fe1f5cb 1529 template <typename T, typename U>
<> 128:9bcdf88f62b0 1530 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1531 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 1532 void attach(volatile U *obj, R (*func)(volatile T*, A0, A1)) {
<> 128:9bcdf88f62b0 1533 this->~Callback();
<> 128:9bcdf88f62b0 1534 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1535 }
<> 128:9bcdf88f62b0 1536
<> 128:9bcdf88f62b0 1537 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 1538 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1539 * @param func Static function to attach
<> 128:9bcdf88f62b0 1540 * @deprecated
<> 128:9bcdf88f62b0 1541 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 1542 */
<> 130:d75b3fe1f5cb 1543 template <typename T, typename U>
<> 128:9bcdf88f62b0 1544 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1545 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 1546 void attach(const volatile U *obj, R (*func)(const volatile T*, A0, A1)) {
<> 128:9bcdf88f62b0 1547 this->~Callback();
<> 128:9bcdf88f62b0 1548 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1549 }
<> 128:9bcdf88f62b0 1550
<> 128:9bcdf88f62b0 1551 /** Assign a callback
<> 128:9bcdf88f62b0 1552 */
<> 128:9bcdf88f62b0 1553 Callback &operator=(const Callback &that) {
<> 128:9bcdf88f62b0 1554 if (this != &that) {
<> 128:9bcdf88f62b0 1555 this->~Callback();
<> 128:9bcdf88f62b0 1556 new (this) Callback(that);
<> 128:9bcdf88f62b0 1557 }
<> 128:9bcdf88f62b0 1558
<> 128:9bcdf88f62b0 1559 return *this;
<> 128:9bcdf88f62b0 1560 }
<> 128:9bcdf88f62b0 1561
<> 128:9bcdf88f62b0 1562 /** Call the attached function
<> 128:9bcdf88f62b0 1563 */
<> 128:9bcdf88f62b0 1564 R call(A0 a0, A1 a1) const {
<> 128:9bcdf88f62b0 1565 MBED_ASSERT(_ops);
<> 128:9bcdf88f62b0 1566 return _ops->call(this, a0, a1);
<> 128:9bcdf88f62b0 1567 }
<> 128:9bcdf88f62b0 1568
<> 128:9bcdf88f62b0 1569 /** Call the attached function
<> 128:9bcdf88f62b0 1570 */
<> 128:9bcdf88f62b0 1571 R operator()(A0 a0, A1 a1) const {
<> 128:9bcdf88f62b0 1572 return call(a0, a1);
<> 128:9bcdf88f62b0 1573 }
<> 128:9bcdf88f62b0 1574
<> 128:9bcdf88f62b0 1575 /** Test if function has been attached
<> 128:9bcdf88f62b0 1576 */
<> 128:9bcdf88f62b0 1577 operator bool() const {
<> 128:9bcdf88f62b0 1578 return _ops;
<> 128:9bcdf88f62b0 1579 }
<> 128:9bcdf88f62b0 1580
<> 128:9bcdf88f62b0 1581 /** Test for equality
<> 128:9bcdf88f62b0 1582 */
<> 128:9bcdf88f62b0 1583 friend bool operator==(const Callback &l, const Callback &r) {
<> 128:9bcdf88f62b0 1584 return memcmp(&l, &r, sizeof(Callback)) == 0;
<> 128:9bcdf88f62b0 1585 }
<> 128:9bcdf88f62b0 1586
<> 128:9bcdf88f62b0 1587 /** Test for inequality
<> 128:9bcdf88f62b0 1588 */
<> 128:9bcdf88f62b0 1589 friend bool operator!=(const Callback &l, const Callback &r) {
<> 128:9bcdf88f62b0 1590 return !(l == r);
<> 128:9bcdf88f62b0 1591 }
<> 128:9bcdf88f62b0 1592
<> 128:9bcdf88f62b0 1593 /** Static thunk for passing as C-style function
<> 128:9bcdf88f62b0 1594 * @param func Callback to call passed as void pointer
<> 128:9bcdf88f62b0 1595 */
<> 128:9bcdf88f62b0 1596 static R thunk(void *func, A0 a0, A1 a1) {
<> 128:9bcdf88f62b0 1597 return static_cast<Callback*>(func)->call(a0, a1);
<> 128:9bcdf88f62b0 1598 }
<> 128:9bcdf88f62b0 1599
<> 128:9bcdf88f62b0 1600 private:
<> 128:9bcdf88f62b0 1601 // Stored as pointer to function and pointer to optional object
<> 128:9bcdf88f62b0 1602 // Function pointer is stored as union of possible function types
<> 128:9bcdf88f62b0 1603 // to garuntee proper size and alignment
<> 128:9bcdf88f62b0 1604 struct _class;
<> 128:9bcdf88f62b0 1605 union {
<> 128:9bcdf88f62b0 1606 void (*_staticfunc)(A0, A1);
<> 128:9bcdf88f62b0 1607 void (*_boundfunc)(_class*, A0, A1);
<> 128:9bcdf88f62b0 1608 void (_class::*_methodfunc)(A0, A1);
<> 128:9bcdf88f62b0 1609 } _func;
<> 128:9bcdf88f62b0 1610 void *_obj;
<> 128:9bcdf88f62b0 1611
<> 128:9bcdf88f62b0 1612 // Dynamically dispatched operations
<> 128:9bcdf88f62b0 1613 const struct ops {
<> 128:9bcdf88f62b0 1614 R (*call)(const void*, A0, A1);
<> 128:9bcdf88f62b0 1615 void (*move)(void*, const void*);
<> 128:9bcdf88f62b0 1616 void (*dtor)(void*);
<> 128:9bcdf88f62b0 1617 } *_ops;
<> 128:9bcdf88f62b0 1618
<> 128:9bcdf88f62b0 1619 // Generate operations for function object
<> 128:9bcdf88f62b0 1620 template <typename F>
<> 128:9bcdf88f62b0 1621 void generate(const F &f) {
<> 128:9bcdf88f62b0 1622 static const ops ops = {
<> 128:9bcdf88f62b0 1623 &Callback::function_call<F>,
<> 128:9bcdf88f62b0 1624 &Callback::function_move<F>,
<> 128:9bcdf88f62b0 1625 &Callback::function_dtor<F>,
<> 128:9bcdf88f62b0 1626 };
<> 128:9bcdf88f62b0 1627
<> 130:d75b3fe1f5cb 1628 MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F),
<> 130:d75b3fe1f5cb 1629 "Type F must not exceed the size of the Callback class");
<> 128:9bcdf88f62b0 1630 new (this) F(f);
<> 128:9bcdf88f62b0 1631 _ops = &ops;
<> 128:9bcdf88f62b0 1632 }
<> 128:9bcdf88f62b0 1633
<> 128:9bcdf88f62b0 1634 // Function attributes
<> 128:9bcdf88f62b0 1635 template <typename F>
<> 128:9bcdf88f62b0 1636 static R function_call(const void *p, A0 a0, A1 a1) {
<> 128:9bcdf88f62b0 1637 return (*(F*)p)(a0, a1);
<> 128:9bcdf88f62b0 1638 }
<> 128:9bcdf88f62b0 1639
<> 128:9bcdf88f62b0 1640 template <typename F>
<> 128:9bcdf88f62b0 1641 static void function_move(void *d, const void *p) {
<> 128:9bcdf88f62b0 1642 new (d) F(*(F*)p);
<> 128:9bcdf88f62b0 1643 }
<> 128:9bcdf88f62b0 1644
<> 128:9bcdf88f62b0 1645 template <typename F>
<> 128:9bcdf88f62b0 1646 static void function_dtor(void *p) {
<> 128:9bcdf88f62b0 1647 ((F*)p)->~F();
<> 128:9bcdf88f62b0 1648 }
<> 128:9bcdf88f62b0 1649
<> 128:9bcdf88f62b0 1650 // Wrappers for functions with context
<> 128:9bcdf88f62b0 1651 template <typename O, typename M>
<> 128:9bcdf88f62b0 1652 struct method_context {
<> 128:9bcdf88f62b0 1653 M method;
<> 128:9bcdf88f62b0 1654 O *obj;
<> 128:9bcdf88f62b0 1655
<> 128:9bcdf88f62b0 1656 method_context(O *obj, M method)
<> 128:9bcdf88f62b0 1657 : method(method), obj(obj) {}
<> 128:9bcdf88f62b0 1658
<> 128:9bcdf88f62b0 1659 R operator()(A0 a0, A1 a1) const {
<> 128:9bcdf88f62b0 1660 return (obj->*method)(a0, a1);
<> 128:9bcdf88f62b0 1661 }
<> 128:9bcdf88f62b0 1662 };
<> 128:9bcdf88f62b0 1663
<> 128:9bcdf88f62b0 1664 template <typename F, typename A>
<> 128:9bcdf88f62b0 1665 struct function_context {
<> 128:9bcdf88f62b0 1666 F func;
<> 128:9bcdf88f62b0 1667 A *arg;
<> 128:9bcdf88f62b0 1668
<> 128:9bcdf88f62b0 1669 function_context(F func, A *arg)
<> 128:9bcdf88f62b0 1670 : func(func), arg(arg) {}
<> 128:9bcdf88f62b0 1671
<> 128:9bcdf88f62b0 1672 R operator()(A0 a0, A1 a1) const {
<> 128:9bcdf88f62b0 1673 return func(arg, a0, a1);
<> 128:9bcdf88f62b0 1674 }
<> 128:9bcdf88f62b0 1675 };
<> 128:9bcdf88f62b0 1676 };
<> 128:9bcdf88f62b0 1677
<> 128:9bcdf88f62b0 1678 /** Callback class based on template specialization
<> 128:9bcdf88f62b0 1679 *
<> 128:9bcdf88f62b0 1680 * @Note Synchronization level: Not protected
<> 128:9bcdf88f62b0 1681 */
<> 128:9bcdf88f62b0 1682 template <typename R, typename A0, typename A1, typename A2>
<> 128:9bcdf88f62b0 1683 class Callback<R(A0, A1, A2)> {
<> 128:9bcdf88f62b0 1684 public:
<> 128:9bcdf88f62b0 1685 /** Create a Callback with a static function
<> 128:9bcdf88f62b0 1686 * @param func Static function to attach
<> 128:9bcdf88f62b0 1687 */
<> 128:9bcdf88f62b0 1688 Callback(R (*func)(A0, A1, A2) = 0) {
<> 128:9bcdf88f62b0 1689 if (!func) {
<> 128:9bcdf88f62b0 1690 _ops = 0;
<> 128:9bcdf88f62b0 1691 } else {
<> 128:9bcdf88f62b0 1692 generate(func);
<> 128:9bcdf88f62b0 1693 }
<> 128:9bcdf88f62b0 1694 }
<> 128:9bcdf88f62b0 1695
<> 128:9bcdf88f62b0 1696 /** Attach a Callback
<> 128:9bcdf88f62b0 1697 * @param func The Callback to attach
<> 128:9bcdf88f62b0 1698 */
<> 128:9bcdf88f62b0 1699 Callback(const Callback<R(A0, A1, A2)> &func) {
<> 128:9bcdf88f62b0 1700 if (func._ops) {
<> 128:9bcdf88f62b0 1701 func._ops->move(this, &func);
<> 128:9bcdf88f62b0 1702 }
<> 128:9bcdf88f62b0 1703 _ops = func._ops;
<> 128:9bcdf88f62b0 1704 }
<> 128:9bcdf88f62b0 1705
<> 128:9bcdf88f62b0 1706 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 1707 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1708 * @param method Member function to attach
<> 128:9bcdf88f62b0 1709 */
<> 130:d75b3fe1f5cb 1710 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1711 Callback(U *obj, R (T::*method)(A0, A1, A2)) {
<> 128:9bcdf88f62b0 1712 generate(method_context<T, R (T::*)(A0, A1, A2)>(obj, method));
<> 128:9bcdf88f62b0 1713 }
<> 128:9bcdf88f62b0 1714
<> 128:9bcdf88f62b0 1715 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 1716 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1717 * @param method Member function to attach
<> 128:9bcdf88f62b0 1718 */
<> 130:d75b3fe1f5cb 1719 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1720 Callback(const U *obj, R (T::*method)(A0, A1, A2) const) {
<> 128:9bcdf88f62b0 1721 generate(method_context<const T, R (T::*)(A0, A1, A2) const>(obj, method));
<> 128:9bcdf88f62b0 1722 }
<> 128:9bcdf88f62b0 1723
<> 128:9bcdf88f62b0 1724 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 1725 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1726 * @param method Member function to attach
<> 128:9bcdf88f62b0 1727 */
<> 130:d75b3fe1f5cb 1728 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1729 Callback(volatile U *obj, R (T::*method)(A0, A1, A2) volatile) {
<> 128:9bcdf88f62b0 1730 generate(method_context<volatile T, R (T::*)(A0, A1, A2) volatile>(obj, method));
<> 128:9bcdf88f62b0 1731 }
<> 128:9bcdf88f62b0 1732
<> 128:9bcdf88f62b0 1733 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 1734 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1735 * @param method Member function to attach
<> 128:9bcdf88f62b0 1736 */
<> 130:d75b3fe1f5cb 1737 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1738 Callback(const volatile U *obj, R (T::*method)(A0, A1, A2) const volatile) {
<> 128:9bcdf88f62b0 1739 generate(method_context<const volatile T, R (T::*)(A0, A1, A2) const volatile>(obj, method));
<> 128:9bcdf88f62b0 1740 }
<> 128:9bcdf88f62b0 1741
<> 128:9bcdf88f62b0 1742 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1743 * @param func Static function to attach
<> 128:9bcdf88f62b0 1744 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1745 */
<> 130:d75b3fe1f5cb 1746 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1747 Callback(R (*func)(T*, A0, A1, A2), U *arg) {
<> 128:9bcdf88f62b0 1748 generate(function_context<R (*)(T*, A0, A1, A2), T>(func, arg));
<> 128:9bcdf88f62b0 1749 }
<> 128:9bcdf88f62b0 1750
<> 128:9bcdf88f62b0 1751 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1752 * @param func Static function to attach
<> 128:9bcdf88f62b0 1753 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1754 */
<> 130:d75b3fe1f5cb 1755 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1756 Callback(R (*func)(const T*, A0, A1, A2), const U *arg) {
<> 128:9bcdf88f62b0 1757 generate(function_context<R (*)(const T*, A0, A1, A2), const T>(func, arg));
<> 128:9bcdf88f62b0 1758 }
<> 128:9bcdf88f62b0 1759
<> 128:9bcdf88f62b0 1760 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1761 * @param func Static function to attach
<> 128:9bcdf88f62b0 1762 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1763 */
<> 130:d75b3fe1f5cb 1764 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1765 Callback(R (*func)(volatile T*, A0, A1, A2), volatile U *arg) {
<> 128:9bcdf88f62b0 1766 generate(function_context<R (*)(volatile T*, A0, A1, A2), volatile T>(func, arg));
<> 128:9bcdf88f62b0 1767 }
<> 128:9bcdf88f62b0 1768
<> 128:9bcdf88f62b0 1769 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1770 * @param func Static function to attach
<> 128:9bcdf88f62b0 1771 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1772 */
<> 130:d75b3fe1f5cb 1773 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1774 Callback(R (*func)(const volatile T*, A0, A1, A2), const volatile U *arg) {
<> 128:9bcdf88f62b0 1775 generate(function_context<R (*)(const volatile T*, A0, A1, A2), const volatile T>(func, arg));
<> 128:9bcdf88f62b0 1776 }
<> 128:9bcdf88f62b0 1777
<> 128:9bcdf88f62b0 1778 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 1779 * @param func Function object to attach
<> 128:9bcdf88f62b0 1780 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1781 */
<> 128:9bcdf88f62b0 1782 template <typename F>
<> 128:9bcdf88f62b0 1783 Callback(F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1784 detail::is_type<R (F::*)(A0, A1, A2), &F::operator()>::value &&
<> 128:9bcdf88f62b0 1785 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1786 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1787 generate(f);
<> 128:9bcdf88f62b0 1788 }
<> 128:9bcdf88f62b0 1789
<> 128:9bcdf88f62b0 1790 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 1791 * @param func Function object to attach
<> 128:9bcdf88f62b0 1792 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1793 */
<> 128:9bcdf88f62b0 1794 template <typename F>
<> 128:9bcdf88f62b0 1795 Callback(const F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1796 detail::is_type<R (F::*)(A0, A1, A2) const, &F::operator()>::value &&
<> 128:9bcdf88f62b0 1797 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1798 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1799 generate(f);
<> 128:9bcdf88f62b0 1800 }
<> 128:9bcdf88f62b0 1801
<> 128:9bcdf88f62b0 1802 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 1803 * @param func Function object to attach
<> 128:9bcdf88f62b0 1804 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1805 */
<> 128:9bcdf88f62b0 1806 template <typename F>
<> 128:9bcdf88f62b0 1807 Callback(volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1808 detail::is_type<R (F::*)(A0, A1, A2) volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 1809 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1810 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1811 generate(f);
<> 128:9bcdf88f62b0 1812 }
<> 128:9bcdf88f62b0 1813
<> 128:9bcdf88f62b0 1814 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 1815 * @param func Function object to attach
<> 128:9bcdf88f62b0 1816 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1817 */
<> 128:9bcdf88f62b0 1818 template <typename F>
<> 128:9bcdf88f62b0 1819 Callback(const volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1820 detail::is_type<R (F::*)(A0, A1, A2) const volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 1821 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1822 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1823 generate(f);
<> 128:9bcdf88f62b0 1824 }
<> 128:9bcdf88f62b0 1825
<> 128:9bcdf88f62b0 1826 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1827 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1828 * @param func Static function to attach
<> 128:9bcdf88f62b0 1829 * @deprecated
<> 128:9bcdf88f62b0 1830 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 1831 */
<> 130:d75b3fe1f5cb 1832 template<typename T, typename U>
<> 128:9bcdf88f62b0 1833 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1834 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 1835 Callback(U *obj, R (*func)(T*, A0, A1, A2)) {
<> 128:9bcdf88f62b0 1836 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1837 }
<> 128:9bcdf88f62b0 1838
<> 128:9bcdf88f62b0 1839 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1840 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1841 * @param func Static function to attach
<> 128:9bcdf88f62b0 1842 * @deprecated
<> 128:9bcdf88f62b0 1843 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 1844 */
<> 130:d75b3fe1f5cb 1845 template<typename T, typename U>
<> 128:9bcdf88f62b0 1846 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1847 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 1848 Callback(const U *obj, R (*func)(const T*, A0, A1, A2)) {
<> 128:9bcdf88f62b0 1849 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1850 }
<> 128:9bcdf88f62b0 1851
<> 128:9bcdf88f62b0 1852 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1853 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1854 * @param func Static function to attach
<> 128:9bcdf88f62b0 1855 * @deprecated
<> 128:9bcdf88f62b0 1856 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 1857 */
<> 130:d75b3fe1f5cb 1858 template<typename T, typename U>
<> 128:9bcdf88f62b0 1859 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1860 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 1861 Callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2)) {
<> 128:9bcdf88f62b0 1862 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1863 }
<> 128:9bcdf88f62b0 1864
<> 128:9bcdf88f62b0 1865 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 1866 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 1867 * @param func Static function to attach
<> 128:9bcdf88f62b0 1868 * @deprecated
<> 128:9bcdf88f62b0 1869 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 1870 */
<> 130:d75b3fe1f5cb 1871 template<typename T, typename U>
<> 128:9bcdf88f62b0 1872 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 1873 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 1874 Callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2)) {
<> 128:9bcdf88f62b0 1875 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 1876 }
<> 128:9bcdf88f62b0 1877
<> 128:9bcdf88f62b0 1878 /** Destroy a callback
<> 128:9bcdf88f62b0 1879 */
<> 128:9bcdf88f62b0 1880 ~Callback() {
<> 128:9bcdf88f62b0 1881 if (_ops) {
<> 128:9bcdf88f62b0 1882 _ops->dtor(this);
<> 128:9bcdf88f62b0 1883 }
<> 128:9bcdf88f62b0 1884 }
<> 128:9bcdf88f62b0 1885
<> 128:9bcdf88f62b0 1886 /** Attach a static function
<> 128:9bcdf88f62b0 1887 * @param func Static function to attach
<> 128:9bcdf88f62b0 1888 */
<> 128:9bcdf88f62b0 1889 void attach(R (*func)(A0, A1, A2)) {
<> 128:9bcdf88f62b0 1890 this->~Callback();
<> 128:9bcdf88f62b0 1891 new (this) Callback(func);
<> 128:9bcdf88f62b0 1892 }
<> 128:9bcdf88f62b0 1893
<> 128:9bcdf88f62b0 1894 /** Attach a Callback
<> 128:9bcdf88f62b0 1895 * @param func The Callback to attach
<> 128:9bcdf88f62b0 1896 */
<> 128:9bcdf88f62b0 1897 void attach(const Callback<R(A0, A1, A2)> &func) {
<> 128:9bcdf88f62b0 1898 this->~Callback();
<> 128:9bcdf88f62b0 1899 new (this) Callback(func);
<> 128:9bcdf88f62b0 1900 }
<> 128:9bcdf88f62b0 1901
<> 128:9bcdf88f62b0 1902 /** Attach a member function
<> 128:9bcdf88f62b0 1903 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1904 * @param method Member function to attach
<> 128:9bcdf88f62b0 1905 */
<> 130:d75b3fe1f5cb 1906 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1907 void attach(U *obj, R (T::*method)(A0, A1, A2)) {
<> 128:9bcdf88f62b0 1908 this->~Callback();
<> 128:9bcdf88f62b0 1909 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 1910 }
<> 128:9bcdf88f62b0 1911
<> 128:9bcdf88f62b0 1912 /** Attach a member function
<> 128:9bcdf88f62b0 1913 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1914 * @param method Member function to attach
<> 128:9bcdf88f62b0 1915 */
<> 130:d75b3fe1f5cb 1916 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1917 void attach(const U *obj, R (T::*method)(A0, A1, A2) const) {
<> 128:9bcdf88f62b0 1918 this->~Callback();
<> 128:9bcdf88f62b0 1919 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 1920 }
<> 128:9bcdf88f62b0 1921
<> 128:9bcdf88f62b0 1922 /** Attach a member function
<> 128:9bcdf88f62b0 1923 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1924 * @param method Member function to attach
<> 128:9bcdf88f62b0 1925 */
<> 130:d75b3fe1f5cb 1926 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1927 void attach(volatile U *obj, R (T::*method)(A0, A1, A2) volatile) {
<> 128:9bcdf88f62b0 1928 this->~Callback();
<> 128:9bcdf88f62b0 1929 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 1930 }
<> 128:9bcdf88f62b0 1931
<> 128:9bcdf88f62b0 1932 /** Attach a member function
<> 128:9bcdf88f62b0 1933 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 1934 * @param method Member function to attach
<> 128:9bcdf88f62b0 1935 */
<> 130:d75b3fe1f5cb 1936 template<typename T, typename U>
<> 130:d75b3fe1f5cb 1937 void attach(const volatile U *obj, R (T::*method)(A0, A1, A2) const volatile) {
<> 128:9bcdf88f62b0 1938 this->~Callback();
<> 128:9bcdf88f62b0 1939 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 1940 }
<> 128:9bcdf88f62b0 1941
<> 128:9bcdf88f62b0 1942 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 1943 * @param func Static function to attach
<> 128:9bcdf88f62b0 1944 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1945 */
<> 130:d75b3fe1f5cb 1946 template <typename T, typename U>
<> 130:d75b3fe1f5cb 1947 void attach(R (*func)(T*, A0, A1, A2), U *arg) {
<> 128:9bcdf88f62b0 1948 this->~Callback();
<> 128:9bcdf88f62b0 1949 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 1950 }
<> 128:9bcdf88f62b0 1951
<> 128:9bcdf88f62b0 1952 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 1953 * @param func Static function to attach
<> 128:9bcdf88f62b0 1954 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1955 */
<> 130:d75b3fe1f5cb 1956 template <typename T, typename U>
<> 130:d75b3fe1f5cb 1957 void attach(R (*func)(const T*, A0, A1, A2), const U *arg) {
<> 128:9bcdf88f62b0 1958 this->~Callback();
<> 128:9bcdf88f62b0 1959 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 1960 }
<> 128:9bcdf88f62b0 1961
<> 128:9bcdf88f62b0 1962 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 1963 * @param func Static function to attach
<> 128:9bcdf88f62b0 1964 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1965 */
<> 130:d75b3fe1f5cb 1966 template <typename T, typename U>
<> 130:d75b3fe1f5cb 1967 void attach(R (*func)(volatile T*, A0, A1, A2), volatile U *arg) {
<> 128:9bcdf88f62b0 1968 this->~Callback();
<> 128:9bcdf88f62b0 1969 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 1970 }
<> 128:9bcdf88f62b0 1971
<> 128:9bcdf88f62b0 1972 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 1973 * @param func Static function to attach
<> 128:9bcdf88f62b0 1974 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 1975 */
<> 130:d75b3fe1f5cb 1976 template <typename T, typename U>
<> 130:d75b3fe1f5cb 1977 void attach(R (*func)(const volatile T*, A0, A1, A2), const volatile U *arg) {
<> 128:9bcdf88f62b0 1978 this->~Callback();
<> 128:9bcdf88f62b0 1979 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 1980 }
<> 128:9bcdf88f62b0 1981
<> 128:9bcdf88f62b0 1982 /** Attach a function object
<> 128:9bcdf88f62b0 1983 * @param func Function object to attach
<> 128:9bcdf88f62b0 1984 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1985 */
<> 128:9bcdf88f62b0 1986 template <typename F>
<> 128:9bcdf88f62b0 1987 void attach(F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 1988 detail::is_type<R (F::*)(A0, A1, A2), &F::operator()>::value &&
<> 128:9bcdf88f62b0 1989 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 1990 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 1991 this->~Callback();
<> 128:9bcdf88f62b0 1992 new (this) Callback(f);
<> 128:9bcdf88f62b0 1993 }
<> 128:9bcdf88f62b0 1994
<> 128:9bcdf88f62b0 1995 /** Attach a function object
<> 128:9bcdf88f62b0 1996 * @param func Function object to attach
<> 128:9bcdf88f62b0 1997 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 1998 */
<> 128:9bcdf88f62b0 1999 template <typename F>
<> 128:9bcdf88f62b0 2000 void attach(const F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2001 detail::is_type<R (F::*)(A0, A1, A2) const, &F::operator()>::value &&
<> 128:9bcdf88f62b0 2002 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2003 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2004 this->~Callback();
<> 128:9bcdf88f62b0 2005 new (this) Callback(f);
<> 128:9bcdf88f62b0 2006 }
<> 128:9bcdf88f62b0 2007
<> 128:9bcdf88f62b0 2008 /** Attach a function object
<> 128:9bcdf88f62b0 2009 * @param func Function object to attach
<> 128:9bcdf88f62b0 2010 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2011 */
<> 128:9bcdf88f62b0 2012 template <typename F>
<> 128:9bcdf88f62b0 2013 void attach(volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2014 detail::is_type<R (F::*)(A0, A1, A2) volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 2015 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2016 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2017 this->~Callback();
<> 128:9bcdf88f62b0 2018 new (this) Callback(f);
<> 128:9bcdf88f62b0 2019 }
<> 128:9bcdf88f62b0 2020
<> 128:9bcdf88f62b0 2021 /** Attach a function object
<> 128:9bcdf88f62b0 2022 * @param func Function object to attach
<> 128:9bcdf88f62b0 2023 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2024 */
<> 128:9bcdf88f62b0 2025 template <typename F>
<> 128:9bcdf88f62b0 2026 void attach(const volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2027 detail::is_type<R (F::*)(A0, A1, A2) const volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 2028 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2029 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2030 this->~Callback();
<> 128:9bcdf88f62b0 2031 new (this) Callback(f);
<> 128:9bcdf88f62b0 2032 }
<> 128:9bcdf88f62b0 2033
<> 128:9bcdf88f62b0 2034 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 2035 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2036 * @param func Static function to attach
<> 128:9bcdf88f62b0 2037 * @deprecated
<> 128:9bcdf88f62b0 2038 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 2039 */
<> 130:d75b3fe1f5cb 2040 template <typename T, typename U>
<> 128:9bcdf88f62b0 2041 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2042 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 2043 void attach(U *obj, R (*func)(T*, A0, A1, A2)) {
<> 128:9bcdf88f62b0 2044 this->~Callback();
<> 128:9bcdf88f62b0 2045 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2046 }
<> 128:9bcdf88f62b0 2047
<> 128:9bcdf88f62b0 2048 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 2049 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2050 * @param func Static function to attach
<> 128:9bcdf88f62b0 2051 * @deprecated
<> 128:9bcdf88f62b0 2052 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 2053 */
<> 130:d75b3fe1f5cb 2054 template <typename T, typename U>
<> 128:9bcdf88f62b0 2055 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2056 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 2057 void attach(const U *obj, R (*func)(const T*, A0, A1, A2)) {
<> 128:9bcdf88f62b0 2058 this->~Callback();
<> 128:9bcdf88f62b0 2059 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2060 }
<> 128:9bcdf88f62b0 2061
<> 128:9bcdf88f62b0 2062 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 2063 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2064 * @param func Static function to attach
<> 128:9bcdf88f62b0 2065 * @deprecated
<> 128:9bcdf88f62b0 2066 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 2067 */
<> 130:d75b3fe1f5cb 2068 template <typename T, typename U>
<> 128:9bcdf88f62b0 2069 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2070 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 2071 void attach(volatile U *obj, R (*func)(volatile T*, A0, A1, A2)) {
<> 128:9bcdf88f62b0 2072 this->~Callback();
<> 128:9bcdf88f62b0 2073 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2074 }
<> 128:9bcdf88f62b0 2075
<> 128:9bcdf88f62b0 2076 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 2077 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2078 * @param func Static function to attach
<> 128:9bcdf88f62b0 2079 * @deprecated
<> 128:9bcdf88f62b0 2080 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 2081 */
<> 130:d75b3fe1f5cb 2082 template <typename T, typename U>
<> 128:9bcdf88f62b0 2083 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2084 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 2085 void attach(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2)) {
<> 128:9bcdf88f62b0 2086 this->~Callback();
<> 128:9bcdf88f62b0 2087 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2088 }
<> 128:9bcdf88f62b0 2089
<> 128:9bcdf88f62b0 2090 /** Assign a callback
<> 128:9bcdf88f62b0 2091 */
<> 128:9bcdf88f62b0 2092 Callback &operator=(const Callback &that) {
<> 128:9bcdf88f62b0 2093 if (this != &that) {
<> 128:9bcdf88f62b0 2094 this->~Callback();
<> 128:9bcdf88f62b0 2095 new (this) Callback(that);
<> 128:9bcdf88f62b0 2096 }
<> 128:9bcdf88f62b0 2097
<> 128:9bcdf88f62b0 2098 return *this;
<> 128:9bcdf88f62b0 2099 }
<> 128:9bcdf88f62b0 2100
<> 128:9bcdf88f62b0 2101 /** Call the attached function
<> 128:9bcdf88f62b0 2102 */
<> 128:9bcdf88f62b0 2103 R call(A0 a0, A1 a1, A2 a2) const {
<> 128:9bcdf88f62b0 2104 MBED_ASSERT(_ops);
<> 128:9bcdf88f62b0 2105 return _ops->call(this, a0, a1, a2);
<> 128:9bcdf88f62b0 2106 }
<> 128:9bcdf88f62b0 2107
<> 128:9bcdf88f62b0 2108 /** Call the attached function
<> 128:9bcdf88f62b0 2109 */
<> 128:9bcdf88f62b0 2110 R operator()(A0 a0, A1 a1, A2 a2) const {
<> 128:9bcdf88f62b0 2111 return call(a0, a1, a2);
<> 128:9bcdf88f62b0 2112 }
<> 128:9bcdf88f62b0 2113
<> 128:9bcdf88f62b0 2114 /** Test if function has been attached
<> 128:9bcdf88f62b0 2115 */
<> 128:9bcdf88f62b0 2116 operator bool() const {
<> 128:9bcdf88f62b0 2117 return _ops;
<> 128:9bcdf88f62b0 2118 }
<> 128:9bcdf88f62b0 2119
<> 128:9bcdf88f62b0 2120 /** Test for equality
<> 128:9bcdf88f62b0 2121 */
<> 128:9bcdf88f62b0 2122 friend bool operator==(const Callback &l, const Callback &r) {
<> 128:9bcdf88f62b0 2123 return memcmp(&l, &r, sizeof(Callback)) == 0;
<> 128:9bcdf88f62b0 2124 }
<> 128:9bcdf88f62b0 2125
<> 128:9bcdf88f62b0 2126 /** Test for inequality
<> 128:9bcdf88f62b0 2127 */
<> 128:9bcdf88f62b0 2128 friend bool operator!=(const Callback &l, const Callback &r) {
<> 128:9bcdf88f62b0 2129 return !(l == r);
<> 128:9bcdf88f62b0 2130 }
<> 128:9bcdf88f62b0 2131
<> 128:9bcdf88f62b0 2132 /** Static thunk for passing as C-style function
<> 128:9bcdf88f62b0 2133 * @param func Callback to call passed as void pointer
<> 128:9bcdf88f62b0 2134 */
<> 128:9bcdf88f62b0 2135 static R thunk(void *func, A0 a0, A1 a1, A2 a2) {
<> 128:9bcdf88f62b0 2136 return static_cast<Callback*>(func)->call(a0, a1, a2);
<> 128:9bcdf88f62b0 2137 }
<> 128:9bcdf88f62b0 2138
<> 128:9bcdf88f62b0 2139 private:
<> 128:9bcdf88f62b0 2140 // Stored as pointer to function and pointer to optional object
<> 128:9bcdf88f62b0 2141 // Function pointer is stored as union of possible function types
<> 128:9bcdf88f62b0 2142 // to garuntee proper size and alignment
<> 128:9bcdf88f62b0 2143 struct _class;
<> 128:9bcdf88f62b0 2144 union {
<> 128:9bcdf88f62b0 2145 void (*_staticfunc)(A0, A1, A2);
<> 128:9bcdf88f62b0 2146 void (*_boundfunc)(_class*, A0, A1, A2);
<> 128:9bcdf88f62b0 2147 void (_class::*_methodfunc)(A0, A1, A2);
<> 128:9bcdf88f62b0 2148 } _func;
<> 128:9bcdf88f62b0 2149 void *_obj;
<> 128:9bcdf88f62b0 2150
<> 128:9bcdf88f62b0 2151 // Dynamically dispatched operations
<> 128:9bcdf88f62b0 2152 const struct ops {
<> 128:9bcdf88f62b0 2153 R (*call)(const void*, A0, A1, A2);
<> 128:9bcdf88f62b0 2154 void (*move)(void*, const void*);
<> 128:9bcdf88f62b0 2155 void (*dtor)(void*);
<> 128:9bcdf88f62b0 2156 } *_ops;
<> 128:9bcdf88f62b0 2157
<> 128:9bcdf88f62b0 2158 // Generate operations for function object
<> 128:9bcdf88f62b0 2159 template <typename F>
<> 128:9bcdf88f62b0 2160 void generate(const F &f) {
<> 128:9bcdf88f62b0 2161 static const ops ops = {
<> 128:9bcdf88f62b0 2162 &Callback::function_call<F>,
<> 128:9bcdf88f62b0 2163 &Callback::function_move<F>,
<> 128:9bcdf88f62b0 2164 &Callback::function_dtor<F>,
<> 128:9bcdf88f62b0 2165 };
<> 128:9bcdf88f62b0 2166
<> 130:d75b3fe1f5cb 2167 MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F),
<> 130:d75b3fe1f5cb 2168 "Type F must not exceed the size of the Callback class");
<> 128:9bcdf88f62b0 2169 new (this) F(f);
<> 128:9bcdf88f62b0 2170 _ops = &ops;
<> 128:9bcdf88f62b0 2171 }
<> 128:9bcdf88f62b0 2172
<> 128:9bcdf88f62b0 2173 // Function attributes
<> 128:9bcdf88f62b0 2174 template <typename F>
<> 128:9bcdf88f62b0 2175 static R function_call(const void *p, A0 a0, A1 a1, A2 a2) {
<> 128:9bcdf88f62b0 2176 return (*(F*)p)(a0, a1, a2);
<> 128:9bcdf88f62b0 2177 }
<> 128:9bcdf88f62b0 2178
<> 128:9bcdf88f62b0 2179 template <typename F>
<> 128:9bcdf88f62b0 2180 static void function_move(void *d, const void *p) {
<> 128:9bcdf88f62b0 2181 new (d) F(*(F*)p);
<> 128:9bcdf88f62b0 2182 }
<> 128:9bcdf88f62b0 2183
<> 128:9bcdf88f62b0 2184 template <typename F>
<> 128:9bcdf88f62b0 2185 static void function_dtor(void *p) {
<> 128:9bcdf88f62b0 2186 ((F*)p)->~F();
<> 128:9bcdf88f62b0 2187 }
<> 128:9bcdf88f62b0 2188
<> 128:9bcdf88f62b0 2189 // Wrappers for functions with context
<> 128:9bcdf88f62b0 2190 template <typename O, typename M>
<> 128:9bcdf88f62b0 2191 struct method_context {
<> 128:9bcdf88f62b0 2192 M method;
<> 128:9bcdf88f62b0 2193 O *obj;
<> 128:9bcdf88f62b0 2194
<> 128:9bcdf88f62b0 2195 method_context(O *obj, M method)
<> 128:9bcdf88f62b0 2196 : method(method), obj(obj) {}
<> 128:9bcdf88f62b0 2197
<> 128:9bcdf88f62b0 2198 R operator()(A0 a0, A1 a1, A2 a2) const {
<> 128:9bcdf88f62b0 2199 return (obj->*method)(a0, a1, a2);
<> 128:9bcdf88f62b0 2200 }
<> 128:9bcdf88f62b0 2201 };
<> 128:9bcdf88f62b0 2202
<> 128:9bcdf88f62b0 2203 template <typename F, typename A>
<> 128:9bcdf88f62b0 2204 struct function_context {
<> 128:9bcdf88f62b0 2205 F func;
<> 128:9bcdf88f62b0 2206 A *arg;
<> 128:9bcdf88f62b0 2207
<> 128:9bcdf88f62b0 2208 function_context(F func, A *arg)
<> 128:9bcdf88f62b0 2209 : func(func), arg(arg) {}
<> 128:9bcdf88f62b0 2210
<> 128:9bcdf88f62b0 2211 R operator()(A0 a0, A1 a1, A2 a2) const {
<> 128:9bcdf88f62b0 2212 return func(arg, a0, a1, a2);
<> 128:9bcdf88f62b0 2213 }
<> 128:9bcdf88f62b0 2214 };
<> 128:9bcdf88f62b0 2215 };
<> 128:9bcdf88f62b0 2216
<> 128:9bcdf88f62b0 2217 /** Callback class based on template specialization
<> 128:9bcdf88f62b0 2218 *
<> 128:9bcdf88f62b0 2219 * @Note Synchronization level: Not protected
<> 128:9bcdf88f62b0 2220 */
<> 128:9bcdf88f62b0 2221 template <typename R, typename A0, typename A1, typename A2, typename A3>
<> 128:9bcdf88f62b0 2222 class Callback<R(A0, A1, A2, A3)> {
<> 128:9bcdf88f62b0 2223 public:
<> 128:9bcdf88f62b0 2224 /** Create a Callback with a static function
<> 128:9bcdf88f62b0 2225 * @param func Static function to attach
<> 128:9bcdf88f62b0 2226 */
<> 128:9bcdf88f62b0 2227 Callback(R (*func)(A0, A1, A2, A3) = 0) {
<> 128:9bcdf88f62b0 2228 if (!func) {
<> 128:9bcdf88f62b0 2229 _ops = 0;
<> 128:9bcdf88f62b0 2230 } else {
<> 128:9bcdf88f62b0 2231 generate(func);
<> 128:9bcdf88f62b0 2232 }
<> 128:9bcdf88f62b0 2233 }
<> 128:9bcdf88f62b0 2234
<> 128:9bcdf88f62b0 2235 /** Attach a Callback
<> 128:9bcdf88f62b0 2236 * @param func The Callback to attach
<> 128:9bcdf88f62b0 2237 */
<> 128:9bcdf88f62b0 2238 Callback(const Callback<R(A0, A1, A2, A3)> &func) {
<> 128:9bcdf88f62b0 2239 if (func._ops) {
<> 128:9bcdf88f62b0 2240 func._ops->move(this, &func);
<> 128:9bcdf88f62b0 2241 }
<> 128:9bcdf88f62b0 2242 _ops = func._ops;
<> 128:9bcdf88f62b0 2243 }
<> 128:9bcdf88f62b0 2244
<> 128:9bcdf88f62b0 2245 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 2246 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2247 * @param method Member function to attach
<> 128:9bcdf88f62b0 2248 */
<> 130:d75b3fe1f5cb 2249 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2250 Callback(U *obj, R (T::*method)(A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 2251 generate(method_context<T, R (T::*)(A0, A1, A2, A3)>(obj, method));
<> 128:9bcdf88f62b0 2252 }
<> 128:9bcdf88f62b0 2253
<> 128:9bcdf88f62b0 2254 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 2255 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2256 * @param method Member function to attach
<> 128:9bcdf88f62b0 2257 */
<> 130:d75b3fe1f5cb 2258 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2259 Callback(const U *obj, R (T::*method)(A0, A1, A2, A3) const) {
<> 128:9bcdf88f62b0 2260 generate(method_context<const T, R (T::*)(A0, A1, A2, A3) const>(obj, method));
<> 128:9bcdf88f62b0 2261 }
<> 128:9bcdf88f62b0 2262
<> 128:9bcdf88f62b0 2263 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 2264 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2265 * @param method Member function to attach
<> 128:9bcdf88f62b0 2266 */
<> 130:d75b3fe1f5cb 2267 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2268 Callback(volatile U *obj, R (T::*method)(A0, A1, A2, A3) volatile) {
<> 128:9bcdf88f62b0 2269 generate(method_context<volatile T, R (T::*)(A0, A1, A2, A3) volatile>(obj, method));
<> 128:9bcdf88f62b0 2270 }
<> 128:9bcdf88f62b0 2271
<> 128:9bcdf88f62b0 2272 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 2273 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2274 * @param method Member function to attach
<> 128:9bcdf88f62b0 2275 */
<> 130:d75b3fe1f5cb 2276 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2277 Callback(const volatile U *obj, R (T::*method)(A0, A1, A2, A3) const volatile) {
<> 128:9bcdf88f62b0 2278 generate(method_context<const volatile T, R (T::*)(A0, A1, A2, A3) const volatile>(obj, method));
<> 128:9bcdf88f62b0 2279 }
<> 128:9bcdf88f62b0 2280
<> 128:9bcdf88f62b0 2281 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2282 * @param func Static function to attach
<> 128:9bcdf88f62b0 2283 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 2284 */
<> 130:d75b3fe1f5cb 2285 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2286 Callback(R (*func)(T*, A0, A1, A2, A3), U *arg) {
<> 128:9bcdf88f62b0 2287 generate(function_context<R (*)(T*, A0, A1, A2, A3), T>(func, arg));
<> 128:9bcdf88f62b0 2288 }
<> 128:9bcdf88f62b0 2289
<> 128:9bcdf88f62b0 2290 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2291 * @param func Static function to attach
<> 128:9bcdf88f62b0 2292 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 2293 */
<> 130:d75b3fe1f5cb 2294 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2295 Callback(R (*func)(const T*, A0, A1, A2, A3), const U *arg) {
<> 128:9bcdf88f62b0 2296 generate(function_context<R (*)(const T*, A0, A1, A2, A3), const T>(func, arg));
<> 128:9bcdf88f62b0 2297 }
<> 128:9bcdf88f62b0 2298
<> 128:9bcdf88f62b0 2299 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2300 * @param func Static function to attach
<> 128:9bcdf88f62b0 2301 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 2302 */
<> 130:d75b3fe1f5cb 2303 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2304 Callback(R (*func)(volatile T*, A0, A1, A2, A3), volatile U *arg) {
<> 128:9bcdf88f62b0 2305 generate(function_context<R (*)(volatile T*, A0, A1, A2, A3), volatile T>(func, arg));
<> 128:9bcdf88f62b0 2306 }
<> 128:9bcdf88f62b0 2307
<> 128:9bcdf88f62b0 2308 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2309 * @param func Static function to attach
<> 128:9bcdf88f62b0 2310 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 2311 */
<> 130:d75b3fe1f5cb 2312 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2313 Callback(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile U *arg) {
<> 128:9bcdf88f62b0 2314 generate(function_context<R (*)(const volatile T*, A0, A1, A2, A3), const volatile T>(func, arg));
<> 128:9bcdf88f62b0 2315 }
<> 128:9bcdf88f62b0 2316
<> 128:9bcdf88f62b0 2317 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 2318 * @param func Function object to attach
<> 128:9bcdf88f62b0 2319 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2320 */
<> 128:9bcdf88f62b0 2321 template <typename F>
<> 128:9bcdf88f62b0 2322 Callback(F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2323 detail::is_type<R (F::*)(A0, A1, A2, A3), &F::operator()>::value &&
<> 128:9bcdf88f62b0 2324 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2325 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2326 generate(f);
<> 128:9bcdf88f62b0 2327 }
<> 128:9bcdf88f62b0 2328
<> 128:9bcdf88f62b0 2329 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 2330 * @param func Function object to attach
<> 128:9bcdf88f62b0 2331 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2332 */
<> 128:9bcdf88f62b0 2333 template <typename F>
<> 128:9bcdf88f62b0 2334 Callback(const F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2335 detail::is_type<R (F::*)(A0, A1, A2, A3) const, &F::operator()>::value &&
<> 128:9bcdf88f62b0 2336 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2337 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2338 generate(f);
<> 128:9bcdf88f62b0 2339 }
<> 128:9bcdf88f62b0 2340
<> 128:9bcdf88f62b0 2341 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 2342 * @param func Function object to attach
<> 128:9bcdf88f62b0 2343 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2344 */
<> 128:9bcdf88f62b0 2345 template <typename F>
<> 128:9bcdf88f62b0 2346 Callback(volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2347 detail::is_type<R (F::*)(A0, A1, A2, A3) volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 2348 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2349 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2350 generate(f);
<> 128:9bcdf88f62b0 2351 }
<> 128:9bcdf88f62b0 2352
<> 128:9bcdf88f62b0 2353 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 2354 * @param func Function object to attach
<> 128:9bcdf88f62b0 2355 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2356 */
<> 128:9bcdf88f62b0 2357 template <typename F>
<> 128:9bcdf88f62b0 2358 Callback(const volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2359 detail::is_type<R (F::*)(A0, A1, A2, A3) const volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 2360 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2361 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2362 generate(f);
<> 128:9bcdf88f62b0 2363 }
<> 128:9bcdf88f62b0 2364
<> 128:9bcdf88f62b0 2365 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2366 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2367 * @param func Static function to attach
<> 128:9bcdf88f62b0 2368 * @deprecated
<> 128:9bcdf88f62b0 2369 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 2370 */
<> 130:d75b3fe1f5cb 2371 template<typename T, typename U>
<> 128:9bcdf88f62b0 2372 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2373 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 2374 Callback(U *obj, R (*func)(T*, A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 2375 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2376 }
<> 128:9bcdf88f62b0 2377
<> 128:9bcdf88f62b0 2378 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2379 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2380 * @param func Static function to attach
<> 128:9bcdf88f62b0 2381 * @deprecated
<> 128:9bcdf88f62b0 2382 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 2383 */
<> 130:d75b3fe1f5cb 2384 template<typename T, typename U>
<> 128:9bcdf88f62b0 2385 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2386 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 2387 Callback(const U *obj, R (*func)(const T*, A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 2388 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2389 }
<> 128:9bcdf88f62b0 2390
<> 128:9bcdf88f62b0 2391 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2392 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2393 * @param func Static function to attach
<> 128:9bcdf88f62b0 2394 * @deprecated
<> 128:9bcdf88f62b0 2395 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 2396 */
<> 130:d75b3fe1f5cb 2397 template<typename T, typename U>
<> 128:9bcdf88f62b0 2398 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2399 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 2400 Callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 2401 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2402 }
<> 128:9bcdf88f62b0 2403
<> 128:9bcdf88f62b0 2404 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2405 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2406 * @param func Static function to attach
<> 128:9bcdf88f62b0 2407 * @deprecated
<> 128:9bcdf88f62b0 2408 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 2409 */
<> 130:d75b3fe1f5cb 2410 template<typename T, typename U>
<> 128:9bcdf88f62b0 2411 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2412 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 2413 Callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 2414 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2415 }
<> 128:9bcdf88f62b0 2416
<> 128:9bcdf88f62b0 2417 /** Destroy a callback
<> 128:9bcdf88f62b0 2418 */
<> 128:9bcdf88f62b0 2419 ~Callback() {
<> 128:9bcdf88f62b0 2420 if (_ops) {
<> 128:9bcdf88f62b0 2421 _ops->dtor(this);
<> 128:9bcdf88f62b0 2422 }
<> 128:9bcdf88f62b0 2423 }
<> 128:9bcdf88f62b0 2424
<> 128:9bcdf88f62b0 2425 /** Attach a static function
<> 128:9bcdf88f62b0 2426 * @param func Static function to attach
<> 128:9bcdf88f62b0 2427 */
<> 128:9bcdf88f62b0 2428 void attach(R (*func)(A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 2429 this->~Callback();
<> 128:9bcdf88f62b0 2430 new (this) Callback(func);
<> 128:9bcdf88f62b0 2431 }
<> 128:9bcdf88f62b0 2432
<> 128:9bcdf88f62b0 2433 /** Attach a Callback
<> 128:9bcdf88f62b0 2434 * @param func The Callback to attach
<> 128:9bcdf88f62b0 2435 */
<> 128:9bcdf88f62b0 2436 void attach(const Callback<R(A0, A1, A2, A3)> &func) {
<> 128:9bcdf88f62b0 2437 this->~Callback();
<> 128:9bcdf88f62b0 2438 new (this) Callback(func);
<> 128:9bcdf88f62b0 2439 }
<> 128:9bcdf88f62b0 2440
<> 128:9bcdf88f62b0 2441 /** Attach a member function
<> 128:9bcdf88f62b0 2442 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2443 * @param method Member function to attach
<> 128:9bcdf88f62b0 2444 */
<> 130:d75b3fe1f5cb 2445 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2446 void attach(U *obj, R (T::*method)(A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 2447 this->~Callback();
<> 128:9bcdf88f62b0 2448 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 2449 }
<> 128:9bcdf88f62b0 2450
<> 128:9bcdf88f62b0 2451 /** Attach a member function
<> 128:9bcdf88f62b0 2452 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2453 * @param method Member function to attach
<> 128:9bcdf88f62b0 2454 */
<> 130:d75b3fe1f5cb 2455 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2456 void attach(const U *obj, R (T::*method)(A0, A1, A2, A3) const) {
<> 128:9bcdf88f62b0 2457 this->~Callback();
<> 128:9bcdf88f62b0 2458 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 2459 }
<> 128:9bcdf88f62b0 2460
<> 128:9bcdf88f62b0 2461 /** Attach a member function
<> 128:9bcdf88f62b0 2462 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2463 * @param method Member function to attach
<> 128:9bcdf88f62b0 2464 */
<> 130:d75b3fe1f5cb 2465 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2466 void attach(volatile U *obj, R (T::*method)(A0, A1, A2, A3) volatile) {
<> 128:9bcdf88f62b0 2467 this->~Callback();
<> 128:9bcdf88f62b0 2468 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 2469 }
<> 128:9bcdf88f62b0 2470
<> 128:9bcdf88f62b0 2471 /** Attach a member function
<> 128:9bcdf88f62b0 2472 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2473 * @param method Member function to attach
<> 128:9bcdf88f62b0 2474 */
<> 130:d75b3fe1f5cb 2475 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2476 void attach(const volatile U *obj, R (T::*method)(A0, A1, A2, A3) const volatile) {
<> 128:9bcdf88f62b0 2477 this->~Callback();
<> 128:9bcdf88f62b0 2478 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 2479 }
<> 128:9bcdf88f62b0 2480
<> 128:9bcdf88f62b0 2481 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 2482 * @param func Static function to attach
<> 128:9bcdf88f62b0 2483 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 2484 */
<> 130:d75b3fe1f5cb 2485 template <typename T, typename U>
<> 130:d75b3fe1f5cb 2486 void attach(R (*func)(T*, A0, A1, A2, A3), U *arg) {
<> 128:9bcdf88f62b0 2487 this->~Callback();
<> 128:9bcdf88f62b0 2488 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 2489 }
<> 128:9bcdf88f62b0 2490
<> 128:9bcdf88f62b0 2491 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 2492 * @param func Static function to attach
<> 128:9bcdf88f62b0 2493 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 2494 */
<> 130:d75b3fe1f5cb 2495 template <typename T, typename U>
<> 130:d75b3fe1f5cb 2496 void attach(R (*func)(const T*, A0, A1, A2, A3), const U *arg) {
<> 128:9bcdf88f62b0 2497 this->~Callback();
<> 128:9bcdf88f62b0 2498 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 2499 }
<> 128:9bcdf88f62b0 2500
<> 128:9bcdf88f62b0 2501 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 2502 * @param func Static function to attach
<> 128:9bcdf88f62b0 2503 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 2504 */
<> 130:d75b3fe1f5cb 2505 template <typename T, typename U>
<> 130:d75b3fe1f5cb 2506 void attach(R (*func)(volatile T*, A0, A1, A2, A3), volatile U *arg) {
<> 128:9bcdf88f62b0 2507 this->~Callback();
<> 128:9bcdf88f62b0 2508 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 2509 }
<> 128:9bcdf88f62b0 2510
<> 128:9bcdf88f62b0 2511 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 2512 * @param func Static function to attach
<> 128:9bcdf88f62b0 2513 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 2514 */
<> 130:d75b3fe1f5cb 2515 template <typename T, typename U>
<> 130:d75b3fe1f5cb 2516 void attach(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile U *arg) {
<> 128:9bcdf88f62b0 2517 this->~Callback();
<> 128:9bcdf88f62b0 2518 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 2519 }
<> 128:9bcdf88f62b0 2520
<> 128:9bcdf88f62b0 2521 /** Attach a function object
<> 128:9bcdf88f62b0 2522 * @param func Function object to attach
<> 128:9bcdf88f62b0 2523 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2524 */
<> 128:9bcdf88f62b0 2525 template <typename F>
<> 128:9bcdf88f62b0 2526 void attach(F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2527 detail::is_type<R (F::*)(A0, A1, A2, A3), &F::operator()>::value &&
<> 128:9bcdf88f62b0 2528 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2529 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2530 this->~Callback();
<> 128:9bcdf88f62b0 2531 new (this) Callback(f);
<> 128:9bcdf88f62b0 2532 }
<> 128:9bcdf88f62b0 2533
<> 128:9bcdf88f62b0 2534 /** Attach a function object
<> 128:9bcdf88f62b0 2535 * @param func Function object to attach
<> 128:9bcdf88f62b0 2536 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2537 */
<> 128:9bcdf88f62b0 2538 template <typename F>
<> 128:9bcdf88f62b0 2539 void attach(const F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2540 detail::is_type<R (F::*)(A0, A1, A2, A3) const, &F::operator()>::value &&
<> 128:9bcdf88f62b0 2541 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2542 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2543 this->~Callback();
<> 128:9bcdf88f62b0 2544 new (this) Callback(f);
<> 128:9bcdf88f62b0 2545 }
<> 128:9bcdf88f62b0 2546
<> 128:9bcdf88f62b0 2547 /** Attach a function object
<> 128:9bcdf88f62b0 2548 * @param func Function object to attach
<> 128:9bcdf88f62b0 2549 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2550 */
<> 128:9bcdf88f62b0 2551 template <typename F>
<> 128:9bcdf88f62b0 2552 void attach(volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2553 detail::is_type<R (F::*)(A0, A1, A2, A3) volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 2554 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2555 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2556 this->~Callback();
<> 128:9bcdf88f62b0 2557 new (this) Callback(f);
<> 128:9bcdf88f62b0 2558 }
<> 128:9bcdf88f62b0 2559
<> 128:9bcdf88f62b0 2560 /** Attach a function object
<> 128:9bcdf88f62b0 2561 * @param func Function object to attach
<> 128:9bcdf88f62b0 2562 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2563 */
<> 128:9bcdf88f62b0 2564 template <typename F>
<> 128:9bcdf88f62b0 2565 void attach(const volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2566 detail::is_type<R (F::*)(A0, A1, A2, A3) const volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 2567 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2568 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2569 this->~Callback();
<> 128:9bcdf88f62b0 2570 new (this) Callback(f);
<> 128:9bcdf88f62b0 2571 }
<> 128:9bcdf88f62b0 2572
<> 128:9bcdf88f62b0 2573 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 2574 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2575 * @param func Static function to attach
<> 128:9bcdf88f62b0 2576 * @deprecated
<> 128:9bcdf88f62b0 2577 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 2578 */
<> 130:d75b3fe1f5cb 2579 template <typename T, typename U>
<> 128:9bcdf88f62b0 2580 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2581 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 2582 void attach(U *obj, R (*func)(T*, A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 2583 this->~Callback();
<> 128:9bcdf88f62b0 2584 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2585 }
<> 128:9bcdf88f62b0 2586
<> 128:9bcdf88f62b0 2587 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 2588 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2589 * @param func Static function to attach
<> 128:9bcdf88f62b0 2590 * @deprecated
<> 128:9bcdf88f62b0 2591 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 2592 */
<> 130:d75b3fe1f5cb 2593 template <typename T, typename U>
<> 128:9bcdf88f62b0 2594 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2595 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 2596 void attach(const U *obj, R (*func)(const T*, A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 2597 this->~Callback();
<> 128:9bcdf88f62b0 2598 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2599 }
<> 128:9bcdf88f62b0 2600
<> 128:9bcdf88f62b0 2601 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 2602 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2603 * @param func Static function to attach
<> 128:9bcdf88f62b0 2604 * @deprecated
<> 128:9bcdf88f62b0 2605 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 2606 */
<> 130:d75b3fe1f5cb 2607 template <typename T, typename U>
<> 128:9bcdf88f62b0 2608 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2609 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 2610 void attach(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 2611 this->~Callback();
<> 128:9bcdf88f62b0 2612 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2613 }
<> 128:9bcdf88f62b0 2614
<> 128:9bcdf88f62b0 2615 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 2616 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2617 * @param func Static function to attach
<> 128:9bcdf88f62b0 2618 * @deprecated
<> 128:9bcdf88f62b0 2619 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 2620 */
<> 130:d75b3fe1f5cb 2621 template <typename T, typename U>
<> 128:9bcdf88f62b0 2622 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2623 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 2624 void attach(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 2625 this->~Callback();
<> 128:9bcdf88f62b0 2626 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2627 }
<> 128:9bcdf88f62b0 2628
<> 128:9bcdf88f62b0 2629 /** Assign a callback
<> 128:9bcdf88f62b0 2630 */
<> 128:9bcdf88f62b0 2631 Callback &operator=(const Callback &that) {
<> 128:9bcdf88f62b0 2632 if (this != &that) {
<> 128:9bcdf88f62b0 2633 this->~Callback();
<> 128:9bcdf88f62b0 2634 new (this) Callback(that);
<> 128:9bcdf88f62b0 2635 }
<> 128:9bcdf88f62b0 2636
<> 128:9bcdf88f62b0 2637 return *this;
<> 128:9bcdf88f62b0 2638 }
<> 128:9bcdf88f62b0 2639
<> 128:9bcdf88f62b0 2640 /** Call the attached function
<> 128:9bcdf88f62b0 2641 */
<> 128:9bcdf88f62b0 2642 R call(A0 a0, A1 a1, A2 a2, A3 a3) const {
<> 128:9bcdf88f62b0 2643 MBED_ASSERT(_ops);
<> 128:9bcdf88f62b0 2644 return _ops->call(this, a0, a1, a2, a3);
<> 128:9bcdf88f62b0 2645 }
<> 128:9bcdf88f62b0 2646
<> 128:9bcdf88f62b0 2647 /** Call the attached function
<> 128:9bcdf88f62b0 2648 */
<> 128:9bcdf88f62b0 2649 R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const {
<> 128:9bcdf88f62b0 2650 return call(a0, a1, a2, a3);
<> 128:9bcdf88f62b0 2651 }
<> 128:9bcdf88f62b0 2652
<> 128:9bcdf88f62b0 2653 /** Test if function has been attached
<> 128:9bcdf88f62b0 2654 */
<> 128:9bcdf88f62b0 2655 operator bool() const {
<> 128:9bcdf88f62b0 2656 return _ops;
<> 128:9bcdf88f62b0 2657 }
<> 128:9bcdf88f62b0 2658
<> 128:9bcdf88f62b0 2659 /** Test for equality
<> 128:9bcdf88f62b0 2660 */
<> 128:9bcdf88f62b0 2661 friend bool operator==(const Callback &l, const Callback &r) {
<> 128:9bcdf88f62b0 2662 return memcmp(&l, &r, sizeof(Callback)) == 0;
<> 128:9bcdf88f62b0 2663 }
<> 128:9bcdf88f62b0 2664
<> 128:9bcdf88f62b0 2665 /** Test for inequality
<> 128:9bcdf88f62b0 2666 */
<> 128:9bcdf88f62b0 2667 friend bool operator!=(const Callback &l, const Callback &r) {
<> 128:9bcdf88f62b0 2668 return !(l == r);
<> 128:9bcdf88f62b0 2669 }
<> 128:9bcdf88f62b0 2670
<> 128:9bcdf88f62b0 2671 /** Static thunk for passing as C-style function
<> 128:9bcdf88f62b0 2672 * @param func Callback to call passed as void pointer
<> 128:9bcdf88f62b0 2673 */
<> 128:9bcdf88f62b0 2674 static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3) {
<> 128:9bcdf88f62b0 2675 return static_cast<Callback*>(func)->call(a0, a1, a2, a3);
<> 128:9bcdf88f62b0 2676 }
<> 128:9bcdf88f62b0 2677
<> 128:9bcdf88f62b0 2678 private:
<> 128:9bcdf88f62b0 2679 // Stored as pointer to function and pointer to optional object
<> 128:9bcdf88f62b0 2680 // Function pointer is stored as union of possible function types
<> 128:9bcdf88f62b0 2681 // to garuntee proper size and alignment
<> 128:9bcdf88f62b0 2682 struct _class;
<> 128:9bcdf88f62b0 2683 union {
<> 128:9bcdf88f62b0 2684 void (*_staticfunc)(A0, A1, A2, A3);
<> 128:9bcdf88f62b0 2685 void (*_boundfunc)(_class*, A0, A1, A2, A3);
<> 128:9bcdf88f62b0 2686 void (_class::*_methodfunc)(A0, A1, A2, A3);
<> 128:9bcdf88f62b0 2687 } _func;
<> 128:9bcdf88f62b0 2688 void *_obj;
<> 128:9bcdf88f62b0 2689
<> 128:9bcdf88f62b0 2690 // Dynamically dispatched operations
<> 128:9bcdf88f62b0 2691 const struct ops {
<> 128:9bcdf88f62b0 2692 R (*call)(const void*, A0, A1, A2, A3);
<> 128:9bcdf88f62b0 2693 void (*move)(void*, const void*);
<> 128:9bcdf88f62b0 2694 void (*dtor)(void*);
<> 128:9bcdf88f62b0 2695 } *_ops;
<> 128:9bcdf88f62b0 2696
<> 128:9bcdf88f62b0 2697 // Generate operations for function object
<> 128:9bcdf88f62b0 2698 template <typename F>
<> 128:9bcdf88f62b0 2699 void generate(const F &f) {
<> 128:9bcdf88f62b0 2700 static const ops ops = {
<> 128:9bcdf88f62b0 2701 &Callback::function_call<F>,
<> 128:9bcdf88f62b0 2702 &Callback::function_move<F>,
<> 128:9bcdf88f62b0 2703 &Callback::function_dtor<F>,
<> 128:9bcdf88f62b0 2704 };
<> 128:9bcdf88f62b0 2705
<> 130:d75b3fe1f5cb 2706 MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F),
<> 130:d75b3fe1f5cb 2707 "Type F must not exceed the size of the Callback class");
<> 128:9bcdf88f62b0 2708 new (this) F(f);
<> 128:9bcdf88f62b0 2709 _ops = &ops;
<> 128:9bcdf88f62b0 2710 }
<> 128:9bcdf88f62b0 2711
<> 128:9bcdf88f62b0 2712 // Function attributes
<> 128:9bcdf88f62b0 2713 template <typename F>
<> 128:9bcdf88f62b0 2714 static R function_call(const void *p, A0 a0, A1 a1, A2 a2, A3 a3) {
<> 128:9bcdf88f62b0 2715 return (*(F*)p)(a0, a1, a2, a3);
<> 128:9bcdf88f62b0 2716 }
<> 128:9bcdf88f62b0 2717
<> 128:9bcdf88f62b0 2718 template <typename F>
<> 128:9bcdf88f62b0 2719 static void function_move(void *d, const void *p) {
<> 128:9bcdf88f62b0 2720 new (d) F(*(F*)p);
<> 128:9bcdf88f62b0 2721 }
<> 128:9bcdf88f62b0 2722
<> 128:9bcdf88f62b0 2723 template <typename F>
<> 128:9bcdf88f62b0 2724 static void function_dtor(void *p) {
<> 128:9bcdf88f62b0 2725 ((F*)p)->~F();
<> 128:9bcdf88f62b0 2726 }
<> 128:9bcdf88f62b0 2727
<> 128:9bcdf88f62b0 2728 // Wrappers for functions with context
<> 128:9bcdf88f62b0 2729 template <typename O, typename M>
<> 128:9bcdf88f62b0 2730 struct method_context {
<> 128:9bcdf88f62b0 2731 M method;
<> 128:9bcdf88f62b0 2732 O *obj;
<> 128:9bcdf88f62b0 2733
<> 128:9bcdf88f62b0 2734 method_context(O *obj, M method)
<> 128:9bcdf88f62b0 2735 : method(method), obj(obj) {}
<> 128:9bcdf88f62b0 2736
<> 128:9bcdf88f62b0 2737 R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const {
<> 128:9bcdf88f62b0 2738 return (obj->*method)(a0, a1, a2, a3);
<> 128:9bcdf88f62b0 2739 }
<> 128:9bcdf88f62b0 2740 };
<> 128:9bcdf88f62b0 2741
<> 128:9bcdf88f62b0 2742 template <typename F, typename A>
<> 128:9bcdf88f62b0 2743 struct function_context {
<> 128:9bcdf88f62b0 2744 F func;
<> 128:9bcdf88f62b0 2745 A *arg;
<> 128:9bcdf88f62b0 2746
<> 128:9bcdf88f62b0 2747 function_context(F func, A *arg)
<> 128:9bcdf88f62b0 2748 : func(func), arg(arg) {}
<> 128:9bcdf88f62b0 2749
<> 128:9bcdf88f62b0 2750 R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const {
<> 128:9bcdf88f62b0 2751 return func(arg, a0, a1, a2, a3);
<> 128:9bcdf88f62b0 2752 }
<> 128:9bcdf88f62b0 2753 };
<> 128:9bcdf88f62b0 2754 };
<> 128:9bcdf88f62b0 2755
<> 128:9bcdf88f62b0 2756 /** Callback class based on template specialization
<> 128:9bcdf88f62b0 2757 *
<> 128:9bcdf88f62b0 2758 * @Note Synchronization level: Not protected
<> 128:9bcdf88f62b0 2759 */
<> 128:9bcdf88f62b0 2760 template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 128:9bcdf88f62b0 2761 class Callback<R(A0, A1, A2, A3, A4)> {
<> 128:9bcdf88f62b0 2762 public:
<> 128:9bcdf88f62b0 2763 /** Create a Callback with a static function
<> 128:9bcdf88f62b0 2764 * @param func Static function to attach
<> 128:9bcdf88f62b0 2765 */
<> 128:9bcdf88f62b0 2766 Callback(R (*func)(A0, A1, A2, A3, A4) = 0) {
<> 128:9bcdf88f62b0 2767 if (!func) {
<> 128:9bcdf88f62b0 2768 _ops = 0;
<> 128:9bcdf88f62b0 2769 } else {
<> 128:9bcdf88f62b0 2770 generate(func);
<> 128:9bcdf88f62b0 2771 }
<> 128:9bcdf88f62b0 2772 }
<> 128:9bcdf88f62b0 2773
<> 128:9bcdf88f62b0 2774 /** Attach a Callback
<> 128:9bcdf88f62b0 2775 * @param func The Callback to attach
<> 128:9bcdf88f62b0 2776 */
<> 128:9bcdf88f62b0 2777 Callback(const Callback<R(A0, A1, A2, A3, A4)> &func) {
<> 128:9bcdf88f62b0 2778 if (func._ops) {
<> 128:9bcdf88f62b0 2779 func._ops->move(this, &func);
<> 128:9bcdf88f62b0 2780 }
<> 128:9bcdf88f62b0 2781 _ops = func._ops;
<> 128:9bcdf88f62b0 2782 }
<> 128:9bcdf88f62b0 2783
<> 128:9bcdf88f62b0 2784 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 2785 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2786 * @param method Member function to attach
<> 128:9bcdf88f62b0 2787 */
<> 130:d75b3fe1f5cb 2788 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2789 Callback(U *obj, R (T::*method)(A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 2790 generate(method_context<T, R (T::*)(A0, A1, A2, A3, A4)>(obj, method));
<> 128:9bcdf88f62b0 2791 }
<> 128:9bcdf88f62b0 2792
<> 128:9bcdf88f62b0 2793 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 2794 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2795 * @param method Member function to attach
<> 128:9bcdf88f62b0 2796 */
<> 130:d75b3fe1f5cb 2797 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2798 Callback(const U *obj, R (T::*method)(A0, A1, A2, A3, A4) const) {
<> 128:9bcdf88f62b0 2799 generate(method_context<const T, R (T::*)(A0, A1, A2, A3, A4) const>(obj, method));
<> 128:9bcdf88f62b0 2800 }
<> 128:9bcdf88f62b0 2801
<> 128:9bcdf88f62b0 2802 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 2803 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2804 * @param method Member function to attach
<> 128:9bcdf88f62b0 2805 */
<> 130:d75b3fe1f5cb 2806 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2807 Callback(volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) {
<> 128:9bcdf88f62b0 2808 generate(method_context<volatile T, R (T::*)(A0, A1, A2, A3, A4) volatile>(obj, method));
<> 128:9bcdf88f62b0 2809 }
<> 128:9bcdf88f62b0 2810
<> 128:9bcdf88f62b0 2811 /** Create a Callback with a member function
<> 128:9bcdf88f62b0 2812 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2813 * @param method Member function to attach
<> 128:9bcdf88f62b0 2814 */
<> 130:d75b3fe1f5cb 2815 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2816 Callback(const volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) {
<> 128:9bcdf88f62b0 2817 generate(method_context<const volatile T, R (T::*)(A0, A1, A2, A3, A4) const volatile>(obj, method));
<> 128:9bcdf88f62b0 2818 }
<> 128:9bcdf88f62b0 2819
<> 128:9bcdf88f62b0 2820 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2821 * @param func Static function to attach
<> 128:9bcdf88f62b0 2822 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 2823 */
<> 130:d75b3fe1f5cb 2824 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2825 Callback(R (*func)(T*, A0, A1, A2, A3, A4), U *arg) {
<> 128:9bcdf88f62b0 2826 generate(function_context<R (*)(T*, A0, A1, A2, A3, A4), T>(func, arg));
<> 128:9bcdf88f62b0 2827 }
<> 128:9bcdf88f62b0 2828
<> 128:9bcdf88f62b0 2829 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2830 * @param func Static function to attach
<> 128:9bcdf88f62b0 2831 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 2832 */
<> 130:d75b3fe1f5cb 2833 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2834 Callback(R (*func)(const T*, A0, A1, A2, A3, A4), const U *arg) {
<> 128:9bcdf88f62b0 2835 generate(function_context<R (*)(const T*, A0, A1, A2, A3, A4), const T>(func, arg));
<> 128:9bcdf88f62b0 2836 }
<> 128:9bcdf88f62b0 2837
<> 128:9bcdf88f62b0 2838 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2839 * @param func Static function to attach
<> 128:9bcdf88f62b0 2840 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 2841 */
<> 130:d75b3fe1f5cb 2842 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2843 Callback(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile U *arg) {
<> 128:9bcdf88f62b0 2844 generate(function_context<R (*)(volatile T*, A0, A1, A2, A3, A4), volatile T>(func, arg));
<> 128:9bcdf88f62b0 2845 }
<> 128:9bcdf88f62b0 2846
<> 128:9bcdf88f62b0 2847 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2848 * @param func Static function to attach
<> 128:9bcdf88f62b0 2849 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 2850 */
<> 130:d75b3fe1f5cb 2851 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2852 Callback(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile U *arg) {
<> 128:9bcdf88f62b0 2853 generate(function_context<R (*)(const volatile T*, A0, A1, A2, A3, A4), const volatile T>(func, arg));
<> 128:9bcdf88f62b0 2854 }
<> 128:9bcdf88f62b0 2855
<> 128:9bcdf88f62b0 2856 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 2857 * @param func Function object to attach
<> 128:9bcdf88f62b0 2858 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2859 */
<> 128:9bcdf88f62b0 2860 template <typename F>
<> 128:9bcdf88f62b0 2861 Callback(F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2862 detail::is_type<R (F::*)(A0, A1, A2, A3, A4), &F::operator()>::value &&
<> 128:9bcdf88f62b0 2863 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2864 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2865 generate(f);
<> 128:9bcdf88f62b0 2866 }
<> 128:9bcdf88f62b0 2867
<> 128:9bcdf88f62b0 2868 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 2869 * @param func Function object to attach
<> 128:9bcdf88f62b0 2870 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2871 */
<> 128:9bcdf88f62b0 2872 template <typename F>
<> 128:9bcdf88f62b0 2873 Callback(const F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2874 detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const, &F::operator()>::value &&
<> 128:9bcdf88f62b0 2875 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2876 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2877 generate(f);
<> 128:9bcdf88f62b0 2878 }
<> 128:9bcdf88f62b0 2879
<> 128:9bcdf88f62b0 2880 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 2881 * @param func Function object to attach
<> 128:9bcdf88f62b0 2882 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2883 */
<> 128:9bcdf88f62b0 2884 template <typename F>
<> 128:9bcdf88f62b0 2885 Callback(volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2886 detail::is_type<R (F::*)(A0, A1, A2, A3, A4) volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 2887 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2888 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2889 generate(f);
<> 128:9bcdf88f62b0 2890 }
<> 128:9bcdf88f62b0 2891
<> 128:9bcdf88f62b0 2892 /** Create a Callback with a function object
<> 128:9bcdf88f62b0 2893 * @param func Function object to attach
<> 128:9bcdf88f62b0 2894 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 2895 */
<> 128:9bcdf88f62b0 2896 template <typename F>
<> 128:9bcdf88f62b0 2897 Callback(const volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 2898 detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 2899 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 2900 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 2901 generate(f);
<> 128:9bcdf88f62b0 2902 }
<> 128:9bcdf88f62b0 2903
<> 128:9bcdf88f62b0 2904 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2905 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2906 * @param func Static function to attach
<> 128:9bcdf88f62b0 2907 * @deprecated
<> 128:9bcdf88f62b0 2908 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 2909 */
<> 130:d75b3fe1f5cb 2910 template<typename T, typename U>
<> 128:9bcdf88f62b0 2911 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2912 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 2913 Callback(U *obj, R (*func)(T*, A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 2914 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2915 }
<> 128:9bcdf88f62b0 2916
<> 128:9bcdf88f62b0 2917 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2918 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2919 * @param func Static function to attach
<> 128:9bcdf88f62b0 2920 * @deprecated
<> 128:9bcdf88f62b0 2921 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 2922 */
<> 130:d75b3fe1f5cb 2923 template<typename T, typename U>
<> 128:9bcdf88f62b0 2924 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2925 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 2926 Callback(const U *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 2927 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2928 }
<> 128:9bcdf88f62b0 2929
<> 128:9bcdf88f62b0 2930 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2931 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2932 * @param func Static function to attach
<> 128:9bcdf88f62b0 2933 * @deprecated
<> 128:9bcdf88f62b0 2934 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 2935 */
<> 130:d75b3fe1f5cb 2936 template<typename T, typename U>
<> 128:9bcdf88f62b0 2937 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2938 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 2939 Callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 2940 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2941 }
<> 128:9bcdf88f62b0 2942
<> 128:9bcdf88f62b0 2943 /** Create a Callback with a static function and bound pointer
<> 128:9bcdf88f62b0 2944 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 2945 * @param func Static function to attach
<> 128:9bcdf88f62b0 2946 * @deprecated
<> 128:9bcdf88f62b0 2947 * Arguments to callback have been reordered to Callback(func, arg)
<> 128:9bcdf88f62b0 2948 */
<> 130:d75b3fe1f5cb 2949 template<typename T, typename U>
<> 128:9bcdf88f62b0 2950 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 2951 "Arguments to callback have been reordered to Callback(func, arg)")
<> 130:d75b3fe1f5cb 2952 Callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 2953 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 2954 }
<> 128:9bcdf88f62b0 2955
<> 128:9bcdf88f62b0 2956 /** Destroy a callback
<> 128:9bcdf88f62b0 2957 */
<> 128:9bcdf88f62b0 2958 ~Callback() {
<> 128:9bcdf88f62b0 2959 if (_ops) {
<> 128:9bcdf88f62b0 2960 _ops->dtor(this);
<> 128:9bcdf88f62b0 2961 }
<> 128:9bcdf88f62b0 2962 }
<> 128:9bcdf88f62b0 2963
<> 128:9bcdf88f62b0 2964 /** Attach a static function
<> 128:9bcdf88f62b0 2965 * @param func Static function to attach
<> 128:9bcdf88f62b0 2966 */
<> 128:9bcdf88f62b0 2967 void attach(R (*func)(A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 2968 this->~Callback();
<> 128:9bcdf88f62b0 2969 new (this) Callback(func);
<> 128:9bcdf88f62b0 2970 }
<> 128:9bcdf88f62b0 2971
<> 128:9bcdf88f62b0 2972 /** Attach a Callback
<> 128:9bcdf88f62b0 2973 * @param func The Callback to attach
<> 128:9bcdf88f62b0 2974 */
<> 128:9bcdf88f62b0 2975 void attach(const Callback<R(A0, A1, A2, A3, A4)> &func) {
<> 128:9bcdf88f62b0 2976 this->~Callback();
<> 128:9bcdf88f62b0 2977 new (this) Callback(func);
<> 128:9bcdf88f62b0 2978 }
<> 128:9bcdf88f62b0 2979
<> 128:9bcdf88f62b0 2980 /** Attach a member function
<> 128:9bcdf88f62b0 2981 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2982 * @param method Member function to attach
<> 128:9bcdf88f62b0 2983 */
<> 130:d75b3fe1f5cb 2984 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2985 void attach(U *obj, R (T::*method)(A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 2986 this->~Callback();
<> 128:9bcdf88f62b0 2987 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 2988 }
<> 128:9bcdf88f62b0 2989
<> 128:9bcdf88f62b0 2990 /** Attach a member function
<> 128:9bcdf88f62b0 2991 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 2992 * @param method Member function to attach
<> 128:9bcdf88f62b0 2993 */
<> 130:d75b3fe1f5cb 2994 template<typename T, typename U>
<> 130:d75b3fe1f5cb 2995 void attach(const U *obj, R (T::*method)(A0, A1, A2, A3, A4) const) {
<> 128:9bcdf88f62b0 2996 this->~Callback();
<> 128:9bcdf88f62b0 2997 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 2998 }
<> 128:9bcdf88f62b0 2999
<> 128:9bcdf88f62b0 3000 /** Attach a member function
<> 128:9bcdf88f62b0 3001 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 3002 * @param method Member function to attach
<> 128:9bcdf88f62b0 3003 */
<> 130:d75b3fe1f5cb 3004 template<typename T, typename U>
<> 130:d75b3fe1f5cb 3005 void attach(volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) {
<> 128:9bcdf88f62b0 3006 this->~Callback();
<> 128:9bcdf88f62b0 3007 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 3008 }
<> 128:9bcdf88f62b0 3009
<> 128:9bcdf88f62b0 3010 /** Attach a member function
<> 128:9bcdf88f62b0 3011 * @param obj Pointer to object to invoke member function on
<> 128:9bcdf88f62b0 3012 * @param method Member function to attach
<> 128:9bcdf88f62b0 3013 */
<> 130:d75b3fe1f5cb 3014 template<typename T, typename U>
<> 130:d75b3fe1f5cb 3015 void attach(const volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) {
<> 128:9bcdf88f62b0 3016 this->~Callback();
<> 128:9bcdf88f62b0 3017 new (this) Callback(obj, method);
<> 128:9bcdf88f62b0 3018 }
<> 128:9bcdf88f62b0 3019
<> 128:9bcdf88f62b0 3020 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 3021 * @param func Static function to attach
<> 128:9bcdf88f62b0 3022 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3023 */
<> 130:d75b3fe1f5cb 3024 template <typename T, typename U>
<> 130:d75b3fe1f5cb 3025 void attach(R (*func)(T*, A0, A1, A2, A3, A4), U *arg) {
<> 128:9bcdf88f62b0 3026 this->~Callback();
<> 128:9bcdf88f62b0 3027 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 3028 }
<> 128:9bcdf88f62b0 3029
<> 128:9bcdf88f62b0 3030 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 3031 * @param func Static function to attach
<> 128:9bcdf88f62b0 3032 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3033 */
<> 130:d75b3fe1f5cb 3034 template <typename T, typename U>
<> 130:d75b3fe1f5cb 3035 void attach(R (*func)(const T*, A0, A1, A2, A3, A4), const U *arg) {
<> 128:9bcdf88f62b0 3036 this->~Callback();
<> 128:9bcdf88f62b0 3037 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 3038 }
<> 128:9bcdf88f62b0 3039
<> 128:9bcdf88f62b0 3040 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 3041 * @param func Static function to attach
<> 128:9bcdf88f62b0 3042 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3043 */
<> 130:d75b3fe1f5cb 3044 template <typename T, typename U>
<> 130:d75b3fe1f5cb 3045 void attach(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile U *arg) {
<> 128:9bcdf88f62b0 3046 this->~Callback();
<> 128:9bcdf88f62b0 3047 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 3048 }
<> 128:9bcdf88f62b0 3049
<> 128:9bcdf88f62b0 3050 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 3051 * @param func Static function to attach
<> 128:9bcdf88f62b0 3052 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3053 */
<> 130:d75b3fe1f5cb 3054 template <typename T, typename U>
<> 130:d75b3fe1f5cb 3055 void attach(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile U *arg) {
<> 128:9bcdf88f62b0 3056 this->~Callback();
<> 128:9bcdf88f62b0 3057 new (this) Callback(func, arg);
<> 128:9bcdf88f62b0 3058 }
<> 128:9bcdf88f62b0 3059
<> 128:9bcdf88f62b0 3060 /** Attach a function object
<> 128:9bcdf88f62b0 3061 * @param func Function object to attach
<> 128:9bcdf88f62b0 3062 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 3063 */
<> 128:9bcdf88f62b0 3064 template <typename F>
<> 128:9bcdf88f62b0 3065 void attach(F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 3066 detail::is_type<R (F::*)(A0, A1, A2, A3, A4), &F::operator()>::value &&
<> 128:9bcdf88f62b0 3067 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 3068 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 3069 this->~Callback();
<> 128:9bcdf88f62b0 3070 new (this) Callback(f);
<> 128:9bcdf88f62b0 3071 }
<> 128:9bcdf88f62b0 3072
<> 128:9bcdf88f62b0 3073 /** Attach a function object
<> 128:9bcdf88f62b0 3074 * @param func Function object to attach
<> 128:9bcdf88f62b0 3075 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 3076 */
<> 128:9bcdf88f62b0 3077 template <typename F>
<> 128:9bcdf88f62b0 3078 void attach(const F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 3079 detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const, &F::operator()>::value &&
<> 128:9bcdf88f62b0 3080 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 3081 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 3082 this->~Callback();
<> 128:9bcdf88f62b0 3083 new (this) Callback(f);
<> 128:9bcdf88f62b0 3084 }
<> 128:9bcdf88f62b0 3085
<> 128:9bcdf88f62b0 3086 /** Attach a function object
<> 128:9bcdf88f62b0 3087 * @param func Function object to attach
<> 128:9bcdf88f62b0 3088 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 3089 */
<> 128:9bcdf88f62b0 3090 template <typename F>
<> 128:9bcdf88f62b0 3091 void attach(volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 3092 detail::is_type<R (F::*)(A0, A1, A2, A3, A4) volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 3093 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 3094 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 3095 this->~Callback();
<> 128:9bcdf88f62b0 3096 new (this) Callback(f);
<> 128:9bcdf88f62b0 3097 }
<> 128:9bcdf88f62b0 3098
<> 128:9bcdf88f62b0 3099 /** Attach a function object
<> 128:9bcdf88f62b0 3100 * @param func Function object to attach
<> 128:9bcdf88f62b0 3101 * @note The function object is limited to a single word of storage
<> 128:9bcdf88f62b0 3102 */
<> 128:9bcdf88f62b0 3103 template <typename F>
<> 128:9bcdf88f62b0 3104 void attach(const volatile F f, typename detail::enable_if<
<> 128:9bcdf88f62b0 3105 detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const volatile, &F::operator()>::value &&
<> 128:9bcdf88f62b0 3106 sizeof(F) <= sizeof(uintptr_t)
<> 128:9bcdf88f62b0 3107 >::type = detail::nil()) {
<> 128:9bcdf88f62b0 3108 this->~Callback();
<> 128:9bcdf88f62b0 3109 new (this) Callback(f);
<> 128:9bcdf88f62b0 3110 }
<> 128:9bcdf88f62b0 3111
<> 128:9bcdf88f62b0 3112 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 3113 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 3114 * @param func Static function to attach
<> 128:9bcdf88f62b0 3115 * @deprecated
<> 128:9bcdf88f62b0 3116 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 3117 */
<> 130:d75b3fe1f5cb 3118 template <typename T, typename U>
<> 128:9bcdf88f62b0 3119 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3120 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 3121 void attach(U *obj, R (*func)(T*, A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 3122 this->~Callback();
<> 128:9bcdf88f62b0 3123 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 3124 }
<> 128:9bcdf88f62b0 3125
<> 128:9bcdf88f62b0 3126 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 3127 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 3128 * @param func Static function to attach
<> 128:9bcdf88f62b0 3129 * @deprecated
<> 128:9bcdf88f62b0 3130 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 3131 */
<> 130:d75b3fe1f5cb 3132 template <typename T, typename U>
<> 128:9bcdf88f62b0 3133 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3134 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 3135 void attach(const U *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 3136 this->~Callback();
<> 128:9bcdf88f62b0 3137 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 3138 }
<> 128:9bcdf88f62b0 3139
<> 128:9bcdf88f62b0 3140 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 3141 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 3142 * @param func Static function to attach
<> 128:9bcdf88f62b0 3143 * @deprecated
<> 128:9bcdf88f62b0 3144 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 3145 */
<> 130:d75b3fe1f5cb 3146 template <typename T, typename U>
<> 128:9bcdf88f62b0 3147 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3148 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 3149 void attach(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 3150 this->~Callback();
<> 128:9bcdf88f62b0 3151 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 3152 }
<> 128:9bcdf88f62b0 3153
<> 128:9bcdf88f62b0 3154 /** Attach a static function with a bound pointer
<> 128:9bcdf88f62b0 3155 * @param obj Pointer to object to bind to function
<> 128:9bcdf88f62b0 3156 * @param func Static function to attach
<> 128:9bcdf88f62b0 3157 * @deprecated
<> 128:9bcdf88f62b0 3158 * Arguments to callback have been reordered to attach(func, arg)
<> 128:9bcdf88f62b0 3159 */
<> 130:d75b3fe1f5cb 3160 template <typename T, typename U>
<> 128:9bcdf88f62b0 3161 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3162 "Arguments to callback have been reordered to attach(func, arg)")
<> 130:d75b3fe1f5cb 3163 void attach(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 3164 this->~Callback();
<> 128:9bcdf88f62b0 3165 new (this) Callback(func, obj);
<> 128:9bcdf88f62b0 3166 }
<> 128:9bcdf88f62b0 3167
<> 128:9bcdf88f62b0 3168 /** Assign a callback
<> 128:9bcdf88f62b0 3169 */
<> 128:9bcdf88f62b0 3170 Callback &operator=(const Callback &that) {
<> 128:9bcdf88f62b0 3171 if (this != &that) {
<> 128:9bcdf88f62b0 3172 this->~Callback();
<> 128:9bcdf88f62b0 3173 new (this) Callback(that);
<> 128:9bcdf88f62b0 3174 }
<> 128:9bcdf88f62b0 3175
<> 128:9bcdf88f62b0 3176 return *this;
<> 128:9bcdf88f62b0 3177 }
<> 128:9bcdf88f62b0 3178
<> 128:9bcdf88f62b0 3179 /** Call the attached function
<> 128:9bcdf88f62b0 3180 */
<> 128:9bcdf88f62b0 3181 R call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const {
<> 128:9bcdf88f62b0 3182 MBED_ASSERT(_ops);
<> 128:9bcdf88f62b0 3183 return _ops->call(this, a0, a1, a2, a3, a4);
<> 128:9bcdf88f62b0 3184 }
<> 128:9bcdf88f62b0 3185
<> 128:9bcdf88f62b0 3186 /** Call the attached function
<> 128:9bcdf88f62b0 3187 */
<> 128:9bcdf88f62b0 3188 R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const {
<> 128:9bcdf88f62b0 3189 return call(a0, a1, a2, a3, a4);
<> 128:9bcdf88f62b0 3190 }
<> 128:9bcdf88f62b0 3191
<> 128:9bcdf88f62b0 3192 /** Test if function has been attached
<> 128:9bcdf88f62b0 3193 */
<> 128:9bcdf88f62b0 3194 operator bool() const {
<> 128:9bcdf88f62b0 3195 return _ops;
<> 128:9bcdf88f62b0 3196 }
<> 128:9bcdf88f62b0 3197
<> 128:9bcdf88f62b0 3198 /** Test for equality
<> 128:9bcdf88f62b0 3199 */
<> 128:9bcdf88f62b0 3200 friend bool operator==(const Callback &l, const Callback &r) {
<> 128:9bcdf88f62b0 3201 return memcmp(&l, &r, sizeof(Callback)) == 0;
<> 128:9bcdf88f62b0 3202 }
<> 128:9bcdf88f62b0 3203
<> 128:9bcdf88f62b0 3204 /** Test for inequality
<> 128:9bcdf88f62b0 3205 */
<> 128:9bcdf88f62b0 3206 friend bool operator!=(const Callback &l, const Callback &r) {
<> 128:9bcdf88f62b0 3207 return !(l == r);
<> 128:9bcdf88f62b0 3208 }
<> 128:9bcdf88f62b0 3209
<> 128:9bcdf88f62b0 3210 /** Static thunk for passing as C-style function
<> 128:9bcdf88f62b0 3211 * @param func Callback to call passed as void pointer
<> 128:9bcdf88f62b0 3212 */
<> 128:9bcdf88f62b0 3213 static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
<> 128:9bcdf88f62b0 3214 return static_cast<Callback*>(func)->call(a0, a1, a2, a3, a4);
<> 128:9bcdf88f62b0 3215 }
<> 128:9bcdf88f62b0 3216
<> 128:9bcdf88f62b0 3217 private:
<> 128:9bcdf88f62b0 3218 // Stored as pointer to function and pointer to optional object
<> 128:9bcdf88f62b0 3219 // Function pointer is stored as union of possible function types
<> 128:9bcdf88f62b0 3220 // to garuntee proper size and alignment
<> 128:9bcdf88f62b0 3221 struct _class;
<> 128:9bcdf88f62b0 3222 union {
<> 128:9bcdf88f62b0 3223 void (*_staticfunc)(A0, A1, A2, A3, A4);
<> 128:9bcdf88f62b0 3224 void (*_boundfunc)(_class*, A0, A1, A2, A3, A4);
<> 128:9bcdf88f62b0 3225 void (_class::*_methodfunc)(A0, A1, A2, A3, A4);
<> 128:9bcdf88f62b0 3226 } _func;
<> 128:9bcdf88f62b0 3227 void *_obj;
<> 128:9bcdf88f62b0 3228
<> 128:9bcdf88f62b0 3229 // Dynamically dispatched operations
<> 128:9bcdf88f62b0 3230 const struct ops {
<> 128:9bcdf88f62b0 3231 R (*call)(const void*, A0, A1, A2, A3, A4);
<> 128:9bcdf88f62b0 3232 void (*move)(void*, const void*);
<> 128:9bcdf88f62b0 3233 void (*dtor)(void*);
<> 128:9bcdf88f62b0 3234 } *_ops;
<> 128:9bcdf88f62b0 3235
<> 128:9bcdf88f62b0 3236 // Generate operations for function object
<> 128:9bcdf88f62b0 3237 template <typename F>
<> 128:9bcdf88f62b0 3238 void generate(const F &f) {
<> 128:9bcdf88f62b0 3239 static const ops ops = {
<> 128:9bcdf88f62b0 3240 &Callback::function_call<F>,
<> 128:9bcdf88f62b0 3241 &Callback::function_move<F>,
<> 128:9bcdf88f62b0 3242 &Callback::function_dtor<F>,
<> 128:9bcdf88f62b0 3243 };
<> 128:9bcdf88f62b0 3244
<> 130:d75b3fe1f5cb 3245 MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F),
<> 130:d75b3fe1f5cb 3246 "Type F must not exceed the size of the Callback class");
<> 128:9bcdf88f62b0 3247 new (this) F(f);
<> 128:9bcdf88f62b0 3248 _ops = &ops;
<> 128:9bcdf88f62b0 3249 }
<> 128:9bcdf88f62b0 3250
<> 128:9bcdf88f62b0 3251 // Function attributes
<> 128:9bcdf88f62b0 3252 template <typename F>
<> 128:9bcdf88f62b0 3253 static R function_call(const void *p, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
<> 128:9bcdf88f62b0 3254 return (*(F*)p)(a0, a1, a2, a3, a4);
<> 128:9bcdf88f62b0 3255 }
<> 128:9bcdf88f62b0 3256
<> 128:9bcdf88f62b0 3257 template <typename F>
<> 128:9bcdf88f62b0 3258 static void function_move(void *d, const void *p) {
<> 128:9bcdf88f62b0 3259 new (d) F(*(F*)p);
<> 128:9bcdf88f62b0 3260 }
<> 128:9bcdf88f62b0 3261
<> 128:9bcdf88f62b0 3262 template <typename F>
<> 128:9bcdf88f62b0 3263 static void function_dtor(void *p) {
<> 128:9bcdf88f62b0 3264 ((F*)p)->~F();
<> 128:9bcdf88f62b0 3265 }
<> 128:9bcdf88f62b0 3266
<> 128:9bcdf88f62b0 3267 // Wrappers for functions with context
<> 128:9bcdf88f62b0 3268 template <typename O, typename M>
<> 128:9bcdf88f62b0 3269 struct method_context {
<> 128:9bcdf88f62b0 3270 M method;
<> 128:9bcdf88f62b0 3271 O *obj;
<> 128:9bcdf88f62b0 3272
<> 128:9bcdf88f62b0 3273 method_context(O *obj, M method)
<> 128:9bcdf88f62b0 3274 : method(method), obj(obj) {}
<> 128:9bcdf88f62b0 3275
<> 128:9bcdf88f62b0 3276 R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const {
<> 128:9bcdf88f62b0 3277 return (obj->*method)(a0, a1, a2, a3, a4);
<> 128:9bcdf88f62b0 3278 }
<> 128:9bcdf88f62b0 3279 };
<> 128:9bcdf88f62b0 3280
<> 128:9bcdf88f62b0 3281 template <typename F, typename A>
<> 128:9bcdf88f62b0 3282 struct function_context {
<> 128:9bcdf88f62b0 3283 F func;
<> 128:9bcdf88f62b0 3284 A *arg;
<> 128:9bcdf88f62b0 3285
<> 128:9bcdf88f62b0 3286 function_context(F func, A *arg)
<> 128:9bcdf88f62b0 3287 : func(func), arg(arg) {}
<> 128:9bcdf88f62b0 3288
<> 128:9bcdf88f62b0 3289 R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const {
<> 128:9bcdf88f62b0 3290 return func(arg, a0, a1, a2, a3, a4);
<> 128:9bcdf88f62b0 3291 }
<> 128:9bcdf88f62b0 3292 };
<> 128:9bcdf88f62b0 3293 };
<> 128:9bcdf88f62b0 3294
<> 128:9bcdf88f62b0 3295 // Internally used event type
<> 128:9bcdf88f62b0 3296 typedef Callback<void(int)> event_callback_t;
<> 128:9bcdf88f62b0 3297
<> 128:9bcdf88f62b0 3298
<> 128:9bcdf88f62b0 3299 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3300 *
<> 128:9bcdf88f62b0 3301 * @param func Static function to attach
<> 128:9bcdf88f62b0 3302 * @return Callback with infered type
<> 128:9bcdf88f62b0 3303 */
<> 128:9bcdf88f62b0 3304 template <typename R>
<> 128:9bcdf88f62b0 3305 Callback<R()> callback(R (*func)() = 0) {
<> 128:9bcdf88f62b0 3306 return Callback<R()>(func);
<> 128:9bcdf88f62b0 3307 }
<> 128:9bcdf88f62b0 3308
<> 128:9bcdf88f62b0 3309 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3310 *
<> 128:9bcdf88f62b0 3311 * @param func Static function to attach
<> 128:9bcdf88f62b0 3312 * @return Callback with infered type
<> 128:9bcdf88f62b0 3313 */
<> 128:9bcdf88f62b0 3314 template <typename R>
<> 128:9bcdf88f62b0 3315 Callback<R()> callback(const Callback<R()> &func) {
<> 128:9bcdf88f62b0 3316 return Callback<R()>(func);
<> 128:9bcdf88f62b0 3317 }
<> 128:9bcdf88f62b0 3318
<> 128:9bcdf88f62b0 3319 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3320 *
<> 128:9bcdf88f62b0 3321 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3322 * @param method Member function to attach
<> 128:9bcdf88f62b0 3323 * @return Callback with infered type
<> 128:9bcdf88f62b0 3324 */
<> 130:d75b3fe1f5cb 3325 template<typename T, typename U, typename R>
<> 130:d75b3fe1f5cb 3326 Callback<R()> callback(U *obj, R (T::*method)()) {
<> 130:d75b3fe1f5cb 3327 return Callback<R()>(obj, method);
<> 128:9bcdf88f62b0 3328 }
<> 128:9bcdf88f62b0 3329
<> 128:9bcdf88f62b0 3330 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3331 *
<> 128:9bcdf88f62b0 3332 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3333 * @param method Member function to attach
<> 128:9bcdf88f62b0 3334 * @return Callback with infered type
<> 128:9bcdf88f62b0 3335 */
<> 130:d75b3fe1f5cb 3336 template<typename T, typename U, typename R>
<> 130:d75b3fe1f5cb 3337 Callback<R()> callback(const U *obj, R (T::*method)() const) {
<> 130:d75b3fe1f5cb 3338 return Callback<R()>(obj, method);
<> 128:9bcdf88f62b0 3339 }
<> 128:9bcdf88f62b0 3340
<> 128:9bcdf88f62b0 3341 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3342 *
<> 128:9bcdf88f62b0 3343 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3344 * @param method Member function to attach
<> 128:9bcdf88f62b0 3345 * @return Callback with infered type
<> 128:9bcdf88f62b0 3346 */
<> 130:d75b3fe1f5cb 3347 template<typename T, typename U, typename R>
<> 130:d75b3fe1f5cb 3348 Callback<R()> callback(volatile U *obj, R (T::*method)() volatile) {
<> 130:d75b3fe1f5cb 3349 return Callback<R()>(obj, method);
<> 128:9bcdf88f62b0 3350 }
<> 128:9bcdf88f62b0 3351
<> 128:9bcdf88f62b0 3352 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3353 *
<> 128:9bcdf88f62b0 3354 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3355 * @param method Member function to attach
<> 128:9bcdf88f62b0 3356 * @return Callback with infered type
<> 128:9bcdf88f62b0 3357 */
<> 130:d75b3fe1f5cb 3358 template<typename T, typename U, typename R>
<> 130:d75b3fe1f5cb 3359 Callback<R()> callback(const volatile U *obj, R (T::*method)() const volatile) {
<> 130:d75b3fe1f5cb 3360 return Callback<R()>(obj, method);
<> 128:9bcdf88f62b0 3361 }
<> 128:9bcdf88f62b0 3362
<> 128:9bcdf88f62b0 3363 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3364 *
<> 128:9bcdf88f62b0 3365 * @param func Static function to attach
<> 128:9bcdf88f62b0 3366 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3367 * @return Callback with infered type
<> 128:9bcdf88f62b0 3368 */
<> 130:d75b3fe1f5cb 3369 template <typename T, typename U, typename R>
<> 130:d75b3fe1f5cb 3370 Callback<R()> callback(R (*func)(T*), U *arg) {
<> 128:9bcdf88f62b0 3371 return Callback<R()>(func, arg);
<> 128:9bcdf88f62b0 3372 }
<> 128:9bcdf88f62b0 3373
<> 128:9bcdf88f62b0 3374 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3375 *
<> 128:9bcdf88f62b0 3376 * @param func Static function to attach
<> 128:9bcdf88f62b0 3377 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3378 * @return Callback with infered type
<> 128:9bcdf88f62b0 3379 */
<> 130:d75b3fe1f5cb 3380 template <typename T, typename U, typename R>
<> 130:d75b3fe1f5cb 3381 Callback<R()> callback(R (*func)(const T*), const U *arg) {
<> 128:9bcdf88f62b0 3382 return Callback<R()>(func, arg);
<> 128:9bcdf88f62b0 3383 }
<> 128:9bcdf88f62b0 3384
<> 128:9bcdf88f62b0 3385 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3386 *
<> 128:9bcdf88f62b0 3387 * @param func Static function to attach
<> 128:9bcdf88f62b0 3388 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3389 * @return Callback with infered type
<> 128:9bcdf88f62b0 3390 */
<> 130:d75b3fe1f5cb 3391 template <typename T, typename U, typename R>
<> 130:d75b3fe1f5cb 3392 Callback<R()> callback(R (*func)(volatile T*), volatile U *arg) {
<> 128:9bcdf88f62b0 3393 return Callback<R()>(func, arg);
<> 128:9bcdf88f62b0 3394 }
<> 128:9bcdf88f62b0 3395
<> 128:9bcdf88f62b0 3396 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3397 *
<> 128:9bcdf88f62b0 3398 * @param func Static function to attach
<> 128:9bcdf88f62b0 3399 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3400 * @return Callback with infered type
<> 128:9bcdf88f62b0 3401 */
<> 130:d75b3fe1f5cb 3402 template <typename T, typename U, typename R>
<> 130:d75b3fe1f5cb 3403 Callback<R()> callback(R (*func)(const volatile T*), const volatile U *arg) {
<> 128:9bcdf88f62b0 3404 return Callback<R()>(func, arg);
<> 128:9bcdf88f62b0 3405 }
<> 128:9bcdf88f62b0 3406
<> 128:9bcdf88f62b0 3407 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3408 *
<> 128:9bcdf88f62b0 3409 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3410 * @param func Static function to attach
<> 128:9bcdf88f62b0 3411 * @return Callback with infered type
<> 128:9bcdf88f62b0 3412 * @deprecated
<> 128:9bcdf88f62b0 3413 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3414 */
<> 130:d75b3fe1f5cb 3415 template <typename T, typename U, typename R>
<> 128:9bcdf88f62b0 3416 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3417 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3418 Callback<R()> callback(U *obj, R (*func)(T*)) {
<> 128:9bcdf88f62b0 3419 return Callback<R()>(func, obj);
<> 128:9bcdf88f62b0 3420 }
<> 128:9bcdf88f62b0 3421
<> 128:9bcdf88f62b0 3422 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3423 *
<> 128:9bcdf88f62b0 3424 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3425 * @param func Static function to attach
<> 128:9bcdf88f62b0 3426 * @return Callback with infered type
<> 128:9bcdf88f62b0 3427 * @deprecated
<> 128:9bcdf88f62b0 3428 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3429 */
<> 130:d75b3fe1f5cb 3430 template <typename T, typename U, typename R>
<> 128:9bcdf88f62b0 3431 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3432 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3433 Callback<R()> callback(const U *obj, R (*func)(const T*)) {
<> 128:9bcdf88f62b0 3434 return Callback<R()>(func, obj);
<> 128:9bcdf88f62b0 3435 }
<> 128:9bcdf88f62b0 3436
<> 128:9bcdf88f62b0 3437 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3438 *
<> 128:9bcdf88f62b0 3439 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3440 * @param func Static function to attach
<> 128:9bcdf88f62b0 3441 * @return Callback with infered type
<> 128:9bcdf88f62b0 3442 * @deprecated
<> 128:9bcdf88f62b0 3443 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3444 */
<> 130:d75b3fe1f5cb 3445 template <typename T, typename U, typename R>
<> 128:9bcdf88f62b0 3446 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3447 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3448 Callback<R()> callback(volatile U *obj, R (*func)(volatile T*)) {
<> 128:9bcdf88f62b0 3449 return Callback<R()>(func, obj);
<> 128:9bcdf88f62b0 3450 }
<> 128:9bcdf88f62b0 3451
<> 128:9bcdf88f62b0 3452 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3453 *
<> 128:9bcdf88f62b0 3454 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3455 * @param func Static function to attach
<> 128:9bcdf88f62b0 3456 * @return Callback with infered type
<> 128:9bcdf88f62b0 3457 * @deprecated
<> 128:9bcdf88f62b0 3458 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3459 */
<> 130:d75b3fe1f5cb 3460 template <typename T, typename U, typename R>
<> 128:9bcdf88f62b0 3461 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3462 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3463 Callback<R()> callback(const volatile U *obj, R (*func)(const volatile T*)) {
<> 128:9bcdf88f62b0 3464 return Callback<R()>(func, obj);
<> 128:9bcdf88f62b0 3465 }
<> 128:9bcdf88f62b0 3466
<> 128:9bcdf88f62b0 3467
<> 128:9bcdf88f62b0 3468 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3469 *
<> 128:9bcdf88f62b0 3470 * @param func Static function to attach
<> 128:9bcdf88f62b0 3471 * @return Callback with infered type
<> 128:9bcdf88f62b0 3472 */
<> 128:9bcdf88f62b0 3473 template <typename R, typename A0>
<> 128:9bcdf88f62b0 3474 Callback<R(A0)> callback(R (*func)(A0) = 0) {
<> 128:9bcdf88f62b0 3475 return Callback<R(A0)>(func);
<> 128:9bcdf88f62b0 3476 }
<> 128:9bcdf88f62b0 3477
<> 128:9bcdf88f62b0 3478 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3479 *
<> 128:9bcdf88f62b0 3480 * @param func Static function to attach
<> 128:9bcdf88f62b0 3481 * @return Callback with infered type
<> 128:9bcdf88f62b0 3482 */
<> 128:9bcdf88f62b0 3483 template <typename R, typename A0>
<> 128:9bcdf88f62b0 3484 Callback<R(A0)> callback(const Callback<R(A0)> &func) {
<> 128:9bcdf88f62b0 3485 return Callback<R(A0)>(func);
<> 128:9bcdf88f62b0 3486 }
<> 128:9bcdf88f62b0 3487
<> 128:9bcdf88f62b0 3488 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3489 *
<> 128:9bcdf88f62b0 3490 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3491 * @param method Member function to attach
<> 128:9bcdf88f62b0 3492 * @return Callback with infered type
<> 128:9bcdf88f62b0 3493 */
<> 130:d75b3fe1f5cb 3494 template<typename T, typename U, typename R, typename A0>
<> 130:d75b3fe1f5cb 3495 Callback<R(A0)> callback(U *obj, R (T::*method)(A0)) {
<> 130:d75b3fe1f5cb 3496 return Callback<R(A0)>(obj, method);
<> 128:9bcdf88f62b0 3497 }
<> 128:9bcdf88f62b0 3498
<> 128:9bcdf88f62b0 3499 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3500 *
<> 128:9bcdf88f62b0 3501 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3502 * @param method Member function to attach
<> 128:9bcdf88f62b0 3503 * @return Callback with infered type
<> 128:9bcdf88f62b0 3504 */
<> 130:d75b3fe1f5cb 3505 template<typename T, typename U, typename R, typename A0>
<> 130:d75b3fe1f5cb 3506 Callback<R(A0)> callback(const U *obj, R (T::*method)(A0) const) {
<> 130:d75b3fe1f5cb 3507 return Callback<R(A0)>(obj, method);
<> 128:9bcdf88f62b0 3508 }
<> 128:9bcdf88f62b0 3509
<> 128:9bcdf88f62b0 3510 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3511 *
<> 128:9bcdf88f62b0 3512 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3513 * @param method Member function to attach
<> 128:9bcdf88f62b0 3514 * @return Callback with infered type
<> 128:9bcdf88f62b0 3515 */
<> 130:d75b3fe1f5cb 3516 template<typename T, typename U, typename R, typename A0>
<> 130:d75b3fe1f5cb 3517 Callback<R(A0)> callback(volatile U *obj, R (T::*method)(A0) volatile) {
<> 130:d75b3fe1f5cb 3518 return Callback<R(A0)>(obj, method);
<> 128:9bcdf88f62b0 3519 }
<> 128:9bcdf88f62b0 3520
<> 128:9bcdf88f62b0 3521 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3522 *
<> 128:9bcdf88f62b0 3523 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3524 * @param method Member function to attach
<> 128:9bcdf88f62b0 3525 * @return Callback with infered type
<> 128:9bcdf88f62b0 3526 */
<> 130:d75b3fe1f5cb 3527 template<typename T, typename U, typename R, typename A0>
<> 130:d75b3fe1f5cb 3528 Callback<R(A0)> callback(const volatile U *obj, R (T::*method)(A0) const volatile) {
<> 130:d75b3fe1f5cb 3529 return Callback<R(A0)>(obj, method);
<> 128:9bcdf88f62b0 3530 }
<> 128:9bcdf88f62b0 3531
<> 128:9bcdf88f62b0 3532 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3533 *
<> 128:9bcdf88f62b0 3534 * @param func Static function to attach
<> 128:9bcdf88f62b0 3535 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3536 * @return Callback with infered type
<> 128:9bcdf88f62b0 3537 */
<> 130:d75b3fe1f5cb 3538 template <typename T, typename U, typename R, typename A0>
<> 130:d75b3fe1f5cb 3539 Callback<R(A0)> callback(R (*func)(T*, A0), U *arg) {
<> 128:9bcdf88f62b0 3540 return Callback<R(A0)>(func, arg);
<> 128:9bcdf88f62b0 3541 }
<> 128:9bcdf88f62b0 3542
<> 128:9bcdf88f62b0 3543 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3544 *
<> 128:9bcdf88f62b0 3545 * @param func Static function to attach
<> 128:9bcdf88f62b0 3546 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3547 * @return Callback with infered type
<> 128:9bcdf88f62b0 3548 */
<> 130:d75b3fe1f5cb 3549 template <typename T, typename U, typename R, typename A0>
<> 130:d75b3fe1f5cb 3550 Callback<R(A0)> callback(R (*func)(const T*, A0), const U *arg) {
<> 128:9bcdf88f62b0 3551 return Callback<R(A0)>(func, arg);
<> 128:9bcdf88f62b0 3552 }
<> 128:9bcdf88f62b0 3553
<> 128:9bcdf88f62b0 3554 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3555 *
<> 128:9bcdf88f62b0 3556 * @param func Static function to attach
<> 128:9bcdf88f62b0 3557 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3558 * @return Callback with infered type
<> 128:9bcdf88f62b0 3559 */
<> 130:d75b3fe1f5cb 3560 template <typename T, typename U, typename R, typename A0>
<> 130:d75b3fe1f5cb 3561 Callback<R(A0)> callback(R (*func)(volatile T*, A0), volatile U *arg) {
<> 128:9bcdf88f62b0 3562 return Callback<R(A0)>(func, arg);
<> 128:9bcdf88f62b0 3563 }
<> 128:9bcdf88f62b0 3564
<> 128:9bcdf88f62b0 3565 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3566 *
<> 128:9bcdf88f62b0 3567 * @param func Static function to attach
<> 128:9bcdf88f62b0 3568 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3569 * @return Callback with infered type
<> 128:9bcdf88f62b0 3570 */
<> 130:d75b3fe1f5cb 3571 template <typename T, typename U, typename R, typename A0>
<> 130:d75b3fe1f5cb 3572 Callback<R(A0)> callback(R (*func)(const volatile T*, A0), const volatile U *arg) {
<> 128:9bcdf88f62b0 3573 return Callback<R(A0)>(func, arg);
<> 128:9bcdf88f62b0 3574 }
<> 128:9bcdf88f62b0 3575
<> 128:9bcdf88f62b0 3576 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3577 *
<> 128:9bcdf88f62b0 3578 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3579 * @param func Static function to attach
<> 128:9bcdf88f62b0 3580 * @return Callback with infered type
<> 128:9bcdf88f62b0 3581 * @deprecated
<> 128:9bcdf88f62b0 3582 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3583 */
<> 130:d75b3fe1f5cb 3584 template <typename T, typename U, typename R, typename A0>
<> 128:9bcdf88f62b0 3585 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3586 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3587 Callback<R(A0)> callback(U *obj, R (*func)(T*, A0)) {
<> 128:9bcdf88f62b0 3588 return Callback<R(A0)>(func, obj);
<> 128:9bcdf88f62b0 3589 }
<> 128:9bcdf88f62b0 3590
<> 128:9bcdf88f62b0 3591 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3592 *
<> 128:9bcdf88f62b0 3593 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3594 * @param func Static function to attach
<> 128:9bcdf88f62b0 3595 * @return Callback with infered type
<> 128:9bcdf88f62b0 3596 * @deprecated
<> 128:9bcdf88f62b0 3597 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3598 */
<> 130:d75b3fe1f5cb 3599 template <typename T, typename U, typename R, typename A0>
<> 128:9bcdf88f62b0 3600 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3601 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3602 Callback<R(A0)> callback(const U *obj, R (*func)(const T*, A0)) {
<> 128:9bcdf88f62b0 3603 return Callback<R(A0)>(func, obj);
<> 128:9bcdf88f62b0 3604 }
<> 128:9bcdf88f62b0 3605
<> 128:9bcdf88f62b0 3606 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3607 *
<> 128:9bcdf88f62b0 3608 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3609 * @param func Static function to attach
<> 128:9bcdf88f62b0 3610 * @return Callback with infered type
<> 128:9bcdf88f62b0 3611 * @deprecated
<> 128:9bcdf88f62b0 3612 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3613 */
<> 130:d75b3fe1f5cb 3614 template <typename T, typename U, typename R, typename A0>
<> 128:9bcdf88f62b0 3615 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3616 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3617 Callback<R(A0)> callback(volatile U *obj, R (*func)(volatile T*, A0)) {
<> 128:9bcdf88f62b0 3618 return Callback<R(A0)>(func, obj);
<> 128:9bcdf88f62b0 3619 }
<> 128:9bcdf88f62b0 3620
<> 128:9bcdf88f62b0 3621 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3622 *
<> 128:9bcdf88f62b0 3623 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3624 * @param func Static function to attach
<> 128:9bcdf88f62b0 3625 * @return Callback with infered type
<> 128:9bcdf88f62b0 3626 * @deprecated
<> 128:9bcdf88f62b0 3627 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3628 */
<> 130:d75b3fe1f5cb 3629 template <typename T, typename U, typename R, typename A0>
<> 128:9bcdf88f62b0 3630 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3631 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3632 Callback<R(A0)> callback(const volatile U *obj, R (*func)(const volatile T*, A0)) {
<> 128:9bcdf88f62b0 3633 return Callback<R(A0)>(func, obj);
<> 128:9bcdf88f62b0 3634 }
<> 128:9bcdf88f62b0 3635
<> 128:9bcdf88f62b0 3636
<> 128:9bcdf88f62b0 3637 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3638 *
<> 128:9bcdf88f62b0 3639 * @param func Static function to attach
<> 128:9bcdf88f62b0 3640 * @return Callback with infered type
<> 128:9bcdf88f62b0 3641 */
<> 128:9bcdf88f62b0 3642 template <typename R, typename A0, typename A1>
<> 128:9bcdf88f62b0 3643 Callback<R(A0, A1)> callback(R (*func)(A0, A1) = 0) {
<> 128:9bcdf88f62b0 3644 return Callback<R(A0, A1)>(func);
<> 128:9bcdf88f62b0 3645 }
<> 128:9bcdf88f62b0 3646
<> 128:9bcdf88f62b0 3647 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3648 *
<> 128:9bcdf88f62b0 3649 * @param func Static function to attach
<> 128:9bcdf88f62b0 3650 * @return Callback with infered type
<> 128:9bcdf88f62b0 3651 */
<> 128:9bcdf88f62b0 3652 template <typename R, typename A0, typename A1>
<> 128:9bcdf88f62b0 3653 Callback<R(A0, A1)> callback(const Callback<R(A0, A1)> &func) {
<> 128:9bcdf88f62b0 3654 return Callback<R(A0, A1)>(func);
<> 128:9bcdf88f62b0 3655 }
<> 128:9bcdf88f62b0 3656
<> 128:9bcdf88f62b0 3657 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3658 *
<> 128:9bcdf88f62b0 3659 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3660 * @param method Member function to attach
<> 128:9bcdf88f62b0 3661 * @return Callback with infered type
<> 128:9bcdf88f62b0 3662 */
<> 130:d75b3fe1f5cb 3663 template<typename T, typename U, typename R, typename A0, typename A1>
<> 130:d75b3fe1f5cb 3664 Callback<R(A0, A1)> callback(U *obj, R (T::*method)(A0, A1)) {
<> 130:d75b3fe1f5cb 3665 return Callback<R(A0, A1)>(obj, method);
<> 128:9bcdf88f62b0 3666 }
<> 128:9bcdf88f62b0 3667
<> 128:9bcdf88f62b0 3668 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3669 *
<> 128:9bcdf88f62b0 3670 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3671 * @param method Member function to attach
<> 128:9bcdf88f62b0 3672 * @return Callback with infered type
<> 128:9bcdf88f62b0 3673 */
<> 130:d75b3fe1f5cb 3674 template<typename T, typename U, typename R, typename A0, typename A1>
<> 130:d75b3fe1f5cb 3675 Callback<R(A0, A1)> callback(const U *obj, R (T::*method)(A0, A1) const) {
<> 130:d75b3fe1f5cb 3676 return Callback<R(A0, A1)>(obj, method);
<> 128:9bcdf88f62b0 3677 }
<> 128:9bcdf88f62b0 3678
<> 128:9bcdf88f62b0 3679 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3680 *
<> 128:9bcdf88f62b0 3681 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3682 * @param method Member function to attach
<> 128:9bcdf88f62b0 3683 * @return Callback with infered type
<> 128:9bcdf88f62b0 3684 */
<> 130:d75b3fe1f5cb 3685 template<typename T, typename U, typename R, typename A0, typename A1>
<> 130:d75b3fe1f5cb 3686 Callback<R(A0, A1)> callback(volatile U *obj, R (T::*method)(A0, A1) volatile) {
<> 130:d75b3fe1f5cb 3687 return Callback<R(A0, A1)>(obj, method);
<> 128:9bcdf88f62b0 3688 }
<> 128:9bcdf88f62b0 3689
<> 128:9bcdf88f62b0 3690 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3691 *
<> 128:9bcdf88f62b0 3692 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3693 * @param method Member function to attach
<> 128:9bcdf88f62b0 3694 * @return Callback with infered type
<> 128:9bcdf88f62b0 3695 */
<> 130:d75b3fe1f5cb 3696 template<typename T, typename U, typename R, typename A0, typename A1>
<> 130:d75b3fe1f5cb 3697 Callback<R(A0, A1)> callback(const volatile U *obj, R (T::*method)(A0, A1) const volatile) {
<> 130:d75b3fe1f5cb 3698 return Callback<R(A0, A1)>(obj, method);
<> 128:9bcdf88f62b0 3699 }
<> 128:9bcdf88f62b0 3700
<> 128:9bcdf88f62b0 3701 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3702 *
<> 128:9bcdf88f62b0 3703 * @param func Static function to attach
<> 128:9bcdf88f62b0 3704 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3705 * @return Callback with infered type
<> 128:9bcdf88f62b0 3706 */
<> 130:d75b3fe1f5cb 3707 template <typename T, typename U, typename R, typename A0, typename A1>
<> 130:d75b3fe1f5cb 3708 Callback<R(A0, A1)> callback(R (*func)(T*, A0, A1), U *arg) {
<> 128:9bcdf88f62b0 3709 return Callback<R(A0, A1)>(func, arg);
<> 128:9bcdf88f62b0 3710 }
<> 128:9bcdf88f62b0 3711
<> 128:9bcdf88f62b0 3712 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3713 *
<> 128:9bcdf88f62b0 3714 * @param func Static function to attach
<> 128:9bcdf88f62b0 3715 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3716 * @return Callback with infered type
<> 128:9bcdf88f62b0 3717 */
<> 130:d75b3fe1f5cb 3718 template <typename T, typename U, typename R, typename A0, typename A1>
<> 130:d75b3fe1f5cb 3719 Callback<R(A0, A1)> callback(R (*func)(const T*, A0, A1), const U *arg) {
<> 128:9bcdf88f62b0 3720 return Callback<R(A0, A1)>(func, arg);
<> 128:9bcdf88f62b0 3721 }
<> 128:9bcdf88f62b0 3722
<> 128:9bcdf88f62b0 3723 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3724 *
<> 128:9bcdf88f62b0 3725 * @param func Static function to attach
<> 128:9bcdf88f62b0 3726 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3727 * @return Callback with infered type
<> 128:9bcdf88f62b0 3728 */
<> 130:d75b3fe1f5cb 3729 template <typename T, typename U, typename R, typename A0, typename A1>
<> 130:d75b3fe1f5cb 3730 Callback<R(A0, A1)> callback(R (*func)(volatile T*, A0, A1), volatile U *arg) {
<> 128:9bcdf88f62b0 3731 return Callback<R(A0, A1)>(func, arg);
<> 128:9bcdf88f62b0 3732 }
<> 128:9bcdf88f62b0 3733
<> 128:9bcdf88f62b0 3734 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3735 *
<> 128:9bcdf88f62b0 3736 * @param func Static function to attach
<> 128:9bcdf88f62b0 3737 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3738 * @return Callback with infered type
<> 128:9bcdf88f62b0 3739 */
<> 130:d75b3fe1f5cb 3740 template <typename T, typename U, typename R, typename A0, typename A1>
<> 130:d75b3fe1f5cb 3741 Callback<R(A0, A1)> callback(R (*func)(const volatile T*, A0, A1), const volatile U *arg) {
<> 128:9bcdf88f62b0 3742 return Callback<R(A0, A1)>(func, arg);
<> 128:9bcdf88f62b0 3743 }
<> 128:9bcdf88f62b0 3744
<> 128:9bcdf88f62b0 3745 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3746 *
<> 128:9bcdf88f62b0 3747 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3748 * @param func Static function to attach
<> 128:9bcdf88f62b0 3749 * @return Callback with infered type
<> 128:9bcdf88f62b0 3750 * @deprecated
<> 128:9bcdf88f62b0 3751 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3752 */
<> 130:d75b3fe1f5cb 3753 template <typename T, typename U, typename R, typename A0, typename A1>
<> 128:9bcdf88f62b0 3754 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3755 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3756 Callback<R(A0, A1)> callback(U *obj, R (*func)(T*, A0, A1)) {
<> 128:9bcdf88f62b0 3757 return Callback<R(A0, A1)>(func, obj);
<> 128:9bcdf88f62b0 3758 }
<> 128:9bcdf88f62b0 3759
<> 128:9bcdf88f62b0 3760 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3761 *
<> 128:9bcdf88f62b0 3762 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3763 * @param func Static function to attach
<> 128:9bcdf88f62b0 3764 * @return Callback with infered type
<> 128:9bcdf88f62b0 3765 * @deprecated
<> 128:9bcdf88f62b0 3766 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3767 */
<> 130:d75b3fe1f5cb 3768 template <typename T, typename U, typename R, typename A0, typename A1>
<> 128:9bcdf88f62b0 3769 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3770 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3771 Callback<R(A0, A1)> callback(const U *obj, R (*func)(const T*, A0, A1)) {
<> 128:9bcdf88f62b0 3772 return Callback<R(A0, A1)>(func, obj);
<> 128:9bcdf88f62b0 3773 }
<> 128:9bcdf88f62b0 3774
<> 128:9bcdf88f62b0 3775 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3776 *
<> 128:9bcdf88f62b0 3777 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3778 * @param func Static function to attach
<> 128:9bcdf88f62b0 3779 * @return Callback with infered type
<> 128:9bcdf88f62b0 3780 * @deprecated
<> 128:9bcdf88f62b0 3781 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3782 */
<> 130:d75b3fe1f5cb 3783 template <typename T, typename U, typename R, typename A0, typename A1>
<> 128:9bcdf88f62b0 3784 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3785 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3786 Callback<R(A0, A1)> callback(volatile U *obj, R (*func)(volatile T*, A0, A1)) {
<> 128:9bcdf88f62b0 3787 return Callback<R(A0, A1)>(func, obj);
<> 128:9bcdf88f62b0 3788 }
<> 128:9bcdf88f62b0 3789
<> 128:9bcdf88f62b0 3790 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3791 *
<> 128:9bcdf88f62b0 3792 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3793 * @param func Static function to attach
<> 128:9bcdf88f62b0 3794 * @return Callback with infered type
<> 128:9bcdf88f62b0 3795 * @deprecated
<> 128:9bcdf88f62b0 3796 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3797 */
<> 130:d75b3fe1f5cb 3798 template <typename T, typename U, typename R, typename A0, typename A1>
<> 128:9bcdf88f62b0 3799 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3800 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3801 Callback<R(A0, A1)> callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1)) {
<> 128:9bcdf88f62b0 3802 return Callback<R(A0, A1)>(func, obj);
<> 128:9bcdf88f62b0 3803 }
<> 128:9bcdf88f62b0 3804
<> 128:9bcdf88f62b0 3805
<> 128:9bcdf88f62b0 3806 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3807 *
<> 128:9bcdf88f62b0 3808 * @param func Static function to attach
<> 128:9bcdf88f62b0 3809 * @return Callback with infered type
<> 128:9bcdf88f62b0 3810 */
<> 128:9bcdf88f62b0 3811 template <typename R, typename A0, typename A1, typename A2>
<> 128:9bcdf88f62b0 3812 Callback<R(A0, A1, A2)> callback(R (*func)(A0, A1, A2) = 0) {
<> 128:9bcdf88f62b0 3813 return Callback<R(A0, A1, A2)>(func);
<> 128:9bcdf88f62b0 3814 }
<> 128:9bcdf88f62b0 3815
<> 128:9bcdf88f62b0 3816 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3817 *
<> 128:9bcdf88f62b0 3818 * @param func Static function to attach
<> 128:9bcdf88f62b0 3819 * @return Callback with infered type
<> 128:9bcdf88f62b0 3820 */
<> 128:9bcdf88f62b0 3821 template <typename R, typename A0, typename A1, typename A2>
<> 128:9bcdf88f62b0 3822 Callback<R(A0, A1, A2)> callback(const Callback<R(A0, A1, A2)> &func) {
<> 128:9bcdf88f62b0 3823 return Callback<R(A0, A1, A2)>(func);
<> 128:9bcdf88f62b0 3824 }
<> 128:9bcdf88f62b0 3825
<> 128:9bcdf88f62b0 3826 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3827 *
<> 128:9bcdf88f62b0 3828 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3829 * @param method Member function to attach
<> 128:9bcdf88f62b0 3830 * @return Callback with infered type
<> 128:9bcdf88f62b0 3831 */
<> 130:d75b3fe1f5cb 3832 template<typename T, typename U, typename R, typename A0, typename A1, typename A2>
<> 130:d75b3fe1f5cb 3833 Callback<R(A0, A1, A2)> callback(U *obj, R (T::*method)(A0, A1, A2)) {
<> 130:d75b3fe1f5cb 3834 return Callback<R(A0, A1, A2)>(obj, method);
<> 128:9bcdf88f62b0 3835 }
<> 128:9bcdf88f62b0 3836
<> 128:9bcdf88f62b0 3837 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3838 *
<> 128:9bcdf88f62b0 3839 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3840 * @param method Member function to attach
<> 128:9bcdf88f62b0 3841 * @return Callback with infered type
<> 128:9bcdf88f62b0 3842 */
<> 130:d75b3fe1f5cb 3843 template<typename T, typename U, typename R, typename A0, typename A1, typename A2>
<> 130:d75b3fe1f5cb 3844 Callback<R(A0, A1, A2)> callback(const U *obj, R (T::*method)(A0, A1, A2) const) {
<> 130:d75b3fe1f5cb 3845 return Callback<R(A0, A1, A2)>(obj, method);
<> 128:9bcdf88f62b0 3846 }
<> 128:9bcdf88f62b0 3847
<> 128:9bcdf88f62b0 3848 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3849 *
<> 128:9bcdf88f62b0 3850 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3851 * @param method Member function to attach
<> 128:9bcdf88f62b0 3852 * @return Callback with infered type
<> 128:9bcdf88f62b0 3853 */
<> 130:d75b3fe1f5cb 3854 template<typename T, typename U, typename R, typename A0, typename A1, typename A2>
<> 130:d75b3fe1f5cb 3855 Callback<R(A0, A1, A2)> callback(volatile U *obj, R (T::*method)(A0, A1, A2) volatile) {
<> 130:d75b3fe1f5cb 3856 return Callback<R(A0, A1, A2)>(obj, method);
<> 128:9bcdf88f62b0 3857 }
<> 128:9bcdf88f62b0 3858
<> 128:9bcdf88f62b0 3859 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3860 *
<> 128:9bcdf88f62b0 3861 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3862 * @param method Member function to attach
<> 128:9bcdf88f62b0 3863 * @return Callback with infered type
<> 128:9bcdf88f62b0 3864 */
<> 130:d75b3fe1f5cb 3865 template<typename T, typename U, typename R, typename A0, typename A1, typename A2>
<> 130:d75b3fe1f5cb 3866 Callback<R(A0, A1, A2)> callback(const volatile U *obj, R (T::*method)(A0, A1, A2) const volatile) {
<> 130:d75b3fe1f5cb 3867 return Callback<R(A0, A1, A2)>(obj, method);
<> 128:9bcdf88f62b0 3868 }
<> 128:9bcdf88f62b0 3869
<> 128:9bcdf88f62b0 3870 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3871 *
<> 128:9bcdf88f62b0 3872 * @param func Static function to attach
<> 128:9bcdf88f62b0 3873 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3874 * @return Callback with infered type
<> 128:9bcdf88f62b0 3875 */
<> 130:d75b3fe1f5cb 3876 template <typename T, typename U, typename R, typename A0, typename A1, typename A2>
<> 130:d75b3fe1f5cb 3877 Callback<R(A0, A1, A2)> callback(R (*func)(T*, A0, A1, A2), U *arg) {
<> 128:9bcdf88f62b0 3878 return Callback<R(A0, A1, A2)>(func, arg);
<> 128:9bcdf88f62b0 3879 }
<> 128:9bcdf88f62b0 3880
<> 128:9bcdf88f62b0 3881 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3882 *
<> 128:9bcdf88f62b0 3883 * @param func Static function to attach
<> 128:9bcdf88f62b0 3884 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3885 * @return Callback with infered type
<> 128:9bcdf88f62b0 3886 */
<> 130:d75b3fe1f5cb 3887 template <typename T, typename U, typename R, typename A0, typename A1, typename A2>
<> 130:d75b3fe1f5cb 3888 Callback<R(A0, A1, A2)> callback(R (*func)(const T*, A0, A1, A2), const U *arg) {
<> 128:9bcdf88f62b0 3889 return Callback<R(A0, A1, A2)>(func, arg);
<> 128:9bcdf88f62b0 3890 }
<> 128:9bcdf88f62b0 3891
<> 128:9bcdf88f62b0 3892 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3893 *
<> 128:9bcdf88f62b0 3894 * @param func Static function to attach
<> 128:9bcdf88f62b0 3895 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3896 * @return Callback with infered type
<> 128:9bcdf88f62b0 3897 */
<> 130:d75b3fe1f5cb 3898 template <typename T, typename U, typename R, typename A0, typename A1, typename A2>
<> 130:d75b3fe1f5cb 3899 Callback<R(A0, A1, A2)> callback(R (*func)(volatile T*, A0, A1, A2), volatile U *arg) {
<> 128:9bcdf88f62b0 3900 return Callback<R(A0, A1, A2)>(func, arg);
<> 128:9bcdf88f62b0 3901 }
<> 128:9bcdf88f62b0 3902
<> 128:9bcdf88f62b0 3903 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3904 *
<> 128:9bcdf88f62b0 3905 * @param func Static function to attach
<> 128:9bcdf88f62b0 3906 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 3907 * @return Callback with infered type
<> 128:9bcdf88f62b0 3908 */
<> 130:d75b3fe1f5cb 3909 template <typename T, typename U, typename R, typename A0, typename A1, typename A2>
<> 130:d75b3fe1f5cb 3910 Callback<R(A0, A1, A2)> callback(R (*func)(const volatile T*, A0, A1, A2), const volatile U *arg) {
<> 128:9bcdf88f62b0 3911 return Callback<R(A0, A1, A2)>(func, arg);
<> 128:9bcdf88f62b0 3912 }
<> 128:9bcdf88f62b0 3913
<> 128:9bcdf88f62b0 3914 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3915 *
<> 128:9bcdf88f62b0 3916 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3917 * @param func Static function to attach
<> 128:9bcdf88f62b0 3918 * @return Callback with infered type
<> 128:9bcdf88f62b0 3919 * @deprecated
<> 128:9bcdf88f62b0 3920 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3921 */
<> 130:d75b3fe1f5cb 3922 template <typename T, typename U, typename R, typename A0, typename A1, typename A2>
<> 128:9bcdf88f62b0 3923 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3924 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3925 Callback<R(A0, A1, A2)> callback(U *obj, R (*func)(T*, A0, A1, A2)) {
<> 128:9bcdf88f62b0 3926 return Callback<R(A0, A1, A2)>(func, obj);
<> 128:9bcdf88f62b0 3927 }
<> 128:9bcdf88f62b0 3928
<> 128:9bcdf88f62b0 3929 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3930 *
<> 128:9bcdf88f62b0 3931 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3932 * @param func Static function to attach
<> 128:9bcdf88f62b0 3933 * @return Callback with infered type
<> 128:9bcdf88f62b0 3934 * @deprecated
<> 128:9bcdf88f62b0 3935 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3936 */
<> 130:d75b3fe1f5cb 3937 template <typename T, typename U, typename R, typename A0, typename A1, typename A2>
<> 128:9bcdf88f62b0 3938 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3939 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3940 Callback<R(A0, A1, A2)> callback(const U *obj, R (*func)(const T*, A0, A1, A2)) {
<> 128:9bcdf88f62b0 3941 return Callback<R(A0, A1, A2)>(func, obj);
<> 128:9bcdf88f62b0 3942 }
<> 128:9bcdf88f62b0 3943
<> 128:9bcdf88f62b0 3944 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3945 *
<> 128:9bcdf88f62b0 3946 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3947 * @param func Static function to attach
<> 128:9bcdf88f62b0 3948 * @return Callback with infered type
<> 128:9bcdf88f62b0 3949 * @deprecated
<> 128:9bcdf88f62b0 3950 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3951 */
<> 130:d75b3fe1f5cb 3952 template <typename T, typename U, typename R, typename A0, typename A1, typename A2>
<> 128:9bcdf88f62b0 3953 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3954 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3955 Callback<R(A0, A1, A2)> callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2)) {
<> 128:9bcdf88f62b0 3956 return Callback<R(A0, A1, A2)>(func, obj);
<> 128:9bcdf88f62b0 3957 }
<> 128:9bcdf88f62b0 3958
<> 128:9bcdf88f62b0 3959 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3960 *
<> 128:9bcdf88f62b0 3961 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3962 * @param func Static function to attach
<> 128:9bcdf88f62b0 3963 * @return Callback with infered type
<> 128:9bcdf88f62b0 3964 * @deprecated
<> 128:9bcdf88f62b0 3965 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 3966 */
<> 130:d75b3fe1f5cb 3967 template <typename T, typename U, typename R, typename A0, typename A1, typename A2>
<> 128:9bcdf88f62b0 3968 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 3969 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 3970 Callback<R(A0, A1, A2)> callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2)) {
<> 128:9bcdf88f62b0 3971 return Callback<R(A0, A1, A2)>(func, obj);
<> 128:9bcdf88f62b0 3972 }
<> 128:9bcdf88f62b0 3973
<> 128:9bcdf88f62b0 3974
<> 128:9bcdf88f62b0 3975 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3976 *
<> 128:9bcdf88f62b0 3977 * @param func Static function to attach
<> 128:9bcdf88f62b0 3978 * @return Callback with infered type
<> 128:9bcdf88f62b0 3979 */
<> 128:9bcdf88f62b0 3980 template <typename R, typename A0, typename A1, typename A2, typename A3>
<> 128:9bcdf88f62b0 3981 Callback<R(A0, A1, A2, A3)> callback(R (*func)(A0, A1, A2, A3) = 0) {
<> 128:9bcdf88f62b0 3982 return Callback<R(A0, A1, A2, A3)>(func);
<> 128:9bcdf88f62b0 3983 }
<> 128:9bcdf88f62b0 3984
<> 128:9bcdf88f62b0 3985 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3986 *
<> 128:9bcdf88f62b0 3987 * @param func Static function to attach
<> 128:9bcdf88f62b0 3988 * @return Callback with infered type
<> 128:9bcdf88f62b0 3989 */
<> 128:9bcdf88f62b0 3990 template <typename R, typename A0, typename A1, typename A2, typename A3>
<> 128:9bcdf88f62b0 3991 Callback<R(A0, A1, A2, A3)> callback(const Callback<R(A0, A1, A2, A3)> &func) {
<> 128:9bcdf88f62b0 3992 return Callback<R(A0, A1, A2, A3)>(func);
<> 128:9bcdf88f62b0 3993 }
<> 128:9bcdf88f62b0 3994
<> 128:9bcdf88f62b0 3995 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 3996 *
<> 128:9bcdf88f62b0 3997 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 3998 * @param method Member function to attach
<> 128:9bcdf88f62b0 3999 * @return Callback with infered type
<> 128:9bcdf88f62b0 4000 */
<> 130:d75b3fe1f5cb 4001 template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3>
<> 130:d75b3fe1f5cb 4002 Callback<R(A0, A1, A2, A3)> callback(U *obj, R (T::*method)(A0, A1, A2, A3)) {
<> 130:d75b3fe1f5cb 4003 return Callback<R(A0, A1, A2, A3)>(obj, method);
<> 128:9bcdf88f62b0 4004 }
<> 128:9bcdf88f62b0 4005
<> 128:9bcdf88f62b0 4006 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4007 *
<> 128:9bcdf88f62b0 4008 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4009 * @param method Member function to attach
<> 128:9bcdf88f62b0 4010 * @return Callback with infered type
<> 128:9bcdf88f62b0 4011 */
<> 130:d75b3fe1f5cb 4012 template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3>
<> 130:d75b3fe1f5cb 4013 Callback<R(A0, A1, A2, A3)> callback(const U *obj, R (T::*method)(A0, A1, A2, A3) const) {
<> 130:d75b3fe1f5cb 4014 return Callback<R(A0, A1, A2, A3)>(obj, method);
<> 128:9bcdf88f62b0 4015 }
<> 128:9bcdf88f62b0 4016
<> 128:9bcdf88f62b0 4017 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4018 *
<> 128:9bcdf88f62b0 4019 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4020 * @param method Member function to attach
<> 128:9bcdf88f62b0 4021 * @return Callback with infered type
<> 128:9bcdf88f62b0 4022 */
<> 130:d75b3fe1f5cb 4023 template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3>
<> 130:d75b3fe1f5cb 4024 Callback<R(A0, A1, A2, A3)> callback(volatile U *obj, R (T::*method)(A0, A1, A2, A3) volatile) {
<> 130:d75b3fe1f5cb 4025 return Callback<R(A0, A1, A2, A3)>(obj, method);
<> 128:9bcdf88f62b0 4026 }
<> 128:9bcdf88f62b0 4027
<> 128:9bcdf88f62b0 4028 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4029 *
<> 128:9bcdf88f62b0 4030 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4031 * @param method Member function to attach
<> 128:9bcdf88f62b0 4032 * @return Callback with infered type
<> 128:9bcdf88f62b0 4033 */
<> 130:d75b3fe1f5cb 4034 template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3>
<> 130:d75b3fe1f5cb 4035 Callback<R(A0, A1, A2, A3)> callback(const volatile U *obj, R (T::*method)(A0, A1, A2, A3) const volatile) {
<> 130:d75b3fe1f5cb 4036 return Callback<R(A0, A1, A2, A3)>(obj, method);
<> 128:9bcdf88f62b0 4037 }
<> 128:9bcdf88f62b0 4038
<> 128:9bcdf88f62b0 4039 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4040 *
<> 128:9bcdf88f62b0 4041 * @param func Static function to attach
<> 128:9bcdf88f62b0 4042 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 4043 * @return Callback with infered type
<> 128:9bcdf88f62b0 4044 */
<> 130:d75b3fe1f5cb 4045 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3>
<> 130:d75b3fe1f5cb 4046 Callback<R(A0, A1, A2, A3)> callback(R (*func)(T*, A0, A1, A2, A3), U *arg) {
<> 128:9bcdf88f62b0 4047 return Callback<R(A0, A1, A2, A3)>(func, arg);
<> 128:9bcdf88f62b0 4048 }
<> 128:9bcdf88f62b0 4049
<> 128:9bcdf88f62b0 4050 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4051 *
<> 128:9bcdf88f62b0 4052 * @param func Static function to attach
<> 128:9bcdf88f62b0 4053 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 4054 * @return Callback with infered type
<> 128:9bcdf88f62b0 4055 */
<> 130:d75b3fe1f5cb 4056 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3>
<> 130:d75b3fe1f5cb 4057 Callback<R(A0, A1, A2, A3)> callback(R (*func)(const T*, A0, A1, A2, A3), const U *arg) {
<> 128:9bcdf88f62b0 4058 return Callback<R(A0, A1, A2, A3)>(func, arg);
<> 128:9bcdf88f62b0 4059 }
<> 128:9bcdf88f62b0 4060
<> 128:9bcdf88f62b0 4061 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4062 *
<> 128:9bcdf88f62b0 4063 * @param func Static function to attach
<> 128:9bcdf88f62b0 4064 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 4065 * @return Callback with infered type
<> 128:9bcdf88f62b0 4066 */
<> 130:d75b3fe1f5cb 4067 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3>
<> 130:d75b3fe1f5cb 4068 Callback<R(A0, A1, A2, A3)> callback(R (*func)(volatile T*, A0, A1, A2, A3), volatile U *arg) {
<> 128:9bcdf88f62b0 4069 return Callback<R(A0, A1, A2, A3)>(func, arg);
<> 128:9bcdf88f62b0 4070 }
<> 128:9bcdf88f62b0 4071
<> 128:9bcdf88f62b0 4072 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4073 *
<> 128:9bcdf88f62b0 4074 * @param func Static function to attach
<> 128:9bcdf88f62b0 4075 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 4076 * @return Callback with infered type
<> 128:9bcdf88f62b0 4077 */
<> 130:d75b3fe1f5cb 4078 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3>
<> 130:d75b3fe1f5cb 4079 Callback<R(A0, A1, A2, A3)> callback(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile U *arg) {
<> 128:9bcdf88f62b0 4080 return Callback<R(A0, A1, A2, A3)>(func, arg);
<> 128:9bcdf88f62b0 4081 }
<> 128:9bcdf88f62b0 4082
<> 128:9bcdf88f62b0 4083 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4084 *
<> 128:9bcdf88f62b0 4085 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4086 * @param func Static function to attach
<> 128:9bcdf88f62b0 4087 * @return Callback with infered type
<> 128:9bcdf88f62b0 4088 * @deprecated
<> 128:9bcdf88f62b0 4089 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 4090 */
<> 130:d75b3fe1f5cb 4091 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3>
<> 128:9bcdf88f62b0 4092 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 4093 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 4094 Callback<R(A0, A1, A2, A3)> callback(U *obj, R (*func)(T*, A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 4095 return Callback<R(A0, A1, A2, A3)>(func, obj);
<> 128:9bcdf88f62b0 4096 }
<> 128:9bcdf88f62b0 4097
<> 128:9bcdf88f62b0 4098 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4099 *
<> 128:9bcdf88f62b0 4100 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4101 * @param func Static function to attach
<> 128:9bcdf88f62b0 4102 * @return Callback with infered type
<> 128:9bcdf88f62b0 4103 * @deprecated
<> 128:9bcdf88f62b0 4104 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 4105 */
<> 130:d75b3fe1f5cb 4106 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3>
<> 128:9bcdf88f62b0 4107 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 4108 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 4109 Callback<R(A0, A1, A2, A3)> callback(const U *obj, R (*func)(const T*, A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 4110 return Callback<R(A0, A1, A2, A3)>(func, obj);
<> 128:9bcdf88f62b0 4111 }
<> 128:9bcdf88f62b0 4112
<> 128:9bcdf88f62b0 4113 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4114 *
<> 128:9bcdf88f62b0 4115 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4116 * @param func Static function to attach
<> 128:9bcdf88f62b0 4117 * @return Callback with infered type
<> 128:9bcdf88f62b0 4118 * @deprecated
<> 128:9bcdf88f62b0 4119 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 4120 */
<> 130:d75b3fe1f5cb 4121 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3>
<> 128:9bcdf88f62b0 4122 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 4123 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 4124 Callback<R(A0, A1, A2, A3)> callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 4125 return Callback<R(A0, A1, A2, A3)>(func, obj);
<> 128:9bcdf88f62b0 4126 }
<> 128:9bcdf88f62b0 4127
<> 128:9bcdf88f62b0 4128 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4129 *
<> 128:9bcdf88f62b0 4130 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4131 * @param func Static function to attach
<> 128:9bcdf88f62b0 4132 * @return Callback with infered type
<> 128:9bcdf88f62b0 4133 * @deprecated
<> 128:9bcdf88f62b0 4134 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 4135 */
<> 130:d75b3fe1f5cb 4136 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3>
<> 128:9bcdf88f62b0 4137 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 4138 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 4139 Callback<R(A0, A1, A2, A3)> callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) {
<> 128:9bcdf88f62b0 4140 return Callback<R(A0, A1, A2, A3)>(func, obj);
<> 128:9bcdf88f62b0 4141 }
<> 128:9bcdf88f62b0 4142
<> 128:9bcdf88f62b0 4143
<> 128:9bcdf88f62b0 4144 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4145 *
<> 128:9bcdf88f62b0 4146 * @param func Static function to attach
<> 128:9bcdf88f62b0 4147 * @return Callback with infered type
<> 128:9bcdf88f62b0 4148 */
<> 128:9bcdf88f62b0 4149 template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 128:9bcdf88f62b0 4150 Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(A0, A1, A2, A3, A4) = 0) {
<> 128:9bcdf88f62b0 4151 return Callback<R(A0, A1, A2, A3, A4)>(func);
<> 128:9bcdf88f62b0 4152 }
<> 128:9bcdf88f62b0 4153
<> 128:9bcdf88f62b0 4154 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4155 *
<> 128:9bcdf88f62b0 4156 * @param func Static function to attach
<> 128:9bcdf88f62b0 4157 * @return Callback with infered type
<> 128:9bcdf88f62b0 4158 */
<> 128:9bcdf88f62b0 4159 template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 128:9bcdf88f62b0 4160 Callback<R(A0, A1, A2, A3, A4)> callback(const Callback<R(A0, A1, A2, A3, A4)> &func) {
<> 128:9bcdf88f62b0 4161 return Callback<R(A0, A1, A2, A3, A4)>(func);
<> 128:9bcdf88f62b0 4162 }
<> 128:9bcdf88f62b0 4163
<> 128:9bcdf88f62b0 4164 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4165 *
<> 128:9bcdf88f62b0 4166 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4167 * @param method Member function to attach
<> 128:9bcdf88f62b0 4168 * @return Callback with infered type
<> 128:9bcdf88f62b0 4169 */
<> 130:d75b3fe1f5cb 4170 template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 130:d75b3fe1f5cb 4171 Callback<R(A0, A1, A2, A3, A4)> callback(U *obj, R (T::*method)(A0, A1, A2, A3, A4)) {
<> 130:d75b3fe1f5cb 4172 return Callback<R(A0, A1, A2, A3, A4)>(obj, method);
<> 128:9bcdf88f62b0 4173 }
<> 128:9bcdf88f62b0 4174
<> 128:9bcdf88f62b0 4175 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4176 *
<> 128:9bcdf88f62b0 4177 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4178 * @param method Member function to attach
<> 128:9bcdf88f62b0 4179 * @return Callback with infered type
<> 128:9bcdf88f62b0 4180 */
<> 130:d75b3fe1f5cb 4181 template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 130:d75b3fe1f5cb 4182 Callback<R(A0, A1, A2, A3, A4)> callback(const U *obj, R (T::*method)(A0, A1, A2, A3, A4) const) {
<> 130:d75b3fe1f5cb 4183 return Callback<R(A0, A1, A2, A3, A4)>(obj, method);
<> 128:9bcdf88f62b0 4184 }
<> 128:9bcdf88f62b0 4185
<> 128:9bcdf88f62b0 4186 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4187 *
<> 128:9bcdf88f62b0 4188 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4189 * @param method Member function to attach
<> 128:9bcdf88f62b0 4190 * @return Callback with infered type
<> 128:9bcdf88f62b0 4191 */
<> 130:d75b3fe1f5cb 4192 template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 130:d75b3fe1f5cb 4193 Callback<R(A0, A1, A2, A3, A4)> callback(volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) {
<> 130:d75b3fe1f5cb 4194 return Callback<R(A0, A1, A2, A3, A4)>(obj, method);
<> 128:9bcdf88f62b0 4195 }
<> 128:9bcdf88f62b0 4196
<> 128:9bcdf88f62b0 4197 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4198 *
<> 128:9bcdf88f62b0 4199 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4200 * @param method Member function to attach
<> 128:9bcdf88f62b0 4201 * @return Callback with infered type
<> 128:9bcdf88f62b0 4202 */
<> 130:d75b3fe1f5cb 4203 template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 130:d75b3fe1f5cb 4204 Callback<R(A0, A1, A2, A3, A4)> callback(const volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) {
<> 130:d75b3fe1f5cb 4205 return Callback<R(A0, A1, A2, A3, A4)>(obj, method);
<> 128:9bcdf88f62b0 4206 }
<> 128:9bcdf88f62b0 4207
<> 128:9bcdf88f62b0 4208 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4209 *
<> 128:9bcdf88f62b0 4210 * @param func Static function to attach
<> 128:9bcdf88f62b0 4211 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 4212 * @return Callback with infered type
<> 128:9bcdf88f62b0 4213 */
<> 130:d75b3fe1f5cb 4214 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 130:d75b3fe1f5cb 4215 Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(T*, A0, A1, A2, A3, A4), U *arg) {
<> 128:9bcdf88f62b0 4216 return Callback<R(A0, A1, A2, A3, A4)>(func, arg);
<> 128:9bcdf88f62b0 4217 }
<> 128:9bcdf88f62b0 4218
<> 128:9bcdf88f62b0 4219 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4220 *
<> 128:9bcdf88f62b0 4221 * @param func Static function to attach
<> 128:9bcdf88f62b0 4222 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 4223 * @return Callback with infered type
<> 128:9bcdf88f62b0 4224 */
<> 130:d75b3fe1f5cb 4225 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 130:d75b3fe1f5cb 4226 Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const T*, A0, A1, A2, A3, A4), const U *arg) {
<> 128:9bcdf88f62b0 4227 return Callback<R(A0, A1, A2, A3, A4)>(func, arg);
<> 128:9bcdf88f62b0 4228 }
<> 128:9bcdf88f62b0 4229
<> 128:9bcdf88f62b0 4230 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4231 *
<> 128:9bcdf88f62b0 4232 * @param func Static function to attach
<> 128:9bcdf88f62b0 4233 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 4234 * @return Callback with infered type
<> 128:9bcdf88f62b0 4235 */
<> 130:d75b3fe1f5cb 4236 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 130:d75b3fe1f5cb 4237 Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile U *arg) {
<> 128:9bcdf88f62b0 4238 return Callback<R(A0, A1, A2, A3, A4)>(func, arg);
<> 128:9bcdf88f62b0 4239 }
<> 128:9bcdf88f62b0 4240
<> 128:9bcdf88f62b0 4241 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4242 *
<> 128:9bcdf88f62b0 4243 * @param func Static function to attach
<> 128:9bcdf88f62b0 4244 * @param arg Pointer argument to function
<> 128:9bcdf88f62b0 4245 * @return Callback with infered type
<> 128:9bcdf88f62b0 4246 */
<> 130:d75b3fe1f5cb 4247 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 130:d75b3fe1f5cb 4248 Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile U *arg) {
<> 128:9bcdf88f62b0 4249 return Callback<R(A0, A1, A2, A3, A4)>(func, arg);
<> 128:9bcdf88f62b0 4250 }
<> 128:9bcdf88f62b0 4251
<> 128:9bcdf88f62b0 4252 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4253 *
<> 128:9bcdf88f62b0 4254 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4255 * @param func Static function to attach
<> 128:9bcdf88f62b0 4256 * @return Callback with infered type
<> 128:9bcdf88f62b0 4257 * @deprecated
<> 128:9bcdf88f62b0 4258 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 4259 */
<> 130:d75b3fe1f5cb 4260 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 128:9bcdf88f62b0 4261 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 4262 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 4263 Callback<R(A0, A1, A2, A3, A4)> callback(U *obj, R (*func)(T*, A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 4264 return Callback<R(A0, A1, A2, A3, A4)>(func, obj);
<> 128:9bcdf88f62b0 4265 }
<> 128:9bcdf88f62b0 4266
<> 128:9bcdf88f62b0 4267 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4268 *
<> 128:9bcdf88f62b0 4269 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4270 * @param func Static function to attach
<> 128:9bcdf88f62b0 4271 * @return Callback with infered type
<> 128:9bcdf88f62b0 4272 * @deprecated
<> 128:9bcdf88f62b0 4273 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 4274 */
<> 130:d75b3fe1f5cb 4275 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 128:9bcdf88f62b0 4276 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 4277 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 4278 Callback<R(A0, A1, A2, A3, A4)> callback(const U *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 4279 return Callback<R(A0, A1, A2, A3, A4)>(func, obj);
<> 128:9bcdf88f62b0 4280 }
<> 128:9bcdf88f62b0 4281
<> 128:9bcdf88f62b0 4282 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4283 *
<> 128:9bcdf88f62b0 4284 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4285 * @param func Static function to attach
<> 128:9bcdf88f62b0 4286 * @return Callback with infered type
<> 128:9bcdf88f62b0 4287 * @deprecated
<> 128:9bcdf88f62b0 4288 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 4289 */
<> 130:d75b3fe1f5cb 4290 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 128:9bcdf88f62b0 4291 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 4292 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 4293 Callback<R(A0, A1, A2, A3, A4)> callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 4294 return Callback<R(A0, A1, A2, A3, A4)>(func, obj);
<> 128:9bcdf88f62b0 4295 }
<> 128:9bcdf88f62b0 4296
<> 128:9bcdf88f62b0 4297 /** Create a callback class with type infered from the arguments
<> 128:9bcdf88f62b0 4298 *
<> 128:9bcdf88f62b0 4299 * @param obj Optional pointer to object to bind to function
<> 128:9bcdf88f62b0 4300 * @param func Static function to attach
<> 128:9bcdf88f62b0 4301 * @return Callback with infered type
<> 128:9bcdf88f62b0 4302 * @deprecated
<> 128:9bcdf88f62b0 4303 * Arguments to callback have been reordered to callback(func, arg)
<> 128:9bcdf88f62b0 4304 */
<> 130:d75b3fe1f5cb 4305 template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
<> 128:9bcdf88f62b0 4306 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 128:9bcdf88f62b0 4307 "Arguments to callback have been reordered to callback(func, arg)")
<> 130:d75b3fe1f5cb 4308 Callback<R(A0, A1, A2, A3, A4)> callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) {
<> 128:9bcdf88f62b0 4309 return Callback<R(A0, A1, A2, A3, A4)>(func, obj);
<> 128:9bcdf88f62b0 4310 }
<> 128:9bcdf88f62b0 4311
<> 128:9bcdf88f62b0 4312
<> 128:9bcdf88f62b0 4313 } // namespace mbed
<> 128:9bcdf88f62b0 4314
<> 128:9bcdf88f62b0 4315 #endif
<> 128:9bcdf88f62b0 4316
<> 128:9bcdf88f62b0 4317
<> 128:9bcdf88f62b0 4318 /** @}*/