mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-07-10 21:19:08 +00:00
Implement NGC service (#5681)
* Implement NGC service * Use raw byte arrays instead of string for _wordSeparators * Silence IDE0230 for _wordSeparators * Try to silence warning about _rangeValuesCount not being read on SparseSet * Make AcType enum private * Add abstract methods and one TODO that I forgot * PR feedback * More PR feedback * More PR feedback
This commit is contained in:
49
src/Ryujinx.Horizon/Sdk/Ngc/Detail/MatchState.cs
Normal file
49
src/Ryujinx.Horizon/Sdk/Ngc/Detail/MatchState.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Horizon.Sdk.Ngc.Detail
|
||||
{
|
||||
readonly ref struct MatchState
|
||||
{
|
||||
public readonly Span<byte> OriginalText;
|
||||
public readonly Span<byte> ConvertedText;
|
||||
public readonly ReadOnlySpan<sbyte> DeltaTable;
|
||||
public readonly ref int MaskedCount;
|
||||
public readonly MaskMode MaskMode;
|
||||
public readonly Sbv NoSeparatorMap;
|
||||
public readonly AhoCorasick DelimitedWordsTrie;
|
||||
|
||||
public MatchState(
|
||||
Span<byte> originalText,
|
||||
Span<byte> convertedText,
|
||||
ReadOnlySpan<sbyte> deltaTable,
|
||||
ref int maskedCount,
|
||||
MaskMode maskMode,
|
||||
Sbv noSeparatorMap = null,
|
||||
AhoCorasick delimitedWordsTrie = null)
|
||||
{
|
||||
OriginalText = originalText;
|
||||
ConvertedText = convertedText;
|
||||
DeltaTable = deltaTable;
|
||||
MaskedCount = ref maskedCount;
|
||||
MaskMode = maskMode;
|
||||
NoSeparatorMap = noSeparatorMap;
|
||||
DelimitedWordsTrie = delimitedWordsTrie;
|
||||
}
|
||||
|
||||
public readonly (int, int) GetOriginalRange(int convertedStartOffest, int convertedEndOffset)
|
||||
{
|
||||
int originalStartOffset = 0;
|
||||
int originalEndOffset = 0;
|
||||
|
||||
for (int index = 0; index < convertedEndOffset; index++)
|
||||
{
|
||||
int byteLength = Math.Abs(DeltaTable[index]);
|
||||
|
||||
originalStartOffset += index < convertedStartOffest ? byteLength : 0;
|
||||
originalEndOffset += byteLength;
|
||||
}
|
||||
|
||||
return (originalStartOffset, originalEndOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user