Ryujinx-GtkSharp/glib/Marshaller.cs
Miguel de Icaza f1e095a87b 2003-11-27 Miguel de Icaza <miguel@ximian.com>
* glib/Log.cs: Make LogLevelFlags CLS compliant.

	* glib/SignalCallback.cs: Set the constructor protection level to
	protected, since it can not be instantiate.d

	* glib/Marshaller.cs: Do not allow instances of this class as it
	only exposes static methods.

	* glib/Source.cs, glib/FileUtils.cs, glib/Timeout.cs,
	glib/Thread.cs, glib/Markup.cs, glib/TypeConverter.cs: Ditto.

svn path=/trunk/gtk-sharp/; revision=20573
2003-11-28 05:29:34 +00:00

58 lines
1.2 KiB
C#

// GLibSharp.Marshaller.cs : Marshalling utils
//
// Author: Rachel Hestilow <rachel@nullenvoid.com>
//
// (c) 2002, 2003 Rachel Hestilow
namespace GLibSharp {
using System;
using System.Runtime.InteropServices;
/// <summary>
/// Marshalling utilities
/// </summary>
///
/// <remarks>
/// Utility class for internal wrapper use
/// </remarks>
public class Marshaller {
//
// Do not allow instances of this
//
private Marshaller () {}
[DllImport("libglib-2.0-0.dll")]
static extern void g_free (IntPtr mem);
public static string PtrToStringGFree (IntPtr ptr) {
string ret = Marshal.PtrToStringAnsi (ptr);
g_free (ptr);
return ret;
}
[DllImport("libglib-2.0-0.dll")]
static extern void g_strfreev (IntPtr mem);
public static string[] PtrToStringGFree (IntPtr[] ptrs) {
// The last pointer is a null terminator.
string[] ret = new string[ptrs.Length - 1];
for (int i = 0; i < ret.Length; i++) {
ret[i] = Marshal.PtrToStringAnsi (ptrs[i]);
g_free (ptrs[i]);
}
return ret;
}
[DllImport("libglib-2.0-0.dll")]
static extern IntPtr g_strdup (string str);
public static IntPtr StringToPtrGStrdup (string str) {
return g_strdup (str);
}
}
}