diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-10-03 21:25:04 +0200 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-10-03 21:25:04 +0200 |
commit | aafef187ef856a36c3f8e599afea2dee44f08904 (patch) | |
tree | c84762cc768da2800a0f80b902c704e782bd29ef /tolua++-1.0.93/src/bin/lua/custom.lua | |
parent | MCServer c++ source files (diff) | |
download | cuberite-aafef187ef856a36c3f8e599afea2dee44f08904.tar cuberite-aafef187ef856a36c3f8e599afea2dee44f08904.tar.gz cuberite-aafef187ef856a36c3f8e599afea2dee44f08904.tar.bz2 cuberite-aafef187ef856a36c3f8e599afea2dee44f08904.tar.lz cuberite-aafef187ef856a36c3f8e599afea2dee44f08904.tar.xz cuberite-aafef187ef856a36c3f8e599afea2dee44f08904.tar.zst cuberite-aafef187ef856a36c3f8e599afea2dee44f08904.zip |
Diffstat (limited to 'tolua++-1.0.93/src/bin/lua/custom.lua')
-rw-r--r-- | tolua++-1.0.93/src/bin/lua/custom.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tolua++-1.0.93/src/bin/lua/custom.lua b/tolua++-1.0.93/src/bin/lua/custom.lua new file mode 100644 index 000000000..293175ef9 --- /dev/null +++ b/tolua++-1.0.93/src/bin/lua/custom.lua @@ -0,0 +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
|