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()
{
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);

View file

@ -59,13 +59,11 @@ public class GPUBuffer : IPlugin
public static uint[] ToBuffer(Lua L, bool gc = false)
{
return ObjectManager.ToObject<uint[]>(L, 1, gc);
//return L.CheckObject<uint[]>(1, ObjectType, gc);
}
public static uint[] CheckBuffer(Lua L, bool gc = false)
{
var obj = ObjectManager.CheckObject<uint[]>(L, 1, ObjectType, gc);
//var obj = L.CheckObject<uint[]>(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;
}
}