// GtkSharp.Boxed.cs - Base class for deriving marshallable structures. // // Author: Mike Kestner // // (c) 2001-2002 Mike Kestner namespace GtkSharp { using System; using System.Runtime.InteropServices; /// /// Boxed Class /// /// /// /// An abstract base class to derive structures and marshal them. /// public abstract class Boxed { IntPtr _raw; // Destructor is required since we are allocating unmanaged // heap resources. ~Boxed () { Marshal.FreeHGlobal (_raw); } /// /// Raw Property /// /// /// /// Gets a marshallable IntPtr. /// public IntPtr Raw { get { if (_raw == IntPtr.Zero) { // FIXME: Ugly hack. _raw = Marshal.AllocHGlobal (128); Marshal.StructureToPtr (this, _raw, true); } return _raw; } } /// /// GetBoxed Shared Method /// /// /// /// Gets a managed class representing a raw ref. /// public static Boxed GetBoxed (IntPtr raw) { // FIXME: Use the type manager to box the raw ref. return null; } } }