You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
892 B
37 lines
892 B
2 years ago
|
using System;
|
||
|
using System.Diagnostics;
|
||
2 years ago
|
using System.Runtime.InteropServices;
|
||
|
using static flecs_hub.flecs;
|
||
2 years ago
|
|
||
2 years ago
|
namespace gaemstone.Flecs;
|
||
2 years ago
|
|
||
2 years ago
|
public class FlecsException
|
||
|
: Exception
|
||
2 years ago
|
{
|
||
|
public FlecsException() : base() { }
|
||
|
public FlecsException(string message) : base(message) { }
|
||
|
}
|
||
|
|
||
2 years ago
|
public class FlecsAbortException
|
||
|
: FlecsException
|
||
2 years ago
|
{
|
||
|
private readonly string _stackTrace = new StackTrace(2, true).ToString();
|
||
|
public override string? StackTrace => _stackTrace;
|
||
2 years ago
|
|
||
|
private FlecsAbortException()
|
||
|
: base("Abort was called by flecs") { }
|
||
|
|
||
|
// TODO: This might not be ideal if we ever want to set other OS API settings.
|
||
|
public unsafe static void SetupHook()
|
||
|
{
|
||
|
ecs_os_set_api_defaults();
|
||
|
var api = ecs_os_get_api();
|
||
|
api.abort_ = new FnPtr_Void { Pointer = &Abort };
|
||
|
ecs_os_set_api(&api);
|
||
|
}
|
||
|
|
||
|
[UnmanagedCallersOnly]
|
||
2 years ago
|
private static void Abort()
|
||
|
=> throw new FlecsAbortException();
|
||
2 years ago
|
}
|