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 * @def EO_OP_CLASS_OFFSET
39 * The bit offset of the class inside the ops.
42 #define EO_OP_CLASS_OFFSET 16
45 * @def EO_CLASS_ID_TO_BASE_ID(class_id)
46 * Translates a class id to an op base id.
49 #define EO_CLASS_ID_TO_BASE_ID(class_id) ((class_id) << EO_OP_CLASS_OFFSET)
52 * @var _eo_class_creation_lock
53 * This variable is used for locking purposes in the class_get function
54 * defined in #EO_DEFINE_CLASS.
55 * This is just to work around the fact that we need to init locks before
57 * Don't touch it if you don't know what you are doing.
60 EAPI extern Eina_Lock _eo_class_creation_lock;
64 * An enum representing the possible types of an Op.
68 EO_OP_TYPE_INVALID = -1, /**< Invalid op. */
69 EO_OP_TYPE_REGULAR = 0, /**< Regular op. */
70 EO_OP_TYPE_CONST, /**< Const op - object should not change. */
71 EO_OP_TYPE_CLASS, /**< Class op - a class op. Like static in Java/C++. */
77 * A convenience typedef for #_Eo_Op_Type.
79 typedef enum _Eo_Op_Type Eo_Op_Type;
82 * @defgroup Eo Eo Generic Object System
84 * The Eo generic object system. It was designed to be the base object
91 * @def EO_TYPECHECK(type, x)
93 * Checks x is castable to type "type" and casts it to it.
94 * @param type The C type to check against.
95 * @param x the variable to test and cast.
97 #define EO_TYPECHECK(type, x) \
106 * The basic Object type.
108 typedef struct _Eo Eo;
111 * The Eo operation type id.
113 typedef unsigned int Eo_Op;
117 * The basic Object class type.
120 typedef struct _Eo_Class Eo_Class;
123 * @typedef Eo_Class_Id
127 typedef size_t Eo_Class_Id;
131 * A special #Eo_Op meaning "No operation".
133 #define EO_NOOP ((Eo_Op) 0)
136 * @typedef eo_op_func_type
137 * The type of the Op functions. This is the type of the functions used by
140 * @see eo_op_func_type_const
142 typedef void (*eo_op_func_type)(Eo *, void *class_data, va_list *list);
145 * @typedef eo_op_func_type_const
146 * The type of the const Op functions. This is the type of the functions used
147 * by Eo. This is the same as #eo_op_func_type, except that this should
148 * be used with functions that don't modify the data.
150 * @see eo_op_func_type
152 typedef void (*eo_op_func_type_const)(const Eo *, const void *class_data, va_list *list);
155 * @typedef eo_op_func_type_class
156 * The type of the class Op functions. This is the same as #eo_op_func_type,\
157 * exepct that it's for usage with class functions, and not with object
160 * @see eo_op_func_type
162 typedef void (*eo_op_func_type_class)(const Eo_Class *, va_list *list);
165 * @addtogroup Eo_Events Eo's Event Handling
170 * @struct _Eo_Event_Description
171 * This struct holds the description of a specific event.
173 struct _Eo_Event_Description
175 const char *name; /**< name of the event. */
176 const char *doc; /**< Explanation about the event. */
180 * @typedef Eo_Event_Description
181 * A convenience typedef for #_Eo_Event_Description
183 typedef struct _Eo_Event_Description Eo_Event_Description;
186 * @def EO_EVENT_DESCRIPTION(name, doc)
187 * An helper macro to help populating #Eo_Event_Description
188 * @param name The name of the event.
189 * @param doc Additional doc for the event.
190 * @see Eo_Event_Description
192 #define EO_EVENT_DESCRIPTION(name, doc) { name, doc }
199 * @addtogroup Eo_Class Eo Class
204 * @def EO_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...)
205 * A convenience macro to be used for creating the class_get function. This
206 * macro is fairly simple but should still be used as it'll let us improve
208 * @param class_get_func_name the name of the wanted class_get function name.
209 * @param class_desc the class description.
210 * @param parent_class The parent class for the function. Look at eo_class_new() for more information.
211 * @param ... List of etxensions. Look at eo_class_new() for more information.
213 * You must use this macro if you want thread safety in class creation.
215 #define EO_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...) \
216 EO_DEFINE_CLASS_STATIC(class_get_func_name, 0, class_desc, parent_class, __VA_ARGS__)
219 * @def EO_DEFINE_CLASS_STATIC(class_get_func_name, id, class_desc, parent_class, ...)
220 * *** DO NOT USE UNLESS YOU REALLY KNOW WHAT YOU ARE DOING ***
221 * @param id a positive number to serve as the id of the class. 0 means dynamic. See eo_class_new() for details.
222 * @param class_get_func_name the name of the wanted class_get function name.
223 * @param class_desc the class description.
224 * @param parent_class The parent class for the function. Look at eo_class_new() for more information.
225 * @param ... List of etxensions. Look at eo_class_new() for more information.
227 * This macro should only be used if you know what you are doing and you want
228 * to create a class with a static id.
229 * Use #EO_DEFINE_CLASS instead.
231 * @see #EO_DEFINE_CLASS
233 #define EO_DEFINE_CLASS_STATIC(class_get_func_name, id, class_desc, parent_class, ...) \
234 EAPI const Eo_Class * \
235 class_get_func_name(void) \
237 static volatile char lk_init = 0; \
238 static Eina_Lock _my_lock; \
239 static const Eo_Class * volatile _my_class = NULL; \
240 if (EINA_LIKELY(!!_my_class)) return _my_class; \
242 eina_lock_take(&_eo_class_creation_lock); \
244 eina_lock_new(&_my_lock); \
245 if (lk_init < 2) eina_lock_take(&_my_lock); \
250 if (lk_init < 2) eina_lock_release(&_my_lock); \
251 eina_lock_release(&_eo_class_creation_lock); \
254 eina_lock_release(&_eo_class_creation_lock); \
255 _my_class = eo_class_new(class_desc, id, parent_class, __VA_ARGS__); \
256 eina_lock_release(&_my_lock); \
258 eina_lock_take(&_eo_class_creation_lock); \
259 eina_lock_free(&_my_lock); \
261 eina_lock_release(&_eo_class_creation_lock); \
267 * An enum representing the possible types of an Eo class.
271 EO_CLASS_TYPE_REGULAR = 0, /**< Regular class. */
272 EO_CLASS_TYPE_REGULAR_NO_INSTANT, /**< Regular non instant-able class. */
273 EO_CLASS_TYPE_INTERFACE, /**< Interface */
274 EO_CLASS_TYPE_MIXIN /**< Mixin */
278 * @typedef Eo_Class_Type
279 * A convenience typedef for #_Eo_Class_Type.
281 typedef enum _Eo_Class_Type Eo_Class_Type;
284 * @struct _Eo_Op_Func_Description
285 * Used to associate an Op with a func.
286 * @see eo_class_funcs_set
288 struct _Eo_Op_Func_Description
290 Eo_Op op; /**< The op */
291 eo_op_func_type func; /**< The function to call for the op. */
292 Eo_Op_Type op_type; /**< The type of the op */
296 * @typedef Eo_Op_Func_Description
297 * A convenience typedef for #_Eo_Op_Func_Description
299 typedef struct _Eo_Op_Func_Description Eo_Op_Func_Description;
302 * @def EO_OP_FUNC(op, func)
303 * A convenience macro to be used when populating the #Eo_Op_Func_Description
306 * @see EO_OP_FUNC_CONST
308 #define EO_OP_FUNC(op, func) { op, EO_TYPECHECK(eo_op_func_type, func), EO_OP_TYPE_REGULAR }
311 * @def EO_OP_FUNC_CONST(op, func)
312 * A convenience macro to be used when populating the #Eo_Op_Func_Description
314 * The same as #EO_OP_FUNC but for const functions.
318 #define EO_OP_FUNC_CONST(op, func) { op, (eo_op_func_type) EO_TYPECHECK(eo_op_func_type_const, func), EO_OP_TYPE_CONST }
321 * @def EO_OP_FUNC_CLASS(op, func)
322 * A convenience macro to be used when populating the #Eo_Op_Func_Description
324 * The same as #EO_OP_FUNC but for class functions.
328 #define EO_OP_FUNC_CLASS(op, func) { op, (eo_op_func_type) EO_TYPECHECK(eo_op_func_type_class, func), EO_OP_TYPE_CLASS }
331 * @def EO_OP_FUNC_SENTINEL
332 * A convenience macro to be used when populating the #Eo_Op_Func_Description
333 * array. It must appear at the end of the ARRAY.
335 #define EO_OP_FUNC_SENTINEL { 0, NULL, EO_OP_TYPE_INVALID }
338 * @struct _Eo_Op_Description
339 * This struct holds the description of a specific op.
341 struct _Eo_Op_Description
343 Eo_Op sub_op; /**< The sub_id of the op in it's class. */
344 const char *name; /**< The name of the op. */
345 const char *doc; /**< Explanation about the Op. */
346 Eo_Op_Type op_type; /**< The type of the Op. */
350 * @typedef Eo_Op_Description
351 * A convenience typedef for #_Eo_Op_Description
353 typedef struct _Eo_Op_Description Eo_Op_Description;
356 * @struct _Eo_Class_Description
357 * This struct holds the description of a class.
358 * This description should be passed to eo_class_new.
359 * Please use the #EO_CLASS_DESCRIPTION_OPS macro when populating it.
361 struct _Eo_Class_Description
363 const char *name; /**< The name of the class. */
364 Eo_Class_Type type; /**< The type of the class. */
367 const Eo_Op_Description *descs;
369 } ops; /**< The ops description, should be filled using #EO_CLASS_DESCRIPTION_OPS */
370 const Eo_Event_Description **events; /**< The event descriptions for this class. */
371 size_t data_size; /**< The size of data (private + protected + public) this class needs per object. */
372 void (*constructor)(Eo *obj, void *class_data); /**< The constructor of the object. */
373 void (*destructor)(Eo *obj, void *class_data); /**< The destructor of the object. */
374 void (*class_constructor)(Eo_Class *klass); /**< The constructor of the class. */
375 void (*class_destructor)(Eo_Class *klass); /**< The destructor of the class. */
379 * @typedef Eo_Class_Description
380 * A convenience typedef for #_Eo_Class_Description
382 typedef struct _Eo_Class_Description Eo_Class_Description;
385 * @def EO_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count)
386 * An helper macro to help populating #Eo_Class_Description.
387 * @param base_op_id A pointer to the base op id of the class.
388 * @param op_descs the op descriptions array.
389 * @param count the number of ops in the op descriptions array.
391 #define EO_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) { base_op_id, op_descs, count }
394 * @def EO_OP_DESCRIPTION(op, doc)
395 * An helper macro to help populating #Eo_Op_Description
396 * @param sub_id The sub id of the op being described.
397 * @param doc Additional doc for the op.
398 * @see Eo_Op_Description
399 * @see EO_OP_DESCRIPTION_CLASS
400 * @see EO_OP_DESCRIPTION_CONST
401 * @see EO_OP_DESCRIPTION_SENTINEL
403 #define EO_OP_DESCRIPTION(sub_id, doc) { sub_id, #sub_id, doc, EO_OP_TYPE_REGULAR }
406 * @def EO_OP_DESCRIPTION_CONST(op, doc)
407 * An helper macro to help populating #Eo_Op_Description
408 * This macro is the same as EO_OP_DESCRIPTION but indicates that the op's
409 * implementation should not change the object.
410 * @param sub_id The sub id of the op being described.
411 * @param doc Additional doc for the op.
412 * @see Eo_Op_Description
413 * @see EO_OP_DESCRIPTION
414 * @see EO_OP_DESCRIPTION_SENTINEL
416 #define EO_OP_DESCRIPTION_CONST(sub_id, doc) { sub_id, #sub_id, doc, EO_OP_TYPE_CONST }
419 * @def EO_OP_DESCRIPTION_CLASS(op, doc)
420 * An helper macro to help populating #Eo_Op_Description
421 * This macro is the same as EO_OP_DESCRIPTION but indicates that the op's
422 * implementation is of type CLASS.
423 * @param sub_id The sub id of the op being described.
424 * @param doc Additional doc for the op.
425 * @see Eo_Op_Description
426 * @see EO_OP_DESCRIPTION
427 * @see EO_OP_DESCRIPTION_SENTINEL
429 #define EO_OP_DESCRIPTION_CLASS(sub_id, doc) { sub_id, #sub_id, doc, EO_OP_TYPE_CLASS }
432 * @def EO_OP_DESCRIPTION_SENTINEL
433 * An helper macro to help populating #Eo_Op_Description
434 * Should be placed at the end of the array.
435 * @see Eo_Op_Description
436 * @see EO_OP_DESCRIPTION
438 #define EO_OP_DESCRIPTION_SENTINEL { 0, NULL, NULL, EO_OP_TYPE_INVALID }
441 * @brief Create a new class.
442 * @param desc the class description to create the class with.
443 * @param id a positive number to serve as the id of the class. 0 means dynamic allocation. The number of static Ids is limited and regular users should not use static ids.
444 * @param parent the class to inherit from.
445 * @param ... A NULL terminated list of extensions (interfaces, mixins and the classes of any composite objects).
446 * @return The new class's handle on success, or NULL otherwise.
448 * You should use #EO_DEFINE_CLASS. It'll provide thread safety and other
451 * @see #EO_DEFINE_CLASS
453 EAPI const Eo_Class *eo_class_new(const Eo_Class_Description *desc, Eo_Class_Id id, const Eo_Class *parent, ...);
456 * @brief Sets the OP functions for a class.
457 * @param klass the class to set the functions to.
458 * @param func_descs a NULL terminated array of #Eo_Op_Func_Description
460 * Should be called from within the class constructor.
462 EAPI void eo_class_funcs_set(Eo_Class *klass, const Eo_Op_Func_Description *func_descs);
465 * @brief Gets the name of the passed class.
466 * @param klass the class to work on.
467 * @return The class's name.
469 * @see eo_class_get()
471 EAPI const char *eo_class_name_get(const Eo_Class *klass);
478 * @brief Init the eo subsystem
479 * @return @c EINA_TRUE on success.
483 EAPI Eina_Bool eo_init(void);
486 * @brief Shutdown the eo subsystem
487 * @return @c EINA_TRUE on success.
491 EAPI Eina_Bool eo_shutdown(void);
495 * A convenience wrapper around eo_do_internal()
496 * @see eo_do_internal
498 #define eo_do(obj, ...) eo_do_internal(obj, EO_OP_TYPE_REGULAR, __VA_ARGS__, EO_NOOP)
502 * Same as #eo_do but only for const ops.
505 #define eo_query(obj, ...) eo_do_internal((Eo *) EO_TYPECHECK(const Eo *, obj), EO_OP_TYPE_CONST, __VA_ARGS__, EO_NOOP)
509 * A convenience wrapper around eo_class_do_internal()
510 * @see eo_class_do_internal
512 #define eo_class_do(klass, ...) eo_class_do_internal(klass, __VA_ARGS__, EO_NOOP)
515 * @brief Calls op functions of an object
516 * @param obj The object to work on
517 * @param op_type The type of the ops that are passed.
518 * @param ... NULL terminated list of OPs and parameters.
519 * @return @c EINA_TRUE on success.
521 * Use the helper macros, don't pass the parameters manually.
522 * Use #eo_do instead of this function.
526 EAPI Eina_Bool eo_do_internal(Eo *obj, Eo_Op_Type op_type, ...);
529 * @brief Calls op functions of a class.
530 * @param klass The class to work on
531 * @param ... NULL terminated list of OPs and parameters.
532 * @return @c EINA_TRUE on success.
534 * Use the helper macros, don't pass the parameters manually.
535 * Use #eo_do instead of this function.
539 EAPI Eina_Bool eo_class_do_internal(const Eo_Class *klass, ...);
542 * @brief Calls the super function for the specific op.
543 * @param obj The object to work on
544 * @param ... list of parameters.
545 * @return @c EINA_TRUE on success.
547 * Unlike eo_do() and eo_query(), this function only accepts one op.
549 * Use the helper macros, don't pass the parameters manually.
551 * Same as eo_do_super() just for const objects.
556 #define eo_query_super(obj, ...) eo_do_super_internal((Eo *) EO_TYPECHECK(const Eo *, obj), EO_OP_TYPE_CONST, __VA_ARGS__)
559 * @brief Calls the super function for the specific op.
560 * @param obj The object to work on
561 * @param ... list of parameters.
562 * @return @c EINA_TRUE on success.
564 * Unlike eo_do() and eo_query(), this function only accepts one op.
567 * @see eo_query_super()
569 #define eo_do_super(obj, ...) eo_do_super_internal(obj, EO_OP_TYPE_REGULAR, __VA_ARGS__)
572 * @brief Calls the super function for the specific op.
573 * @param klass The klass to work on
574 * @param ... list of parameters.
575 * @return @c EINA_TRUE on success.
577 * Unlike eo_class_do(), this function only accepts one op.
581 #define eo_class_do_super(klass, ...) eo_class_do_super_internal(klass, __VA_ARGS__)
584 * @brief Calls the super function for the specific op.
585 * @param obj The object to work on
586 * @param op_type The type of the ops that are passed.
587 * @param op The wanted op.
588 * @param ... list of parameters.
589 * @return @c EINA_TRUE on success.
591 * Don't use this function, use the wrapping macros instead.
595 * @see #eo_query_super
597 EAPI Eina_Bool eo_do_super_internal(Eo *obj, Eo_Op_Type op_type, Eo_Op op, ...);
600 * @brief Calls the super function for the specific op.
601 * @param klass The klass to work on
602 * @param op The wanted op.
603 * @param ... list of parameters.
604 * @return @c EINA_TRUE on success.
606 * Don't use this function, use the wrapping macros instead.
609 * @see #eo_class_do_super
611 EAPI Eina_Bool eo_class_do_super_internal(const Eo_Class *klass, Eo_Op op, ...);
614 * @brief Gets the class of the object.
615 * @param obj The object to work on
616 * @return The object's class.
618 * @see eo_class_name_get()
620 EAPI const Eo_Class *eo_class_get(const Eo *obj);
623 * @brief Calls the super constructor of the object passed.
624 * @param obj the object to work on.
626 * @see eo_destructor_super()
628 EAPI void eo_constructor_super(Eo *obj);
631 * @brief Calls the super destructor of the object passed.
632 * @param obj the object to work on.
634 * @see eo_constructor_super()
636 EAPI void eo_destructor_super(Eo *obj);
640 * @brief Notify eo that there was an error when constructing, destructing or calling a function of the object.
641 * @param obj the object to work on.
643 * @see eo_error_get()
645 #define eo_error_set(obj) eo_error_set_internal(obj, __FILE__, __LINE__)
648 EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line);
652 * @brief Create a new object.
653 * @param klass the class of the object to create.
654 * @param parent the parent to set to the object.
655 * @return An handle to the new object on success, NULL otherwise.
657 EAPI Eo *eo_add(const Eo_Class *klass, Eo *parent);
660 * @brief Get the parent of an object
661 * @param obj the object to get the parent of.
662 * @return a pointer to the parent object.
664 * @see eo_parent_set()
666 EAPI Eo *eo_parent_get(const Eo *obj);
669 * @brief Set the parent of an object
670 * @param obj the object to get the parent of.
671 * @param parent the new parent.
672 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure.
674 * Parents keep references to their children so in order to delete objects
675 * that have parents you need to set parent to NULL or use eo_del() that
676 * does that for you (and also unrefs the object).
679 * @see eo_parent_get()
681 EAPI Eina_Bool eo_parent_set(Eo *obj, const Eo *parent);
684 * @brief Get a pointer to the data of an object for a specific class.
685 * @param obj the object to work on.
686 * @param klass the klass associated with the data.
687 * @return a pointer to the data.
689 EAPI void *eo_data_get(const Eo *obj, const Eo_Class *klass);
692 * @brief Increment the object's reference count by 1.
693 * @param obj the object to work on.
694 * @return The object passed.
696 * It's very easy to get a refcount leak and start leaking memory because
697 * of a forgotten unref or an extra ref. That is why there are eo_xref
698 * and eo_xunref that will make debugging easier in such a case.
699 * Therefor, these functions should only be used in small scopes, i.e at the
700 * start of some section in which the object may get freed, or if you know
701 * what you are doing.
706 EAPI Eo *eo_ref(const Eo *obj);
709 * @brief Decrement the object's reference count by 1 and free it if needed.
710 * @param obj the object to work on.
715 EAPI void eo_unref(const Eo *obj);
718 * @brief Return the ref count of the object passed.
719 * @param obj the object to work on.
720 * @return the ref count of the object.
725 EAPI int eo_ref_get(const Eo *obj);
728 * @brief Unrefs the object and reparents it to NULL.
729 * @param obj the object to work on.
731 * Because eo_del() unrefs and reparents to NULL, it doesn't really delete the
735 * @see eo_parent_set()
737 EAPI void eo_del(const Eo *obj);
740 * @def eo_xref(obj, ref_obj)
741 * Convenience macro around eo_xref_internal()
744 #define eo_xref(obj, ref_obj) eo_xref_internal(obj, ref_obj, __FILE__, __LINE__)
747 * @brief Increment the object's reference count by 1 (and associate the ref with ref_obj)
748 * @param obj the object to work on.
749 * @param ref_obj the object that references obj.
750 * @param file the call's filename.
751 * @param line the call's line number.
752 * @return The object passed (obj)
754 * People should not use this function, use #eo_xref instead.
755 * A compile flag my make it and eobj_xunref() behave the same as eobj_ref()
756 * and eobj_unref() respectively. So this should be used wherever possible.
760 EAPI Eo *eo_xref_internal(Eo *obj, const Eo *ref_obj, const char *file, int line);
763 * @brief Decrement the object's reference count by 1 and free it if needed. Will free the ref associated with ref_obj).
764 * @param obj the object to work on.
765 * @param ref_obj the object that references obj.
767 * This function only enforces the checks for object association. I.e don't rely
768 * on it. If such enforces are compiled out, this function behaves the same as
771 * @see eo_xref_internal()
773 EAPI void eo_xunref(Eo *obj, const Eo *ref_obj);
776 * @addtogroup Eo_Composite_Objects Composite Objects.
781 * @brief Make an object a composite object of another.
782 * @param obj the "parent" object.
783 * @param comp_obj the object that will be used to composite obj.
785 * @see eo_composite_object_detach()
786 * @see eo_composite_is()
788 EAPI void eo_composite_object_attach(Eo *obj, Eo *comp_obj);
791 * @brief Detach a composite object from another object.
792 * @param obj the "parent" object.
793 * @param comp_obj the object attached to obj.
795 * @see eo_composite_object_attach()
796 * @see eo_composite_is()
798 EAPI void eo_composite_object_detach(Eo *obj, Eo *comp_obj);
801 * @brief Check if an object is a composite object.
802 * @param comp_obj the object to be checked.
803 * @return @c EINA_TRUE if it is, @c EINA_FALSE otherwise.
805 * @see eo_composite_object_attach()
806 * @see eo_composite_object_detach()
808 EAPI Eina_Bool eo_composite_is(const Eo *comp_obj);
811 * @brief Enable or disable the manual free feature.
812 * @param obj the object to work on.
813 * @param manual_free indicates if the free is manual (EINA_TRUE) or automatic (EINA_FALSE).
815 * The developer is in charge to call the function eo_manual_free to free the memory allocated for this object.
817 * Do not use, unless you really know what you are doing. It's used by Evas
818 * because evas wants to keep its private data available even after the object
819 * is deleted. Setting this to true makes Eo destruct the object but not free
820 * the private data or the object itself.
822 * @see eo_manual_free()
824 EAPI void eo_manual_free_set(Eo *obj, Eina_Bool manual_free);
827 * @brief Frees the object.
828 * @param obj the object to work on.
829 * This function must be called by the developer if the function
830 * eo_manual_free_set has been called before with the parameter EINA_TRUE.
831 * An error will be printed if this function is called when the manual
832 * free option is not set to EINA_TRUE or the number of refs is not 0.
834 * @see eo_manual_free_set()
836 EAPI void eo_manual_free(Eo *obj);
843 * @addtogroup Eo_Class_Base Eo's Base class.
849 * The class type for the Eo base class.
851 #define EO_BASE_CLASS eo_base_class_get()
853 * @brief Use #EO_BASE_CLASS
856 EAPI const Eo_Class *eo_base_class_get(void) EINA_CONST;
859 * @typedef eo_base_data_free_func
860 * Data free func prototype.
862 typedef void (*eo_base_data_free_func)(void *);
865 * @def EO_BASE_CLASS_ID
866 * #EO_BASE_CLASS 's class id.
868 #define EO_BASE_CLASS_ID 1
871 * @def EO_BASE_BASE_ID
872 * #EO_BASE_CLASS 's base id.
874 #define EO_BASE_BASE_ID EO_CLASS_ID_TO_BASE_ID(EO_BASE_CLASS_ID)
877 EO_BASE_SUB_ID_DATA_SET,
878 EO_BASE_SUB_ID_DATA_GET,
879 EO_BASE_SUB_ID_DATA_DEL,
880 EO_BASE_SUB_ID_WREF_ADD,
881 EO_BASE_SUB_ID_WREF_DEL,
882 EO_BASE_SUB_ID_EVENT_CALLBACK_PRIORITY_ADD,
883 EO_BASE_SUB_ID_EVENT_CALLBACK_DEL,
884 EO_BASE_SUB_ID_EVENT_CALLBACK_CALL,
885 EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_ADD,
886 EO_BASE_SUB_ID_EVENT_CALLBACK_FORWARDER_DEL,
887 EO_BASE_SUB_ID_EVENT_FREEZE,
888 EO_BASE_SUB_ID_EVENT_THAW,
889 EO_BASE_SUB_ID_EVENT_FREEZE_GET,
890 EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE,
891 EO_BASE_SUB_ID_EVENT_GLOBAL_THAW,
892 EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET,
897 * @def EO_BASE_ID(sub_id)
898 * Helper macro to get the full Op ID out of the sub_id for EO_BASE.
899 * @param sub_id the sub id inside EO_BASE.
901 #define EO_BASE_ID(sub_id) (EO_BASE_BASE_ID + (sub_id))
904 * @def eo_base_data_set(key, data, free_func)
905 * Set generic data to object.
906 * @param[in] key the key associated with the data
907 * @param[in] data the data to set.
908 * @param[in] free_func the func to free data with (NULL means "do nothing").
910 * @see #eo_base_data_get
911 * @see #eo_base_data_del
913 #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)
916 * @def eo_base_data_get(key, data)
917 * Get generic data from object.
918 * @param[in] key the key associated with the data
919 * @param[out] data the data for the key
921 * @see #eo_base_data_set
922 * @see #eo_base_data_del
924 #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)
927 * @def eo_base_data_del(key)
928 * Del generic data from object.
929 * @param[in] key the key associated with the data
931 * @see #eo_base_data_set
932 * @see #eo_base_data_get
934 #define eo_base_data_del(key) EO_BASE_ID(EO_BASE_SUB_ID_DATA_DEL), EO_TYPECHECK(const char *, key)
938 * @brief Add a new weak reference to obj.
939 * @param wref The pointer to use for the weak ref.
941 * This function registers the object handle pointed by wref to obj so when
942 * obj is deleted it'll be updated to NULL. This functions should be used
943 * when you want to keep track of an object in a safe way, but you don't want
944 * to prevent it from being freed.
948 #define eo_wref_add(wref) EO_BASE_ID(EO_BASE_SUB_ID_WREF_ADD), EO_TYPECHECK(Eo **, wref)
952 * @brief Delete the weak reference passed.
953 * @param wref the weak reference to free.
957 #define eo_wref_del(wref) EO_BASE_ID(EO_BASE_SUB_ID_WREF_DEL), EO_TYPECHECK(Eo **, wref)
960 * @def eo_wref_del_safe
961 * @brief Delete the weak reference passed.
962 * @param wref the weak reference to free.
964 * Same as eo_wref_del(), with the different that it's not called from eobj_do()
965 * so you don't need to check if *wref is not NULL.
969 #define eo_wref_del_safe(wref) \
971 if (*wref) eo_do(*wref, eo_wref_del(wref)); \
975 * @addtogroup Eo_Events Eo's Event Handling
980 * @def EO_CALLBACK_PRIORITY_BEFORE
981 * Slightly more prioritized than default.
983 #define EO_CALLBACK_PRIORITY_BEFORE -100
985 * @def EO_CALLBACK_PRIORITY_DEFAULT
986 * Default callback priority level
988 #define EO_CALLBACK_PRIORITY_DEFAULT 0
990 * @def EO_CALLBACK_PRIORITY_AFTER
991 * Slightly less prioritized than default.
993 #define EO_CALLBACK_PRIORITY_AFTER 100
996 * @typedef Eo_Callback_Priority
998 * Callback priority value. Range is -32k - 32k. The lower the number, the
999 * higher the priority.
1001 * @see EO_CALLBACK_PRIORITY_AFTER
1002 * @see EO_CALLBACK_PRIORITY_BEFORE
1003 * @see EO_CALLBACK_PRIORITY_DEFAULT
1005 typedef short Eo_Callback_Priority;
1008 * @def EO_CALLBACK_STOP
1009 * Stop calling callbacks for the even of which the callback was called for.
1010 * @see EO_CALLBACK_CONTINUE
1012 #define EO_CALLBACK_STOP EINA_FALSE
1015 * @def EO_CALLBACK_CONTINUE
1016 * Continue calling callbacks for the even of which the callback was called for.
1017 * @see EO_CALLBACK_STOP
1019 #define EO_CALLBACK_CONTINUE EINA_TRUE
1022 * @typedef Eo_Event_Cb
1024 * An event callback prototype.
1026 * @param data The user data registered with the callback.
1027 * @param obj The object which initiated the event.
1028 * @param desc The event's description.
1029 * @param event_info additional data passed with the event.
1030 * @return #EO_CALLBACK_STOP to stop calling additional callbacks for the event, #EO_CALLBACK_CONTINUE to continue.
1032 typedef Eina_Bool (*Eo_Event_Cb)(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
1035 * @def eo_event_callback_forwarder_add
1036 * @brief Add an event callback forwarder for an event and an object.
1037 * @param[in] desc The description of the event to listen to.
1038 * @param[in] new_obj The object to emit events from.
1040 * @see eo_event_callback_forwarder_del()
1042 #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)
1045 * @def eo_event_callback_forwarder_del
1046 * @brief Remove an event callback forwarder for an event and an object.
1047 * @param[in] desc The description of the event to listen to.
1048 * @param[in] new_obj The object to emit events from.
1050 * @see eo_event_callback_forwarder_add()
1052 #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)
1055 * @def eo_event_freeze
1056 * @brief freeze events of object.
1058 * Prevents event callbacks from being called for the object.
1060 * @see #eo_event_thaw
1062 #define eo_event_freeze() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE)
1065 * @def eo_event_thaw
1066 * @brief thaw events of object.
1068 * Lets event callbacks be called for the object.
1070 * @see #eo_event_freeze
1072 #define eo_event_thaw() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_THAW)
1075 * @def eo_event_freeze_get
1076 * @brief return freeze events of object.
1078 * @param[out] fcount The event freeze count of the object.
1080 * Return event freeze count.
1082 * @see #eo_event_freeze
1083 * @see #eo_event_thaw
1085 #define eo_event_freeze_get(fcount) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE_GET), EO_TYPECHECK(int *, fcount)
1088 * @def eo_event_global_freeze
1089 * @brief freeze events of object.
1091 * Prevents event callbacks from being called for the object.
1093 * @see #eo_event_freeze
1094 * @see #eo_event_global_thaw
1096 #define eo_event_global_freeze() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE)
1099 * @def eo_event_global_thaw
1100 * @brief thaw events of object.
1102 * Lets event callbacks be called for the object.
1104 * @see #eo_event_thaw
1105 * @see #eo_event_global_freeze
1107 #define eo_event_global_thaw() EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_THAW)
1110 * @def eo_event_global_freeze_get
1111 * @brief return freeze events of object.
1113 * @param[out] fcount The event freeze count of the object.
1115 * Return event freeze count.
1117 * @see #eo_event_freeze_get
1118 * @see #eo_event_global_freeze
1119 * @see #eo_event_global_thaw
1121 #define eo_event_global_freeze_get(fcount) EO_BASE_ID(EO_BASE_SUB_ID_EVENT_GLOBAL_FREEZE_GET), EO_TYPECHECK(int *, fcount)
1124 * @def eo_event_callback_add(obj, desc, cb, data)
1125 * Add a callback for an event.
1126 * @param[in] desc The description of the event to listen to.
1127 * @param[in] cb the callback to call.
1128 * @param[in] data additional data to pass to the callback.
1130 * callbacks of the same priority are called in reverse order of creation.
1132 * @see eo_event_callback_priority_add()
1134 #define eo_event_callback_add(desc, cb, data) \
1135 eo_event_callback_priority_add(desc, \
1136 EO_CALLBACK_PRIORITY_DEFAULT, cb, data)
1139 * @def eo_event_callback_priority_add
1140 * @brief Add a callback for an event with a specific priority.
1141 * @param[in] desc The description of the event to listen to.
1142 * @param[in] priority The priority of the callback.
1143 * @param[in] cb the callback to call.
1144 * @param[in] data additional data to pass to the callback.
1146 * callbacks of the same priority are called in reverse order of creation.
1148 * @see #eo_event_callback_add
1150 #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)
1154 * @def eo_event_callback_del
1155 * @brief Del a callback with a specific data associated to it for an event.
1156 * @param[in] desc The description of the event to listen to.
1157 * @param[in] func the callback to delete.
1158 * @param[in] user_data The data to compare.
1161 #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)
1164 * @def eo_event_callback_call
1165 * @brief Call the callbacks for an event of an object.
1166 * @param[in] desc The description of the event to call.
1167 * @param[in] event_info Extra event info to pass to the callbacks.
1168 * @param[out] aborted @c EINA_TRUE if one of the callbacks aborted the call, @c EINA_FALSE otherwise.
1170 #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)
1177 * @var _EO_EV_CALLBACK_ADD
1178 * see EO_EV_CALLBACK_ADD
1180 EAPI extern const Eo_Event_Description _EO_EV_CALLBACK_ADD;
1183 * @def EO_EV_CALLBACK_ADD
1184 * The event description (of type #Eo_Event_Description) for
1185 * The "Callback listener added" event.
1187 #define EO_EV_CALLBACK_ADD (&(_EO_EV_CALLBACK_ADD))
1190 * @var _EO_EV_CALLBACK_DEL
1191 * see EO_EV_CALLBACK_DEL
1193 EAPI extern const Eo_Event_Description _EO_EV_CALLBACK_DEL;
1196 * @def EO_EV_CALLBACK_DEL
1197 * The event description (of type #Eo_Event_Description) for
1198 * The "Callback listener deleted" event.
1200 #define EO_EV_CALLBACK_DEL (&(_EO_EV_CALLBACK_DEL))
1206 EAPI extern const Eo_Event_Description _EO_EV_DEL;
1210 * Object is being deleted.
1212 #define EO_EV_DEL (&(_EO_EV_DEL))