Skip to content

Commit

Permalink
remove cb-caching
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed Jan 4, 2024
1 parent 2bd9899 commit f004f0f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
13 changes: 2 additions & 11 deletions ZenKit/DaedalusVm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ public delegate void ExternalFuncV<in TP0, in TP1, in TP2, in TP3, in TP4, in TP
public delegate void ExternalFuncV<in TP0, in TP1, in TP2, in TP3, in TP4, in TP5, in TP6, in TP7, in TP8,
in TP9>(TP0 p0, TP1 p1, TP2 p2, TP3 p3, TP4 p4, TP5 p5, TP6 p6, TP7 p7, TP8 p8, TP9 p9);

private readonly List<Native.Callbacks.ZkDaedalusVmExternalCallback> _externalCallbacks =
new List<Native.Callbacks.ZkDaedalusVmExternalCallback>();

private Native.Callbacks.ZkDaedalusVmExternalDefaultCallback? _externalDefaultCallback;

public DaedalusVm(string path) : base(Native.ZkDaedalusVm_loadPath(path))
{
if (Handle == UIntPtr.Zero) throw new Exception("Failed to load DaedalusVm");
Expand Down Expand Up @@ -335,8 +330,7 @@ public void Call<TP0, TP1, TP2, TP3>(int symId, TP0 p0, TP1 p1, TP2 p2, TP3 p3)

public void RegisterExternalDefault(ExternalDefaultFunction cb)
{
_externalDefaultCallback = (_0, _1, sym) => cb(this, new DaedalusSymbol(sym));
Native.ZkDaedalusVm_registerExternalDefault(Handle, _externalDefaultCallback, UIntPtr.Zero);
Native.ZkDaedalusVm_registerExternalDefault(Handle, (_0, _1, sym) => cb(this, new DaedalusSymbol(sym)), UIntPtr.Zero);
}

public void RegisterExternal<TR>(string name, ExternalFunc<TR> cb)
Expand Down Expand Up @@ -677,10 +671,7 @@ private void RegisterExternalUnsafe(string name, ExternalFunc cb)

private void RegisterExternalUnsafe(DaedalusSymbol sym, ExternalFunc cb)
{
Native.Callbacks.ZkDaedalusVmExternalCallback handle = (_0, _1) => cb();
_externalCallbacks.Add(handle);

Native.ZkDaedalusVm_registerExternal(Handle, sym.Handle, handle, UIntPtr.Zero);
Native.ZkDaedalusVm_registerExternal(Handle, sym.Handle, (_0, _1) => cb(), UIntPtr.Zero);
}

private delegate void ExternalFunc();
Expand Down
6 changes: 1 addition & 5 deletions ZenKit/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ public static class Logger
{
public delegate void Callback(LogLevel level, string name, string message);

private static readonly List<Native.Callbacks.ZkLogger> _callbacks = new List<Native.Callbacks.ZkLogger>();

public static void Set(LogLevel lvl, Callback callback)
{
Native.Callbacks.ZkLogger cb = (_, level, name, message) => callback(level, name, message);
_callbacks.Add(cb);
Native.ZkLogger_set(lvl, cb, UIntPtr.Zero);
Native.ZkLogger_set(lvl, (_, level, name, message) => callback(level, name, message), UIntPtr.Zero);
}

public static void SetDefault(LogLevel level)
Expand Down

0 comments on commit f004f0f

Please sign in to comment.