moved code for coherence
This commit is contained in:
29
src/lua_func/tm.lua
Normal file
29
src/lua_func/tm.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
local tm = {}
|
||||
|
||||
local SUPPORTED_API = {
|
||||
"gd",
|
||||
"setgd",
|
||||
"delgd",
|
||||
}
|
||||
|
||||
-- underlying function
|
||||
|
||||
function tm._init_api(rpc)
|
||||
tm._rpc = rpc
|
||||
|
||||
local function _api_request(fname, ...)
|
||||
local args = {...}
|
||||
return tm._rpc:call(fname, args)
|
||||
end
|
||||
|
||||
for _, fname in ipairs(SUPPORTED_API) do
|
||||
-- create a closure that calls common_handler with fname
|
||||
tm[fname] = function(...)
|
||||
return _api_request(fname, ...)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return tm
|
||||
Reference in New Issue
Block a user