diff options
Diffstat (limited to 'tolua++-1.0.93/src/bin')
-rw-r--r-- | tolua++-1.0.93/src/bin/lua/compat-5.1.lua | 114 | ||||
-rw-r--r-- | tolua++-1.0.93/src/bin/lua/custom.lua | 90 |
2 files changed, 102 insertions, 102 deletions
diff --git a/tolua++-1.0.93/src/bin/lua/compat-5.1.lua b/tolua++-1.0.93/src/bin/lua/compat-5.1.lua index c2642d3a6..7a2c60b69 100644 --- a/tolua++-1.0.93/src/bin/lua/compat-5.1.lua +++ b/tolua++-1.0.93/src/bin/lua/compat-5.1.lua @@ -1,57 +1,57 @@ -if string.find(_VERSION, "5%.0") then
- return
-end
-
--- "loadfile"
-local function pp_dofile(path)
-
- local loaded = false
- local getfile = function()
-
- if loaded then
- return
- else
- local file,err = io.open(path)
- if not file then
- error("error loading file "..path..": "..err)
- end
- local ret = file:read("*a")
- file:close()
-
- ret = string.gsub(ret, "%.%.%.%s*%)", "...) local arg = {n=select('#', ...), ...};")
-
- loaded = true
- return ret
- end
- end
-
- local f = load(getfile, path)
- if not f then
-
- error("error loading file "..path)
- end
- return f()
-end
-
-old_dofile = dofile
-dofile = pp_dofile
-
-
--- string.gsub
---[[
-local ogsub = string.gsub
-local function compgsub(a,b,c,d)
- if type(c) == "function" then
- local oc = c
- c = function (...) return oc(...) or '' end
- end
- return ogsub(a,b,c,d)
-end
-string.repl = ogsub
---]]
-
---string.gsub = compgsub
-
-
-
-
+if string.find(_VERSION, "5%.0") then + return +end + +-- "loadfile" +local function pp_dofile(path) + + local loaded = false + local getfile = function() + + if loaded then + return + else + local file,err = io.open(path) + if not file then + error("error loading file "..path..": "..err) + end + local ret = file:read("*a") + file:close() + + ret = string.gsub(ret, "%.%.%.%s*%)", "...) local arg = {n=select('#', ...), ...};") + + loaded = true + return ret + end + end + + local f = load(getfile, path) + if not f then + + error("error loading file "..path) + end + return f() +end + +old_dofile = dofile +dofile = pp_dofile + + +-- string.gsub +--[[ +local ogsub = string.gsub +local function compgsub(a,b,c,d) + if type(c) == "function" then + local oc = c + c = function (...) return oc(...) or '' end + end + return ogsub(a,b,c,d) +end +string.repl = ogsub +--]] + +--string.gsub = compgsub + + + + diff --git a/tolua++-1.0.93/src/bin/lua/custom.lua b/tolua++-1.0.93/src/bin/lua/custom.lua index 293175ef9..de5912fb3 100644 --- a/tolua++-1.0.93/src/bin/lua/custom.lua +++ b/tolua++-1.0.93/src/bin/lua/custom.lua @@ -1,45 +1,45 @@ -
-function extract_code(fn,s)
- local code = ""
- if fn then
- code = '\n$#include "'..fn..'"\n'
- end
- s= "\n" .. s .. "\n" -- add blank lines as sentinels
- local _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n")
- while e do
- t = strlower(t)
- if t == "bind_begin" then
- _,e,c = strfind(s,"(.-)\n[^\n]*SCRIPT_BIND_END[^\n]*\n",e)
- if not e then
- tolua_error("Unbalanced 'SCRIPT_BIND_BEGIN' directive in header file")
- end
- end
- if t == "bind_class" or t == "bind_block" then
- local b
- _,e,c,b = string.find(s, "([^{]-)(%b{})", e)
- c = c..'{\n'..extract_code(nil, b)..'\n};\n'
- end
- code = code .. c .. "\n"
- _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n",e)
- end
- return code
-end
-
-function preprocess_hook(p)
-end
-
-function preparse_hook(p)
-end
-
-function include_file_hook(p, filename)
- do return end
---print("FILENAME is "..filename)
- p.code = string.gsub(p.code, "\n%s*SigC::Signal", "\n\ttolua_readonly SigC::Signal")
- p.code = string.gsub(p.code, "#ifdef __cplusplus\nextern \"C\" {\n#endif", "")
- p.code = string.gsub(p.code, "#ifdef __cplusplus\n};?\n#endif", "")
- p.code = string.gsub(p.code, "DECLSPEC", "")
- p.code = string.gsub(p.code, "SDLCALL", "")
- p.code = string.gsub(p.code, "DLLINTERFACE", "")
- p.code = string.gsub(p.code, "#define[^\n]*_[hH]_?%s*\n", "\n")
---print("code is "..p.code)
-end
+ +function extract_code(fn,s) + local code = "" + if fn then + code = '\n$#include "'..fn..'"\n' + end + s= "\n" .. s .. "\n" -- add blank lines as sentinels + local _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n") + while e do + t = strlower(t) + if t == "bind_begin" then + _,e,c = strfind(s,"(.-)\n[^\n]*SCRIPT_BIND_END[^\n]*\n",e) + if not e then + tolua_error("Unbalanced 'SCRIPT_BIND_BEGIN' directive in header file") + end + end + if t == "bind_class" or t == "bind_block" then + local b + _,e,c,b = string.find(s, "([^{]-)(%b{})", e) + c = c..'{\n'..extract_code(nil, b)..'\n};\n' + end + code = code .. c .. "\n" + _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n",e) + end + return code +end + +function preprocess_hook(p) +end + +function preparse_hook(p) +end + +function include_file_hook(p, filename) + do return end +--print("FILENAME is "..filename) + p.code = string.gsub(p.code, "\n%s*SigC::Signal", "\n\ttolua_readonly SigC::Signal") + p.code = string.gsub(p.code, "#ifdef __cplusplus\nextern \"C\" {\n#endif", "") + p.code = string.gsub(p.code, "#ifdef __cplusplus\n};?\n#endif", "") + p.code = string.gsub(p.code, "DECLSPEC", "") + p.code = string.gsub(p.code, "SDLCALL", "") + p.code = string.gsub(p.code, "DLLINTERFACE", "") + p.code = string.gsub(p.code, "#define[^\n]*_[hH]_?%s*\n", "\n") +--print("code is "..p.code) +end |