Skip to content

Commit

Permalink
Rename Metatable functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ale32bit committed Feb 12, 2023
1 parent 5dddc42 commit f9f56c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
10 changes: 5 additions & 5 deletions Capy64/Runtime/Objects/FileHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -307,7 +307,7 @@ private static int L_Close(IntPtr state)
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);
Expand All @@ -322,7 +322,7 @@ private static unsafe int F_ToString(IntPtr state)
return 1;
}

private static int F_GC(IntPtr state)
private static int LM_GC(IntPtr state)
{
var L = Lua.FromIntPtr(state);

Expand Down
18 changes: 10 additions & 8 deletions Capy64/Runtime/Objects/GPUBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ public static void CreateMeta(Lua L)
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");
Expand Down Expand Up @@ -164,14 +162,18 @@ private static int LM_Length(IntPtr state)
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;
}
}

0 comments on commit f9f56c8

Please sign in to comment.