Files
mir_server/sdk/tolua++/lua/custom_hide.lua
aixianling 5c9f1dae4a init
2025-01-09 17:45:40 +08:00

22 lines
744 B
Lua

-- extract code with tolua_hide, and also
function extract_code(fn,s)
local code = '\n$#include "'..fn..'"\n'
s= "\n" .. s .. "\n" -- add blank lines as sentinels
local _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n")
while e do
t = strlower(t)
if t == "begin" then
_,e,c = strfind(s,"(.-)\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[Ee][Nn][Dd][^\n]*\n",e)
if not e then
tolua_error("Unbalanced 'tolua_begin' directive in header file")
end
end
c = c.."\n"
c = string.gsub(c, "\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[hH][iI][Dd][eE][^\n]*\n", "\n");
c = string.gsub(c, "#define[^%(\n]*%(.-\n", "\n")
code = code .. c
_,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n",e)
end
return code
end