summaryrefslogtreecommitdiff
path: root/ThirdParty/tolua-5.2.4/src/bin/lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-11-08 10:53:42 +0800
committerchai <chaifix@163.com>2021-11-08 10:53:42 +0800
commit5f46b4102c179680d613b6b9e0e6d392318030d2 (patch)
tree16527828dc89133f7af41acf6f5c13c23743e7ef /ThirdParty/tolua-5.2.4/src/bin/lua
parent138d3f4d3d6e2aaf5ba34f89af15ef85ea074357 (diff)
+ tolua
Diffstat (limited to 'ThirdParty/tolua-5.2.4/src/bin/lua')
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._all.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._array.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._basic.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._class.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._clean.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._code.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._compat.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._container.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._declaration.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._define.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._doit.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._enumerate.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._feature.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._function.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._module.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._namespace.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._operator.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._package.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._typedef.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._variable.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/._verbatim.luabin0 -> 280 bytes
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/all.lua26
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/array.lua208
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/basic.lua214
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/class.lua120
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/clean.lua75
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/code.lua73
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/compat.lua201
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/container.lua536
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/declaration.lua482
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/define.lua58
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/doit.lua63
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/enumerate.lua83
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/feature.lua101
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/function.lua402
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/module.lua67
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/namespace.lua52
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/operator.lua113
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/package.lua280
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/typedef.lua68
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/variable.lua253
-rw-r--r--ThirdParty/tolua-5.2.4/src/bin/lua/verbatim.lua76
42 files changed, 3551 insertions, 0 deletions
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._all.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._all.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._all.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._array.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._array.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._array.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._basic.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._basic.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._basic.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._class.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._class.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._class.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._clean.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._clean.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._clean.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._code.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._code.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._code.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._compat.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._compat.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._compat.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._container.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._container.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._container.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._declaration.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._declaration.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._declaration.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._define.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._define.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._define.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._doit.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._doit.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._doit.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._enumerate.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._enumerate.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._enumerate.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._feature.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._feature.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._feature.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._function.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._function.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._function.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._module.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._module.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._module.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._namespace.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._namespace.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._namespace.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._operator.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._operator.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._operator.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._package.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._package.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._package.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._typedef.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._typedef.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._typedef.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._variable.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._variable.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._variable.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/._verbatim.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/._verbatim.lua
new file mode 100644
index 0000000..313e184
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/._verbatim.lua
Binary files differ
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/all.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/all.lua
new file mode 100644
index 0000000..eadf600
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/all.lua
@@ -0,0 +1,26 @@
+dofile(path.."compat.lua")
+dofile(path.."basic.lua")
+dofile(path.."feature.lua")
+dofile(path.."verbatim.lua")
+dofile(path.."code.lua")
+dofile(path.."typedef.lua")
+dofile(path.."container.lua")
+dofile(path.."package.lua")
+dofile(path.."module.lua")
+dofile(path.."namespace.lua")
+dofile(path.."define.lua")
+dofile(path.."enumerate.lua")
+dofile(path.."declaration.lua")
+dofile(path.."variable.lua")
+dofile(path.."array.lua")
+dofile(path.."function.lua")
+dofile(path.."operator.lua")
+dofile(path.."class.lua")
+dofile(path.."clean.lua")
+dofile(path.."doit.lua")
+
+local err,msg = pcall(doit)
+if not err then
+ local _,_,label,msg = strfind(msg,"(.-:.-:%s*)(.*)")
+ tolua_error(msg,label)
+end
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/array.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/array.lua
new file mode 100644
index 0000000..7a9b1ad
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/array.lua
@@ -0,0 +1,208 @@
+-- tolua: array class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1999
+-- $Id: array.lua,v 1.4 2011/01/13 13:43:45 fabraham Exp $
+
+-- 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.
+
+
+-- Array class
+-- Represents a extern array variable or a public member of a class.
+-- Stores all fields present in a declaration.
+classArray = {
+}
+classArray.__index = classArray
+setmetatable(classArray,classDeclaration)
+
+-- Print method
+function classArray:print (ident,close)
+ print(ident.."Array{")
+ print(ident.." mod = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." def = '"..self.def.."',")
+ print(ident.." dim = '"..self.dim.."',")
+ print(ident.." ret = '"..self.ret.."',")
+ print(ident.."}"..close)
+end
+
+-- check if it is a variable
+function classArray:isvariable ()
+ return true
+end
+
+
+-- get variable value
+function classArray:getvalue (class,static)
+ if class and static then
+ return class..'::'..self.name..'[tolua_index]'
+ elseif class then
+ return 'self->'..self.name..'[tolua_index]'
+ else
+ return self.name..'[tolua_index]'
+ end
+end
+
+-- Write binding functions
+function classArray:supcode ()
+ local class = self:inclass()
+
+ -- get function ------------------------------------------------
+ if class then
+ output("/* get function:",self.name," of class ",class," */")
+ else
+ output("/* get function:",self.name," */")
+ end
+ self.cgetname = self:cfuncname("tolua_get")
+ output("static int",self.cgetname,"(lua_State* tolua_S)")
+ output("{")
+ output(" int tolua_index;")
+
+ -- declare self, if the case
+ local _,_,static = strfind(self.mod,'^%s*(static)')
+ if class and static==nil then
+ output(' ',self.parent.type,'*','self;')
+ output(' lua_pushstring(tolua_S,".self");')
+ output(' lua_rawget(tolua_S,1);')
+ output(' self = ')
+ output('(',class,'*) ')
+ output('lua_touserdata(tolua_S,-1);')
+ elseif static then
+ _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+ end
+
+ -- check index
+ output('#ifndef TOLUA_RELEASE\n')
+ output(' {')
+ output(' tolua_Error tolua_err;')
+ output(' if (!tolua_isnumber(tolua_S,2,0,&tolua_err))')
+ output(' tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);')
+ output(' }')
+ output('#endif\n')
+ output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;')
+ output('#ifndef TOLUA_RELEASE\n')
+ output(' if (tolua_index<0 || tolua_index>='..self.dim..')')
+ output(' tolua_error(tolua_S,"array indexing out of range.",NULL);')
+ output('#endif\n')
+
+ -- return value
+ local t,ct = isbasic(self.type)
+ if t then
+ output(' tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static)..');')
+ else
+ t = self.type
+ if self.ptr == '&' or self.ptr == '' then
+ output(' tolua_pushusertype(tolua_S,(void*)&'..self:getvalue(class,static)..',"',t,'");')
+ else
+ output(' tolua_pushusertype(tolua_S,(void*)'..self:getvalue(class,static)..',"',t,'");')
+ end
+ end
+ output(' return 1;')
+ output('}')
+ output('\n')
+
+ -- set function ------------------------------------------------
+ if not strfind(self.type,'const') then
+ if class then
+ output("/* set function:",self.name," of class ",class," */")
+ else
+ output("/* set function:",self.name," */")
+ end
+ self.csetname = self:cfuncname("tolua_set")
+ output("static int",self.csetname,"(lua_State* tolua_S)")
+ output("{")
+
+ -- declare index
+ output(' int tolua_index;')
+
+ -- declare self, if the case
+ local _,_,static = strfind(self.mod,'^%s*(static)')
+ if class and static==nil then
+ output(' ',class,'*','self;')
+ output(' lua_pushstring(tolua_S,".self");')
+ output(' lua_rawget(tolua_S,1);')
+ output(' self = ')
+ output('(',class,'*) ')
+ output('lua_touserdata(tolua_S,-1);')
+ elseif static then
+ _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+ end
+
+ -- check index
+ output('#ifndef TOLUA_RELEASE\n')
+ output(' {')
+ output(' tolua_Error tolua_err;')
+ output(' if (!tolua_isnumber(tolua_S,2,0,&tolua_err))')
+ output(' tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);')
+ output(' }')
+ output('#endif\n')
+ output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;')
+ output('#ifndef TOLUA_RELEASE\n')
+ output(' if (tolua_index<0 || tolua_index>='..self.dim..')')
+ output(' tolua_error(tolua_S,"array indexing out of range.",NULL);')
+ output('#endif\n')
+
+ -- assign value
+ local ptr = ''
+ if self.ptr~='' then ptr = '*' end
+ output(' ')
+ if class and static then
+ output(class..'::'..self.name..'[tolua_index]')
+ elseif class then
+ output('self->'..self.name..'[tolua_index]')
+ else
+ output(self.name..'[tolua_index]')
+ end
+ local t = isbasic(self.type)
+ output(' = ')
+ if not t and ptr=='' then output('*') end
+ output('((',self.mod,self.type)
+ if not t then
+ output('*')
+ end
+ output(') ')
+ local def = 0
+ if self.def ~= '' then def = self.def end
+ if t then
+ if isenum(self.type) then
+ output('(int)')
+ end
+ if t=='function' then t='value' end
+ output('tolua_to'..t,'(tolua_S,3,',def,'));')
+ else
+ output('tolua_tousertype(tolua_S,3,',def,'));')
+ end
+ output(' return 0;')
+ output('}')
+ output('\n')
+ end
+
+end
+
+function classArray:register ()
+ if self.csetname then
+ output(' tolua_array(tolua_S,"'..self.lname..'",'..self.cgetname..','..self.csetname..');')
+ else
+ output(' tolua_array(tolua_S,"'..self.lname..'",'..self.cgetname..',NULL);')
+ end
+end
+
+-- Internal constructor
+function _Array (t)
+ setmetatable(t,classArray)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the variable declaration.
+function Array (s)
+ return _Array (Declaration(s,'var'))
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/basic.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/basic.lua
new file mode 100644
index 0000000..fc9d09d
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/basic.lua
@@ -0,0 +1,214 @@
+-- tolua: basic utility functions
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- Last update: Apr 2003
+-- $Id: basic.lua,v 1.4 2009/11/24 16:45:13 fabraham Exp $
+
+-- 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.
+
+
+-- Basic C types and their corresponding Lua types
+-- All occurrences of "char*" will be replaced by "_cstring",
+-- and all occurrences of "void*" will be replaced by "_userdata"
+_basic = {
+ ['void'] = '',
+ ['char'] = 'number',
+ ['tolua_index'] = 'number',
+ ['tolua_len'] = 'number',
+ ['tolua_byte'] = 'number',
+ ['tolua_ubyte'] = 'number',
+ ['tolua_multret'] = 'number',
+ ['int'] = 'number',
+ ['short'] = 'number',
+ ['long'] = 'number',
+ ['unsigned'] = 'number',
+ ['float'] = 'number',
+ ['double'] = 'number',
+ ['_cstring'] = 'string',
+ ['_userdata'] = 'userdata',
+ ['char*'] = 'string',
+ ['void*'] = 'userdata',
+ ['bool'] = 'boolean',
+ ['lua_State*'] = 'state',
+ ['_lstate'] = 'state',
+ ['lua_Object'] = 'value',
+ ['lua_Function'] = 'function',
+ ['LUA_VALUE'] = 'value', -- for compatibility with tolua 4.0
+}
+
+_basic_ctype = {
+ number = "lua_Number",
+ string = "const char*",
+ userdata = "void*",
+ boolean = "bool",
+ value = "int",
+}
+
+-- List of user defined types
+-- Each type corresponds to a variable name that stores its tag value.
+_usertype = {}
+
+-- List of types that have to be collected
+_collect = {}
+
+
+-- List of auto renaming
+_renaming = {}
+function appendrenaming (s)
+ local b,e,old,new = strfind(s,"%s*(.-)%s*@%s*(.-)%s*$")
+ if not b then
+ error("#Invalid renaming syntax; it should be of the form: pattern@pattern")
+ end
+ tinsert(_renaming,{old=old, new=new})
+end
+
+function applyrenaming (s)
+ for i=1,getn(_renaming) do
+ local m,n = gsub(s,_renaming[i].old,_renaming[i].new)
+ if n ~= 0 then
+ return m
+ end
+ end
+ return nil
+end
+
+-- Error handler
+function tolua_error (s,f)
+ local out = _OUTPUT
+ _OUTPUT = _STDERR
+ if strsub(s,1,1) == '#' then
+ write("\n** tolua: "..strsub(s,2)..".\n\n")
+ if _curr_code then
+ local _,_,s = strfind(_curr_code,"^%s*(.-\n)") -- extract first line
+ if s==nil then s = _curr_code end
+ s = gsub(s,"_userdata","void*") -- return with 'void*'
+ s = gsub(s,"_cstring","char*") -- return with 'char*'
+ s = gsub(s,"_lstate","lua_State*") -- return with 'lua_State*'
+ write("Code being processed:\n"..s.."\n")
+ end
+ else
+ print(debug.traceback("\n** tolua internal error: "..f..s..".\n\n"))
+ return
+ end
+ _OUTPUT = out
+end
+
+function warning (msg)
+ local out = _OUTPUT
+ _OUTPUT = _STDERR
+ write("\n** tolua warning: "..msg..".\n\n")
+ _OUTPUT = out
+end
+
+-- register an user defined type: returns full type
+function regtype (t)
+ local ft = findtype(t)
+ if isbasic(t) then
+ return t
+ end
+ if not ft then
+ return appendusertype(t)
+ end
+end
+
+-- return type name: returns full type
+function typevar(type)
+ if type == '' or type == 'void' or type == "..." then
+ return type
+ else
+ local ft = findtype(type)
+ if ft then
+ return ft
+ end
+ _usertype[type] = type
+ return type
+ end
+end
+
+-- check if basic type
+function isbasic (type)
+ local t = gsub(type,'const ','')
+ local m,t = applytypedef(t)
+ local b = _basic[t]
+ if b then
+ return b,_basic_ctype[b]
+ end
+ return nil
+end
+
+-- split string using a token
+function split (s,t)
+ local l = {n=0}
+ local f = function (s)
+ l.n = l.n + 1
+ l[l.n] = s
+ return ""
+ end
+ local p = "%s*(.-)%s*"..t.."%s*"
+ s = gsub(s,"^%s+","")
+ s = gsub(s,"%s+$","")
+ s = gsub(s,p,f)
+ l.n = l.n + 1
+ l[l.n] = gsub(s,"(%s%s*)$","")
+ return l
+end
+
+
+-- concatenate strings of a table
+function concat (t,f,l)
+ local s = ''
+ local i=f
+ while i<=l do
+ s = s..t[i]
+ i = i+1
+ if i <= l then s = s..' ' end
+ end
+ return s
+end
+
+-- concatenate all parameters, following output rules
+function concatparam (line, ...)
+ local arg = {...}
+ local i=1
+ while i<=#arg do
+ if _cont and not strfind(_cont,'[%(,"]') and
+ strfind(arg[i],"^[%a_~]") then
+ line = line .. ' '
+ end
+ line = line .. arg[i]
+ if arg[i] ~= '' then
+ _cont = strsub(arg[i],-1,-1)
+ end
+ i = i+1
+ end
+ if strfind(arg[#arg],"[%/%)%;%{%}]$") then
+ _cont=nil line = line .. '\n'
+ end
+ return line
+end
+
+-- output line
+function output (...)
+ local arg = {...}
+ local i=1
+ while i<=#arg do
+ if _cont and not strfind(_cont,'[%(,"]') and
+ strfind(arg[i],"^[%a_~]") then
+ write(' ')
+ end
+ write(arg[i])
+ if arg[i] ~= '' then
+ _cont = strsub(arg[i],-1,-1)
+ end
+ i = i+1
+ end
+ if strfind(arg[#arg],"[%/%)%;%{%}]$") then
+ _cont=nil write('\n')
+ end
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/class.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/class.lua
new file mode 100644
index 0000000..bf38405
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/class.lua
@@ -0,0 +1,120 @@
+-- tolua: class class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: class.lua,v 1.3 2009/11/24 16:45:13 fabraham Exp $
+
+-- 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.
+
+
+-- Class class
+-- Represents a class definition.
+-- Stores the following fields:
+-- name = class name
+-- base = class base, if any (only single inheritance is supported)
+-- {i} = list of members
+classClass = {
+ classtype = 'class',
+ name = '',
+ base = '',
+ type = '',
+ btype = '',
+ ctype = '',
+}
+classClass.__index = classClass
+setmetatable(classClass,classContainer)
+
+
+-- register class
+function classClass:register ()
+ push(self)
+ if _collect[self.type] then
+ output('#ifdef __cplusplus\n')
+ output(' tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",'.._collect[self.type]..');')
+ output('#else\n')
+ output(' tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",NULL);')
+ output('#endif\n')
+ else
+ output(' tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",NULL);')
+ end
+ output(' tolua_beginmodule(tolua_S,"'..self.lname..'");')
+ local i=1
+ while self[i] do
+ self[i]:register()
+ i = i+1
+ end
+ output(' tolua_endmodule(tolua_S);')
+ pop()
+end
+
+-- return collection requirement
+function classClass:requirecollection (t)
+ push(self)
+ local r = false
+ local i=1
+ while self[i] do
+ r = self[i]:requirecollection(t) or r
+ i = i+1
+ end
+ pop()
+ -- only class that exports destructor can be appropriately collected
+ if self._delete then
+ t[self.type] = "tolua_collect_" .. gsub(self.type,"::","_")
+ r = true
+ end
+ return r
+end
+
+-- output tags
+function classClass:decltype ()
+ push(self)
+ self.type = regtype(self.name)
+ self.btype = typevar(self.base)
+ self.ctype = 'const '..self.type
+ local i=1
+ while self[i] do
+ self[i]:decltype()
+ i = i+1
+ end
+ pop()
+end
+
+
+-- Print method
+function classClass:print (ident,close)
+ print(ident.."Class{")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." base = '"..self.base.."';")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." btype = '"..self.btype.."',")
+ print(ident.." ctype = '"..self.ctype.."',")
+ local i=1
+ while self[i] do
+ self[i]:print(ident.." ",",")
+ i = i+1
+ end
+ print(ident.."}"..close)
+end
+
+-- Internal constructor
+function _Class (t)
+ setmetatable(t,classClass)
+ t:buildnames()
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects the name, the base and the body of the class.
+function Class (n,p,b)
+ local c = _Class(_Container{name=n, base=p})
+ push(c)
+ c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces
+ pop()
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/clean.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/clean.lua
new file mode 100644
index 0000000..b11e38c
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/clean.lua
@@ -0,0 +1,75 @@
+-- mark up comments and strings
+STR1 = "\001"
+STR2 = "\002"
+STR3 = "\003"
+STR4 = "\004"
+REM = "\005"
+ANY = "([\001-\005])"
+ESC1 = "\006"
+ESC2 = "\007"
+
+MASK = { -- the substitution order is important
+ {ESC1, "\\'", "\\'"},
+ {ESC2, '\\"', '\\"'},
+ {STR1, "'", "'"},
+ {STR2, '"', '"'},
+ {STR3, "%[%[", "[["},
+ {STR4, "%]%]", "]]"},
+ {REM , "%-%-", "--"},
+}
+
+function mask (s)
+ for i = 1,getn(MASK) do
+ s = gsub(s,MASK[i][2],MASK[i][1])
+ end
+ return s
+end
+
+function unmask (s)
+ for i = 1,getn(MASK) do
+ s = gsub(s,MASK[i][1],MASK[i][3])
+ end
+ return s
+end
+
+function clean (s)
+ -- check for compilation error
+ local code = "return function () " .. s .. " end"
+ if not dostring(code) then
+ return nil
+ end
+
+ local S = "" -- saved string
+
+ s = mask(s)
+
+ -- remove blanks and comments
+ while 1 do
+ local b,e,d = strfind(s,ANY)
+ if b then
+ S = S..strsub(s,1,b-1)
+ s = strsub(s,b+1)
+ if d==STR1 or d==STR2 then
+ e = strfind(s,d)
+ S = S ..d..strsub(s,1,e)
+ s = strsub(s,e+1)
+ elseif d==STR3 then
+ e = strfind(s,STR4)
+ S = S..d..strsub(s,1,e)
+ s = strsub(s,e+1)
+ elseif d==REM then
+ s = gsub(s,"[^\n]*(\n?)","%1",1)
+ end
+ else
+ S = S..s
+ break
+ end
+ end
+ -- eliminate unecessary spaces
+ S = gsub(S,"[ \t]+"," ")
+ S = gsub(S,"[ \t]*\n[ \t]*","\n")
+ S = gsub(S,"\n+","\n")
+ S = unmask(S)
+ return S
+end
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/code.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/code.lua
new file mode 100644
index 0000000..6afa84c
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/code.lua
@@ -0,0 +1,73 @@
+-- tolua: code class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1999
+-- $Id: code.lua,v 1.5 2009/11/24 16:45:13 fabraham Exp $
+
+-- 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.
+
+
+-- Code class
+-- Represents Lua code to be compiled and included
+-- in the initialization function.
+-- The following fields are stored:
+-- text = text code
+classCode = {
+ text = '',
+}
+classCode.__index = classCode
+setmetatable(classCode,classFeature)
+
+-- register code
+function classCode:register ()
+ -- clean Lua code
+ local s = clean(self.text)
+ if not s then
+ error("parser error in embedded code")
+ end
+
+ -- convert to C
+ output('\n { /* begin embedded lua code */\n')
+ output(' static unsigned char B[] = {\n ')
+ local t={n=0}
+ local b = gsub(s,'(.)',function (c)
+ local e = ''
+ t.n=t.n+1 if t.n==15 then t.n=0 e='\n ' end
+ return format('%3u,%s',strbyte(c),e)
+ end
+ )
+ output(b..strbyte(" "))
+ output('\n };\n')
+ output(' if (luaL_loadbuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code") == LUA_OK)\n')
+ output(' lua_pcall(tolua_S,0,LUA_MULTRET,0);')
+ output(' } /* end of embedded lua code */\n\n')
+end
+
+
+-- Print method
+function classCode:print (ident,close)
+ print(ident.."Code{")
+ print(ident.." text = [["..self.text.."]],")
+ print(ident.."}"..close)
+end
+
+
+-- Internal constructor
+function _Code (t)
+ setmetatable(t,classCode)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the code text
+function Code (l)
+ return _Code {
+ text = l
+ }
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/compat.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/compat.lua
new file mode 100644
index 0000000..d200399
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/compat.lua
@@ -0,0 +1,201 @@
+-------------------------------------------------------------------
+-- Real globals
+-- _ALERT
+-- _ERRORMESSAGE
+-- _VERSION
+-- _G
+-- assert
+-- error
+-- metatable
+-- next
+-- print
+-- require
+-- tonumber
+-- tostring
+-- type
+
+-------------------------------------------------------------------
+-- collectgarbage
+-- gcinfo
+
+-- globals
+
+-- call -> protect(f, err)
+
+-- rawget
+-- rawset
+
+-- getargs = Main.getargs ??
+
+rawtype = type
+
+function do_ (f, err)
+ if not f then print(err); return end
+ local a,b = pcall(f)
+ if not a then print(b); return nil
+ else return b or true
+ end
+end
+
+function dostring(s) return do_(load(s)) end
+
+-------------------------------------------------------------------
+-- Table library
+local tab = table
+foreach = function(t,f)
+ for k,v in pairs(t) do
+ f(k,v)
+ end
+end
+foreachi = function(t,f)
+ for i,v in ipairs(t) do
+ f(i,v)
+ end
+end
+getn = function(t)
+ return #t
+end
+tinsert = tab.insert
+tremove = tab.remove
+sort = tab.sort
+
+-------------------------------------------------------------------
+-- Debug library
+local dbg = debug
+getinfo = dbg.getinfo
+getlocal = dbg.getlocal
+setcallhook = function () error"`setcallhook' is deprecated" end
+setlinehook = function () error"`setlinehook' is deprecated" end
+setlocal = dbg.setlocal
+
+-------------------------------------------------------------------
+-- math library
+local math = math
+abs = math.abs
+acos = function (x) return math.deg(math.acos(x)) end
+asin = function (x) return math.deg(math.asin(x)) end
+atan = function (x) return math.deg(math.atan(x)) end
+atan2 = function (x,y) return math.deg(math.atan2(x,y)) end
+ceil = math.ceil
+cos = function (x) return math.cos(math.rad(x)) end
+deg = math.deg
+exp = math.exp
+floor = math.floor
+frexp = math.frexp
+ldexp = math.ldexp
+log = math.log
+log10 = math.log10
+max = math.max
+min = math.min
+mod = math.mod
+PI = math.pi
+--??? pow = math.pow
+rad = math.rad
+random = math.random
+randomseed = math.randomseed
+sin = function (x) return math.sin(math.rad(x)) end
+sqrt = math.sqrt
+tan = function (x) return math.tan(math.rad(x)) end
+
+-------------------------------------------------------------------
+-- string library
+local str = string
+strbyte = str.byte
+strchar = str.char
+strfind = str.find
+format = str.format
+gsub = str.gsub
+strlen = str.len
+strlower = str.lower
+strrep = str.rep
+strsub = str.sub
+strupper = str.upper
+
+-------------------------------------------------------------------
+-- os library
+clock = os.clock
+date = os.date
+difftime = os.difftime
+execute = os.execute --?
+exit = os.exit
+getenv = os.getenv
+remove = os.remove
+rename = os.rename
+setlocale = os.setlocale
+time = os.time
+tmpname = os.tmpname
+
+-------------------------------------------------------------------
+-- compatibility only
+getglobal = function (n) return _G[n] end
+setglobal = function (n,v) _G[n] = v end
+
+-------------------------------------------------------------------
+
+local io, tab = io, table
+
+-- IO library (files)
+_STDIN = io.stdin
+_STDERR = io.stderr
+_STDOUT = io.stdout
+_INPUT = io.stdin
+_OUTPUT = io.stdout
+seek = io.stdin.seek -- sick ;-)
+tmpfile = io.tmpfile
+closefile = io.close
+openfile = io.open
+
+function flush (f)
+ if f then f:flush()
+ else _OUTPUT:flush()
+ end
+end
+
+function readfrom (name)
+ if name == nil then
+ local f, err, cod = io.close(_INPUT)
+ _INPUT = io.stdin
+ return f, err, cod
+ else
+ local f, err, cod = io.open(name, "r")
+ _INPUT = f or _INPUT
+ return f, err, cod
+ end
+end
+
+function writeto (name)
+ if name == nil then
+ local f, err, cod = io.close(_OUTPUT)
+ _OUTPUT = io.stdout
+ return f, err, cod
+ else
+ local f, err, cod = io.open(name, "w")
+ _OUTPUT = f or _OUTPUT
+ return f, err, cod
+ end
+end
+
+function appendto (name)
+ local f, err, cod = io.open(name, "a")
+ _OUTPUT = f or _OUTPUT
+ return f, err, cod
+end
+
+function read (...)
+ local f = _INPUT
+ local arg = {...}
+ if rawtype(arg[1]) == 'userdata' then
+ f = tab.remove(arg, 1)
+ end
+ return f:read(table.unpack(arg))
+end
+
+function write (...)
+ local f = _OUTPUT
+ local arg = {...}
+ if rawtype(arg[1]) == 'userdata' then
+ f = tab.remove(arg, 1)
+ end
+ return f:write(table.unpack(arg))
+end
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/container.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/container.lua
new file mode 100644
index 0000000..29c3781
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/container.lua
@@ -0,0 +1,536 @@
+-- tolua: container abstract class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: container.lua,v 1.3 2009/11/24 16:45:13 fabraham Exp $
+
+-- 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.
+
+-- table to store namespaced typedefs/enums in global scope
+global_typedefs = {}
+global_enums = {}
+
+-- Container class
+-- Represents a container of features to be bound
+-- to lua.
+classContainer =
+{
+ curr = nil,
+}
+classContainer.__index = classContainer
+setmetatable(classContainer,classFeature)
+
+-- output tags
+function classContainer:decltype ()
+ push(self)
+ local i=1
+ while self[i] do
+ self[i]:decltype()
+ i = i+1
+ end
+ pop()
+end
+
+
+-- write support code
+function classContainer:supcode ()
+ push(self)
+ local i=1
+ while self[i] do
+ self[i]:supcode()
+ i = i+1
+ end
+ pop()
+end
+
+function classContainer:hasvar ()
+ local i=1
+ while self[i] do
+ if self[i]:isvariable() then
+ return 1
+ end
+ i = i+1
+ end
+ return 0
+end
+
+-- Internal container constructor
+function _Container (self)
+ setmetatable(self,classContainer)
+ self.n = 0
+ self.typedefs = {tolua_n=0}
+ self.usertypes = {}
+ self.enums = {tolua_n=0}
+ self.lnames = {}
+ return self
+end
+
+-- push container
+function push (t)
+ t.prox = classContainer.curr
+ classContainer.curr = t
+end
+
+-- pop container
+function pop ()
+--print("name",classContainer.curr.name)
+--foreach(classContainer.curr.usertypes,print)
+--print("______________")
+ classContainer.curr = classContainer.curr.prox
+end
+
+-- get current namespace
+function getcurrnamespace ()
+ return getnamespace(classContainer.curr)
+end
+
+-- append to current container
+function append (t)
+ return classContainer.curr:append(t)
+end
+
+-- append typedef to current container
+function appendtypedef (t)
+ return classContainer.curr:appendtypedef(t)
+end
+
+-- append usertype to current container
+function appendusertype (t)
+ return classContainer.curr:appendusertype(t)
+end
+
+-- append enum to current container
+function appendenum (t)
+ return classContainer.curr:appendenum(t)
+end
+
+-- substitute typedef
+function applytypedef (type)
+ return classContainer.curr:applytypedef(type)
+end
+
+-- check if is type
+function findtype (type)
+ local t = classContainer.curr:findtype(type)
+ return t
+end
+
+-- check if is typedef
+function istypedef (type)
+ return classContainer.curr:istypedef(type)
+end
+
+-- get fulltype (with namespace)
+function fulltype (t)
+ local curr = classContainer.curr
+ while curr do
+ if curr then
+ if curr.typedefs and curr.typedefs[t] then
+ return curr.typedefs[t]
+ elseif curr.usertypes and curr.usertypes[t] then
+ return curr.usertypes[t]
+ end
+ end
+ curr = curr.prox
+ end
+ return t
+end
+
+-- checks if it requires collection
+function classContainer:requirecollection (t)
+ push(self)
+ local i=1
+ local r = false
+ while self[i] do
+ r = self[i]:requirecollection(t) or r
+ i = i+1
+ end
+ pop()
+ return r
+end
+
+
+-- get namesapce
+function getnamespace (curr)
+ local namespace = ''
+ while curr do
+ if curr and
+ ( curr.classtype == 'class' or curr.classtype == 'namespace')
+ then
+ namespace = curr.name .. '::' .. namespace
+ end
+ curr = curr.prox
+ end
+ return namespace
+end
+
+-- get namespace (only namespace)
+function getonlynamespace ()
+ local curr = classContainer.curr
+ local namespace = ''
+ while curr do
+ if curr.classtype == 'class' then
+ return namespace
+ elseif curr.classtype == 'namespace' then
+ namespace = curr.name .. '::' .. namespace
+ end
+ curr = curr.prox
+ end
+ return namespace
+end
+
+-- check if is enum
+function isenum (type)
+ return classContainer.curr:isenum(type)
+end
+
+-- append feature to container
+function classContainer:append (t)
+ self.n = self.n + 1
+ self[self.n] = t
+ t.parent = self
+end
+
+-- append typedef
+function classContainer:appendtypedef (t)
+ local namespace = getnamespace(classContainer.curr)
+ self.typedefs.tolua_n = self.typedefs.tolua_n + 1
+ self.typedefs[self.typedefs.tolua_n] = t
+ self.typedefs[t.utype] = namespace .. t.utype
+ global_typedefs[namespace..t.utype] = t
+end
+
+-- append usertype: return full type
+function classContainer:appendusertype (t)
+ local container
+ if t == self.name then
+ container = self.prox
+ else
+ container = self
+ end
+ local ft = getnamespace(container) .. t
+ container.usertypes[t] = ft
+ _usertype[ft] = ft
+ return ft
+end
+
+-- append enum
+function classContainer:appendenum (t)
+ local namespace = getnamespace(classContainer.curr)
+ self.enums.tolua_n = self.enums.tolua_n + 1
+ self.enums[self.enums.tolua_n] = t
+ global_enums[namespace..t.name] = t
+end
+
+-- determine lua function name overload
+function classContainer:overload (lname)
+ if not self.lnames[lname] then
+ self.lnames[lname] = 0
+ else
+ self.lnames[lname] = self.lnames[lname] + 1
+ end
+ return format("%02d",self.lnames[lname])
+end
+
+-- applies typedef: returns the 'the facto' modifier and type
+function classContainer:applytypedef (type)
+ if global_typedefs[type] then
+ local mod1, type1 = global_typedefs[type].mod, global_typedefs[type].type
+ local mod2, type2 = applytypedef(type1)
+ return mod2 .. ' ' .. mod1, type2
+ end
+ local basetype = gsub(type,"^.*::","")
+ local env = self
+ while env do
+ if env.typedefs then
+ local i=1
+ while env.typedefs[i] do
+ if env.typedefs[i].utype == basetype then
+ local mod1,type1 = env.typedefs[i].mod,env.typedefs[i].type
+ local mod2,type2 = applytypedef(type1)
+ return mod2..' '..mod1,type2
+ end
+ i = i+1
+ end
+ end
+ env = env.parent
+ end
+ return '',type
+end
+
+-- check if it is a typedef
+function classContainer:istypedef (type)
+ local env = self
+ while env do
+ if env.typedefs then
+ local i=1
+ while env.typedefs[i] do
+ if env.typedefs[i].utype == type then
+ return type
+ end
+ i = i+1
+ end
+ end
+ env = env.parent
+ end
+ return nil
+end
+
+-- check if is a registered type: return full type or nil
+function classContainer:findtype (t)
+ local curr = self
+ while curr do
+ if curr.typedefs and curr.typedefs[t] then
+ return curr.typedefs[t]
+ elseif curr.usertypes and curr.usertypes[t] then
+ return curr.usertypes[t]
+ end
+ curr = curr.prox
+ end
+ if _basic[t] then
+ return t
+ end
+ return nil
+end
+
+
+function classContainer:isenum (type)
+ if global_enums[type] then
+ return true
+ end
+ local basetype = gsub(type,"^.*::","")
+ local env = self
+ while env do
+ if env.enums then
+ local i=1
+ while env.enums[i] do
+ if env.enums[i].name == basetype then
+ return true
+ end
+ i = i+1
+ end
+ end
+ env = env.parent
+ end
+ return false
+end
+
+-- parse chunk
+function classContainer:doparse (s)
+
+ -- try Lua code
+ do
+ local b,e,code = strfind(s,"^%s*(%b\1\2)")
+ if b then
+ Code(strsub(code,2,-2))
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try C code
+ do
+ local b,e,code = strfind(s,"^%s*(%b\3\4)")
+ if b then
+ code = '{'..strsub(code,2,-2)..'\n}\n'
+ Verbatim(code,'r') -- verbatim code for 'r'egister fragment
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try verbatim
+ do
+ local b,e,line = strfind(s,"^%s*%$(.-\n)")
+ if b then
+ Verbatim(line)
+ return strsub(s,e+1)
+ end
+ end
+
+
+ -- try module
+ do
+ local b,e,name,body = strfind(s,"^%s*module%s%s*([_%w][_%w]*)%s*(%b{})%s*")
+ if b then
+ _curr_code = strsub(s,b,e)
+ Module(name,body)
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try namesapce
+ do
+ local b,e,name,body = strfind(s,"^%s*namespace%s%s*([_%w][_%w]*)%s*(%b{})%s*")
+ if b then
+ _curr_code = strsub(s,b,e)
+ Namespace(name,body)
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try define
+ do
+ local b,e,name = strfind(s,"^%s*#define%s%s*([^%s]*)[^\n]*\n%s*")
+ if b then
+ _curr_code = strsub(s,b,e)
+ Define(name)
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try enumerates
+ do
+ local b,e,name,body = strfind(s,"^%s*enum%s+(%S*)%s*(%b{})%s*;?%s*")
+ if b then
+ _curr_code = strsub(s,b,e)
+ Enumerate(name,body)
+ return strsub(s,e+1)
+ end
+ end
+
+ do
+ local b,e,body,name = strfind(s,"^%s*typedef%s+enum[^{]*(%b{})%s*([%w_][^%s]*)%s*;%s*")
+ if b then
+ _curr_code = strsub(s,b,e)
+ Enumerate(name,body)
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try operator
+ do
+ local b,e,decl,kind,arg,const = strfind(s,"^%s*([_%w][_%w%s%*&:]*operator)%s*([^%s][^%s]*)%s*(%b())%s*(c?o?n?s?t?)%s*;%s*")
+ if not b then
+ -- try inline
+ b,e,decl,kind,arg,const = strfind(s,"^%s*([_%w][_%w%s%*&:]*operator)%s*([^%s][^%s]*)%s*(%b())%s*(c?o?n?s?t?)%s*%b{}%s*;?%s*")
+ end
+ if b then
+ _curr_code = strsub(s,b,e)
+ Operator(decl,kind,arg,const)
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try function
+ do
+ local b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:]*[_%w])%s*(%b())%s*(c?o?n?s?t?)%s*=?%s*0?%s*;%s*")
+ if not b then
+ -- try a single letter function name
+ b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?)%s*;%s*")
+ end
+ if b then
+ _curr_code = strsub(s,b,e)
+ Function(decl,arg,const)
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try inline function
+ do
+ local b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:]*[_%w])%s*(%b())%s*(c?o?n?s?t?).-%b{}%s*;?%s*")
+ if not b then
+ -- try a single letter function name
+ b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?).-%b{}%s*;?%s*")
+ end
+ if b then
+ _curr_code = strsub(s,b,e)
+ Function(decl,arg,const)
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try class
+ do
+ local b,e,name,base,body
+ base = '' body = ''
+ b,e,name = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*;") -- dummy class
+ if not b then
+ b,e,name = strfind(s,"^%s*struct%s*([_%w][_%w@]*)%s*;") -- dummy struct
+ if not b then
+ b,e,name,base,body = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*")
+ if not b then
+ b,e,name,base,body = strfind(s,"^%s*struct%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*")
+ if not b then
+ b,e,name,base,body = strfind(s,"^%s*union%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*")
+ if not b then
+ base = ''
+ b,e,body,name = strfind(s,"^%s*typedef%s%s*struct%s*[_%w]*%s*(%b{})%s*([_%w][_%w@]*)%s*;%s*")
+ if not b then
+ base = ''
+ b,e,body,name = strfind(s,"^%s*typedef%s%s*union%s*[_%w]*%s*(%b{})%s*([_%w][_%w@]*)%s*;%s*")
+ end
+ end
+ end
+ end
+ end
+ end
+ if b then
+ if base ~= '' then
+ local b,e
+ b,e,base = strfind(base,".-([_%w][_%w]*)$")
+ end
+ _curr_code = strsub(s,b,e)
+ Class(name,base,body)
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try typedef
+ do
+ local b,e,types = strfind(s,"^%s*typedef%s%s*(.-)%s*;%s*")
+ if b then
+ _curr_code = strsub(s,b,e)
+ Typedef(types)
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try variable
+ do
+ local b,e,decl = strfind(s,"^%s*([_%w][_@%s%w%d%*&:]*[_%w%d])%s*;%s*")
+ if b then
+ _curr_code = strsub(s,b,e)
+ Variable(decl)
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try string
+ do
+ local b,e,decl = strfind(s,"^%s*([_%w]?[_%s%w%d]-char%s+[_@%w%d]*%s*%[%s*%S+%s*%])%s*;%s*")
+ if b then
+ _curr_code = strsub(s,b,e)
+ Variable(decl)
+ return strsub(s,e+1)
+ end
+ end
+
+ -- try array
+ do
+ local b,e,decl = strfind(s,"^%s*([_%w][][_@%s%w%d%*&:]*[]_%w%d])%s*;%s*")
+ if b then
+ _curr_code = strsub(s,b,e)
+ Array(decl)
+ return strsub(s,e+1)
+ end
+ end
+
+ -- no matching
+ if gsub(s,"%s%s*","") ~= "" then
+ _curr_code = s
+ error("#parse error")
+ else
+ return ""
+ end
+
+end
+
+function classContainer:parse (s)
+ while s ~= '' do
+ s = self:doparse(s)
+ end
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/declaration.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/declaration.lua
new file mode 100644
index 0000000..b2aab1e
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/declaration.lua
@@ -0,0 +1,482 @@
+-- tolua: declaration class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: declaration.lua,v 1.5 2011/01/13 13:43:46 fabraham Exp $
+
+-- 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.
+
+
+-- Declaration class
+-- Represents variable, function, or argument declaration.
+-- Stores the following fields:
+-- mod = type modifiers
+-- type = type
+-- ptr = "*" or "&", if representing a pointer or a reference
+-- name = name
+-- dim = dimension, if a vector
+-- def = default value, if any (only for arguments)
+-- ret = "*" or "&", if value is to be returned (only for arguments)
+classDeclaration = {
+ mod = '',
+ type = '',
+ ptr = '',
+ name = '',
+ dim = '',
+ ret = '',
+ def = ''
+}
+classDeclaration.__index = classDeclaration
+setmetatable(classDeclaration,classFeature)
+
+-- Create an unique variable name
+function create_varname ()
+ if not _varnumber then _varnumber = 0 end
+ _varnumber = _varnumber + 1
+ return "tolua_var_".._varnumber
+end
+
+-- Check declaration name
+-- It also identifies default values
+function classDeclaration:checkname ()
+
+ if strsub(self.name,1,1) == '[' and not findtype(self.type) then
+ self.name = self.type..self.name
+ local m = split(self.mod,'%s%s*')
+ self.type = m[m.n]
+ self.mod = concat(m,1,m.n-1)
+ end
+
+ local t = split(self.name,'=')
+ if t.n==2 then
+ self.name = t[1]
+ self.def = t[t.n]
+ end
+
+ local b,e,d = strfind(self.name,"%[(.-)%]")
+ if b then
+ self.name = strsub(self.name,1,b-1)
+ self.dim = d
+ end
+
+ if self.type ~= '' and self.type ~= 'void' and self.name == '' then
+ self.name = create_varname()
+ elseif self.kind=='var' then
+ if self.type=='' and self.name~='' then
+ self.type = self.type..self.name
+ self.name = create_varname()
+ elseif findtype(self.name) then
+ if self.type=='' then self.type = self.name
+ else self.type = self.type..' '..self.name end
+ self.name = create_varname()
+ end
+ end
+
+ -- adjust type of string
+-- if self.type == 'char' and self.dim ~= '' then
+-- self.type = 'char*'
+-- end
+end
+
+-- Check declaration type
+-- Substitutes typedef's.
+function classDeclaration:checktype ()
+
+ -- check if there is a pointer to basic type
+ if isbasic(self.type) and self.ptr~='' then
+ self.ret = self.ptr
+ self.ptr = nil
+ end
+
+ -- check if there is array to be returned
+ if self.dim~='' and self.ret~='' then
+ error('#invalid parameter: cannot return an array of values')
+ end
+
+ -- restore 'void*' and 'string*'
+ if self.type == '_userdata' then self.type = 'void*'
+ elseif self.type == '_cstring' then self.type = 'char*'
+ elseif self.type == '_lstate' then self.type = 'lua_State*'
+ end
+
+--
+-- -- if returning value, automatically set default value
+-- if self.ret ~= '' and self.def == '' then
+-- self.def = '0'
+-- end
+--
+
+end
+
+-- Print method
+function classDeclaration:print (ident,close)
+ print(ident.."Declaration{")
+ print(ident.." mod = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." dim = '"..self.dim.."',")
+ print(ident.." def = '"..self.def.."',")
+ print(ident.." ret = '"..self.ret.."',")
+ print(ident.."}"..close)
+end
+
+-- check if array of values are returned to Lua
+function classDeclaration:requirecollection (t)
+ if self.mod ~= 'const' and
+ self.dim and self.dim ~= '' and
+ not isbasic(self.type) and
+ self.ptr == '' then
+ local type = gsub(self.type,"%s*const%s*","")
+ t[type] = "tolua_collect_" .. gsub(type,"::","_")
+ return true
+ end
+ return false
+end
+
+-- declare tag
+function classDeclaration:decltype ()
+ self.type = typevar(self.type)
+ if strfind(self.mod,'const') then
+ self.type = 'const '..self.type
+ self.mod = gsub(self.mod,'const%s*','')
+ end
+end
+
+
+-- output type checking
+function classDeclaration:outchecktype (narg,var)
+ local def
+ local t = isbasic(self.type)
+ if self.def~='' then
+ def = 1
+ else
+ def = 0
+ end
+ if self.dim ~= '' then
+ if var and self.type=='char' then
+ return 'tolua_isstring(tolua_S,'..narg..','..def..',&tolua_err)'
+ else
+ return 'tolua_istable(tolua_S,'..narg..',0,&tolua_err)'
+ end
+ elseif t then
+ return 'tolua_is'..t..'(tolua_S,'..narg..','..def..',&tolua_err)'
+ else
+ return 'tolua_isusertype(tolua_S,'..narg..',"'..self.type..'",'..def..',&tolua_err)'
+ end
+end
+
+function classDeclaration:builddeclaration (narg, cplusplus)
+ local array = self.dim ~= '' and tonumber(self.dim)==nil
+ local line = ""
+ local ptr = ''
+ local mod
+ local type = self.type
+ if self.dim ~= '' then
+ type = gsub(self.type,'const%s*','') -- eliminates const modifier for arrays
+ end
+ local ctype = type
+ if ctype=="lua_Object" or ctype=="lua_Function" then
+ ctype = "int"
+ end
+ if self.ptr~='' then ptr = '*' end
+ line = concatparam(line," ",self.mod,ctype,ptr)
+ if array then
+ line = concatparam(line,'*')
+ end
+ line = concatparam(line,self.name)
+ if self.dim ~= '' then
+ if tonumber(self.dim)~=nil then
+ line = concatparam(line,'[',self.dim,'];')
+ else
+ if cplusplus then
+ line = concatparam(line,' = new',type,ptr,'['..self.dim..'];')
+ else
+ line = concatparam(line,' = (',type,ptr,'*)',
+ 'malloc((',self.dim,')*sizeof(',type,ptr,'));')
+ end
+ end
+ else
+ local t = isbasic(type)
+ line = concatparam(line,' = ')
+ if t == 'state' then
+ line = concatparam(line, 'tolua_S;')
+ else
+ if not t and ptr=='' then line = concatparam(line,'*') end
+ local ct = type
+ if t == 'value' or t == 'function' then
+ ct = 'int'
+ end
+ line = concatparam(line,'((',self.mod,ct)
+ if not t then
+ line = concatparam(line,'*')
+ end
+ line = concatparam(line,') ')
+ if isenum(type) then
+ --if not t and isenum(type) then
+ line = concatparam(line,'(int) ')
+ end
+ local def = 0
+ if self.def ~= '' then def = self.def end
+ if t then
+ if t=='function' then t='value' end
+ if self.type == "tolua_index" then
+ line = concatparam(line,'tolua_to'..t,'(tolua_S,',narg,',',def,')-1);')
+ else
+ line = concatparam(line,'tolua_to'..t,'(tolua_S,',narg,',',def,'));')
+ end
+ else
+ line = concatparam(line,'tolua_tousertype(tolua_S,',narg,',',def,'));')
+ end
+ end
+ end
+ return line
+end
+
+-- Declare variable
+function classDeclaration:declare (narg)
+ if self.dim ~= '' and self.type~='char' and tonumber(self.dim)==nil then
+ output('#ifdef __cplusplus\n')
+ output(self:builddeclaration(narg,true))
+ output('#else\n')
+ output(self:builddeclaration(narg,false))
+ output('#endif\n')
+ else
+ output(self:builddeclaration(narg,false))
+ end
+end
+
+-- Get parameter value
+function classDeclaration:getarray (narg)
+ if self.dim ~= '' then
+ local type = gsub(self.type,'const ','')
+ output(' {')
+ output('#ifndef TOLUA_RELEASE\n')
+ local def; if self.def~='' then def=1 else def=0 end
+ local t = isbasic(type)
+ if (t) then
+ output(' if (!tolua_is'..t..'array(tolua_S,',narg,',',self.dim,',',def,',&tolua_err))')
+ else
+ output(' if (!tolua_isusertypearray(tolua_S,',narg,',"',type,'",',self.dim,',',def,',&tolua_err))')
+ end
+ output(' goto tolua_lerror;')
+ output(' else\n')
+ output('#endif\n')
+ output(' {')
+ output(' int i;')
+ output(' for(i=0; i<'..self.dim..';i++)')
+ local t = isbasic(type)
+ local ptr = ''
+ if self.ptr~='' then ptr = '*' end
+ output(' ',self.name..'[i] = ')
+ if not t and ptr=='' then output('*') end
+ output('((',type)
+ if not t then
+ output('*')
+ end
+ output(') ')
+ local def = 0
+ if self.def ~= '' then def = self.def end
+ if t then
+ if t=='function' then t='value' end
+ output('tolua_tofield'..t..'(tolua_S,',narg,',i+1,',def,'));')
+ else
+ output('tolua_tofieldusertype(tolua_S,',narg,',i+1,',def,'));')
+ end
+ output(' }')
+ output(' }')
+ end
+end
+
+-- Get parameter value
+function classDeclaration:setarray (narg)
+ if not strfind(self.type,'const') and self.dim ~= '' then
+ local type = gsub(self.type,'const ','')
+ output(' {')
+ output(' int i;')
+ output(' for(i=0; i<'..self.dim..';i++)')
+ local t,ct = isbasic(type)
+ if t then
+ if t=='function' then t='value' end
+ output(' tolua_pushfield'..t..'(tolua_S,',narg,',i+1,(',ct,')',self.name,'[i]);')
+ else
+ if self.ptr == '' then
+ output(' {')
+ output('#ifdef __cplusplus\n')
+ output(' void* tolua_obj = new',type,'(',self.name,'[i]);')
+ output(' tolua_pushfieldusertype(tolua_S,',narg,',i+1,tolua_clone(tolua_S,tolua_obj,'.. (_collect[type] or 'NULL') ..'),"',type,'");')
+ output('#else\n')
+ output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&',self.name,'[i],sizeof(',type,'));')
+ output(' tolua_pushfieldusertype(tolua_S,',narg,',i+1,tolua_clone(tolua_S,tolua_obj,NULL),"',type,'");')
+ output('#endif\n')
+ output(' }')
+ else
+ output(' tolua_pushfieldusertype(tolua_S,',narg,',i+1,(void*)',self.name,'[i],"',type,'");')
+ end
+ end
+ output(' }')
+ end
+end
+
+-- Free dynamically allocated array
+function classDeclaration:freearray ()
+ if self.dim ~= '' and tonumber(self.dim)==nil then
+ output('#ifdef __cplusplus\n')
+ output(' delete []',self.name,';')
+ output('#else\n')
+ output(' free(',self.name,');')
+ output('#endif\n')
+ end
+end
+
+-- Pass parameter
+function classDeclaration:passpar ()
+ local name = self.name
+ if self.ptr=='&' then
+ output('*'..name)
+ elseif self.ret=='*' then
+ output('&'..name)
+ else
+ output(name)
+ end
+end
+
+-- Return parameter value
+function classDeclaration:retvalue ()
+ if self.ret ~= '' then
+ local t,ct = isbasic(self.type)
+ if t then
+ if t=='function' then t='value' end
+ if self.type=="tolua_index" then
+ output(' tolua_push'..t..'(tolua_S,(',ct,')'..self.name..'+1);')
+ else
+ output(' tolua_push'..t..'(tolua_S,(',ct,')'..self.name..');')
+ end
+ else
+ output(' tolua_pushusertype(tolua_S,(void*)'..self.name..',"',self.type,'");')
+ end
+ return 1
+ end
+ return 0
+end
+
+-- Internal constructor
+function _Declaration (t)
+ setmetatable(t,classDeclaration)
+ t:buildnames()
+ t:checkname()
+ t:checktype()
+ return t
+end
+
+-- Constructor
+-- Expects the string declaration.
+-- The kind of declaration can be "var" or "func".
+function Declaration (s,kind)
+ -- eliminate spaces if default value is provided
+ s = gsub(s,"%s*=%s*","=")
+
+ if kind == "var" then
+ -- check the form: void
+ if s == '' or s == 'void' then
+ return _Declaration{type = 'void', kind = kind}
+ end
+ end
+
+ -- check the form: mod type*& name
+ local t = split(s,'%*%s*&')
+ if t.n == 2 then
+ if kind == 'func' then
+ error("#invalid function return type: "..s)
+ end
+ local m = split(t[1],'%s%s*')
+ return _Declaration{
+ name = t[2],
+ ptr = '*',
+ ret = '&',
+ type = m[m.n],
+ mod = concat(m,1,m.n-1),
+ kind = kind
+ }
+ end
+
+ -- check the form: mod type** name
+ t = split(s,'%*%s*%*')
+ if t.n == 2 then
+ if kind == 'func' then
+ error("#invalid function return type: "..s)
+ end
+ local m = split(t[1],'%s%s*')
+ return _Declaration{
+ name = t[2],
+ ptr = '*',
+ ret = '*',
+ type = m[m.n],
+ mod = concat(m,1,m.n-1),
+ kind = kind
+ }
+ end
+
+ -- check the form: mod type& name
+ t = split(s,'&')
+ if t.n == 2 then
+ local m = split(t[1],'%s%s*')
+ return _Declaration{
+ name = t[2],
+ ptr = '&',
+ type = m[m.n],
+ mod = concat(m,1,m.n-1) ,
+ kind = kind
+ }
+ end
+
+ -- check the form: mod type* name
+ local s1 = gsub(s,"(%b%[%])",function (n) return gsub(n,'%*','\1') end)
+ t = split(s1,'%*')
+ if t.n == 2 then
+ t[2] = gsub(t[2],'\1','%*') -- restore * in dimension expression
+ local m = split(t[1],'%s%s*')
+ return _Declaration{
+ name = t[2],
+ ptr = '*',
+ type = m[m.n],
+ mod = concat(m,1,m.n-1) ,
+ kind = kind
+ }
+ end
+
+ if kind == 'var' then
+ -- check the form: mod type name
+ t = split(s,'%s%s*')
+ local v
+ if findtype(t[t.n]) then v = '' else v = t[t.n]; t.n = t.n-1 end
+ return _Declaration{
+ name = v,
+ type = t[t.n],
+ mod = concat(t,1,t.n-1),
+ kind = kind
+ }
+
+ else -- kind == "func"
+
+ -- check the form: mod type name
+ t = split(s,'%s%s*')
+ local v = t[t.n] -- last word is the function name
+ local tp,md
+ if t.n>1 then
+ tp = t[t.n-1]
+ md = concat(t,1,t.n-2)
+ end
+ return _Declaration{
+ name = v,
+ type = tp,
+ mod = md,
+ kind = kind
+ }
+ end
+
+end
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/define.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/define.lua
new file mode 100644
index 0000000..a903d2a
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/define.lua
@@ -0,0 +1,58 @@
+-- tolua: define class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: define.lua,v 1.3 2009/11/24 16:45:13 fabraham Exp $
+
+-- 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.
+
+
+-- Define class
+-- Represents a numeric const definition
+-- The following filds are stored:
+-- name = constant name
+classDefine = {
+ name = '',
+}
+classDefine.__index = classDefine
+setmetatable(classDefine,classFeature)
+
+-- register define
+function classDefine:register ()
+ output(' tolua_constant(tolua_S,"'..self.lname..'",'..self.name..');')
+end
+
+-- Print method
+function classDefine:print (ident,close)
+ print(ident.."Define{")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.."}"..close)
+end
+
+
+-- Internal constructor
+function _Define (t)
+ setmetatable(t,classDefine)
+ t:buildnames()
+
+ if t.name == '' then
+ error("#invalid define")
+ end
+
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the constant name
+function Define (n)
+ return _Define{
+ name = n
+ }
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/doit.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/doit.lua
new file mode 100644
index 0000000..4050058
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/doit.lua
@@ -0,0 +1,63 @@
+-- Generate binding code
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- Last update: Apr 2003
+-- $Id: doit.lua,v 1.3 2009/11/24 16:45:13 fabraham Exp $
+
+
+-- 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 doit ()
+ -- define package name, if not provided
+ if not flags.n then
+ if flags.f then
+ flags.n = gsub(flags.f,"%..*","")
+ else
+ error("#no package name nor input file provided")
+ end
+ 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
+ p:preamble()
+ p:supcode()
+ p:register()
+ 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
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/enumerate.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/enumerate.lua
new file mode 100644
index 0000000..41ce314
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/enumerate.lua
@@ -0,0 +1,83 @@
+-- tolua: enumerate class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: enumerate.lua,v 1.3 2009/11/24 16:45:13 fabraham Exp $
+
+-- 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.
+
+
+-- Enumerate class
+-- Represents enumeration
+-- The following fields are stored:
+-- {i} = list of constant names
+classEnumerate = {
+}
+classEnumerate.__index = classEnumerate
+setmetatable(classEnumerate,classFeature)
+
+-- register enumeration
+function classEnumerate:register ()
+ local nspace = getnamespace(classContainer.curr)
+ local i=1
+ while self[i] do
+ output(' tolua_constant(tolua_S,"'..self.lnames[i]..'",'..nspace..self[i]..');')
+ i = i+1
+ end
+end
+
+-- Print method
+function classEnumerate:print (ident,close)
+ print(ident.."Enumerate{")
+ print(ident.." name = "..self.name)
+ local i=1
+ while self[i] do
+ print(ident.." '"..self[i].."'("..self.lnames[i].."),")
+ i = i+1
+ end
+ print(ident.."}"..close)
+end
+
+-- Internal constructor
+function _Enumerate (t)
+ setmetatable(t,classEnumerate)
+ append(t)
+ appendenum(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the enumerate body
+function Enumerate (n,b)
+ local t = split(strsub(b,2,-2),',') -- eliminate braces
+ local i = 1
+ local e = {n=0}
+ while t[i] do
+ local tt = split(t[i],'=') -- discard initial value
+ e.n = e.n + 1
+ e[e.n] = tt[1]
+ i = i+1
+ end
+ -- set lua names
+ i = 1
+ e.lnames = {}
+ while e[i] do
+ local t = split(e[i],'@')
+ e[i] = t[1]
+ if not t[2] then
+ t[2] = applyrenaming(t[1])
+ end
+ e.lnames[i] = t[2] or t[1]
+ i = i+1
+ end
+ e.name = n
+ if n~="" then
+ Typedef("int "..n)
+ end
+ return _Enumerate(e)
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/feature.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/feature.lua
new file mode 100644
index 0000000..dbf76ca
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/feature.lua
@@ -0,0 +1,101 @@
+-- tolua: abstract feature class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: feature.lua,v 1.3 2009/11/24 16:45:14 fabraham Exp $
+
+-- 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.
+
+
+-- Feature class
+-- Represents the base class of all mapped feature.
+classFeature = {
+}
+classFeature.__index = classFeature
+
+-- write support code
+function classFeature:supcode ()
+end
+
+-- output tag
+function classFeature:decltype ()
+end
+
+-- register feature
+function classFeature:register ()
+end
+
+-- translate verbatim
+function classFeature:preamble ()
+end
+
+-- check if it is a variable
+function classFeature:isvariable ()
+ return false
+end
+
+-- checi if it requires collection
+function classFeature:requirecollection (t)
+ return false
+end
+
+-- build names
+function classFeature:buildnames ()
+ if self.name and self.name~='' then
+ local n = split(self.name,'@')
+ self.name = n[1]
+ if not n[2] then
+ n[2] = applyrenaming(n[1])
+ end
+ self.lname = n[2] or gsub(n[1],"%[.-%]","")
+ end
+ self.name = getonlynamespace() .. self.name
+end
+
+
+-- check if feature is inside a container definition
+-- it returns the container class name or nil.
+function classFeature:incontainer (which)
+ if self.parent then
+ local parent = self.parent
+ while parent do
+ if parent.classtype == which then
+ return parent.name
+ end
+ parent = parent.parent
+ end
+ end
+ return nil
+end
+
+function classFeature:inclass ()
+ return self:incontainer('class')
+end
+
+function classFeature:inmodule ()
+ return self:incontainer('module')
+end
+
+function classFeature:innamespace ()
+ return self:incontainer('namespace')
+end
+
+-- return C binding function name based on name
+-- the client specifies a prefix
+function classFeature:cfuncname (n)
+ if self.parent then
+ n = self.parent:cfuncname(n)
+ end
+
+ if self.lname and
+ strsub(self.lname,1,1)~="." -- operator are named as ".add"
+ then
+ return n..'_'..self.lname
+ else
+ return n..'_'..self.name
+ end
+end
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/function.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/function.lua
new file mode 100644
index 0000000..b435b93
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/function.lua
@@ -0,0 +1,402 @@
+-- tolua: function class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: function.lua,v 1.4 2009/11/24 16:45:14 fabraham Exp $
+
+-- 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 class
+-- Represents a function or a class method.
+-- The following fields are stored:
+-- mod = type modifiers
+-- type = type
+-- ptr = "*" or "&", if representing a pointer or a reference
+-- name = name
+-- lname = lua name
+-- args = list of argument declarations
+-- const = if it is a method receiving a const "this".
+classFunction = {
+ mod = '',
+ type = '',
+ ptr = '',
+ name = '',
+ args = {n=0},
+ const = '',
+}
+classFunction.__index = classFunction
+setmetatable(classFunction,classFeature)
+
+-- declare tags
+function classFunction:decltype ()
+ self.type = typevar(self.type)
+ if strfind(self.mod,'const') then
+ self.type = 'const '..self.type
+ self.mod = gsub(self.mod,'const%s*','')
+ end
+ local i=1
+ while self.args[i] do
+ self.args[i]:decltype()
+ i = i+1
+ end
+end
+
+
+-- Write binding function
+-- Outputs C/C++ binding function.
+function classFunction:supcode ()
+ local overload = strsub(self.cname,-2,-1) - 1 -- indicate overloaded func
+ local nret = 0 -- number of returned values
+ local class = self:inclass()
+ local _,_,static = strfind(self.mod,'^%s*(static)')
+
+ if class then
+ output("/* method:",self.name," of class ",class," */")
+ else
+ output("/* function:",self.name," */")
+ end
+ output("static int",self.cname,"(lua_State* tolua_S)")
+ output("{")
+ if self.type == 'tolua_multret' then
+ output(' int tolua_ret;')
+ end
+
+ -- check types
+ if overload < 0 then
+ output('#ifndef TOLUA_RELEASE\n')
+ end
+ output(' tolua_Error tolua_err;')
+ output(' if (\n')
+ -- check self
+ local narg
+ if class then narg=2 else narg=1 end
+ if class then
+ local func = 'tolua_isusertype'
+ local type = self.parent.type
+ if self.const ~= '' then
+ type = self.const .. " " .. type
+ end
+ if self.name=='new' or static~=nil then
+ func = 'tolua_isusertable'
+ type = self.parent.type
+ end
+ output(' !'..func..'(tolua_S,1,"'..type..'",0,&tolua_err) || \n')
+ end
+ -- check args
+ local vararg = false
+ if self.args[1].type ~= 'void' then
+ local i=1
+ while self.args[i] and self.args[i].type ~= "..." do
+ local btype = isbasic(self.args[i].type)
+ if btype ~= 'state' then
+ output(' !'..self.args[i]:outchecktype(narg,false)..' || \n')
+ end
+ if btype ~= 'state' then
+ narg = narg+1
+ end
+ i = i+1
+ end
+ if self.args[i] then
+ vararg = true
+ end
+ end
+ -- check end of list
+ if not vararg then
+ output(' !tolua_isnoobj(tolua_S,'..narg..',&tolua_err)\n')
+ else
+ output(' 0\n')
+ end
+ output(' )')
+ output(' goto tolua_lerror;')
+
+ output(' else\n')
+ if overload < 0 then
+ output('#endif\n')
+ end
+ output(' {')
+
+ -- declare self, if the case
+ local narg
+ if class then narg=2 else narg=1 end
+ if class and self.name~='new' and static==nil then
+ output(' ',self.const,self.parent.type,'*','self = ')
+ output('(',self.const,self.parent.type,'*) ')
+ output('tolua_tousertype(tolua_S,1,0);')
+ elseif static then
+ _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+ end
+ -- declare parameters
+ if self.args[1].type ~= 'void' then
+ local i=1
+ while self.args[i] and self.args[i].type ~= "..." do
+ self.args[i]:declare(narg)
+ if isbasic(self.args[i].type) ~= "state" then
+ narg = narg+1
+ end
+ i = i+1
+ end
+ end
+
+ -- check self
+ if class and self.name~='new' and static==nil then
+ output('#ifndef TOLUA_RELEASE\n')
+ output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in function \''..self.name..'\'",NULL);');
+ output('#endif\n')
+ end
+
+ -- get array element values
+ if class then narg=2 else narg=1 end
+ if self.args[1].type ~= 'void' then
+ local i=1
+ while self.args[i] and self.args[i].type ~= "..." do
+ if isbasic(self.args[i].type) ~= "state" then
+ self.args[i]:getarray(narg)
+ narg = narg+1
+ end
+ i = i+1
+ end
+ end
+
+ -- call function
+ if class and self.name=='delete' then
+ output(' tolua_release(tolua_S,self);')
+ output(' delete self;')
+ elseif class and self.name == 'operator&[]' then
+ output(' self->operator[](',self.args[1].name,'-1) = ',self.args[2].name,';')
+ else
+ output(' {')
+ if self.type ~= '' and self.type ~= 'void' then
+ local ctype = self.type
+ if ctype == 'value' or ctype == 'function' then
+ ctype = 'int'
+ end
+ if self.type == 'tolua_multret' then
+ output(' tolua_ret = ')
+ else
+ output(' ',self.mod,ctype,self.ptr,'tolua_ret = ')
+ end
+ if isbasic(self.type) or self.ptr ~= '' then
+ output('(',self.mod,ctype,self.ptr,') ')
+ end
+ else
+ output(' ')
+ end
+ if class and self.name=='new' then
+ output('new',self.type,'(')
+ elseif class and static then
+ output(class..'::'..self.name,'(')
+ elseif class then
+ output('self->'..self.name,'(')
+ else
+ output(self.name,'(')
+ end
+
+ -- write parameters
+ local i=1
+ while self.args[i] and self.args[i].type ~= "..." do
+ self.args[i]:passpar()
+ i = i+1
+ if self.args[i] and self.args[i].type ~= "..." then
+ output(',')
+ end
+ end
+
+ if class and self.name == 'operator[]' then
+ output('-1);')
+ else
+ output(');')
+ end
+
+ -- return values
+ if self.type ~= '' and self.type ~= 'void' and self.type ~= 'tolua_multret' then
+ nret = nret + 1
+ local t,ct = isbasic(self.type)
+ if t then
+ if t=='function' then t='value' end
+ if self.type == 'tolua_index' then
+ output(' if (tolua_ret < 0) lua_pushnil(tolua_S);')
+ output(' else tolua_push'..t..'(tolua_S,(',ct,')tolua_ret+1);')
+ else
+ output(' tolua_push'..t..'(tolua_S,(',ct,')tolua_ret);')
+ end
+ else
+ t = self.type
+ if self.ptr == '' then
+ output(' {')
+ output('#ifdef __cplusplus\n')
+ output(' void* tolua_obj = new',t,'(tolua_ret);')
+ output(' tolua_pushusertype(tolua_S,tolua_clone(tolua_S,tolua_obj,'.. (_collect[t] or 'NULL') ..'),"',t,'");')
+ output('#else\n')
+ output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));')
+ output(' tolua_pushusertype(tolua_S,tolua_clone(tolua_S,tolua_obj,NULL),"',t,'");')
+ output('#endif\n')
+ output(' }')
+ elseif self.ptr == '&' then
+ output(' tolua_pushusertype(tolua_S,(void*)&tolua_ret,"',t,'");')
+ else
+ output(' tolua_pushusertype(tolua_S,(void*)tolua_ret,"',t,'");')
+ if self.mod == 'tolua_own' then
+ output(' lua_pushcfunction(tolua_S, tolua_bnd_takeownership);')
+ output(' lua_pushvalue(tolua_S, -2);')
+ output(' lua_call(tolua_S, 1, 0);')
+ end
+ end
+ end
+ end
+ local i=1
+ while self.args[i] do
+ nret = nret + self.args[i]:retvalue()
+ i = i+1
+ end
+ output(' }')
+
+ -- set array element values
+ if class then narg=2 else narg=1 end
+ if self.args[1].type ~= 'void' then
+ local i=1
+ while self.args[i] do
+ if isbasic(self.args[i].type) ~= "state" then
+ self.args[i]:setarray(narg)
+ narg = narg+1
+ end
+ i = i+1
+ end
+ end
+
+ -- free dynamically allocated array
+ if self.args[1].type ~= 'void' then
+ local i=1
+ while self.args[i] do
+ self.args[i]:freearray()
+ i = i+1
+ end
+ end
+ end
+
+ output(' }')
+ if self.type == "tolua_multret" then
+ output(' return '..nret..' + tolua_ret;')
+ else
+ output(' return '..nret..';')
+ end
+
+ -- call overloaded function or generate error
+ if overload < 0 then
+ output('#ifndef TOLUA_RELEASE\n')
+ output('tolua_lerror:\n')
+ output(' tolua_error(tolua_S,"#ferror in function \''..self.lname..'\'.",&tolua_err);')
+ output(' return 0;')
+ output('#endif\n')
+ else
+ output('tolua_lerror:\n')
+ output(' return '..strsub(self.cname,1,-3)..format("%02d",overload)..'(tolua_S);')
+ end
+ output('}')
+ output('\n')
+end
+
+
+-- register function
+function classFunction:register ()
+ output(' tolua_function(tolua_S,"'..self.lname..'",'..self.cname..');')
+end
+
+-- Print method
+function classFunction:print (ident,close)
+ print(ident.."Function{")
+ print(ident.." mod = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.." const = '"..self.const.."',")
+ print(ident.." cname = '"..self.cname.."',")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.." args = {")
+ local i=1
+ while self.args[i] do
+ self.args[i]:print(ident.." ",",")
+ i = i+1
+ end
+ print(ident.." }")
+ print(ident.."}"..close)
+end
+
+-- check if it returns a object by value
+function classFunction:requirecollection (t)
+ local r = false
+ if self.type ~= '' and not isbasic(self.type) and self.ptr=='' then
+ local type = gsub(self.type,"%s*const%s*","")
+ t[type] = "tolua_collect_" .. gsub(type,"::","_")
+ r = true
+ end
+ local i=1
+ while self.args[i] do
+ r = self.args[i]:requirecollection(t) or r
+ i = i+1
+ end
+ return r
+end
+
+-- determine lua function name overload
+function classFunction:overload ()
+ return self.parent:overload(self.lname)
+end
+
+
+
+-- Internal constructor
+function _Function (t)
+ setmetatable(t,classFunction)
+
+ if t.const ~= 'const' and t.const ~= '' then
+ error("#invalid 'const' specification")
+ end
+
+ append(t)
+ if t:inclass() then
+ if t.name == t.parent.name then
+ t.name = 'new'
+ t.lname = 'new'
+ if string.find(t.type,"tolua_own") then
+ t.mod = "tolua_own"
+ end
+ t.type = t.parent.name
+ t.ptr = '*'
+ elseif t.name == '~'..t.parent.name then
+ t.name = 'delete'
+ t.lname = 'delete'
+ t.parent._delete = true
+ elseif t.type == 'tolua_len' then
+ t.lname = ".len"
+ end
+ end
+ t.cname = t:cfuncname("tolua")..t:overload(t)
+ return t
+end
+
+-- Constructor
+-- Expects three strings: one representing the function declaration,
+-- another representing the argument list, and the third representing
+-- the "const" or empty string.
+function Function (d,a,c)
+ local t = split(strsub(a,2,-2),',') -- eliminate braces
+ local i=1
+ local l = {n=0}
+ while t[i] do
+ l.n = l.n+1
+ l[l.n] = Declaration(t[i],'var')
+ i = i+1
+ end
+ local f = Declaration(d,'func')
+ f.args = l
+ f.const = c
+ return _Function(f)
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/module.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/module.lua
new file mode 100644
index 0000000..10d541b
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/module.lua
@@ -0,0 +1,67 @@
+-- tolua: module class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: module.lua,v 1.3 2009/11/24 16:45:14 fabraham Exp $
+
+-- 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.
+
+
+
+-- Module class
+-- Represents module.
+-- The following fields are stored:
+-- {i} = list of objects in the module.
+classModule = {
+ classtype = 'module'
+}
+classModule.__index = classModule
+setmetatable(classModule,classContainer)
+
+-- register module
+function classModule:register ()
+ push(self)
+ output(' tolua_module(tolua_S,"'..self.name..'",',self:hasvar(),');')
+ output(' tolua_beginmodule(tolua_S,"'..self.name..'");')
+ local i=1
+ while self[i] do
+ self[i]:register()
+ i = i+1
+ end
+ output(' tolua_endmodule(tolua_S);')
+ pop()
+end
+
+-- Print method
+function classModule:print (ident,close)
+ print(ident.."Module{")
+ print(ident.." name = '"..self.name.."';")
+ local i=1
+ while self[i] do
+ self[i]:print(ident.." ",",")
+ i = i+1
+ end
+ print(ident.."}"..close)
+end
+
+-- Internal constructor
+function _Module (t)
+ setmetatable(t,classModule)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects two string representing the module name and body.
+function Module (n,b)
+ local t = _Module(_Container{name=n})
+ push(t)
+ t:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces
+ pop()
+ return t
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/namespace.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/namespace.lua
new file mode 100644
index 0000000..572a8dc
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/namespace.lua
@@ -0,0 +1,52 @@
+-- tolua: namespace class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 2003
+-- $Id: namespace.lua,v 1.3 2009/11/24 16:45:14 fabraham Exp $
+
+-- 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.
+
+
+-- Namespace class
+-- Represents a namesapce definition.
+-- Stores the following fields:
+-- name = class name
+-- {i} = list of members
+classNamespace = {
+ classtype = 'namespace',
+ name = '',
+}
+classNamespace.__index = classNamespace
+setmetatable(classNamespace,classModule)
+
+-- Print method
+function classNamespace:print (ident,close)
+ print(ident.."Namespace{")
+ print(ident.." name = '"..self.name.."',")
+ local i=1
+ while self[i] do
+ self[i]:print(ident.." ",",")
+ i = i+1
+ end
+ print(ident.."}"..close)
+end
+
+-- Internal constructor
+function _Namespace (t)
+ setmetatable(t,classNamespace)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects the name and the body of the namespace.
+function Namespace (n,b)
+ local c = _Namespace(_Container{name=n})
+ push(c)
+ c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces
+ pop()
+end
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/operator.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/operator.lua
new file mode 100644
index 0000000..822fe83
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/operator.lua
@@ -0,0 +1,113 @@
+-- tolua: operator class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: operator.lua,v 1.3 2009/11/24 16:45:14 fabraham Exp $
+
+-- 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.
+
+
+-- Operator class
+-- Represents an operator function or a class operator method.
+-- It stores the same fields as functions do plus:
+-- kind = set of character representing the operator (as it appers in C++ code)
+classOperator = {
+ kind = '',
+}
+classOperator.__index = classOperator
+setmetatable(classOperator,classFunction)
+
+-- table to transform operator kind into the appropriate tag method name
+_TM = {['+'] = 'add',
+ ['-'] = 'sub',
+ ['*'] = 'mul',
+ ['/'] = 'div',
+ ['<'] = 'lt',
+ ['<='] = 'le',
+ ['=='] = 'eq',
+ ['[]'] = 'geti',
+ ['&[]'] = 'seti',
+ }
+
+
+-- Print method
+function classOperator:print (ident,close)
+ print(ident.."Operator{")
+ print(ident.." kind = '"..self.kind.."',")
+ print(ident.." mod = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." const = '"..self.const.."',")
+ print(ident.." cname = '"..self.cname.."',")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.." args = {")
+ local i=1
+ while self.args[i] do
+ self.args[i]:print(ident.." ",",")
+ i = i+1
+ end
+ print(ident.." }")
+ print(ident.."}"..close)
+end
+
+-- Internal constructor
+function _Operator (t)
+ setmetatable(t,classOperator)
+
+ if t.const ~= 'const' and t.const ~= '' then
+ error("#invalid 'const' specification")
+ end
+
+ append(t)
+ if not t:inclass() then
+ error("#operator can only be defined as class member")
+ end
+
+ t.name = t.name .. "_" .. _TM[t.kind]
+ t.cname = t:cfuncname("tolua")..t:overload(t)
+ t.name = "operator" .. t.kind -- set appropriate calling name
+ return t
+end
+
+-- Constructor
+function Operator (d,k,a,c)
+ local ref = ''
+ local t = split(strsub(a,2,strlen(a)-1),',') -- eliminate braces
+ local i=1
+ local l = {n=0}
+ while t[i] do
+ l.n = l.n+1
+ l[l.n] = Declaration(t[i],'var')
+ i = i+1
+ end
+ if k == '[]' then
+ local _
+ _, _, ref = strfind(d,'(&)')
+ d = gsub(d,'&','')
+ elseif k=='&[]' then
+ l.n = l.n+1
+ l[l.n] = Declaration(d,'var')
+ l[l.n].name = 'tolua_value'
+ end
+ local f = Declaration(d,'func')
+ if k == '[]' and (l[1]==nil or isbasic(l[1].type)~='number') then
+ error('operator[] can only be defined for numeric index.')
+ end
+ f.args = l
+ f.const = c
+ f.kind = gsub(k,"%s","")
+ if not _TM[f.kind] then
+ error("tolua: no support for operator" .. f.kind)
+ end
+ f.lname = ".".._TM[f.kind]
+ if f.kind == '[]' and ref=='&' and f.const~='const' then
+ Operator(d,'&'..k,a,c) -- create correspoding set operator
+ end
+ return _Operator(f)
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/package.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/package.lua
new file mode 100644
index 0000000..d0a7b08
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/package.lua
@@ -0,0 +1,280 @@
+-- tolua: package class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: package.lua,v 1.4 2009/11/24 16:45:15 fabraham Exp $
+
+-- 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.
+
+
+
+-- Package class
+-- Represents the whole package being bound.
+-- The following fields are stored:
+-- {i} = list of objects in the package.
+classPackage = {
+ classtype = 'package'
+}
+classPackage.__index = classPackage
+setmetatable(classPackage,classContainer)
+
+-- Print method
+function classPackage:print ()
+ print("Package: "..self.name)
+ local i=1
+ while self[i] do
+ self[i]:print("","")
+ i = i+1
+ end
+end
+
+function classPackage:preprocess ()
+ -- avoid preprocessing embedded Lua code
+ local L = {}
+ self.code = gsub(self.code,"\n%s*%$%[","\1") -- deal with embedded C code
+ self.code = gsub(self.code,"\n%s*%$%]","\2")
+ self.code = gsub(self.code,"(%b\1\2)", function (c)
+ tinsert(L,c)
+ return "\n#["..getn(L).."]#"
+ end)
+ -- avoid preprocessing embedded C code
+ local C = {}
+ self.code = gsub(self.code,"\n%s*%$%<","\3") -- deal with embedded C code
+ self.code = gsub(self.code,"\n%s*%$%>","\4")
+ self.code = gsub(self.code,"(%b\3\4)", function (c)
+ tinsert(C,c)
+ return "\n#<"..getn(C)..">#"
+ end)
+
+ -- avoid preprocessing verbatim lines
+ local V = {}
+ self.code = gsub(self.code,"\n(%s*%$[^%[%]][^\n]*)",function (v)
+ tinsert(V,v)
+ return "\n#"..getn(V).."#"
+ end)
+ -- perform global substitution
+
+ self.code = gsub(self.code,"(//[^\n]*)","") -- eliminate C++ comments
+ self.code = gsub(self.code,"/%*","\1")
+ self.code = gsub(self.code,"%*/","\2")
+ self.code = gsub(self.code,"%b\1\2","")
+ self.code = gsub(self.code,"\1","/%*")
+ self.code = gsub(self.code,"\2","%*/")
+ self.code = gsub(self.code,"%s*@%s*","@") -- eliminate spaces beside @
+ self.code = gsub(self.code,"%s?inline(%s)","%1") -- eliminate 'inline' keyword
+ self.code = gsub(self.code,"%s?extern(%s)","%1") -- eliminate 'extern' keyword
+ self.code = gsub(self.code,"%s?virtual(%s)","%1") -- eliminate 'virtual' keyword
+ self.code = gsub(self.code,"public:","") -- eliminate 'public:' keyword
+ self.code = gsub(self.code,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*'
+ self.code = gsub(self.code,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*'
+ self.code = gsub(self.code,"([^%w_])char%s*%*","%1_cstring ") -- substitute 'char*'
+ self.code = gsub(self.code,"([^%w_])lua_State%s*%*","%1_lstate ") -- substitute 'lua_State*'
+
+ -- restore embedded code
+ self.code = gsub(self.code,"%#%[(%d+)%]%#",function (n)
+ return L[tonumber(n)]
+ end)
+ -- restore embedded code
+ self.code = gsub(self.code,"%#%<(%d+)%>%#",function (n)
+ return C[tonumber(n)]
+ end)
+ -- restore verbatim lines
+ self.code = gsub(self.code,"%#(%d+)%#",function (n)
+ return V[tonumber(n)]
+ end)
+end
+
+-- translate verbatim
+function classPackage:preamble ()
+ output('/*\n')
+ output('** Lua binding: '..self.name..'\n')
+-- fred: removido porque gera trabalho na hora de fazer diffs
+-- output('** Generated automatically by '..TOLUA_VERSION..' on '..date()..'.\n')
+ output('*/\n\n')
+
+ output('#include "tolua.h"\n\n')
+ output('#ifndef __cplusplus\n')
+ output('#include <stdlib.h>\n')
+ output('#endif\n')
+ output('#ifdef __cplusplus\n')
+ output('extern "C" int tolua_bnd_takeownership (lua_State* L); // from tolua_map.c\n')
+ output('#else\n')
+ output('int tolua_bnd_takeownership (lua_State* L); /* from tolua_map.c */\n')
+ output('#endif\n')
+ output('#include <string.h>\n\n')
+
+ if not flags.h then
+ output('/* Exported function */')
+ output('TOLUA_API int tolua_'..self.name..'_open (lua_State* tolua_S);')
+ output('LUALIB_API int luaopen_'..self.name..' (lua_State* tolua_S);')
+ output('\n')
+ end
+
+ local i=1
+ while self[i] do
+ self[i]:preamble()
+ i = i+1
+ end
+
+
+
+ if self:requirecollection(_collect) then
+ output('\n')
+ output('/* function to release collected object via destructor */')
+ output('#ifdef __cplusplus\n')
+ for i,v in pairs(_collect) do
+ output('\nstatic int '..v..' (lua_State* tolua_S)')
+ output('{')
+ output(' '..i..'* self = ('..i..'*) tolua_tousertype(tolua_S,1,0);')
+ output(' tolua_release(tolua_S,self);')
+ output(' delete self;')
+ output(' return 0;')
+ output('}')
+ end
+ output('#endif\n\n')
+ end
+
+ output('\n')
+ output('/* function to register type */')
+ output('static void tolua_reg_types (lua_State* tolua_S)')
+ output('{')
+ foreach(_usertype,function(n,v) output(' tolua_usertype(tolua_S,"',v,'");') end)
+ output('}')
+ output('\n')
+end
+
+-- register package
+-- write package open function
+function classPackage:register ()
+ push(self)
+
+ output("/* Open lib function */")
+ output('LUALIB_API int luaopen_'..self.name..' (lua_State* tolua_S)')
+ output("{")
+ output(" tolua_open(tolua_S);")
+ output(" tolua_reg_types(tolua_S);")
+ output(" tolua_module(tolua_S,NULL,",self:hasvar(),");")
+ output(" tolua_beginmodule(tolua_S,NULL);")
+ local i=1
+ while self[i] do
+ self[i]:register()
+ i = i+1
+ end
+ output(" tolua_endmodule(tolua_S);")
+ output(" return 1;")
+ output("}")
+
+ output("/* Open tolua function */")
+ output("TOLUA_API int tolua_"..self.name.."_open (lua_State* tolua_S)")
+ output("{")
+ output(" lua_pushcfunction(tolua_S, luaopen_"..self.name..");")
+ output(' lua_pushstring(tolua_S, "'..self.name..'");')
+ output(" lua_call(tolua_S, 1, 0);")
+ output(" return 1;")
+ output("}")
+
+ pop()
+end
+
+-- write header file
+function classPackage:header ()
+ output('/*\n') output('** Lua binding: '..self.name..'\n')
+ output('** Generated automatically by '..TOLUA_VERSION..' on '..date()..'.\n')
+ output('*/\n\n')
+
+ if not flags.h then
+ output('/* Exported function */')
+ output('TOLUA_API int tolua_'..self.name..'_open (lua_State* tolua_S);')
+ output('LUALIB_API int luaopen_'..self.name..' (lua_State* tolua_S);')
+ output('\n')
+ end
+end
+
+-- Internal constructor
+function _Package (self)
+ setmetatable(self,classPackage)
+ return self
+end
+
+-- Parse C header file with tolua directives
+-- *** Thanks to Ariel Manzur for fixing bugs in nested directives ***
+function extract_code(fn,s)
+ local code = '\n$#include "'..fn..'"\n'
+ s= "\n" .. s .. "\n" -- add blank lines as sentinels
+ local _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n")
+ while e do
+ t = strlower(t)
+ if t == "begin" then
+ _,e,c = strfind(s,"(.-)\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[Ee][Nn][Dd][^\n]*\n",e)
+ if not e then
+ tolua_error("Unbalanced 'tolua_begin' directive in header file")
+ end
+ end
+ code = code .. c .. "\n"
+ _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n",e)
+ end
+ return code
+end
+
+-- Constructor
+-- Expects the package name, the file extension, and the file text.
+function Package (name,fn)
+ local ext = "pkg"
+
+ -- open input file, if any
+ if fn then
+ local st, msg = readfrom(flags.f)
+ if not st then
+ error('#'..msg)
+ end
+ local _; _, _, ext = strfind(fn,".*%.(.*)$")
+ end
+ local code = "\n" .. read('*a')
+ if ext == 'h' or ext == 'hpp' then
+ code = extract_code(fn,code)
+ end
+
+ -- close file
+ if fn then
+ readfrom()
+ end
+
+ -- deal with renaming directive
+ code = gsub(code,'%s*%$renaming%s*(.-)%s*\n', function (r) appendrenaming(r) return "\n" end)
+
+ -- deal with include directive
+ local nsubst
+ repeat
+ code,nsubst = gsub(code,'\n%s*%$(.)file%s*"(.-)"%s*\n',
+ function (kind,fn)
+ local _, _, ext = strfind(fn,".*%.(.*)$")
+ local fp,msg = openfile(fn,'r')
+ if not fp then
+ error('#'..msg..': '..fn)
+ end
+ local s = read(fp,'*a')
+ closefile(fp)
+ if kind == 'c' or kind == 'h' then
+ return extract_code(fn,s)
+ elseif kind == 'p' then
+ return "\n\n" .. s
+ elseif kind == 'l' then
+ return "\n$[\n" .. s .. "\n$]\n"
+ else
+ error('#Invalid include directive (use $cfile, $pfile or $lfile)')
+ end
+ end)
+ until nsubst==0
+
+ local t = _Package(_Container{name=name, code=code})
+ push(t)
+ t:preprocess()
+ t:parse(t.code)
+ pop()
+ return t
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/typedef.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/typedef.lua
new file mode 100644
index 0000000..e7b4bc9
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/typedef.lua
@@ -0,0 +1,68 @@
+-- tolua: typedef class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: typedef.lua,v 1.3 2009/11/24 16:45:15 fabraham Exp $
+
+-- 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.
+
+
+
+-- Typedef class
+-- Represents a type synonym.
+-- The 'de facto' type replaces the typedef before the
+-- remaining code is parsed.
+-- The following fields are stored:
+-- utype = typedef name
+-- type = 'the facto' type
+-- mod = modifiers to the 'de facto' type
+classTypedef = {
+ utype = '',
+ mod = '',
+ type = ''
+}
+classTypedef.__index = classTypedef
+
+-- Print method
+function classTypedef:print (ident,close)
+ print(ident.."Typedef{")
+ print(ident.." utype = '"..self.utype.."',")
+ print(ident.." mod = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.."}"..close)
+end
+
+-- Return it's not a variable
+function classTypedef:isvariable ()
+ return false
+end
+
+-- Internal constructor
+function _Typedef (t)
+ setmetatable(t,classTypedef)
+ appendtypedef(t)
+ return t
+end
+
+-- Constructor
+-- Expects one string representing the type definition.
+function Typedef (s)
+ if strfind(s,'[%*&]') then
+ tolua_error("#invalid typedef: pointers (and references) are not supported")
+ end
+ local t = split(gsub(s,"%s%s*"," ")," ")
+ if not isbasic(t[t.n]) then
+ return _Typedef {
+ utype = t[t.n],
+ type = t[t.n-1],
+ mod = concat(t,1,t.n-2),
+ }
+ else
+ return nil
+ end
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/variable.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/variable.lua
new file mode 100644
index 0000000..517a91c
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/variable.lua
@@ -0,0 +1,253 @@
+-- tolua: variable class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: variable.lua,v 1.3 2009/11/24 16:45:15 fabraham Exp $
+
+-- 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.
+
+
+-- Variable class
+-- Represents a extern variable or a public member of a class.
+-- Stores all fields present in a declaration.
+classVariable = {
+ _get = {}, -- mapped get functions
+ _set = {}, -- mapped set functions
+}
+classVariable.__index = classVariable
+setmetatable(classVariable,classDeclaration)
+
+-- Print method
+function classVariable:print (ident,close)
+ print(ident.."Variable{")
+ print(ident.." mod = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ if self.dim then print(ident.." dim = '"..self.dim.."',") end
+ print(ident.." def = '"..self.def.."',")
+ print(ident.." ret = '"..self.ret.."',")
+ print(ident.."}"..close)
+end
+
+-- Generates C function name
+function classVariable:cfuncname (prefix)
+ local parent = ""
+ local unsigned = ""
+ local ptr = ""
+
+ local p = self:inmodule() or self:innamespace() or self:inclass()
+
+ if p then
+ parent = "_" .. p
+ end
+
+ if strfind(self.mod,"(unsigned)") then
+ unsigned = "_unsigned"
+ end
+
+ if self.ptr == "*" then ptr = "_ptr"
+ elseif self.ptr == "&" then ptr = "_ref"
+ end
+
+ local name = prefix .. parent .. unsigned .. "_" .. gsub(self.name,".*::","") .. ptr
+
+ return name
+
+end
+
+-- check if it is a variable
+function classVariable:isvariable ()
+ return true
+end
+
+-- get variable value
+function classVariable:getvalue (class,static)
+ if class and static then
+ return class..'::'..self.name
+ elseif class then
+ return 'self->'..self.name
+ else
+ return self.name
+ end
+end
+
+-- get variable pointer value
+function classVariable:getpointervalue (class,static)
+ if class and static then
+ return class..'::p'
+ elseif class then
+ return 'self->p'
+ else
+ return 'p'
+ end
+end
+
+-- Write binding functions
+function classVariable:supcode ()
+ local class = self:inclass()
+
+ -- get function ------------------------------------------------
+ if class then
+ output("/* get function:",self.name," of class ",class," */")
+ self.cgetname = self:cfuncname("tolua_get_"..class)
+ else
+ output("/* get function:",self.name," */")
+ self.cgetname = self:cfuncname("tolua_get")
+ end
+
+ output("static int",self.cgetname,"(lua_State* tolua_S)")
+ output("{")
+
+ -- declare self, if the case
+ local _,_,static = strfind(self.mod,'^%s*(static)')
+ if class and static==nil then
+ output(' ',class,'*','self = ')
+ output('(',class,'*) ')
+ output('tolua_tousertype(tolua_S,1,0);')
+ elseif static then
+ _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+ end
+
+
+ -- check self value
+ if class and static==nil then
+ output('#ifndef TOLUA_RELEASE\n')
+ output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);');
+ output('#endif\n')
+ end
+
+ -- return value
+ local type = self.type
+ if gsub(type,'const ','')=='char' and self.dim~='' then
+ type = 'char*'
+ end
+ local t,ct = isbasic(type)
+ if t then
+ output(' tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static)..');')
+ else
+ t = self.type
+ if self.ptr == '&' or self.ptr == '' then
+ output(' tolua_pushusertype(tolua_S,(void*)&'..self:getvalue(class,static)..',"',t,'");')
+ else
+ output(' tolua_pushusertype(tolua_S,(void*)'..self:getvalue(class,static)..',"',t,'");')
+ end
+ end
+ output(' return 1;')
+ output('}')
+ output('\n')
+
+ -- set function ------------------------------------------------
+ if not strfind(self.type,'const') then
+ if class then
+ output("/* set function:",self.name," of class ",class," */")
+ self.csetname = self:cfuncname("tolua_set_"..class)
+ else
+ output("/* set function:",self.name," */")
+ self.csetname = self:cfuncname("tolua_set")
+ end
+ output("static int",self.csetname,"(lua_State* tolua_S)")
+ output("{")
+
+ -- declare self, if the case
+ if class and static==nil then
+ output(' ',class,'*','self = ')
+ output('(',class,'*) ')
+ output('tolua_tousertype(tolua_S,1,0);')
+ -- check self value
+ end
+ -- check types
+ output('#ifndef TOLUA_RELEASE\n')
+ output(' tolua_Error tolua_err;')
+ if class and static==nil then
+ output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);');
+ elseif static then
+ _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+ end
+
+ -- check variable type
+ output(' if (!'..self:outchecktype(2,true)..')')
+ output(' tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);')
+ output('#endif\n')
+
+ -- assign value
+ local def = 0
+ if self.def ~= '' then def = self.def end
+ if self.type == 'char' and self.dim ~= '' then -- is string
+ output(' strncpy(')
+ if class and static then
+ output(class..'::'..self.name)
+ elseif class then
+ output('self->'..self.name)
+ else
+ output(self.name)
+ end
+ output(',tolua_tostring(tolua_S,2,',def,'),',self.dim,'-1);')
+ else
+ local ptr = ''
+ if self.ptr~='' then ptr = '*' end
+ output(' ')
+ if class and static then
+ output(class..'::'..self.name)
+ elseif class then
+ output('self->'..self.name)
+ else
+ output(self.name)
+ end
+ local t = isbasic(self.type)
+ output(' = ')
+ if not t and ptr=='' then output('*') end
+ output('((',self.mod,self.type)
+ if not t then
+ output('*')
+ end
+ output(') ')
+ if t then
+ if isenum(self.type) then
+ output('(int) ')
+ end
+ if t=='function' then t='value' end
+ output('tolua_to'..t,'(tolua_S,2,',def,'));')
+ else
+ output('tolua_tousertype(tolua_S,2,',def,'));')
+ end
+ end
+ output(' return 0;')
+ output('}')
+ output('\n')
+ end
+
+end
+
+function classVariable:register ()
+ local parent = self:inmodule() or self:innamespace() or self:inclass()
+ if not parent then
+ if classVariable._warning==nil then
+ warning("Mapping variable to global may degrade performance")
+ classVariable._warning = 1
+ end
+ end
+ if self.csetname then
+ output(' tolua_variable(tolua_S,"'..self.lname..'",'..self.cgetname..','..self.csetname..');')
+ else
+ output(' tolua_variable(tolua_S,"'..self.lname..'",'..self.cgetname..',NULL);')
+ end
+end
+
+-- Internal constructor
+function _Variable (t)
+ setmetatable(t,classVariable)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the variable declaration.
+function Variable (s)
+ return _Variable (Declaration(s,'var'))
+end
+
+
diff --git a/ThirdParty/tolua-5.2.4/src/bin/lua/verbatim.lua b/ThirdParty/tolua-5.2.4/src/bin/lua/verbatim.lua
new file mode 100644
index 0000000..1581092
--- /dev/null
+++ b/ThirdParty/tolua-5.2.4/src/bin/lua/verbatim.lua
@@ -0,0 +1,76 @@
+-- tolua: verbatim class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: verbatim.lua,v 1.3 2009/11/24 16:45:15 fabraham Exp $
+
+-- 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.
+
+
+
+-- Verbatim class
+-- Represents a line translated directed to the binding file.
+-- The following filds are stored:
+-- line = line text
+classVerbatim = {
+ line = '',
+ cond = nil, -- condition: where to generate the code (s=suport, r=register)
+}
+classVerbatim.__index = classVerbatim
+setmetatable(classVerbatim,classFeature)
+
+-- preamble verbatim
+function classVerbatim:preamble ()
+ if self.cond == '' then
+ write(self.line)
+ end
+end
+
+-- support code
+function classVerbatim:supcode ()
+ if strfind(self.cond,'s') then
+ write(self.line)
+ write('\n')
+ end
+end
+
+-- register code
+function classVerbatim:register ()
+ if strfind(self.cond,'r') then
+ write(self.line)
+ end
+end
+
+
+-- Print method
+function classVerbatim:print (ident,close)
+ print(ident.."Verbatim{")
+ print(ident.." line = '"..self.line.."',")
+ print(ident.."}"..close)
+end
+
+
+-- Internal constructor
+function _Verbatim (t)
+ setmetatable(t,classVerbatim)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the text line
+function Verbatim (l,cond)
+ if strsub(l,1,1) == '$' then
+ cond = 'sr' -- generates in both suport and register fragments
+ l = strsub(l,2)
+ end
+ return _Verbatim {
+ line = l,
+ cond = cond or '',
+ }
+end
+
+