diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-06-12 10:21:55 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-06-12 10:21:55 +0200 |
commit | 580dae2183e27ccec00f127b85188df143f49c54 (patch) | |
tree | 35e43a1587a8b624218006e2e41d73c28dd1b160 /src/uca-enums.c.template | |
parent | 733da14c66d347bb2ae452766a36bf3c1381cacd (diff) | |
download | uca-580dae2183e27ccec00f127b85188df143f49c54.tar.gz uca-580dae2183e27ccec00f127b85188df143f49c54.tar.bz2 uca-580dae2183e27ccec00f127b85188df143f49c54.tar.xz uca-580dae2183e27ccec00f127b85188df143f49c54.zip |
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.
Diffstat (limited to 'src/uca-enums.c.template')
-rw-r--r-- | src/uca-enums.c.template | 44 |
1 files changed, 44 insertions, 0 deletions
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 <config.h> + +#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 ***/ |