We don't currently have any enum in our API, but we will need some. This commit adds the generation of libvirt-gconfig-enum-types.[ch] using glib-mkenums. These files will register the various enums that will get added to libvirt-gconfig header files with glib. -- v2: move libvirt-gconfig-enum-types.h to HEADERS in Makefile.am so that it's installed --- configure.ac | 4 ++ libvirt-gconfig/Makefile.am | 23 +++++++++++- .../libvirt-gconfig-enum-types.c.template | 36 ++++++++++++++++++++ .../libvirt-gconfig-enum-types.h.template | 24 +++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + 5 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-enum-types.c.template create mode 100644 libvirt-gconfig/libvirt-gconfig-enum-types.h.template diff --git a/configure.ac b/configure.ac index 56110d2..4683daf 100644 --- a/configure.ac +++ b/configure.ac @@ -51,6 +51,10 @@ PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_REQUIRED) GTK_DOC_CHECK([1.10],[--flavour no-tmpl]) +# Setup GLIB_MKENUMS to use glib-mkenums even if GLib is uninstalled. +GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` +AC_SUBST(GLIB_MKENUMS) + dnl Extra link-time flags for Cygwin. dnl Copied from libxml2 configure.in, but I removed mingw changes dnl for now since I'm not supporting mingw at present. - RWMJ diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index daa99b8..641aab3 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -1,6 +1,9 @@ SUBDIRS = . tests -EXTRA_DIST = libvirt-gconfig.sym +EXTRA_DIST = \ + libvirt-gconfig.sym \ + libvirt-gconfig-enum-types.h.template \ + libvirt-gconfig-enum-types.c.template lib_LTLIBRARIES = libvirt-gconfig-1.0.la @@ -30,6 +33,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-clock.c \ libvirt-gconfig-domain-snapshot.c \ libvirt-gconfig-domain-timer.c \ + libvirt-gconfig-enum-types.c \ libvirt-gconfig-helpers.c \ libvirt-gconfig-interface.c \ libvirt-gconfig-network.c \ @@ -41,7 +45,8 @@ GCONFIG_SOURCE_FILES = \ libvirt_gconfig_1_0_ladir = $(includedir)/libvirt-gconfig-1.0/libvirt-gconfig libvirt_gconfig_1_0_la_HEADERS = \ - $(GCONFIG_HEADER_FILES) + $(GCONFIG_HEADER_FILES) \ + libvirt-gconfig-enum-types.h libvirt_gconfig_1_0_la_SOURCES = \ $(libvirt_gconfig_1_0_la_HEADERS) \ $(GCONFIG_SOURCE_FILES) @@ -65,6 +70,20 @@ libvirt_gconfig_1_0_la_LDFLAGS = \ -Wl,--version-script=$(srcdir)/libvirt-gconfig.sym \ -version-info $(LIBVIRT_GLIB_VERSION_INFO) +BUILT_SOURCES = \ + libvirt-gconfig-enum-types.c \ + libvirt-gconfig-enum-types.h + +libvirt-gconfig-enum-types.h: $(GCONFIG_HEADER_FILES) libvirt-gconfig-enum-types.h.template + $(AM_V_GEN) ( cd $(srcdir) \ + && $(GLIB_MKENUMS) --template libvirt-gconfig-enum-types.h.template $(GCONFIG_HEADER_FILES) ) >libvirt-gconfig-enum-types.h.tmp \ + && sed -e "s/G_TYPE_VIR/GVIR_TYPE/" -e "s/g_vir/gvir/" libvirt-gconfig-enum-types.h.tmp >libvirt-gconfig-enum-types.h + +libvirt-gconfig-enum-types.c: $(GCONFIG_HEADER_FILES) libvirt-gconfig-enum-types.c.template + $(AM_V_GEN) ( cd $(srcdir) \ + && $(GLIB_MKENUMS) --template libvirt-gconfig-enum-types.c.template $(GCONFIG_HEADER_FILES) ) >libvirt-gconfig-enum-types.c.tmp \ + && sed -e "s/G_TYPE_VIR/GVIR_TYPE/" -e "s/g_vir/gvir/" libvirt-gconfig-enum-types.c.tmp >libvirt-gconfig-enum-types.c + if WITH_GOBJECT_INTROSPECTION LibvirtGConfig-1.0.gir: libvirt-gconfig-1.0.la $(G_IR_SCANNER) Makefile.am diff --git a/libvirt-gconfig/libvirt-gconfig-enum-types.c.template b/libvirt-gconfig/libvirt-gconfig-enum-types.c.template new file mode 100644 index 0000000..cccea77 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-enum-types.c.template @@ -0,0 +1,36 @@ +/*** BEGIN file-header ***/ +#include <libvirt-gconfig/libvirt-gconfig.h> + +/*** END file-header ***/ + +/*** BEGIN file-production ***/ +/* enumerations from "@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 ***/ diff --git a/libvirt-gconfig/libvirt-gconfig-enum-types.h.template b/libvirt-gconfig/libvirt-gconfig-enum-types.h.template new file mode 100644 index 0000000..2cab1c5 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-enum-types.h.template @@ -0,0 +1,24 @@ +/*** BEGIN file-header ***/ +#ifndef __LIBVIRT_GCONFIG_ENUM_TYPES_H__ +#define __LIBVIRT_GCONFIG_ENUM_TYPES_H__ + +#include <libvirt-gconfig/libvirt-gconfig.h> + +G_BEGIN_DECLS +/*** END file-header ***/ + +/*** BEGIN file-production ***/ + +/* enumerations from "@filename@" */ +/*** END file-production ***/ + +/*** BEGIN value-header ***/ +GType @enum_name@_get_type (void) G_GNUC_CONST; +#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) +/*** END value-header ***/ + +/*** BEGIN file-tail ***/ +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_ENUM_TYPES_H__ */ +/*** END file-tail ***/ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 9656f32..3c00788 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -32,6 +32,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-clock.h> #include <libvirt-gconfig/libvirt-gconfig-domain-snapshot.h> #include <libvirt-gconfig/libvirt-gconfig-domain-timer.h> +#include <libvirt-gconfig/libvirt-gconfig-enum-types.h> #include <libvirt-gconfig/libvirt-gconfig-helpers.h> #include <libvirt-gconfig/libvirt-gconfig-interface.h> #include <libvirt-gconfig/libvirt-gconfig-network.h> -- 1.7.7.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list