Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 9, 2009, 4:29:42 PM (15 years ago)
Author:
rgrieder
Message:

Update to tolua 1.0.93

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pch/src/tolua/lua/declaration.lua

    r2710 r3127  
    140140        for i=1, table.getn(m) do
    141141            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
    144147        end
    145148
    146149        local b,i
    147150        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, ",")..">"
    149153        type = rebuild_template(type, b, template_part)
    150154        type = string.gsub(type, ">>", "> >")
     
    187191-- check if array of values are returned to Lua
    188192function classDeclaration:requirecollection (t)
    189  if self.mod ~= 'const' and
     193    if self.mod ~= 'const' and
    190194        self.dim and self.dim ~= '' and
    191195                 not isbasic(self.type) and
    192                  self.ptr == '' then
     196                 self.ptr == '' and self:check_public_access() then
    193197        local type = gsub(self.type,"%s*const%s+","")
    194198        t[type] = "tolua_collect_" .. clean_template(type)
     
    222226        --    return 'tolua_isstringarray(tolua_S,'..narg..','..def..',&tolua_err)'
    223227        --else
    224         return 'tolua_istable(tolua_S,'..narg..',0,&tolua_err)'
     228        return '!tolua_istable(tolua_S,'..narg..',0,&tolua_err)'
    225229        --end
    226230    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
    231240end
    232241
     
    237246    local mod
    238247    local type = self.type
     248    local nctype = gsub(self.type,'const%s+','')
    239249    if self.dim ~= '' then
    240250        type = gsub(self.type,'const%s+','')  -- eliminates const modifier for arrays
     
    251261        else
    252262            if cplusplus then
    253                 line = concatparam(line,' = new',type,ptr,'['..self.dim..'];')
     263                line = concatparam(line,' = Mtolua_new_dim(',type,ptr,', '..self.dim..');')
    254264            else
    255265                line = concatparam(line,' = (',type,ptr,'*)',
     
    273283            end
    274284            line = concatparam(line,') ')
    275             if isenum(type) then
     285            if isenum(nctype) then
    276286                line = concatparam(line,'(int) ')
    277287            end
     
    286296                line = concatparam(line,'tolua_to'..t,'(tolua_S,',narg,',',def,'));')
    287297            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,'));')
    289300            end
    290301        end
     
    361372                output('   {')
    362373                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]));')
    364375                output('    tolua_pushfieldusertype_and_takeownership(tolua_S,',narg,',i+1,tolua_obj,"',type,'");')
    365376                output('#else\n')
     
    380391    if self.dim ~= '' and tonumber(self.dim)==nil then
    381392        output('#ifdef __cplusplus\n')
    382         output('  delete []',self.name,';')
     393        output('  Mtolua_delete_dim(',self.name,');')
    383394        output('#else\n')
    384395        output('  free(',self.name,');')
     
    405416            output('   tolua_push'..t..'(tolua_S,(',ct,')'..self.name..');')
    406417        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,'");')
    408420        end
    409421        return 1
Note: See TracChangeset for help on using the changeset viewer.