summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-05-15 09:53:24 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2018-05-15 09:53:24 -0400
commit048adae83de0006802b649ef5c562ee34b407f3e (patch)
tree4510694b64843dc48b31e8834dccb5567553608d
parent114873c5454804c137c93119ec4be02f862db3e2 (diff)
Eo: introduce convenience macro efl_new()
Summary: This is just a wrapper around efl_add_ref() with a NULL parent. It only simplifies a bit object creation when no parent is desired, but it simplifies a lot the explanation of the refcounting concepts (and tutorials). Reviewers: cedric, bu5hm4n Reviewed By: cedric, bu5hm4n Subscribers: bu5hm4n, zmike Tags: #efl Differential Revision: https://phab.enlightenment.org/D6024
-rw-r--r--src/lib/eo/Eo.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index cfe6d7e67f..9b45e22e27 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -1469,6 +1469,23 @@ EAPI Eo *_efl_added_get(void);
1469 */ 1469 */
1470#define efl_add_ref(klass, parent, ...) _efl_add_common(klass, parent, EINA_TRUE, ##__VA_ARGS__) 1470#define efl_add_ref(klass, parent, ...) _efl_add_common(klass, parent, EINA_TRUE, ##__VA_ARGS__)
1471 1471
1472/**
1473 * @def efl_new
1474 * @brief Create a new object
1475 *
1476 * The object returned by this function has 1 ref which belongs to the caller.
1477 * You need to manually remove the ref by calling #efl_unref when you are done
1478 * working with the object. The object will be destroyed when all other refs
1479 * obtained with #efl_ref have been returned with #efl_unref.
1480 *
1481 * If the object's class has a constructor, it is called.
1482 *
1483 * @param klass The class of the object to create.
1484 * @param ... The ops to run.
1485 * @return An handle to the new object on success, NULL otherwise.
1486 */
1487#define efl_new(klass, ...) efl_add_ref(klass, NULL, __VA_ARGS__)
1488
1472EAPI Eo * _efl_add_internal_start(const char *file, int line, const Efl_Class *klass_id, Eo *parent, Eina_Bool ref, Eina_Bool is_fallback); 1489EAPI Eo * _efl_add_internal_start(const char *file, int line, const Efl_Class *klass_id, Eo *parent, Eina_Bool ref, Eina_Bool is_fallback);
1473 1490
1474/** 1491/**