[Orxonox-commit 606] r3138 - in branches/pch/src/tolua: . lua
rgrieder at orxonox.net
rgrieder at orxonox.net
Wed Jun 10 16:01:43 CEST 2009
Author: rgrieder
Date: 2009-06-10 16:01:42 +0200 (Wed, 10 Jun 2009)
New Revision: 3138
Removed:
branches/pch/src/tolua/lua/template_class.lua
Modified:
branches/pch/src/tolua/CMakeLists.txt
branches/pch/src/tolua/README
branches/pch/src/tolua/VERSION
branches/pch/src/tolua/all-5.0.lua
branches/pch/src/tolua/all-5.1.lua
branches/pch/src/tolua/changes_orxonox.diff
branches/pch/src/tolua/lua/array.lua
branches/pch/src/tolua/lua/basic.lua
branches/pch/src/tolua/lua/class.lua
branches/pch/src/tolua/lua/code.lua
branches/pch/src/tolua/lua/compat-5.1.lua
branches/pch/src/tolua/lua/container.lua
branches/pch/src/tolua/lua/declaration.lua
branches/pch/src/tolua/lua/doit.lua
branches/pch/src/tolua/lua/enumerate.lua
branches/pch/src/tolua/lua/feature.lua
branches/pch/src/tolua/lua/function.lua
branches/pch/src/tolua/lua/operator.lua
branches/pch/src/tolua/lua/package.lua
branches/pch/src/tolua/lua/variable.lua
branches/pch/src/tolua/tolua++.h
branches/pch/src/tolua/tolua.c
branches/pch/src/tolua/tolua_event.c
branches/pch/src/tolua/tolua_is.c
branches/pch/src/tolua/tolua_map.c
branches/pch/src/tolua/tolua_push.c
branches/pch/src/tolua/tolua_to.c
Log:
Tolua update to v1.0.93 is not working properly and I would not know how to fix it. I have created a patch however, just in case we need it after all.
Modified: branches/pch/src/tolua/CMakeLists.txt
===================================================================
--- branches/pch/src/tolua/CMakeLists.txt 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/CMakeLists.txt 2009-06-10 14:01:42 UTC (rev 3138)
@@ -53,7 +53,7 @@
ORXONOX_ADD_EXECUTABLE(tolua++app_orxonox
ORXONOX_EXTERNAL
VERSION
- 1.0.93
+ 1.0.92
LINK_LIBRARIES
${LUA_LIBRARIES}
SOURCE_FILES
@@ -87,7 +87,6 @@
${CMAKE_CURRENT_SOURCE_DIR}/lua/operator.lua
${CMAKE_CURRENT_SOURCE_DIR}/lua/class.lua
${CMAKE_CURRENT_SOURCE_DIR}/lua/clean.lua
- ${CMAKE_CURRENT_SOURCE_DIR}/lua/template_class.lua
${CMAKE_CURRENT_SOURCE_DIR}/lua/doit.lua
CACHE INTERNAL ""
Modified: branches/pch/src/tolua/README
===================================================================
--- branches/pch/src/tolua/README 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/README 2009-06-10 14:01:42 UTC (rev 3138)
@@ -13,12 +13,14 @@
to Lua. It also provides facilities to create Lua modules.
* Availability
+ tolua is freely available; 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.
- tolua++ is freely available for both academic and commercial purposes.
- See COPYRIGHT for details.
-
- tolua++ can be downloaded from the sites below:
+ tolua can be downloaded from the sites below:
http://www.codenix.com/~tolua/
+ http://www.codenix.com/~tolua/tolua++-1.0.tar.bz2
* Installation
See INSTALL.
Modified: branches/pch/src/tolua/VERSION
===================================================================
--- branches/pch/src/tolua/VERSION 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/VERSION 2009-06-10 14:01:42 UTC (rev 3138)
@@ -1,4 +1,4 @@
-Tolua++ v1.0.93 with changes:
+Tolua++ v1.0.92 with changes:
- Exception handling by CEGUI team
- Corrected all indentation by Orxonox
Modified: branches/pch/src/tolua/all-5.0.lua
===================================================================
--- branches/pch/src/tolua/all-5.0.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/all-5.0.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -17,7 +17,6 @@
dofile(path.."lua/operator.lua")
dofile(path.."lua/class.lua")
dofile(path.."lua/clean.lua")
-dofile(path.."lua/template_class.lua")
--dofile(path.."lua/custom.lua")
dofile(path.."lua/doit.lua")
Modified: branches/pch/src/tolua/all-5.1.lua
===================================================================
--- branches/pch/src/tolua/all-5.1.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/all-5.1.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -18,7 +18,6 @@
dofile(path.."lua/operator.lua")
dofile(path.."lua/class.lua")
dofile(path.."lua/clean.lua")
-dofile(path.."lua/template_class.lua")
--dofile(path.."lua/custom.lua")
dofile(path.."lua/doit.lua")
Modified: branches/pch/src/tolua/changes_orxonox.diff
===================================================================
--- branches/pch/src/tolua/changes_orxonox.diff 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/changes_orxonox.diff 2009-06-10 14:01:42 UTC (rev 3138)
@@ -1,5 +1,6 @@
---- tolua++.h Tue Jun 9 16:27:17 2009
-+++ tolua++.h Tue Jun 9 14:50:04 2009
+diff -ruN tolua/tolua++.h tolua2/tolua++.h
+--- tolua/tolua++.h Wed Jan 28 21:51:38 2009
++++ tolua2/tolua++.h Sat Jan 10 14:48:44 2009
@@ -16,9 +16,34 @@
#ifndef TOLUA_H
#define TOLUA_H
@@ -35,8 +36,9 @@
#define TOLUA_VERSION "tolua++-1.0.92"
---- tolua.c Tue Jun 9 16:27:12 2009
-+++ tolua.c Tue Jun 9 14:50:04 2009
+diff -ruN tolua/tolua.c tolua2/tolua.c
+--- tolua/tolua.c Wed Jan 28 21:51:00 2009
++++ tolua2/tolua.c Sat Jan 10 14:48:45 2009
@@ -4,6 +4,8 @@
** TeCGraf/PUC-Rio
** Aug 2003
@@ -55,7 +57,7 @@
" -p : parse only.\n"
" -P : parse and print structure information (for debug).\n"
" -S : disable support for c++ strings.\n"
-@@ -65,12 +69,12 @@
+@@ -64,12 +68,12 @@
}
static void add_extra (lua_State* L, char* value) {
@@ -74,7 +76,7 @@
};
static void error (char* o)
-@@ -82,6 +86,9 @@
+@@ -81,6 +85,9 @@
int main (int argc, char* argv[])
{
@@ -84,7 +86,7 @@
#ifdef LUA_VERSION_NUM /* lua 5.1 */
lua_State* L = luaL_newstate();
luaL_openlibs(L);
-@@ -98,6 +105,7 @@
+@@ -97,6 +104,7 @@
lua_pushstring(L,TOLUA_VERSION); lua_setglobal(L,"TOLUA_VERSION");
lua_pushstring(L,LUA_VERSION); lua_setglobal(L,"TOLUA_LUA_VERSION");
@@ -92,7 +94,7 @@
if (argc==1)
{
help();
-@@ -125,6 +133,14 @@
+@@ -124,6 +132,14 @@
case 'o': setfield(L,t,"o",argv[++i]); break;
case 'n': setfield(L,t,"n",argv[++i]); break;
case 'H': setfield(L,t,"H",argv[++i]); break;
@@ -107,7 +109,7 @@
case 'S': setfield(L,t,"S",""); break;
case '1': setfield(L,t,"1",""); break;
case 'L': setfield(L,t,"L",argv[++i]); break;
-@@ -145,25 +161,53 @@
+@@ -143,25 +159,53 @@
}
lua_pop(L,1);
}
Modified: branches/pch/src/tolua/lua/array.lua
===================================================================
--- branches/pch/src/tolua/lua/array.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/array.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -101,15 +101,14 @@
-- return value
local t,ct = isbasic(self.type)
- local push_func = get_push_function(t)
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(' ',push_func,'(tolua_S,(void*)&'..self:getvalue(class,static)..',"',t,'");')
+ output(' tolua_pushusertype(tolua_S,(void*)&'..self:getvalue(class,static)..',"',t,'");')
else
- output(' ',push_func,'(tolua_S,(void*)'..self:getvalue(class,static)..',"',t,'");')
+ output(' tolua_pushusertype(tolua_S,(void*)'..self:getvalue(class,static)..',"',t,'");')
end
end
output(' return 1;')
@@ -193,8 +192,7 @@
if t then
output('tolua_to'..t,'(tolua_S,3,',def,'));')
else
- local to_func = get_to_function(self.type)
- output(to_func,'(tolua_S,3,',def,'));')
+ output('tolua_tousertype(tolua_S,3,',def,'));')
end
output(' return 0;')
output('}')
@@ -204,10 +202,6 @@
end
function classArray:register (pre)
- if not self:check_public_access() then
- return
- end
-
pre = pre or ''
if self.csetname then
output(pre..'tolua_array(tolua_S,"'..self.lname..'",'..self.cgetname..','..self.csetname..');')
Modified: branches/pch/src/tolua/lua/basic.lua
===================================================================
--- branches/pch/src/tolua/lua/basic.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/basic.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -111,9 +111,6 @@
end
function warning (msg)
- if flags.q then
- return
- end
local out = _OUTPUT
_OUTPUT = _STDERR
write("\n** tolua warning: "..msg..".\n\n")
@@ -335,11 +332,7 @@
end
--- called before starting output
-function pre_output_hook(package)
-end
-
-- called after writing all the output.
-- takes the Package object
function post_output_hook(package)
@@ -360,57 +353,4 @@
return nil
end
--- called from classFunction:supcode, before the call to the function is output
-function pre_call_hook(f)
-end
-
--- called from classFunction:supcode, after the call to the function is output
-function post_call_hook(f)
-
-end
-
--- called before the register code is output
-function pre_register_hook(package)
-
-end
-
--- called to output an error message
-function output_error_hook(str, arg)
- return string.format(str, arg)
-end
-
--- custom pushers
-
-_push_functions = {}
-_is_functions = {}
-_to_functions = {}
-
-_base_push_functions = {}
-_base_is_functions = {}
-_base_to_functions = {}
-
-local function search_base(t, funcs)
- local class = _global_classes[t]
-
- while class do
- if funcs[class.type] then
- return funcs[class.type]
- end
- class = _global_classes[class.btype]
- end
- return nil
-end
-
-function get_push_function(t)
- return _push_functions[t] or search_base(t, _base_push_functions) or "tolua_pushusertype"
-end
-
-function get_to_function(t)
- return _to_functions[t] or search_base(t, _base_to_functions) or "tolua_tousertype"
-end
-
-function get_is_function(t)
- return _is_functions[t] or search_base(t, _base_is_functions) or "tolua_isusertype"
-end
-
Modified: branches/pch/src/tolua/lua/class.lua
===================================================================
--- branches/pch/src/tolua/lua/class.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/class.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -63,7 +63,7 @@
-- return collection requirement
function classClass:requirecollection (t)
- if self.flags.protected_destructor or (not self:check_public_access()) then
+ if self.flags.protected_destructor then
return false
end
push(self)
@@ -147,7 +147,7 @@
-- check for template
b = string.gsub(b, "^{%s*TEMPLATE_BIND", "{\nTOLUA_TEMPLATE_BIND")
- local t,_,T,I = string.find(b, '^{%s*TOLUA_TEMPLATE_BIND%s*%(+%s*\"?([^\",]*)\"?%s*,%s*([^%)]*)%s*%)+')
+ local t,_,T,I = string.find(b, "^{%s*TOLUA_TEMPLATE_BIND%s*%(+%s*\"?([^\",]*)\"?%s*,%s*([^%)]*)%s*%)+")
if t then
-- remove quotes
@@ -158,13 +158,33 @@
-- remove TEMPLATE_BIND line
local bs = string.gsub(b, "^{%s*TOLUA_TEMPLATE_BIND[^\n]*\n", "{\n")
- local Tl = split(T, " ")
- local tc = TemplateClass(n, p, bs, Tl)
+ -- replace
+ for i =1 , types.n do
- tc:throw(types, true)
- --for i=1,types.n do
- -- tc:throw(split_c_tokens(types[i], " "), true)
- --end
+ local Tl = split(T, " ")
+ local Il = split_c_tokens(types[i], " ")
+ local bI = bs
+ local pI = {}
+ for j = 1,Tl.n do
+ Tl[j] = findtype(Tl[j]) or Tl[j]
+ bI = string.gsub(bI, "([^_%w])"..Tl[j].."([^_%w])", "%1"..Il[j].."%2")
+ if p then
+ for i=1,table.getn(p) do
+ pI[i] = string.gsub(p[i], "([^_%w]?)"..Tl[j].."([^_%w]?)", "%1"..Il[j].."%2")
+ end
+ end
+ end
+ --local append = "<"..string.gsub(types[i], "%s+", ",")..">"
+ local append = "<"..concat(Il, 1, table.getn(Il), ",")..">"
+ append = string.gsub(append, "%s*,%s*", ",")
+ append = string.gsub(append, ">>", "> >")
+ for i=1,table.getn(pI) do
+ --pI[i] = string.gsub(pI[i], ">>", "> >")
+ pI[i] = resolve_template_types(pI[i])
+ end
+ bI = string.gsub(bI, ">>", "> >")
+ Class(n..append, pI, bI)
+ end
return
end
Modified: branches/pch/src/tolua/lua/code.lua
===================================================================
--- branches/pch/src/tolua/lua/code.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/code.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -46,18 +46,10 @@
first_line = ""
end
- -- pad to 16 bytes
- local npad = 16 - (#s % 16)
- local spad = ""
- for i=1,npad do
- spad = spad .. "-"
- end
- s = s..spad
-
-- convert to C
output('\n'..pre..'{ /* begin embedded lua code */\n')
output(pre..' int top = lua_gettop(tolua_S);')
- output(pre..' static const unsigned char B[] = {\n ')
+ output(pre..' static unsigned char B[] = {\n ')
local t={n=0}
local b = gsub(s, '(.)',
function (c)
Modified: branches/pch/src/tolua/lua/compat-5.1.lua
===================================================================
--- branches/pch/src/tolua/lua/compat-5.1.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/compat-5.1.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -25,9 +25,6 @@
end
local f = load(getfile, path)
- if not f then
- error("error loading file "..path)
- end
return f()
end
Modified: branches/pch/src/tolua/lua/container.lua
===================================================================
--- branches/pch/src/tolua/lua/container.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/container.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -614,13 +614,6 @@
-- 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 not b then
- -- try function pointer
- b,e,decl,arg,const = strfind(s,"^%s*([^%(;\n]+%b())%s*(%b())%s*;%s*")
- if b then
- decl = string.gsub(decl, "%(%s*%*([^%)]*)%s*%)", " %1 ")
- end
- end
if b then
if virt and string.find(virt, "[=0]") then
if self.flags then
@@ -653,23 +646,22 @@
local b,e,name,base,body
base = '' body = ''
b,e,name = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*;") -- dummy class
- local dummy = false
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*")
+ 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*")
+ 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*")
+ 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%s*[_%w]*%s*(%b{})%s*([_%w][_%w@]*)%s*;")
+ b,e,body,name = strfind(s,"^%s*typedef%s%s*struct%s%s*[_%w]*%s*(%b{})%s*([_%w][_%w@]*)%s*;%s*")
end
end
end
- else dummy = 1 end
- else dummy = 1 end
+ end
+ end
if b then
if base ~= '' then
base = string.gsub(base, "^%s*:%s*", "")
@@ -682,13 +674,6 @@
end
_curr_code = strsub(s,b,e)
Class(name,base,body)
- if not dummy then
- varb,vare,varname = string.find(s, "^%s*([_%w]+)%s*;", e+1)
- if varb then
- Variable(name.." "..varname)
- e = vare
- end
- end
return strsub(s,e+1)
end
end
@@ -737,7 +722,7 @@
-- try array
do
- local b,e,decl = strfind(s,"^%s*([_%w][][_@%s%w%d%*&:<>]*[]_%w%d])%s*;%s*")
+ 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)
@@ -757,7 +742,7 @@
function classContainer:parse (s)
- --self.curr_member_access = nil
+ self.curr_member_access = nil
while s ~= '' do
s = self:doparse(s)
Modified: branches/pch/src/tolua/lua/declaration.lua
===================================================================
--- branches/pch/src/tolua/lua/declaration.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/declaration.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -139,17 +139,13 @@
m = split_c_tokens(string.sub(m, 2, -2), ",")
for i=1, table.getn(m) do
m[i] = string.gsub(m[i],"%s*([%*&])", "%1")
- if not isbasic(m[i]) then
- if not isenum(m[i]) then _, m[i] = applytypedef("", m[i]) end
- m[i] = findtype(m[i]) or m[i]
- m[i] = resolve_template_types(m[i])
- end
+ m[i] = findtype(m[i]) or m[i]
+ m[i] = resolve_template_types(m[i])
end
local b,i
type,b,i = break_template(type)
- --print("concat is ",concat(m, 1, m.n))
- local template_part = "<"..concat(m, 1, m.n, ",")..">"
+ local template_part = "<"..string.gsub(concat(m, 1, m.n), " ", ",")..">"
type = rebuild_template(type, b, template_part)
type = string.gsub(type, ">>", "> >")
end
@@ -190,10 +186,10 @@
-- check if array of values are returned to Lua
function classDeclaration:requirecollection (t)
- if self.mod ~= 'const' and
+ if self.mod ~= 'const' and
self.dim and self.dim ~= '' and
not isbasic(self.type) and
- self.ptr == '' and self:check_public_access() then
+ self.ptr == '' then
local type = gsub(self.type,"%s*const%s+","")
t[type] = "tolua_collect_" .. clean_template(type)
return true
@@ -225,18 +221,13 @@
--if t=='string' then
-- return 'tolua_isstringarray(tolua_S,'..narg..','..def..',&tolua_err)'
--else
- return '!tolua_istable(tolua_S,'..narg..',0,&tolua_err)'
+ return 'tolua_istable(tolua_S,'..narg..',0,&tolua_err)'
--end
elseif t then
- return '!tolua_is'..t..'(tolua_S,'..narg..','..def..',&tolua_err)'
+ return 'tolua_is'..t..'(tolua_S,'..narg..','..def..',&tolua_err)'
else
- local is_func = get_is_function(self.type)
- if self.ptr == '&' or self.ptr == '' then
- return '(tolua_isvaluenil(tolua_S,'..narg..',&tolua_err) || !'..is_func..'(tolua_S,'..narg..',"'..self.type..'",'..def..',&tolua_err))'
- else
- return '!'..is_func..'(tolua_S,'..narg..',"'..self.type..'",'..def..',&tolua_err)'
- end
- end
+ return 'tolua_isusertype(tolua_S,'..narg..',"'..self.type..'",'..def..',&tolua_err)'
+ end
end
function classDeclaration:builddeclaration (narg, cplusplus)
@@ -245,7 +236,6 @@
local ptr = ''
local mod
local type = self.type
- local nctype = gsub(self.type,'const%s+','')
if self.dim ~= '' then
type = gsub(self.type,'const%s+','') -- eliminates const modifier for arrays
end
@@ -260,7 +250,7 @@
line = concatparam(line,'[',self.dim,'];')
else
if cplusplus then
- line = concatparam(line,' = Mtolua_new_dim(',type,ptr,', '..self.dim..');')
+ line = concatparam(line,' = new',type,ptr,'['..self.dim..'];')
else
line = concatparam(line,' = (',type,ptr,'*)',
'malloc((',self.dim,')*sizeof(',type,ptr,'));')
@@ -282,7 +272,7 @@
line = concatparam(line,'*')
end
line = concatparam(line,') ')
- if isenum(nctype) then
+ if isenum(type) then
line = concatparam(line,'(int) ')
end
local def = 0
@@ -295,8 +285,7 @@
if t then
line = concatparam(line,'tolua_to'..t,'(tolua_S,',narg,',',def,'));')
else
- local to_func = get_to_function(type)
- line = concatparam(line,to_func..'(tolua_S,',narg,',',def,'));')
+ line = concatparam(line,'tolua_tousertype(tolua_S,',narg,',',def,'));')
end
end
end
@@ -371,7 +360,7 @@
if self.ptr == '' then
output(' {')
output('#ifdef __cplusplus\n')
- output(' void* tolua_obj = Mtolua_new((',type,')(',self.name,'[i]));')
+ output(' void* tolua_obj = new',type,'(',self.name,'[i]);')
output(' tolua_pushfieldusertype_and_takeownership(tolua_S,',narg,',i+1,tolua_obj,"',type,'");')
output('#else\n')
output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&',self.name,'[i],sizeof(',type,'));')
@@ -390,7 +379,7 @@
function classDeclaration:freearray ()
if self.dim ~= '' and tonumber(self.dim)==nil then
output('#ifdef __cplusplus\n')
- output(' Mtolua_delete_dim(',self.name,');')
+ output(' delete []',self.name,';')
output('#else\n')
output(' free(',self.name,');')
output('#endif\n')
@@ -415,8 +404,7 @@
if t and t~='' then
output(' tolua_push'..t..'(tolua_S,(',ct,')'..self.name..');')
else
- local push_func = get_push_function(self.type)
- output(' ',push_func,'(tolua_S,(void*)'..self.name..',"',self.type,'");')
+ output(' tolua_pushusertype(tolua_S,(void*)'..self.name..',"',self.type,'");')
end
return 1
end
Modified: branches/pch/src/tolua/lua/doit.lua
===================================================================
--- branches/pch/src/tolua/lua/doit.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/doit.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -15,7 +15,7 @@
for k,v in ipairs(_extra_parameters or {}) do
- local b,e,name,value = string.find(v, "^([^=]*)=(.*)$")
+ local b,e,name,value = string.find(v, "^([^=])=(.*)$")
if b then
_extra_parameters[name] = value
else
@@ -93,14 +93,8 @@
if flags.P then
p:print()
else
- push(p)
- pre_output_hook(p)
- pop()
p:preamble()
p:supcode()
- push(p)
- pre_register_hook(p)
- pop()
p:register()
push(p)
post_output_hook(p)
Modified: branches/pch/src/tolua/lua/enumerate.lua
===================================================================
--- branches/pch/src/tolua/lua/enumerate.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/enumerate.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -21,16 +21,11 @@
-- register enumeration
function classEnumerate:register (pre)
- if not self:check_public_access() then
- return
- end
pre = pre or ''
local nspace = getnamespace(classContainer.curr)
local i=1
while self[i] do
- if self.lnames[i] and self.lnames[i] ~= "" then
- output(pre..'tolua_constant(tolua_S,"'..self.lnames[i]..'",'..nspace..self[i]..');')
- end
+ output(pre..'tolua_constant(tolua_S,"'..self.lnames[i]..'",'..nspace..self[i]..');')
i = i+1
end
end
@@ -61,11 +56,6 @@
Variable("tolua_readonly int "..varname)
end
end
- local parent = classContainer.curr
- if parent then
- t.access = parent.curr_member_access
- t.global_access = t:check_public_access()
- end
return t
end
Modified: branches/pch/src/tolua/lua/feature.lua
===================================================================
--- branches/pch/src/tolua/lua/feature.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/feature.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -47,12 +47,10 @@
if self.name and self.name~='' then
local n = split(self.name,'@')
self.name = n[1]
- self.name = string.gsub(self.name, ":%d*$", "")
if not n[2] then
n[2] = applyrenaming(n[1])
end
self.lname = n[2] or gsub(n[1],"%[.-%]","")
- self.lname = string.gsub(self.lname, ":%d*$", "")
self.original_name = self.name
self.lname = clean_template(self.lname)
end
@@ -63,17 +61,12 @@
local parent = classContainer.curr
if parent then
self.access = parent.curr_member_access
- self.global_access = self:check_public_access()
else
end
end
function classFeature:check_public_access()
- if type(self.global_access) == "boolean" then
- return self.global_access
- end
-
if self.access and self.access ~= 0 then
return false
end
@@ -128,11 +121,7 @@
n = self.parent:cfuncname(n)
end
- local fname = self.lname
- if not fname or fname == '' then
- fname = self.name
- end
- n = string.gsub(n..'_'.. (fname), "[<>:, \.%*&]", "_")
+ n = string.gsub(n..'_'.. (self.lname or self.name), "[<>:, \.%*&]", "_")
return n
end
Modified: branches/pch/src/tolua/lua/function.lua
===================================================================
--- branches/pch/src/tolua/lua/function.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/function.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -208,7 +208,7 @@
local narg
if class then narg=2 else narg=1 end
if class then
- local func = get_is_function(self.parent.type)
+ local func = 'tolua_isusertype'
local type = self.parent.type
if self.name=='new' or static~=nil then
func = 'tolua_isusertable'
@@ -225,7 +225,7 @@
while self.args[i] do
local btype = isbasic(self.args[i].type)
if btype ~= 'value' and btype ~= 'state' then
- output(' '..self.args[i]:outchecktype(narg)..' ||\n')
+ output(' !'..self.args[i]:outchecktype(narg)..' ||\n')
end
if btype ~= 'state' then
narg = narg+1
@@ -249,8 +249,7 @@
if class and self.name~='new' and static==nil then
output(' ',self.const,self.parent.type,'*','self = ')
output('(',self.const,self.parent.type,'*) ')
- local to_func = get_to_function(self.parent.type)
- output(to_func,'(tolua_S,1,0);')
+ output('tolua_tousertype(tolua_S,1,0);')
elseif static then
_,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
end
@@ -269,7 +268,7 @@
-- check self
if class and self.name~='new' and static==nil then
output('#ifndef TOLUA_RELEASE\n')
- output(' if (!self) tolua_error(tolua_S,"'..output_error_hook("invalid \'self\' in function \'%s\'", self.name)..'", NULL);');
+ output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in function \''..self.name..'\'",NULL);');
output('#endif\n')
end
@@ -312,8 +311,6 @@
local exRaiseError = false
--------------------------------------------------
- pre_call_hook(self)
-
local out = string.find(self.mod, "tolua_outside")
---------------
@@ -325,7 +322,7 @@
-- call function
if class and self.name=='delete' then
- output(' Mtolua_delete(self);')
+ output(' delete self;')
elseif class and self.name == 'operator&[]' then
if flags['1'] then -- for compatibility with tolua5 ?
output(' self->operator[](',self.args[1].name,'-1) = ',self.args[2].name,';')
@@ -354,7 +351,7 @@
output(' ')
end
if class and self.name=='new' then
- output('Mtolua_new((',self.type,')(')
+ output('new',self.type,'(')
elseif class and static then
if out then
output(self.name,'(')
@@ -366,8 +363,7 @@
output(self.name,'(')
else
if self.cast_operator then
- --output('static_cast<',self.mod,self.type,self.ptr,' >(*self')
- output('self->operator ',self.mod,self.type,'(')
+ output('static_cast<',self.mod,self.type,self.ptr,'>(*self')
else
output('self->'..self.name,'(')
end
@@ -395,18 +391,14 @@
if class and self.name == 'operator[]' and flags['1'] then
output('-1);')
else
- if class and self.name=='new' then
- output('));') -- close Mtolua_new(
- else
- output(');')
- end
+ output(');')
end
-- return values
if self.type ~= '' and self.type ~= 'void' then
nret = nret + 1
local t,ct = isbasic(self.type)
- if t and self.name ~= "new" then
+ if t then
if self.cast_operator and _basic_raw_push[t] then
output(' ',_basic_raw_push[t],'(tolua_S,(',ct,')tolua_ret);')
else
@@ -415,29 +407,23 @@
else
t = self.type
new_t = string.gsub(t, "const%s+", "")
- local owned = false
- if string.find(self.mod, "tolua_owned") then
- owned = true
- end
- local push_func = get_push_function(t)
if self.ptr == '' then
output(' {')
output('#ifdef __cplusplus\n')
- output(' void* tolua_obj = Mtolua_new((',new_t,')(tolua_ret));')
- output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");')
- output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));')
+ output(' void* tolua_obj = new',new_t,'(tolua_ret);')
+ output(' tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
output('#else\n')
output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));')
- output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");')
- output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));')
+ output(' tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
output('#endif\n')
output(' }')
elseif self.ptr == '&' then
- output(' ',push_func,'(tolua_S,(void*)&tolua_ret,"',t,'");')
+ output(' tolua_pushusertype(tolua_S,(void*)&tolua_ret,"',t,'");')
else
- output(' ',push_func,'(tolua_S,(void*)tolua_ret,"',t,'");')
- if owned or local_constructor then
- output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));')
+ if local_constructor then
+ output(' tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"',t,'");')
+ else
+ output(' tolua_pushusertype(tolua_S,(void*)tolua_ret,"',t,'");')
end
end
end
@@ -479,8 +465,6 @@
end
end
- post_call_hook(self)
-
output(' }')
output(' return '..nret..';')
@@ -489,7 +473,7 @@
output('#ifndef TOLUA_RELEASE\n')
output('tolua_lerror:\n')
- output(' tolua_error(tolua_S,"'..output_error_hook("#ferror in function \'%s\'.", self.lname)..'",&tolua_err);')
+ output(' tolua_error(tolua_S,"#ferror in function \''..self.lname..'\'.",&tolua_err);')
output(' return 0;')
output('#endif\n')
else
@@ -589,7 +573,7 @@
if string.find(par, "%*") then -- it's a pointer with a default value
- if string.find(par, '=%s*new') or string.find(par, "%(") then -- it's a pointer with an instance as default parameter.. is that valid?
+ if string.find(par, '=%s*new') then -- it's a pointer with an instance as default parameter.. is that valid?
return true
end
return false -- default value is 'NULL' or something
@@ -676,7 +660,7 @@
ns = "("..string.gsub(ns, "%s*,%s*$", "")..')'
--ns = strip_defaults(ns)
- local f = Function(d, ns, c)
+ Function(d, ns, c)
for i=1,last do
t[i] = string.gsub(t[i], "=.*$", "")
end
Modified: branches/pch/src/tolua/lua/operator.lua
===================================================================
--- branches/pch/src/tolua/lua/operator.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/operator.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -74,8 +74,7 @@
output(' tolua_Error tolua_err;')
output(' if (\n')
-- check self
- local is_func = get_is_function(self.parent.type)
- output(' !'..is_func..'(tolua_S,1,"'..self.parent.type..'",0,&tolua_err) ||\n')
+ output(' !'..'tolua_isusertype(tolua_S,1,"'..self.parent.type..'",0,&tolua_err) ||\n')
output(' !tolua_isnoobj(tolua_S,2,&tolua_err)\n )')
output(' goto tolua_lerror;')
@@ -86,12 +85,11 @@
-- declare self
output(' ',self.const,self.parent.type,'*','self = ')
output('(',self.const,self.parent.type,'*) ')
- local to_func = get_to_func(self.parent.type)
- output(to_func,'(tolua_S,1,0);')
+ output('tolua_tousertype(tolua_S,1,0);')
-- check self
output('#ifndef TOLUA_RELEASE\n')
- output(' if (!self) tolua_error(tolua_S,"'..output_error_hook("invalid \'self\' in function \'%s\'", self.name)..'",NULL);');
+ output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in function \''..self.name..'\'",NULL);');
output('#endif\n')
-- cast self
@@ -104,28 +102,24 @@
output(' tolua_push'..t..'(tolua_S,(',ct,')tolua_ret);')
else
t = self.type
- local push_func = get_push_function(t)
new_t = string.gsub(t, "const%s+", "")
if self.ptr == '' then
output(' {')
output('#ifdef __cplusplus\n')
- output(' void* tolua_obj = Mtolua_new((',new_t,')(tolua_ret));')
- output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");')
- output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));')
+ output(' void* tolua_obj = new',new_t,'(tolua_ret);')
+ output(' tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
output('#else\n')
output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));')
- output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");')
- output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));')
+ output(' tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
output('#endif\n')
output(' }')
elseif self.ptr == '&' then
- output(' ',push_func,'(tolua_S,(void*)&tolua_ret,"',t,'");')
+ output(' tolua_pushusertype(tolua_S,(void*)&tolua_ret,"',t,'");')
else
if local_constructor then
- output(' ',push_func,'(tolua_S,(void *)tolua_ret,"',t,'");')
- output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));')
+ output(' tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"',t,'");')
else
- output(' ',push_func,'(tolua_S,(void*)tolua_ret,"',t,'");')
+ output(' tolua_pushusertype(tolua_S,(void*)tolua_ret,"',t,'");')
end
end
end
@@ -135,7 +129,7 @@
output('#ifndef TOLUA_RELEASE\n')
output('tolua_lerror:\n')
- output(' tolua_error(tolua_S,"'..output_error_hook("#ferror in function \'%s\'.", self.lname)..'",&tolua_err);')
+ output(' tolua_error(tolua_S,"#ferror in function \''..self.lname..'\'.",&tolua_err);')
output(' return 0;')
output('#endif\n')
Modified: branches/pch/src/tolua/lua/package.lua
===================================================================
--- branches/pch/src/tolua/lua/package.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/package.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -145,7 +145,7 @@
output('\nstatic int '..v..' (lua_State* tolua_S)')
output('{')
output(' '..i..'* self = ('..i..'*) tolua_tousertype(tolua_S,1,0);')
- output(' Mtolua_delete(self);')
+ output(' delete self;')
output(' return 0;')
output('}')
end
@@ -156,19 +156,12 @@
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)
if flags.t then
output("#ifndef Mtolua_typeid\n#define Mtolua_typeid(L,TI,T)\n#endif\n")
+ foreach(_usertype,function(n,v) output(' Mtolua_typeid(tolua_S,typeid(',v,'), "',v,'");') end)
end
- foreach(_usertype,function(n,v)
- if (not _global_classes[v]) or _global_classes[v]:check_public_access() then
- output(' tolua_usertype(tolua_S,"',v,'");')
- if flags.t then
- output(' Mtolua_typeid(tolua_S,typeid(',v,'), "',v,'");')
- end
- end
- end)
- output('}')
+ output('}')
output('\n')
end
@@ -255,7 +248,6 @@
local ext = "pkg"
-- open input file, if any
- local st,msg
if fn then
local file
if flags.f then
@@ -267,20 +259,15 @@
else
file = flags.f
end
- st, msg = readfrom(file)
+ local st, msg = readfrom(file)
if not st then
error('#'..msg..' path: '..flags.f)
end
local _; _, _, ext = strfind(fn,".*%.(.*)$")
end
- local code
- if ext == 'pkg' then
- code = prep(st)
- else
- code = "\n" .. read('*a')
- if ext == 'h' or ext == 'hpp' then
- code = extract_code(fn,code)
- end
+ local code = "\n" .. read('*a')
+ if ext == 'h' or ext == 'hpp' then
+ code = extract_code(fn,code)
end
-- close file
@@ -312,15 +299,12 @@
if not fp then
error('#'..msg..': '..fn)
end
- if kind == 'p' then
- local s = prep(fp)
- closefile(fp)
- return s
- 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$[--##"..fn.."\n" .. s .. "\n$]\n"
elseif kind == 'i' then
@@ -352,32 +336,3 @@
end
-setmetatable(_extra_parameters, { __index = _G })
-
-function prep(file)
-
- local chunk = {'local __ret = {"\\n"}\n'}
- for line in file:lines() do
- if string.find(line, "^##") then
- table.insert(chunk, string.sub(line, 3) .. "\n")
- else
- local last = 1
- for text, expr, index in string.gfind(line, "(.-)$(%b())()") do
- last = index
- if text ~= "" then
- table.insert(chunk, string.format('table.insert(__ret, %q )', text))
- end
- table.insert(chunk, string.format('table.insert(__ret, %s )', expr))
- end
- table.insert(chunk, string.format('table.insert(__ret, %q)\n',
- string.sub(line, last).."\n"))
- end
- end
- table.insert(chunk, '\nreturn table.concat(__ret)\n')
- local f,e = loadstring(table.concat(chunk))
- if e then
- error("#"..e)
- end
- setfenv(f, _extra_parameters)
- return f()
-end
Deleted: branches/pch/src/tolua/lua/template_class.lua
===================================================================
--- branches/pch/src/tolua/lua/template_class.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/template_class.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -1,82 +0,0 @@
-
-_global_templates = {}
-
-classTemplateClass = {
-
- name = '',
- body = '',
- parents = {},
- args = {}, -- the template arguments
-}
-
-classTemplateClass.__index = classTemplateClass
-
-
-function classTemplateClass:throw(types, local_scope)
-
- --if table.getn(types) ~= table.getn(self.args) then
- -- error("#invalid parameter count")
- --end
-
- -- replace
- for i =1 , types.n do
-
- local Il = split_c_tokens(types[i], " ")
- if table.getn(Il) ~= table.getn(self.args) then
- error("#invalid parameter count for "..types[i])
- end
- local bI = self.body
- local pI = {}
- for j = 1,self.args.n do
- --Tl[j] = findtype(Tl[j]) or Tl[j]
- bI = string.gsub(bI, "([^_%w])"..self.args[j].."([^_%w])", "%1"..Il[j].."%2")
- if self.parents then
- for i=1,table.getn(self.parents) do
- pI[i] = string.gsub(self.parents[i], "([^_%w]?)"..self.args[j].."([^_%w]?)", "%1"..Il[j].."%2")
- end
- end
- end
- --local append = "<"..string.gsub(types[i], "%s+", ",")..">"
- local append = "<"..concat(Il, 1, table.getn(Il), ",")..">"
- append = string.gsub(append, "%s*,%s*", ",")
- append = string.gsub(append, ">>", "> >")
- for i=1,table.getn(pI) do
- --pI[i] = string.gsub(pI[i], ">>", "> >")
- pI[i] = resolve_template_types(pI[i])
- end
- bI = string.gsub(bI, ">>", "> >")
- local n = self.name
- if local_scope then
- n = self.local_name
- end
-
- Class(n..append, pI, bI)
- end
-end
-
-
-function TemplateClass(name, parents, body, parameters)
-
- local o = {
-
- parents = parents,
- body = body,
- args = parameters,
- }
-
- local oname = string.gsub(name, "@.*$", "")
- oname = getnamespace(classContainer.curr)..oname
- o.name = oname
-
- o.local_name = name
-
- setmetatable(o, classTemplateClass)
-
- if _global_templates[oname] then
- warning("Duplicate declaration of template "..oname)
- else
- _global_templates[oname] = o
- end
-
- return o
-end
Modified: branches/pch/src/tolua/lua/variable.lua
===================================================================
--- branches/pch/src/tolua/lua/variable.lua 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/lua/variable.lua 2009-06-10 14:01:42 UTC (rev 3138)
@@ -108,7 +108,7 @@
local prop_get,prop_set
if string.find(self.mod, 'tolua_property') then
- local _,_,type = string.find(self.mod, "tolua_property__([^%s]*)")
+ _,_,type = string.find(self.mod, "tolua_property__([^%s]*)")
type = type or "default"
prop_get,prop_set = get_property_methods(type, self.name)
self.mod = string.gsub(self.mod, "tolua_property[^%s]*", "")
@@ -130,8 +130,7 @@
if class and static==nil then
output(' ',self.parent.type,'*','self = ')
output('(',self.parent.type,'*) ')
- local to_func = get_to_function(self.parent.type)
- output(to_func,'(tolua_S,1,0);')
+ output('tolua_tousertype(tolua_S,1,0);')
elseif static then
_,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
end
@@ -140,29 +139,27 @@
-- check self value
if class and static==nil then
output('#ifndef TOLUA_RELEASE\n')
- output(' if (!self) tolua_error(tolua_S,"'..output_error_hook("invalid \'self\' in accessing variable \'%s\'", self.name)..'",NULL);');
+ output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);');
output('#endif\n')
end
-- return value
if string.find(self.mod, 'tolua_inherits') then
- local push_func = get_push_function(self.type)
output('#ifdef __cplusplus\n')
- output(' ',push_func,'(tolua_S,(void*)static_cast<'..self.type..'*>(self), "',self.type,'");')
+ output(' tolua_pushusertype(tolua_S,(void*)static_cast<'..self.type..'*>(self), "',self.type,'");')
output('#else\n')
- output(' ',push_func,'(tolua_S,(void*)(('..self.type..'*)self), "',self.type,'");')
+ output(' tolua_pushusertype(tolua_S,(void*)(('..self.type..'*)self), "',self.type,'");')
output('#endif\n')
else
local t,ct = isbasic(self.type)
if t then
output(' tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static,prop_get)..');')
else
- local push_func = get_push_function(self.type)
t = self.type
if self.ptr == '&' or self.ptr == '' then
- output(' ',push_func,'(tolua_S,(void*)&'..self:getvalue(class,static,prop_get)..',"',t,'");')
+ output(' tolua_pushusertype(tolua_S,(void*)&'..self:getvalue(class,static,prop_get)..',"',t,'");')
else
- output(' ',push_func,'(tolua_S,(void*)'..self:getvalue(class,static,prop_get)..',"',t,'");')
+ output(' tolua_pushusertype(tolua_S,(void*)'..self:getvalue(class,static,prop_get)..',"',t,'");')
end
end
end
@@ -187,21 +184,20 @@
if class and static==nil then
output(' ',self.parent.type,'*','self = ')
output('(',self.parent.type,'*) ')
- local to_func = get_to_function(self.parent.type)
- output(to_func,'(tolua_S,1,0);')
+ 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,"'..output_error_hook("invalid \'self\' in accessing variable \'%s\'", self.name)..'",NULL);');
+ 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)..')')
+ output(' if (!'..self:outchecktype(2)..')')
output(' tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);')
output('#endif\n')
@@ -209,7 +205,7 @@
local def = 0
if self.def ~= '' then def = self.def end
if self.type == 'char*' and self.dim ~= '' then -- is string
- output(' strncpy((char*)')
+ output(' strncpy(')
if class and static then
output(self.parent.type..'::'..self.name)
elseif class then
@@ -217,7 +213,7 @@
else
output(self.name)
end
- output(',(const char*)tolua_tostring(tolua_S,2,',def,'),',self.dim,'-1);')
+ output(',tolua_tostring(tolua_S,2,',def,'),',self.dim,'-1);')
else
local ptr = ''
if self.ptr~='' then ptr = '*' end
@@ -248,8 +244,7 @@
end
output('tolua_to'..t,'(tolua_S,2,',def,'))')
else
- local to_func = get_to_function(self.type)
- output(to_func,'(tolua_S,2,',def,'))')
+ output('tolua_tousertype(tolua_S,2,',def,'))')
end
if prop_set then
output(")")
Modified: branches/pch/src/tolua/tolua++.h
===================================================================
--- branches/pch/src/tolua/tolua++.h 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/tolua++.h 2009-06-10 14:01:42 UTC (rev 3138)
@@ -57,12 +57,8 @@
#define tolua_iscppstringarray tolua_isstringarray
#define tolua_pushfieldcppstring(L,lo,idx,s) tolua_pushfieldstring(L, lo, idx, s.c_str())
-#ifndef TEMPLATE_BIND
- #define TEMPLATE_BIND(p)
-#endif
-
+#define TEMPLATE_BIND(p)
#define TOLUA_TEMPLATE_BIND(p)
-
#define TOLUA_PROTECTED_DESTRUCTOR
#define TOLUA_PROPERTY_TYPE(p)
@@ -82,10 +78,9 @@
#define TOLUA_NOPEER LUA_REGISTRYINDEX /* for lua 5.1 */
TOLUA_API const char* tolua_typename (lua_State* L, int lo);
-TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err);
+TOLUA_API void tolua_error (lua_State* L, char* msg, tolua_Error* err);
TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err);
TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err);
-TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err);
TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err);
TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err);
TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err);
@@ -114,42 +109,42 @@
TOLUA_API int tolua_register_gc (lua_State* L, int lo);
TOLUA_API int tolua_default_collect (lua_State* tolua_S);
-TOLUA_API void tolua_usertype (lua_State* L, const char* type);
-TOLUA_API void tolua_beginmodule (lua_State* L, const char* name);
+TOLUA_API void tolua_usertype (lua_State* L, char* type);
+TOLUA_API void tolua_beginmodule (lua_State* L, char* name);
TOLUA_API void tolua_endmodule (lua_State* L);
-TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar);
-TOLUA_API void tolua_class (lua_State* L, const char* name, const char* base);
-TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name, const char* base, lua_CFunction col);
-TOLUA_API void tolua_function (lua_State* L, const char* name, lua_CFunction func);
-TOLUA_API void tolua_constant (lua_State* L, const char* name, lua_Number value);
-TOLUA_API void tolua_variable (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set);
-TOLUA_API void tolua_array (lua_State* L,const char* name, lua_CFunction get, lua_CFunction set);
+TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar);
+TOLUA_API void tolua_class (lua_State* L, char* name, char* base);
+TOLUA_API void tolua_cclass (lua_State* L, char* lname, char* name, char* base, lua_CFunction col);
+TOLUA_API void tolua_function (lua_State* L, char* name, lua_CFunction func);
+TOLUA_API void tolua_constant (lua_State* L, char* name, double value);
+TOLUA_API void tolua_variable (lua_State* L, char* name, lua_CFunction get, lua_CFunction set);
+TOLUA_API void tolua_array (lua_State* L,char* name, lua_CFunction get, lua_CFunction set);
/* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type); */
/* TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base); */
TOLUA_API void tolua_pushvalue (lua_State* L, int lo);
TOLUA_API void tolua_pushboolean (lua_State* L, int value);
-TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value);
+TOLUA_API void tolua_pushnumber (lua_State* L, double value);
TOLUA_API void tolua_pushstring (lua_State* L, const char* value);
TOLUA_API void tolua_pushuserdata (lua_State* L, void* value);
TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type);
TOLUA_API void tolua_pushusertype_and_takeownership(lua_State* L, void* value, const char* type);
TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v);
TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v);
-TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v);
+TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, double v);
TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v);
TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v);
TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type);
TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type);
-TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def);
+TOLUA_API double tolua_tonumber (lua_State* L, int narg, double def);
TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def);
TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def);
TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def);
TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def);
TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def);
-TOLUA_API lua_Number tolua_tofieldnumber (lua_State* L, int lo, int index, lua_Number def);
+TOLUA_API double tolua_tofieldnumber (lua_State* L, int lo, int index, double def);
TOLUA_API const char* tolua_tofieldstring (lua_State* L, int lo, int index, const char* def);
TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def);
TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def);
@@ -180,30 +175,6 @@
TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index);
-#ifndef Mtolua_new
-#define Mtolua_new(EXP) new EXP
-#endif
-
-#ifndef Mtolua_delete
-#define Mtolua_delete(EXP) delete EXP
-#endif
-
-#ifndef Mtolua_new_dim
-#define Mtolua_new_dim(EXP, len) new EXP[len]
-#endif
-
-#ifndef Mtolua_delete_dim
-#define Mtolua_delete_dim(EXP) delete [] EXP
-#endif
-
-#ifndef tolua_outside
-#define tolua_outside
-#endif
-
-#ifndef tolua_owned
-#define tolua_owned
-#endif
-
#ifdef __cplusplus
}
#endif
Modified: branches/pch/src/tolua/tolua.c
===================================================================
--- branches/pch/src/tolua/tolua.c 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/tolua.c 2009-06-10 14:01:42 UTC (rev 3138)
@@ -49,7 +49,6 @@
" -C : disable cleanup of included lua code (for easier debugging)\n"
" -E value[=value] : add extra values to the luastate\n"
" -t : export a list of types asociates with the C++ typeid name\n"
- " -q : don't print warnings to the console\n"
" -h : print this message.\n"
"Should the input file be omitted, stdin is assumed;\n"
"in that case, the package name must be explicitly set.\n\n"
@@ -149,7 +148,6 @@
case 'C': setfield(L,t,"C",""); break;
case 'E': add_extra(L,argv[++i]); break;
case 't': setfield(L,t,"t",""); break;
- case 'q': setfield(L,t,"q",""); break;
default: error(argv[i]); break;
}
}
Modified: branches/pch/src/tolua/tolua_event.c
===================================================================
--- branches/pch/src/tolua/tolua_event.c 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/tolua_event.c 2009-06-10 14:01:42 UTC (rev 3138)
@@ -371,30 +371,7 @@
static int class_eq_event (lua_State* L)
{
- /* copying code from do_operator here to return false when no operator is found */
- if (lua_isuserdata(L,1))
- {
- /* Try metatables */
- lua_pushvalue(L,1); /* stack: op1 op2 */
- while (lua_getmetatable(L,-1))
- { /* stack: op1 op2 op1 mt */
- lua_remove(L,-2); /* stack: op1 op2 mt */
- lua_pushstring(L,".eq"); /* stack: op1 op2 mt key */
- lua_rawget(L,-2); /* stack: obj key mt func */
- if (lua_isfunction(L,-1))
- {
- lua_pushvalue(L,1);
- lua_pushvalue(L,2);
- lua_call(L,2,1);
- return 1;
- }
- lua_settop(L,3);
- }
- }
-
- lua_settop(L, 3);
- lua_pushboolean(L, 0);
- return 1;
+ return do_operator(L,".eq");
}
/*
Modified: branches/pch/src/tolua/tolua_is.c
===================================================================
--- branches/pch/src/tolua/tolua_is.c 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/tolua_is.c 2009-06-10 14:01:42 UTC (rev 3138)
@@ -85,7 +85,7 @@
return lua_tostring(L,-1);
}
-TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err)
+TOLUA_API void tolua_error (lua_State* L, char* msg, tolua_Error* err)
{
if (msg[0] == '#')
{
@@ -116,7 +116,7 @@
}
/* the equivalent of lua_is* for usertable */
-static int lua_isusertable (lua_State* L, int lo, const const char* type)
+static int lua_isusertable (lua_State* L, int lo, const char* type)
{
int r = 0;
if (lo < 0) lo = lua_gettop(L)+lo+1;
@@ -212,6 +212,15 @@
err->type = "[no object]";
return 0;
}
+TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err)
+{
+ if (def || abs(lo)<=lua_gettop(L)) /* any valid index */
+ return 1;
+ err->index = lo;
+ err->array = 0;
+ err->type = "value";
+ return 0;
+}
TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err)
{
@@ -286,29 +295,6 @@
return 0;
}
-TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err) {
-
- if (lua_gettop(L)<abs(lo))
- return 0; /* somebody else should chack this */
- if (!lua_isnil(L, lo))
- return 0;
-
- err->index = lo;
- err->array = 0;
- err->type = "value";
- return 1;
-};
-
-TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err)
-{
- if (def || abs(lo)<=lua_gettop(L)) /* any valid index */
- return 1;
- err->index = lo;
- err->array = 0;
- err->type = "value";
- return 0;
-}
-
TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err)
{
if (def && lua_gettop(L)<abs(lo))
Modified: branches/pch/src/tolua/tolua_map.c
===================================================================
--- branches/pch/src/tolua/tolua_map.c 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/tolua_map.c 2009-06-10 14:01:42 UTC (rev 3138)
@@ -389,7 +389,7 @@
* It creates the correspoding metatable in the registry, for both 'type' and 'const type'.
* It maps 'const type' as being also a 'type'
*/
-TOLUA_API void tolua_usertype (lua_State* L, const char* type)
+TOLUA_API void tolua_usertype (lua_State* L, char* type)
{
char ctype[128] = "const ";
strncat(ctype,type,120);
@@ -403,7 +403,7 @@
/* Begin module
* It pushes the module (or class) table on the stack
*/
-TOLUA_API void tolua_beginmodule (lua_State* L, const char* name)
+TOLUA_API void tolua_beginmodule (lua_State* L, char* name)
{
if (name)
{
@@ -426,7 +426,7 @@
* It creates a new module
*/
#if 1
-TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar)
+TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar)
{
if (name)
{
@@ -462,7 +462,7 @@
lua_pop(L,1); /* pop module */
}
#else
-TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar)
+TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar)
{
if (name)
{
@@ -518,7 +518,7 @@
/* Map C class
* It maps a C class, setting the appropriate inheritance and super classes.
*/
-TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name, const char* base, lua_CFunction col)
+TOLUA_API void tolua_cclass (lua_State* L, char* lname, char* name, char* base, lua_CFunction col)
{
char cname[128] = "const ";
char cbase[128] = "const ";
@@ -577,7 +577,7 @@
/* Map function
* It assigns a function into the current module (or class)
*/
-TOLUA_API void tolua_function (lua_State* L, const char* name, lua_CFunction func)
+TOLUA_API void tolua_function (lua_State* L, char* name, lua_CFunction func)
{
lua_pushstring(L,name);
lua_pushcfunction(L,func);
@@ -600,7 +600,7 @@
/* Map constant number
* It assigns a constant number into the current module (or class)
*/
-TOLUA_API void tolua_constant (lua_State* L, const char* name, lua_Number value)
+TOLUA_API void tolua_constant (lua_State* L, char* name, double value)
{
lua_pushstring(L,name);
tolua_pushnumber(L,value);
@@ -611,7 +611,7 @@
/* Map variable
* It assigns a variable into the current module (or class)
*/
-TOLUA_API void tolua_variable (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set)
+TOLUA_API void tolua_variable (lua_State* L, char* name, lua_CFunction get, lua_CFunction set)
{
/* get func */
lua_pushstring(L,".get");
@@ -663,7 +663,7 @@
/* Map an array
* It assigns an array into the current module (or class)
*/
-TOLUA_API void tolua_array (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set)
+TOLUA_API void tolua_array (lua_State* L, char* name, lua_CFunction get, lua_CFunction set)
{
lua_pushstring(L,".get");
lua_rawget(L,-2);
Modified: branches/pch/src/tolua/tolua_push.c
===================================================================
--- branches/pch/src/tolua/tolua_push.c 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/tolua_push.c 2009-06-10 14:01:42 UTC (rev 3138)
@@ -27,7 +27,7 @@
lua_pushboolean(L,value);
}
-TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value)
+TOLUA_API void tolua_pushnumber (lua_State* L, double value)
{
lua_pushnumber(L,value);
}
@@ -133,7 +133,7 @@
}
-TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v)
+TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, double v)
{
lua_pushnumber(L,index);
tolua_pushnumber(L,v);
Modified: branches/pch/src/tolua/tolua_to.c
===================================================================
--- branches/pch/src/tolua/tolua_to.c 2009-06-10 10:24:27 UTC (rev 3137)
+++ branches/pch/src/tolua/tolua_to.c 2009-06-10 14:01:42 UTC (rev 3138)
@@ -17,7 +17,7 @@
#include <string.h>
#include <stdlib.h>
-TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def)
+TOLUA_API double tolua_tonumber (lua_State* L, int narg, double def)
{
return lua_gettop(L)<abs(narg) ? def : lua_tonumber(L,narg);
}
@@ -71,7 +71,7 @@
return lua_gettop(L)<abs(narg) ? def : lua_toboolean(L,narg);
}
-TOLUA_API lua_Number tolua_tofieldnumber (lua_State* L, int lo, int index, lua_Number def)
+TOLUA_API double tolua_tofieldnumber (lua_State* L, int lo, int index, double def)
{
double v;
lua_pushnumber(L,index);
More information about the Orxonox-commit
mailing list