Refactored WmudClientState to enumtypes.[ch]

enumtypes.[ch] will hold all future enums' GType equivalent
This commit is contained in:
Gergely Polonkai 2013-01-06 14:52:12 +01:00
parent 3ea30a812b
commit cdd4be1e59
9 changed files with 159 additions and 30 deletions

View File

@ -51,4 +51,6 @@ if test "$libcurl_protocol_SMTP" != "yes"; then
exit 1
fi
AM_PATH_GLIB_2_0
AC_OUTPUT(Makefile wmud/Makefile docs/reference/wmud/Makefile create-world.sh drop-world.sh)

View File

@ -1,5 +1,48 @@
bin_PROGRAMS = wmud
AM_CPPFLAGS = -DWMUD_STATEDIR=\""$(localstatedir)"\" -DWMUD_CONFDIR=\""$(sysconfdir)"\" $(MEMCACHED_CFLAGS) $(GLIB_CFLAGS) $(GIO_CFLAGS) $(GTHREAD_CFLAGS) $(SQLITE3_CFLAGS) $(CURL_CFLAGS)
wmud_SOURCES = main.c game-networking.c interpreter.c db.c players.c maintenance.c game.c configuration.c world.c menu.c texts.c wmudclient.c wmudplayer.c wmudclientstate.c
wmud_SOURCES = \
main.c \
main.h \
game-networking.c \
game-networking.h \
interpreter.c \
interpreter.h \
db.c \
db.h \
players.c \
players.h \
maintenance.c \
maintenance.h \
game.c \
game.h \
configuration.c \
configuration.h \
world.c \
world.h \
menu.c \
menu.h \
texts.c \
texts.h \
wmudclient.c \
wmudclient.h \
wmudplayer.c \
wmudplayer.h \
wmudclientstate.h \
enumtypes.h \
enumtypes.c
wmud_LDADD = $(MEMCACHED_LIBS) $(GLIB_LIBS) $(GIO_LIBS) $(GTHREAD_LIBS) $(SQLITE3_LIBS) $(CURL_LIBS)
enum_headers = wmudclientstate.h
enumtypes.h: $(enum_headers) enumtypes.h.template
$(AM_V_GEN) ( top_builddir=`cd $(top_builddir) && pwd`; \
cd $(srcdir) && $(GLIB_MKENUMS) --template enumtypes.h.template $(enum_headers) ) > \
enumtypes.h.tmp && mv enumtypes.h.tmp enumtypes.h
enumtypes.c: $(enum_headers) enumtypes.h enumtypes.c.template
$(AM_V_GEN) ( top_builddir=`cd $(top_builddir) && pwd`; \
cd $(srcdir) && $(GLIB_MKENUMS) --template enumtypes.c.template $(enum_headers) ) > \
enumtypes.c.tmp && mv enumtypes.c.tmp enumtypes.c

35
wmud/enumtypes.c Normal file
View File

@ -0,0 +1,35 @@
/* Generated data (by glib-mkenums) */
#include "enumtypes.h"
#include "wmudclientstate.h"
/* enumerations from "wmudclientstate.h" */
GType
wmud_client_state_get_type (void)
{
static volatile gsize g_define_type_id__volatile = 0;
if (g_once_init_enter(&g_define_type_id__volatile)) {
static const GEnumValue values[] = {
{ WMUD_CLIENT_STATE_FRESH, "WMUD_CLIENT_STATE_FRESH", "fresh" },
{ WMUD_CLIENT_STATE_PASSWAIT, "WMUD_CLIENT_STATE_PASSWAIT", "passwait" },
{ WMUD_CLIENT_STATE_MENU, "WMUD_CLIENT_STATE_MENU", "menu" },
{ WMUD_CLIENT_STATE_INGAME, "WMUD_CLIENT_STATE_INGAME", "ingame" },
{ WMUD_CLIENT_STATE_YESNO, "WMUD_CLIENT_STATE_YESNO", "yesno" },
{ WMUD_CLIENT_STATE_REGISTERING, "WMUD_CLIENT_STATE_REGISTERING", "registering" },
{ WMUD_CLIENT_STATE_REGEMAIL_CONFIRM, "WMUD_CLIENT_STATE_REGEMAIL_CONFIRM", "regemail-confirm" },
{ 0, NULL, NULL }
};
GType g_define_type_id = g_enum_register_static(g_intern_static_string("WmudClientState"), values);
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
}
return g_define_type_id__volatile;
}
/* Generated data ends here */

38
wmud/enumtypes.c.template Normal file
View File

@ -0,0 +1,38 @@
/*** BEGIN file-header ***/
#include "enumtypes.h"
#include "@filename@"
/*** 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 ***/

17
wmud/enumtypes.h Normal file
View File

@ -0,0 +1,17 @@
/* Generated data (by glib-mkenums) */
#ifndef __WMUD_ENUM_TYPES_H__
#define __WMUD_ENUM_TYPES_H__
#include <glib-object.h>
/* enumerations from "wmudclientstate.h" */
GType wmud_client_state_get_type(void);
#define WMUD_TYPE_CLIENT_STATE (wmud_client_state_get_type())
#endif /* __WMUD_ENUM_TYPES_H__ */
/* Generated data ends here */

22
wmud/enumtypes.h.template Normal file
View File

@ -0,0 +1,22 @@
/*** BEGIN file-header ***/
#ifndef __WMUD_ENUM_TYPES_H__
#define __WMUD_ENUM_TYPES_H__
#include <glib-object.h>
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
GType @enum_name@_get_type(void);
#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
/*** END value-header ***/
/*** BEGIN file-tail ***/
#endif /* __WMUD_ENUM_TYPES_H__ */
/*** END file-tail ***/

View File

@ -19,6 +19,7 @@
#include "wmudclient.h"
#include "wmudclientstate.h"
#include "enumtypes.h"
#include "players.h"
/**

View File

@ -1,25 +0,0 @@
#include "wmudclientstate.h"
GType
wmud_client_state_get_type (void)
{
static volatile gsize g_define_type_id__volatile = 0;
if (g_once_init_enter(&g_define_type_id__volatile)) {
static const GEnumValue values[] = {
{ WMUD_CLIENT_STATE_FRESH, "WMUD_CLIENT_STATE_FRESH", "fresh" },
{ WMUD_CLIENT_STATE_PASSWAIT, "WMUD_CLIENT_STATE_PASSWAIT", "passwait" },
{ WMUD_CLIENT_STATE_MENU, "WMUD_CLIENT_STATE_MENU", "menu" },
{ WMUD_CLIENT_STATE_INGAME, "WMUD_CLIENT_STATE_INGAME", "ingame" },
{ WMUD_CLIENT_STATE_YESNO, "WMUD_CLIENT_STATE_YESNO", "yesno" },
{ WMUD_CLIENT_STATE_REGISTERING, "WMUD_CLIENT_STATE_REGISTERING", "registering" },
{ WMUD_CLIENT_STATE_REGEMAIL_CONFIRM, "WMUD_CLIENT_STATE_REGEMAIL_CONFIRM", "regemail-confirm" },
{ 0, NULL, NULL }
};
GType g_define_type_id = g_enum_register_static(g_intern_static_string("WmudClientState"), values);
g_once_init_leave(&g_define_type_id__volatile, g_define_type_id);
}
return g_define_type_id__volatile;
}

View File

@ -36,9 +36,5 @@ typedef enum {
WMUD_CLIENT_STATE_REGEMAIL_CONFIRM
} WmudClientState;
GType wmud_client_state_get_type (void) G_GNUC_CONST;
#define WMUD_TYPE_CLIENT_STATE (wmud_client_state_get_type())
#endif /* __WMUD_CLIENT_STATE_H__ */