glib: Switch to generic collections in Marshaller and ValueArray

This commit is contained in:
Bertrand Lorentz 2012-11-04 16:43:35 +01:00
parent 6e3e73e2ac
commit df751f87ce
2 changed files with 5 additions and 3 deletions

View File

@ -23,6 +23,7 @@
namespace GLib { namespace GLib {
using System; using System;
using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
public class Marshaller { public class Marshaller {
@ -202,7 +203,7 @@ namespace GLib {
return new string [0]; return new string [0];
int count = 0; int count = 0;
System.Collections.ArrayList result = new System.Collections.ArrayList (); var result = new List<string> ();
IntPtr s = Marshal.ReadIntPtr (null_term_array, count++ * IntPtr.Size); IntPtr s = Marshal.ReadIntPtr (null_term_array, count++ * IntPtr.Size);
while (s != IntPtr.Zero) { while (s != IntPtr.Zero) {
result.Add (Utf8PtrToString (s)); result.Add (Utf8PtrToString (s));
@ -212,7 +213,7 @@ namespace GLib {
if (owned) if (owned)
g_strfreev (null_term_array); g_strfreev (null_term_array);
return (string[]) result.ToArray (typeof(string)); return result.ToArray ();
} }
public static string[] PtrToStringArrayGFree (IntPtr string_array) public static string[] PtrToStringArrayGFree (IntPtr string_array)

View File

@ -23,13 +23,14 @@ namespace GLib {
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
public class ValueArray : IDisposable, ICollection, ICloneable, IWrapper { public class ValueArray : IDisposable, ICollection, ICloneable, IWrapper {
private IntPtr handle = IntPtr.Zero; private IntPtr handle = IntPtr.Zero;
static private ArrayList PendingFrees = new ArrayList (); static private IList<IntPtr> PendingFrees = new List<IntPtr> ();
static private bool idle_queued = false; static private bool idle_queued = false;
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]