Changeset 3127 for code/branches/pch/src/tolua/lua/declaration.lua
- Timestamp:
- Jun 9, 2009, 4:29:42 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pch/src/tolua/lua/declaration.lua
r2710 r3127 140 140 for i=1, table.getn(m) do 141 141 m[i] = string.gsub(m[i],"%s*([%*&])", "%1") 142 m[i] = findtype(m[i]) or m[i] 143 m[i] = resolve_template_types(m[i]) 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 144 147 end 145 148 146 149 local b,i 147 150 type,b,i = break_template(type) 148 local template_part = "<"..string.gsub(concat(m, 1, m.n), " ", ",")..">" 151 --print("concat is ",concat(m, 1, m.n)) 152 local template_part = "<"..concat(m, 1, m.n, ",")..">" 149 153 type = rebuild_template(type, b, template_part) 150 154 type = string.gsub(type, ">>", "> >") … … 187 191 -- check if array of values are returned to Lua 188 192 function classDeclaration:requirecollection (t) 189 if self.mod ~= 'const' and193 if self.mod ~= 'const' and 190 194 self.dim and self.dim ~= '' and 191 195 not isbasic(self.type) and 192 self.ptr == '' then196 self.ptr == '' and self:check_public_access() then 193 197 local type = gsub(self.type,"%s*const%s+","") 194 198 t[type] = "tolua_collect_" .. clean_template(type) … … 222 226 -- return 'tolua_isstringarray(tolua_S,'..narg..','..def..',&tolua_err)' 223 227 --else 224 return ' tolua_istable(tolua_S,'..narg..',0,&tolua_err)'228 return '!tolua_istable(tolua_S,'..narg..',0,&tolua_err)' 225 229 --end 226 230 elseif t then 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 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 231 240 end 232 241 … … 237 246 local mod 238 247 local type = self.type 248 local nctype = gsub(self.type,'const%s+','') 239 249 if self.dim ~= '' then 240 250 type = gsub(self.type,'const%s+','') -- eliminates const modifier for arrays … … 251 261 else 252 262 if cplusplus then 253 line = concatparam(line,' = new',type,ptr,'['..self.dim..'];')263 line = concatparam(line,' = Mtolua_new_dim(',type,ptr,', '..self.dim..');') 254 264 else 255 265 line = concatparam(line,' = (',type,ptr,'*)', … … 273 283 end 274 284 line = concatparam(line,') ') 275 if isenum( type) then285 if isenum(nctype) then 276 286 line = concatparam(line,'(int) ') 277 287 end … … 286 296 line = concatparam(line,'tolua_to'..t,'(tolua_S,',narg,',',def,'));') 287 297 else 288 line = concatparam(line,'tolua_tousertype(tolua_S,',narg,',',def,'));') 298 local to_func = get_to_function(type) 299 line = concatparam(line,to_func..'(tolua_S,',narg,',',def,'));') 289 300 end 290 301 end … … 361 372 output(' {') 362 373 output('#ifdef __cplusplus\n') 363 output(' void* tolua_obj = new',type,'(',self.name,'[i]);')374 output(' void* tolua_obj = Mtolua_new((',type,')(',self.name,'[i]));') 364 375 output(' tolua_pushfieldusertype_and_takeownership(tolua_S,',narg,',i+1,tolua_obj,"',type,'");') 365 376 output('#else\n') … … 380 391 if self.dim ~= '' and tonumber(self.dim)==nil then 381 392 output('#ifdef __cplusplus\n') 382 output(' delete []',self.name,';')393 output(' Mtolua_delete_dim(',self.name,');') 383 394 output('#else\n') 384 395 output(' free(',self.name,');') … … 405 416 output(' tolua_push'..t..'(tolua_S,(',ct,')'..self.name..');') 406 417 else 407 output(' tolua_pushusertype(tolua_S,(void*)'..self.name..',"',self.type,'");') 418 local push_func = get_push_function(self.type) 419 output(' ',push_func,'(tolua_S,(void*)'..self.name..',"',self.type,'");') 408 420 end 409 421 return 1
Note: See TracChangeset
for help on using the changeset viewer.