[gnome-bluetooth] Generate headers and sources for enum classes



commit cfceee09c5e386c1d1ef00c5f65a4d6b6397ba9e
Author: Bastien Nocera <hadess hadess net>
Date:   Thu May 28 11:29:50 2009 +0100

    Generate headers and sources for enum classes
---
 common/Makefile.am |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/common/Makefile.am b/common/Makefile.am
index 51d8aa5..4079abf 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -15,6 +15,8 @@ libgnome_bluetooth_la_SOURCES =				\
 	bluetooth-enums.h				\
 	bluetooth-client.h bluetooth-client.c		\
 	marshal.h marshal.c				\
+	gnome-bluetooth-enum-types.h			\
+	gnome-bluetooth-enum-types.c			\
 	bluetooth-chooser.c bluetooth-chooser.h		\
 	bluetooth-chooser-button.c bluetooth-chooser-button.h
 
@@ -74,3 +76,32 @@ bluetooth-agent-glue.h: bluetooth-agent.xml
 
 obex-agent-glue.h: obex-agent.xml
 	$(DBUS_BINDING_TOOL) --prefix=obex_agent --mode=glib-server --output=$@ $<
+
+gnome_bluetooth_headers_to_scan_for_enums = bluetooth-client.h bluetooth-enums.h
+# Generate the enums source code, with glib-mkenums:
+# This is based on the same Makefile.am stuff in pango:
+gnome_bluetooth_built_headers = gnome-bluetooth-enum-types.h
+gnome_bluetooth_built_cfiles = gnome-bluetooth-enum-types.c
+
+# Don't build the library until we have built the header that it needs:
+$(OBJECTS) $(libgnomevfs_2_la_OBJECTS): $(libgnomevfs_built_headers)
+
+gnome-bluetooth-enum-types.h: $(gnome_bluetooth_headers_to_scan_for_enums) Makefile
+	(cd $(srcdir) && glib-mkenums \
+			--fhead "#ifndef __GNOME_BLUETOOTH_ENUM_TYPES_H__\n#define __GNOME_BLUETOOTH_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
+			--fprod "/* enumerations from \"@filename \" */\n" \
+			--vhead "GType @enum_name _get_type (void);\n#define BLUETOOTH_TYPE_ ENUMSHORT@ (@enum_name _get_type())\n" 	\
+			--ftail "G_END_DECLS\n\n#endif /* __GNOME_BLUETOOTH_ENUM_TYPES_H__ */" \
+		$(gnome_bluetooth_headers_to_scan_for_enums)) > $@
+
+gnome-bluetooth-enum-types.c: $(gnome_bluetooth_headers_to_scan_for_enums) Makefile gnome-bluetooth-enum-types.h
+	(cd $(srcdir) && glib-mkenums \
+			--fhead "#include <bluetooth-enums.h>\n" \
+			--fhead "#include \"gnome-bluetooth-enum-types.h\"\n" \
+			--fhead "#include \"bluetooth-client.h\"\n" \
+			--fhead "#include <glib-object.h>" \
+		      	--fprod "\n/* enumerations from \"@filename \" */" \
+			--vhead "GType\n enum_name@_get_type (void)\n{\n  static GType etype = 0;\n  if (etype == 0) {\n    static const G Type@Value values[] = {" 	\
+			--vprod "      { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
+			--vtail "      { 0, NULL, NULL }\n    };\n    etype = g_ type@_register_static (\"@EnumName \", values);\n  }\n  return etype;\n}\n" \
+		$(gnome_bluetooth_headers_to_scan_for_enums)) > $@



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]