Skip to content

Commit f316779

Browse files
committed
unity structure changes
1 parent 96b6861 commit f316779

15 files changed

+271
-192
lines changed

src/ZLinq.Unity/Assets/ZLinq.Unity/Runtime/Internal.meta src/ZLinq.Unity/Assets/ZLinq.Unity/Runtime/External.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ZLinq.Unity/Assets/ZLinq.Unity/Runtime/External/UnityCollections.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ZLinq.Unity/Assets/ZLinq.Unity/Runtime/UnityCollectionsExtensions.cs src/ZLinq.Unity/Assets/ZLinq.Unity/Runtime/External/UnityCollections/UnityCollectionsExtensions.cs

+17-140
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#pragma warning disable CS9074
2+
#nullable enable
23

34
using System;
45
using System.ComponentModel;
@@ -12,24 +13,6 @@ namespace ZLinq
1213
{
1314
public static class UnityCollectionsExtensions
1415
{
15-
public static ValueEnumerable<FromNativeArray<T>, T> AsValueEnumerable<T>(this NativeArray<T> source)
16-
where T : struct
17-
{
18-
return new(new(source.AsReadOnly()));
19-
}
20-
21-
public static ValueEnumerable<FromNativeArray<T>, T> AsValueEnumerable<T>(this NativeArray<T>.ReadOnly source)
22-
where T : struct
23-
{
24-
return new(new(source));
25-
}
26-
27-
public static ValueEnumerable<FromNativeSlice<T>, T> AsValueEnumerable<T>(this NativeSlice<T> source)
28-
where T : struct
29-
{
30-
return new(new(source));
31-
}
32-
3316
#if ZLINQ_UNITY_COLLECTIONS_SUPPORT
3417
public static ValueEnumerable<FromNativeList<T>, T> AsValueEnumerable<T>(this NativeList<T> source)
3518
where T : unmanaged
@@ -136,112 +119,6 @@ public static ValueEnumerable<FromFixedList4096Bytes<T>, T> AsValueEnumerable<T>
136119
#endif
137120
}
138121

139-
[StructLayout(LayoutKind.Auto)]
140-
[EditorBrowsable(EditorBrowsableState.Never)]
141-
public struct FromNativeArray<T> : IValueEnumerator<T>
142-
where T : struct
143-
{
144-
public FromNativeArray(NativeArray<T>.ReadOnly source)
145-
{
146-
this.source = source;
147-
this.index = 0;
148-
}
149-
150-
NativeArray<T>.ReadOnly source;
151-
int index;
152-
153-
public void Dispose()
154-
{
155-
}
156-
157-
public bool TryCopyTo(Span<T> destination, Index offset)
158-
{
159-
if (EnumeratorHelper.TryGetSlice<T>(source, offset, destination.Length, out var slice))
160-
{
161-
slice.CopyTo(destination);
162-
return true;
163-
}
164-
return false;
165-
}
166-
167-
public bool TryGetNext(out T current)
168-
{
169-
if (index < source.Length)
170-
{
171-
current = source[index++];
172-
return true;
173-
}
174-
175-
Unsafe.SkipInit(out current);
176-
return false;
177-
}
178-
179-
public bool TryGetNonEnumeratedCount(out int count)
180-
{
181-
count = source.Length;
182-
return true;
183-
}
184-
185-
public bool TryGetSpan(out ReadOnlySpan<T> span)
186-
{
187-
span = source;
188-
return true;
189-
}
190-
}
191-
192-
[StructLayout(LayoutKind.Auto)]
193-
[EditorBrowsable(EditorBrowsableState.Never)]
194-
public struct FromNativeSlice<T> : IValueEnumerator<T>
195-
where T : struct
196-
{
197-
NativeSlice<T> source;
198-
int index;
199-
200-
public FromNativeSlice(NativeSlice<T> source)
201-
{
202-
this.source = source;
203-
this.index = 0;
204-
}
205-
206-
public void Dispose()
207-
{
208-
}
209-
210-
public unsafe bool TryCopyTo(Span<T> destination, Index offset)
211-
{
212-
if (EnumeratorHelper.TryGetSlice(new ReadOnlySpan<T>(source.GetUnsafePtr(), source.Length), offset, destination.Length, out var slice))
213-
{
214-
slice.CopyTo(destination);
215-
return true;
216-
}
217-
return false;
218-
}
219-
220-
public bool TryGetNext(out T current)
221-
{
222-
if (index < source.Length)
223-
{
224-
current = source[index++];
225-
return true;
226-
}
227-
228-
Unsafe.SkipInit(out current);
229-
return false;
230-
}
231-
232-
public bool TryGetNonEnumeratedCount(out int count)
233-
{
234-
count = source.Length;
235-
return true;
236-
}
237-
238-
public unsafe bool TryGetSpan(out ReadOnlySpan<T> span)
239-
{
240-
span = new ReadOnlySpan<T>(source.GetUnsafePtr(), source.Length);
241-
return true;
242-
}
243-
}
244-
245122
#if ZLINQ_UNITY_COLLECTIONS_SUPPORT
246123
[StructLayout(LayoutKind.Auto)]
247124
[EditorBrowsable(EditorBrowsableState.Never)]
@@ -279,7 +156,7 @@ public bool TryGetNext(out T current)
279156
return true;
280157
}
281158

282-
Unsafe.SkipInit(out current);
159+
current = default!;
283160
return false;
284161
}
285162

@@ -324,7 +201,7 @@ public bool TryGetNext(out T current)
324201
return true;
325202
}
326203

327-
Unsafe.SkipInit(out current);
204+
current = default!;
328205
return false;
329206
}
330207

@@ -369,7 +246,7 @@ public bool TryGetNext(out T current)
369246
return true;
370247
}
371248

372-
Unsafe.SkipInit(out current);
249+
current = default!;
373250
return false;
374251
}
375252

@@ -415,7 +292,7 @@ public bool TryGetNext(out KVPair<TKey, TValue> current)
415292
return true;
416293
}
417294

418-
Unsafe.SkipInit(out current);
295+
current = default!;
419296
return false;
420297
}
421298

@@ -457,7 +334,7 @@ public bool TryGetNext(out Unicode.Rune current)
457334
return true;
458335
}
459336

460-
Unsafe.SkipInit(out current);
337+
current = default!;
461338
return false;
462339
}
463340

@@ -500,7 +377,7 @@ public bool TryGetNext(out T current)
500377
return true;
501378
}
502379

503-
Unsafe.SkipInit(out current);
380+
current = default!;
504381
return false;
505382
}
506383

@@ -543,7 +420,7 @@ public bool TryGetNext(out T current)
543420
return true;
544421
}
545422

546-
Unsafe.SkipInit(out current);
423+
current = default!;
547424
return false;
548425
}
549426

@@ -586,7 +463,7 @@ public bool TryGetNext(out T current)
586463
return true;
587464
}
588465

589-
Unsafe.SkipInit(out current);
466+
current = default!;
590467
return false;
591468
}
592469

@@ -629,7 +506,7 @@ public bool TryGetNext(out T current)
629506
return true;
630507
}
631508

632-
Unsafe.SkipInit(out current);
509+
current = default!;
633510
return false;
634511
}
635512

@@ -672,7 +549,7 @@ public bool TryGetNext(out T current)
672549
return true;
673550
}
674551

675-
Unsafe.SkipInit(out current);
552+
current = default!;
676553
return false;
677554
}
678555

@@ -714,7 +591,7 @@ public bool TryGetNext(out Unicode.Rune current)
714591
return true;
715592
}
716593

717-
Unsafe.SkipInit(out current);
594+
current = default!;
718595
return false;
719596
}
720597

@@ -756,7 +633,7 @@ public bool TryGetNext(out Unicode.Rune current)
756633
return true;
757634
}
758635

759-
Unsafe.SkipInit(out current);
636+
current = default!;
760637
return false;
761638
}
762639

@@ -798,7 +675,7 @@ public bool TryGetNext(out Unicode.Rune current)
798675
return true;
799676
}
800677

801-
Unsafe.SkipInit(out current);
678+
current = default!;
802679
return false;
803680
}
804681

@@ -840,7 +717,7 @@ public bool TryGetNext(out Unicode.Rune current)
840717
return true;
841718
}
842719

843-
Unsafe.SkipInit(out current);
720+
current = default!;
844721
return false;
845722
}
846723

@@ -882,7 +759,7 @@ public bool TryGetNext(out Unicode.Rune current)
882759
return true;
883760
}
884761

885-
Unsafe.SkipInit(out current);
762+
current = default!;
886763
return false;
887764
}
888765

@@ -901,4 +778,4 @@ public unsafe bool TryGetSpan(out ReadOnlySpan<Unicode.Rune> span)
901778
#endif
902779
}
903780

904-
#pragma warning restore CS9074
781+
#pragma warning restore CS9074

src/ZLinq.Unity/Assets/ZLinq.Unity/Runtime/UnityCollectionsExtensions.cs.meta src/ZLinq.Unity/Assets/ZLinq.Unity/Runtime/External/UnityCollections/UnityCollectionsExtensions.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "ZLinq.Unity.UnityCollectoins",
3+
"rootNamespace": "ZLinq",
4+
"references": [
5+
"Unity.Collections"
6+
],
7+
"includePlatforms": [],
8+
"excludePlatforms": [],
9+
"allowUnsafeCode": true,
10+
"overrideReferences": true,
11+
"precompiledReferences": [
12+
"ZLinq.dll"
13+
],
14+
"autoReferenced": true,
15+
"defineConstraints": [],
16+
"versionDefines": [
17+
{
18+
"name": "com.unity.collections",
19+
"expression": "",
20+
"define": "ZLINQ_UNITY_COLLECTIONS_SUPPORT"
21+
}
22+
],
23+
"noEngineReferences": false
24+
}

src/ZLinq.Unity/Assets/ZLinq.Unity/Runtime/External/UnityCollections/ZLinq.Unity.UnityCollections.asmdef.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ZLinq.Unity/Assets/ZLinq.Unity/Runtime/Internal/EnumeratorHelper.cs

-36
This file was deleted.

src/ZLinq.Unity/Assets/ZLinq.Unity/Runtime/Internal/EnumeratorHelper.cs.meta

-2
This file was deleted.

0 commit comments

Comments
 (0)