Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/tolua/lua/custom.lua @ 10054

Last change on this file since 10054 was 5738, checked in by landauf, 15 years ago

merged libraries2 back to trunk

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1
2function extract_code(fn,s)
3    local code = ""
4    if fn then
5        code = '\n$#include "'..fn..'"\n'
6    end
7    s= "\n" .. s .. "\n" -- add blank lines as sentinels
8    local _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n")
9    while e do
10        t = strlower(t)
11        if t == "bind_begin" then
12            _,e,c = strfind(s,"(.-)\n[^\n]*SCRIPT_BIND_END[^\n]*\n",e)
13            if not e then
14             tolua_error("Unbalanced 'SCRIPT_BIND_BEGIN' directive in header file")
15            end
16        end
17        if t == "bind_class" or t == "bind_block" then
18            local b
19            _,e,c,b = string.find(s, "([^{]-)(%b{})", e)
20            c = c..'{\n'..extract_code(nil, b)..'\n};\n'
21        end
22        code = code .. c .. "\n"
23     _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n",e)
24    end
25    return code
26end
27
28function preprocess_hook(p)
29end
30
31function preparse_hook(p)
32end
33
34function include_file_hook(p, filename)
35    do return end
36--print("FILENAME is "..filename)
37    p.code = string.gsub(p.code, "\n%s*SigC::Signal", "\n\ttolua_readonly SigC::Signal")
38    p.code = string.gsub(p.code, "#ifdef __cplusplus\nextern \"C\" {\n#endif", "")
39    p.code = string.gsub(p.code, "#ifdef __cplusplus\n};?\n#endif", "")
40    p.code = string.gsub(p.code, "DECLSPEC", "")
41    p.code = string.gsub(p.code, "SDLCALL", "")
42    p.code = string.gsub(p.code, "DLLINTERFACE", "")
43    p.code = string.gsub(p.code, "#define[^\n]*_[hH]_?%s*\n", "\n")
44--print("code is "..p.code)
45end
Note: See TracBrowser for help on using the repository browser.