From 74b799a0b43e75747e576775965c5f872548509d Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Fri, 28 Apr 2023 11:37:45 +0200 Subject: [PATCH] Remove native event.pull and event.pullRaw --- Capy64/Runtime/Libraries/EventLib.cs | 54 ---------------------------- Capy64/Runtime/Objects/Task.cs | 4 ++- 2 files changed, 3 insertions(+), 55 deletions(-) diff --git a/Capy64/Runtime/Libraries/EventLib.cs b/Capy64/Runtime/Libraries/EventLib.cs index 2170596..c3fbed1 100644 --- a/Capy64/Runtime/Libraries/EventLib.cs +++ b/Capy64/Runtime/Libraries/EventLib.cs @@ -37,16 +37,6 @@ public class EventLib : IComponent private static readonly LuaRegister[] Library = new LuaRegister[] { - new() - { - name = "pull", - function = L_Pull, - }, - new() - { - name = "pullRaw", - function = L_PullRaw - }, new() { name = "push", @@ -92,50 +82,6 @@ public class EventLib : IComponent return 1; } - private static int LK_Pull(IntPtr state, int status, IntPtr ctx) - { - var L = Lua.FromIntPtr(state); - - if (L.ToString(1) == "interrupt") - { - L.Error("interrupt"); - } - - var nargs = L.GetTop(); - - return nargs; - } - - public static int L_Pull(IntPtr state) - { - var L = Lua.FromIntPtr(state); - - var nargs = L.GetTop(); - for (int i = 1; i <= nargs; i++) - { - L.CheckString(i); - } - - L.YieldK(nargs, 0, LK_Pull); - - return 0; - } - - private static int L_PullRaw(IntPtr state) - { - var L = Lua.FromIntPtr(state); - - var nargs = L.GetTop(); - for (int i = 1; i <= nargs; i++) - { - L.CheckString(i); - } - - L.Yield(nargs); - - return 0; - } - private static int L_Push(IntPtr state) { var L = Lua.FromIntPtr(state); diff --git a/Capy64/Runtime/Objects/Task.cs b/Capy64/Runtime/Objects/Task.cs index 9134581..e2143f1 100644 --- a/Capy64/Runtime/Objects/Task.cs +++ b/Capy64/Runtime/Objects/Task.cs @@ -255,7 +255,9 @@ public class TaskMeta : IComponent private static void WaitForTask(Lua L) { - L.PushCFunction(Libraries.EventLib.L_Pull); + L.PushString("coroutine"); + L.GetTable(-1); + L.GetField(-1, "yield"); L.PushString("task_finish"); L.CallK(1, 4, 0, LK_Await); }