Changeset 3138 for code/branches
- Timestamp:
- Jun 10, 2009, 4:01:42 PM (15 years ago)
- Location:
- code/branches/pch/src/tolua
- Files:
-
- 1 deleted
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pch/src/tolua/CMakeLists.txt
r3127 r3138 54 54 ORXONOX_EXTERNAL 55 55 VERSION 56 1.0.9 356 1.0.92 57 57 LINK_LIBRARIES 58 58 ${LUA_LIBRARIES} … … 88 88 ${CMAKE_CURRENT_SOURCE_DIR}/lua/class.lua 89 89 ${CMAKE_CURRENT_SOURCE_DIR}/lua/clean.lua 90 ${CMAKE_CURRENT_SOURCE_DIR}/lua/template_class.lua91 90 ${CMAKE_CURRENT_SOURCE_DIR}/lua/doit.lua 92 91 -
code/branches/pch/src/tolua/README
r3127 r3138 14 14 15 15 * Availability 16 tolua is freely available; you can redistribute it and/or modify it. 17 The software provided hereunder is on an "as is" basis, and 18 the author has no obligation to provide maintenance, support, 19 updates, enhancements, or modifications. 16 20 17 tolua++ is freely available for both academic and commercial purposes. 18 See COPYRIGHT for details. 19 20 tolua++ can be downloaded from the sites below: 21 tolua can be downloaded from the sites below: 21 22 http://www.codenix.com/~tolua/ 23 http://www.codenix.com/~tolua/tolua++-1.0.tar.bz2 22 24 23 25 * Installation -
code/branches/pch/src/tolua/VERSION
r3127 r3138 1 Tolua++ v1.0.9 3with changes:1 Tolua++ v1.0.92 with changes: 2 2 3 3 - Exception handling by CEGUI team -
code/branches/pch/src/tolua/all-5.0.lua
r3127 r3138 18 18 dofile(path.."lua/class.lua") 19 19 dofile(path.."lua/clean.lua") 20 dofile(path.."lua/template_class.lua")21 20 --dofile(path.."lua/custom.lua") 22 21 dofile(path.."lua/doit.lua") -
code/branches/pch/src/tolua/all-5.1.lua
r3127 r3138 19 19 dofile(path.."lua/class.lua") 20 20 dofile(path.."lua/clean.lua") 21 dofile(path.."lua/template_class.lua")22 21 --dofile(path.."lua/custom.lua") 23 22 dofile(path.."lua/doit.lua") -
code/branches/pch/src/tolua/changes_orxonox.diff
r3127 r3138 1 --- tolua++.h Tue Jun 9 16:27:17 2009 2 +++ tolua++.h Tue Jun 9 14:50:04 2009 1 diff -ruN tolua/tolua++.h tolua2/tolua++.h 2 --- tolua/tolua++.h Wed Jan 28 21:51:38 2009 3 +++ tolua2/tolua++.h Sat Jan 10 14:48:44 2009 3 4 @@ -16,9 +16,34 @@ 4 5 #ifndef TOLUA_H … … 36 37 #define TOLUA_VERSION "tolua++-1.0.92" 37 38 38 --- tolua.c Tue Jun 9 16:27:12 2009 39 +++ tolua.c Tue Jun 9 14:50:04 2009 39 diff -ruN tolua/tolua.c tolua2/tolua.c 40 --- tolua/tolua.c Wed Jan 28 21:51:00 2009 41 +++ tolua2/tolua.c Sat Jan 10 14:48:45 2009 40 42 @@ -4,6 +4,8 @@ 41 43 ** TeCGraf/PUC-Rio … … 56 58 " -P : parse and print structure information (for debug).\n" 57 59 " -S : disable support for c++ strings.\n" 58 @@ -6 5,12 +69,12 @@60 @@ -64,12 +68,12 @@ 59 61 } 60 62 … … 75 77 76 78 static void error (char* o) 77 @@ -8 2,6 +86,9 @@79 @@ -81,6 +85,9 @@ 78 80 79 81 int main (int argc, char* argv[]) … … 85 87 lua_State* L = luaL_newstate(); 86 88 luaL_openlibs(L); 87 @@ -9 8,6 +105,7 @@89 @@ -97,6 +104,7 @@ 88 90 lua_pushstring(L,TOLUA_VERSION); lua_setglobal(L,"TOLUA_VERSION"); 89 91 lua_pushstring(L,LUA_VERSION); lua_setglobal(L,"TOLUA_LUA_VERSION"); … … 93 95 { 94 96 help(); 95 @@ -12 5,6 +133,14 @@97 @@ -124,6 +132,14 @@ 96 98 case 'o': setfield(L,t,"o",argv[++i]); break; 97 99 case 'n': setfield(L,t,"n",argv[++i]); break; … … 108 110 case '1': setfield(L,t,"1",""); break; 109 111 case 'L': setfield(L,t,"L",argv[++i]); break; 110 @@ -14 5,25 +161,53 @@112 @@ -143,25 +159,53 @@ 111 113 } 112 114 lua_pop(L,1); -
code/branches/pch/src/tolua/lua/array.lua
r3127 r3138 102 102 -- return value 103 103 local t,ct = isbasic(self.type) 104 local push_func = get_push_function(t)105 104 if t then 106 105 output(' tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static)..');') … … 108 107 t = self.type 109 108 if self.ptr == '&' or self.ptr == '' then 110 output(' ',push_func,'(tolua_S,(void*)&'..self:getvalue(class,static)..',"',t,'");')111 else 112 output(' ',push_func,'(tolua_S,(void*)'..self:getvalue(class,static)..',"',t,'");')109 output(' tolua_pushusertype(tolua_S,(void*)&'..self:getvalue(class,static)..',"',t,'");') 110 else 111 output(' tolua_pushusertype(tolua_S,(void*)'..self:getvalue(class,static)..',"',t,'");') 113 112 end 114 113 end … … 194 193 output('tolua_to'..t,'(tolua_S,3,',def,'));') 195 194 else 196 local to_func = get_to_function(self.type) 197 output(to_func,'(tolua_S,3,',def,'));') 195 output('tolua_tousertype(tolua_S,3,',def,'));') 198 196 end 199 197 output(' return 0;') … … 205 203 206 204 function classArray:register (pre) 207 if not self:check_public_access() then208 return209 end210 211 205 pre = pre or '' 212 206 if self.csetname then -
code/branches/pch/src/tolua/lua/basic.lua
r3129 r3138 112 112 113 113 function warning (msg) 114 if flags.q then115 return116 end117 114 local out = _OUTPUT 118 115 _OUTPUT = _STDERR … … 336 333 end 337 334 338 -- called before starting output339 function pre_output_hook(package)340 341 end342 335 343 336 -- called after writing all the output. … … 361 354 end 362 355 363 -- called from classFunction:supcode, before the call to the function is output 364 function pre_call_hook(f) 365 366 end 367 368 -- called from classFunction:supcode, after the call to the function is output 369 function post_call_hook(f) 370 371 end 372 373 -- called before the register code is output 374 function pre_register_hook(package) 375 376 end 377 378 -- called to output an error message 379 function output_error_hook(str, arg) 380 return string.format(str, arg) 381 end 382 383 -- custom pushers 384 385 _push_functions = {} 386 _is_functions = {} 387 _to_functions = {} 388 389 _base_push_functions = {} 390 _base_is_functions = {} 391 _base_to_functions = {} 392 393 local function search_base(t, funcs) 394 local class = _global_classes[t] 395 396 while class do 397 if funcs[class.type] then 398 return funcs[class.type] 399 end 400 class = _global_classes[class.btype] 401 end 402 return nil 403 end 404 405 function get_push_function(t) 406 return _push_functions[t] or search_base(t, _base_push_functions) or "tolua_pushusertype" 407 end 408 409 function get_to_function(t) 410 return _to_functions[t] or search_base(t, _base_to_functions) or "tolua_tousertype" 411 end 412 413 function get_is_function(t) 414 return _is_functions[t] or search_base(t, _base_is_functions) or "tolua_isusertype" 415 end 416 356 -
code/branches/pch/src/tolua/lua/class.lua
r3127 r3138 64 64 -- return collection requirement 65 65 function classClass:requirecollection (t) 66 if self.flags.protected_destructor or (not self:check_public_access())then66 if self.flags.protected_destructor then 67 67 return false 68 68 end … … 148 148 -- check for template 149 149 b = string.gsub(b, "^{%s*TEMPLATE_BIND", "{\nTOLUA_TEMPLATE_BIND") 150 local t,_,T,I = string.find(b, '^{%s*TOLUA_TEMPLATE_BIND%s*%(+%s*\"?([^\",]*)\"?%s*,%s*([^%)]*)%s*%)+')150 local t,_,T,I = string.find(b, "^{%s*TOLUA_TEMPLATE_BIND%s*%(+%s*\"?([^\",]*)\"?%s*,%s*([^%)]*)%s*%)+") 151 151 if t then 152 152 … … 159 159 local bs = string.gsub(b, "^{%s*TOLUA_TEMPLATE_BIND[^\n]*\n", "{\n") 160 160 161 local Tl = split(T, " ") 162 local tc = TemplateClass(n, p, bs, Tl) 163 164 tc:throw(types, true) 165 --for i=1,types.n do 166 -- tc:throw(split_c_tokens(types[i], " "), true) 167 --end 161 -- replace 162 for i =1 , types.n do 163 164 local Tl = split(T, " ") 165 local Il = split_c_tokens(types[i], " ") 166 local bI = bs 167 local pI = {} 168 for j = 1,Tl.n do 169 Tl[j] = findtype(Tl[j]) or Tl[j] 170 bI = string.gsub(bI, "([^_%w])"..Tl[j].."([^_%w])", "%1"..Il[j].."%2") 171 if p then 172 for i=1,table.getn(p) do 173 pI[i] = string.gsub(p[i], "([^_%w]?)"..Tl[j].."([^_%w]?)", "%1"..Il[j].."%2") 174 end 175 end 176 end 177 --local append = "<"..string.gsub(types[i], "%s+", ",")..">" 178 local append = "<"..concat(Il, 1, table.getn(Il), ",")..">" 179 append = string.gsub(append, "%s*,%s*", ",") 180 append = string.gsub(append, ">>", "> >") 181 for i=1,table.getn(pI) do 182 --pI[i] = string.gsub(pI[i], ">>", "> >") 183 pI[i] = resolve_template_types(pI[i]) 184 end 185 bI = string.gsub(bI, ">>", "> >") 186 Class(n..append, pI, bI) 187 end 168 188 return 169 189 end -
code/branches/pch/src/tolua/lua/code.lua
r3127 r3138 47 47 end 48 48 49 -- pad to 16 bytes50 local npad = 16 - (#s % 16)51 local spad = ""52 for i=1,npad do53 spad = spad .. "-"54 end55 s = s..spad56 57 49 -- convert to C 58 50 output('\n'..pre..'{ /* begin embedded lua code */\n') 59 51 output(pre..' int top = lua_gettop(tolua_S);') 60 output(pre..' static constunsigned char B[] = {\n ')52 output(pre..' static unsigned char B[] = {\n ') 61 53 local t={n=0} 62 54 local b = gsub(s, '(.)', -
code/branches/pch/src/tolua/lua/compat-5.1.lua
r3127 r3138 26 26 27 27 local f = load(getfile, path) 28 if not f then29 error("error loading file "..path)30 end31 28 return f() 32 29 end -
code/branches/pch/src/tolua/lua/container.lua
r3127 r3138 615 615 b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?)%s*;%s*") 616 616 end 617 if not b then618 -- try function pointer619 b,e,decl,arg,const = strfind(s,"^%s*([^%(;\n]+%b())%s*(%b())%s*;%s*")620 if b then621 decl = string.gsub(decl, "%(%s*%*([^%)]*)%s*%)", " %1 ")622 end623 end624 617 if b then 625 618 if virt and string.find(virt, "[=0]") then … … 654 647 base = '' body = '' 655 648 b,e,name = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*;") -- dummy class 656 local dummy = false657 649 if not b then 658 650 b,e,name = strfind(s,"^%s*struct%s*([_%w][_%w@]*)%s*;") -- dummy struct 659 651 if not b then 660 b,e,name,base,body = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*( [^{]-)%s*(%b{})%s*")652 b,e,name,base,body = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*") 661 653 if not b then 662 b,e,name,base,body = strfind(s,"^%s*struct%s +([_%w][_%w@]*)%s*([^{]-)%s*(%b{})%s*")654 b,e,name,base,body = strfind(s,"^%s*struct%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*") 663 655 if not b then 664 b,e,name,base,body = strfind(s,"^%s*union%s*([_%w][_%w@]*)%s*( [^{]-)%s*(%b{})%s*")656 b,e,name,base,body = strfind(s,"^%s*union%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*") 665 657 if not b then 666 658 base = '' 667 b,e,body,name = strfind(s,"^%s*typedef%s%s*struct%s%s*[_%w]*%s*(%b{})%s*([_%w][_%w@]*)%s*; ")659 b,e,body,name = strfind(s,"^%s*typedef%s%s*struct%s%s*[_%w]*%s*(%b{})%s*([_%w][_%w@]*)%s*;%s*") 668 660 end 669 661 end 670 662 end 671 e lse dummy = 1 end672 e lse dummy = 1 end663 end 664 end 673 665 if b then 674 666 if base ~= '' then … … 683 675 _curr_code = strsub(s,b,e) 684 676 Class(name,base,body) 685 if not dummy then686 varb,vare,varname = string.find(s, "^%s*([_%w]+)%s*;", e+1)687 if varb then688 Variable(name.." "..varname)689 e = vare690 end691 end692 677 return strsub(s,e+1) 693 678 end … … 738 723 -- try array 739 724 do 740 local b,e,decl = strfind(s,"^%s*([_%w][][_@%s%w%d%*&:<>]*[]_%w%d])%s*;%s*")725 local b,e,decl = strfind(s,"^%s*([_%w][][_@%s%w%d%*&:]*[]_%w%d])%s*;%s*") 741 726 if b then 742 727 _curr_code = strsub(s,b,e) … … 758 743 function classContainer:parse (s) 759 744 760 --self.curr_member_access = nil745 self.curr_member_access = nil 761 746 762 747 while s ~= '' do -
code/branches/pch/src/tolua/lua/declaration.lua
r3127 r3138 140 140 for i=1, table.getn(m) do 141 141 m[i] = string.gsub(m[i],"%s*([%*&])", "%1") 142 if not isbasic(m[i]) then 143 if not isenum(m[i]) then _, m[i] = applytypedef("", m[i]) end 144 m[i] = findtype(m[i]) or m[i] 145 m[i] = resolve_template_types(m[i]) 146 end 142 m[i] = findtype(m[i]) or m[i] 143 m[i] = resolve_template_types(m[i]) 147 144 end 148 145 149 146 local b,i 150 147 type,b,i = break_template(type) 151 --print("concat is ",concat(m, 1, m.n)) 152 local template_part = "<"..concat(m, 1, m.n, ",")..">" 148 local template_part = "<"..string.gsub(concat(m, 1, m.n), " ", ",")..">" 153 149 type = rebuild_template(type, b, template_part) 154 150 type = string.gsub(type, ">>", "> >") … … 191 187 -- check if array of values are returned to Lua 192 188 function classDeclaration:requirecollection (t) 193 189 if self.mod ~= 'const' and 194 190 self.dim and self.dim ~= '' and 195 191 not isbasic(self.type) and 196 self.ptr == '' and self:check_public_access()then192 self.ptr == '' then 197 193 local type = gsub(self.type,"%s*const%s+","") 198 194 t[type] = "tolua_collect_" .. clean_template(type) … … 226 222 -- return 'tolua_isstringarray(tolua_S,'..narg..','..def..',&tolua_err)' 227 223 --else 228 return ' !tolua_istable(tolua_S,'..narg..',0,&tolua_err)'224 return 'tolua_istable(tolua_S,'..narg..',0,&tolua_err)' 229 225 --end 230 226 elseif t then 231 return '!tolua_is'..t..'(tolua_S,'..narg..','..def..',&tolua_err)' 232 else 233 local is_func = get_is_function(self.type) 234 if self.ptr == '&' or self.ptr == '' then 235 return '(tolua_isvaluenil(tolua_S,'..narg..',&tolua_err) || !'..is_func..'(tolua_S,'..narg..',"'..self.type..'",'..def..',&tolua_err))' 236 else 237 return '!'..is_func..'(tolua_S,'..narg..',"'..self.type..'",'..def..',&tolua_err)' 238 end 239 end 227 return 'tolua_is'..t..'(tolua_S,'..narg..','..def..',&tolua_err)' 228 else 229 return 'tolua_isusertype(tolua_S,'..narg..',"'..self.type..'",'..def..',&tolua_err)' 230 end 240 231 end 241 232 … … 246 237 local mod 247 238 local type = self.type 248 local nctype = gsub(self.type,'const%s+','')249 239 if self.dim ~= '' then 250 240 type = gsub(self.type,'const%s+','') -- eliminates const modifier for arrays … … 261 251 else 262 252 if cplusplus then 263 line = concatparam(line,' = Mtolua_new_dim(',type,ptr,', '..self.dim..');')253 line = concatparam(line,' = new',type,ptr,'['..self.dim..'];') 264 254 else 265 255 line = concatparam(line,' = (',type,ptr,'*)', … … 283 273 end 284 274 line = concatparam(line,') ') 285 if isenum( nctype) then275 if isenum(type) then 286 276 line = concatparam(line,'(int) ') 287 277 end … … 296 286 line = concatparam(line,'tolua_to'..t,'(tolua_S,',narg,',',def,'));') 297 287 else 298 local to_func = get_to_function(type) 299 line = concatparam(line,to_func..'(tolua_S,',narg,',',def,'));') 288 line = concatparam(line,'tolua_tousertype(tolua_S,',narg,',',def,'));') 300 289 end 301 290 end … … 372 361 output(' {') 373 362 output('#ifdef __cplusplus\n') 374 output(' void* tolua_obj = Mtolua_new((',type,')(',self.name,'[i]));')363 output(' void* tolua_obj = new',type,'(',self.name,'[i]);') 375 364 output(' tolua_pushfieldusertype_and_takeownership(tolua_S,',narg,',i+1,tolua_obj,"',type,'");') 376 365 output('#else\n') … … 391 380 if self.dim ~= '' and tonumber(self.dim)==nil then 392 381 output('#ifdef __cplusplus\n') 393 output(' Mtolua_delete_dim(',self.name,');')382 output(' delete []',self.name,';') 394 383 output('#else\n') 395 384 output(' free(',self.name,');') … … 416 405 output(' tolua_push'..t..'(tolua_S,(',ct,')'..self.name..');') 417 406 else 418 local push_func = get_push_function(self.type) 419 output(' ',push_func,'(tolua_S,(void*)'..self.name..',"',self.type,'");') 407 output(' tolua_pushusertype(tolua_S,(void*)'..self.name..',"',self.type,'");') 420 408 end 421 409 return 1 -
code/branches/pch/src/tolua/lua/doit.lua
r3127 r3138 16 16 for k,v in ipairs(_extra_parameters or {}) do 17 17 18 local b,e,name,value = string.find(v, "^([^=] *)=(.*)$")18 local b,e,name,value = string.find(v, "^([^=])=(.*)$") 19 19 if b then 20 20 _extra_parameters[name] = value … … 94 94 p:print() 95 95 else 96 push(p)97 pre_output_hook(p)98 pop()99 96 p:preamble() 100 97 p:supcode() 101 push(p)102 pre_register_hook(p)103 pop()104 98 p:register() 105 99 push(p) -
code/branches/pch/src/tolua/lua/enumerate.lua
r3127 r3138 22 22 -- register enumeration 23 23 function classEnumerate:register (pre) 24 if not self:check_public_access() then25 return26 end27 24 pre = pre or '' 28 25 local nspace = getnamespace(classContainer.curr) 29 26 local i=1 30 27 while self[i] do 31 if self.lnames[i] and self.lnames[i] ~= "" then 32 output(pre..'tolua_constant(tolua_S,"'..self.lnames[i]..'",'..nspace..self[i]..');') 33 end 28 output(pre..'tolua_constant(tolua_S,"'..self.lnames[i]..'",'..nspace..self[i]..');') 34 29 i = i+1 35 30 end … … 61 56 Variable("tolua_readonly int "..varname) 62 57 end 63 end64 local parent = classContainer.curr65 if parent then66 t.access = parent.curr_member_access67 t.global_access = t:check_public_access()68 58 end 69 59 return t -
code/branches/pch/src/tolua/lua/feature.lua
r3127 r3138 48 48 local n = split(self.name,'@') 49 49 self.name = n[1] 50 self.name = string.gsub(self.name, ":%d*$", "")51 50 if not n[2] then 52 51 n[2] = applyrenaming(n[1]) 53 52 end 54 53 self.lname = n[2] or gsub(n[1],"%[.-%]","") 55 self.lname = string.gsub(self.lname, ":%d*$", "")56 54 self.original_name = self.name 57 55 self.lname = clean_template(self.lname) … … 64 62 if parent then 65 63 self.access = parent.curr_member_access 66 self.global_access = self:check_public_access()67 64 else 68 65 end … … 70 67 71 68 function classFeature:check_public_access() 72 73 if type(self.global_access) == "boolean" then74 return self.global_access75 end76 69 77 70 if self.access and self.access ~= 0 then … … 129 122 end 130 123 131 local fname = self.lname 132 if not fname or fname == '' then 133 fname = self.name 134 end 135 n = string.gsub(n..'_'.. (fname), "[<>:, \.%*&]", "_") 124 n = string.gsub(n..'_'.. (self.lname or self.name), "[<>:, \.%*&]", "_") 136 125 137 126 return n -
code/branches/pch/src/tolua/lua/function.lua
r3127 r3138 209 209 if class then narg=2 else narg=1 end 210 210 if class then 211 local func = get_is_function(self.parent.type)211 local func = 'tolua_isusertype' 212 212 local type = self.parent.type 213 213 if self.name=='new' or static~=nil then … … 226 226 local btype = isbasic(self.args[i].type) 227 227 if btype ~= 'value' and btype ~= 'state' then 228 output(' '..self.args[i]:outchecktype(narg)..' ||\n')228 output(' !'..self.args[i]:outchecktype(narg)..' ||\n') 229 229 end 230 230 if btype ~= 'state' then … … 250 250 output(' ',self.const,self.parent.type,'*','self = ') 251 251 output('(',self.const,self.parent.type,'*) ') 252 local to_func = get_to_function(self.parent.type) 253 output(to_func,'(tolua_S,1,0);') 252 output('tolua_tousertype(tolua_S,1,0);') 254 253 elseif static then 255 254 _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)') … … 270 269 if class and self.name~='new' and static==nil then 271 270 output('#ifndef TOLUA_RELEASE\n') 272 output(' if (!self) tolua_error(tolua_S," '..output_error_hook("invalid \'self\' in function \'%s\'", self.name)..'",NULL);');271 output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in function \''..self.name..'\'",NULL);'); 273 272 output('#endif\n') 274 273 end … … 313 312 -------------------------------------------------- 314 313 315 pre_call_hook(self)316 317 314 local out = string.find(self.mod, "tolua_outside") 318 315 … … 326 323 -- call function 327 324 if class and self.name=='delete' then 328 output(' Mtolua_delete(self);')325 output(' delete self;') 329 326 elseif class and self.name == 'operator&[]' then 330 327 if flags['1'] then -- for compatibility with tolua5 ? … … 355 352 end 356 353 if class and self.name=='new' then 357 output(' Mtolua_new((',self.type,')(')354 output('new',self.type,'(') 358 355 elseif class and static then 359 356 if out then … … 367 364 else 368 365 if self.cast_operator then 369 --output('static_cast<',self.mod,self.type,self.ptr,' >(*self') 370 output('self->operator ',self.mod,self.type,'(') 366 output('static_cast<',self.mod,self.type,self.ptr,'>(*self') 371 367 else 372 368 output('self->'..self.name,'(') … … 396 392 output('-1);') 397 393 else 398 if class and self.name=='new' then 399 output('));') -- close Mtolua_new( 400 else 401 output(');') 402 end 394 output(');') 403 395 end 404 396 … … 407 399 nret = nret + 1 408 400 local t,ct = isbasic(self.type) 409 if t and self.name ~= "new"then401 if t then 410 402 if self.cast_operator and _basic_raw_push[t] then 411 403 output(' ',_basic_raw_push[t],'(tolua_S,(',ct,')tolua_ret);') … … 416 408 t = self.type 417 409 new_t = string.gsub(t, "const%s+", "") 418 local owned = false419 if string.find(self.mod, "tolua_owned") then420 owned = true421 end422 local push_func = get_push_function(t)423 410 if self.ptr == '' then 424 411 output(' {') 425 412 output('#ifdef __cplusplus\n') 426 output(' void* tolua_obj = Mtolua_new((',new_t,')(tolua_ret));') 427 output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");') 428 output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') 413 output(' void* tolua_obj = new',new_t,'(tolua_ret);') 414 output(' tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");') 429 415 output('#else\n') 430 416 output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));') 431 output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");') 432 output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') 417 output(' tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");') 433 418 output('#endif\n') 434 419 output(' }') 435 420 elseif self.ptr == '&' then 436 output(' ',push_func,'(tolua_S,(void*)&tolua_ret,"',t,'");')421 output(' tolua_pushusertype(tolua_S,(void*)&tolua_ret,"',t,'");') 437 422 else 438 output(' ',push_func,'(tolua_S,(void*)tolua_ret,"',t,'");') 439 if owned or local_constructor then 440 output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') 423 if local_constructor then 424 output(' tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"',t,'");') 425 else 426 output(' tolua_pushusertype(tolua_S,(void*)tolua_ret,"',t,'");') 441 427 end 442 428 end … … 480 466 end 481 467 482 post_call_hook(self)483 484 468 output(' }') 485 469 output(' return '..nret..';') … … 490 474 output('#ifndef TOLUA_RELEASE\n') 491 475 output('tolua_lerror:\n') 492 output(' tolua_error(tolua_S," '..output_error_hook("#ferror in function \'%s\'.", self.lname)..'",&tolua_err);')476 output(' tolua_error(tolua_S,"#ferror in function \''..self.lname..'\'.",&tolua_err);') 493 477 output(' return 0;') 494 478 output('#endif\n') … … 590 574 if string.find(par, "%*") then -- it's a pointer with a default value 591 575 592 if string.find(par, '=%s*new') or string.find(par, "%(")then -- it's a pointer with an instance as default parameter.. is that valid?576 if string.find(par, '=%s*new') then -- it's a pointer with an instance as default parameter.. is that valid? 593 577 return true 594 578 end … … 677 661 --ns = strip_defaults(ns) 678 662 679 local f =Function(d, ns, c)663 Function(d, ns, c) 680 664 for i=1,last do 681 665 t[i] = string.gsub(t[i], "=.*$", "") -
code/branches/pch/src/tolua/lua/operator.lua
r3127 r3138 75 75 output(' if (\n') 76 76 -- check self 77 local is_func = get_is_function(self.parent.type) 78 output(' !'..is_func..'(tolua_S,1,"'..self.parent.type..'",0,&tolua_err) ||\n') 77 output(' !'..'tolua_isusertype(tolua_S,1,"'..self.parent.type..'",0,&tolua_err) ||\n') 79 78 output(' !tolua_isnoobj(tolua_S,2,&tolua_err)\n )') 80 79 output(' goto tolua_lerror;') … … 87 86 output(' ',self.const,self.parent.type,'*','self = ') 88 87 output('(',self.const,self.parent.type,'*) ') 89 local to_func = get_to_func(self.parent.type) 90 output(to_func,'(tolua_S,1,0);') 88 output('tolua_tousertype(tolua_S,1,0);') 91 89 92 90 -- check self 93 91 output('#ifndef TOLUA_RELEASE\n') 94 output(' if (!self) tolua_error(tolua_S," '..output_error_hook("invalid \'self\' in function \'%s\'", self.name)..'",NULL);');92 output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in function \''..self.name..'\'",NULL);'); 95 93 output('#endif\n') 96 94 … … 105 103 else 106 104 t = self.type 107 local push_func = get_push_function(t)108 105 new_t = string.gsub(t, "const%s+", "") 109 106 if self.ptr == '' then 110 107 output(' {') 111 108 output('#ifdef __cplusplus\n') 112 output(' void* tolua_obj = Mtolua_new((',new_t,')(tolua_ret));') 113 output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");') 114 output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') 109 output(' void* tolua_obj = new',new_t,'(tolua_ret);') 110 output(' tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");') 115 111 output('#else\n') 116 112 output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));') 117 output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");') 118 output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') 113 output(' tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");') 119 114 output('#endif\n') 120 115 output(' }') 121 116 elseif self.ptr == '&' then 122 output(' ',push_func,'(tolua_S,(void*)&tolua_ret,"',t,'");')117 output(' tolua_pushusertype(tolua_S,(void*)&tolua_ret,"',t,'");') 123 118 else 124 119 if local_constructor then 125 output(' ',push_func,'(tolua_S,(void *)tolua_ret,"',t,'");') 126 output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') 120 output(' tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"',t,'");') 127 121 else 128 output(' ',push_func,'(tolua_S,(void*)tolua_ret,"',t,'");')122 output(' tolua_pushusertype(tolua_S,(void*)tolua_ret,"',t,'");') 129 123 end 130 124 end … … 136 130 output('#ifndef TOLUA_RELEASE\n') 137 131 output('tolua_lerror:\n') 138 output(' tolua_error(tolua_S," '..output_error_hook("#ferror in function \'%s\'.", self.lname)..'",&tolua_err);')132 output(' tolua_error(tolua_S,"#ferror in function \''..self.lname..'\'.",&tolua_err);') 139 133 output(' return 0;') 140 134 output('#endif\n') -
code/branches/pch/src/tolua/lua/package.lua
r3129 r3138 146 146 output('{') 147 147 output(' '..i..'* self = ('..i..'*) tolua_tousertype(tolua_S,1,0);') 148 output(' Mtolua_delete(self);')148 output(' delete self;') 149 149 output(' return 0;') 150 150 output('}') … … 157 157 output('static void tolua_reg_types (lua_State* tolua_S)') 158 158 output('{') 159 159 foreach(_usertype,function(n,v) output(' tolua_usertype(tolua_S,"',v,'");') end) 160 160 if flags.t then 161 161 output("#ifndef Mtolua_typeid\n#define Mtolua_typeid(L,TI,T)\n#endif\n") 162 end 163 foreach(_usertype,function(n,v) 164 if (not _global_classes[v]) or _global_classes[v]:check_public_access() then 165 output(' tolua_usertype(tolua_S,"',v,'");') 166 if flags.t then 167 output(' Mtolua_typeid(tolua_S,typeid(',v,'), "',v,'");') 168 end 169 end 170 end) 171 output('}') 162 foreach(_usertype,function(n,v) output(' Mtolua_typeid(tolua_S,typeid(',v,'), "',v,'");') end) 163 end 164 output('}') 172 165 output('\n') 173 166 end … … 256 249 257 250 -- open input file, if any 258 local st,msg259 251 if fn then 260 252 local file … … 268 260 file = flags.f 269 261 end 270 st, msg = readfrom(file)262 local st, msg = readfrom(file) 271 263 if not st then 272 264 error('#'..msg..' path: '..flags.f) … … 274 266 local _; _, _, ext = strfind(fn,".*%.(.*)$") 275 267 end 276 local code 277 if ext == 'pkg' then 278 code = prep(st) 279 else 280 code = "\n" .. read('*a') 281 if ext == 'h' or ext == 'hpp' then 282 code = extract_code(fn,code) 283 end 268 local code = "\n" .. read('*a') 269 if ext == 'h' or ext == 'hpp' then 270 code = extract_code(fn,code) 284 271 end 285 272 … … 313 300 error('#'..msg..': '..fn) 314 301 end 315 if kind == 'p' then316 local s = prep(fp)317 closefile(fp)318 return s319 end320 302 local s = read(fp,'*a') 321 303 closefile(fp) 322 304 if kind == 'c' or kind == 'h' then 323 305 return extract_code(fn,s) 306 elseif kind == 'p' then 307 return "\n\n" .. s 324 308 elseif kind == 'l' then 325 309 return "\n$[--##"..fn.."\n" .. s .. "\n$]\n" … … 353 337 354 338 355 setmetatable(_extra_parameters, { __index = _G })356 357 function prep(file)358 359 local chunk = {'local __ret = {"\\n"}\n'}360 for line in file:lines() do361 if string.find(line, "^##") then362 table.insert(chunk, string.sub(line, 3) .. "\n")363 else364 local last = 1365 for text, expr, index in string.gfind(line, "(.-)$(%b())()") do366 last = index367 if text ~= "" then368 table.insert(chunk, string.format('table.insert(__ret, %q )', text))369 end370 table.insert(chunk, string.format('table.insert(__ret, %s )', expr))371 end372 table.insert(chunk, string.format('table.insert(__ret, %q)\n',373 string.sub(line, last).."\n"))374 end375 end376 table.insert(chunk, '\nreturn table.concat(__ret)\n')377 local f,e = loadstring(table.concat(chunk))378 if e then379 error("#"..e)380 end381 setfenv(f, _extra_parameters)382 return f()383 end -
code/branches/pch/src/tolua/lua/variable.lua
r3127 r3138 109 109 if string.find(self.mod, 'tolua_property') then 110 110 111 local_,_,type = string.find(self.mod, "tolua_property__([^%s]*)")111 _,_,type = string.find(self.mod, "tolua_property__([^%s]*)") 112 112 type = type or "default" 113 113 prop_get,prop_set = get_property_methods(type, self.name) … … 131 131 output(' ',self.parent.type,'*','self = ') 132 132 output('(',self.parent.type,'*) ') 133 local to_func = get_to_function(self.parent.type) 134 output(to_func,'(tolua_S,1,0);') 133 output('tolua_tousertype(tolua_S,1,0);') 135 134 elseif static then 136 135 _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)') … … 141 140 if class and static==nil then 142 141 output('#ifndef TOLUA_RELEASE\n') 143 output(' if (!self) tolua_error(tolua_S," '..output_error_hook("invalid \'self\' in accessing variable \'%s\'", self.name)..'",NULL);');142 output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);'); 144 143 output('#endif\n') 145 144 end … … 147 146 -- return value 148 147 if string.find(self.mod, 'tolua_inherits') then 149 local push_func = get_push_function(self.type)150 148 output('#ifdef __cplusplus\n') 151 output(' ',push_func,'(tolua_S,(void*)static_cast<'..self.type..'*>(self), "',self.type,'");')149 output(' tolua_pushusertype(tolua_S,(void*)static_cast<'..self.type..'*>(self), "',self.type,'");') 152 150 output('#else\n') 153 output(' ',push_func,'(tolua_S,(void*)(('..self.type..'*)self), "',self.type,'");')151 output(' tolua_pushusertype(tolua_S,(void*)(('..self.type..'*)self), "',self.type,'");') 154 152 output('#endif\n') 155 153 else … … 158 156 output(' tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static,prop_get)..');') 159 157 else 160 local push_func = get_push_function(self.type)161 158 t = self.type 162 159 if self.ptr == '&' or self.ptr == '' then 163 output(' ',push_func,'(tolua_S,(void*)&'..self:getvalue(class,static,prop_get)..',"',t,'");')164 else 165 output(' ',push_func,'(tolua_S,(void*)'..self:getvalue(class,static,prop_get)..',"',t,'");')160 output(' tolua_pushusertype(tolua_S,(void*)&'..self:getvalue(class,static,prop_get)..',"',t,'");') 161 else 162 output(' tolua_pushusertype(tolua_S,(void*)'..self:getvalue(class,static,prop_get)..',"',t,'");') 166 163 end 167 164 end … … 188 185 output(' ',self.parent.type,'*','self = ') 189 186 output('(',self.parent.type,'*) ') 190 local to_func = get_to_function(self.parent.type) 191 output(to_func,'(tolua_S,1,0);') 187 output('tolua_tousertype(tolua_S,1,0);') 192 188 -- check self value 193 189 end … … 196 192 output(' tolua_Error tolua_err;') 197 193 if class and static==nil then 198 output(' if (!self) tolua_error(tolua_S," '..output_error_hook("invalid \'self\' in accessing variable \'%s\'", self.name)..'",NULL);');194 output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);'); 199 195 elseif static then 200 196 _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)') … … 202 198 203 199 -- check variable type 204 output(' if ( '..self:outchecktype(2)..')')200 output(' if (!'..self:outchecktype(2)..')') 205 201 output(' tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);') 206 202 output('#endif\n') … … 210 206 if self.def ~= '' then def = self.def end 211 207 if self.type == 'char*' and self.dim ~= '' then -- is string 212 output(' strncpy( (char*)')208 output(' strncpy(') 213 209 if class and static then 214 210 output(self.parent.type..'::'..self.name) … … 218 214 output(self.name) 219 215 end 220 output(', (const char*)tolua_tostring(tolua_S,2,',def,'),',self.dim,'-1);')216 output(',tolua_tostring(tolua_S,2,',def,'),',self.dim,'-1);') 221 217 else 222 218 local ptr = '' … … 249 245 output('tolua_to'..t,'(tolua_S,2,',def,'))') 250 246 else 251 local to_func = get_to_function(self.type) 252 output(to_func,'(tolua_S,2,',def,'))') 247 output('tolua_tousertype(tolua_S,2,',def,'))') 253 248 end 254 249 if prop_set then -
code/branches/pch/src/tolua/tolua++.h
r3127 r3138 58 58 #define tolua_pushfieldcppstring(L,lo,idx,s) tolua_pushfieldstring(L, lo, idx, s.c_str()) 59 59 60 #ifndef TEMPLATE_BIND 61 #define TEMPLATE_BIND(p) 62 #endif 63 60 #define TEMPLATE_BIND(p) 64 61 #define TOLUA_TEMPLATE_BIND(p) 65 66 62 #define TOLUA_PROTECTED_DESTRUCTOR 67 63 #define TOLUA_PROPERTY_TYPE(p) … … 83 79 84 80 TOLUA_API const char* tolua_typename (lua_State* L, int lo); 85 TOLUA_API void tolua_error (lua_State* L, c onst char* msg, tolua_Error* err);81 TOLUA_API void tolua_error (lua_State* L, char* msg, tolua_Error* err); 86 82 TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err); 87 83 TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err); 88 TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err);89 84 TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err); 90 85 TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err); … … 115 110 TOLUA_API int tolua_default_collect (lua_State* tolua_S); 116 111 117 TOLUA_API void tolua_usertype (lua_State* L, c onst char* type);118 TOLUA_API void tolua_beginmodule (lua_State* L, c onst char* name);112 TOLUA_API void tolua_usertype (lua_State* L, char* type); 113 TOLUA_API void tolua_beginmodule (lua_State* L, char* name); 119 114 TOLUA_API void tolua_endmodule (lua_State* L); 120 TOLUA_API void tolua_module (lua_State* L, c onst char* name, int hasvar);121 TOLUA_API void tolua_class (lua_State* L, c onst char* name, constchar* base);122 TOLUA_API void tolua_cclass (lua_State* L, c onst char* lname, const char* name, constchar* base, lua_CFunction col);123 TOLUA_API void tolua_function (lua_State* L, c onst char* name, lua_CFunction func);124 TOLUA_API void tolua_constant (lua_State* L, c onst char* name, lua_Numbervalue);125 TOLUA_API void tolua_variable (lua_State* L, c onst char* name, lua_CFunction get, lua_CFunction set);126 TOLUA_API void tolua_array (lua_State* L,c onst char* name, lua_CFunction get, lua_CFunction set);115 TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar); 116 TOLUA_API void tolua_class (lua_State* L, char* name, char* base); 117 TOLUA_API void tolua_cclass (lua_State* L, char* lname, char* name, char* base, lua_CFunction col); 118 TOLUA_API void tolua_function (lua_State* L, char* name, lua_CFunction func); 119 TOLUA_API void tolua_constant (lua_State* L, char* name, double value); 120 TOLUA_API void tolua_variable (lua_State* L, char* name, lua_CFunction get, lua_CFunction set); 121 TOLUA_API void tolua_array (lua_State* L,char* name, lua_CFunction get, lua_CFunction set); 127 122 128 123 /* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type); */ … … 131 126 TOLUA_API void tolua_pushvalue (lua_State* L, int lo); 132 127 TOLUA_API void tolua_pushboolean (lua_State* L, int value); 133 TOLUA_API void tolua_pushnumber (lua_State* L, lua_Numbervalue);128 TOLUA_API void tolua_pushnumber (lua_State* L, double value); 134 129 TOLUA_API void tolua_pushstring (lua_State* L, const char* value); 135 130 TOLUA_API void tolua_pushuserdata (lua_State* L, void* value); … … 138 133 TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v); 139 134 TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v); 140 TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Numberv);135 TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, double v); 141 136 TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v); 142 137 TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v); … … 144 139 TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type); 145 140 146 TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Numberdef);141 TOLUA_API double tolua_tonumber (lua_State* L, int narg, double def); 147 142 TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def); 148 143 TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def); … … 150 145 TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def); 151 146 TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def); 152 TOLUA_API lua_Number tolua_tofieldnumber (lua_State* L, int lo, int index, lua_Numberdef);147 TOLUA_API double tolua_tofieldnumber (lua_State* L, int lo, int index, double def); 153 148 TOLUA_API const char* tolua_tofieldstring (lua_State* L, int lo, int index, const char* def); 154 149 TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def); … … 181 176 TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index); 182 177 183 #ifndef Mtolua_new184 #define Mtolua_new(EXP) new EXP185 #endif186 187 #ifndef Mtolua_delete188 #define Mtolua_delete(EXP) delete EXP189 #endif190 191 #ifndef Mtolua_new_dim192 #define Mtolua_new_dim(EXP, len) new EXP[len]193 #endif194 195 #ifndef Mtolua_delete_dim196 #define Mtolua_delete_dim(EXP) delete [] EXP197 #endif198 199 #ifndef tolua_outside200 #define tolua_outside201 #endif202 203 #ifndef tolua_owned204 #define tolua_owned205 #endif206 207 178 #ifdef __cplusplus 208 179 } -
code/branches/pch/src/tolua/tolua.c
r3127 r3138 50 50 " -E value[=value] : add extra values to the luastate\n" 51 51 " -t : export a list of types asociates with the C++ typeid name\n" 52 " -q : don't print warnings to the console\n"53 52 " -h : print this message.\n" 54 53 "Should the input file be omitted, stdin is assumed;\n" … … 150 149 case 'E': add_extra(L,argv[++i]); break; 151 150 case 't': setfield(L,t,"t",""); break; 152 case 'q': setfield(L,t,"q",""); break;153 151 default: error(argv[i]); break; 154 152 } -
code/branches/pch/src/tolua/tolua_event.c
r3127 r3138 372 372 static int class_eq_event (lua_State* L) 373 373 { 374 /* copying code from do_operator here to return false when no operator is found */ 375 if (lua_isuserdata(L,1)) 376 { 377 /* Try metatables */ 378 lua_pushvalue(L,1); /* stack: op1 op2 */ 379 while (lua_getmetatable(L,-1)) 380 { /* stack: op1 op2 op1 mt */ 381 lua_remove(L,-2); /* stack: op1 op2 mt */ 382 lua_pushstring(L,".eq"); /* stack: op1 op2 mt key */ 383 lua_rawget(L,-2); /* stack: obj key mt func */ 384 if (lua_isfunction(L,-1)) 385 { 386 lua_pushvalue(L,1); 387 lua_pushvalue(L,2); 388 lua_call(L,2,1); 389 return 1; 390 } 391 lua_settop(L,3); 392 } 393 } 394 395 lua_settop(L, 3); 396 lua_pushboolean(L, 0); 397 return 1; 374 return do_operator(L,".eq"); 398 375 } 399 376 -
code/branches/pch/src/tolua/tolua_is.c
r3127 r3138 86 86 } 87 87 88 TOLUA_API void tolua_error (lua_State* L, c onst char* msg, tolua_Error* err)88 TOLUA_API void tolua_error (lua_State* L, char* msg, tolua_Error* err) 89 89 { 90 90 if (msg[0] == '#') … … 117 117 118 118 /* the equivalent of lua_is* for usertable */ 119 static int lua_isusertable (lua_State* L, int lo, const c onst char* type)119 static int lua_isusertable (lua_State* L, int lo, const char* type) 120 120 { 121 121 int r = 0; … … 213 213 return 0; 214 214 } 215 TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err) 216 { 217 if (def || abs(lo)<=lua_gettop(L)) /* any valid index */ 218 return 1; 219 err->index = lo; 220 err->array = 0; 221 err->type = "value"; 222 return 0; 223 } 215 224 216 225 TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err) … … 284 293 err->array = 0; 285 294 err->type = "userdata"; 286 return 0;287 }288 289 TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err) {290 291 if (lua_gettop(L)<abs(lo))292 return 0; /* somebody else should chack this */293 if (!lua_isnil(L, lo))294 return 0;295 296 err->index = lo;297 err->array = 0;298 err->type = "value";299 return 1;300 };301 302 TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err)303 {304 if (def || abs(lo)<=lua_gettop(L)) /* any valid index */305 return 1;306 err->index = lo;307 err->array = 0;308 err->type = "value";309 295 return 0; 310 296 } -
code/branches/pch/src/tolua/tolua_map.c
r3127 r3138 390 390 * It maps 'const type' as being also a 'type' 391 391 */ 392 TOLUA_API void tolua_usertype (lua_State* L, c onst char* type)392 TOLUA_API void tolua_usertype (lua_State* L, char* type) 393 393 { 394 394 char ctype[128] = "const "; … … 404 404 * It pushes the module (or class) table on the stack 405 405 */ 406 TOLUA_API void tolua_beginmodule (lua_State* L, c onst char* name)406 TOLUA_API void tolua_beginmodule (lua_State* L, char* name) 407 407 { 408 408 if (name) … … 427 427 */ 428 428 #if 1 429 TOLUA_API void tolua_module (lua_State* L, c onst char* name, int hasvar)429 TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar) 430 430 { 431 431 if (name) … … 463 463 } 464 464 #else 465 TOLUA_API void tolua_module (lua_State* L, c onst char* name, int hasvar)465 TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar) 466 466 { 467 467 if (name) … … 519 519 * It maps a C class, setting the appropriate inheritance and super classes. 520 520 */ 521 TOLUA_API void tolua_cclass (lua_State* L, c onst char* lname, const char* name, constchar* base, lua_CFunction col)521 TOLUA_API void tolua_cclass (lua_State* L, char* lname, char* name, char* base, lua_CFunction col) 522 522 { 523 523 char cname[128] = "const "; … … 578 578 * It assigns a function into the current module (or class) 579 579 */ 580 TOLUA_API void tolua_function (lua_State* L, c onst char* name, lua_CFunction func)580 TOLUA_API void tolua_function (lua_State* L, char* name, lua_CFunction func) 581 581 { 582 582 lua_pushstring(L,name); … … 601 601 * It assigns a constant number into the current module (or class) 602 602 */ 603 TOLUA_API void tolua_constant (lua_State* L, c onst char* name, lua_Numbervalue)603 TOLUA_API void tolua_constant (lua_State* L, char* name, double value) 604 604 { 605 605 lua_pushstring(L,name); … … 612 612 * It assigns a variable into the current module (or class) 613 613 */ 614 TOLUA_API void tolua_variable (lua_State* L, c onst char* name, lua_CFunction get, lua_CFunction set)614 TOLUA_API void tolua_variable (lua_State* L, char* name, lua_CFunction get, lua_CFunction set) 615 615 { 616 616 /* get func */ … … 664 664 * It assigns an array into the current module (or class) 665 665 */ 666 TOLUA_API void tolua_array (lua_State* L, c onst char* name, lua_CFunction get, lua_CFunction set)666 TOLUA_API void tolua_array (lua_State* L, char* name, lua_CFunction get, lua_CFunction set) 667 667 { 668 668 lua_pushstring(L,".get"); -
code/branches/pch/src/tolua/tolua_push.c
r3127 r3138 28 28 } 29 29 30 TOLUA_API void tolua_pushnumber (lua_State* L, lua_Numbervalue)30 TOLUA_API void tolua_pushnumber (lua_State* L, double value) 31 31 { 32 32 lua_pushnumber(L,value); … … 134 134 135 135 136 TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Numberv)136 TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, double v) 137 137 { 138 138 lua_pushnumber(L,index); -
code/branches/pch/src/tolua/tolua_to.c
r3127 r3138 18 18 #include <stdlib.h> 19 19 20 TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Numberdef)20 TOLUA_API double tolua_tonumber (lua_State* L, int narg, double def) 21 21 { 22 22 return lua_gettop(L)<abs(narg) ? def : lua_tonumber(L,narg); … … 72 72 } 73 73 74 TOLUA_API lua_Number tolua_tofieldnumber (lua_State* L, int lo, int index, lua_Numberdef)74 TOLUA_API double tolua_tofieldnumber (lua_State* L, int lo, int index, double def) 75 75 { 76 76 double v;
Note: See TracChangeset
for help on using the changeset viewer.