Changeset 3127 for code/branches/pch/src/tolua/lua/operator.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/operator.lua
r2710 r3127 75 75 output(' if (\n') 76 76 -- check self 77 output(' !'..'tolua_isusertype(tolua_S,1,"'..self.parent.type..'",0,&tolua_err) ||\n') 77 local is_func = get_is_function(self.parent.type) 78 output(' !'..is_func..'(tolua_S,1,"'..self.parent.type..'",0,&tolua_err) ||\n') 78 79 output(' !tolua_isnoobj(tolua_S,2,&tolua_err)\n )') 79 80 output(' goto tolua_lerror;') … … 86 87 output(' ',self.const,self.parent.type,'*','self = ') 87 88 output('(',self.const,self.parent.type,'*) ') 88 output('tolua_tousertype(tolua_S,1,0);') 89 local to_func = get_to_func(self.parent.type) 90 output(to_func,'(tolua_S,1,0);') 89 91 90 92 -- check self 91 93 output('#ifndef TOLUA_RELEASE\n') 92 output(' if (!self) tolua_error(tolua_S," invalid \'self\' in function \''..self.name..'\'",NULL);');94 output(' if (!self) tolua_error(tolua_S,"'..output_error_hook("invalid \'self\' in function \'%s\'", self.name)..'",NULL);'); 93 95 output('#endif\n') 94 96 … … 103 105 else 104 106 t = self.type 107 local push_func = get_push_function(t) 105 108 new_t = string.gsub(t, "const%s+", "") 106 109 if self.ptr == '' then 107 110 output(' {') 108 111 output('#ifdef __cplusplus\n') 109 output(' void* tolua_obj = new',new_t,'(tolua_ret);') 110 output(' tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");') 112 output(' void* tolua_obj = Mtolua_new((',new_t,')(tolua_ret));') 113 output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");') 114 output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') 111 115 output('#else\n') 112 116 output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));') 113 output(' tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");') 117 output(' ',push_func,'(tolua_S,tolua_obj,"',t,'");') 118 output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') 114 119 output('#endif\n') 115 120 output(' }') 116 121 elseif self.ptr == '&' then 117 output(' tolua_pushusertype(tolua_S,(void*)&tolua_ret,"',t,'");')122 output(' ',push_func,'(tolua_S,(void*)&tolua_ret,"',t,'");') 118 123 else 119 124 if local_constructor then 120 output(' tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"',t,'");') 125 output(' ',push_func,'(tolua_S,(void *)tolua_ret,"',t,'");') 126 output(' tolua_register_gc(tolua_S,lua_gettop(tolua_S));') 121 127 else 122 output(' tolua_pushusertype(tolua_S,(void*)tolua_ret,"',t,'");')128 output(' ',push_func,'(tolua_S,(void*)tolua_ret,"',t,'");') 123 129 end 124 130 end … … 130 136 output('#ifndef TOLUA_RELEASE\n') 131 137 output('tolua_lerror:\n') 132 output(' tolua_error(tolua_S," #ferror in function \''..self.lname..'\'.",&tolua_err);')138 output(' tolua_error(tolua_S,"'..output_error_hook("#ferror in function \'%s\'.", self.lname)..'",&tolua_err);') 133 139 output(' return 0;') 134 140 output('#endif\n')
Note: See TracChangeset
for help on using the changeset viewer.