forked from cheat-engine/cheat-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LuaCollection.pas
executable file
·68 lines (51 loc) · 1.73 KB
/
LuaCollection.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
unit LuaCollection;
{$mode delphi}
interface
uses
Classes, SysUtils,Lua, Lualib, lauxlib;
procedure collection_addMetaData(L: PLua_state; metatable: integer; userdata: integer );
procedure initializeLuaCollection;
implementation
uses luaclass, luahandler, LuaObject;
function collection_clear(L: Plua_State): integer; cdecl;
var
collection: TCollection;
begin
collection:=luaclass_getClassObject(L);
collection.clear;
result:=0;
end;
function collection_getCount(L: PLua_State): integer; cdecl;
var
collection: TCollection;
begin
collection:=luaclass_getClassObject(L);
lua_pushinteger(L, collection.Count);
result:=1;
end;
function collection_delete(L: Plua_State): integer; cdecl;
var
collection: TCollection;
begin
collection:=luaclass_getClassObject(L);
if lua_gettop(L)>=1 then
collection.Delete(lua_tointeger(L, -1));
result:=0;
end;
procedure collection_addMetaData(L: PLua_state; metatable: integer; userdata: integer );
begin
object_addMetaData(L, metatable, userdata);
luaclass_addClassFunctionToTable(L, metatable, userdata, 'clear', collection_clear);
luaclass_addClassFunctionToTable(L, metatable, userdata, 'getCount', collection_getCount);
luaclass_addClassFunctionToTable(L, metatable, userdata, 'delete', collection_delete);
luaclass_addPropertyToTable(L, metatable, userdata, 'Count', collection_getCount, nil);
end;
procedure initializeLuaCollection;
begin
lua_register(LuaVM, 'collection_clear', collection_clear);
lua_register(LuaVM, 'collection_getCount', collection_getCount);
lua_register(LuaVM, 'collection_delete', collection_delete);
end;
initialization
luaclass_register(Tcollection, collection_addMetaData);
end.