Rename Metatable functions

This commit is contained in:
Alessandro Proto 2023-02-12 11:19:29 +01:00
parent 5dddc42910
commit f9f56c8063
2 changed files with 15 additions and 13 deletions

View file

@ -57,17 +57,17 @@ public class FileHandle : IPlugin
new() new()
{ {
name = "__gc", name = "__gc",
function = F_GC, function = LM_GC,
}, },
new() new()
{ {
name = "__close", name = "__close",
function = F_GC, function = LM_GC,
}, },
new() new()
{ {
name = "__tostring", name = "__tostring",
function = F_ToString, function = LM_ToString,
}, },
new(), new(),
@ -307,7 +307,7 @@ public class FileHandle : IPlugin
return 0; return 0;
} }
private static unsafe int F_ToString(IntPtr state) private static unsafe int LM_ToString(IntPtr state)
{ {
var L = Lua.FromIntPtr(state); var L = Lua.FromIntPtr(state);
var stream = ToStream(L); var stream = ToStream(L);
@ -322,7 +322,7 @@ public class FileHandle : IPlugin
return 1; return 1;
} }
private static int F_GC(IntPtr state) private static int LM_GC(IntPtr state)
{ {
var L = Lua.FromIntPtr(state); var L = Lua.FromIntPtr(state);

View file

@ -59,13 +59,11 @@ public class GPUBuffer : IPlugin
public static uint[] ToBuffer(Lua L, bool gc = false) public static uint[] ToBuffer(Lua L, bool gc = false)
{ {
return ObjectManager.ToObject<uint[]>(L, 1, gc); return ObjectManager.ToObject<uint[]>(L, 1, gc);
//return L.CheckObject<uint[]>(1, ObjectType, gc);
} }
public static uint[] CheckBuffer(Lua L, bool gc = false) public static uint[] CheckBuffer(Lua L, bool gc = false)
{ {
var obj = ObjectManager.CheckObject<uint[]>(L, 1, ObjectType, gc); var obj = ObjectManager.CheckObject<uint[]>(L, 1, ObjectType, gc);
//var obj = L.CheckObject<uint[]>(1, ObjectType, gc);
if (obj is null) if (obj is null)
{ {
L.Error("attempt to use a closed buffer"); L.Error("attempt to use a closed buffer");
@ -164,14 +162,18 @@ public class GPUBuffer : IPlugin
return 1; return 1;
} }
private static int LM_ToString(IntPtr state) private static unsafe int LM_ToString(IntPtr state)
{ {
var L = Lua.FromIntPtr(state); var L = Lua.FromIntPtr(state);
var buffer = ToBuffer(L);
var buffer = CheckBuffer(L, false); if (buffer is not null)
{
L.PushString(ObjectType); L.PushString("GPUBuffer ({0:X})", (ulong)&buffer);
}
else
{
L.PushString("GPUBuffer (closed)");
}
return 1; return 1;
} }
} }