Applied more astyle fixes

pull/9768/head
Russ Butler 2019-02-20 16:58:56 -06:00
parent 005df3559c
commit 9f116d9f33
10 changed files with 206 additions and 150 deletions

View File

@ -113,7 +113,7 @@ void control_basic_test()
{ {
USBTester serial(get_phy(), vendor_id, product_id, product_release); USBTester serial(get_phy(), vendor_id, product_id, product_release);
sprintf (str, "%s %d %d", serial.get_serial_desc_string(), vendor_id, product_id); sprintf(str, "%s %d %d", serial.get_serial_desc_string(), vendor_id, product_id);
greentea_send_kv("control_basic_test", str); greentea_send_kv("control_basic_test", str);
// Wait for host before terminating // Wait for host before terminating
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
@ -447,30 +447,30 @@ void device_reset_test()
USBTester serial(get_phy(), vendor_id, product_id, product_release); USBTester serial(get_phy(), vendor_id, product_id, product_release);
serial.clear_reset_count(); serial.clear_reset_count();
greentea_send_kv("device_reset_test", serial.get_serial_desc_string()); greentea_send_kv("device_reset_test", serial.get_serial_desc_string());
while(serial.get_reset_count() == 0); while (serial.get_reset_count() == 0);
// Wait for host before terminating // Wait for host before terminating
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
TEST_ASSERT_EQUAL_STRING("pass", _key); TEST_ASSERT_EQUAL_STRING("pass", _key);
while(!serial.configured()); while (!serial.configured());
serial.clear_reset_count(); serial.clear_reset_count();
greentea_send_kv("device_reset_test", serial.get_serial_desc_string()); greentea_send_kv("device_reset_test", serial.get_serial_desc_string());
while(serial.get_reset_count() == 0); while (serial.get_reset_count() == 0);
// Wait for host before terminating // Wait for host before terminating
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
TEST_ASSERT_EQUAL_STRING("pass", _key); TEST_ASSERT_EQUAL_STRING("pass", _key);
while(!serial.configured()); while (!serial.configured());
serial.clear_reset_count(); serial.clear_reset_count();
greentea_send_kv("device_reset_test", serial.get_serial_desc_string()); greentea_send_kv("device_reset_test", serial.get_serial_desc_string());
while(serial.get_reset_count() == 0); while (serial.get_reset_count() == 0);
// Wait for host before terminating // Wait for host before terminating
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
TEST_ASSERT_EQUAL_STRING("pass", _key); TEST_ASSERT_EQUAL_STRING("pass", _key);
while(!serial.configured()); while (!serial.configured());
greentea_send_kv("device_reset_test", serial.get_serial_desc_string()); greentea_send_kv("device_reset_test", serial.get_serial_desc_string());
// Wait for host before terminating // Wait for host before terminating
@ -504,7 +504,7 @@ void device_soft_reconnection_test()
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
TEST_ASSERT_EQUAL_STRING("pass", _key); TEST_ASSERT_EQUAL_STRING("pass", _key);
for(int i = 0; i < reconnect_try_count; i++) { for (int i = 0; i < reconnect_try_count; i++) {
serial.disconnect(); serial.disconnect();
wait_us(MIN_DISCONNECT_TIME_US); wait_us(MIN_DISCONNECT_TIME_US);
serial.connect(); serial.connect();

View File

@ -178,7 +178,7 @@ public:
* can be used, the functionality of those endpoints and the * can be used, the functionality of those endpoints and the
* resource cost. * resource cost.
*/ */
virtual const usb_ep_table_t* endpoint_table() = 0; virtual const usb_ep_table_t *endpoint_table() = 0;
/** /**
* Set wMaxPacketSize of endpoint 0 * Set wMaxPacketSize of endpoint 0

View File

@ -34,7 +34,7 @@ enum {
USB_EP_ATTR_ALLOW_INT = 1 << USB_EP_TYPE_INT, USB_EP_ATTR_ALLOW_INT = 1 << USB_EP_TYPE_INT,
USB_EP_ATTR_ALLOW_ISO = 1 << USB_EP_TYPE_ISO, USB_EP_ATTR_ALLOW_ISO = 1 << USB_EP_TYPE_ISO,
USB_EP_ATTR_ALLOW_ALL = USB_EP_ATTR_ALLOW_CTRL | USB_EP_ATTR_ALLOW_BULK | USB_EP_ATTR_ALLOW_ALL = USB_EP_ATTR_ALLOW_CTRL | USB_EP_ATTR_ALLOW_BULK |
USB_EP_ATTR_ALLOW_INT | USB_EP_ATTR_ALLOW_ISO, USB_EP_ATTR_ALLOW_INT | USB_EP_ATTR_ALLOW_ISO,
USB_EP_ATTR_DIR_IN = 0 << 4, USB_EP_ATTR_DIR_IN = 0 << 4,
USB_EP_ATTR_DIR_OUT = 1 << 4, USB_EP_ATTR_DIR_OUT = 1 << 4,

View File

@ -41,7 +41,7 @@ public:
* @param product_id Your product_id * @param product_id Your product_id
* @param product_release Your product_release * @param product_release Your product_release
*/ */
USBCDC(bool connect_blocking=true, uint16_t vendor_id=0x1f00, uint16_t product_id=0x2012, uint16_t product_release=0x0001); USBCDC(bool connect_blocking = true, uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001);
/** /**
* Fully featured constructor * Fully featured constructor
@ -114,7 +114,7 @@ public:
* or NULL to read the full size * or NULL to read the full size
* @returns true if successful false if interrupted due to a state change * @returns true if successful false if interrupted due to a state change
*/ */
bool receive(uint8_t *buffer, uint32_t size, uint32_t *actual=NULL); bool receive(uint8_t *buffer, uint32_t size, uint32_t *actual = NULL);
/** /**
* Read from the receive buffer * Read from the receive buffer

View File

@ -20,7 +20,7 @@
USBSerial::USBSerial(bool connect_blocking, uint16_t vendor_id, uint16_t product_id, uint16_t product_release): USBSerial::USBSerial(bool connect_blocking, uint16_t vendor_id, uint16_t product_id, uint16_t product_release):
USBCDC(get_usb_phy(), vendor_id, product_id, product_release) USBCDC(get_usb_phy(), vendor_id, product_id, product_release)
{ {
_settings_changed_callback = 0; _settings_changed_callback = 0;
@ -33,7 +33,7 @@ USBSerial::USBSerial(bool connect_blocking, uint16_t vendor_id, uint16_t product
} }
USBSerial::USBSerial(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release): USBSerial::USBSerial(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release):
USBCDC(phy, vendor_id, product_id, product_release) USBCDC(phy, vendor_id, product_id, product_release)
{ {
_settings_changed_callback = 0; _settings_changed_callback = 0;
} }

View File

@ -52,7 +52,7 @@ public:
* *
* @note - the host object's lock MUST NOT be held when this call is made * @note - the host object's lock MUST NOT be held when this call is made
*/ */
void wait(rtos::Mutex *host_mutex, uint32_t milliseconds=osWaitForever); void wait(rtos::Mutex *host_mutex, uint32_t milliseconds = osWaitForever);
/** /**
* Abort this asynchronous operation * Abort this asynchronous operation

View File

@ -27,7 +27,7 @@ public:
* *
* @param size Number of bytes this buffer can hold * @param size Number of bytes this buffer can hold
*/ */
ByteBuffer(uint32_t size=0); ByteBuffer(uint32_t size = 0);
/** /**
* Delete this byte buffer * Delete this byte buffer

View File

@ -42,11 +42,11 @@ void PolledQueue::dispatch()
break; break;
} }
MBED_ASSERT(sizeof(buf) >= task_size(task)); MBED_ASSERT(sizeof(buf) >= task_size(task));
TaskBase::run_callback_t callback = task_start(task, (uint8_t*)buf, sizeof(buf)); TaskBase::run_callback_t callback = task_start(task, (uint8_t *)buf, sizeof(buf));
// Run the callback outside the critical section // Run the callback outside the critical section
core_util_critical_section_exit(); core_util_critical_section_exit();
callback((uint8_t*)buf); callback((uint8_t *)buf);
core_util_critical_section_enter(); core_util_critical_section_enter();
// Finish // Finish

View File

@ -39,7 +39,7 @@ public:
* *
* @param cb Callback called when dispatch needs to be called * @param cb Callback called when dispatch needs to be called
*/ */
PolledQueue(mbed::Callback<void()> cb=NULL); PolledQueue(mbed::Callback<void()> cb = NULL);
virtual ~PolledQueue(); virtual ~PolledQueue();

View File

@ -26,7 +26,7 @@ namespace events {
/** \addtogroup events */ /** \addtogroup events */
template<typename F, typename A1=void, typename A2=void, typename A3=void, typename A4=void, typename A5=void> template<typename F, typename A1 = void, typename A2 = void, typename A3 = void, typename A4 = void, typename A5 = void>
struct AllArgs; struct AllArgs;
template<typename B0> template<typename B0>
@ -34,17 +34,18 @@ struct AllArgs<B0> {
typedef AllArgs<B0> Self; typedef AllArgs<B0> Self;
B0 b0; B0 b0;
AllArgs(B0 b0=B0()): b0(b0) {} AllArgs(B0 b0 = B0()): b0(b0) {}
template <typename T, typename _> template <typename T, typename _>
struct Operations { struct Operations {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
s->b0(); s->b0();
s->~Self(); s->~Self();
} }
@ -56,75 +57,81 @@ struct AllArgs<B0> {
template<typename B0, typename B1> template<typename B0, typename B1>
struct AllArgs<B0, B1> { struct AllArgs<B0, B1> {
typedef AllArgs<B0, B1> Self; typedef AllArgs<B0, B1> Self;
B0 b0; B1 b1; B0 b0;
B1 b1;
AllArgs(B0 b0=B0(), B1 b1=B1()): b0(b0), b1(b1) {} AllArgs(B0 b0 = B0(), B1 b1 = B1()): b0(b0), b1(b1) {}
template <typename T, typename _> template <typename T, typename _>
struct Operations { struct Operations {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
s->b0(s->b1); s->b0(s->b1);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T*, R (U::*)()> { struct Operations<T *, R(U::*)()> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(); ((s->b0)->*(s->b1))();
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)() const> { struct Operations<T, R(U::*)() const> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(); ((s->b0)->*(s->b1))();
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)() volatile> { struct Operations<T, R(U::*)() volatile> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(); ((s->b0)->*(s->b1))();
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)() const volatile> { struct Operations<T, R(U::*)() const volatile> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(); ((s->b0)->*(s->b1))();
s->~Self(); s->~Self();
} }
@ -136,76 +143,83 @@ struct AllArgs<B0, B1> {
template<typename B0, typename B1, typename B2> template<typename B0, typename B1, typename B2>
struct AllArgs<B0, B1, B2> { struct AllArgs<B0, B1, B2> {
typedef AllArgs<B0, B1, B2> Self; typedef AllArgs<B0, B1, B2> Self;
B0 b0; B1 b1; B2 b2; B0 b0;
B1 b1;
B2 b2;
AllArgs(B0 b0=B0(), B1 b1=B1(), B2 b2=B2()): b0(b0), b1(b1), b2(b2) {} AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2()): b0(b0), b1(b1), b2(b2) {}
template <typename T, typename _> template <typename T, typename _>
struct Operations { struct Operations {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
s->b0(s->b1, s->b2); s->b0(s->b1, s->b2);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T*, R (U::*)(B2)> { struct Operations<T *, R(U::*)(B2)> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2); ((s->b0)->*(s->b1))(s->b2);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)(B2) const> { struct Operations<T, R(U::*)(B2) const> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2); ((s->b0)->*(s->b1))(s->b2);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)(B2) volatile> { struct Operations<T, R(U::*)(B2) volatile> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2); ((s->b0)->*(s->b1))(s->b2);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)(B2) const volatile> { struct Operations<T, R(U::*)(B2) const volatile> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2); ((s->b0)->*(s->b1))(s->b2);
s->~Self(); s->~Self();
} }
@ -217,76 +231,84 @@ struct AllArgs<B0, B1, B2> {
template<typename B0, typename B1, typename B2, typename B3> template<typename B0, typename B1, typename B2, typename B3>
struct AllArgs<B0, B1, B2, B3> { struct AllArgs<B0, B1, B2, B3> {
typedef AllArgs<B0, B1, B2, B3> Self; typedef AllArgs<B0, B1, B2, B3> Self;
B0 b0; B1 b1; B2 b2; B3 b3; B0 b0;
B1 b1;
B2 b2;
B3 b3;
AllArgs(B0 b0=B0(), B1 b1=B1(), B2 b2=B2(), B3 b3=B3()): b0(b0), b1(b1), b2(b2), b3(b3) {} AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2(), B3 b3 = B3()): b0(b0), b1(b1), b2(b2), b3(b3) {}
template <typename T, typename _> template <typename T, typename _>
struct Operations { struct Operations {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
s->b0(s->b1, s->b2, s->b3); s->b0(s->b1, s->b2, s->b3);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T*, R (U::*)(B2, B3)> { struct Operations<T *, R(U::*)(B2, B3)> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2, s->b3); ((s->b0)->*(s->b1))(s->b2, s->b3);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)(B2, B3) const> { struct Operations<T, R(U::*)(B2, B3) const> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2, s->b3); ((s->b0)->*(s->b1))(s->b2, s->b3);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)(B2, B3) volatile> { struct Operations<T, R(U::*)(B2, B3) volatile> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2, s->b3); ((s->b0)->*(s->b1))(s->b2, s->b3);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)(B2, B3) const volatile> { struct Operations<T, R(U::*)(B2, B3) const volatile> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2, s->b3); ((s->b0)->*(s->b1))(s->b2, s->b3);
s->~Self(); s->~Self();
} }
@ -298,76 +320,85 @@ struct AllArgs<B0, B1, B2, B3> {
template<typename B0, typename B1, typename B2, typename B3, typename B4> template<typename B0, typename B1, typename B2, typename B3, typename B4>
struct AllArgs<B0, B1, B2, B3, B4> { struct AllArgs<B0, B1, B2, B3, B4> {
typedef AllArgs<B0, B1, B2, B3, B4> Self; typedef AllArgs<B0, B1, B2, B3, B4> Self;
B0 b0; B1 b1; B2 b2; B3 b3; B4 b4; B0 b0;
B1 b1;
B2 b2;
B3 b3;
B4 b4;
AllArgs(B0 b0=B0(), B1 b1=B1(), B2 b2=B2(), B3 b3=B3(), B4 b4=B4()): b0(b0), b1(b1), b2(b2), b3(b3), b4(b4) {} AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2(), B3 b3 = B3(), B4 b4 = B4()): b0(b0), b1(b1), b2(b2), b3(b3), b4(b4) {}
template <typename T, typename _> template <typename T, typename _>
struct Operations { struct Operations {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
s->b0(s->b1, s->b2, s->b3, s->b4); s->b0(s->b1, s->b2, s->b3, s->b4);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T*, R (U::*)(B2, B3, B4)> { struct Operations<T *, R(U::*)(B2, B3, B4)> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2, s->b3, s->b4); ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)(B2, B3, B4) const> { struct Operations<T, R(U::*)(B2, B3, B4) const> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2, s->b3, s->b4); ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)(B2, B3, B4) volatile> { struct Operations<T, R(U::*)(B2, B3, B4) volatile> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2, s->b3, s->b4); ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)(B2, B3, B4) const volatile> { struct Operations<T, R(U::*)(B2, B3, B4) const volatile> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2, s->b3, s->b4); ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
s->~Self(); s->~Self();
} }
@ -379,76 +410,86 @@ struct AllArgs<B0, B1, B2, B3, B4> {
template<typename B0, typename B1, typename B2, typename B3, typename B4, typename B5> template<typename B0, typename B1, typename B2, typename B3, typename B4, typename B5>
struct AllArgs { struct AllArgs {
typedef AllArgs<B0, B1, B2, B3, B4, B5> Self; typedef AllArgs<B0, B1, B2, B3, B4, B5> Self;
B0 b0; B1 b1; B2 b2; B3 b3; B4 b4; B5 b5; B0 b0;
B1 b1;
B2 b2;
B3 b3;
B4 b4;
B5 b5;
AllArgs(B0 b0=B0(), B1 b1=B1(), B2 b2=B2(), B3 b3=B3(), B4 b4=B4(), B5 b5=B5()): b0(b0), b1(b1), b2(b2), b3(b3), b4(b4), b5(b5) {} AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2(), B3 b3 = B3(), B4 b4 = B4(), B5 b5 = B5()): b0(b0), b1(b1), b2(b2), b3(b3), b4(b4), b5(b5) {}
template <typename T, typename _> template <typename T, typename _>
struct Operations { struct Operations {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
s->b0(s->b1, s->b2, s->b3, s->b4, s->b5); s->b0(s->b1, s->b2, s->b3, s->b4, s->b5);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T*, R (U::*)(B2, B3, B4, B5)> { struct Operations<T *, R(U::*)(B2, B3, B4, B5)> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5); ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)(B2, B3, B4, B5) const> { struct Operations<T, R(U::*)(B2, B3, B4, B5) const> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5); ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)(B2, B3, B4, B5) volatile> { struct Operations<T, R(U::*)(B2, B3, B4, B5) volatile> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5); ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
s->~Self(); s->~Self();
} }
}; };
template <typename T, typename R, typename U> template <typename T, typename R, typename U>
struct Operations<T, R (U::*)(B2, B3, B4, B5) const volatile> { struct Operations<T, R(U::*)(B2, B3, B4, B5) const volatile> {
static void copy(void *_dest, void *_src) static void copy(void *_dest, void *_src)
{ {
new (_dest) Self(*(Self*)_src); new (_dest) Self(*(Self *)_src);
} }
static void call(void *data) { static void call(void *data)
Self *s = static_cast<Self*>(data); {
Self *s = static_cast<Self *>(data);
((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5); ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
s->~Self(); s->~Self();
} }
@ -465,27 +506,32 @@ template <typename R>
class Task<R()>: public TaskBase { class Task<R()>: public TaskBase {
public: public:
Task(TaskQueue *q=NULL, mbed::Callback<R()> cb=mbed::Callback<R()>()) Task(TaskQueue *q = NULL, mbed::Callback<R()> cb = mbed::Callback<R()>())
: TaskBase(q), _args(cb) { : TaskBase(q), _args(cb)
{
} }
Task& operator=( mbed::Callback<R()> cb) { Task &operator=(mbed::Callback<R()> cb)
{
_args.b0 = cb; _args.b0 = cb;
return *this; return *this;
} }
void call() { void call()
{
post(); post();
} }
protected: protected:
virtual uint32_t size() { virtual uint32_t size()
{
return sizeof(_args); return sizeof(_args);
} }
virtual run_callback_t start(void *data, uint32_t max_size) { virtual run_callback_t start(void *data, uint32_t max_size)
All::ops::copy(data, (void*)&_args); {
All::ops::copy(data, (void *)&_args);
return &All::ops::call; return &All::ops::call;
} }
@ -498,28 +544,33 @@ template <typename R, typename A0>
class Task<R(A0)>: public TaskBase { class Task<R(A0)>: public TaskBase {
public: public:
Task(TaskQueue *q=NULL, mbed::Callback<R(A0)> cb=mbed::Callback<R(A0)>()) Task(TaskQueue *q = NULL, mbed::Callback<R(A0)> cb = mbed::Callback<R(A0)>())
: TaskBase(q), _args(cb) { : TaskBase(q), _args(cb)
{
} }
Task& operator=( mbed::Callback<R(A0)> cb) { Task &operator=(mbed::Callback<R(A0)> cb)
{
_args.b0 = cb; _args.b0 = cb;
return *this; return *this;
} }
void call(A0 a0) { void call(A0 a0)
{
_args.b1 = a0; _args.b1 = a0;
post(); post();
} }
protected: protected:
virtual uint32_t size() { virtual uint32_t size()
{
return sizeof(_args); return sizeof(_args);
} }
virtual run_callback_t start(void *data, uint32_t max_size) { virtual run_callback_t start(void *data, uint32_t max_size)
All::ops::copy(data, (void*)&_args); {
All::ops::copy(data, (void *)&_args);
return &All::ops::call; return &All::ops::call;
} }
@ -543,8 +594,9 @@ public:
* @param q TaskQueue to post to * @param q TaskQueue to post to
* @param cb Callback to run * @param cb Callback to run
*/ */
Task(TaskQueue *q=NULL, mbed::Callback<R(A0, A1)> cb=mbed::Callback<R(A0, A1)>()) Task(TaskQueue *q = NULL, mbed::Callback<R(A0, A1)> cb = mbed::Callback<R(A0, A1)>())
: TaskBase(q), _args(cb) { : TaskBase(q), _args(cb)
{
} }
/** /**
@ -552,7 +604,8 @@ public:
* *
* @param cb Callback to run * @param cb Callback to run
*/ */
Task& operator=(mbed::Callback<R(A0, A1)> cb) { Task &operator=(mbed::Callback<R(A0, A1)> cb)
{
_args.b0 = cb; _args.b0 = cb;
return *this; return *this;
} }
@ -568,7 +621,8 @@ public:
* @param a0 First callback parameter * @param a0 First callback parameter
* @param a1 Second callback parameter * @param a1 Second callback parameter
*/ */
void call(A0 a0, A1 a1) { void call(A0 a0, A1 a1)
{
_args.b1 = a0; _args.b1 = a0;
_args.b2 = a1; _args.b2 = a1;
post(); post();
@ -576,12 +630,14 @@ public:
protected: protected:
virtual uint32_t size() { virtual uint32_t size()
{
return sizeof(_args); return sizeof(_args);
} }
virtual run_callback_t start(void *data, uint32_t max_size) { virtual run_callback_t start(void *data, uint32_t max_size)
All::ops::copy(data, (void*)&_args); {
All::ops::copy(data, (void *)&_args);
return &All::ops::call; return &All::ops::call;
} }