[yelp/yelp-3-0] [libyelp] Autogenerating enum types with glib-mkenums
- From: Shaun McCance <shaunm src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [yelp/yelp-3-0] [libyelp] Autogenerating enum types with glib-mkenums
- Date: Wed, 7 Oct 2009 04:12:44 +0000 (UTC)
commit 49bf376f02b325e610a5e69e1ee87d7ef29e80da
Author: Shaun McCance <shaunm gnome org>
Date: Fri Oct 2 10:52:58 2009 -0500
[libyelp] Autogenerating enum types with glib-mkenums
docs/libyelp/Makefile.am | 4 +-
libyelp/Makefile.am | 47 ++++++++++++++++++++++++++++++++++++++++++++++
libyelp/yelp-view.c | 21 ++-----------------
libyelp/yelp-view.h | 2 -
4 files changed, 52 insertions(+), 22 deletions(-)
---
diff --git a/docs/libyelp/Makefile.am b/docs/libyelp/Makefile.am
index dd54bd0..9a8d530 100644
--- a/docs/libyelp/Makefile.am
+++ b/docs/libyelp/Makefile.am
@@ -20,9 +20,9 @@ GTKDOC_LIBS = \
HFILE_GLOB = $(top_srcdir)/libyelp/*.h
CFILE_GLOB = $(top_srcdir)/libyelp/*.c
-IGNORE_HFILES = yelp-debug.h
+IGNORE_HFILES = yelp-debug.h yelp-types.h
-MKDB_OPTIONS = --output-format=xml --sgml-mode --name-space=yelp --ignore-files='yelp-debug.h yelp-debug.c'
+MKDB_OPTIONS = --output-format=xml --sgml-mode --name-space=yelp --ignore-files='yelp-debug.c yelp-debug.h yelp-types.c yelp-types.h'
content_files = version.xml
diff --git a/libyelp/Makefile.am b/libyelp/Makefile.am
index 69e6e9a..89298d6 100644
--- a/libyelp/Makefile.am
+++ b/libyelp/Makefile.am
@@ -7,6 +7,7 @@ libyelp_la_SOURCES = \
yelp-settings.c \
yelp-simple-document.c \
yelp-uri.c \
+ yelp-types.c \
yelp-view.c
libyelp_la_CFLAGS = \
@@ -15,3 +16,49 @@ libyelp_la_CFLAGS = \
libyelp_la_LIBADD = \
$(YELP_LIBS)
+
+libyelp_headers = \
+ yelp-document.h \
+ yelp-location-entry.h \
+ yelp-settings.h \
+ yelp-simple-document.h \
+ yelp-uri.h \
+ yelp-view.h
+
+libyelp_includedir = $(includedir)/libyelp/
+
+libyelp_include_HEADERS = \
+ $(libyelp_headers) \
+ yelp-types.h
+
+BUILT_SOURCES = yelp-types.c yelp-types.h
+
+CLEANFILES = $(BUILT_SOURCES)
+
+yelp-types.h: $(libyelp_headers)
+ (cd $(srcdir) && glib-mkenums \
+ --fhead "#ifndef __LIBYELP_TYPES_H__\n" \
+ --fhead "#define __LIBYELP_TYPES_H__\n\n" \
+ --fhead "#include <glib-object.h>\n\n" \
+ --fhead "G_BEGIN_DECLS\n\n" \
+ --ftail "G_END_DECLS\n\n" \
+ --ftail "#endif /* __LIBYELP_TYPES_H__ */\n" \
+ --fprod "#include <libyelp/@filename@>\n" \
+ --eprod "#define YELP_TYPE_ ENUMSHORT@ @enum_name _get_type()\n" \
+ --eprod "GType @enum_name _get_type (void);\n" \
+ $(libyelp_headers)) > $@
+
+yelp-types.c: $(libyelp_headers)
+ (cd $(srcdir) && glib-mkenums \
+ --fhead "#include <glib-object.h>\n" \
+ --fhead "#include \"yelp-types.h\"\n\n" \
+ --fprod "\n/* enumerations from \"@filename \" */" \
+ --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\n" \
+ --vtail " if (!type)\n" \
+ --vtail " type = g_ type@_register_static (\"@EnumName \", _ enum_name@_values);\n\n" \
+ --vtail " return type;\n}\n\n" \
+ $(libyelp_headers)) > $@
diff --git a/libyelp/yelp-view.c b/libyelp/yelp-view.c
index 78ea51e..f77c74d 100644
--- a/libyelp/yelp-view.c
+++ b/libyelp/yelp-view.c
@@ -30,6 +30,7 @@
#include <webkit/webkit.h>
#include "yelp-error.h"
+#include "yelp-types.h"
#include "yelp-view.h"
static void yelp_view_init (YelpView *view);
@@ -81,23 +82,6 @@ enum {
TARGET_URI_LIST
};
-GType
-yelp_view_state_get_type (void)
-{
- static GType etype = 0;
- if (etype == 0) {
- static const GEnumValue values[] = {
- { YELP_VIEW_STATE_BLANK, "YELP_VIEW_STATE_BLANK", "blank" },
- { YELP_VIEW_STATE_LOADING, "YELP_VIEW_STATE_LOADING", "loading" },
- { YELP_VIEW_STATE_LOADED, "YELP_VIEW_STATE_LOADED", "loaded" },
- { YELP_VIEW_STATE_ERROR, "YELP_VIEW_STATE_ERROR", "error" },
- { 0, NULL, NULL }
- };
- etype = g_enum_register_static (g_intern_static_string ("YelpViewState"), values);
- }
- return etype;
-}
-
static void
yelp_view_init (YelpView *view)
{
@@ -165,7 +149,8 @@ yelp_view_class_init (YelpViewClass *klass)
N_("The loading state of the view"),
YELP_TYPE_VIEW_STATE,
YELP_VIEW_STATE_BLANK,
- G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+ G_PARAM_READWRITE | G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
}
static void
diff --git a/libyelp/yelp-view.h b/libyelp/yelp-view.h
index 40b02eb..70b4314 100644
--- a/libyelp/yelp-view.h
+++ b/libyelp/yelp-view.h
@@ -37,8 +37,6 @@ G_BEGIN_DECLS
#define YELP_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), YELP_TYPE_VIEW))
#define YELP_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), YELP_TYPE_VIEW))
-#define YELP_TYPE_VIEW_STATE (yelp_view_state_get_type ())
-
typedef struct _YelpView YelpView;
typedef struct _YelpViewClass YelpViewClass;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]