Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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.

File:
1 edited

Legend:

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

    r3127 r3138  
    140140        for i=1, table.getn(m) do
    141141            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])
    147144        end
    148145
    149146        local b,i
    150147        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), " ", ",")..">"
    153149        type = rebuild_template(type, b, template_part)
    154150        type = string.gsub(type, ">>", "> >")
     
    191187-- check if array of values are returned to Lua
    192188function classDeclaration:requirecollection (t)
    193     if self.mod ~= 'const' and
     189 if self.mod ~= 'const' and
    194190        self.dim and self.dim ~= '' and
    195191                 not isbasic(self.type) and
    196                  self.ptr == '' and self:check_public_access() then
     192                 self.ptr == '' then
    197193        local type = gsub(self.type,"%s*const%s+","")
    198194        t[type] = "tolua_collect_" .. clean_template(type)
     
    226222        --    return 'tolua_isstringarray(tolua_S,'..narg..','..def..',&tolua_err)'
    227223        --else
    228         return '!tolua_istable(tolua_S,'..narg..',0,&tolua_err)'
     224        return 'tolua_istable(tolua_S,'..narg..',0,&tolua_err)'
    229225        --end
    230226    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
    240231end
    241232
     
    246237    local mod
    247238    local type = self.type
    248     local nctype = gsub(self.type,'const%s+','')
    249239    if self.dim ~= '' then
    250240        type = gsub(self.type,'const%s+','')  -- eliminates const modifier for arrays
     
    261251        else
    262252            if cplusplus then
    263                 line = concatparam(line,' = Mtolua_new_dim(',type,ptr,', '..self.dim..');')
     253                line = concatparam(line,' = new',type,ptr,'['..self.dim..'];')
    264254            else
    265255                line = concatparam(line,' = (',type,ptr,'*)',
     
    283273            end
    284274            line = concatparam(line,') ')
    285             if isenum(nctype) then
     275            if isenum(type) then
    286276                line = concatparam(line,'(int) ')
    287277            end
     
    296286                line = concatparam(line,'tolua_to'..t,'(tolua_S,',narg,',',def,'));')
    297287            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,'));')
    300289            end
    301290        end
     
    372361                output('   {')
    373362                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]);')
    375364                output('    tolua_pushfieldusertype_and_takeownership(tolua_S,',narg,',i+1,tolua_obj,"',type,'");')
    376365                output('#else\n')
     
    391380    if self.dim ~= '' and tonumber(self.dim)==nil then
    392381        output('#ifdef __cplusplus\n')
    393         output('  Mtolua_delete_dim(',self.name,');')
     382        output('  delete []',self.name,';')
    394383        output('#else\n')
    395384        output('  free(',self.name,');')
     
    416405            output('   tolua_push'..t..'(tolua_S,(',ct,')'..self.name..');')
    417406        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,'");')
    420408        end
    421409        return 1
Note: See TracChangeset for help on using the changeset viewer.