summaryrefslogtreecommitdiffstats
path: root/tolua++-1.0.93/src/bin/lua/doit.lua
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-10-03 21:25:04 +0200
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-10-03 21:25:04 +0200
commitaafef187ef856a36c3f8e599afea2dee44f08904 (patch)
treec84762cc768da2800a0f80b902c704e782bd29ef /tolua++-1.0.93/src/bin/lua/doit.lua
parentMCServer c++ source files (diff)
downloadcuberite-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/doit.lua')
-rw-r--r--tolua++-1.0.93/src/bin/lua/doit.lua101
1 files changed, 101 insertions, 0 deletions
diff --git a/tolua++-1.0.93/src/bin/lua/doit.lua b/tolua++-1.0.93/src/bin/lua/doit.lua
new file mode 100644
index 000000000..4ddfc61fa
--- /dev/null
+++ b/tolua++-1.0.93/src/bin/lua/doit.lua
@@ -0,0 +1,101 @@
+-- Generate binding code
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- Last update: Apr 2003
+-- $Id: $
+
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+function parse_extra()
+
+ for k,v in ipairs(_extra_parameters or {}) do
+
+ local b,e,name,value = string.find(v, "^([^=]*)=(.*)$")
+ if b then
+ _extra_parameters[name] = value
+ else
+ _extra_parameters[v] = true
+ end
+ end
+end
+
+function doit ()
+ -- define package name, if not provided
+ if not flags.n then
+ if flags.f then
+ flags.n = gsub(flags.f,"%..*$","")
+ _,_,flags.n = string.find(flags.n, "([^/\\]*)$")
+ else
+ error("#no package name nor input file provided")
+ end
+ end
+
+ -- parse table with extra paramters
+ parse_extra()
+
+ -- do this after setting the package name
+ if flags['L'] then
+ dofile(flags['L'])
+ end
+
+ -- add cppstring
+ if not flags['S'] then
+ _basic['string'] = 'cppstring'
+ _basic['std::string'] = 'cppstring'
+ _basic_ctype.cppstring = 'const char*'
+ end
+
+ -- proccess package
+ local p = Package(flags.n,flags.f)
+
+ if flags.p then
+ return -- only parse
+ end
+
+ if flags.o then
+ local st,msg = writeto(flags.o)
+ if not st then
+ error('#'..msg)
+ end
+ end
+
+ p:decltype()
+ if flags.P then
+ p:print()
+ else
+ push(p)
+ pre_output_hook(p)
+ pop()
+ p:preamble()
+ p:supcode()
+ push(p)
+ pre_register_hook(p)
+ pop()
+ p:register()
+ push(p)
+ post_output_hook(p)
+ pop()
+ end
+
+ if flags.o then
+ writeto()
+ end
+
+ -- write header file
+ if not flags.P then
+ if flags.H then
+ local st,msg = writeto(flags.H)
+ if not st then
+ error('#'..msg)
+ end
+ p:header()
+ writeto()
+ end
+ end
+end
+