From: Bruno Dilly Date: Tue, 3 Jul 2012 02:09:21 +0000 (+0000) Subject: EPhysics: implement event callback del full for body X-Git-Tag: submit/devel/efl/20131022.203902~5090 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=068e1711b02b8e9cbc244b3f4d4d98514b654874;p=platform%2Fupstream%2Fefl.git EPhysics: implement event callback del full for body SVN revision: 73178 --- diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h index ca3a8dc..2b88d84 100644 --- a/legacy/ephysics/src/lib/EPhysics.h +++ b/legacy/ephysics/src/lib/EPhysics.h @@ -1065,6 +1065,8 @@ EAPI void ephysics_body_event_callback_add(EPhysics_Body *body, EPhysics_Callbac * on error. * * @see ephysics_body_event_callback_add() for details. + * @see ephysics_body_event_callback_del_full() if you need to match data + * pointer. * * @ingroup EPhysics_Body */ @@ -1072,6 +1074,28 @@ EAPI void *ephysics_body_event_callback_del(EPhysics_Body *body, EPhysics_Callba /** * @brief + * Unregister an ephysics body event callback matching data pointer. + * + * A previously added callback that match @p body, @p type, @p func + * and @p data will be deleted. + * + * @param body The physics body. + * @param type The type of callback to be unregistered. + * @param func The callback function to be unregistered. + * @param data The data pointer that was passed to the callback. + * @return The user data passed when the callback was registered, or @c NULL + * on error. + * + * @see ephysics_body_event_callback_add() for details. + * @see ephysics_body_event_callback_del() if you don't need to match data + * pointer. + * + * @ingroup EPhysics_Body + */ +EAPI void *ephysics_body_event_callback_del_full(EPhysics_Body *body, EPhysics_Callback_Type type, EPhysics_Body_Event_Cb func, void *data); + +/** + * @brief * Set body's coefficient of restitution. * * The coefficient of restitution is proporcion between speed after and diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp index 1a27b3d..ba35db5 100644 --- a/legacy/ephysics/src/lib/ephysics_body.cpp +++ b/legacy/ephysics/src/lib/ephysics_body.cpp @@ -623,6 +623,32 @@ ephysics_body_event_callback_del(EPhysics_Body *body, EPhysics_Callback_Type typ return NULL; } +EAPI void * +ephysics_body_event_callback_del_full(EPhysics_Body *body, EPhysics_Callback_Type type, EPhysics_Body_Event_Cb func, void *data) +{ + EPhysics_Body_Callback *cb; + void *cb_data; + + if (!body) + { + ERR("Can't delete body event callback, body is null."); + return NULL; + } + + EINA_INLIST_FOREACH(body->callbacks, cb) + { + if ((cb->type == type) && (cb->func == func) && (cb->data == data)) { + cb_data = cb->data; + body->callbacks = eina_inlist_remove(body->callbacks, + EINA_INLIST_GET(cb)); + free(cb); + return cb_data; + } + } + + return NULL; +} + EAPI void ephysics_body_restitution_set(EPhysics_Body *body, double restitution) {