// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== namespace System { using System; using System.Globalization; using System.Runtime.CompilerServices; //| [CLSCompliant(false)] [NoCCtor] public struct UIntPtr : IFormattable { unsafe private void* m_value; //| [Intrinsic] public static readonly UIntPtr Zero; //| [Intrinsic] public static readonly UIntPtr MaxValue; //| [Intrinsic] public static readonly int Size; //| [Intrinsic] [NoHeapAllocation] public extern UIntPtr(uint value); [Intrinsic] [NoHeapAllocation] public extern UIntPtr(int value); //| [Intrinsic] [NoHeapAllocation] public extern UIntPtr(ulong value); //| [CLSCompliant(false)] [Intrinsic] [NoHeapAllocation] public extern unsafe UIntPtr(void* value); //| [Inline] public unsafe override bool Equals(Object obj) { if (obj is UIntPtr) { return (m_value == ((UIntPtr)obj).m_value); } else { return false; } } //| [Inline] public unsafe override int GetHashCode() { return (int)m_value & 0x7fffffff; } //| [Intrinsic] [NoHeapAllocation] public extern uint ToUInt32(); //| [Intrinsic] [NoHeapAllocation] public extern ulong ToUInt64(); //| [Inline] public unsafe override String ToString() { if (sizeof(UIntPtr) == 4) { return this.ToUInt32().ToString(); } else { return this.ToUInt64().ToString(); } } [Inline] public unsafe String ToString(String format) { if (sizeof(UIntPtr) == 4) { return this.ToUInt32().ToString(format); } else { return this.ToUInt64().ToString(format); } } //| [CLSCompliant(false)] public static UIntPtr Parse(String s) { return Parse(s, NumberStyles.Integer); } //| [CLSCompliant(false)] public unsafe static UIntPtr Parse(String s, NumberStyles style) { NumberFormatInfo.ValidateParseStyle(style); if (sizeof(UIntPtr) == 4) { return Number.ParseUInt32(s, style); } else { return Number.ParseUInt64(s, style); } } //| [Intrinsic] [NoHeapAllocation] public extern static implicit operator UIntPtr (uint value); //| [Intrinsic] [NoHeapAllocation] public extern static implicit operator UIntPtr (ulong value); #if false [NoHeapAllocation] public static implicit operator UIntPtr (int value) { return (UIntPtr)unchecked((uint)value); } #endif [Intrinsic] [NoHeapAllocation] public extern static explicit operator IntPtr (UIntPtr value); //| [Intrinsic] [NoHeapAllocation] public extern static explicit operator uint (UIntPtr value); //| [Intrinsic] [NoHeapAllocation] public extern static explicit operator ulong (UIntPtr value); //| [CLSCompliant(false)] [Intrinsic] [NoHeapAllocation] public extern static unsafe explicit operator UIntPtr (void* value); //| [CLSCompliant(false)] [Intrinsic] [NoHeapAllocation] public extern static unsafe explicit operator void* (UIntPtr value); //| [Intrinsic] [NoHeapAllocation] public extern static bool operator == (UIntPtr value1, UIntPtr value2); //| [Intrinsic] [NoHeapAllocation] public extern static bool operator != (UIntPtr value1, UIntPtr value2); //| [CLSCompliant(false)] [Intrinsic] [NoHeapAllocation] public extern unsafe void* ToPointer(); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator - (UIntPtr value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator - (UIntPtr value1, uint value2); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator - (UIntPtr value1, int value2); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator -- (UIntPtr value); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator + (UIntPtr value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator + (UIntPtr value1, uint value2); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator + (UIntPtr value1, int value2); [Intrinsic] [NoHeapAllocation] public extern static unsafe sbyte * operator + (sbyte *value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static unsafe byte * operator + (byte *value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static unsafe short * operator + (short *value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static unsafe uint * operator + (uint* value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static unsafe short * operator - (short *value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static unsafe uint * operator - (uint* value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator ++ (UIntPtr value); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator * (UIntPtr value1, uint value2); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator * (UIntPtr value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator / (UIntPtr value1, uint value2); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator >> (UIntPtr value, int shift); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator << (UIntPtr value, int shift); [Intrinsic] [NoHeapAllocation] public extern static uint operator & (UIntPtr value1, uint value2); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator & (UIntPtr value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator | (UIntPtr value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static UIntPtr operator ~ (UIntPtr value); [Intrinsic] [NoHeapAllocation] public extern static bool operator < (UIntPtr value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static bool operator > (UIntPtr value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static bool operator <= (UIntPtr value1, UIntPtr value2); [Intrinsic] [NoHeapAllocation] public extern static bool operator >= (UIntPtr value1, UIntPtr value2); } }