From ffee0a2aa307dabcde9f02850f7dabfda542eb37 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Sat, 29 Aug 2020 07:10:04 -0700 Subject: [PATCH] Removed deprecated IOp* conformance, added missing consts and properties --- BeefLibs/corlib/src/Char16.bf | 11 ++++++++- BeefLibs/corlib/src/Char32.bf | 11 ++++++++- BeefLibs/corlib/src/Char8.bf | 7 +----- BeefLibs/corlib/src/Double.bf | 43 ++++++++++++++++++++++++++--------- BeefLibs/corlib/src/Float.bf | 2 +- BeefLibs/corlib/src/Int.bf | 5 +++- BeefLibs/corlib/src/Int16.bf | 2 +- BeefLibs/corlib/src/Int32.bf | 2 +- BeefLibs/corlib/src/Int64.bf | 2 +- BeefLibs/corlib/src/Int8.bf | 2 +- BeefLibs/corlib/src/UInt.bf | 2 +- BeefLibs/corlib/src/UInt16.bf | 2 +- BeefLibs/corlib/src/UInt32.bf | 2 +- BeefLibs/corlib/src/UInt64.bf | 2 +- BeefLibs/corlib/src/UInt8.bf | 2 +- 15 files changed, 67 insertions(+), 30 deletions(-) diff --git a/BeefLibs/corlib/src/Char16.bf b/BeefLibs/corlib/src/Char16.bf index 9d63b8b8..e9aa835e 100644 --- a/BeefLibs/corlib/src/Char16.bf +++ b/BeefLibs/corlib/src/Char16.bf @@ -1,6 +1,6 @@ namespace System { - struct Char16 : char16, IHashable + struct Char16 : char16, IHashable, IIsNaN { const int UNICODE_PLANE00_END = 0x00ffff; // The starting codepoint for Unicode plane 1. Plane 1 contains 0x010000 ~ 0x01ffff. @@ -14,6 +14,15 @@ namespace System const char16 HIGH_SURROGATE_END = (char16)0xdbff; const char16 LOW_SURROGATE_START = (char16)0xdc00; + bool IIsNaN.IsNaN + { + [SkipCall] + get + { + return false; + } + } + public int GetHashCode() { return (int)this; diff --git a/BeefLibs/corlib/src/Char32.bf b/BeefLibs/corlib/src/Char32.bf index b519cbb7..0ea8a01a 100644 --- a/BeefLibs/corlib/src/Char32.bf +++ b/BeefLibs/corlib/src/Char32.bf @@ -1,12 +1,21 @@ namespace System { - struct Char32 : char32, IHashable + struct Char32 : char32, IHashable, IIsNaN { public int GetHashCode() { return (int)this; } + bool IIsNaN.IsNaN + { + [SkipCall] + get + { + return false; + } + } + public extern char32 ToLower { get; diff --git a/BeefLibs/corlib/src/Char8.bf b/BeefLibs/corlib/src/Char8.bf index 3405a9bf..56220618 100644 --- a/BeefLibs/corlib/src/Char8.bf +++ b/BeefLibs/corlib/src/Char8.bf @@ -1,13 +1,8 @@ namespace System { #unwarn - struct Char8 : char8, IHashable, IOpComparable, IIsNaN + struct Char8 : char8, IHashable, IIsNaN { - public static int operator<=>(Char8 a, Char8 b) - { - return (char8)a <=> (char8)b; - } - bool IIsNaN.IsNaN { [SkipCall] diff --git a/BeefLibs/corlib/src/Double.bf b/BeefLibs/corlib/src/Double.bf index fb9a48ed..64a72f69 100644 --- a/BeefLibs/corlib/src/Double.bf +++ b/BeefLibs/corlib/src/Double.bf @@ -10,7 +10,7 @@ namespace System using System.Diagnostics; #unwarn - public struct Double : double, IFloating, ISigned, IFormattable, IHashable, IOpComparable, IOpNegatable, IOpAddable, IOpSubtractable, IOpMultiplicable, IOpDividable, ICanBeNaN + public struct Double : double, IFloating, ISigned, IFormattable, IHashable, ICanBeNaN { public const double MinValue = -1.7976931348623157E+308; public const double MaxValue = 1.7976931348623157E+308; @@ -65,7 +65,25 @@ namespace System return *((int*)&d) ^ ((int32*)&d)[1]; } - + + public bool IsNegative + { + get + { + double val = (double)this; + return (*(uint64*)(&val) & 0x8000000000000000UL) == 0x8000000000000000UL; + } + } + + public bool IsFinite + { + get + { + double val = (double)this; + return (*(int64*)(&val) & 0x7FFFFFFFFFFFFFFFL) < 0x7FF0000000000000L; + } + } + public bool IsInfinity { get @@ -91,15 +109,7 @@ namespace System } } - public bool IsNegative - { - get - { - double val = (double)this; - return (*(uint64*)(&val) & 0x8000000000000000UL) == 0x8000000000000000UL; - } - } - + public bool IsNaN { get @@ -109,6 +119,17 @@ namespace System } } + public bool IsSubnormal + { + get + { + double val = (double)this; + var bits = *(int64*)(&val); + bits &= 0x7FFFFFFFFFFFFFFFUL; + return (bits < 0x7F80000000000000UL) && (bits != 0) && ((bits & 0x7F80000000000000UL) == 0); + } + } + // Compares this object to another object, returning an instance of System.Relation. // Null is considered less than any instance. // diff --git a/BeefLibs/corlib/src/Float.bf b/BeefLibs/corlib/src/Float.bf index 63e7e6a0..a3c7dc23 100644 --- a/BeefLibs/corlib/src/Float.bf +++ b/BeefLibs/corlib/src/Float.bf @@ -3,7 +3,7 @@ using System.Globalization; namespace System { #unwarn - struct Float : float, IFloating, ISigned, IFormattable, IHashable, IEquatable, IOpComparable, IOpNegatable, IOpAddable, IOpSubtractable, IOpMultiplicable, IOpDividable, ICanBeNaN + struct Float : float, IFloating, ISigned, IFormattable, IHashable, IEquatable, ICanBeNaN { public const float MinValue = (float)-3.40282346638528859e+38; public const float Epsilon = (float)1.4e-45; diff --git a/BeefLibs/corlib/src/Int.bf b/BeefLibs/corlib/src/Int.bf index e408ef5f..722e85e3 100644 --- a/BeefLibs/corlib/src/Int.bf +++ b/BeefLibs/corlib/src/Int.bf @@ -3,7 +3,7 @@ using System; namespace System { #unwarn - struct Int : int, IInteger, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable, IOpMultiplicable, IOpDividable + struct Int : int, IInteger, IHashable, IFormattable, IIsNaN { public enum ParseError { @@ -12,6 +12,9 @@ namespace System case InvalidChar(int partialResult); } + public const int MaxValue = (sizeof(uint) == 8) ? 0x7FFFFFFFFFFFFFFFL : 0x7FFFFFFF; + public const int MinValue = (sizeof(uint) == 8) ? -0x8000000000000000L : -0x80000000; + public static int operator<=>(Self a, Self b) { return (SelfBase)a <=> (SelfBase)b; diff --git a/BeefLibs/corlib/src/Int16.bf b/BeefLibs/corlib/src/Int16.bf index 2e80252f..bf61bf4c 100644 --- a/BeefLibs/corlib/src/Int16.bf +++ b/BeefLibs/corlib/src/Int16.bf @@ -1,7 +1,7 @@ namespace System { #unwarn - struct Int16 : int16, IInteger, ISigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable, IOpMultiplicable, IOpDividable + struct Int16 : int16, IInteger, ISigned, IHashable, IFormattable, IIsNaN { public const int32 MaxValue = 0x7FFF; public const int32 MinValue = -0x8000; diff --git a/BeefLibs/corlib/src/Int32.bf b/BeefLibs/corlib/src/Int32.bf index dcb2fb4c..f1c8ae66 100644 --- a/BeefLibs/corlib/src/Int32.bf +++ b/BeefLibs/corlib/src/Int32.bf @@ -3,7 +3,7 @@ using System.Globalization; namespace System { #unwarn - struct Int32 : int32, IInteger, ISigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable, IOpMultiplicable, IOpDividable + struct Int32 : int32, IInteger, ISigned, IHashable, IFormattable, IIsNaN { public enum ParseError { diff --git a/BeefLibs/corlib/src/Int64.bf b/BeefLibs/corlib/src/Int64.bf index 0b35102e..89bd1cc4 100644 --- a/BeefLibs/corlib/src/Int64.bf +++ b/BeefLibs/corlib/src/Int64.bf @@ -3,7 +3,7 @@ using System.Globalization; namespace System { #unwarn - struct Int64 : int64, IInteger, ISigned, IFormattable, IHashable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable, IOpMultiplicable, IOpDividable + struct Int64 : int64, IInteger, ISigned, IFormattable, IHashable, IIsNaN { public enum ParseError { diff --git a/BeefLibs/corlib/src/Int8.bf b/BeefLibs/corlib/src/Int8.bf index 455cdc9d..5305b6bc 100644 --- a/BeefLibs/corlib/src/Int8.bf +++ b/BeefLibs/corlib/src/Int8.bf @@ -1,7 +1,7 @@ namespace System { #unwarn - struct Int8 : int8, IInteger, ISigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable, IOpMultiplicable, IOpDividable + struct Int8 : int8, IInteger, ISigned, IHashable, IFormattable, IIsNaN { public const int32 MaxValue = 0x7F; public const int32 MinValue = -0x80; diff --git a/BeefLibs/corlib/src/UInt.bf b/BeefLibs/corlib/src/UInt.bf index 194d1126..4d9ac341 100644 --- a/BeefLibs/corlib/src/UInt.bf +++ b/BeefLibs/corlib/src/UInt.bf @@ -1,7 +1,7 @@ namespace System { #unwarn - struct UInt : uint, IInteger, IUnsigned, IHashable, IOpComparable, IFormattable, IIsNaN, IOpAddable, IOpSubtractable + struct UInt : uint, IInteger, IUnsigned, IHashable, IFormattable, IIsNaN { public enum ParseError { diff --git a/BeefLibs/corlib/src/UInt16.bf b/BeefLibs/corlib/src/UInt16.bf index f43d7e43..7167f4b0 100644 --- a/BeefLibs/corlib/src/UInt16.bf +++ b/BeefLibs/corlib/src/UInt16.bf @@ -1,7 +1,7 @@ namespace System { #unwarn - struct UInt16 : uint16, IInteger, IUnsigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable, IOpMultiplicable, IOpDividable + struct UInt16 : uint16, IInteger, IUnsigned, IHashable, IFormattable, IIsNaN { public const uint16 MaxValue = (uint16)0xFFFF; public const uint16 MinValue = 0; diff --git a/BeefLibs/corlib/src/UInt32.bf b/BeefLibs/corlib/src/UInt32.bf index d48dbc41..53df66e0 100644 --- a/BeefLibs/corlib/src/UInt32.bf +++ b/BeefLibs/corlib/src/UInt32.bf @@ -1,7 +1,7 @@ namespace System { #unwarn - struct UInt32 : uint32, IInteger, IUnsigned, IHashable, IOpComparable, IFormattable, IIsNaN, IOpAddable, IOpSubtractable, IOpMultiplicable, IOpDividable + struct UInt32 : uint32, IInteger, IUnsigned, IHashable, IFormattable, IIsNaN { public enum ParseError { diff --git a/BeefLibs/corlib/src/UInt64.bf b/BeefLibs/corlib/src/UInt64.bf index 232fe9bd..e9f6b1de 100644 --- a/BeefLibs/corlib/src/UInt64.bf +++ b/BeefLibs/corlib/src/UInt64.bf @@ -3,7 +3,7 @@ using System.Globalization; namespace System { #unwarn - struct UInt64 : uint64, IInteger, IUnsigned, IHashable, IOpComparable, IIsNaN, IFormattable, IOpAddable, IOpSubtractable, IOpMultiplicable, IOpDividable + struct UInt64 : uint64, IInteger, IUnsigned, IHashable, IIsNaN, IFormattable { public const uint64 MaxValue = 0xFFFFFFFFFFFFFFFFUL; public const uint64 MinValue = 0; diff --git a/BeefLibs/corlib/src/UInt8.bf b/BeefLibs/corlib/src/UInt8.bf index fa4ce52d..67119af1 100644 --- a/BeefLibs/corlib/src/UInt8.bf +++ b/BeefLibs/corlib/src/UInt8.bf @@ -1,7 +1,7 @@ namespace System { #unwarn - struct UInt8 : uint8, IInteger, IUnsigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable, IOpMultiplicable, IOpDividable + struct UInt8 : uint8, IInteger, IUnsigned, IHashable, IFormattable, IIsNaN { public const uint8 MaxValue = (uint8)0xFF; public const uint8 MinValue = 0;