7 /* Check that the types are castable and cast them. */
8 #define EOBJ_TYPECHECK(type, x) \
16 #define EOBJ_ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*arr))
18 typedef struct _Eobj Eobj;
19 typedef uintptr_t Eobj_Op;
21 typedef struct _Eobj_Class Eobj_Class;
22 typedef int Eobj_Class_Id;
26 EOBJ_CLASS_TYPE_REGULAR = 0,
27 EOBJ_CLASS_TYPE_REGULAR_NO_INSTANT,
28 EOBJ_CLASS_TYPE_INTERFACE,
32 typedef void (*eobj_op_func_type)(Eobj *, Eobj_Op, va_list *list);
37 eobj_op_func_type func;
38 } Eobj_Op_Func_Description;
40 #define EOBJ_OP_FUNC_DESCRIPTION(op, func) { op, func }
41 #define EOBJ_OP_FUNC_DESCRIPTION_SENTINEL { 0, NULL }
45 const char *name; /**< name used for lookups */
46 const char *type; /**< used for introspection purposes, documents what goes as callback event information (@c event_info) */
47 const char *doc; /**< documentation for introspection purposes */
48 } Eobj_Event_Description;
55 /* FIXME: properly define the type so it'll support get/set and etc.
56 * Do I even need/want type? If so, do I need/want it here? docs aren't
60 } Eobj_Op_Description;
68 const Eobj_Op_Description *descs;
71 const Eobj_Event_Description **events;
73 void (*constructor)(Eobj *obj);
74 void (*destructor)(Eobj *obj);
75 void (*class_constructor)(Eobj_Class *klass);
76 void (*class_destructor)(Eobj_Class *klass);
77 } Eobj_Class_Description;
79 #define EOBJ_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) { base_op_id, op_descs, count }
81 #define EOBJ_OP_DESCRIPTION(op, type, doc) { op, #op, type, doc }
82 #define EOBJ_OP_DESCRIPTION_SENTINEL { 0, NULL, NULL, NULL }
84 #define EOBJ_EVENT_DESCRIPTION(name, type, doc) { name, type, doc }
86 EAPI Eina_Bool eobj_init(void);
87 EAPI Eina_Bool eobj_shutdown(void);
89 #define eobj_do(object, ...) eobj_do_internal(object, __VA_ARGS__, NULL)
90 #define eobj_class_do(object, klass, ...) eobj_class_do_internal(object, klass, __VA_ARGS__, NULL)
91 #define eobj_class_parent_do(object, klass, ...) eobj_class_do_internal(object, eobj_class_parent_get(klass), __VA_ARGS__, NULL)
93 EAPI Eina_Bool eobj_do_internal(Eobj *obj, ...);
95 EAPI Eina_Bool eobj_class_do_internal(Eobj *obj, const Eobj_Class *klass, ...);
97 EAPI const Eobj_Class *eobj_class_get(Eobj *obj);
98 EAPI const Eobj_Class *eobj_class_parent_get(const Eobj_Class *klass);
99 EAPI const char *eobj_class_name_get(const Eobj_Class *klass);
101 EAPI void eobj_constructor_super(Eobj *obj);
102 EAPI void eobj_destructor_super(Eobj *obj);
103 EAPI void eobj_constructor_error_set(Eobj *obj);
104 EAPI Eina_Bool eobj_constructor_error_get(const Eobj *obj);
106 EAPI Eobj_Class *eobj_class_new(const Eobj_Class_Description *desc, const Eobj_Class *parent, ...);
107 EAPI void eobj_class_free(Eobj_Class *klass);
108 EAPI void eobj_class_funcs_set(Eobj_Class *klass, const Eobj_Op_Func_Description *func_descs);
110 EAPI Eobj *eobj_add(const Eobj_Class *klass, Eobj *parent);
111 EAPI Eobj *eobj_parent_get(Eobj *obj);
112 EAPI void *eobj_data_get(Eobj *obj, const Eobj_Class *klass);
113 EAPI Eobj *eobj_ref(Eobj *obj);
114 EAPI void eobj_unref(Eobj *obj);
115 EAPI void eobj_del(Eobj *obj);
116 EAPI void *eobj_generic_data_set(Eobj *obj, const char *key, const void *data);
117 EAPI void *eobj_generic_data_get(const Eobj *obj, const char *key);
118 EAPI void *eobj_generic_data_del(Eobj *obj, const char *key);
120 #define EOBJ_CLASS_BASE eobj_base_class_get()
121 EAPI const Eobj_Class *eobj_base_class_get(void) EINA_CONST;
123 EAPI void eobj_composite_object_attach(Eobj *obj, Eobj *emb_obj);
124 EAPI void eobj_composite_object_detach(Eobj *obj, Eobj *emb_obj);
125 EAPI Eina_Bool eobj_composite_is(Eobj *emb_obj);
129 * @def EOBJ_CALLBACK_PRIORITY_BEFORE
130 * Slightly more prioritized than default.
132 #define EOBJ_CALLBACK_PRIORITY_BEFORE -100
134 * @def EOBJ_CALLBACK_PRIORITY_DEFAULT
135 * Default callback priority level
137 #define EOBJ_CALLBACK_PRIORITY_DEFAULT 0
139 * @def EOBJ_CALLBACK_PRIORITY_AFTER
140 * Slightly less prioritized than default.
142 #define EOBJ_CALLBACK_PRIORITY_AFTER 100
143 typedef short Eobj_Callback_Priority;
145 /* True meaning continue, False meaning stop callbacks. - Make it an enum? */
146 typedef Eina_Bool (*Eobj_Event_Cb)(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info);
148 EAPI Eina_Bool eobj_event_callback_forwarder_add(Eobj *obj, const Eobj_Event_Description *desc, Eobj *new_obj);
149 EAPI Eina_Bool eobj_event_callback_forwarder_del(Eobj *obj, const Eobj_Event_Description *desc, Eobj *new_obj);
151 /* callbacks of the same priority are called in reverse order of creation. */
152 EAPI Eina_Bool eobj_event_callback_add(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb cb, const void *data);
153 EAPI Eina_Bool eobj_event_callback_priority_add(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Callback_Priority priority, Eobj_Event_Cb cb, const void *data);
154 EAPI void *eobj_event_callback_del(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb func);
155 EAPI void *eobj_event_callback_del_full(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb func, const void *user_data);
156 EAPI Eina_Bool eobj_event_callback_call(Eobj *obj, const Eobj_Event_Description *desc, const void *event_info);
158 EAPI extern const Eobj_Event_Description _EOBJ_SIG_CALLBACK_ADD;
159 #define EOBJ_SIG_CALLBACK_ADD (&(_EOBJ_SIG_CALLBACK_ADD))
160 EAPI extern const Eobj_Event_Description _EOBJ_SIG_CALLBACK_DEL;
161 #define EOBJ_SIG_CALLBACK_DEL (&(_EOBJ_SIG_CALLBACK_DEL))