14 # define EAPI __declspec(dllexport)
17 # endif /* ! DLL_EXPORT */
19 # define EAPI __declspec(dllimport)
20 # endif /* ! EFL_EO_BUILD */
24 # define EAPI __attribute__ ((visibility("default")))
38 * @var _eo_class_creation_lock
39 * This variable is used for locking purposes in the class_get function
40 * defined in #EO_DEFINE_CLASS.
41 * This is just to work around the fact that we need to init locks before
43 * Don't touch it if you don't know what you are doing.
46 EAPI extern Eina_Lock _eo_class_creation_lock;
50 * An enum representing the possible types of an Op.
54 EO_OP_TYPE_INVALID = -1, /**< Invalid op. */
55 EO_OP_TYPE_REGULAR = 0, /**< Regular op. */
56 EO_OP_TYPE_CLASS, /**< Class op - a class op. Like static in Java/C++. */
62 * A convenience typedef for #_Eo_Op_Type.
64 typedef enum _Eo_Op_Type Eo_Op_Type;
67 * @defgroup Eo Eo Generic Object System
69 * The Eo generic object system. It was designed to be the base object
76 * @def EO_TYPECHECK(type, x)
78 * Checks x is castable to type "type" and casts it to it.
79 * @param type The C type to check against.
80 * @param x the variable to test and cast.
82 #define EO_TYPECHECK(type, x) \
91 * The basic Object type.
93 typedef struct _Eo Eo;
96 * The Eo operation type id.
98 typedef unsigned int Eo_Op;
102 * The basic Object class type.
105 typedef struct _Eo_Class Eo_Class;
108 * @typedef Eo_Class_Id
112 typedef size_t Eo_Class_Id;
116 * A special #Eo_Op meaning "No operation".
118 #define EO_NOOP ((Eo_Op) 0)
121 * @typedef eo_op_func_type
122 * The type of the Op functions. This is the type of the functions used by
125 * @see eo_op_func_type_class
127 typedef void (*eo_op_func_type)(Eo *, void *class_data, va_list *list);
130 * @typedef eo_op_func_type_class
131 * The type of the class Op functions. This is the same as #eo_op_func_type,\
132 * exepct that it's for usage with class functions, and not with object
135 * @see eo_op_func_type
137 typedef void (*eo_op_func_type_class)(const Eo_Class *, va_list *list);
140 * @addtogroup Eo_Events Eo's Event Handling
145 * @struct _Eo_Event_Description
146 * This struct holds the description of a specific event.
148 struct _Eo_Event_Description
150 const char *name; /**< name of the event. */
151 const char *doc; /**< Explanation about the event. */
155 * @typedef Eo_Event_Description
156 * A convenience typedef for #_Eo_Event_Description
158 typedef struct _Eo_Event_Description Eo_Event_Description;
161 * @def EO_EVENT_DESCRIPTION(name, doc)
162 * An helper macro to help populating #Eo_Event_Description
163 * @param name The name of the event.
164 * @param doc Additional doc for the event.
165 * @see Eo_Event_Description
167 #define EO_EVENT_DESCRIPTION(name, doc) { name, doc }
174 * @addtogroup Eo_Class Eo Class
179 * @def EO_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...)
180 * A convenience macro to be used for creating the class_get function. This
181 * macro is fairly simple but should still be used as it'll let us improve
183 * @param class_get_func_name the name of the wanted class_get function name.
184 * @param class_desc the class description.
185 * @param parent_class The parent class for the function. Look at eo_class_new() for more information.
186 * @param ... List of etxensions. Look at eo_class_new() for more information.
188 * You must use this macro if you want thread safety in class creation.
190 #define EO_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...) \
191 EAPI const Eo_Class * \
192 class_get_func_name(void) \
194 const Eo_Class *_tmp_parent_class; \
195 static volatile char lk_init = 0; \
196 static Eina_Lock _my_lock; \
197 static const Eo_Class * volatile _my_class = NULL; \
198 if (EINA_LIKELY(!!_my_class)) return _my_class; \
200 eina_lock_take(&_eo_class_creation_lock); \
202 eina_lock_new(&_my_lock); \
203 if (lk_init < 2) eina_lock_take(&_my_lock); \
208 if (lk_init < 2) eina_lock_release(&_my_lock); \
209 eina_lock_release(&_eo_class_creation_lock); \
212 eina_lock_release(&_eo_class_creation_lock); \
213 _tmp_parent_class = parent_class; \
214 _my_class = eo_class_new(class_desc, _tmp_parent_class, __VA_ARGS__); \
215 eina_lock_release(&_my_lock); \
217 eina_lock_take(&_eo_class_creation_lock); \
218 eina_lock_free(&_my_lock); \
220 eina_lock_release(&_eo_class_creation_lock); \
226 * An enum representing the possible types of an Eo class.
230 EO_CLASS_TYPE_REGULAR = 0, /**< Regular class. */
231 EO_CLASS_TYPE_REGULAR_NO_INSTANT, /**< Regular non instant-able class. */
232 EO_CLASS_TYPE_INTERFACE, /**< Interface */
233 EO_CLASS_TYPE_MIXIN /**< Mixin */
237 * @typedef Eo_Class_Type
238 * A convenience typedef for #_Eo_Class_Type.
240 typedef enum _Eo_Class_Type Eo_Class_Type;
243 * @struct _Eo_Op_Func_Description
244 * Used to associate an Op with a func.
245 * @see eo_class_funcs_set
247 struct _Eo_Op_Func_Description
249 Eo_Op op; /**< The op */
250 eo_op_func_type func; /**< The function to call for the op. */
251 Eo_Op_Type op_type; /**< The type of the op */
255 * @typedef Eo_Op_Func_Description
256 * A convenience typedef for #_Eo_Op_Func_Description
258 typedef struct _Eo_Op_Func_Description Eo_Op_Func_Description;
261 * @def EO_OP_FUNC(op, func)
262 * A convenience macro to be used when populating the #Eo_Op_Func_Description
265 #define EO_OP_FUNC(op, func) { op, EO_TYPECHECK(eo_op_func_type, func), EO_OP_TYPE_REGULAR }
268 * @def EO_OP_FUNC_CLASS(op, func)
269 * A convenience macro to be used when populating the #Eo_Op_Func_Description
271 * The same as #EO_OP_FUNC but for class functions.
275 #define EO_OP_FUNC_CLASS(op, func) { op, (eo_op_func_type) EO_TYPECHECK(eo_op_func_type_class, func), EO_OP_TYPE_CLASS }
278 * @def EO_OP_FUNC_SENTINEL
279 * A convenience macro to be used when populating the #Eo_Op_Func_Description
280 * array. It must appear at the end of the ARRAY.
282 #define EO_OP_FUNC_SENTINEL { 0, NULL, EO_OP_TYPE_INVALID }
285 * @struct _Eo_Op_Description
286 * This struct holds the description of a specific op.
288 struct _Eo_Op_Description
290 Eo_Op sub_op; /**< The sub_id of the op in it's class. */
291 const char *name; /**< The name of the op. */
292 const char *doc; /**< Explanation about the Op. */
293 Eo_Op_Type op_type; /**< The type of the Op. */
297 * @typedef Eo_Op_Description
298 * A convenience typedef for #_Eo_Op_Description
300 typedef struct _Eo_Op_Description Eo_Op_Description;
304 * The current version of EO.
309 * @struct _Eo_Class_Description
310 * This struct holds the description of a class.
311 * This description should be passed to eo_class_new.
312 * Please use the #EO_CLASS_DESCRIPTION_OPS macro when populating it.
314 struct _Eo_Class_Description
316 unsigned int version; /**< The current version of eo, use #EO_VERSION */
317 const char *name; /**< The name of the class. */
318 Eo_Class_Type type; /**< The type of the class. */
321 const Eo_Op_Description *descs;
323 } ops; /**< The ops description, should be filled using #EO_CLASS_DESCRIPTION_OPS */
324 const Eo_Event_Description **events; /**< The event descriptions for this class. */
325 size_t data_size; /**< The size of data (private + protected + public) this class needs per object. */
326 void (*class_constructor)(Eo_Class *klass); /**< The constructor of the class. */
327 void (*class_destructor)(Eo_Class *klass); /**< The destructor of the class. */
331 * @typedef Eo_Class_Description
332 * A convenience typedef for #_Eo_Class_Description
334 typedef struct _Eo_Class_Description Eo_Class_Description;
337 * @def EO_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count)
338 * An helper macro to help populating #Eo_Class_Description.
339 * @param base_op_id A pointer to the base op id of the class.
340 * @param op_descs the op descriptions array.
341 * @param count the number of ops in the op descriptions array.
343 #define EO_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) { base_op_id, op_descs, count }
346 * @def EO_OP_DESCRIPTION(op, doc)
347 * An helper macro to help populating #Eo_Op_Description
348 * @param sub_id The sub id of the op being described.
349 * @param doc Additional doc for the op.
350 * @see Eo_Op_Description
351 * @see EO_OP_DESCRIPTION_CLASS
352 * @see EO_OP_DESCRIPTION_SENTINEL
354 #define EO_OP_DESCRIPTION(sub_id, doc) { sub_id, #sub_id, doc, EO_OP_TYPE_REGULAR }
357 * @def EO_OP_DESCRIPTION_CLASS(op, doc)
358 * An helper macro to help populating #Eo_Op_Description
359 * This macro is the same as EO_OP_DESCRIPTION but indicates that the op's
360 * implementation is of type CLASS.
361 * @param sub_id The sub id of the op being described.
362 * @param doc Additional doc for the op.
363 * @see Eo_Op_Description
364 * @see EO_OP_DESCRIPTION
365 * @see EO_OP_DESCRIPTION_SENTINEL
367 #define EO_OP_DESCRIPTION_CLASS(sub_id, doc) { sub_id, #sub_id, doc, EO_OP_TYPE_CLASS }
370 * @def EO_OP_DESCRIPTION_SENTINEL
371 * An helper macro to help populating #Eo_Op_Description
372 * Should be placed at the end of the array.
373 * @see Eo_Op_Description
374 * @see EO_OP_DESCRIPTION
376 #define EO_OP_DESCRIPTION_SENTINEL { 0, NULL, NULL, EO_OP_TYPE_INVALID }
379 * @brief Create a new class.
380 * @param desc the class description to create the class with.
381 * @param parent the class to inherit from.
382 * @param ... A NULL terminated list of extensions (interfaces, mixins and the classes of any composite objects).
383 * @return The new class's handle on success, or NULL otherwise.
385 * You should use #EO_DEFINE_CLASS. It'll provide thread safety and other
388 * @see #EO_DEFINE_CLASS
390 EAPI const Eo_Class *eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent, ...);
393 * @brief Check if an object "is a" klass.
394 * @param obj The object to check
395 * @param klass The klass to check against.
396 * @return @c EINA_TRUE if obj implements klass, @c EINA_FALSE otherwise.
398 * Notice: This function does not support composite objects.
400 EAPI Eina_Bool eo_isa(const Eo *obj, const Eo_Class *klass);
403 * @brief Sets the OP functions for a class.
404 * @param klass the class to set the functions to.
405 * @param func_descs a NULL terminated array of #Eo_Op_Func_Description
407 * Should be called from within the class constructor.
409 EAPI void eo_class_funcs_set(Eo_Class *klass, const Eo_Op_Func_Description *func_descs);
412 * @brief Gets the name of the passed class.
413 * @param klass the class to work on.
414 * @return The class's name.
416 * @see eo_class_get()
418 EAPI const char *eo_class_name_get(const Eo_Class *klass);
425 * @brief Init the eo subsystem
426 * @return @c EINA_TRUE on success.
430 EAPI Eina_Bool eo_init(void);
433 * @brief Shutdown the eo subsystem
434 * @return @c EINA_TRUE on success.
438 EAPI Eina_Bool eo_shutdown(void);
442 * A convenience wrapper around eo_do_internal()
443 * @see eo_do_internal
445 #define eo_do(obj, ...) eo_do_internal(obj, EO_OP_TYPE_REGULAR, __VA_ARGS__, EO_NOOP)
449 * A convenience wrapper around eo_class_do_internal()
450 * @see eo_class_do_internal
452 #define eo_class_do(klass, ...) eo_class_do_internal(klass, __VA_ARGS__, EO_NOOP)
455 * @brief Calls op functions of an object
456 * @param obj The object to work on
457 * @param op_type The type of the ops that are passed.
458 * @param ... NULL terminated list of OPs and parameters.
459 * @return @c EINA_TRUE on success.
461 * Use the helper macros, don't pass the parameters manually.
462 * Use #eo_do instead of this function.
466 EAPI Eina_Bool eo_do_internal(Eo *obj, Eo_Op_Type op_type, ...);
469 * @brief Calls op functions of a class.
470 * @param klass The class to work on
471 * @param ... NULL terminated list of OPs and parameters.
472 * @return @c EINA_TRUE on success.
474 * Use the helper macros, don't pass the parameters manually.
475 * Use #eo_do instead of this function.
479 EAPI Eina_Bool eo_class_do_internal(const Eo_Class *klass, ...);
482 * @brief Calls the super function for the specific op.
483 * @param obj The object to work on
484 * @param ... list of parameters.
485 * @return @c EINA_TRUE on success.
487 * Unlike eo_do(), this function only accepts one op.
491 #define eo_do_super(obj, ...) eo_do_super_internal(obj, EO_OP_TYPE_REGULAR, __VA_ARGS__)
494 * @brief Calls the super function for the specific op.
495 * @param klass The klass to work on
496 * @param ... list of parameters.
497 * @return @c EINA_TRUE on success.
499 * Unlike eo_class_do(), this function only accepts one op.
503 #define eo_class_do_super(klass, ...) eo_class_do_super_internal(klass, __VA_ARGS__)
506 * @brief Calls the super function for the specific op.
507 * @param obj The object to work on
508 * @param op_type The type of the ops that are passed.
509 * @param op The wanted op.
510 * @param ... list of parameters.
511 * @return @c EINA_TRUE on success.
513 * Don't use this function, use the wrapping macros instead.
518 EAPI Eina_Bool eo_do_super_internal(Eo *obj, Eo_Op_Type op_type, Eo_Op op, ...);
521 * @brief Calls the super function for the specific op.
522 * @param klass The klass to work on
523 * @param op The wanted op.
524 * @param ... list of parameters.
525 * @return @c EINA_TRUE on success.
527 * Don't use this function, use the wrapping macros instead.
530 * @see #eo_class_do_super
532 EAPI Eina_Bool eo_class_do_super_internal(const Eo_Class *klass, Eo_Op op, ...);
535 * @brief Gets the class of the object.
536 * @param obj The object to work on
537 * @return The object's class.
539 * @see eo_class_name_get()
541 EAPI const Eo_Class *eo_class_get(const Eo *obj);
545 * @brief Notify eo that there was an error when constructing, destructing or calling a function of the object.
546 * @param obj the object to work on.
548 * @see eo_error_get()
550 #define eo_error_set(obj) eo_error_set_internal(obj, __FILE__, __LINE__)
553 EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line);
558 * @brief Create a new object with the default constructor.
559 * @param klass the class of the object to create.
560 * @param parent the parent to set to the object.
561 * @param ... The ops to run.
562 * @return An handle to the new object on success, NULL otherwise.
564 * @see #eo_add_custom
566 #define eo_add(klass, parent, ...) \
568 const Eo_Class *_tmp_klass = klass; \
569 eo_add_internal(_tmp_klass, parent, eo_constructor(), ## __VA_ARGS__, EO_NOOP); \
574 * @brief Create a new object with a custom constructor.
575 * @param klass the class of the object to create.
576 * @param parent the parent to set to the object.
577 * @param ... The ops to run. With the constructor being first.
578 * @return An handle to the new object on success, NULL otherwise.
582 #define eo_add_custom(klass, parent, ...) \
584 const Eo_Class *_tmp_klass = klass; \
585 eo_add_internal(_tmp_klass, parent, ## __VA_ARGS__, EO_NOOP); \
589 * @brief Create a new object.
590 * @param klass the class of the object to create.
591 * @param parent the parent to set to the object.
592 * @param ... The ops to run. With the constructor being first.
593 * @return An handle to the new object on success, NULL otherwise.
595 * Use the helper macros, don't pass the parameters manually.
596 * Use #eo_add or #eo_add_custom instead of this function.
600 EAPI Eo *eo_add_internal(const Eo_Class *klass, Eo *parent, ...);
603 * @brief Get the parent of an object
604 * @param obj the object to get the parent of.
605 * @return a pointer to the parent object.
607 * @see eo_parent_set()
609 EAPI Eo *eo_parent_get(const Eo *obj);
612 * @brief Set the parent of an object
613 * @param obj the object to get the parent of.
614 * @param parent the new parent.
615 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure.
617 * Parents keep references to their children so in order to delete objects
618 * that have parents you need to set parent to NULL or use eo_del() that
619 * does that for you (and also unrefs the object).
622 * @see eo_parent_get()
624 EAPI Eina_Bool eo_parent_set(Eo *obj, const Eo *parent);
627 * @brief Get a pointer to the data of an object for a specific class.
628 * @param obj the object to work on.
629 * @param klass the klass associated with the data.
630 * @return a pointer to the data.
632 EAPI void *eo_data_get(const Eo *obj, const Eo_Class *klass);
635 * @brief Increment the object's reference count by 1.
636 * @param obj the object to work on.
637 * @return The object passed.
639 * It's very easy to get a refcount leak and start leaking memory because
640 * of a forgotten unref or an extra ref. That is why there are eo_xref
641 * and eo_xunref that will make debugging easier in such a case.
642 * Therefor, these functions should only be used in small scopes, i.e at the
643 * start of some section in which the object may get freed, or if you know
644 * what you are doing.
649 EAPI Eo *eo_ref(const Eo *obj);
652 * @brief Decrement the object's reference count by 1 and free it if needed.
653 * @param obj the object to work on.
658 EAPI void eo_unref(const Eo *obj);
661 * @brief Return the ref count of the object passed.
662 * @param obj the object to work on.
663 * @return the ref count of the object.
668 EAPI int eo_ref_get(const Eo *obj);
671 * @brief Unrefs the object and reparents it to NULL.
672 * @param obj the object to work on.
674 * Because eo_del() unrefs and reparents to NULL, it doesn't really delete the
678 * @see eo_parent_set()
680 EAPI void eo_del(const Eo *obj);
683 * @def eo_xref(obj, ref_obj)
684 * Convenience macro around eo_xref_internal()
687 #define eo_xref(obj, ref_obj) eo_xref_internal(obj, ref_obj, __FILE__, __LINE__)
690 * @brief Increment the object's reference count by 1 (and associate the ref with ref_obj)
691 * @param obj the object to work on.
692 * @param ref_obj the object that references obj.
693 * @param file the call's filename.
694 * @param line the call's line number.
695 * @return The object passed (obj)
697 * People should not use this function, use #eo_xref instead.
698 * A compile flag my make it and eobj_xunref() behave the same as eobj_ref()
699 * and eobj_unref() respectively. So this should be used wherever possible.
703 EAPI Eo *eo_xref_internal(Eo *obj, const Eo *ref_obj, const char *file, int line);
706 * @brief Decrement the object's reference count by 1 and free it if needed. Will free the ref associated with ref_obj).
707 * @param obj the object to work on.
708 * @param ref_obj the object that references obj.
710 * This function only enforces the checks for object association. I.e don't rely
711 * on it. If such enforces are compiled out, this function behaves the same as
714 * @see eo_xref_internal()
716 EAPI void eo_xunref(Eo *obj, const Eo *ref_obj);
719 * @brief Enable or disable the manual free feature.
720 * @param obj the object to work on.
721 * @param manual_free indicates if the free is manual (EINA_TRUE) or automatic (EINA_FALSE).
723 * The developer is in charge to call the function eo_manual_free to free the memory allocated for this object.
725 * Do not use, unless you really know what you are doing. It's used by Evas
726 * because evas wants to keep its private data available even after the object
727 * is deleted. Setting this to true makes Eo destruct the object but not free
728 * the private data or the object itself.
730 * @see eo_manual_free()
732 EAPI void eo_manual_free_set(Eo *obj, Eina_Bool manual_free);
735 * @brief Frees the object.
736 * @param obj the object to work on.
737 * This function must be called by the developer if the function
738 * eo_manual_free_set has been called before with the parameter EINA_TRUE.
739 * An error will be printed if this function is called when the manual
740 * free option is not set to EINA_TRUE or the number of refs is not 0.
742 * @see eo_manual_free_set()
744 EAPI void eo_manual_free(Eo *obj);
747 * @addtogroup Eo_Composite_Objects Composite Objects.
752 * @brief Make an object a composite object of another.
753 * @param comp_obj the object that will be used to composite parent.
754 * @param parent the "parent" object.
756 * This functions also sets the parent of comp_obj to parent.
758 * @see eo_composite_detach()
759 * @see eo_composite_is()
761 EAPI void eo_composite_attach(Eo *comp_obj, Eo *parent);
764 * @brief Detach a composite object from another object.
765 * @param comp_obj the object attached to parent.
766 * @param parent the "parent" object.
768 * This functions also sets the parent of comp_obj to @c NULL.
770 * @see eo_composite_attach()
771 * @see eo_composite_is()
773 EAPI void eo_composite_detach(Eo *comp_obj, Eo *parent);
776 * @brief Check if an object is a composite object.
777 * @param comp_obj the object to be checked.
778 * @return @c EINA_TRUE if it is, @c EINA_FALSE otherwise.
780 * @see eo_composite_attach()
781 * @see eo_composite_detach()
783 EAPI Eina_Bool eo_composite_is(const Eo *comp_obj);
790 * @addtogroup Eo_Class_Base Eo's Base class.
796 * The class type for the Eo base class.
798 #define EO_BASE_CLASS eo_base_class_get()
800 * @brief Use #EO_BASE_CLASS
803 EAPI const Eo_Class *eo_base_class_get(void);
806 * @typedef eo_base_data_free_func
807 * Data free func prototype.
809 typedef void (*eo_base_data_free_func)(void *);
812 * @var EO_BASE_BASE_ID
813 * #EO_BASE_CLASS 's base id.
815 extern EAPI Eo_Op EO_BASE_BASE_ID;
818 EO_BASE_SUB_ID_CONSTRUCTOR,
819 EO_BASE_SUB_ID_DESTRUCTOR,
820 EO_BASE_SUB_ID_DATA_SET,
821 EO_BASE_SUB_ID_DATA_GET,
822 EO_BASE_SUB_ID_DATA_DEL,
823 EO_BASE_SUB_ID_WREF_ADD,
824 EO_BASE_SUB_ID_WREF_DEL,
825 EO_BASE_SUB_ID_EVENT_CALLBACK_PRIORITY_ADD,
826 EO_BASE_SUB_ID_EVENT_CALLBACK_DEL,
827 EO_BASE_SUB_ID_EVENT_CALLBACK_CALL,
828 EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_ADD,
829 EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_DEL,
830 EO_BASE_SUB_ID_EVENT_FREEZE,
831 EO_BASE_SUB_ID_EVENT_THAW,
832 EO_BASE_SUB_ID_EVENT_FREEZE_GET,
833 EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE,
834 EO_BASE_SUB_ID_EVENT_GLOBAL_THAW,
835 EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET,
840 * @def EO_BASE_ID(sub_id)
841 * Helper macro to get the full Op ID out of the sub_id for EO_BASE.
842 * @param sub_id the sub id inside EO_BASE.
844 #define EO_BASE_ID(sub_id) (EO_BASE_BASE_ID + (sub_id))
847 * @def eo_base_data_set(key, data, free_func)
848 * Set generic data to object.
849 * @param[in] key the key associated with the data
850 * @param[in] data the data to set.
851 * @param[in] free_func the func to free data with (NULL means "do nothing").
853 * @see #eo_base_data_get
854 * @see #eo_base_data_del
856 #define eo_base_data_set(key, data, free_func) EO_BASE_ID(EO_BASE_SUB_ID_DATA_SET), EO_TYPECHECK(const char *, key), EO_TYPECHECK(const void *, data), EO_TYPECHECK(eo_base_data_free_func, free_func)
859 * @def eo_base_data_get(key, data)
860 * Get generic data from object.
861 * @param[in] key the key associated with the data
862 * @param[out] data the data for the key
864 * @see #eo_base_data_set
865 * @see #eo_base_data_del
867 #define eo_base_data_get(key, data) EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), EO_TYPECHECK(const char *, key), EO_TYPECHECK(void **, data)
870 * @def eo_base_data_del(key)
871 * Del generic data from object.
872 * @param[in] key the key associated with the data
874 * @see #eo_base_data_set
875 * @see #eo_base_data_get
877 #define eo_base_data_del(key) EO_BASE_ID(EO_BASE_SUB_ID_DATA_DEL), EO_TYPECHECK(const char *, key)
881 * @brief Add a new weak reference to obj.
882 * @param wref The pointer to use for the weak ref.
884 * This function registers the object handle pointed by wref to obj so when
885 * obj is deleted it'll be updated to NULL. This functions should be used
886 * when you want to keep track of an object in a safe way, but you don't want
887 * to prevent it from being freed.
891 #define eo_wref_add(wref) EO_BASE_ID(EO_BASE_SUB_ID_WREF_ADD), EO_TYPECHECK(Eo **, wref)
895 * @brief Delete the weak reference passed.
896 * @param wref the weak reference to free.
900 #define eo_wref_del(wref) EO_BASE_ID(EO_BASE_SUB_ID_WREF_DEL), EO_TYPECHECK(Eo **, wref)
903 * @def eo_wref_del_safe
904 * @brief Delete the weak reference passed.
905 * @param wref the weak reference to free.
907 * Same as eo_wref_del(), with the different that it's not called from eobj_do()
908 * so you don't need to check if *wref is not NULL.
912 #define eo_wref_del_safe(wref) \
914 if (*wref) eo_do(*wref, eo_wref_del(wref)); \
918 * @def eo_constructor
919 * @brief Call the object's constructor.
921 * Should not be used with #eo_do. Only use it with #eo_do_super.
923 * @see #eo_destructor
925 #define eo_constructor() EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR)
929 * @brief Call the object's destructor.
931 * Should not be used with #eo_do. Only use it with #eo_do_super.
933 * @see #eo_constructor
935 #define eo_destructor() EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR)
938 * @addtogroup Eo_Events Eo's Event Handling
943 * @def EO_CALLBACK_PRIORITY_BEFORE
944 * Slightly more prioritized than default.
946 #define EO_CALLBACK_PRIORITY_BEFORE -100
948 * @def EO_CALLBACK_PRIORITY_DEFAULT
949 * Default callback priority level
951 #define EO_CALLBACK_PRIORITY_DEFAULT 0
953 * @def EO_CALLBACK_PRIORITY_AFTER
954 * Slightly less prioritized than default.
956 #define EO_CALLBACK_PRIORITY_AFTER 100
959 * @typedef Eo_Callback_Priority
961 * Callback priority value. Range is -32k - 32k. The lower the number, the
962 * higher the priority.
964 * @see EO_CALLBACK_PRIORITY_AFTER
965 * @see EO_CALLBACK_PRIORITY_BEFORE
966 * @see EO_CALLBACK_PRIORITY_DEFAULT
968 typedef short Eo_Callback_Priority;
971 * @def EO_CALLBACK_STOP
972 * Stop calling callbacks for the even of which the callback was called for.
973 * @see EO_CALLBACK_CONTINUE
975 #define EO_CALLBACK_STOP EINA_FALSE
978 * @def EO_CALLBACK_CONTINUE
979 * Continue calling callbacks for the even of which the callback was called for.
980 * @see EO_CALLBACK_STOP
982 #define EO_CALLBACK_CONTINUE EINA_TRUE
985 * @typedef Eo_Event_Cb
987 * An event callback prototype.
989 * @param data The user data registered with the callback.
990 * @param obj The object which initiated the event.
991 * @param desc The event's description.
992 * @param event_info additional data passed with the event.
993 * @return #EO_CALLBACK_STOP to stop calling additional callbacks for the event, #EO_CALLBACK_CONTINUE to continue.
995 typedef Eina_Bool (*Eo_Event_Cb)(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
998 * @def eo_event_callback_forwarder_add
999 * @brief Add an event callback forwarder for an event and an object.
1000 * @param[in] desc The description of the event to listen to.
1001 * @param[in] new_obj The object to emit events from.
1003 * @see eo_event_callback_forwarder_del()
1005 #define eo_event_callback_forwarder_add(desc, new_obj) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_ADD), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo *, new_obj)
1008 * @def eo_event_callback_forwarder_del
1009 * @brief Remove an event callback forwarder for an event and an object.
1010 * @param[in] desc The description of the event to listen to.
1011 * @param[in] new_obj The object to emit events from.
1013 * @see eo_event_callback_forwarder_add()
1015 #define eo_event_callback_forwarder_del(desc, new_obj) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_DEL), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo *, new_obj)
1018 * @def eo_event_freeze
1019 * @brief freeze events of object.
1021 * Prevents event callbacks from being called for the object.
1023 * @see #eo_event_thaw
1025 #define eo_event_freeze() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE)
1028 * @def eo_event_thaw
1029 * @brief thaw events of object.
1031 * Lets event callbacks be called for the object.
1033 * @see #eo_event_freeze
1035 #define eo_event_thaw() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_THAW)
1038 * @def eo_event_freeze_get
1039 * @brief return freeze events of object.
1041 * @param[out] fcount The event freeze count of the object.
1043 * Return event freeze count.
1045 * @see #eo_event_freeze
1046 * @see #eo_event_thaw
1048 #define eo_event_freeze_get(fcount) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE_GET), EO_TYPECHECK(int *, fcount)
1051 * @def eo_event_global_freeze
1052 * @brief freeze events of object.
1054 * Prevents event callbacks from being called for the object.
1056 * @see #eo_event_freeze
1057 * @see #eo_event_global_thaw
1059 #define eo_event_global_freeze() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE)
1062 * @def eo_event_global_thaw
1063 * @brief thaw events of object.
1065 * Lets event callbacks be called for the object.
1067 * @see #eo_event_thaw
1068 * @see #eo_event_global_freeze
1070 #define eo_event_global_thaw() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_THAW)
1073 * @def eo_event_global_freeze_get
1074 * @brief return freeze events of object.
1076 * @param[out] fcount The event freeze count of the object.
1078 * Return event freeze count.
1080 * @see #eo_event_freeze_get
1081 * @see #eo_event_global_freeze
1082 * @see #eo_event_global_thaw
1084 #define eo_event_global_freeze_get(fcount) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET), EO_TYPECHECK(int *, fcount)
1087 * @def eo_event_callback_add(obj, desc, cb, data)
1088 * Add a callback for an event.
1089 * @param[in] desc The description of the event to listen to.
1090 * @param[in] cb the callback to call.
1091 * @param[in] data additional data to pass to the callback.
1093 * callbacks of the same priority are called in reverse order of creation.
1095 * @see eo_event_callback_priority_add()
1097 #define eo_event_callback_add(desc, cb, data) \
1098 eo_event_callback_priority_add(desc, \
1099 EO_CALLBACK_PRIORITY_DEFAULT, cb, data)
1102 * @def eo_event_callback_priority_add
1103 * @brief Add a callback for an event with a specific priority.
1104 * @param[in] desc The description of the event to listen to.
1105 * @param[in] priority The priority of the callback.
1106 * @param[in] cb the callback to call.
1107 * @param[in] data additional data to pass to the callback.
1109 * callbacks of the same priority are called in reverse order of creation.
1111 * @see #eo_event_callback_add
1113 #define eo_event_callback_priority_add(desc, priority, cb, data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_PRIORITY_ADD), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo_Callback_Priority, priority), EO_TYPECHECK(Eo_Event_Cb, cb), EO_TYPECHECK(const void *, data)
1117 * @def eo_event_callback_del
1118 * @brief Del a callback with a specific data associated to it for an event.
1119 * @param[in] desc The description of the event to listen to.
1120 * @param[in] func the callback to delete.
1121 * @param[in] user_data The data to compare.
1124 #define eo_event_callback_del(desc, func, user_data) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_DEL), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(Eo_Event_Cb, func), EO_TYPECHECK(const void *, user_data)
1127 * @def eo_event_callback_call
1128 * @brief Call the callbacks for an event of an object.
1129 * @param[in] desc The description of the event to call.
1130 * @param[in] event_info Extra event info to pass to the callbacks.
1131 * @param[out] aborted @c EINA_TRUE if one of the callbacks aborted the call, @c EINA_FALSE otherwise.
1133 #define eo_event_callback_call(desc, event_info, aborted) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_CALLBACK_CALL), EO_TYPECHECK(const Eo_Event_Description *, desc), EO_TYPECHECK(const void *, event_info), EO_TYPECHECK(Eina_Bool *, aborted)
1140 * @var _EO_EV_CALLBACK_ADD
1141 * see EO_EV_CALLBACK_ADD
1143 EAPI extern const Eo_Event_Description _EO_EV_CALLBACK_ADD;
1146 * @def EO_EV_CALLBACK_ADD
1147 * The event description (of type #Eo_Event_Description) for
1148 * The "Callback listener added" event.
1150 #define EO_EV_CALLBACK_ADD (&(_EO_EV_CALLBACK_ADD))
1153 * @var _EO_EV_CALLBACK_DEL
1154 * see EO_EV_CALLBACK_DEL
1156 EAPI extern const Eo_Event_Description _EO_EV_CALLBACK_DEL;
1159 * @def EO_EV_CALLBACK_DEL
1160 * The event description (of type #Eo_Event_Description) for
1161 * The "Callback listener deleted" event.
1163 #define EO_EV_CALLBACK_DEL (&(_EO_EV_CALLBACK_DEL))
1169 EAPI extern const Eo_Event_Description _EO_EV_DEL;
1173 * Object is being deleted.
1175 #define EO_EV_DEL (&(_EO_EV_DEL))