Merge pull request #3004 from geky/callback-fix-iar-typeinfo-2

callback - Fixed missing workaround for IAR issue with type information
pull/3016/head
Sam Grove 2016-10-13 11:15:32 -05:00 committed by GitHub
commit d642b9fef2
2 changed files with 31 additions and 99 deletions

View File

@ -212,8 +212,8 @@ private:
new (p) C(*(F*)(e + 1));
equeue_event_delay(p, e->delay);
equeue_event_period(p, e->period);
equeue_event_dtor(p, &Event::function_dtor<C>);
return equeue_post(e->equeue, &Event::function_call<C>, p);
equeue_event_dtor(p, &EventQueue::function_dtor<C>);
return equeue_post(e->equeue, &EventQueue::function_call<C>, p);
}
template <typename F>
@ -221,17 +221,6 @@ private:
((F*)(e + 1))->~F();
}
// Function attributes
template <typename F>
static void function_call(void *p) {
(*(F*)p)();
}
template <typename F>
static void function_dtor(void *p) {
((F*)p)->~F();
}
public:
/** Create an event
* @see Event::Event
@ -616,8 +605,8 @@ private:
new (p) C(*(F*)(e + 1), a0);
equeue_event_delay(p, e->delay);
equeue_event_period(p, e->period);
equeue_event_dtor(p, &Event::function_dtor<C>);
return equeue_post(e->equeue, &Event::function_call<C>, p);
equeue_event_dtor(p, &EventQueue::function_dtor<C>);
return equeue_post(e->equeue, &EventQueue::function_call<C>, p);
}
template <typename F>
@ -625,17 +614,6 @@ private:
((F*)(e + 1))->~F();
}
// Function attributes
template <typename F>
static void function_call(void *p) {
(*(F*)p)();
}
template <typename F>
static void function_dtor(void *p) {
((F*)p)->~F();
}
public:
/** Create an event
* @see Event::Event
@ -1020,8 +998,8 @@ private:
new (p) C(*(F*)(e + 1), a0, a1);
equeue_event_delay(p, e->delay);
equeue_event_period(p, e->period);
equeue_event_dtor(p, &Event::function_dtor<C>);
return equeue_post(e->equeue, &Event::function_call<C>, p);
equeue_event_dtor(p, &EventQueue::function_dtor<C>);
return equeue_post(e->equeue, &EventQueue::function_call<C>, p);
}
template <typename F>
@ -1029,17 +1007,6 @@ private:
((F*)(e + 1))->~F();
}
// Function attributes
template <typename F>
static void function_call(void *p) {
(*(F*)p)();
}
template <typename F>
static void function_dtor(void *p) {
((F*)p)->~F();
}
public:
/** Create an event
* @see Event::Event
@ -1424,8 +1391,8 @@ private:
new (p) C(*(F*)(e + 1), a0, a1, a2);
equeue_event_delay(p, e->delay);
equeue_event_period(p, e->period);
equeue_event_dtor(p, &Event::function_dtor<C>);
return equeue_post(e->equeue, &Event::function_call<C>, p);
equeue_event_dtor(p, &EventQueue::function_dtor<C>);
return equeue_post(e->equeue, &EventQueue::function_call<C>, p);
}
template <typename F>
@ -1433,17 +1400,6 @@ private:
((F*)(e + 1))->~F();
}
// Function attributes
template <typename F>
static void function_call(void *p) {
(*(F*)p)();
}
template <typename F>
static void function_dtor(void *p) {
((F*)p)->~F();
}
public:
/** Create an event
* @see Event::Event
@ -1828,8 +1784,8 @@ private:
new (p) C(*(F*)(e + 1), a0, a1, a2, a3);
equeue_event_delay(p, e->delay);
equeue_event_period(p, e->period);
equeue_event_dtor(p, &Event::function_dtor<C>);
return equeue_post(e->equeue, &Event::function_call<C>, p);
equeue_event_dtor(p, &EventQueue::function_dtor<C>);
return equeue_post(e->equeue, &EventQueue::function_call<C>, p);
}
template <typename F>
@ -1837,17 +1793,6 @@ private:
((F*)(e + 1))->~F();
}
// Function attributes
template <typename F>
static void function_call(void *p) {
(*(F*)p)();
}
template <typename F>
static void function_dtor(void *p) {
((F*)p)->~F();
}
public:
/** Create an event
* @see Event::Event
@ -2232,8 +2177,8 @@ private:
new (p) C(*(F*)(e + 1), a0, a1, a2, a3, a4);
equeue_event_delay(p, e->delay);
equeue_event_period(p, e->period);
equeue_event_dtor(p, &Event::function_dtor<C>);
return equeue_post(e->equeue, &Event::function_call<C>, p);
equeue_event_dtor(p, &EventQueue::function_dtor<C>);
return equeue_post(e->equeue, &EventQueue::function_call<C>, p);
}
template <typename F>
@ -2241,17 +2186,6 @@ private:
((F*)(e + 1))->~F();
}
// Function attributes
template <typename F>
static void function_call(void *p) {
(*(F*)p)();
}
template <typename F>
static void function_dtor(void *p) {
((F*)p)->~F();
}
public:
/** Create an event
* @see Event::Event

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EVENT_QUEUE_H
#define EVENT_QUEUE_H
@ -173,19 +174,14 @@ public:
*/
template <typename F>
int call(F f) {
struct local {
static void call(void *p) { (*static_cast<F*>(p))(); }
static void dtor(void *p) { static_cast<F*>(p)->~F(); }
};
void *p = equeue_alloc(&_equeue, sizeof(F));
if (!p) {
return 0;
}
F *e = new (p) F(f);
equeue_event_dtor(e, &local::dtor);
return equeue_post(&_equeue, &local::call, e);
equeue_event_dtor(e, &EventQueue::function_dtor<F>);
return equeue_post(&_equeue, &EventQueue::function_call<F>, e);
}
/** Calls an event on the queue
@ -437,11 +433,6 @@ public:
*/
template <typename F>
int call_in(int ms, F f) {
struct local {
static void call(void *p) { (*static_cast<F*>(p))(); }
static void dtor(void *p) { static_cast<F*>(p)->~F(); }
};
void *p = equeue_alloc(&_equeue, sizeof(F));
if (!p) {
return 0;
@ -449,8 +440,8 @@ public:
F *e = new (p) F(f);
equeue_event_delay(e, ms);
equeue_event_dtor(e, &local::dtor);
return equeue_post(&_equeue, &local::call, e);
equeue_event_dtor(e, &EventQueue::function_dtor<F>);
return equeue_post(&_equeue, &EventQueue::function_call<F>, e);
}
/** Calls an event on the queue after a specified delay
@ -702,11 +693,6 @@ public:
*/
template <typename F>
int call_every(int ms, F f) {
struct local {
static void call(void *p) { (*static_cast<F*>(p))(); }
static void dtor(void *p) { static_cast<F*>(p)->~F(); }
};
void *p = equeue_alloc(&_equeue, sizeof(F));
if (!p) {
return 0;
@ -715,8 +701,8 @@ public:
F *e = new (p) F(f);
equeue_event_delay(e, ms);
equeue_event_period(e, ms);
equeue_event_dtor(e, &local::dtor);
return equeue_post(&_equeue, &local::call, e);
equeue_event_dtor(e, &EventQueue::function_dtor<F>);
return equeue_post(&_equeue, &EventQueue::function_call<F>, e);
}
/** Calls an event on the queue periodically
@ -2044,6 +2030,18 @@ protected:
struct equeue _equeue;
mbed::Callback<void(int)> _update;
// Function attributes
template <typename F>
static void function_call(void *p) {
(*(F*)p)();
}
template <typename F>
static void function_dtor(void *p) {
((F*)p)->~F();
}
// Context structures
template <typename F>
struct context00 {
F f;