1 // SList.cs - GSList class wrapper implementation
2 //
3 // Authors: Mike Kestner <mkestner@speakeasy.net>
4 //
5 // Copyright (c) 2002 Mike Kestner
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of version 2 of the Lesser GNU General
9 // Public License as published by the Free Software Foundation.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this program; if not, write to the
18 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 // Boston, MA 02111-1307, USA.
20 
21 
22 namespace GLib {
23 
24 	using System;
25 	using System.Runtime.InteropServices;
26 
27 	public class SList : ListBase {
28 
29 		[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
g_slist_copy(IntPtr l)30 		static extern IntPtr g_slist_copy (IntPtr l);
31 
Clone()32 		public override object Clone ()
33 		{
34 			return new SList (g_slist_copy (Handle));
35 		}
36 
37 		[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
g_slist_length(IntPtr l)38 		static extern int g_slist_length (IntPtr l);
39 
Length(IntPtr list)40 		internal override int Length (IntPtr list)
41 		{
42 			return g_slist_length (list);
43 		}
44 
45 		[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
g_slist_free(IntPtr l)46 		static extern void g_slist_free(IntPtr l);
47 
Free(IntPtr list)48 		internal override void Free (IntPtr list)
49 		{
50 			if (list != IntPtr.Zero)
51 				g_slist_free (list);
52 		}
53 
54 		[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
g_slist_append(IntPtr l, IntPtr raw)55 		static extern IntPtr g_slist_append (IntPtr l, IntPtr raw);
56 
Append(IntPtr list, IntPtr raw)57 		internal override IntPtr Append (IntPtr list, IntPtr raw)
58 		{
59 			return g_slist_append (list, raw);
60 		}
61 
62 		[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
g_slist_prepend(IntPtr l, IntPtr raw)63 		static extern IntPtr g_slist_prepend (IntPtr l, IntPtr raw);
64 
Prepend(IntPtr list, IntPtr raw)65 		internal override IntPtr Prepend (IntPtr list, IntPtr raw)
66 		{
67 			return g_slist_prepend (list, raw);
68 		}
69 
70 
71 		[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
g_slist_nth_data(IntPtr l, uint n)72 	        static extern IntPtr g_slist_nth_data (IntPtr l, uint n);
73 
NthData(uint n)74 		internal override IntPtr NthData (uint n)
75 		{
76 			return g_slist_nth_data (Handle, n);
77 		}
78 
SList(IntPtr raw)79 		public SList (IntPtr raw) : this (raw, null) {}
80 
SList(System.Type element_type)81 		public SList (System.Type element_type) : this (IntPtr.Zero, element_type) {}
82 
SList(IntPtr raw, System.Type element_type)83 		public SList (IntPtr raw, System.Type element_type) : this (raw, element_type, false, false) {}
84 
SList(IntPtr raw, System.Type element_type, bool owned, bool elements_owned)85 		public SList (IntPtr raw, System.Type element_type, bool owned, bool elements_owned) : base (raw, element_type, false, false) {}
86 
SList(object[] members, System.Type element_type, bool owned, bool elements_owned)87 		public SList (object[] members, System.Type element_type, bool owned, bool elements_owned) : this (IntPtr.Zero, element_type, owned, elements_owned)
88 		{
89 			foreach (object o in members)
90 				Append (o);
91 		}
92 
SList(Array members, System.Type element_type, bool owned, bool elements_owned)93 		public SList (Array members, System.Type element_type, bool owned, bool elements_owned) : this (IntPtr.Zero, element_type, owned, elements_owned)
94 		{
95 			foreach (object o in members)
96 				Append (o);
97 		}
98 	}
99 }
100