Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core4/src/tolua/lua/custom.lua @ 3607

Last change on this file since 3607 was 2710, checked in by rgrieder, 16 years ago

Merged buildsystem3 containing buildsystem2 containing Adi's buildsystem branch back to the trunk.
Please update the media directory if you were not using buildsystem3 before.

  • 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.