From 1fa1fa4a3c4653ac5a4f36bfd27a789789000063 Mon Sep 17 00:00:00 2001 From: copygirl Date: Thu, 29 Dec 2022 02:55:45 +0100 Subject: [PATCH] Minor cleanup, remove sealed modifier --- src/gaemstone.ECS/Filter.cs | 6 +++--- src/gaemstone.ECS/Query.cs | 2 +- src/gaemstone.ECS/Rule.cs | 2 +- src/gaemstone.Utility/Allocators.cs | 7 ++++--- src/gaemstone.Utility/CallbackContextHelper.cs | 1 - 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gaemstone.ECS/Filter.cs b/src/gaemstone.ECS/Filter.cs index d3b38c1..5acf0c4 100644 --- a/src/gaemstone.ECS/Filter.cs +++ b/src/gaemstone.ECS/Filter.cs @@ -6,7 +6,7 @@ using static flecs_hub.flecs; namespace gaemstone.ECS; -public unsafe sealed class Filter +public unsafe class Filter : IDisposable { public World World { get; } @@ -21,13 +21,13 @@ public unsafe sealed class Filter } public void Dispose() - => ecs_filter_fini(Handle); + => ecs_filter_fini(this); public Iterator Iter() => new(World, IteratorType.Filter, ecs_filter_iter(World, this)); public override string ToString() - => ecs_filter_str(World, Handle).FlecsToStringAndFree()!; + => ecs_filter_str(World, this).FlecsToStringAndFree()!; public static implicit operator ecs_filter_t*(Filter q) => q.Handle; } diff --git a/src/gaemstone.ECS/Query.cs b/src/gaemstone.ECS/Query.cs index 73de798..b8ab013 100644 --- a/src/gaemstone.ECS/Query.cs +++ b/src/gaemstone.ECS/Query.cs @@ -4,7 +4,7 @@ using static flecs_hub.flecs; namespace gaemstone.ECS; -public unsafe sealed class Query +public unsafe class Query : IDisposable { public World World { get; } diff --git a/src/gaemstone.ECS/Rule.cs b/src/gaemstone.ECS/Rule.cs index 1013723..9f6bd65 100644 --- a/src/gaemstone.ECS/Rule.cs +++ b/src/gaemstone.ECS/Rule.cs @@ -4,7 +4,7 @@ using static flecs_hub.flecs; namespace gaemstone.ECS; -public unsafe sealed class Rule +public unsafe class Rule : IDisposable { public World World { get; } diff --git a/src/gaemstone.Utility/Allocators.cs b/src/gaemstone.Utility/Allocators.cs index e8342b5..f392222 100644 --- a/src/gaemstone.Utility/Allocators.cs +++ b/src/gaemstone.Utility/Allocators.cs @@ -68,6 +68,7 @@ public static class TempAllocator public ResetOnDispose(ArenaAllocator allocator, int start) { _allocator = allocator; _start = start; } + // TODO: Print warning in finalizer if Dispose wasn't called manually. // IAllocator implementation @@ -90,7 +91,7 @@ public class GlobalHeapAllocator => Marshal.FreeHGlobal(pointer); } -public sealed class ArenaAllocator +public class ArenaAllocator : IAllocator , IDisposable { @@ -133,7 +134,7 @@ public sealed class ArenaAllocator } } -public sealed class RingAllocator +public class RingAllocator : IAllocator , IDisposable { @@ -166,5 +167,5 @@ public sealed class RingAllocator } public void Free(nint pointer) - { /* IGNORE */ } + { /* Do nothing. */ } } diff --git a/src/gaemstone.Utility/CallbackContextHelper.cs b/src/gaemstone.Utility/CallbackContextHelper.cs index d7c4939..3d22015 100644 --- a/src/gaemstone.Utility/CallbackContextHelper.cs +++ b/src/gaemstone.Utility/CallbackContextHelper.cs @@ -27,5 +27,4 @@ public static class CallbackContextHelper lock (_contexts) _contexts.Remove(id); } - }