[Gstreamer-openmax] [PATCH 1/2] Add GSTOMX_BOILERPLATE macros
Felipe Contreras
felipe.contreras at gmail.com
Mon Mar 1 07:32:43 PST 2010
On Sun, Feb 28, 2010 at 10:22 PM, Rob Clark <rob at ti.com> wrote:
> These work like the GST_BOILERPLATE macros, but following the naming conventions for init functions used in the gst-openmax code, to remove a lot of gobject related boilerplate code.
> ---
> --- a/omx/gstomx_util.h
> +++ b/omx/gstomx_util.h
> @@ -142,4 +142,48 @@ void g_omx_port_enable (GOmxPort *port);
> void g_omx_port_disable (GOmxPort *port);
> void g_omx_port_finish (GOmxPort *port);
>
> +/* Utility Macros */
> +
> +/**
> + * Basically like GST_BOILERPLATE / GST_BOILERPLATE_FULL, but follows the
> + * init fxn naming conventions used by gst-openmax. It expects the following
> + * functions to be defined in the same src file following this macro
> + * <ul>
> + * <li> type_base_init(gpointer g_class)
> + * <li> type_class_init(gpointer g_class, gpointer class_data)
> + * <li> type_instance_init(GTypeInstance *instance, gpointer g_class)
> + * </ul>
> + */
> +#define GSTOMX_BOILERPLATE_FULL(type, type_as_function, parent_type, parent_type_macro, additional_initializations) \
> +static void type_base_init (gpointer g_class); \
> +static void type_class_init (gpointer g_class, gpointer class_data); \
> +static void type_instance_init (GTypeInstance *instance, gpointer g_class); \
> +static parent_type ## Class *parent_class; \
> +static void type_class_init_trampoline (gpointer g_class, gpointer class_data)\
> +{ \
> + parent_class = g_type_class_ref (parent_type_macro); \
> + type_class_init (g_class, class_data); \
> +} \
> +GType type_as_function ## _get_type (void) \
> +{ \
> + static GType _type = 0; \
> + if (G_UNLIKELY (_type == 0)) \
> + { \
> + GTypeInfo *type_info; \
> + type_info = g_new0 (GTypeInfo, 1); \
> + type_info->class_size = sizeof (type ## Class); \
> + type_info->base_init = type_base_init; \
> + type_info->class_init = type_class_init_trampoline; \
> + type_info->instance_size = sizeof (type); \
> + type_info->instance_init = type_instance_init; \
> + _type = g_type_register_static (parent_type_macro, #type, type_info, 0);\
> + g_free (type_info); \
> + additional_initializations (_type); \
> + } \
> + return _type; \
> +}
> +#define GSTOMX_BOILERPLATE(type,type_as_function,parent_type,parent_type_macro) \
> + GSTOMX_BOILERPLATE_FULL (type, type_as_function, parent_type, parent_type_macro, \
> + __GST_DO_NOTHING)
> +
> #endif /* GSTOMX_UTIL_H */
Ahg, my eyes!
However, I don't see a better way to do this... ACK'ed.
--
Felipe Contreras
More information about the Gstreamer-openmax
mailing list