[glibmm] DateTime: Add methods and create() methods not creating now instances.



commit 9bd7541d3feffacd0c732ed93123ce11547009d4
Author: Josà Alburquerque <jaalburqu svn gnome org>
Date:   Wed Jun 15 16:29:39 2011 -0400

    DateTime: Add methods and create() methods not creating now instances.
    
    	* glib/src/glib_functions.defs: h2def.py missed the g_date_time_add*()
    	functions because they were preceded by an unknown macro, namely
    	G_GNUC_WARN_UNUSED_RESULT, so temporarily removed the macros and
    	regenerated this file to get the definitions for those functions.
    	h2def.py will probably have to be modified to skip over those macros
    	properly in the future.  Also corrected the
    	g_date_time_[compare|hash|equal] definitions so that the functions
    	could be wrapped as method members of DateTime.
    	* glib/src/glib_functions.defs.patch: Added this patch file so future
    	editing of the above file should not be necessary.
    	* glib/src/datetime.hg: Added the missing create() and the rest of the
    	methods.
    	* tools/m4/convert_glib.m4: Added necessary conversions.

 ChangeLog                          |   25 ++++++
 glib/src/datetime.hg               |   50 ++++++++++-
 glib/src/glib_functions.defs       |  104 +++++++++++++++++++++--
 glib/src/glib_functions.defs.patch |  163 ++++++++++++++++++++++++++++++++++++
 tools/m4/convert_glib.m4           |    6 +-
 5 files changed, 334 insertions(+), 14 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1b06145..436f0b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2011-06-15  Josà Alburquerque  <jaalburqu svn gnome org>
+
+	DateTime: Add methods and create() methods not creating now instances.
+
+	* glib/src/glib_functions.defs: h2def.py missed the g_date_time_add*()
+	functions because they were preceded by an unknown macro, namely
+	G_GNUC_WARN_UNUSED_RESULT, so temporarily removed the macros and
+	regenerated this file to get the definitions for those functions.
+	h2def.py will probably have to be modified to skip over those macros
+	properly in the future.  Also corrected the
+	g_date_time_[compare|hash|equal] definitions so that the functions
+	could be wrapped as method members of DateTime.
+	* glib/src/glib_functions.defs.patch: Added this patch file so future
+	editing of the above file should not be necessary.
+	* glib/src/datetime.hg: Added the missing create() and the rest of the
+	methods.
+	* tools/m4/convert_glib.m4: Added necessary conversions.
+
+2011-06-14  Josà Alburquerque  <jaalburqu svn gnome org>
+
+	TimeZone: Const corrections.
+
+	* glib/src/timezone.hg: Correct the constness of the TimeZone for some
+	methods.
+
 2011-06-14  Josà Alburquerque  <jaalburqu svn gnome org>
 
 	TimeZone: Const corrections.
diff --git a/glib/src/datetime.hg b/glib/src/datetime.hg
index 88d9db2..8717ae5 100644
--- a/glib/src/datetime.hg
+++ b/glib/src/datetime.hg
@@ -32,6 +32,11 @@ namespace Glib
 class TimeVal;
 class TimeZone;
 
+/** A value representing an interval of time, in microseconds.  As GTimeSpan,
+ * its underlying type is gint64.
+ */
+typedef GTimeSpan TimeSpan;
+
 /** DateTime - A structure representing Date and Time.
  * DateTime is a structure that combines a Gregorian date and time into a
  * single structure. It provides many conversion and methods to manipulate
@@ -62,7 +67,7 @@ class DateTime
   _IGNORE(g_date_time_ref, g_date_time_unref)
 
 public:
- _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now(const Glib::RefPtr<const TimeZone>& timezone), g_date_time_new_now)
+ _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now(const Glib::RefPtr<const TimeZone>& tz), g_date_time_new_now)
   _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now_local(), g_date_time_new_now_local)
   _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now_utc(), g_date_time_new_now_utc)
 
@@ -72,8 +77,47 @@ public:
   _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now_local(const TimeVal& tv), g_date_time_new_from_timeval_local)
   _WRAP_METHOD(static Glib::RefPtr<DateTime> create_now_utc(const TimeVal& tv), g_date_time_new_from_timeval_utc)
 
-  //TODO: Wrap the create() methods not creating now instances.
-  //TODO: Wrap the the rest of the methods.
+  _WRAP_METHOD(static Glib::RefPtr<DateTime> create(const Glib::RefPtr<const TimeZone>& tz, int year, int month, int day, int hour, int minute, double seconds), g_date_time_new)
+  _WRAP_METHOD(static Glib::RefPtr<DateTime> create_local(int year, int month, int day, int hour, int minute, double seconds), g_date_time_new_local)
+  _WRAP_METHOD(static Glib::RefPtr<DateTime> create_utc(int year, int month, int day, int hour, int minute, double seconds), g_date_time_new_utc)
+
+  _WRAP_METHOD(Glib::RefPtr<DateTime> add(TimeSpan timespan) const, g_date_time_add)
+  _WRAP_METHOD(Glib::RefPtr<DateTime> add_years(int years) const, g_date_time_add_years)
+  _WRAP_METHOD(Glib::RefPtr<DateTime> add_months(int months) const, g_date_time_add_months)
+  _WRAP_METHOD(Glib::RefPtr<DateTime> add_weeks(int weeks) const, g_date_time_add_weeks)
+  _WRAP_METHOD(Glib::RefPtr<DateTime> add_days(int days) const, g_date_time_add_days)
+  _WRAP_METHOD(Glib::RefPtr<DateTime> add_hours(int hours) const, g_date_time_add_hours)
+  _WRAP_METHOD(Glib::RefPtr<DateTime> add_minutes(int minutes) const, g_date_time_add_minutes)
+  _WRAP_METHOD(Glib::RefPtr<DateTime> add_seconds(double seconds) const, g_date_time_add_seconds)
+  _WRAP_METHOD(Glib::RefPtr<DateTime> add_full(int years, int months, int days, int hours, int minutes, double seconds) const, g_date_time_add_full)
+  _WRAP_METHOD(TimeSpan difference(const Glib::RefPtr<const DateTime>& other) const, g_date_time_difference)
+
+  _WRAP_METHOD(int compare(const Glib::RefPtr<const DateTime>& other) const, g_date_time_compare)
+  _WRAP_METHOD(guint hash() const, g_date_time_hash)
+  _WRAP_METHOD(bool equal(const Glib::RefPtr<const DateTime>& other) const, g_date_time_equal)
+
+  _WRAP_METHOD(void get_ymd(int& year, int& month, int& day) const, g_date_time_get_ymd)
+  _WRAP_METHOD(int get_year() const, g_date_time_get_year)
+  _WRAP_METHOD(int get_month() const, g_date_time_get_month)
+  _WRAP_METHOD(int get_day_of_month() const, g_date_time_get_day_of_month)
+  _WRAP_METHOD(int get_week_numbering_year() const, g_date_time_get_week_numbering_year)
+  _WRAP_METHOD(int get_week_of_year() const, g_date_time_get_week_of_year)
+  _WRAP_METHOD(int get_day_of_week() const, g_date_time_get_day_of_week)
+  _WRAP_METHOD(int get_day_of_year() const, g_date_time_get_day_of_year)
+  _WRAP_METHOD(int get_hour() const, g_date_time_get_hour)
+  _WRAP_METHOD(int get_minute() const, g_date_time_get_minute)
+  _WRAP_METHOD(int get_second() const, g_date_time_get_second)
+  _WRAP_METHOD(int get_microsecond() const, g_date_time_get_microsecond)
+  _WRAP_METHOD(double get_seconds() const, g_date_time_get_seconds)
+  _WRAP_METHOD(gint64 to_unix() const, g_date_time_to_unix)
+  _WRAP_METHOD(bool to_timeval(TimeVal& tv) const, g_date_time_to_timeval)
+  _WRAP_METHOD(TimeSpan get_utc_offset() const, g_date_time_get_utc_offset)
+  _WRAP_METHOD(Glib::ustring get_timezone_abbreviation() const, g_date_time_get_timezone_abbreviation)
+  _WRAP_METHOD(bool is_daylight_savings() const, g_date_time_is_daylight_savings)
+  _WRAP_METHOD(Glib::RefPtr<DateTime> to_timezone(const Glib::RefPtr<const TimeZone>& tz) const, g_date_time_to_timezone)
+  _WRAP_METHOD(Glib::RefPtr<DateTime> to_local() const, g_date_time_to_local)
+  _WRAP_METHOD(Glib::RefPtr<DateTime> to_utc() const, g_date_time_to_utc)
+  _WRAP_METHOD(Glib::ustring format(const Glib::ustring& format) const, g_date_time_format)
 };
 
 } // namespace Glib
diff --git a/glib/src/glib_functions.defs b/glib/src/glib_functions.defs
index 4adc3ff..fd38301 100644
--- a/glib/src/glib_functions.defs
+++ b/glib/src/glib_functions.defs
@@ -3286,12 +3286,98 @@
   )
 )
 
-(define-function g_date_time_compare
+(define-method add
+  (of-object "GDateTime")
+  (c-name "g_date_time_add")
+  (return-type "GDateTime*")
+  (parameters
+    '("GTimeSpan" "timespan")
+  )
+)
+
+(define-method add_years
+  (of-object "GDateTime")
+  (c-name "g_date_time_add_years")
+  (return-type "GDateTime*")
+  (parameters
+    '("gint" "years")
+  )
+)
+
+(define-method add_months
+  (of-object "GDateTime")
+  (c-name "g_date_time_add_months")
+  (return-type "GDateTime*")
+  (parameters
+    '("gint" "months")
+  )
+)
+
+(define-method add_weeks
+  (of-object "GDateTime")
+  (c-name "g_date_time_add_weeks")
+  (return-type "GDateTime*")
+  (parameters
+    '("gint" "weeks")
+  )
+)
+
+(define-method add_days
+  (of-object "GDateTime")
+  (c-name "g_date_time_add_days")
+  (return-type "GDateTime*")
+  (parameters
+    '("gint" "days")
+  )
+)
+
+(define-method add_hours
+  (of-object "GDateTime")
+  (c-name "g_date_time_add_hours")
+  (return-type "GDateTime*")
+  (parameters
+    '("gint" "hours")
+  )
+)
+
+(define-method add_minutes
+  (of-object "GDateTime")
+  (c-name "g_date_time_add_minutes")
+  (return-type "GDateTime*")
+  (parameters
+    '("gint" "minutes")
+  )
+)
+
+(define-method add_seconds
+  (of-object "GDateTime")
+  (c-name "g_date_time_add_seconds")
+  (return-type "GDateTime*")
+  (parameters
+    '("gdouble" "seconds")
+  )
+)
+
+(define-method add_full
+  (of-object "GDateTime")
+  (c-name "g_date_time_add_full")
+  (return-type "GDateTime*")
+  (parameters
+    '("gint" "years")
+    '("gint" "months")
+    '("gint" "days")
+    '("gint" "hours")
+    '("gint" "minutes")
+    '("gdouble" "seconds")
+  )
+)
+
+(define-method compare
+  (of-object "GDateTime")
   (c-name "g_date_time_compare")
   (return-type "gint")
   (parameters
-    '("gconstpointer" "dt1")
-    '("gconstpointer" "dt2")
+    '("GDateTime*" "dt2")
   )
 )
 
@@ -3304,20 +3390,18 @@
   )
 )
 
-(define-function g_date_time_hash
+(define-method hash
+  (of-object "GDateTime")
   (c-name "g_date_time_hash")
   (return-type "guint")
-  (parameters
-    '("gconstpointer" "datetime")
-  )
 )
 
-(define-function g_date_time_equal
+(define-method equal
+  (of-object "GDateTime")
   (c-name "g_date_time_equal")
   (return-type "gboolean")
   (parameters
-    '("gconstpointer" "dt1")
-    '("gconstpointer" "dt2")
+    '("GDateTime*" "dt2")
   )
 )
 
diff --git a/glib/src/glib_functions.defs.patch b/glib/src/glib_functions.defs.patch
new file mode 100644
index 0000000..d2e6bc3
--- /dev/null
+++ b/glib/src/glib_functions.defs.patch
@@ -0,0 +1,163 @@
+--- glib_functions.defs	2011-06-15 16:16:57.000000000 -0400
++++ glib_functions_new.defs	2011-06-15 16:16:06.000000000 -0400
+@@ -627,7 +627,7 @@
+   (c-name "GThreadError")
+   (gtype-id "G_TYPE_THREAD_ERROR")
+   (values
+-    '("n" "G_THREAD_ERROR_AGAIN")
++    '("again" "G_THREAD_ERROR_AGAIN")
+   )
+ )
+ 
+@@ -2482,7 +2482,7 @@
+   )
+ )
+ 
+-(define-method 
++(define-method iconv
+   (of-object "GIConv")
+   (c-name "g_iconv")
+   (return-type "gsize")
+@@ -3286,12 +3286,98 @@
+   )
+ )
+ 
+-(define-function g_date_time_compare
++(define-method add
++  (of-object "GDateTime")
++  (c-name "g_date_time_add")
++  (return-type "GDateTime*")
++  (parameters
++    '("GTimeSpan" "timespan")
++  )
++)
++
++(define-method add_years
++  (of-object "GDateTime")
++  (c-name "g_date_time_add_years")
++  (return-type "GDateTime*")
++  (parameters
++    '("gint" "years")
++  )
++)
++
++(define-method add_months
++  (of-object "GDateTime")
++  (c-name "g_date_time_add_months")
++  (return-type "GDateTime*")
++  (parameters
++    '("gint" "months")
++  )
++)
++
++(define-method add_weeks
++  (of-object "GDateTime")
++  (c-name "g_date_time_add_weeks")
++  (return-type "GDateTime*")
++  (parameters
++    '("gint" "weeks")
++  )
++)
++
++(define-method add_days
++  (of-object "GDateTime")
++  (c-name "g_date_time_add_days")
++  (return-type "GDateTime*")
++  (parameters
++    '("gint" "days")
++  )
++)
++
++(define-method add_hours
++  (of-object "GDateTime")
++  (c-name "g_date_time_add_hours")
++  (return-type "GDateTime*")
++  (parameters
++    '("gint" "hours")
++  )
++)
++
++(define-method add_minutes
++  (of-object "GDateTime")
++  (c-name "g_date_time_add_minutes")
++  (return-type "GDateTime*")
++  (parameters
++    '("gint" "minutes")
++  )
++)
++
++(define-method add_seconds
++  (of-object "GDateTime")
++  (c-name "g_date_time_add_seconds")
++  (return-type "GDateTime*")
++  (parameters
++    '("gdouble" "seconds")
++  )
++)
++
++(define-method add_full
++  (of-object "GDateTime")
++  (c-name "g_date_time_add_full")
++  (return-type "GDateTime*")
++  (parameters
++    '("gint" "years")
++    '("gint" "months")
++    '("gint" "days")
++    '("gint" "hours")
++    '("gint" "minutes")
++    '("gdouble" "seconds")
++  )
++)
++
++(define-method compare
++  (of-object "GDateTime")
+   (c-name "g_date_time_compare")
+   (return-type "gint")
+   (parameters
+-    '("gconstpointer" "dt1")
+-    '("gconstpointer" "dt2")
++    '("GDateTime*" "dt2")
+   )
+ )
+ 
+@@ -3304,20 +3390,18 @@
+   )
+ )
+ 
+-(define-function g_date_time_hash
++(define-method hash
++  (of-object "GDateTime")
+   (c-name "g_date_time_hash")
+   (return-type "guint")
+-  (parameters
+-    '("gconstpointer" "datetime")
+-  )
+ )
+ 
+-(define-function g_date_time_equal
++(define-method equal
++  (of-object "GDateTime")
+   (c-name "g_date_time_equal")
+   (return-type "gboolean")
+   (parameters
+-    '("gconstpointer" "dt1")
+-    '("gconstpointer" "dt2")
++    '("GDateTime*" "dt2")
+   )
+ )
+ 
+@@ -12131,14 +12215,6 @@
+   )
+ )
+ 
+-(define-function atexit
+-  (c-name "atexit")
+-  (return-type "int")
+-  (parameters
+-    '("void" "(*")
+-  )
+-)
+-
+ (define-function g_find_program_in_path
+   (c-name "g_find_program_in_path")
+   (return-type "gchar*")
diff --git a/tools/m4/convert_glib.m4 b/tools/m4/convert_glib.m4
index ddf8025..c2bc5a7 100644
--- a/tools/m4/convert_glib.m4
+++ b/tools/m4/convert_glib.m4
@@ -29,12 +29,14 @@ _EQUAL(gdouble*,double*)
 _EQUAL(gfloat, float)
 _EQUAL(float*,gfloat[])
 
-_EQUAL(GdkAtom,Gdk::Atom)
 _EQUAL(const-char*,const-gchar*)
 _EQUAL(return-char*,return-gchar*)
 _EQUAL(gpointer,void*)
 _EQUAL(gconstpointer,const void*)
 
+_EQUAL(GdkAtom,Gdk::Atom)
+_EQUAL(GTimeSpan,TimeSpan)
+
 # Basic Types
 _CONVERSION(`int',`bool',`$3')
 _CONVERSION(`bool',`int',`static_cast<int>($3)')
@@ -102,6 +104,7 @@ _CONVERSION(`return-char*',`Glib::ustring',`Glib::convert_return_gchar_ptr_to_us
 
 dnl DateTime
 _CONVERSION(`GDateTime*',`Glib::RefPtr<DateTime>',`Glib::wrap($3)')
+_CONVERSION(`const Glib::RefPtr<const DateTime>&',`GDateTime*',`const_cast<$2>(Glib::unwrap($3))')
 
 dnl KeyFile
 _CONVERSION(`Glib::KeyFile&',`GKeyFile*',`($3).gobj()')
@@ -125,6 +128,7 @@ _CONVERSION(`GRegex*',`Glib::RefPtr<const Regex>',`Glib::wrap($3)')
 
 dnl TimeVal
 _CONVERSION(`const TimeVal&',`const GTimeVal*',`&($3)')
+_CONVERSION(`TimeVal&',`GTimeVal*',`&($3)')
 
 dnl TimeZone
 _CONVERSION(`GTimeZone*',`Glib::RefPtr<TimeZone>',`Glib::wrap($3)')



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