From f9f56c806372014c5c133d45b7cadbd6c3af0ce5 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Sun, 12 Feb 2023 11:19:29 +0100 Subject: [PATCH] Rename Metatable functions --- Capy64/Runtime/Objects/FileHandle.cs | 10 +++++----- Capy64/Runtime/Objects/GPUBuffer.cs | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Capy64/Runtime/Objects/FileHandle.cs b/Capy64/Runtime/Objects/FileHandle.cs index ffabbca..07a12cc 100644 --- a/Capy64/Runtime/Objects/FileHandle.cs +++ b/Capy64/Runtime/Objects/FileHandle.cs @@ -57,17 +57,17 @@ public class FileHandle : IPlugin new() { name = "__gc", - function = F_GC, + function = LM_GC, }, new() { name = "__close", - function = F_GC, + function = LM_GC, }, new() { name = "__tostring", - function = F_ToString, + function = LM_ToString, }, new(), @@ -307,7 +307,7 @@ public class FileHandle : IPlugin return 0; } - private static unsafe int F_ToString(IntPtr state) + private static unsafe int LM_ToString(IntPtr state) { var L = Lua.FromIntPtr(state); var stream = ToStream(L); @@ -322,7 +322,7 @@ public class FileHandle : IPlugin return 1; } - private static int F_GC(IntPtr state) + private static int LM_GC(IntPtr state) { var L = Lua.FromIntPtr(state); diff --git a/Capy64/Runtime/Objects/GPUBuffer.cs b/Capy64/Runtime/Objects/GPUBuffer.cs index ddbf6e7..07f95a3 100644 --- a/Capy64/Runtime/Objects/GPUBuffer.cs +++ b/Capy64/Runtime/Objects/GPUBuffer.cs @@ -59,13 +59,11 @@ public class GPUBuffer : IPlugin public static uint[] ToBuffer(Lua L, bool gc = false) { return ObjectManager.ToObject(L, 1, gc); - //return L.CheckObject(1, ObjectType, gc); } public static uint[] CheckBuffer(Lua L, bool gc = false) { var obj = ObjectManager.CheckObject(L, 1, ObjectType, gc); - //var obj = L.CheckObject(1, ObjectType, gc); if (obj is null) { L.Error("attempt to use a closed buffer"); @@ -164,14 +162,18 @@ public class GPUBuffer : IPlugin return 1; } - private static int LM_ToString(IntPtr state) + private static unsafe int LM_ToString(IntPtr state) { var L = Lua.FromIntPtr(state); - - var buffer = CheckBuffer(L, false); - - L.PushString(ObjectType); - + var buffer = ToBuffer(L); + if (buffer is not null) + { + L.PushString("GPUBuffer ({0:X})", (ulong)&buffer); + } + else + { + L.PushString("GPUBuffer (closed)"); + } return 1; } }