build-aux,mkenums: use mixed enums+flags template without docs in daemon
This commit is contained in:

committed by
Aleksander Morgado

parent
efcfce02a9
commit
fdf03f9b2c
@@ -1 +1 @@
|
|||||||
mm-enums-types.c.template
|
mm-enumflags-types.c.template
|
@@ -1 +1 @@
|
|||||||
mm-enums-types.h.template
|
mm-enumflags-types.h.template
|
92
build-aux/templates/mm-enumflags-types.c.template
Normal file
92
build-aux/templates/mm-enumflags-types.c.template
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
/*** BEGIN file-header ***/
|
||||||
|
|
||||||
|
/*** END file-header ***/
|
||||||
|
|
||||||
|
/*** BEGIN file-production ***/
|
||||||
|
/* enumerations from "@filename@" */
|
||||||
|
/*** END file-production ***/
|
||||||
|
|
||||||
|
/*** BEGIN value-header ***/
|
||||||
|
static const G@Type@Value @enum_name@_values[] = {
|
||||||
|
/*** END value-header ***/
|
||||||
|
/*** BEGIN value-production ***/
|
||||||
|
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
|
||||||
|
/*** END value-production ***/
|
||||||
|
/*** BEGIN value-tail ***/
|
||||||
|
{ 0, NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
GType
|
||||||
|
@enum_name@_get_type (void)
|
||||||
|
{
|
||||||
|
static gsize g_define_type_id_initialized = 0;
|
||||||
|
|
||||||
|
if (g_once_init_enter (&g_define_type_id_initialized)) {
|
||||||
|
GType g_define_type_id =
|
||||||
|
g_@type@_register_static (g_intern_static_string ("@EnumName@"),
|
||||||
|
@enum_name@_values);
|
||||||
|
g_once_init_leave (&g_define_type_id_initialized, g_define_type_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_define_type_id_initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined __@ENUMNAME@_IS_ENUM__
|
||||||
|
const gchar *
|
||||||
|
@enum_name@_get_string (@EnumName@ val)
|
||||||
|
{
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
for (i = 0; @enum_name@_values[i].value_nick; i++) {
|
||||||
|
if ((gint)val == @enum_name@_values[i].value)
|
||||||
|
return @enum_name@_values[i].value_nick;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined __@ENUMNAME@_IS_FLAGS__
|
||||||
|
gchar *
|
||||||
|
@enum_name@_build_string_from_mask (@EnumName@ mask)
|
||||||
|
{
|
||||||
|
guint i;
|
||||||
|
gboolean first = TRUE;
|
||||||
|
GString *str = NULL;
|
||||||
|
|
||||||
|
for (i = 0; @enum_name@_values[i].value_nick; i++) {
|
||||||
|
/* We also look for exact matches */
|
||||||
|
if (mask == @enum_name@_values[i].value) {
|
||||||
|
if (str)
|
||||||
|
g_string_free (str, TRUE);
|
||||||
|
return g_strdup (@enum_name@_values[i].value_nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Build list with single-bit masks */
|
||||||
|
if (mask & @enum_name@_values[i].value) {
|
||||||
|
guint c;
|
||||||
|
gulong number = @enum_name@_values[i].value;
|
||||||
|
|
||||||
|
for (c = 0; number; c++)
|
||||||
|
number &= number - 1;
|
||||||
|
|
||||||
|
if (c == 1) {
|
||||||
|
if (!str)
|
||||||
|
str = g_string_new ("");
|
||||||
|
g_string_append_printf (str, "%s%s",
|
||||||
|
first ? "" : ", ",
|
||||||
|
@enum_name@_values[i].value_nick);
|
||||||
|
if (first)
|
||||||
|
first = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (str ? g_string_free (str, FALSE) : NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*** END value-tail ***/
|
||||||
|
|
||||||
|
/*** BEGIN file-tail ***/
|
||||||
|
/*** END file-tail ***/
|
33
build-aux/templates/mm-enumflags-types.h.template
Normal file
33
build-aux/templates/mm-enumflags-types.h.template
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/*** BEGIN file-header ***/
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
/*** END file-header ***/
|
||||||
|
|
||||||
|
/*** BEGIN file-production ***/
|
||||||
|
|
||||||
|
/* enumerations from "@basename@" */
|
||||||
|
/*** END file-production ***/
|
||||||
|
|
||||||
|
/*** BEGIN value-header ***/
|
||||||
|
GType @enum_name@_get_type (void) G_GNUC_CONST;
|
||||||
|
#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
|
||||||
|
|
||||||
|
/* Define type-specific symbols */
|
||||||
|
#define __@ENUMNAME@_IS_@TYPE@__
|
||||||
|
|
||||||
|
#if defined __@ENUMNAME@_IS_ENUM__
|
||||||
|
const gchar *@enum_name@_get_string (@EnumName@ val);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined __@ENUMNAME@_IS_FLAGS__
|
||||||
|
gchar *@enum_name@_build_string_from_mask (@EnumName@ mask);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*** END value-header ***/
|
||||||
|
|
||||||
|
/*** BEGIN file-tail ***/
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
/*** END file-tail ***/
|
@@ -1 +1 @@
|
|||||||
mm-enums-types.c.template
|
mm-enumflags-types.c.template
|
@@ -1 +1 @@
|
|||||||
mm-enums-types.h.template
|
mm-enumflags-types.h.template
|
@@ -1 +1 @@
|
|||||||
mm-enums-types.c.template
|
mm-enumflags-types.c.template
|
@@ -1 +1 @@
|
|||||||
mm-enums-types.h.template
|
mm-enumflags-types.h.template
|
@@ -1 +1 @@
|
|||||||
mm-enums-types.c.template
|
mm-enumflags-types.c.template
|
@@ -1 +1 @@
|
|||||||
mm-enums-types.h.template
|
mm-enumflags-types.h.template
|
@@ -1 +1 @@
|
|||||||
mm-enums-types.c.template
|
mm-enumflags-types.c.template
|
@@ -1 +1 @@
|
|||||||
mm-enums-types.h.template
|
mm-enumflags-types.h.template
|
@@ -1 +1 @@
|
|||||||
mm-enums-types.c.template
|
mm-enumflags-types.c.template
|
@@ -1 +1 @@
|
|||||||
mm-enums-types.h.template
|
mm-enumflags-types.h.template
|
Reference in New Issue
Block a user