mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 18:46:43 +00:00
Add length metamethod to GPUBuffer
This commit is contained in:
parent
9fad3258c5
commit
3a7914ee6d
1 changed files with 15 additions and 0 deletions
|
@ -27,6 +27,10 @@ public class GPUBuffer
|
||||||
L.PushCFunction(LM_NewIndex);
|
L.PushCFunction(LM_NewIndex);
|
||||||
L.SetTable(-3);
|
L.SetTable(-3);
|
||||||
|
|
||||||
|
L.PushString("__len");
|
||||||
|
L.PushCFunction(LM_Length);
|
||||||
|
L.SetTable(-3);
|
||||||
|
|
||||||
L.PushString("__gc");
|
L.PushString("__gc");
|
||||||
L.PushCFunction(LM_GC);
|
L.PushCFunction(LM_GC);
|
||||||
L.SetTable(-3);
|
L.SetTable(-3);
|
||||||
|
@ -114,4 +118,15 @@ public class GPUBuffer
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int LM_Length(IntPtr state)
|
||||||
|
{
|
||||||
|
var L = Lua.FromIntPtr(state);
|
||||||
|
|
||||||
|
var buffer = L.CheckObject<uint[]>(1, ObjectType, false);
|
||||||
|
|
||||||
|
L.PushInteger(buffer.LongLength);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue