[glibmm/glibmm-2-62] Glib::Checksum, DateTime, TimeZone: Add Glib::Value<> specializations
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/glibmm-2-62] Glib::Checksum, DateTime, TimeZone: Add Glib::Value<> specializations
- Date: Tue, 17 Sep 2019 13:12:33 +0000 (UTC)
commit 6dd340c95c18ac2c6164d5759ab04bc562b6021b
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Tue Sep 17 15:09:00 2019 +0200
Glib::Checksum, DateTime, TimeZone: Add Glib::Value<> specializations
With Glib::Value<> specializations these classes can be used in
Glib::Value<> and _WRAP_PROPERTY.
See https://mail.gnome.org/archives/gtkmm-list/2019-April/msg00012.html
glib/src/checksum.ccg | 16 ++++++++++++++++
glib/src/checksum.hg | 19 +++++++++++++++++--
glib/src/datetime.ccg | 16 ++++++++++++++++
glib/src/datetime.hg | 19 +++++++++++++++++--
glib/src/timezone.ccg | 16 ++++++++++++++++
glib/src/timezone.hg | 19 +++++++++++++++++--
6 files changed, 99 insertions(+), 6 deletions(-)
---
diff --git a/glib/src/checksum.ccg b/glib/src/checksum.ccg
index f38e2fc9..f83810c6 100644
--- a/glib/src/checksum.ccg
+++ b/glib/src/checksum.ccg
@@ -48,4 +48,20 @@ Checksum::update(const std::string& data)
g_checksum_update(gobj(), (const guchar*)data.c_str(), data.size());
}
+// Glib::Value<Glib::Checksum>
+GType Value<Checksum>::value_type()
+{
+ return G_TYPE_CHECKSUM;
+}
+
+void Value<Checksum>::set(const CppType& data)
+{
+ set_boxed(data.gobj());
+}
+
+Value<Checksum>::CppType Value<Checksum>::get() const
+{
+ return Glib::wrap(static_cast<CType>(get_boxed()), true);
+}
+
} // Glib namespace
diff --git a/glib/src/checksum.hg b/glib/src/checksum.hg
index d7b30c4e..56a6b8cc 100644
--- a/glib/src/checksum.hg
+++ b/glib/src/checksum.hg
@@ -16,6 +16,7 @@
_DEFS(glibmm,glib)
+#include <glibmm/value.h>
#include <glib.h>
#include <string>
@@ -23,8 +24,6 @@ _DEFS(glibmm,glib)
extern "C" { typedef struct _GChecksum GChecksum; }
#endif
-//TODO: When we can add API, add a Glib::Value specialization, similar to the one in
-// https://mail.gnome.org/archives/gtkmm-list/2019-April/msg00012.html
//TODO: When we can change API, make Checksum a _CLASS_BOXEDTYPE.
namespace Glib
@@ -101,5 +100,21 @@ public:
static gssize get_length(ChecksumType checksum_type);
};
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+// This is needed so Glib::Checksum can be used with Glib::Value and _WRAP_PROPERTY.
+template <>
+class Value<Glib::Checksum> : public ValueBase_Boxed
+{
+public:
+ using CppType = Glib::Checksum;
+ using CType = GChecksum*;
+
+ static GType value_type();
+
+ void set(const CppType& data);
+ CppType get() const;
+};
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
} //namespace Glib
diff --git a/glib/src/datetime.ccg b/glib/src/datetime.ccg
index 738d4f8f..9207fefa 100644
--- a/glib/src/datetime.ccg
+++ b/glib/src/datetime.ccg
@@ -26,4 +26,20 @@ DateTime::operator bool() const
return (gobject_ != nullptr);
}
+// Glib::Value<Glib::DateTime>
+GType Value<DateTime>::value_type()
+{
+ return G_TYPE_DATE_TIME;
+}
+
+void Value<DateTime>::set(const CppType& data)
+{
+ set_boxed(data.gobj());
+}
+
+Value<DateTime>::CppType Value<DateTime>::get() const
+{
+ return Glib::wrap(static_cast<CType>(get_boxed()), true);
+}
+
} // namespace Glib
diff --git a/glib/src/datetime.hg b/glib/src/datetime.hg
index 0512d4a3..280df71a 100644
--- a/glib/src/datetime.hg
+++ b/glib/src/datetime.hg
@@ -20,14 +20,13 @@ _DEFS(glibmm,glib)
#include <glibmm/refptr.h>
#include <glibmm/timezone.h>
#include <glibmm/ustring.h>
+#include <glibmm/value.h>
#include <glib.h>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GDateTime GDateTime;
#endif
-//TODO: When we can add API, add a Glib::Value specialization, similar to the one in
-// https://mail.gnome.org/archives/gtkmm-list/2019-April/msg00012.html
//TODO: When we can change API, make DateTime a _CLASS_BOXEDTYPE.
namespace Glib
@@ -171,4 +170,20 @@ public:
_WRAP_METHOD(Glib::ustring format_iso8601() const, g_date_time_format_iso8601)
};
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+// This is needed so Glib::DateTime can be used with Glib::Value and _WRAP_PROPERTY.
+template <>
+class Value<Glib::DateTime> : public ValueBase_Boxed
+{
+public:
+ using CppType = Glib::DateTime;
+ using CType = GDateTime*;
+
+ static GType value_type();
+
+ void set(const CppType& data);
+ CppType get() const;
+};
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
} // namespace Glib
diff --git a/glib/src/timezone.ccg b/glib/src/timezone.ccg
index 7faf86e2..42a5ae1c 100644
--- a/glib/src/timezone.ccg
+++ b/glib/src/timezone.ccg
@@ -19,4 +19,20 @@
namespace Glib
{
+// Glib::Value<Glib::TimeZone>
+GType Value<TimeZone>::value_type()
+{
+ return G_TYPE_TIME_ZONE;
+}
+
+void Value<TimeZone>::set(const CppType& data)
+{
+ set_boxed(data.gobj());
+}
+
+Value<TimeZone>::CppType Value<TimeZone>::get() const
+{
+ return Glib::wrap(static_cast<CType>(get_boxed()), true);
+}
+
} // namespace Glib
diff --git a/glib/src/timezone.hg b/glib/src/timezone.hg
index 1c2b0b5a..cc6105ad 100644
--- a/glib/src/timezone.hg
+++ b/glib/src/timezone.hg
@@ -19,14 +19,13 @@ _DEFS(glibmm,glib)
#include <glibmmconfig.h>
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
+#include <glibmm/value.h>
#include <glib.h>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GTimeZone GTimeZone;
#endif
-//TODO: When we can add API, add a Glib::Value specialization, similar to the one in
-// https://mail.gnome.org/archives/gtkmm-list/2019-April/msg00012.html
//TODO: When we can change API, make TimeZone a _CLASS_BOXEDTYPE.
namespace Glib
@@ -73,4 +72,20 @@ public:
_WRAP_METHOD(Glib::ustring get_identifier() const, g_time_zone_get_identifier, newin "2,60")
};
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+// This is needed so Glib::TimeZone can be used with Glib::Value and _WRAP_PROPERTY.
+template <>
+class Value<Glib::TimeZone> : public ValueBase_Boxed
+{
+public:
+ using CppType = Glib::TimeZone;
+ using CType = GTimeZone*;
+
+ static GType value_type();
+
+ void set(const CppType& data);
+ CppType get() const;
+};
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
} // namespace Glib
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]