f-spot r4658 - in trunk/GKeyFile: . generated



Author: sdelcroix
Date: Tue Dec  9 10:16:13 2008
New Revision: 4658
URL: http://svn.gnome.org/viewvc/f-spot?rev=4658&view=rev

Log:
GetIntegerList

Modified:
   trunk/GKeyFile/GKeyFile.custom
   trunk/GKeyFile/Makefile.am
   trunk/GKeyFile/generated/GKeyFile.cs
   trunk/GKeyFile/sample.cs

Modified: trunk/GKeyFile/GKeyFile.custom
==============================================================================
--- trunk/GKeyFile/GKeyFile.custom	(original)
+++ trunk/GKeyFile/GKeyFile.custom	Tue Dec  9 10:16:13 2008
@@ -83,23 +83,26 @@
 //		return ret;
 //	}
 //
-//	[DllImport("libglib-2.0.dll")]
-//	static extern unsafe int g_key_file_get_integer_list(IntPtr raw, IntPtr group_name, IntPtr key, out UIntPtr length, out IntPtr error);
-//
-//	public unsafe int GetIntegerList(string group_name, string key, out ulong length) {
-//		IntPtr native_group_name = GLib.Marshaller.StringToPtrGStrdup (group_name);
-//		IntPtr native_key = GLib.Marshaller.StringToPtrGStrdup (key);
-//		UIntPtr native_length;
-//		IntPtr error = IntPtr.Zero;
-//		int raw_ret = g_key_file_get_integer_list(Handle, native_group_name, native_key, out native_length, out error);
-//		int ret = raw_ret;
-//		GLib.Marshaller.Free (native_group_name);
-//		GLib.Marshaller.Free (native_key);
-//		length = (ulong) native_length;
-//		if (error != IntPtr.Zero) throw new GLib.GException (error);
-//		return ret;
-//	}
-//
+	[DllImport("libglib-2.0.dll")]
+	static extern unsafe IntPtr g_key_file_get_integer_list(IntPtr raw, IntPtr group_name, IntPtr key, out UIntPtr length, out IntPtr error);
+
+	public unsafe int[] GetIntegerList(string group_name, string key) {
+		IntPtr native_group_name = GLib.Marshaller.StringToPtrGStrdup (group_name);
+		IntPtr native_key = GLib.Marshaller.StringToPtrGStrdup (key);
+		UIntPtr native_length;
+		IntPtr error = IntPtr.Zero;
+		IntPtr raw_ret = g_key_file_get_integer_list(Handle, native_group_name, native_key, out native_length, out error);
+		ulong length = (ulong) native_length;
+		int[] ret = new int[(int)length];
+		GLib.Marshaller.Free (native_group_name);
+		GLib.Marshaller.Free (native_key);
+		for (int i=0; i < (int)length; i++)
+			ret[i] = Marshal.ReadInt32 (raw_ret, i * Marshal.SizeOf(typeof(Int32)));
+
+		if (error != IntPtr.Zero) throw new GLib.GException (error);
+		return ret;
+	}
+
 //	[DllImport("libglib-2.0.dll")]
 //	static extern unsafe double g_key_file_get_double_list(IntPtr raw, IntPtr group_name, IntPtr key, out UIntPtr length, out IntPtr error);
 //

Modified: trunk/GKeyFile/Makefile.am
==============================================================================
--- trunk/GKeyFile/Makefile.am	(original)
+++ trunk/GKeyFile/Makefile.am	Tue Dec  9 10:16:13 2008
@@ -1,5 +1,7 @@
 all: gkeyfile-sharp.dll
 
+CSFLAGS=-g
+
 gkeyfile-api.raw: gkeyfile-sharp-sources.xml
 	gapi2-parser gkeyfile-sharp-sources.xml
 
@@ -12,7 +14,7 @@
 	touch $@
 
 gkeyfile-sharp.dll: .generated_timestamp $(SOURCES) $(CUSTOMS)
-	gmcs -unsafe -pkg:glib-sharp-2.0 -target:library -out:$@ $(srcdir)/generated/*.cs $(SOURCES)
+	gmcs -unsafe $(CSFLAGS) -pkg:glib-sharp-2.0 -target:library -out:$@ $(srcdir)/generated/*.cs $(SOURCES)
 
 CUSTOMS =				\
 	$(srcdir)/GKeyFile.custom

Modified: trunk/GKeyFile/generated/GKeyFile.cs
==============================================================================
--- trunk/GKeyFile/generated/GKeyFile.cs	(original)
+++ trunk/GKeyFile/generated/GKeyFile.cs	Tue Dec  9 10:16:13 2008
@@ -614,23 +614,26 @@
 //		return ret;
 //	}
 //
-//	[DllImport("libglib-2.0.dll")]
-//	static extern unsafe int g_key_file_get_integer_list(IntPtr raw, IntPtr group_name, IntPtr key, out UIntPtr length, out IntPtr error);
-//
-//	public unsafe int GetIntegerList(string group_name, string key, out ulong length) {
-//		IntPtr native_group_name = GLib.Marshaller.StringToPtrGStrdup (group_name);
-//		IntPtr native_key = GLib.Marshaller.StringToPtrGStrdup (key);
-//		UIntPtr native_length;
-//		IntPtr error = IntPtr.Zero;
-//		int raw_ret = g_key_file_get_integer_list(Handle, native_group_name, native_key, out native_length, out error);
-//		int ret = raw_ret;
-//		GLib.Marshaller.Free (native_group_name);
-//		GLib.Marshaller.Free (native_key);
-//		length = (ulong) native_length;
-//		if (error != IntPtr.Zero) throw new GLib.GException (error);
-//		return ret;
-//	}
-//
+	[DllImport("libglib-2.0.dll")]
+	static extern unsafe IntPtr g_key_file_get_integer_list(IntPtr raw, IntPtr group_name, IntPtr key, out UIntPtr length, out IntPtr error);
+
+	public unsafe int[] GetIntegerList(string group_name, string key) {
+		IntPtr native_group_name = GLib.Marshaller.StringToPtrGStrdup (group_name);
+		IntPtr native_key = GLib.Marshaller.StringToPtrGStrdup (key);
+		UIntPtr native_length;
+		IntPtr error = IntPtr.Zero;
+		IntPtr raw_ret = g_key_file_get_integer_list(Handle, native_group_name, native_key, out native_length, out error);
+		ulong length = (ulong) native_length;
+		int[] ret = new int[(int)length];
+		GLib.Marshaller.Free (native_group_name);
+		GLib.Marshaller.Free (native_key);
+		for (int i=0; i < (int)length; i++)
+			ret[i] = Marshal.ReadInt32 (raw_ret, i * Marshal.SizeOf(typeof(Int32)));
+
+		if (error != IntPtr.Zero) throw new GLib.GException (error);
+		return ret;
+	}
+
 //	[DllImport("libglib-2.0.dll")]
 //	static extern unsafe double g_key_file_get_double_list(IntPtr raw, IntPtr group_name, IntPtr key, out UIntPtr length, out IntPtr error);
 //

Modified: trunk/GKeyFile/sample.cs
==============================================================================
--- trunk/GKeyFile/sample.cs	(original)
+++ trunk/GKeyFile/sample.cs	Tue Dec  9 10:16:13 2008
@@ -71,6 +71,9 @@
 		foreach (string val in key_file.GetStringList ("Lists", "sList"))
 			Console.WriteLine (val);
 
+		foreach (int i in key_file.GetIntegerList ("Lists", "ints"))
+			Console.WriteLine (i);
+
 		key_file.Save ("mysamplefile2.ini");
 
 		key_file = new GKeyFile ("mysamplefile.ini");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]