Re: GDate API Rename Patch #2



Hi,

> > It is the _get patch. Not the Islamic stuff. Feel free to apply the
> > GDate patch then, or if you're too busy, tell me and I can do it myself.
> 
> Give Owen/Tim a couple days to complain, then apply it. ;-)

Not being explicitly invited to complain, I'd still prefer to do ;-)

I do not like the idea of a compat.h file very much. I suppose, that this will
be around forever (and every function in it), 'cause noone will change their
programs to the new API as long as they aren't "forced" to. 

Here's my proposal:

We add the following function to gutils.c

G_LOCK_DEFINE_STATIC (g_deprecated);

void 
g_deprecated (const gchar* name, const gchar* message)
{
  static gboolean init = FALSE;
  static GData *datalist;

  G_LOCK (g_deprecated);
  if (!init)
    {
      init = TRUE;
      g_datalist_init (&datalist);
    }

  /* We already warned about that */
  if (g_datalist_get_data (&datalist, name) != NULL)  
    {
      G_UNLOCK (g_deprecated);
      return;
    }

  g_datalist_set_data (&datalist, name, GINT_TO_POINTER (1));

  g_warning ("The use of %s() is deprecated.\n"
	     "\tIt might disappear in the next major release of GLib.%s%s",
	     name, message ? "\n\t" : "", message ? message : "");  
}

And then the following macros to gutils.h

void g_deprecated (const gchar* oldname, const gchar* message);

#define G_DEPRECATED_MSG(function, message) 			\
  (g_deprecated (#function, (message)))

#define G_DEPRECATED_USE(oldfunc, newfunc, arg)			\
  (g_deprecated (#oldfunc, "Use " #newfunc " instead."), newfunc arg)

And then voila we add the following lines to gdate.h

/* Deprecated functions */

#define g_date_weekday(date) 						\
  G_DEPRECATED_USE (g_date_weekday, g_date_get_weekday, (date))
#define g_date_year(date) 						\
  G_DEPRECATED_USE (g_date_year, g_date_get_year, (date))
#define g_date_day(date) 						\
  G_DEPRECATED_USE (g_date_day, g_date_get_day, (date))
#define g_date_julian(date) 						\
  G_DEPRECATED_USE (g_date_julian, g_date_get_julian, (date))
#define g_date_day_of_year(date)					\
  G_DEPRECATED_USE (g_date_day_of_year, g_date_get_day_of_year, (date))
#define g_date_monday_week_of_year(date) 				\
  G_DEPRECATED_USE (g_date_monday_week_of_year, 			\
		    g_date_get_monday_week_of_year, (date))
#define g_date_sunday_week_of_year(date) 				\
  G_DEPRECATED_USE (g_date_sunday_week_of_year,  			\
		    g_date_get_sunday_week_of_year, (date))
#define g_date_days_in_month(date) 					\
  G_DEPRECATED_USE (g_date_days_in_month, g_date_get_days_in_month, (date))
#define g_date_monday_weeks_in_year(date) 				\
  G_DEPRECATED_USE (g_date_monday_weeks_in_year, 			\
		    g_date_get_monday_weeks_in_year, (date))
#define g_date_sunday_weeks_in_year(date) 				\
  G_DEPRECATED_USE (g_date_sunday_weeks_in_year,			\
		    g_date_get_sunday_weeks_in_year, (date))


Now every user of g_date_weekday get the following message _once_, no matter
how often he uses this function:

GLib-WARNING **: The use of g_date_weekday() is deprecated.
	It might disappear in the next major release of GLib.
	Use g_date_get_weekday instead.

That way the GLib library won't blow up in size for additional compatibility
functions and every programmer could see this warnings and heed them and we
could throw away all old G_DEPRECATED_USE macros for a new major release.

If of course you don't like that, I'll add my the deprecated functions to
gcompat.h as well to make it more consistent. 

Bye,
Sebastian
-- 
Sebastian Wilhelmi
mailto:wilhelmi ira uka de
http://goethe.ira.uka.de/~wilhelmi




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