Changeset 3138 for code/branches/pch/src/tolua/lua/declaration.lua
- Timestamp:
- Jun 10, 2009, 4:01:42 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.