As Gst.Date is a boxed type we need to implement IWrapper and a New method

This fixes boxing/deboxing from GLib.Value
This commit is contained in:
Sebastian Dröge 2009-05-21 21:37:44 +02:00
parent c54dc8ce93
commit 9b85d88450

View file

@ -381,27 +381,45 @@ namespace Gst {
} }
public struct Date { public class Date : IWrapper {
public DateTime Val; public DateTime Val;
private IntPtr handle;
public IntPtr Handle {
get {
return handle;
}
}
public static GLib.GType GType { public static GLib.GType GType {
get { get {
return new GType (gst_date_get_type ()); return new GType (gst_date_get_type ());
} }
} }
~Date () {
g_date_free (handle);
}
public Date (DateTime date) { public Date (DateTime date) {
this.Val = 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) { public Date (int day, int month, int year) {
this.Val = new DateTime (year, month, day); 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) { public Date (GLib.Value val) {
IntPtr date = gst_value_get_date (ref 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)); 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) { public void SetGValue (ref GLib.Value val) {
@ -436,6 +454,8 @@ namespace Gst {
private static extern ushort g_date_get_year (IntPtr date); private static extern ushort g_date_get_year (IntPtr date);
[DllImport ("libglib-2.0-0.dll") ] [DllImport ("libglib-2.0-0.dll") ]
private static extern IntPtr g_date_new_dmy (byte day, int month, ushort year); 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") ] [DllImport ("gstreamer-0.10.dll") ]
private static extern IntPtr gst_date_get_type (); private static extern IntPtr gst_date_get_type ();