diff --git a/BeefLibs/Beefy2D/src/utils/StructuredData.bf b/BeefLibs/Beefy2D/src/utils/StructuredData.bf index 90706db5..86346a4f 100644 --- a/BeefLibs/Beefy2D/src/utils/StructuredData.bf +++ b/BeefLibs/Beefy2D/src/utils/StructuredData.bf @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.Collections; using System.Text; using System.Diagnostics; using System.IO; diff --git a/BeefLibs/corlib/src/Collections/Dictionary.bf b/BeefLibs/corlib/src/Collections/Dictionary.bf index 0bfec1f8..9917ccf9 100644 --- a/BeefLibs/corlib/src/Collections/Dictionary.bf +++ b/BeefLibs/corlib/src/Collections/Dictionary.bf @@ -13,8 +13,10 @@ namespace System.Collections using System.Diagnostics; using System.Diagnostics.Contracts; - public class Dictionary : ICollection> where TKey : IHashable //: IDictionary, IDictionary, IReadOnlyDictionary, ISerializable, IDeserializationCallback + public class Dictionary : ICollection<(TKey key, TValue* value)>, IEnumerable<(TKey key, TValue* value)> where TKey : IHashable //: IDictionary, IDictionary, IReadOnlyDictionary, ISerializable, IDeserializationCallback { + typealias KeyValuePair=(TKey key, TValue* value); + private struct Entry { public TKey mKey; // Key of entry @@ -107,10 +109,10 @@ namespace System.Collections { Insert(key, value, true); } - - public void Add(KeyValuePair kvPair) + + public void Add(KeyValuePair kvPair) { - Insert(kvPair.Key, kvPair.Value, true); + Insert(kvPair.key, *kvPair.value, true); } public bool TryAdd(TKey key, TValue value) @@ -221,18 +223,18 @@ namespace System.Collections return false; } - public bool Contains(KeyValuePair kvPair) + public bool Contains(KeyValuePair kvPair) { TValue value; - if(TryGetValue(kvPair.Key, out value)) + if(TryGetValue(kvPair.key, out value)) { - return value == kvPair.Value; + return value == *kvPair.value; }else{ return false; } } - public void CopyTo(KeyValuePair[] kvPair, int index) + public void CopyTo(KeyValuePair[] kvPair, int index) { Keys.Reset(); Values.Reset(); @@ -242,7 +244,7 @@ namespace System.Collections { if(i >= index) { - kvPair[i] = KeyValuePair(Keys.Current, Values.CurrentRef); + kvPair[i]=(Keys.Current, &Values.CurrentRef); } } while(Keys.MoveNext() && Values.MoveNext()); @@ -496,9 +498,9 @@ namespace System.Collections } [Inline] - public bool Remove(KeyValuePair kvPair) + public bool Remove(KeyValuePair kvPair) { - return Remove(kvPair.Key); + return Remove(kvPair.key); } public Result<(TKey key, TValue value)> GetAndRemove(TKey key) @@ -602,7 +604,7 @@ namespace System.Collections return (key is TKey); } - public struct Enumerator : IEnumerator<(TKey key, TValue value)>//, IDictionaryEnumerator + public struct Enumerator : IEnumerator//, IDictionaryEnumerator { private Dictionary mDictionary; #if VERSION_DICTIONARY @@ -678,13 +680,14 @@ namespace System.Collections } } - public (TKey key, TValue value) Current + public KeyValuePair Current { - get { return (mDictionary.mEntries[mCurrentIndex].mKey, mDictionary.mEntries[mCurrentIndex].mValue); } + get { return (mDictionary.mEntries[mCurrentIndex].mKey, &mDictionary.mEntries[mCurrentIndex].mValue); } } public void Dispose() { + } public void SetValue(TValue value) @@ -742,7 +745,7 @@ namespace System.Collections } }*/ - public Result<(TKey key, TValue value)> GetNext() mut + public Result GetNext() mut { if (!MoveNext()) return .Err; diff --git a/BeefLibs/corlib/src/Collections/IEnumerator.bf b/BeefLibs/corlib/src/Collections/IEnumerator.bf index e1950341..0515a636 100644 --- a/BeefLibs/corlib/src/Collections/IEnumerator.bf +++ b/BeefLibs/corlib/src/Collections/IEnumerator.bf @@ -5,6 +5,7 @@ namespace System.Collections interface IEnumerator { Result GetNext() mut; + T Current { get; }; } interface IResettable diff --git a/BeefLibs/corlib/src/Collections/KeyValuePair.bf b/BeefLibs/corlib/src/Collections/KeyValuePair.bf deleted file mode 100644 index e2c1133b..00000000 --- a/BeefLibs/corlib/src/Collections/KeyValuePair.bf +++ /dev/null @@ -1,45 +0,0 @@ -namespace System.Collections -{ - public struct KeyValuePair - { - private TKey mKey; - private TValue mValue; - - public this(TKey key, TValue value) - { - this.mKey = key; - this.mValue = value; - } - - public TKey Key - { - get { return mKey; } - } - - public TValue Value - { - get { return mValue; } - } - - public override void ToString(String strOut) - { - strOut.Append('['); - if (Key != null) - { - Key.ToString(strOut); - } - strOut.Append(", "); - if (Value != null) - { - Value.ToString(strOut); - } - strOut.Append(']'); - } - } -} - -namespace System.Collections.Generic -{ - [Obsolete("The System.Collections.Generic types have been moved into System.Collections", false)] - typealias KeyValuePair = System.Collections.KeyValuePair; -} diff --git a/BeefLibs/corlib/src/Environment.bf b/BeefLibs/corlib/src/Environment.bf index 9789855e..0ccc010a 100644 --- a/BeefLibs/corlib/src/Environment.bf +++ b/BeefLibs/corlib/src/Environment.bf @@ -120,7 +120,7 @@ namespace System for (let kv in envVars) { keys[idx] = kv.key; - values[idx] = kv.value; + values[idx] = *kv.value; ++idx; } @@ -158,7 +158,7 @@ namespace System for (let kv in envVars) { keys[idx] = kv.key; - values[idx] = kv.value; + values[idx] = *kv.value; ++idx; } @@ -182,4 +182,4 @@ namespace System data.Add(0); } } -} \ No newline at end of file +} diff --git a/BeefLibs/corlib/src/PropertyBag.bf b/BeefLibs/corlib/src/PropertyBag.bf index f9864082..04543eb7 100644 --- a/BeefLibs/corlib/src/PropertyBag.bf +++ b/BeefLibs/corlib/src/PropertyBag.bf @@ -76,7 +76,7 @@ namespace System for (let kv in lhs.mProperties) { - Object lhsVal = kv.value; + Object lhsVal = *kv.value; Object rhsVal; if (!rhs.Get(kv.key, out rhsVal)) return false; diff --git a/IDE/dist/BeefDbgVis.toml b/IDE/dist/BeefDbgVis.toml index c8006616..249e18ad 100644 --- a/IDE/dist/BeefDbgVis.toml +++ b/IDE/dist/BeefDbgVis.toml @@ -214,7 +214,7 @@ Size = "mLength" ValuePointer = "mPtr" [[Type]] -Name = "System.Collections.Generic.List<*>" +Name = "System.Collections.List<*>" DisplayString = "{{ count={mSize} }}" [[Type.Expand.Item]] Name = "[Count]" @@ -232,7 +232,7 @@ Size = "mSize" ValuePointer = "mItems" [[Type]] -Name = "System.Collections.Generic.Queue<*>" +Name = "System.Collections.Queue<*>" DisplayString = "{{ count={mSize} }}" [[Type.Expand.Item]] Name = "[Count]" @@ -250,7 +250,7 @@ Size = "mSize" ValueNode = "mItems[($i + mHead) % __clearHighBits(mAllocSizeAndFlags, 2)]" [[Type]] -Name = "System.Collections.Generic.BinaryHeap<*>" +Name = "System.Collections.BinaryHeap<*>" DisplayString = "{{ count={mSize} }}" [[Type.Expand.Item]] Name = "[Count]" @@ -260,7 +260,7 @@ Size = "mSize" ValuePointer = "&this.mData.mFirstElement" [[Type]] -Name = "System.Collections.Generic.Dictionary<*, *>" +Name = "System.Collections.Dictionary<*, *>" DisplayString = "{{ count={mCount - mFreeCount} }}" [[Type.Expand.Item]] Name = "[Count]" @@ -274,7 +274,7 @@ Value = "mValue" Next = "mNext" [[Type]] -Name = "System.Collections.Generic.Dictionary<*, *>.Entry" +Name = "System.Collections.Dictionary<*, *>.Entry" DisplayString = "{{[{mKey}, {mValue}]}}" [[Type.Expand.Item]] Name = "[Key]" @@ -284,7 +284,7 @@ Name = "[Value]" Value = "mValue" [[Type]] -Name = "System.Collections.Generic.HashSet<*>" +Name = "System.Collections.HashSet<*>" DisplayString = "{{ count={mCount} }}" [[Type.Expand.Item]] Name = "[Count]" @@ -294,16 +294,6 @@ Size = "mCount" ValuePointer = "&mSlots.mFirstElement" Condition = "mHashCode >= 0" -[[Type]] -Name = "System.Collections.Generic.KeyValuePair<*, *>" -DisplayString = "{{{mKey}, {mValue}}}" -[[Type.Expand.Item]] -Name = "[Key]" -Value = "mKey" -[[Type.Expand.Item]] -Name = "[Value]" -Value = "mValue" - #################### C++ Standard Types #################### [[Type]] diff --git a/IDE/dist/Standard.dbgvis b/IDE/dist/Standard.dbgvis index 065a6c61..3756cda5 100644 --- a/IDE/dist/Standard.dbgvis +++ b/IDE/dist/Standard.dbgvis @@ -620,7 +620,7 @@ }, "Type": { - "Name": "System.Collections.Generic.List<*>", + "Name": "System.Collections.List<*>", "DisplayString": "{{ count={mSize} }}", "Expand": { "Item": { @@ -635,7 +635,7 @@ }, "Type": { - "Name": "System.Collections.Generic.Dictionary<*, *>", + "Name": "System.Collections.Dictionary<*, *>", "DisplayString": "{{ count={mCount - mFreeCount} }}", "Expand": { "Item": { @@ -654,7 +654,7 @@ }, "Type": { - "Name": "System.Collections.Generic.Dictionary<*, *>.Entry", + "Name": "System.Collections.Dictionary<*, *>.Entry", "DisplayString": "{{[{mKey}, {mValue}]}}", "Expand": { "Item": { @@ -669,7 +669,7 @@ }, "Type": { - "Name": "System.Collections.Generic.HashSet<*>", + "Name": "System.Collections.HashSet<*>", "DisplayString": "{{ count={mCount} }}", "Expand": { "Item": { @@ -683,21 +683,6 @@ } } }, - - "Type": { - "Name": "System.Collections.Generic.KeyValuePair<*, *>", - "DisplayString": "{{{mKey}, {mValue}}}", - "Expand": { - "Item": { - "Name": "[Key]", - "Value": "mKey" - }, - "Item": { - "Name": "[Value]", - "Value": "mValue" - } - } - }, "Type": { "Name": "llvm::SmallVectorImpl<*>", @@ -1183,4 +1168,4 @@ } } -} \ No newline at end of file +}