summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2016-09-19 10:02:33 -0500
committerFrediano Ziglio <fziglio@redhat.com>2016-09-27 15:27:05 +0100
commitc96f8c9f9b8f87e183a554a818ca8b2c06f60fda (patch)
tree022858574f5a0ea367143af1f63a537d558a7d90
parent5d04ad7359f38dd2db7eb928ed1e55effeb231e8 (diff)
Generate GTypes for spice-server enums
The GType will be useful to allow these enums to be used as GObject properties. Acked-by: Christophe Fergeau <cfergeau@redhat.com>
-rw-r--r--.gitignore2
-rw-r--r--server/Makefile.am31
2 files changed, 33 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 90fb62a6..2df7c3fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,3 +33,5 @@ INSTALL
.tarball-version
docs/manual/manual.chunked/
docs/manual/manual.html
+spice-server-enums.h
+spice-server-enums.c
diff --git a/server/Makefile.am b/server/Makefile.am
index d31a9e83..9c5b3b6a 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -68,6 +68,8 @@ libspice_serverinclude_HEADERS = \
spice.h \
$(NULL)
+spice_built_sources = spice-server-enums.h spice-server-enums.c
+
libserver_la_SOURCES = \
$(libspice_serverinclude_HEADERS) \
agent-msg-filter.c \
@@ -156,6 +158,7 @@ libserver_la_SOURCES = \
dcc-private.h \
image-encoders.c \
image-encoders.h \
+ $(spice_built_sources) \
$(NULL)
if HAVE_LZ4
@@ -187,6 +190,34 @@ endif
libspice_server_la_LIBADD = libserver.la
libspice_server_la_SOURCES =
+spice-server-enums.c: spice-server.h
+ $(AM_V_GEN)glib-mkenums --fhead "#include \"config.h\"\n\n" \
+ --fhead "#include <glib-object.h>\n" \
+ --fhead "#include \"spice-server-enums.h\"\n\n" \
+ --fprod "\n#include \"spice-server.h\"\n" \
+ --vhead "static const G@Type@Value _@enum_name@_values[] = {" \
+ --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
+ --vtail " { 0, NULL, NULL }\n};\n\n" \
+ --vtail "GType\n@enum_name@_get_type (void)\n{\n" \
+ --vtail " static GType type = 0;\n" \
+ --vtail " static volatile gsize type_volatile = 0;\n\n" \
+ --vtail " if (g_once_init_enter(&type_volatile)) {\n" \
+ --vtail " type = g_@type@_register_static (\"@EnumName@\", _@enum_name@_values);\n" \
+ --vtail " g_once_init_leave(&type_volatile, type);\n" \
+ --vtail " }\n\n" \
+ --vtail " return type;\n}\n\n" \
+ $^ > $@
+
+spice-server-enums.h: spice-server.h
+ $(AM_V_GEN)glib-mkenums --fhead "#ifndef SPICE_SERVER_ENUMS_H\n" \
+ --fhead "#define SPICE_SERVER_ENUMS_H\n\n" \
+ --fhead "G_BEGIN_DECLS\n\n" \
+ --ftail "G_END_DECLS\n\n" \
+ --ftail "#endif /* SPICE_SERVER_ENUMS_H */\n" \
+ --eprod "#define SPICE_TYPE_@ENUMSHORT@ @enum_name@_get_type()\n" \
+ --eprod "GType @enum_name@_get_type (void);\n" \
+ $^ > $@
+
EXTRA_DIST = \
spice-bitmap-utils.tmpl.c \
cache-item.tmpl.c \