From 580dae2183e27ccec00f127b85188df143f49c54 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Tue, 12 Jun 2012 10:21:55 +0200 Subject: Generate enum types from source It became a little unwieldy to create the enum types manually via g_enums_register_static(). This changeset creates the types from enum definitions in public headers using glib2-mkenum. Be sure to include uca-enums.h in every source file that needs to know GObject enum type. --- src/uca-enums.c.template | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/uca-enums.c.template (limited to 'src/uca-enums.c.template') diff --git a/src/uca-enums.c.template b/src/uca-enums.c.template new file mode 100644 index 0000000..4e4a8bb --- /dev/null +++ b/src/uca-enums.c.template @@ -0,0 +1,44 @@ +/*** BEGIN file-header ***/ +#include + +#include "uca-enums.h" + +/*** END file-header ***/ + +/*** BEGIN file-production ***/ +/* enumerations from "@filename@" */ +#include "@filename@" +/*** END file-production ***/ + + +/*** BEGIN value-header ***/ +GType +@enum_name@_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) { + static const G@Type@Value values[] = { +/*** END value-header ***/ + +/*** BEGIN value-production ***/ + { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, +/*** END value-production ***/ + +/*** BEGIN value-tail ***/ + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); + + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} + +/*** END value-tail ***/ + +/*** BEGIN file-tail ***/ + +/*** END file-tail ***/ -- cgit v1.2.3