core: object: add more virtual function dispatch macros
This commit is contained in:
@@ -10,8 +10,6 @@
|
||||
#define __B_IFACE_I0(p, x) p##x
|
||||
#define __B_IFACE_I1(p, x) __B_IFACE_I0(p, x)
|
||||
|
||||
#define B_TYPE_FWDREF(name) struct _b_object
|
||||
|
||||
/* Type definitions macros (for use in .c source file) */
|
||||
|
||||
#define B_TYPE_CLASS_DEFINITION_BEGIN(type_name) \
|
||||
@@ -65,6 +63,7 @@
|
||||
&type_info->t_interfaces[type_info->t_nr_interfaces++])
|
||||
#define B_TYPE_CLASS(class_struct) \
|
||||
type_info->t_class_size = sizeof(class_struct)
|
||||
#define B_TYPE_FLAGS(flags) type_info->t_flags = (flags)
|
||||
#define B_TYPE_INSTANCE_INIT(func) type_info->t_instance_init = (func)
|
||||
#define B_TYPE_INSTANCE_FINI(func) type_info->t_instance_fini = (func)
|
||||
|
||||
@@ -114,23 +113,46 @@
|
||||
|
||||
/* Other macros */
|
||||
|
||||
#define B_CLASS_DISPATCH_VIRTUAL(type_name, type_id, object, func, ...) \
|
||||
#define B_CLASS_DISPATCH_VIRTUAL( \
|
||||
type_name, type_id, default_value, func, object, ...) \
|
||||
do { \
|
||||
type_name##_class *iface \
|
||||
= b_object_get_interface(object, type_id); \
|
||||
if (iface && iface->func) { \
|
||||
return iface->func(__VA_ARGS__); \
|
||||
return iface->func(object, __VA_ARGS__); \
|
||||
} else { \
|
||||
return default_value; \
|
||||
} \
|
||||
} while (0)
|
||||
#define B_CLASS_DISPATCH_VIRTUAL_V(type_name, type_id, object, func, ...) \
|
||||
#define B_CLASS_DISPATCH_VIRTUAL_0(type_name, type_id, default_value, func, object) \
|
||||
do { \
|
||||
type_name##_class *iface \
|
||||
= b_object_get_interface(object, type_id); \
|
||||
if (iface && iface->func) { \
|
||||
iface->func(__VA_ARGS__); \
|
||||
return iface->func(object); \
|
||||
} else { \
|
||||
return default_value; \
|
||||
} \
|
||||
} while (0)
|
||||
#define B_CLASS_DISPATCH_VIRTUAL_V(type_name, type_id, func, object, ...) \
|
||||
do { \
|
||||
type_name##_class *iface \
|
||||
= b_object_get_interface(object, type_id); \
|
||||
if (iface && iface->func) { \
|
||||
iface->func(object, __VA_ARGS__); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
#define B_CLASS_DISPATCH_VIRTUAL_V0(type_name, type_id, func, object) \
|
||||
do { \
|
||||
type_name##_class *iface \
|
||||
= b_object_get_interface(object, type_id); \
|
||||
if (iface && iface->func) { \
|
||||
iface->func(object); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define B_CLASS_DISPATCH_STATIC(type_id, func_name, obj, ...) \
|
||||
do { \
|
||||
void *priv = b_object_get_private(obj, type_id); \
|
||||
|
||||
Reference in New Issue
Block a user