raster pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=835b8756ece4327df90fe03060c61482de6ec5d4
commit 835b8756ece4327df90fe03060c61482de6ec5d4 Author: Felipe Magno de Almeida <fel...@expertisesolutions.com.br> Date: Tue Jul 15 08:01:14 2014 +0900 Fixes ABI breakage in Eldbus for use with C++ Eldbus Summary: This fixes the breakage when Eldbus_Service_Interface_Desc added a wrongfully methods2 field to a class that is allocated by the user. This patch adds the respective eldbus_service_interface_register2 and eldbus_service_interface_fallback_register2 for registration of Eldbus_Service_Interface_Desc2 which is now versioned. So future the functions can be backwards compatible and the struct be forward compatible and leaves the Eldbus_Service_Interface_Desc and eldbus_service_interface_register and eldbus_service_interface_fallback_register intact as it was in EFL 1.10. This fixes T1408 Reviewers: cedric, stefan_schmidt, raster Reviewed By: raster Subscribers: cedric Maniphest Tasks: T1408 Differential Revision: https://phab.enlightenment.org/D1188 --- src/bindings/eldbus_cxx/eldbus_service.hh | 6 ++-- src/lib/eldbus/eldbus_service.c | 26 +++++++++++++---- src/lib/eldbus/eldbus_service.h | 46 ++++++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 9 deletions(-) diff --git a/src/bindings/eldbus_cxx/eldbus_service.hh b/src/bindings/eldbus_cxx/eldbus_service.hh index 5dab684..1568420 100644 --- a/src/bindings/eldbus_cxx/eldbus_service.hh +++ b/src/bindings/eldbus_cxx/eldbus_service.hh @@ -364,13 +364,13 @@ service_interface service_interface_register(connection& c, const char* path ( _create_methods_specification(std::make_tuple(args...)) ); - Eldbus_Service_Interface_Desc description = + Eldbus_Service_Interface_Desc2 description = { - interface, 0, 0, 0, 0, 0, &(*methods)[0] + {interface, 0, 0, 0, 0, 0}, ELDBUS_INTERFACE_DESCRIPTOR_VERSION, &(*methods)[0] }; Eldbus_Service_Interface* iface - = ::eldbus_service_interface_register(c.native_handle(), path, &description); + = ::eldbus_service_interface_register2(c.native_handle(), path, &description); return service_interface(iface); } diff --git a/src/lib/eldbus/eldbus_service.c b/src/lib/eldbus/eldbus_service.c index f8f5b7c..f92f821 100644 --- a/src/lib/eldbus/eldbus_service.c +++ b/src/lib/eldbus/eldbus_service.c @@ -928,7 +928,7 @@ fail_signature: } static Eldbus_Service_Interface * -_eldbus_service_interface_register(Eldbus_Connection *conn, const char *path, const Eldbus_Service_Interface_Desc *desc, Eina_Bool fallback) +_eldbus_service_interface_register(Eldbus_Connection *conn, const char *path, const Eldbus_Service_Interface_Desc *desc, Eina_Bool fallback, unsigned int version) { Eldbus_Service_Object *obj; Eldbus_Service_Interface *iface; @@ -966,8 +966,12 @@ _eldbus_service_interface_register(Eldbus_Connection *conn, const char *path, co for (method = desc->methods; method && method->member; method++) _eldbus_service_method_add(iface, method); - for (method2 = desc->methods2; method2 && method2->method.member; method2++) - _eldbus_service_method_add(iface, &method2->method); + if(version >= 2) + { + Eldbus_Service_Interface_Desc2* desc2 = (void*)desc; + for (method2 = desc2->methods2; method2 && method2->method.member; method2++) + _eldbus_service_method_add(iface, &method2->method); + } iface->signals = desc->signals; iface->sign_of_signals = signatures; @@ -992,13 +996,25 @@ fail: EAPI Eldbus_Service_Interface * eldbus_service_interface_register(Eldbus_Connection *conn, const char *path, const Eldbus_Service_Interface_Desc *desc) { - return _eldbus_service_interface_register(conn, path, desc, EINA_FALSE); + return _eldbus_service_interface_register(conn, path, desc, EINA_FALSE, 1u); +} + +EAPI Eldbus_Service_Interface * +eldbus_service_interface_register2(Eldbus_Connection *conn, const char *path, const Eldbus_Service_Interface_Desc2 *desc) +{ + return _eldbus_service_interface_register(conn, path, &desc->description, EINA_FALSE, desc->version); } EAPI Eldbus_Service_Interface * eldbus_service_interface_fallback_register(Eldbus_Connection *conn, const char *path, const Eldbus_Service_Interface_Desc *desc) { - return _eldbus_service_interface_register(conn, path, desc, EINA_TRUE); + return _eldbus_service_interface_register(conn, path, desc, EINA_TRUE, 1u); +} + +EAPI Eldbus_Service_Interface * +eldbus_service_interface_fallback_register2(Eldbus_Connection *conn, const char *path, const Eldbus_Service_Interface_Desc2 *desc) +{ + return _eldbus_service_interface_register(conn, path, &desc->description, EINA_TRUE, desc->version); } static Eina_Bool diff --git a/src/lib/eldbus/eldbus_service.h b/src/lib/eldbus/eldbus_service.h index 11eff8b..ba5a9a3 100644 --- a/src/lib/eldbus/eldbus_service.h +++ b/src/lib/eldbus/eldbus_service.h @@ -15,6 +15,8 @@ #define ELDBUS_PROPERTY_FLAG_DEPRECATED 1 +#define ELDBUS_INTERFACE_DESCRIPTOR_VERSION 2 + typedef struct _Eldbus_Arg_Info { const char *signature; @@ -105,9 +107,15 @@ typedef struct _Eldbus_Service_Interface_Desc const Eldbus_Property *properties; /**< array of property that this interface have, the last item of array should be filled with NULL */ const Eldbus_Property_Get_Cb default_get; /**< default get function, if a property don't have a get function this will be used */ const Eldbus_Property_Set_Cb default_set; /**< default set function, if a property don't have a set function this will be used */ - const Eldbus_Method2 *methods2; /**< array of the methods that should be registered in this interface, the last item of array should be filled with NULL @since 1.11 */ } Eldbus_Service_Interface_Desc; +typedef struct _Eldbus_Service_Interface_Desc2 +{ + Eldbus_Service_Interface_Desc description; + int version; /**< version of the interface descriptor. Must be initialized with ELDBUS_INTERFACE_DESCRIPTOR_VERSION @since 1.11 >*/ + const Eldbus_Method2 *methods2; /**< array of the methods that should be registered in this interface, the last item of array should be filled with NULL @since 1.11 */ +} Eldbus_Service_Interface_Desc2; + /** * @brief Register an interface in the given path and connection. * @@ -135,6 +143,42 @@ EAPI Eldbus_Service_Interface * eldbus_service_interface_fallback_register(Eldbus_Connection *conn, const char *path, const Eldbus_Service_Interface_Desc *desc) EINA_ARG_NONNULL(1, 2, 3); /** + * @brief Register an interface in the given path and connection. This + * extended register function allows the registration of stateful methods, with void* data. + * + * Note: Use eldbus_service_interface_unregister() to unregister a interface. + * + * @param conn where the interface should listen + * @param path object path + * @param desc description of interface + * + * @since 1.11 + * + * @return Interface + */ +EAPI Eldbus_Service_Interface *eldbus_service_interface_register2(Eldbus_Connection *conn, const char *path, const Eldbus_Service_Interface_Desc2 *desc) EINA_ARG_NONNULL(1, 2, 3); + +/** + * @brief Register a fallback interface handler for a given subsection + * of the object hierarchy. This extended register function allows + * the registration of stateful methods, with void* data. + * + * Note: Use eldbus_service_interface_unregister() to unregister a interface. + * + * @param conn where the interface should listen + * @param path a '/' delimited string of path elements + * @param desc description of interface + * @see eldbus_service_interface_unregister() + * + * @since 1.11 + * + * @return Interface + */ +EAPI Eldbus_Service_Interface * +eldbus_service_interface_fallback_register2(Eldbus_Connection *conn, const char *path, const Eldbus_Service_Interface_Desc2 *desc) EINA_ARG_NONNULL(1, 2, 3); + + +/** * @brief Unregister a interface. * Note: This doesn't unregister the object path if interface count reaches 0. * Use eldbus_service_object_unregister() to unregister the object. --