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/function.lua

    r3127 r3138  
    209209    if class then narg=2 else narg=1 end
    210210    if class then
    211         local func = get_is_function(self.parent.type)
     211        local func = 'tolua_isusertype'
    212212        local type = self.parent.type
    213213        if self.name=='new' or static~=nil then
     
    226226            local btype = isbasic(self.args[i].type)
    227227            if btype ~= 'value' and btype ~= 'state' then
    228                 output('     '..self.args[i]:outchecktype(narg)..' ||\n')
     228                output('     !'..self.args[i]:outchecktype(narg)..' ||\n')
    229229            end
    230230            if btype ~= 'state' then
     
    250250        output(' ',self.const,self.parent.type,'*','self = ')
    251251        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);')
    254253    elseif static then
    255254        _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
     
    270269    if class and self.name~='new' and static==nil then
    271270        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);');
    273272        output('#endif\n')
    274273    end
     
    313312    --------------------------------------------------
    314313
    315     pre_call_hook(self)
    316 
    317314    local out = string.find(self.mod, "tolua_outside")
    318315
     
    326323    -- call function
    327324    if class and self.name=='delete' then
    328         output('  Mtolua_delete(self);')
     325        output('  delete self;')
    329326    elseif class and self.name == 'operator&[]' then
    330327        if flags['1'] then -- for compatibility with tolua5 ?
     
    355352    end
    356353    if class and self.name=='new' then
    357         output('Mtolua_new((',self.type,')(')
     354        output('new',self.type,'(')
    358355    elseif class and static then
    359356        if out then
     
    367364        else
    368365            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')
    371367            else
    372368                output('self->'..self.name,'(')
     
    396392        output('-1);')
    397393    else
    398         if class and self.name=='new' then
    399             output('));') -- close Mtolua_new(
    400         else
    401             output(');')
    402         end
     394        output(');')
    403395    end
    404396
     
    407399        nret = nret + 1
    408400        local t,ct = isbasic(self.type)
    409         if t and self.name ~= "new" then
     401        if t then
    410402            if self.cast_operator and _basic_raw_push[t] then
    411403                output('   ',_basic_raw_push[t],'(tolua_S,(',ct,')tolua_ret);')
     
    416408                t = self.type
    417409                new_t = string.gsub(t, "const%s+", "")
    418                 local owned = false
    419                 if string.find(self.mod, "tolua_owned") then
    420                     owned = true
    421                 end
    422                 local push_func = get_push_function(t)
    423410                if self.ptr == '' then
    424411                    output('   {')
    425412                    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,'");')
    429415                    output('#else\n')
    430416                    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,'");')
    433418                    output('#endif\n')
    434419                    output('   }')
    435420                elseif self.ptr == '&' then
    436                     output('   ',push_func,'(tolua_S,(void*)&tolua_ret,"',t,'");')
     421                    output('   tolua_pushusertype(tolua_S,(void*)&tolua_ret,"',t,'");')
    437422                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,'");')
    441427                    end
    442428                end
     
    480466    end
    481467
    482     post_call_hook(self)
    483 
    484468    output(' }')
    485469    output(' return '..nret..';')
     
    490474        output('#ifndef TOLUA_RELEASE\n')
    491475        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);')
    493477        output(' return 0;')
    494478        output('#endif\n')
     
    590574    if string.find(par, "%*") then -- it's a pointer with a default value
    591575
    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?
    593577            return true
    594578        end
     
    677661        --ns = strip_defaults(ns)
    678662
    679         local f = Function(d, ns, c)
     663        Function(d, ns, c)
    680664        for i=1,last do
    681665            t[i] = string.gsub(t[i], "=.*$", "")
Note: See TracChangeset for help on using the changeset viewer.