Skip to content

Commit

Permalink
chore(*): reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed Jan 4, 2024
1 parent bbd9e09 commit 5b82c08
Show file tree
Hide file tree
Showing 26 changed files with 124 additions and 124 deletions.
2 changes: 1 addition & 1 deletion ZenKit/Boxes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public List<IOrientedBoundingBox> Children
{
var children = new List<IOrientedBoundingBox>();
var count = ChildCount;
for (var i = 0;i < count; ++i) children.Add(GetChild(i));
for (var i = 0; i < count; ++i) children.Add(GetChild(i));
return children;
}
}
Expand Down
6 changes: 3 additions & 3 deletions ZenKit/BspTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public List<Vector3> LightPoints
get
{
var points = new List<Vector3>();
for (var i = 0;i < LightPointCount; ++i) points.Add(GetLightPoint(i));
for (var i = 0; i < LightPointCount; ++i) points.Add(GetLightPoint(i));
return points;
}
}
Expand All @@ -200,7 +200,7 @@ public List<BspNode> Nodes
{
var nodes = new List<BspNode>();
var count = NodeCount;
for (var i = 0;i < count; ++i) nodes.Add(GetNode(i));
for (var i = 0; i < count; ++i) nodes.Add(GetNode(i));
return nodes;
}
}
Expand All @@ -213,7 +213,7 @@ public List<IBspSector> Sectors
{
var sectors = new List<IBspSector>();
var count = SectorCount;
for (var i = 0;i < count; ++i) sectors.Add(GetSector(i));
for (var i = 0; i < count; ++i) sectors.Add(GetSector(i));
return sectors;
}
}
Expand Down
3 changes: 1 addition & 2 deletions ZenKit/CutsceneLibrary.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using ZenKit.Util;

namespace ZenKit
Expand Down Expand Up @@ -180,7 +179,7 @@ public List<ICutsceneBlock> Blocks
get
{
var blocks = new List<ICutsceneBlock>();
var count =(int)Native.ZkCutsceneLibrary_getBlockCount(_handle);
var count = (int)Native.ZkCutsceneLibrary_getBlockCount(_handle);
for (var i = 0; i < count; ++i)
blocks.Add(new CutsceneBlock(Native.ZkCutsceneLibrary_getBlockByIndex(_handle, (ulong)i)));
return blocks;
Expand Down
13 changes: 7 additions & 6 deletions ZenKit/DaedalusScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ public void SetInt(int value, ushort index, DaedalusInstance? context = null)

public class DaedalusScript
{
internal readonly UIntPtr Handle;
private static readonly Native.Callbacks.ZkDaedalusSymbolEnumerator InstanceSymbolsEnumerator =
_enumerateInstanceSymbolsHandler;

internal readonly bool _delete;
internal readonly UIntPtr Handle;

public DaedalusScript(string path)
{
Expand Down Expand Up @@ -173,7 +176,7 @@ public List<DaedalusSymbol> Symbols
get
{
var symbols = new List<DaedalusSymbol>();
for (var i = 0;i < SymbolCount; ++i) symbols.Add(GetSymbolByIndex(i)!);
for (var i = 0; i < SymbolCount; ++i) symbols.Add(GetSymbolByIndex(i)!);
return symbols;
}
}
Expand All @@ -193,7 +196,8 @@ public List<DaedalusSymbol> GetInstanceSymbols(string className)
var symbols = new List<DaedalusSymbol>();

var gch = GCHandle.Alloc(symbols);
Native.ZkDaedalusScript_enumerateInstanceSymbols(Handle, className, InstanceSymbolsEnumerator, GCHandle.ToIntPtr(gch));
Native.ZkDaedalusScript_enumerateInstanceSymbols(Handle, className, InstanceSymbolsEnumerator,
GCHandle.ToIntPtr(gch));
gch.Free();

return symbols;
Expand Down Expand Up @@ -221,9 +225,6 @@ public DaedalusInstruction GetInstruction(int address)
var sym = Native.ZkDaedalusScript_getSymbolByName(Handle, name);
return sym == UIntPtr.Zero ? null : new DaedalusSymbol(sym);
}


private static readonly Native.Callbacks.ZkDaedalusSymbolEnumerator InstanceSymbolsEnumerator = _enumerateInstanceSymbolsHandler;

[MonoPInvokeCallback]
private static bool _enumerateInstanceSymbolsHandler(IntPtr ctx, UIntPtr ptr)
Expand Down
48 changes: 24 additions & 24 deletions ZenKit/DaedalusVm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,12 @@ public void RegisterExternalDefault(ExternalDefaultFunction cb)

public void RegisterExternal<TR>(string name, ExternalFunc<TR> cb)
{
RegisterExternalUnsafe(name, (vm) => vm.Push(cb()));
RegisterExternalUnsafe(name, vm => vm.Push(cb()));
}

public void RegisterExternal<TR, TP0>(string name, ExternalFunc<TR, TP0> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p0 = vm.Pop<TP0>();
vm.Push(cb(p0));
Expand All @@ -367,7 +367,7 @@ public void RegisterExternal<TR, TP0>(string name, ExternalFunc<TR, TP0> cb)

public void RegisterExternal<TR, TP0, TP1>(string name, ExternalFunc<TR, TP0, TP1> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p1 = vm.Pop<TP1>();
var p0 = vm.Pop<TP0>();
Expand All @@ -377,7 +377,7 @@ public void RegisterExternal<TR, TP0, TP1>(string name, ExternalFunc<TR, TP0, TP

public void RegisterExternal<TR, TP0, TP1, TP2>(string name, ExternalFunc<TR, TP0, TP1, TP2> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p2 = vm.Pop<TP2>();
var p1 = vm.Pop<TP1>();
Expand All @@ -388,7 +388,7 @@ public void RegisterExternal<TR, TP0, TP1, TP2>(string name, ExternalFunc<TR, TP

public void RegisterExternal<TR, TP0, TP1, TP2, TP3>(string name, ExternalFunc<TR, TP0, TP1, TP2, TP3> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p3 = vm.Pop<TP3>();
var p2 = vm.Pop<TP2>();
Expand All @@ -401,7 +401,7 @@ public void RegisterExternal<TR, TP0, TP1, TP2, TP3>(string name, ExternalFunc<T
public void RegisterExternal<TR, TP0, TP1, TP2, TP3, TP4>(string name,
ExternalFunc<TR, TP0, TP1, TP2, TP3, TP4> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p4 = vm.Pop<TP4>();
var p3 = vm.Pop<TP3>();
Expand All @@ -415,7 +415,7 @@ public void RegisterExternal<TR, TP0, TP1, TP2, TP3, TP4>(string name,
public void RegisterExternal<TR, TP0, TP1, TP2, TP3, TP4, TP5>(string name,
ExternalFunc<TR, TP0, TP1, TP2, TP3, TP4, TP5> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p5 = vm.Pop<TP5>();
var p4 = vm.Pop<TP4>();
Expand All @@ -430,7 +430,7 @@ public void RegisterExternal<TR, TP0, TP1, TP2, TP3, TP4, TP5>(string name,
public void RegisterExternal<TR, TP0, TP1, TP2, TP3, TP4, TP5, TP6>(string name,
ExternalFunc<TR, TP0, TP1, TP2, TP3, TP4, TP5, TP6> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p6 = vm.Pop<TP6>();
var p5 = vm.Pop<TP5>();
Expand All @@ -446,7 +446,7 @@ public void RegisterExternal<TR, TP0, TP1, TP2, TP3, TP4, TP5, TP6>(string name,
public void RegisterExternal<TR, TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7>(string name,
ExternalFunc<TR, TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p7 = vm.Pop<TP7>();
var p6 = vm.Pop<TP6>();
Expand All @@ -463,7 +463,7 @@ public void RegisterExternal<TR, TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7>(string
public void RegisterExternal<TR, TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8>(string name,
ExternalFunc<TR, TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p8 = vm.Pop<TP8>();
var p7 = vm.Pop<TP7>();
Expand All @@ -481,7 +481,7 @@ public void RegisterExternal<TR, TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8>(st
public void RegisterExternal<TR, TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9>(string name,
ExternalFunc<TR, TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p9 = vm.Pop<TP9>();
var p8 = vm.Pop<TP8>();
Expand All @@ -499,12 +499,12 @@ public void RegisterExternal<TR, TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP

public void RegisterExternal(string name, ExternalFuncV cb)
{
RegisterExternalUnsafe(name, (_) => cb());
RegisterExternalUnsafe(name, _ => cb());
}

public void RegisterExternal<TP0>(string name, ExternalFuncV<TP0> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p0 = vm.Pop<TP0>();
cb(p0);
Expand All @@ -513,7 +513,7 @@ public void RegisterExternal<TP0>(string name, ExternalFuncV<TP0> cb)

public void RegisterExternal<TP0, TP1>(string name, ExternalFuncV<TP0, TP1> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p1 = vm.Pop<TP1>();
var p0 = vm.Pop<TP0>();
Expand All @@ -523,7 +523,7 @@ public void RegisterExternal<TP0, TP1>(string name, ExternalFuncV<TP0, TP1> cb)

public void RegisterExternal<TP0, TP1, TP2>(string name, ExternalFuncV<TP0, TP1, TP2> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p2 = vm.Pop<TP2>();
var p1 = vm.Pop<TP1>();
Expand All @@ -534,7 +534,7 @@ public void RegisterExternal<TP0, TP1, TP2>(string name, ExternalFuncV<TP0, TP1,

public void RegisterExternal<TP0, TP1, TP2, TP3>(string name, ExternalFuncV<TP0, TP1, TP2, TP3> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p3 = vm.Pop<TP3>();
var p2 = vm.Pop<TP2>();
Expand All @@ -546,7 +546,7 @@ public void RegisterExternal<TP0, TP1, TP2, TP3>(string name, ExternalFuncV<TP0,

public void RegisterExternal<TP0, TP1, TP2, TP3, TP4>(string name, ExternalFuncV<TP0, TP1, TP2, TP3, TP4> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p4 = vm.Pop<TP4>();
var p3 = vm.Pop<TP3>();
Expand All @@ -560,7 +560,7 @@ public void RegisterExternal<TP0, TP1, TP2, TP3, TP4>(string name, ExternalFuncV
public void RegisterExternal<TP0, TP1, TP2, TP3, TP4, TP5>(string name,
ExternalFuncV<TP0, TP1, TP2, TP3, TP4, TP5> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p5 = vm.Pop<TP5>();
var p4 = vm.Pop<TP4>();
Expand All @@ -575,7 +575,7 @@ public void RegisterExternal<TP0, TP1, TP2, TP3, TP4, TP5>(string name,
public void RegisterExternal<TP0, TP1, TP2, TP3, TP4, TP5, TP6>(string name,
ExternalFuncV<TP0, TP1, TP2, TP3, TP4, TP5, TP6> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p6 = vm.Pop<TP6>();
var p5 = vm.Pop<TP5>();
Expand All @@ -591,7 +591,7 @@ public void RegisterExternal<TP0, TP1, TP2, TP3, TP4, TP5, TP6>(string name,
public void RegisterExternal<TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7>(string name,
ExternalFuncV<TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p7 = vm.Pop<TP7>();
var p6 = vm.Pop<TP6>();
Expand All @@ -608,7 +608,7 @@ public void RegisterExternal<TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7>(string name
public void RegisterExternal<TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8>(string name,
ExternalFuncV<TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p8 = vm.Pop<TP8>();
var p7 = vm.Pop<TP7>();
Expand All @@ -626,7 +626,7 @@ public void RegisterExternal<TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8>(string
public void RegisterExternal<TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9>(string name,
ExternalFuncV<TP0, TP1, TP2, TP3, TP4, TP5, TP6, TP7, TP8, TP9> cb)
{
RegisterExternalUnsafe(name, (vm) =>
RegisterExternalUnsafe(name, vm =>
{
var p9 = vm.Pop<TP9>();
var p8 = vm.Pop<TP8>();
Expand Down Expand Up @@ -695,8 +695,6 @@ private void RegisterExternalUnsafe(DaedalusSymbol sym, ExternalFunc cb)
GCHandle.ToIntPtr(gcHandle));
}

private delegate void ExternalFunc(DaedalusVm vm);

[MonoPInvokeCallback]
private static void _nativeExternalCallbackHandler(IntPtr ctx, UIntPtr vm)
{
Expand All @@ -712,5 +710,7 @@ private static void _nativeExternalCallbackDefaultHandle(IntPtr ctx, UIntPtr vm,
var cb = (ExternalDefaultFunction)gcHandle.Target;
cb(new DaedalusVm(vm), new DaedalusSymbol(sym));
}

private delegate void ExternalFunc(DaedalusVm vm);
}
}
2 changes: 1 addition & 1 deletion ZenKit/Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public List<FontGlyph> Glyphs
{
var glyphs = new List<FontGlyph>(GlyphCount);
var count = GlyphCount;
for (var i = 0;i < count; ++i) glyphs.Add(GetGlyph(i));
for (var i = 0; i < count; ++i) glyphs.Add(GetGlyph(i));
return glyphs;
}
}
Expand Down
6 changes: 2 additions & 4 deletions ZenKit/Logger.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using ZenKit.Util;
using ZenKit.Vobs;

namespace ZenKit
{
Expand All @@ -19,14 +17,14 @@ public static class Logger
{
public delegate void Callback(LogLevel level, string name, string message);

private static GCHandle? _handler = null;
private static GCHandle? _handler;
private static readonly Native.Callbacks.ZkLogger NativeHandler = _nativeCallbackHandler;

public static void Set(LogLevel lvl, Callback callback)
{
var handler = GCHandle.Alloc(callback);
Native.ZkLogger_set(lvl, NativeHandler, GCHandle.ToIntPtr(handler));

_handler?.Free();
_handler = handler;
}
Expand Down
10 changes: 5 additions & 5 deletions ZenKit/Mesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public List<IMaterial> Materials
{
var materials = new List<IMaterial>();
var count = MaterialCount;
for (var i = 0;i < count; ++i) materials.Add(GetMaterial(i));
for (var i = 0; i < count; ++i) materials.Add(GetMaterial(i));
return materials;
}
}
Expand All @@ -317,7 +317,7 @@ public List<Vector3> Positions
{
var positions = new List<Vector3>();
var count = PositionCount;
for (var i = 0;i < count; ++i) positions.Add(GetPosition(i));
for (var i = 0; i < count; ++i) positions.Add(GetPosition(i));
return positions;
}
}
Expand All @@ -330,7 +330,7 @@ public List<Vertex> Features
{
var features = new List<Vertex>();
var count = FeatureCount;
for (var i = 0;i < count; ++i) features.Add(GetFeature(i));
for (var i = 0; i < count; ++i) features.Add(GetFeature(i));
return features;
}
}
Expand All @@ -343,7 +343,7 @@ public List<ILightMap> LightMap
{
var lightMaps = new List<ILightMap>();
var count = LightMapCount;
for (var i = 0;i < count; ++i) lightMaps.Add(GetLightMap(i));
for (var i = 0; i < count; ++i) lightMaps.Add(GetLightMap(i));
return lightMaps;
}
}
Expand All @@ -356,7 +356,7 @@ public List<IPolygon> Polygons
{
var polygons = new List<IPolygon>();
var count = PolygonCount;
for (var i = 0;i < count; ++i) polygons.Add(GetPolygon(i));
for (var i = 0; i < count; ++i) polygons.Add(GetPolygon(i));
return polygons;
}
}
Expand Down
2 changes: 1 addition & 1 deletion ZenKit/ModelAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public List<AnimationSample> Samples
{
var samples = new List<AnimationSample>();
var count = SampleCount;
for (var i = 0;i < count; ++i) samples.Add(GetSample(i));
for (var i = 0; i < count; ++i) samples.Add(GetSample(i));
return samples;
}
}
Expand Down
Loading

0 comments on commit 5b82c08

Please sign in to comment.