From 9b85d88450bd287c7ae4e69cc297f0b76d13b80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 21 May 2009 21:37:44 +0200 Subject: [PATCH] As Gst.Date is a boxed type we need to implement IWrapper and a New method This fixes boxing/deboxing from GLib.Value --- gstreamer-sharp/Value.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gstreamer-sharp/Value.cs b/gstreamer-sharp/Value.cs index 9d44328250..4c2c982bdd 100644 --- a/gstreamer-sharp/Value.cs +++ b/gstreamer-sharp/Value.cs @@ -381,27 +381,45 @@ namespace Gst { } - public struct Date { + public class Date : IWrapper { public DateTime Val; + private IntPtr handle; + public IntPtr Handle { + get { + return handle; + } + } + public static GLib.GType GType { get { return new GType (gst_date_get_type ()); } } + ~Date () { + g_date_free (handle); + } + public Date (DateTime date) { this.Val = date; + handle = g_date_new_dmy ( (byte) Val.Day, (int) Val.Month, (ushort) Val.Year); } public Date (int day, int month, int year) { this.Val = new DateTime (year, month, day); + handle = g_date_new_dmy ( (byte) Val.Day, (int) Val.Month, (ushort) Val.Year); } public Date (GLib.Value val) { IntPtr date = gst_value_get_date (ref val); this.Val = new DateTime (g_date_get_year (date), g_date_get_month (date), g_date_get_day (date)); + handle = g_date_new_dmy ( (byte) Val.Day, (int) Val.Month, (ushort) Val.Year); + } + + public static Date New (IntPtr date) { + return new Date (g_date_get_day (date), g_date_get_month (date), g_date_get_year (date)); } public void SetGValue (ref GLib.Value val) { @@ -436,6 +454,8 @@ namespace Gst { private static extern ushort g_date_get_year (IntPtr date); [DllImport ("libglib-2.0-0.dll") ] private static extern IntPtr g_date_new_dmy (byte day, int month, ushort year); + [DllImport ("libglib-2.0-0.dll") ] + private static extern void g_date_free (IntPtr date); [DllImport ("gstreamer-0.10.dll") ] private static extern IntPtr gst_date_get_type ();