Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 17, 2008, 8:59:48 PM (15 years ago)
Author:
rgrieder
Message:

Merged revisions 1875-2278 of the buildsystem branch to buildsystem2.

Location:
code/branches/buildsystem2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/buildsystem2

  • code/branches/buildsystem2/src/tolua/lua/custom.lua

    r2087 r2509  
    11
    22function 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
     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
    2626end
    2727
     
    3333
    3434function include_file_hook(p, filename)
    35         do return end
     35    do return end
    3636--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")
     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")
    4444--print("code is "..p.code)
    4545end
Note: See TracChangeset for help on using the changeset viewer.