Formatting (again)
This commit is contained in:
@@ -49,9 +49,7 @@ public class Reader {
|
||||
/// </summary>
|
||||
/// <param name="memAddr">memory address in current system endianness</param>
|
||||
/// <returns>A <see cref="Kaitai.BlendFile.FileBlock"/> object</returns>
|
||||
public FileBlock? GetBlock(long memAddr)
|
||||
{
|
||||
|
||||
public FileBlock? GetBlock(long memAddr) {
|
||||
var blocks = OrderedBlocks.Where(x =>
|
||||
memAddr >= x.MemAddr.ToPointer() && memAddr < x.MemAddr.ToPointer() + x.LenBody);
|
||||
|
||||
@@ -299,26 +297,24 @@ public class Reader {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int[] CalculateArrayIndices(List<int> sizes, int index)
|
||||
{
|
||||
private static int[] CalculateArrayIndices(List<int> sizes, int index) {
|
||||
int[] indexArray = new int[sizes.Count];
|
||||
for (int k = 0; k < sizes.Count; k++) {
|
||||
indexArray[k] = index/sizes[(k+1) ..].Aggregate(1, (a, b) => a * b) % sizes[k];
|
||||
indexArray[k] = index / sizes[(k + 1) ..].Aggregate(1, (a, b) => a * b) % sizes[k];
|
||||
}
|
||||
|
||||
return indexArray;
|
||||
}
|
||||
|
||||
private Array FillPointersArray(DNAArrayAttribute arrayAttribute, byte[] data,
|
||||
Type type, List<int> sizes)
|
||||
{
|
||||
Type type, List<int> sizes) {
|
||||
//Create the array
|
||||
var array = Array.CreateInstance(type, sizes.ToArray());
|
||||
|
||||
for (int i = 0; i < arrayAttribute.Size; i += 8) {
|
||||
var itemData = new byte[8];
|
||||
Array.Copy(data, i, itemData, 0, 8);
|
||||
if(itemData.ToPointer() == IntPtr.Zero) continue;
|
||||
if (itemData.ToPointer() == IntPtr.Zero) continue;
|
||||
object? cellData = ActivateInstance(type);
|
||||
FillObject(itemData.ToPointer(), ref cellData, type.GetFields());
|
||||
|
||||
@@ -330,8 +326,8 @@ public class Reader {
|
||||
return array;
|
||||
}
|
||||
|
||||
private Array FillNormalTypeArray(DNAArrayAttribute arrayAttribute, byte[] data, FileBlock block, Type type, List<int> sizes, int itemLenght, int offset)
|
||||
{
|
||||
private Array FillNormalTypeArray(DNAArrayAttribute arrayAttribute, byte[] data, FileBlock block, Type type,
|
||||
List<int> sizes, int itemLenght, int offset) {
|
||||
var array = Array.CreateInstance(type, sizes.ToArray());
|
||||
|
||||
for (int i = 0; i < arrayAttribute.Size; i += itemLenght) {
|
||||
@@ -347,8 +343,8 @@ public class Reader {
|
||||
return array;
|
||||
}
|
||||
|
||||
private Array FillCustomTypeArray(DNAArrayAttribute arrayAttribute, byte[] data, FileBlock block, Type type, List<int> sizes, int itemLenght, int offset)
|
||||
{
|
||||
private Array FillCustomTypeArray(DNAArrayAttribute arrayAttribute, byte[] data, FileBlock block, Type type,
|
||||
List<int> sizes, int itemLenght, int offset) {
|
||||
var array = Array.CreateInstance(type, sizes.ToArray());
|
||||
|
||||
for (int i = 0; i < arrayAttribute.Size; i += itemLenght) {
|
||||
@@ -380,19 +376,18 @@ public class Reader {
|
||||
var type = Type.GetType(arrayAttribute.OriginalType.ParseFType()) ?? dnaTypesDb[arrayAttribute.OriginalType];
|
||||
if (type == null) throw new NotSupportedException($"Unknown type \"{arrayAttribute.OriginalType}\"");
|
||||
|
||||
if(arrayAttribute.IsPointer){
|
||||
if (arrayAttribute.IsPointer) {
|
||||
return FillPointersArray(arrayAttribute, data, type, sizes);
|
||||
}
|
||||
|
||||
if (!dnaTypesDb.ContainsKey(arrayAttribute.OriginalType)) {
|
||||
|
||||
return FillNormalTypeArray(arrayAttribute, data, block, type, sizes, arrayAttribute.OriginalType.ParseFSize()!.Value, offset.ToInt32());
|
||||
return FillNormalTypeArray(arrayAttribute, data, block, type, sizes,
|
||||
arrayAttribute.OriginalType.ParseFSize()!.Value, offset.ToInt32());
|
||||
}
|
||||
|
||||
int itemLenght = type.GetCustomAttribute<DNAFieldAttribute>()?.Size ??
|
||||
type.GetCustomAttribute<DNAClassAttribute>()!.Size;
|
||||
return FillCustomTypeArray(arrayAttribute, data, block, type, sizes, itemLenght, offset.ToInt32());
|
||||
|
||||
}
|
||||
|
||||
private object? ConvertListField(FileBlock block, FieldInfo field, DNAListAttribute attrib, IntPtr startOffset) {
|
||||
|
||||
Reference in New Issue
Block a user