diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2019-08-12 18:53:23 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2019-08-12 18:53:23 +0200 |
commit | 41fb5b7db3c0b7e679ceebeefbc6e0b1285debb1 (patch) | |
tree | 70724bba95aa44634f6e67f0ef10168c5a595019 | |
parent | 8a251c026131781c8d564ca91b756cba162c8b9f (diff) | |
download | glibmm-41fb5b7db3c0b7e679ceebeefbc6e0b1285debb1.tar.gz |
Disable warnings from deprecated GTimeVal and GTime
GTimeVal and GTime have been deprecated in glib.
They can't be deprecated in the stable glibmm-2-60 branch now.
This patch makes it possible to build glibmm-2.60.x against the newest glib.
This affects Glib::TimeVal, Glib::Date, Glib::DateTime and Gio::FileInfo.
-rw-r--r-- | gio/src/fileinfo.ccg | 7 | ||||
-rw-r--r-- | gio/src/fileinfo.hg | 12 | ||||
-rw-r--r-- | glib/glibmm/timeval.cc | 5 | ||||
-rw-r--r-- | glib/glibmm/timeval.h | 7 | ||||
-rw-r--r-- | glib/src/date.ccg | 6 | ||||
-rw-r--r-- | glib/src/date.hg | 12 | ||||
-rw-r--r-- | glib/src/datetime.ccg | 21 | ||||
-rw-r--r-- | glib/src/datetime.hg | 21 |
8 files changed, 79 insertions, 12 deletions
diff --git a/gio/src/fileinfo.ccg b/gio/src/fileinfo.ccg index d18d926a..d5862950 100644 --- a/gio/src/fileinfo.ccg +++ b/gio/src/fileinfo.ccg @@ -27,6 +27,7 @@ FileAttributeMatcher::create(const std::string& attributes) return Glib::wrap(g_file_attribute_matcher_new(attributes.c_str())); } +G_GNUC_BEGIN_IGNORE_DEPRECATIONS Glib::TimeVal FileInfo::modification_time() const { @@ -35,4 +36,10 @@ FileInfo::modification_time() const return result; } +void FileInfo::set_modification_time(const Glib::TimeVal& mtime) +{ + g_file_info_set_modification_time(gobj(), const_cast<GTimeVal*>(static_cast<const GTimeVal*>(&mtime))); +} +G_GNUC_END_IGNORE_DEPRECATIONS + } // namespace Gio diff --git a/gio/src/fileinfo.hg b/gio/src/fileinfo.hg index 80399c3e..9fb95946 100644 --- a/gio/src/fileinfo.hg +++ b/gio/src/fileinfo.hg @@ -181,8 +181,11 @@ public: _WRAP_METHOD(goffset get_size() const, g_file_info_get_size) + //TODO: In the next minor stable release (glibmm 2.62.0?), deprecate modification_time() + // and add get_modification_date_time(). Glib::TimeVal modification_time() const; _IGNORE(g_file_info_get_modification_time) + //_WRAP_METHOD(Glib::DateTime get_modification_date_time() const, g_file_info_get_modification_date_time) _WRAP_METHOD(std::string get_symlink_target() const, g_file_info_get_symlink_target) @@ -215,7 +218,14 @@ public: _WRAP_METHOD(void set_size(goffset size), g_file_info_set_size) - _WRAP_METHOD(void set_modification_time(const Glib::TimeVal& mtime), g_file_info_set_modification_time) + //TODO: In the next minor stable release (glibmm 2.62.0?), deprecate set_modification_time() + // and add set_modification_date_time(). + _WRAP_METHOD_DOCS_ONLY(g_file_info_set_modification_time) + void set_modification_time(const Glib::TimeVal& mtime); + //_WRAP_METHOD(void set_modification_time(const Glib::TimeVal& mtime), g_file_info_set_modification_time, + // deprecated "Use set_modification_date_time() instead.") + //_WRAP_METHOD(void set_modification_date_time(const Glib::DateTime& mtime), g_file_info_set_modification_date_time) + _WRAP_METHOD(void set_symlink_target(const std::string& symlink_target), g_file_info_set_symlink_target) _WRAP_METHOD(void set_sort_order(gint32 sort_order), g_file_info_set_sort_order) }; diff --git a/glib/glibmm/timeval.cc b/glib/glibmm/timeval.cc index c8bb9a91..dcd39bab 100644 --- a/glib/glibmm/timeval.cc +++ b/glib/glibmm/timeval.cc @@ -20,7 +20,7 @@ namespace Glib { - +G_GNUC_BEGIN_IGNORE_DEPRECATIONS void TimeVal::assign_current_time() { @@ -32,6 +32,7 @@ TimeVal::assign_from_iso8601(const Glib::ustring& iso_date) { return g_time_val_from_iso8601(iso_date.c_str(), this); } +G_GNUC_END_IGNORE_DEPRECATIONS void TimeVal::add(const TimeVal& rhs) @@ -110,6 +111,7 @@ TimeVal::subtract_milliseconds(long milliseconds) add_milliseconds(-1 * milliseconds); } +G_GNUC_BEGIN_IGNORE_DEPRECATIONS void TimeVal::add_microseconds(long microseconds) { @@ -134,5 +136,6 @@ TimeVal::as_iso8601() const } return Glib::ustring(); } +G_GNUC_END_IGNORE_DEPRECATIONS } // namespace Glib diff --git a/glib/glibmm/timeval.h b/glib/glibmm/timeval.h index e67a9e0b..f13164c6 100644 --- a/glib/glibmm/timeval.h +++ b/glib/glibmm/timeval.h @@ -25,6 +25,12 @@ namespace Glib { +//TODO: Deprecate TimeVal in the next minor stable release (glibmm 2.62.0?). +// GTimeVal is deprecated. +// Note: Before TimeVal is deprecated, check what will happen with +// Gdk::PixbufAnimationIter::advance(const Glib::TimeVal& current_time), +// especially if GLIBMM_DISABLE_DEPRECATED is defined but GDKMM_DISABLE_DEPRECATED is not. +G_GNUC_BEGIN_IGNORE_DEPRECATIONS /** Glib::TimeVal is a wrapper around the glib structure GTimeVal. * The glib structure GTimeVal itself is equivalent to struct timeval, * which is returned by the gettimeofday() UNIX call. Additionally @@ -234,6 +240,7 @@ operator>=(const TimeVal& lhs, const TimeVal& rhs) { return ((lhs.tv_sec > rhs.tv_sec) || (lhs.tv_sec == rhs.tv_sec && lhs.tv_usec >= rhs.tv_usec)); } +G_GNUC_END_IGNORE_DEPRECATIONS } // namespace Glib diff --git a/glib/src/date.ccg b/glib/src/date.ccg index 7e62718c..dc0cb37c 100644 --- a/glib/src/date.ccg +++ b/glib/src/date.ccg @@ -76,7 +76,7 @@ Date::set_parse(const Glib::ustring& str) } _DEPRECATE_IFDEF_START - +G_GNUC_BEGIN_IGNORE_DEPRECATIONS // Avoid a build problem in the case that std::time_t is equivalent to gint32 (GTime is also gint32) // That would make the set_time() method overload impossible. #ifdef GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 @@ -90,7 +90,7 @@ Date::set_time(GTime time) g_date_set_time_t(&gobject_, static_cast<time_t>(time)); } #endif // GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 - +G_GNUC_END_IGNORE_DEPRECATIONS _DEPRECATE_IFDEF_END void @@ -106,11 +106,13 @@ Date::set_time_current() g_date_set_time_t(&gobject_, time(nullptr)); } +G_GNUC_BEGIN_IGNORE_DEPRECATIONS void Date::set_time(const GTimeVal& timeval) { g_date_set_time_val(&gobject_, const_cast<GTimeVal*>(&timeval)); } +G_GNUC_END_IGNORE_DEPRECATIONS void Date::set_month(Date::Month month) diff --git a/glib/src/date.hg b/glib/src/date.hg index 4c29fb59..8b15ccb7 100644 --- a/glib/src/date.hg +++ b/glib/src/date.hg @@ -108,9 +108,8 @@ public: */ void set_parse (const Glib::ustring& str); - _DEPRECATE_IFDEF_START - + G_GNUC_BEGIN_IGNORE_DEPRECATIONS //Avoid a build problem in the case that std::time_t is equivalent to gint32 (GTime is also gint32) //That would make the set_time() method overload impossible. #ifdef GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 @@ -118,14 +117,13 @@ public: * * @param time GTime value to set. * - * @deprecated Please use set_time(std::time_t) or set_time(const GTimeVal&). + * @deprecated Please use set_time(std::time_t) instead. */ void set_time(GTime time); #endif //GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 - + G_GNUC_END_IGNORE_DEPRECATIONS _DEPRECATE_IFDEF_END - /** Sets the value of a date from a <type>std::time_t</type> value. * * @param timet std::time_t value to set @@ -136,6 +134,9 @@ public: */ void set_time(std::time_t timet); + //TODO: Deprecate set_time() in the next minor stable release (glibmm 2.62.0?). + // GTimeVal is deprecated. + G_GNUC_BEGIN_IGNORE_DEPRECATIONS /** Sets the value of a date from a GTimeVal value. Note that the * tv_usec member is ignored, because Glib::Date can't make use of the * additional precision. @@ -147,6 +148,7 @@ public: * Since: 2.10 */ void set_time(const GTimeVal& timeval); + G_GNUC_END_IGNORE_DEPRECATIONS /** Set this Glib::Date to the current time. */ diff --git a/glib/src/datetime.ccg b/glib/src/datetime.ccg index 3295b3e4..14b800ae 100644 --- a/glib/src/datetime.ccg +++ b/glib/src/datetime.ccg @@ -17,3 +17,24 @@ #include <glibmm/utility.h> #include <glibmm/timeval.h> #include <glibmm/wrap.h> + +namespace Glib +{ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +DateTime DateTime::create_now_local(const TimeVal& tv) +{ + return Glib::wrap(g_date_time_new_from_timeval_local(&(tv))); +} + +DateTime DateTime::create_now_utc(const TimeVal& tv) +{ + return Glib::wrap(g_date_time_new_from_timeval_utc(&(tv))); +} + +bool DateTime::to_timeval(TimeVal& tv) const +{ + return g_date_time_to_timeval(const_cast<GDateTime*>(gobj()), &(tv)); +} +G_GNUC_END_IGNORE_DEPRECATIONS + +} // namespace Glib diff --git a/glib/src/datetime.hg b/glib/src/datetime.hg index 70167046..730fcab6 100644 --- a/glib/src/datetime.hg +++ b/glib/src/datetime.hg @@ -74,8 +74,17 @@ public: _WRAP_METHOD(static DateTime create_now_local(gint64 t), g_date_time_new_from_unix_local) _WRAP_METHOD(static DateTime create_now_utc(gint64 t), g_date_time_new_from_unix_utc) - _WRAP_METHOD(static DateTime create_now_local(const TimeVal& tv), g_date_time_new_from_timeval_local) - _WRAP_METHOD(static DateTime create_now_utc(const TimeVal& tv), g_date_time_new_from_timeval_utc) + _WRAP_METHOD_DOCS_ONLY(g_date_time_new_from_timeval_local) + static DateTime create_now_local(const TimeVal& tv); +//TODO: Deprecate in the next minor stable release (glibmm 2.62.0?). +// _WRAP_METHOD(static DateTime create_now_local(const TimeVal& tv), g_date_time_new_from_timeval_local, +// deprecated "Use create_now_local(gint64 t) instead.") + + _WRAP_METHOD_DOCS_ONLY(g_date_time_new_from_timeval_utc) + static DateTime create_now_utc(const TimeVal& tv); +//TODO: Deprecate in the next minor stable release (glibmm 2.62.0?). +// _WRAP_METHOD(static DateTime create_now_utc(const TimeVal& tv), g_date_time_new_from_timeval_utc, +// deprecated "Use create_now_utc(gint64 t) instead.") _WRAP_METHOD(static DateTime create(const TimeZone& tz, int year, int month, int day, int hour, int minute, double seconds), g_date_time_new) _WRAP_METHOD(static DateTime create_local(int year, int month, int day, int hour, int minute, double seconds), g_date_time_new_local) @@ -142,7 +151,13 @@ public: _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_DOCS_ONLY(g_date_time_to_timeval) + bool to_timeval(TimeVal& tv) const; +//TODO: Deprecate in the next minor stable release (glibmm 2.62.0?). +// _WRAP_METHOD(bool to_timeval(TimeVal& tv) const, g_date_time_to_timeval, +// deprecated "Use to_unix() instead.") + _WRAP_METHOD(TimeSpan get_utc_offset() const, g_date_time_get_utc_offset) #m4 _CONVERSION(`GTimeZone*',`TimeZone',`Glib::wrap($3, true)') _WRAP_METHOD(TimeZone get_timezone() const, g_date_time_get_timezone, newin "2,60") |