[virt-tools-list] [PATCH virt-viewer 04/19] build: generate enums type boilerplate
Marc-André Lureau
marcandre.lureau at gmail.com
Mon Jul 16 16:57:39 UTC 2012
---
configure.ac | 3 ++
src/Makefile.am | 23 ++++++++++++--
src/virt-viewer-enums.c.etemplate | 60 +++++++++++++++++++++++++++++++++++++
src/virt-viewer-enums.h.etemplate | 41 +++++++++++++++++++++++++
4 files changed, 124 insertions(+), 3 deletions(-)
create mode 100644 src/virt-viewer-enums.c.etemplate
create mode 100644 src/virt-viewer-enums.h.etemplate
diff --git a/configure.ac b/configure.ac
index a2471f4..548b945 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,6 +72,9 @@ AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],"$GETTEXT_PACKAGE", [GETTEXT package name])
AM_GLIB_GNU_GETTEXT
IT_PROG_INTLTOOL([0.35.0])
+PKG_PROG_PKG_CONFIG
+GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
+AC_SUBST(GLIB_MKENUMS)
PKG_CHECK_MODULES(GLIB2, glib-2.0 >= $GLIB2_REQUIRED gthread-2.0 gmodule-export-2.0)
PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_REQUIRED)
diff --git a/src/Makefile.am b/src/Makefile.am
index d99b043..5daa98a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,11 +10,28 @@ builderxml_DATA = \
virt-viewer-auth.xml \
$(NULL)
-EXTRA_DIST = $(builderxml_DATA) \
- gbinding.c \
- gbinding.h
+EXTRA_DIST = \
+ $(builderxml_DATA) \
+ virt-viewer-enums.c.etemplate \
+ virt-viewer-enums.h.etemplate \
+ gbinding.c \
+ gbinding.h \
+ $(NULL)
+
+ENUMS_FILES = \
+ virt-viewer-display.h \
+ $(NULL)
+
+BUILT_SOURCES = \
+ virt-viewer-enums.h \
+ virt-viewer-enums.c \
+ $(NULL)
+
+$(BUILT_SOURCES): %: %.etemplate $(ENUMS_FILES)
+ $(AM_V_GEN)$(GLIB_MKENUMS) --template $^ | sed -e 's/VIRT_TYPE_VIEWER/VIRT_VIEWER_TYPE/' > $@
COMMON_SOURCES = \
+ $(BUILT_SOURCES) \
virt-gtk-compat.h \
virt-viewer-util.h virt-viewer-util.c \
virt-viewer-auth.h virt-viewer-auth.c \
diff --git a/src/virt-viewer-enums.c.etemplate b/src/virt-viewer-enums.c.etemplate
new file mode 100644
index 0000000..6f9925f
--- /dev/null
+++ b/src/virt-viewer-enums.c.etemplate
@@ -0,0 +1,60 @@
+/*** BEGIN file-header ***/
+/*
+ * Virt Viewer: A virtual machine console viewer
+ *
+ * Copyright (C) 2007-2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Marc-André Lureau <marcandre.lureau at redhat.com>
+ */
+
+#include "virt-viewer-enums.h"
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+#include "@filename@"
+/*** END file-production ***/
+
+
+/*** BEGIN value-header ***/
+
+GType
+ at 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 at 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_ at 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/src/virt-viewer-enums.h.etemplate b/src/virt-viewer-enums.h.etemplate
new file mode 100644
index 0000000..f33158d
--- /dev/null
+++ b/src/virt-viewer-enums.h.etemplate
@@ -0,0 +1,41 @@
+/*** BEGIN file-header ***/
+/*
+ * Virt Viewer: A virtual machine console viewer
+ *
+ * Copyright (C) 2007-2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Marc-André Lureau <marcandre.lureau at redhat.com>
+ */
+
+#ifndef VIRT_VIEWER_ENUMS_H
+#define VIRT_VIEWER_ENUMS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name at _get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX at _TYPE_@ENUMSHORT@ (@enum_name at _get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif
+/*** END file-tail ***/
--
1.7.10.4
More information about the virt-tools-list
mailing list