[Spice-devel] [spice-server 4/5] build: Add GEnum generation for RedPipeItem types
Christophe Fergeau
cfergeau at redhat.com
Thu Oct 12 10:13:25 UTC 2017
---
server/Makefile.am | 21 ++++++++++++++---
server/common-graphics-channel.h | 4 ++--
server/cursor-channel-client.h | 4 ++--
server/display-channel-private.h | 4 ++--
server/inputs-channel-client.h | 4 ++--
server/main-channel-client.h | 4 ++--
server/red-channel-client.h | 4 ++--
server/red-pipe-item-enums.tmpl.c | 47 +++++++++++++++++++++++++++++++++++++++
server/red-pipe-item-enums.tmpl.h | 22 ++++++++++++++++++
server/smartcard.h | 4 ++--
10 files changed, 101 insertions(+), 17 deletions(-)
create mode 100644 server/red-pipe-item-enums.tmpl.c
create mode 100644 server/red-pipe-item-enums.tmpl.h
diff --git a/server/Makefile.am b/server/Makefile.am
index 5d5590af9..ac7650d18 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -73,7 +73,11 @@ libspice_serverinclude_HEADERS = \
spice.h \
$(NULL)
-spice_built_sources = spice-server-enums.h spice-server-enums.c
+spice_built_sources = \
+ spice-server-enums.h \
+ spice-server-enums.c \
+ red-pipe-item-enums.h \
+ red-pipe-item-enums.c
libserver_la_SOURCES = \
$(libspice_serverinclude_HEADERS) \
@@ -201,12 +205,21 @@ endif
libspice_server_la_LIBADD = libserver.la
libspice_server_la_SOURCES =
-spice-server-enums.c: spice-server.h spice-server-enums.tmpl.c
+spice-server-enums.c: spice-server-enums.tmpl.c
+spice-server-enums.h: spice-server-enums.tmpl.h
+
+spice-server-enums.c: spice-server.h
$(AM_V_GEN)glib-mkenums --template $(srcdir)/spice-server-enums.tmpl.c $< > $@
-spice-server-enums.h: spice-server.h spice-server-enums.tmpl.h
+spice-server-enums.h: spice-server.h
$(AM_V_GEN)glib-mkenums --template $(srcdir)/spice-server-enums.tmpl.h $< > $@
+red-pipe-item-enums.c: red-pipe-item-enums.tmpl.c common-graphics-channel.h cursor-channel-client.h display-channel-private.h inputs-channel-client.h main-channel-client.h red-channel-client.h red-pipe-item.h smartcard.h
+ $(AM_V_GEN)glib-mkenums --template $^ > $@
+
+red-pipe-item-enums.h: red-pipe-item-enums.tmpl.h common-graphics-channel.h cursor-channel-client.h display-channel-private.h inputs-channel-client.h main-channel-client.h red-channel-client.h red-pipe-item.h smartcard.h
+ $(AM_V_GEN)glib-mkenums --template $^ > $@
+
EXTRA_DIST = \
spice-bitmap-utils.tmpl.c \
cache-item.tmpl.c \
@@ -215,6 +228,8 @@ EXTRA_DIST = \
spice-server.syms \
spice-server-enums.tmpl.h \
spice-server-enums.tmpl.c \
+ red-pipe-item-enums.tmpl.h \
+ red-pipe-item-enums.tmpl.c \
$(NULL)
BUILT_SOURCES = $(spice_built_sources)
diff --git a/server/common-graphics-channel.h b/server/common-graphics-channel.h
index d23f0c695..bef1a5094 100644
--- a/server/common-graphics-channel.h
+++ b/server/common-graphics-channel.h
@@ -63,11 +63,11 @@ GType common_graphics_channel_get_type(void) G_GNUC_CONST;
void common_graphics_channel_set_during_target_migrate(CommonGraphicsChannel *self, gboolean value);
gboolean common_graphics_channel_get_during_target_migrate(CommonGraphicsChannel *self);
-enum {
+typedef enum {
RED_PIPE_ITEM_TYPE_INVAL_ONE = RED_PIPE_ITEM_TYPE_CHANNEL_BASE,
RED_PIPE_ITEM_TYPE_COMMON_LAST
-};
+} CommonGraphicsChannelPipeItemType;
#define TYPE_COMMON_GRAPHICS_CHANNEL_CLIENT common_graphics_channel_client_get_type()
diff --git a/server/cursor-channel-client.h b/server/cursor-channel-client.h
index dc69369f5..c0a5d07bb 100644
--- a/server/cursor-channel-client.h
+++ b/server/cursor-channel-client.h
@@ -69,11 +69,11 @@ void cursor_channel_client_reset_cursor_cache(RedChannelClient *rcc);
RedCacheItem* cursor_channel_client_cache_find(CursorChannelClient *ccc, uint64_t id);
int cursor_channel_client_cache_add(CursorChannelClient *ccc, uint64_t id, size_t size);
-enum {
+typedef enum {
RED_PIPE_ITEM_TYPE_CURSOR = RED_PIPE_ITEM_TYPE_COMMON_LAST,
RED_PIPE_ITEM_TYPE_CURSOR_INIT,
RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE,
-};
+} CursorChannelPipeItemType;
G_END_DECLS
diff --git a/server/display-channel-private.h b/server/display-channel-private.h
index 82a3e8c69..a1c3721df 100644
--- a/server/display-channel-private.h
+++ b/server/display-channel-private.h
@@ -136,7 +136,7 @@ typedef struct RedMonitorsConfigItem {
MonitorsConfig *monitors_config;
} RedMonitorsConfigItem;
-enum {
+typedef enum {
RED_PIPE_ITEM_TYPE_DRAW = RED_PIPE_ITEM_TYPE_COMMON_LAST,
RED_PIPE_ITEM_TYPE_IMAGE,
RED_PIPE_ITEM_TYPE_STREAM_CREATE,
@@ -153,7 +153,7 @@ enum {
RED_PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT,
RED_PIPE_ITEM_TYPE_GL_SCANOUT,
RED_PIPE_ITEM_TYPE_GL_DRAW,
-};
+} DisplayChannelPipeItemType;
void drawable_unref(Drawable *drawable);
diff --git a/server/inputs-channel-client.h b/server/inputs-channel-client.h
index b57a7a798..b69adb674 100644
--- a/server/inputs-channel-client.h
+++ b/server/inputs-channel-client.h
@@ -71,11 +71,11 @@ void inputs_channel_client_handle_migrate_data(InputsChannelClient *icc, uint16_
G_END_DECLS
-enum {
+typedef enum {
RED_PIPE_ITEM_INPUTS_INIT = RED_PIPE_ITEM_TYPE_CHANNEL_BASE,
RED_PIPE_ITEM_MOUSE_MOTION_ACK,
RED_PIPE_ITEM_KEY_MODIFIERS,
RED_PIPE_ITEM_MIGRATE_DATA,
-};
+} InputChannelPipeItemType;
#endif /* INPUTS_CHANNEL_CLIENT_H_ */
diff --git a/server/main-channel-client.h b/server/main-channel-client.h
index 26b7e20b8..70dd1bac6 100644
--- a/server/main-channel-client.h
+++ b/server/main-channel-client.h
@@ -105,7 +105,7 @@ void main_channel_client_push_uuid(MainChannelClient *mcc, const uint8_t uuid[16
uint32_t main_channel_client_get_connection_id(MainChannelClient *mcc);
void main_channel_client_send_item(RedChannelClient *rcc, RedPipeItem *base);
-enum {
+typedef enum {
RED_PIPE_ITEM_TYPE_MAIN_CHANNELS_LIST = RED_PIPE_ITEM_TYPE_CHANNEL_BASE,
RED_PIPE_ITEM_TYPE_MAIN_PING,
RED_PIPE_ITEM_TYPE_MAIN_MOUSE_MODE,
@@ -122,7 +122,7 @@ enum {
RED_PIPE_ITEM_TYPE_MAIN_NAME,
RED_PIPE_ITEM_TYPE_MAIN_UUID,
RED_PIPE_ITEM_TYPE_MAIN_AGENT_CONNECTED_TOKENS,
-};
+} MainChannelPipeItemType;
RedPipeItem *main_mouse_mode_item_new(SpiceMouseMode current_mode, int is_client_mouse_allowed);
diff --git a/server/red-channel-client.h b/server/red-channel-client.h
index d57f54cc7..572831dd3 100644
--- a/server/red-channel-client.h
+++ b/server/red-channel-client.h
@@ -184,7 +184,7 @@ enum
* Note that the numbers don't have to correspond to spice message types,
* but we keep the 100 first allocated for base channel approach.
* */
-enum {
+typedef enum {
RED_PIPE_ITEM_TYPE_SET_ACK=1,
RED_PIPE_ITEM_TYPE_MIGRATE,
RED_PIPE_ITEM_TYPE_EMPTY_MSG,
@@ -192,7 +192,7 @@ enum {
RED_PIPE_ITEM_TYPE_MARKER,
RED_PIPE_ITEM_TYPE_CHANNEL_BASE=101,
-};
+} RedChannelPipeItemType;
G_END_DECLS
diff --git a/server/red-pipe-item-enums.tmpl.c b/server/red-pipe-item-enums.tmpl.c
new file mode 100644
index 000000000..5fcf89040
--- /dev/null
+++ b/server/red-pipe-item-enums.tmpl.c
@@ -0,0 +1,47 @@
+/*** BEGIN file-header ***/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib-object.h>
+
+#include "red-pipe-item-enums.h"
+#include "common-graphics-channel.h"
+#include "cursor-channel-client.h"
+#include "display-channel-private.h"
+#include "inputs-channel-client.h"
+#include "main-channel-client.h"
+#include "red-channel-client.h"
+#include "red-pipe-item.h"
+#include "smartcard.h"
+#include "red-channel-client.h"
+
+/*** END file-header ***/
+
+/*** BEGIN value-header ***/
+static const G at Type@Value _ at enum_name@_values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ { 0, NULL, NULL }
+};
+
+GType
+ at enum_name@_get_type (void)
+{
+ static GType type = 0;
+ static volatile gsize type_volatile = 0;
+
+ if (g_once_init_enter(&type_volatile)) {
+ type = g_ at type@_register_static ("@EnumName@", _ at enum_name@_values);
+ g_once_init_leave(&type_volatile, type);
+ }
+
+ return type;
+}
+
+/*** END value-tail ***/
diff --git a/server/red-pipe-item-enums.tmpl.h b/server/red-pipe-item-enums.tmpl.h
new file mode 100644
index 000000000..1704a908c
--- /dev/null
+++ b/server/red-pipe-item-enums.tmpl.h
@@ -0,0 +1,22 @@
+/*** BEGIN file-header ***/
+#ifndef RED_PIPE_ITEM_ENUMS_H
+#define RED_PIPE_ITEM_ENUMS_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN enumeration-production ***/
+#define @ENUMNAME@ @enum_name at _get_type()
+GType @enum_name at _get_type (void);
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+
+G_END_DECLS
+
+#endif /* RED_PIPE_ITEM_ENUMS_H */
+/*** END file-tail ***/
diff --git a/server/smartcard.h b/server/smartcard.h
index 11d334f1f..ff183475a 100644
--- a/server/smartcard.h
+++ b/server/smartcard.h
@@ -70,10 +70,10 @@ SmartCardChannelClient* smartcard_char_device_get_client(RedCharDeviceSmartcard
int smartcard_char_device_handle_migrate_data(RedCharDeviceSmartcard *smartcard,
SpiceMigrateDataSmartcard *mig_data);
-enum {
+typedef enum {
RED_PIPE_ITEM_TYPE_ERROR = RED_PIPE_ITEM_TYPE_CHANNEL_BASE,
RED_PIPE_ITEM_TYPE_SMARTCARD_DATA,
RED_PIPE_ITEM_TYPE_SMARTCARD_MIGRATE_DATA,
-};
+} SmartcardChannelPipeItemType;
#endif /* SMART_CARD_H_ */
--
2.13.6
More information about the Spice-devel
mailing list