File: TimeVal.cs

package info (click to toggle)
gtk-sharp3 2.99.3-4.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 25,488 kB
  • sloc: xml: 308,885; cs: 38,796; sh: 11,336; perl: 1,295; makefile: 1,099; ansic: 903
file content (105 lines) | stat: -rw-r--r-- 3,343 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace GLib {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;

#region Autogenerated code
	[StructLayout(LayoutKind.Sequential)]
	public partial struct TimeVal : IEquatable<TimeVal> {

		private IntPtr tv_sec;
		public long TvSec {
			get {
				return (long) tv_sec;
			}
			set {
				tv_sec = new IntPtr (value);
			}
		}
		private IntPtr tv_usec;
		public long TvUsec {
			get {
				return (long) tv_usec;
			}
			set {
				tv_usec = new IntPtr (value);
			}
		}

		public static GLib.TimeVal Zero = new GLib.TimeVal ();

		public static GLib.TimeVal New(IntPtr raw) {
			if (raw == IntPtr.Zero)
				return GLib.TimeVal.Zero;
			return (GLib.TimeVal) Marshal.PtrToStructure (raw, typeof (GLib.TimeVal));
		}

		[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
		static extern void g_time_val_add(IntPtr raw, IntPtr microseconds);

		public void Add(long microseconds) {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			g_time_val_add(this_as_native, new IntPtr (microseconds));
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
		}

		[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr g_time_val_to_iso8601(IntPtr raw);

		public string ToIso8601() {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			IntPtr raw_ret = g_time_val_to_iso8601(this_as_native);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
			return ret;
		}

		[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
		static extern bool g_time_val_from_iso8601(IntPtr iso_date, IntPtr time_);

		public static bool FromIso8601(string iso_date, out GLib.TimeVal time_) {
			IntPtr native_iso_date = GLib.Marshaller.StringToPtrGStrdup (iso_date);
			IntPtr native_time_ = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (GLib.TimeVal)));
			bool raw_ret = g_time_val_from_iso8601(native_iso_date, native_time_);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_iso_date);
			time_ = GLib.TimeVal.New (native_time_);
			Marshal.FreeHGlobal (native_time_);
			return ret;
		}

		static void ReadNative (IntPtr native, ref GLib.TimeVal target)
		{
			target = New (native);
		}

		public bool Equals (TimeVal other)
		{
			return true && TvSec.Equals (other.TvSec) && TvUsec.Equals (other.TvUsec);
		}

		public override bool Equals (object other)
		{
			return other is TimeVal && Equals ((TimeVal) other);
		}

		public override int GetHashCode ()
		{
			return this.GetType().FullName.GetHashCode() ^ TvSec.GetHashCode () ^ TvUsec.GetHashCode ();
		}

		private static GLib.GType GType {
			get { return GLib.GType.Pointer; }
		}
#endregion
	}
}