Skip to content

Commit

Permalink
Add copyright notice to generated files.
Browse files Browse the repository at this point in the history
These were added only to files with a significant amount of roslyn code.
  • Loading branch information
GGG-KILLER committed Feb 1, 2024
1 parent dee33bc commit 42ff839
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects.
// <auto-generated />

#nullable enable

namespace Tsu.Trees.RedGreen.Sample.Internal
{
internal partial struct SampleList<TNode> where TNode : global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode
{
internal struct Enumerator
{
private readonly SampleList<TNode> _list;
private int _index;

internal Enumerator(SampleList<TNode> list)
{
_list = list;
_index = -1;
}

public bool MoveNext()
{
var newIndex = _index + 1;
if (newIndex < _list.Count)
{
_index = newIndex;
return true;
}

return false;
}

public TNode Current => _list[_index]!;
}
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,145 @@

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects.
// <auto-generated />

#nullable enable

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace Tsu.Trees.RedGreen.Sample.Internal
{
internal readonly partial struct SampleList<TNode> : global::System.IEquatable<SampleList<TNode>>
where TNode : global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode
{
private readonly global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode? _node;

internal SampleList(global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode? node)
{
_node = node;
}

internal global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode? Node => _node;

public int Count => _node == null ? 0 : (_node.IsList ? _node.SlotCount : 1);

public TNode? this[int index]
{
get
{
if (_node == null)
{
return null;
}
else if (_node.IsList)
{
global::System.Diagnostics.Debug.Assert(index >= 0);
global::System.Diagnostics.Debug.Assert(index <= _node.SlotCount);

return (TNode?) _node.GetSlot(index);
}
else if (index == 0)
{
return (TNode?) _node;
}
else
{
throw new global::System.InvalidOperationException("The program has reached a state that was thought to be unreachable.");
}
}
}

internal TNode GetRequiredItem(int index)
{
var node = this[index];
global::System.Diagnostics.Debug.Assert(node is object);
return node!;
}

internal global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode? ItemUntyped(int index)
{
global::System.Diagnostics.Debug.Assert(_node is not null);
var node = _node!;
if (node.IsList)
{
return node.GetSlot(index);
}

global::System.Diagnostics.Debug.Assert(index == 0);
return node;
}

public bool Any() => _node != null;

public bool Any(global::Tsu.Trees.RedGreen.Sample.SampleKind kind)
{
foreach (var element in this)
{
if (element.Kind == kind)
{
return true;
}
}

return false;
}

internal TNode[] Nodes
{
get
{
var arr = new TNode[Count];
for (int i = 0; i < Count; i++)
{
arr[i] = GetRequiredItem(i);
}
return arr;
}
}

public TNode? Last
{
get
{
global::System.Diagnostics.Debug.Assert(_node is not null);
var node = _node!;
if (node.IsList)
{
return (TNode?) node.GetSlot(node.SlotCount - 1);
}

return (TNode?) node;
}
}

public Enumerator GetEnumerator() => new(this);

internal void CopyTo(int offset, global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode[] array, int arrayOffset, int count)
{
for (int i = 0; i < count; i++)
{
array[arrayOffset + i] = GetRequiredItem(i + offset);
}
}

public static bool operator ==(SampleList<TNode> left, SampleList<TNode> right) =>
left._node == right._node;

public static bool operator !=(SampleList<TNode> left, SampleList<TNode> right) =>
left._node != right._node;

public bool Equals(SampleList<TNode> other) => _node == other._node;

public override bool Equals(object? obj) => (obj is SampleList<TNode> list) && Equals(list);

public override int GetHashCode() => _node != null ? _node.GetHashCode() : 0;

public static implicit operator SampleList<TNode>(TNode node) => new(node);

public static implicit operator SampleList<TNode>(SampleList<global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode> nodes) => new(nodes._node);

public static implicit operator SampleList<global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode>(SampleList<TNode> nodes) => new(nodes.Node);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// <auto-generated />
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects.
// <auto-generated />

#nullable enable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// <auto-generated />
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects.
// <auto-generated />

#nullable enable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// <auto-generated />
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects.
// <auto-generated />

#nullable enable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// <auto-generated />
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects.
// <auto-generated />

#nullable enable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{{~ if create_lists ~}}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects.
// <auto-generated />

namespace {{ green_list.namespace | not_global }}
#nullable enable

namespace {{ green_base.namespace | not_global }}
{
{{ green_list.accessibility }} partial struct {{ green_list.name }}<TNode> where TNode : {{ green_base.csharp }}
{{ green_base.accessibility }} partial struct {{ suffix }}List<TNode> where TNode : {{ green_base.csharp }}
{
{{ green_list.accessibility }} struct Enumerator
{{ green_base.accessibility }} struct Enumerator
{
private readonly {{ green_list.name }}<TNode> _list;
private readonly {{ suffix }}List<TNode> _list;
private int _index;

internal Enumerator({{ green_list.name }}<TNode> list)
{{ green_base.accessibility }} Enumerator({{ suffix }}List<TNode> list)
{
_list = list;
_index = -1;
Expand Down
21 changes: 11 additions & 10 deletions Tsu.Trees.RedGreen/src/Templates/Internal/GreenList`1.sbn-cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{~ if create_lists ~}}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects.
// <auto-generated />

#nullable enable
Expand All @@ -9,14 +10,14 @@ using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace {{ green_list.namespace | not_global }}
namespace {{ green_base.namespace | not_global }}
{
{{ green_list.accessibility }} readonly partial struct {{ green_list.name }}<TNode> : global::System.IEquatable<{{ green_list.name }}<TNode>>
{{ green_base.accessibility }} readonly partial struct {{ suffix }}List<TNode> : global::System.IEquatable<{{ suffix }}List<TNode>>
where TNode : {{ green_base.csharp | not_null }}
{
private readonly {{ green_base.csharp | not_null }}? _node;

internal {{ green_list.name }}({{ green_base.csharp | not_null }}? node)
{{ green_base.accessibility }} {{ suffix }}List({{ green_base.csharp | not_null }}? node)
{
_node = node;
}
Expand Down Expand Up @@ -124,23 +125,23 @@ namespace {{ green_list.namespace | not_global }}
}
}

public static bool operator ==({{ green_list.name }}<TNode> left, {{ green_list.name }}<TNode> right) =>
public static bool operator ==({{ suffix }}List<TNode> left, {{ suffix }}List<TNode> right) =>
left._node == right._node;

public static bool operator !=({{ green_list.name }}<TNode> left, {{ green_list.name }}<TNode> right) =>
public static bool operator !=({{ suffix }}List<TNode> left, {{ suffix }}List<TNode> right) =>
left._node != right._node;

public bool Equals({{ green_list.name }}<TNode> other) => _node == other._node;
public bool Equals({{ suffix }}List<TNode> other) => _node == other._node;

public override bool Equals(object? obj) => (obj is {{ green_list.name }}<TNode> list) && Equals(list);
public override bool Equals(object? obj) => (obj is {{ suffix }}List<TNode> list) && Equals(list);

public override int GetHashCode() => _node != null ? _node.GetHashCode() : 0;

public static implicit operator {{ green_list.name }}<TNode>(TNode node) => new(node);
public static implicit operator {{ suffix }}List<TNode>(TNode node) => new(node);

public static implicit operator {{ green_list.name }}<TNode>({{ green_list.name }}<{{ green_base.csharp }}> nodes) => new(nodes._node);
public static implicit operator {{ suffix }}List<TNode>({{ suffix }}List<{{ green_base.csharp }}> nodes) => new(nodes._node);

public static implicit operator {{ green_list.name }}<{{ green_base.csharp }}>({{ green_list.name }}<TNode> nodes) => new(nodes.Node);
public static implicit operator {{ suffix }}List<{{ green_base.csharp }}>({{ suffix }}List<TNode> nodes) => new(nodes.Node);
}
}
{{~ end ~}}
3 changes: 3 additions & 0 deletions Tsu.Trees.RedGreen/src/Templates/Internal/GreenRoot.sbn-cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects.
// <auto-generated />

#nullable enable
Expand Down
3 changes: 3 additions & 0 deletions Tsu.Trees.RedGreen/src/Templates/Internal/GreenWalker.sbn-cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects.
// <auto-generated />

#nullable enable
Expand Down
3 changes: 3 additions & 0 deletions Tsu.Trees.RedGreen/src/Templates/RedBase.sbn-cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects.
// <auto-generated />

#nullable enable
Expand Down
3 changes: 3 additions & 0 deletions Tsu.Trees.RedGreen/src/Templates/RedWalker.sbn-cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects.
// <auto-generated />

#nullable enable
Expand Down

0 comments on commit 42ff839

Please sign in to comment.