-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlua_features.cpp
More file actions
53 lines (45 loc) · 1.38 KB
/
lua_features.cpp
File metadata and controls
53 lines (45 loc) · 1.38 KB
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
#include <string>
#include "lua_features.h"
std::string lua_code::lemi_code = u8R"(local _isfunction = isfunction
local _string_sub = string.sub
local _istable = istable
local _pairs = pairs
local _tostring = tostring
local _string_byte = string.byte
local _debug_getinfo = debug.getinfo
local _debug_getregistry = debug.getregistry
local funcs = {}
local funcsBlacklist = {}
funcsBlacklist[_tostring] = true
funcsBlacklist[_string_byte] = true
funcsBlacklist[_string_sub] = true
local tablesBlacklist = {}
tablesBlacklist[package] = true
tablesBlacklist[math] = true
tablesBlacklist[bit] = true
tablesBlacklist[chat] = true
tablesBlacklist[mesh] = true
local function iter(t, name, done)
done = done or {}
done[t] = true
for k, v in _pairs(t) do
local newname = name .. '.' .. _tostring(k)
if (_istable(v) and not done[v] and not tablesBlacklist[v]) then
iter(v, newname, done)
elseif (_isfunction(v)) then
local info = _debug_getinfo(v)
if (info and info.short_src == "[C]" and not funcsBlacklist[v] and not funcs[v]) then
funcs[v] = newname
end
end
end
end
local _R = _debug_getregistry()
iter(_G, "_G")
iter(_R.CMoveData, "_R.CMoveData")
iter(_R.CUserCmd, "_R.CUserCmd")
iter(_R.Entity, "_R.Entity")
iter(_R.Player, "_R.Player")
iter(_R.File, "_R.File")
iter(_R.ConVar, "_R.ConVar")
)";