mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-21 17:28:00 +02:00
Moving corlib files out of "System" directory into root
This commit is contained in:
parent
4cd58262e4
commit
7dbfd15292
179 changed files with 3 additions and 0 deletions
74
BeefLibs/corlib/src/UInt.bf
Normal file
74
BeefLibs/corlib/src/UInt.bf
Normal file
|
@ -0,0 +1,74 @@
|
|||
namespace System
|
||||
{
|
||||
struct UInt : uint, IInteger, IUnsigned, IHashable, IOpComparable, IFormattable, IIsNaN, IOpAddable
|
||||
{
|
||||
public enum ParseError
|
||||
{
|
||||
case Ok;
|
||||
case NoValue;
|
||||
case InvalidChar(uint partialResult);
|
||||
}
|
||||
|
||||
public const uint64 MaxValue = (sizeof(uint) == 8) ? 0xFFFFFFFFFFFFFFFFUL : 0xFFFFFFFFL;
|
||||
public const uint64 MinValue = 0;
|
||||
|
||||
public bool IsNull()
|
||||
{
|
||||
return this == 0;
|
||||
}
|
||||
|
||||
public static int operator<=>(UInt a, UInt b)
|
||||
{
|
||||
return (int)a <=> (int)b;
|
||||
}
|
||||
|
||||
public static Self operator+(Self lhs, Self rhs)
|
||||
{
|
||||
return (SelfBase)lhs + (SelfBase)rhs;
|
||||
}
|
||||
|
||||
int IHashable.GetHashCode()
|
||||
{
|
||||
return (int)this;
|
||||
}
|
||||
|
||||
bool IIsNaN.IsNaN
|
||||
{
|
||||
[SkipCall]
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ToString(String strBuffer)
|
||||
{
|
||||
if (sizeof(Self) == sizeof(uint64))
|
||||
((uint64)this).ToString(strBuffer);
|
||||
else
|
||||
((uint32)this).ToString(strBuffer);
|
||||
}
|
||||
|
||||
public void ToString(String outString, String format, IFormatProvider formatProvider)
|
||||
{
|
||||
if (sizeof(Self) == sizeof(uint64))
|
||||
((uint64)this).ToString(outString, format, formatProvider);
|
||||
else
|
||||
((uint32)this).ToString(outString, format, formatProvider);
|
||||
}
|
||||
|
||||
public static Result<uint, ParseError> Parse(StringView val)
|
||||
{
|
||||
if (sizeof(Self) == sizeof(uint64))
|
||||
{
|
||||
var result = UInt64.Parse(val);
|
||||
return *(Result<uint, ParseError>*)&result;
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = UInt64.Parse(val);
|
||||
return *(Result<uint, ParseError>*)&result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue