libgweather r375 - in trunk: . libgweather



Author: danw
Date: Thu Sep  4 12:36:23 2008
New Revision: 375
URL: http://svn.gnome.org/viewvc/libgweather?rev=375&view=rev

Log:
	Set libgweather up for bindings. Part of #547824

	* configure.in: set GLIB_MKENUMS

	* libgweather/Makefile.am: build gweather-enum-types.[ch]

	* libgweather/gweather-enum-types.c.tmpl:
	* libgweather/gweather-enum-types.h.tmpl: Add these

	* libgweather/gweather-location.c (gweather_location_get_type):
	* libgweather/gweather-timezone.c (gweather_timezone_get_type):
	register as boxed types


Added:
   trunk/libgweather/gweather-enum-types.c.tmpl
   trunk/libgweather/gweather-enum-types.h.tmpl
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/libgweather/   (props changed)
   trunk/libgweather/Makefile.am
   trunk/libgweather/gweather-location.c
   trunk/libgweather/gweather-location.h
   trunk/libgweather/gweather-timezone.c
   trunk/libgweather/gweather-timezone.h

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Thu Sep  4 12:36:23 2008
@@ -104,6 +104,9 @@
 
 AM_GCONF_SOURCE_2
 
+dnl -- check for glib; redundant at this point, but sets $GLIB_MKENUMS
+AM_PATH_GLIB_2_0($GLIB_REQUIRED)
+
 dnl gettext
 
 GETTEXT_PACKAGE=libgweather

Modified: trunk/libgweather/Makefile.am
==============================================================================
--- trunk/libgweather/Makefile.am	(original)
+++ trunk/libgweather/Makefile.am	Thu Sep  4 12:36:23 2008
@@ -1,10 +1,15 @@
 lib_LTLIBRARIES = libgweather.la
 
 libgweatherincdir = $(includedir)/libgweather
-libgweatherinc_HEADERS = \
-	weather.h gweather-gconf.h gweather-prefs.h gweather-xml.h \
+gweather_old_headers = \
+	weather.h gweather-gconf.h gweather-prefs.h gweather-xml.h
+gweather_new_headers = \
 	gweather-location.h location-entry.h \
 	gweather-timezone.h timezone-menu.h
+libgweatherinc_HEADERS = \
+	$(gweather_old_headers)		\
+	$(gweather_new_headers)		\
+	gweather-enum-types.h
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = gweather.pc
@@ -14,6 +19,7 @@
 	weather-metar.c weather-iwin.c weather-met.c \
 	weather-bom.c weather-wx.c \
 	weather-sun.c \
+	gweather-enum-types.c \
 	gweather-prefs.c gweather-prefs.h \
 	gweather-gconf.c gweather-gconf.h \
 	gweather-xml.c gweather-xml.h \
@@ -44,6 +50,22 @@
 libgweather_la_LDFLAGS = \
 	-version-info $(LT_VERSION) -no-undefined
 
+MKENUMS_GENERATED = gweather-enum-types.c gweather-enum-types.h
+
+gweather-enum-types.h: $(gweather_new_headers)
+	( cd $(srcdir) && $(GLIB_MKENUMS) --template gweather-enum-types.h.tmpl \
+		$(gweather_new_headers) ) > gweather-enum-types.h.tmp \
+	&& mv gweather-enum-types.h.tmp gweather-enum-types.h \
+	|| rm -f gweather-enum-type.h.tmp
+
+gweather-enum-types.c: $(libgweatherinclude_HEADERS)
+	( cd $(srcdir) && $(GLIB_MKENUMS) --template gweather-enum-types.c.tmpl \
+		$(gweather_new_headers) ) > gweather-enum-types.c.tmp \
+	&& mv gweather-enum-types.c.tmp gweather-enum-types.c \
+	|| rm -f gweather-enum-type.c.tmp
+
+BUILT_SOURCES = $(MKENUMS_GENERATED)
+
 test_metar_SOURCES = test_metar.c
 
 test_metar_CFLAGS = \
@@ -96,4 +118,4 @@
 
 EXTRA_PROGRAMS = test_metar
 
-CLEANFILES = $(schema_DATA) $(EXTRA_PROGRAMS)
+CLEANFILES = $(schema_DATA) $(EXTRA_PROGRAMS) $(MKENUMS_GENERATED)

Added: trunk/libgweather/gweather-enum-types.c.tmpl
==============================================================================
--- (empty file)
+++ trunk/libgweather/gweather-enum-types.c.tmpl	Thu Sep  4 12:36:23 2008
@@ -0,0 +1,35 @@
+/*** BEGIN file-header ***/
+#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
+#include "gweather-enum-types.h"
+#include "gweather-location.h"
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+ enum_name@_get_type (void)
+{
+	static GType etype = 0;
+	if (G_UNLIKELY (etype == 0)) {
+		static const G Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+			{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+			{ 0, NULL, NULL }
+		};
+		etype = g_ type@_register_static (g_intern_static_string ("@EnumName@"), values);
+	}
+	return etype;
+}
+
+/*** END value-tail ***/
+
+/*** BEGIN file-tail ***/
+/*** END file-tail ***/

Added: trunk/libgweather/gweather-enum-types.h.tmpl
==============================================================================
--- (empty file)
+++ trunk/libgweather/gweather-enum-types.h.tmpl	Thu Sep  4 12:36:23 2008
@@ -0,0 +1,24 @@
+/*** BEGIN file-header ***/
+#ifndef __GWEATHER_ENUM_TYPES_H__
+#define __GWEATHER_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name _get_type (void) G_GNUC_CONST;
+#define GWEATHER_TYPE_ ENUMSHORT@ (@enum_name _get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __GWEATHER_ENUM_TYPES_H__ */
+/*** END file-tail ***/

Modified: trunk/libgweather/gweather-location.c
==============================================================================
--- trunk/libgweather/gweather-location.c	(original)
+++ trunk/libgweather/gweather-location.c	Thu Sep  4 12:36:23 2008
@@ -321,6 +321,21 @@
     g_slice_free (GWeatherLocation, loc);
 }
 
+GType
+gweather_location_get_type (void)
+{
+    static volatile gsize type_volatile = 0;
+
+    if (g_once_init_enter (&type_volatile)) {
+	GType type = g_boxed_type_register_static (
+	    g_intern_static_string ("GWeatherLocation"),
+	    (GBoxedCopyFunc) gweather_location_ref,
+	    (GBoxedFreeFunc) gweather_location_unref);
+	g_once_init_leave (&type_volatile, type);
+    }
+    return type_volatile;
+}
+
 const char *
 gweather_location_get_name (GWeatherLocation *loc)
 {

Modified: trunk/libgweather/gweather-location.h
==============================================================================
--- trunk/libgweather/gweather-location.h	(original)
+++ trunk/libgweather/gweather-location.h	Thu Sep  4 12:36:23 2008
@@ -35,7 +35,7 @@
 typedef struct _GWeatherWeather  GWeatherWeather;
 typedef struct _GWeatherForecast GWeatherForecast;
 
-typedef enum {
+typedef enum { /*< underscore_name=gweather_location_level >*/
     GWEATHER_LOCATION_WORLD,
     GWEATHER_LOCATION_REGION,
     GWEATHER_LOCATION_COUNTRY,
@@ -47,6 +47,9 @@
     GWEATHER_LOCATION_WEATHER_STATION
 } GWeatherLocationLevel;
 
+GType gweather_location_get_type (void);
+#define GWEATHER_TYPE_LOCATION (gweather_location_get_type ())
+
 GWeatherLocation      *gweather_location_new_world      (gboolean           use_regions);
 GWeatherLocation      *gweather_location_ref            (GWeatherLocation  *loc);
 void                   gweather_location_unref          (GWeatherLocation  *loc);

Modified: trunk/libgweather/gweather-timezone.c
==============================================================================
--- trunk/libgweather/gweather-timezone.c	(original)
+++ trunk/libgweather/gweather-timezone.c	Thu Sep  4 12:36:23 2008
@@ -253,6 +253,21 @@
     }
 }
 
+GType
+gweather_timezone_get_type (void)
+{
+    static volatile gsize type_volatile = 0;
+
+    if (g_once_init_enter (&type_volatile)) {
+	GType type = g_boxed_type_register_static (
+	    g_intern_static_string ("GWeatherTimezone"),
+	    (GBoxedCopyFunc) gweather_timezone_ref,
+	    (GBoxedFreeFunc) gweather_timezone_unref);
+	g_once_init_leave (&type_volatile, type);
+    }
+    return type_volatile;
+}
+
 const char *
 gweather_timezone_get_name (GWeatherTimezone *zone)
 {

Modified: trunk/libgweather/gweather-timezone.h
==============================================================================
--- trunk/libgweather/gweather-timezone.h	(original)
+++ trunk/libgweather/gweather-timezone.h	Thu Sep  4 12:36:23 2008
@@ -25,12 +25,15 @@
 #error "libgweather should only be used if you understand that it's subject to change, and is not supported as a fixed API/ABI or as part of the platform"
 #endif
 
-#include <glib.h>
+#include <glib-object.h>
 
 G_BEGIN_DECLS
 
 typedef struct _GWeatherTimezone GWeatherTimezone;
 
+GType gweather_timezone_get_type (void);
+#define GWEATHER_TYPE_TIMEZONE (gweather_timezone_get_type ())
+
 const char       *gweather_timezone_get_name       (GWeatherTimezone *zone);
 const char       *gweather_timezone_get_tzid       (GWeatherTimezone *zone);
 int               gweather_timezone_get_offset     (GWeatherTimezone *zone);



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