using System; using System.Runtime.InteropServices; namespace Math.Gmp.Native { /// /// Represents a pointer to a block of unmanaged memory. /// /// public struct void_ptr { private IntPtr _pointer; internal void_ptr(IntPtr pointer) { _pointer = pointer; } /// /// Gets a from a pointer to a block of unmanaged memory. /// /// A pointer to a block of unmanaged memory. /// A from a pointer to a block of unmanaged memory. public void_ptr FromIntPtr(IntPtr value) { _pointer = value; return this; } /// /// Gets pointer to block of unmanaged memory. /// /// Pointer to block of unmanaged memory. public IntPtr ToIntPtr() { return _pointer; } /// /// Gets a null . /// public static readonly void_ptr Zero = new void_ptr(IntPtr.Zero); /// /// Returns a value indicating whether this instance is equal to a specified object. /// /// An object to compare with this instance. /// True if is an instance of and equals the value of this instance; otherwise, False. public override bool Equals(object obj) { if (!(obj is void_ptr)) return false; return Equals((void_ptr)obj); } /// /// Returns a value indicating whether this instance is equal to a specified value. /// /// A value to compare to this instance. /// True if has the same value as this instance; otherwise, False. public bool Equals(void_ptr other) { return _pointer == other._pointer; } /// /// Returns the hash code for this instance. /// /// A 32-bit signed integer hash code. public override int GetHashCode() { return _pointer.GetHashCode(); } /// /// Gets a value that indicates whether the two argument values are equal. /// /// A value. /// A value. /// True if the two values are equal, and False otherwise. public static bool operator ==(void_ptr value1, void_ptr value2) { return value1.Equals(value2); } /// /// Gets a value that indicates whether the two argument values are different. /// /// A value. /// A value. /// True if the two values are different, and False otherwise. public static bool operator !=(void_ptr value1, void_ptr value2) { return !value1.Equals(value2); } } }