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 #define EOBJ_NOOP ((Eobj_Op) 0)
23 typedef struct _Eobj_Class Eobj_Class;
24 typedef int Eobj_Class_Id;
28 EOBJ_CLASS_TYPE_REGULAR = 0,
29 EOBJ_CLASS_TYPE_REGULAR_NO_INSTANT,
30 EOBJ_CLASS_TYPE_INTERFACE,
34 typedef void (*eobj_op_func_type)(Eobj *, Eobj_Op, va_list *list);
39 eobj_op_func_type func;
40 } Eobj_Op_Func_Description;
42 #define EOBJ_OP_FUNC_DESCRIPTION(op, func) { op, func }
43 #define EOBJ_OP_FUNC_DESCRIPTION_SENTINEL { 0, NULL }
47 const char *name; /**< name used for lookups */
48 const char *type; /**< used for introspection purposes, documents what goes as callback event information (@c event_info) */
49 const char *doc; /**< documentation for introspection purposes */
50 } Eobj_Event_Description;
57 /* FIXME: properly define the type so it'll support get/set and etc.
58 * Do I even need/want type? If so, do I need/want it here? docs aren't
62 } Eobj_Op_Description;
70 const Eobj_Op_Description *descs;
73 const Eobj_Event_Description **events;
75 void (*constructor)(Eobj *obj);
76 void (*destructor)(Eobj *obj);
77 void (*class_constructor)(Eobj_Class *klass);
78 void (*class_destructor)(Eobj_Class *klass);
79 } Eobj_Class_Description;
81 #define EOBJ_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) { base_op_id, op_descs, count }
83 #define EOBJ_OP_DESCRIPTION(op, type, doc) { op, #op, type, doc }
84 #define EOBJ_OP_DESCRIPTION_SENTINEL { 0, NULL, NULL, NULL }
86 #define EOBJ_EVENT_DESCRIPTION(name, type, doc) { name, type, doc }
88 EAPI Eina_Bool eobj_init(void);
89 EAPI Eina_Bool eobj_shutdown(void);
91 #define eobj_do(object, ...) eobj_do_internal(object, __VA_ARGS__, NULL)
93 EAPI Eina_Bool eobj_do_internal(Eobj *obj, ...);
95 EAPI Eina_Bool eobj_super_do(Eobj *obj, Eobj_Op op, ...);
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 int eobj_ref_get(const Eobj *obj);
116 EAPI void eobj_del(Eobj *obj);
117 EAPI void *eobj_generic_data_set(Eobj *obj, const char *key, const void *data);
118 EAPI void *eobj_generic_data_get(const Eobj *obj, const char *key);
119 EAPI void *eobj_generic_data_del(Eobj *obj, const char *key);
121 #define EOBJ_CLASS_BASE eobj_base_class_get()
122 EAPI const Eobj_Class *eobj_base_class_get(void) EINA_CONST;
124 EAPI void eobj_composite_object_attach(Eobj *obj, Eobj *emb_obj);
125 EAPI void eobj_composite_object_detach(Eobj *obj, Eobj *emb_obj);
126 EAPI Eina_Bool eobj_composite_is(Eobj *emb_obj);
130 * @def EOBJ_CALLBACK_PRIORITY_BEFORE
131 * Slightly more prioritized than default.
133 #define EOBJ_CALLBACK_PRIORITY_BEFORE -100
135 * @def EOBJ_CALLBACK_PRIORITY_DEFAULT
136 * Default callback priority level
138 #define EOBJ_CALLBACK_PRIORITY_DEFAULT 0
140 * @def EOBJ_CALLBACK_PRIORITY_AFTER
141 * Slightly less prioritized than default.
143 #define EOBJ_CALLBACK_PRIORITY_AFTER 100
144 typedef short Eobj_Callback_Priority;
146 /* True meaning continue, False meaning stop callbacks. - Make it an enum? */
147 typedef Eina_Bool (*Eobj_Event_Cb)(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info);
149 EAPI Eina_Bool eobj_event_callback_forwarder_add(Eobj *obj, const Eobj_Event_Description *desc, Eobj *new_obj);
150 EAPI Eina_Bool eobj_event_callback_forwarder_del(Eobj *obj, const Eobj_Event_Description *desc, Eobj *new_obj);
152 /* callbacks of the same priority are called in reverse order of creation. */
153 EAPI Eina_Bool eobj_event_callback_add(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb cb, const void *data);
154 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);
155 EAPI void *eobj_event_callback_del(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb func);
156 EAPI void *eobj_event_callback_del_full(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb func, const void *user_data);
157 EAPI Eina_Bool eobj_event_callback_call(Eobj *obj, const Eobj_Event_Description *desc, const void *event_info);
159 EAPI extern const Eobj_Event_Description _EOBJ_SIG_CALLBACK_ADD;
160 #define EOBJ_SIG_CALLBACK_ADD (&(_EOBJ_SIG_CALLBACK_ADD))
161 EAPI extern const Eobj_Event_Description _EOBJ_SIG_CALLBACK_DEL;
162 #define EOBJ_SIG_CALLBACK_DEL (&(_EOBJ_SIG_CALLBACK_DEL))