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)
91 EAPI Eina_Bool eobj_do_internal(Eobj *obj, ...);
93 EAPI Eina_Bool eobj_super_do(Eobj *obj, Eobj_Op op, ...);
95 EAPI const Eobj_Class *eobj_class_get(Eobj *obj);
96 EAPI const Eobj_Class *eobj_class_parent_get(const Eobj_Class *klass);
97 EAPI const char *eobj_class_name_get(const Eobj_Class *klass);
99 EAPI void eobj_constructor_super(Eobj *obj);
100 EAPI void eobj_destructor_super(Eobj *obj);
101 EAPI void eobj_constructor_error_set(Eobj *obj);
102 EAPI Eina_Bool eobj_constructor_error_get(const Eobj *obj);
104 EAPI Eobj_Class *eobj_class_new(const Eobj_Class_Description *desc, const Eobj_Class *parent, ...);
105 EAPI void eobj_class_free(Eobj_Class *klass);
106 EAPI void eobj_class_funcs_set(Eobj_Class *klass, const Eobj_Op_Func_Description *func_descs);
108 EAPI Eobj *eobj_add(const Eobj_Class *klass, Eobj *parent);
109 EAPI Eobj *eobj_parent_get(Eobj *obj);
110 EAPI void *eobj_data_get(Eobj *obj, const Eobj_Class *klass);
111 EAPI Eobj *eobj_ref(Eobj *obj);
112 EAPI void eobj_unref(Eobj *obj);
113 EAPI void eobj_del(Eobj *obj);
114 EAPI void *eobj_generic_data_set(Eobj *obj, const char *key, const void *data);
115 EAPI void *eobj_generic_data_get(const Eobj *obj, const char *key);
116 EAPI void *eobj_generic_data_del(Eobj *obj, const char *key);
118 #define EOBJ_CLASS_BASE eobj_base_class_get()
119 EAPI const Eobj_Class *eobj_base_class_get(void) EINA_CONST;
121 EAPI void eobj_composite_object_attach(Eobj *obj, Eobj *emb_obj);
122 EAPI void eobj_composite_object_detach(Eobj *obj, Eobj *emb_obj);
123 EAPI Eina_Bool eobj_composite_is(Eobj *emb_obj);
127 * @def EOBJ_CALLBACK_PRIORITY_BEFORE
128 * Slightly more prioritized than default.
130 #define EOBJ_CALLBACK_PRIORITY_BEFORE -100
132 * @def EOBJ_CALLBACK_PRIORITY_DEFAULT
133 * Default callback priority level
135 #define EOBJ_CALLBACK_PRIORITY_DEFAULT 0
137 * @def EOBJ_CALLBACK_PRIORITY_AFTER
138 * Slightly less prioritized than default.
140 #define EOBJ_CALLBACK_PRIORITY_AFTER 100
141 typedef short Eobj_Callback_Priority;
143 /* True meaning continue, False meaning stop callbacks. - Make it an enum? */
144 typedef Eina_Bool (*Eobj_Event_Cb)(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info);
146 EAPI Eina_Bool eobj_event_callback_forwarder_add(Eobj *obj, const Eobj_Event_Description *desc, Eobj *new_obj);
147 EAPI Eina_Bool eobj_event_callback_forwarder_del(Eobj *obj, const Eobj_Event_Description *desc, Eobj *new_obj);
149 /* callbacks of the same priority are called in reverse order of creation. */
150 EAPI Eina_Bool eobj_event_callback_add(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb cb, const void *data);
151 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);
152 EAPI void *eobj_event_callback_del(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb func);
153 EAPI void *eobj_event_callback_del_full(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb func, const void *user_data);
154 EAPI Eina_Bool eobj_event_callback_call(Eobj *obj, const Eobj_Event_Description *desc, const void *event_info);
156 EAPI extern const Eobj_Event_Description _EOBJ_SIG_CALLBACK_ADD;
157 #define EOBJ_SIG_CALLBACK_ADD (&(_EOBJ_SIG_CALLBACK_ADD))
158 EAPI extern const Eobj_Event_Description _EOBJ_SIG_CALLBACK_DEL;
159 #define EOBJ_SIG_CALLBACK_DEL (&(_EOBJ_SIG_CALLBACK_DEL))