Re: [libvirt] [libvirt-gconfig PATCHv2 09/32] Use glib-mkenums to register enums with glib

2011-11-22 Thread Daniel P. Berrange
On Mon, Nov 21, 2011 at 07:04:06PM +0100, Christophe Fergeau wrote:
 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

ACK

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-gconfig PATCHv2 09/32] Use glib-mkenums to register enums with glib

2011-11-21 Thread Christophe Fergeau
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 464160c..3281baa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,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 a2f01fd..13655f9 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
 
@@ -29,6 +32,7 @@ GCONFIG_SOURCE_FILES = \
libvirt-gconfig-clock.c \
libvirt-gconfig-domain.c \
libvirt-gconfig-domain-snapshot.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 000..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