Skip to content

Commit

Permalink
Migrated more types to auto generate readonly.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Apr 17, 2024
1 parent 43ce2b4 commit 1d8a821
Show file tree
Hide file tree
Showing 28 changed files with 72 additions and 68 deletions.
2 changes: 1 addition & 1 deletion FinModelUtility/Fin/Fin/Fin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
<PackageReference Include="SubstreamSharp" Version="1.0.3" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.IO.Abstractions" Version="19.2.51" />
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>
</Project>
16 changes: 8 additions & 8 deletions FinModelUtility/Fin/Fin/src/data/Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@

using fin.util.asserts;

using schema.readOnly;

namespace fin.data {
public interface IReadOnlyGrid<out T> : IEnumerable<T> {
[GenerateReadOnly]
public partial interface IGrid<T> : IEnumerable<T> {
int Width { get; }
int Height { get; }

T this[int x, int y] { get; }
}

public interface IGrid<T> : IReadOnlyGrid<T> {
new T this[int x, int y] { get; set; }
T this[int x, int y] { get; set; }
}

public class Grid<T> : IGrid<T> {
Expand All @@ -23,7 +21,7 @@ public class Grid<T> : IGrid<T> {
public Grid(int width, int height, T defaultValue = default!) {
this.Width = width;
this.Height = height;

this.impl_ = new T[width * height];
for (var i = 0; i < this.impl_.Count; ++i) {
this.impl_[i] = defaultValue;
Expand Down Expand Up @@ -56,11 +54,13 @@ private int GetIndex_(int x, int y) {
Asserts.Fail(
$"Expected ({x}, {y}) to be a valid index in grid of size ({this.Width}, {this.Height}).");
}

return y * this.Width + x;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public IEnumerator<T> GetEnumerator() => this.impl_.GetEnumerator();
}
Expand Down
14 changes: 8 additions & 6 deletions FinModelUtility/Fin/Fin/src/data/dictionaries/ListDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
using System.Collections.Generic;
using System.Linq;

using schema.readOnly;

namespace fin.data.dictionaries {
public interface IReadOnlyListDictionary<TKey, TValue>
: IReadOnlyFinCollection<(TKey Key, IList<TValue> Value)> {
[GenerateReadOnly]
public partial interface IListDictionary<TKey, TValue>
: IFinCollection<(TKey Key, IList<TValue> Value)> {
[Const]
bool HasList(TKey key);

IList<TValue> this[TKey key] { get; }

[Const]
bool TryGetList(TKey key, out IList<TValue>? list);
}

public interface IListDictionary<TKey, TValue>
: IReadOnlyListDictionary<TKey, TValue>,
IFinCollection<(TKey Key, IList<TValue> Value)> {
void ClearList(TKey key);
void Add(TKey key, TValue value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

using fin.util.asserts;

using schema.readOnly;

namespace fin.data.dictionaries {
public interface IReadOnlySubTypeDictionary<TKey, TValue>
: IReadOnlyFinCollection<(TKey Key, TValue Value)> {
[GenerateReadOnly]
public partial interface ISubTypeDictionary<TKey, TValue>
: IFinCollection<(TKey Key, TValue Value)> {
[Const]
TValueSub Get<TValueSub>(TKey key) where TValueSub : TValue;
}

public interface ISubTypeDictionary<TKey, TValue>
: IReadOnlySubTypeDictionary<TKey, TValue>,
IFinCollection<(TKey Key, TValue Value)> {
void Set<TValueSub>(TKey key, TValueSub value) where TValueSub : TValue;
}

Expand Down
20 changes: 10 additions & 10 deletions FinModelUtility/Fin/Fin/src/data/indexable/IndexableDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
using System.Linq;
using System.Runtime.CompilerServices;

using schema.readOnly;

namespace fin.data.indexable {
public interface IReadOnlyIndexableDictionary<TIndexable, TValue>
[GenerateReadOnly]
public partial interface IIndexableDictionary<TIndexable, TValue>
: IEnumerable<TValue>
where TIndexable : IIndexable {
TValue this[int index] { get; }
TValue this[TIndexable key] { get; }

[Const]
bool TryGetValue(int index, out TValue value);

[Const]
bool TryGetValue(TIndexable key, out TValue value);
}

public interface IIndexableDictionary<TIndexable, TValue>
: IReadOnlyIndexableDictionary<TIndexable, TValue>
where TIndexable : IIndexable {

void Clear();
new TValue this[int index] { get; set; }
new TValue this[TIndexable key] { get; set; }
TValue this[int index] { get; set; }
TValue this[TIndexable key] { get; set; }
}

public class IndexableDictionary<TIndexable, TValue>(int capacity)
Expand Down
17 changes: 8 additions & 9 deletions FinModelUtility/Fin/Fin/src/data/indexable/IndexableSet.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using fin.data.sets;

using fin.data.sets;
using schema.readOnly;

namespace fin.data.indexable {
public interface IReadOnlyIndexableSet<TIndexable> : IFinSet<TIndexable>
[GenerateReadOnly]
public partial interface IIndexableSet<TIndexable> : IFinSet<TIndexable>
where TIndexable : IIndexable {
[Const]
bool Contains(int index);

TIndexable this[int index] { get; }

[Const]
bool TryGetValue(int index, out TIndexable value);
}

public interface IIndexableSet<TIndexable> :
IReadOnlyIndexableSet<TIndexable>,
IFinSet<TIndexable>
where TIndexable : IIndexable { }
}
17 changes: 10 additions & 7 deletions FinModelUtility/Fin/Fin/src/model/IVertexInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ public interface ITangentVertex : IReadOnlyTangentVertex, IVertex {
}


public interface IReadOnlyNormalTangentVertex : IReadOnlyNormalVertex,
IReadOnlyTangentVertex { }
public interface IReadOnlyNormalTangentVertex
: IReadOnlyNormalVertex,
IReadOnlyTangentVertex { }

public interface INormalTangentVertex : IReadOnlyNormalTangentVertex,
INormalVertex, ITangentVertex { }
public interface INormalTangentVertex
: IReadOnlyNormalTangentVertex,
INormalVertex, ITangentVertex { }


public interface IReadOnlySingleColorVertex : IReadOnlyVertex {
Expand All @@ -66,12 +68,13 @@ public interface ISingleColorVertex : IReadOnlySingleColorVertex, IVertex {
}


public interface IReadOnlyMultiColorVertex : IReadOnlyVertex {
[GenerateReadOnly]
public partial interface IMultiColorVertex : IVertex {
int ColorCount { get; }

[Const]
IColor? GetColor(int colorIndex);
}

public interface IMultiColorVertex : IReadOnlyMultiColorVertex, IVertex {
void SetColor(int colorIndex, IColor? color);

void SetColorBytes(int colorIndex,
Expand Down
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Ast/Ast/Ast.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Cmb/Cmb/Cmb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Dat/Dat/Dat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/F3dzex2/F3dzex2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Glo/Glo/Glo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Granny3d/Granny3d.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Gx/Gx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/JSystem/JSystem/JSystem.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Level5/Level5/Level5.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
<PackageReference Include="OpenTK" Version="3.3.3" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Mdl/Mdl/Mdl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Mod/Mod/Mod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Modl/Modl/Modl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Nitro/Nitro/Nitro.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Visceral/Visceral/Visceral.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="BCnEncoder.Net" Version="2.1.0" />
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion FinModelUtility/Formats/Xmod/Xmod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="BCnEncoder.Net" Version="2.1.0" />
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion FinModelUtility/Games/BanjoKazooie/BanjoKazooie.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.HighPerformance" Version="7.1.2" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="OpenTK" Version="3.3.3" />
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="IronPython" Version="3.4.1" />
<PackageReference Include="schema" Version="0.4.4" />
<PackageReference Include="schema" Version="0.4.7" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 1d8a821

Please sign in to comment.