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.
 
 

36 lines
892 B

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using static flecs_hub.flecs;
namespace gaemstone.Flecs;
public class FlecsException
: Exception
{
public FlecsException() : base() { }
public FlecsException(string message) : base(message) { }
}
public class FlecsAbortException
: FlecsException
{
private readonly string _stackTrace = new StackTrace(2, true).ToString();
public override string? StackTrace => _stackTrace;
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]
private static void Abort()
=> throw new FlecsAbortException();
}