Example #1
0
/* method: getDataRootDirectory of class  Global */
static int tolua_LuaAPI_Global_getDataRootDirectory00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
 !tolua_isusertype(tolua_S,1,"Global",0,&tolua_err) || 
 !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
 goto tolua_lerror;
 else
#endif
 {
  Global* self = (Global*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
 if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getDataRootDirectory'",NULL);
#endif
 {
  tstring tolua_ret =  self->getDataRootDirectory();
 {
#ifdef __cplusplus
 void* tolua_obj = new tstring(tolua_ret);
 tolua_pushusertype(tolua_S,tolua_clone(tolua_S,tolua_obj,tolua_collect_tstring),"tstring");
#else
 void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(tstring));
 tolua_pushusertype(tolua_S,tolua_clone(tolua_S,tolua_obj,NULL),"tstring");
#endif
 }
 }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'getDataRootDirectory'.",&tolua_err);
 return 0;
#endif
}
Example #2
0
/* Take ownership
 */
int tolua_bnd_takeownership (lua_State* L)
{
  lua_CFunction func = 0;
  if (lua_isuserdata(L,1))
  {
    if (lua_getmetatable(L,1))        /* if metatable? */
    {
      void* u;
      lua_pushstring(L,".collector");
      lua_rawget(L,-2);
      func = lua_iscfunction(L,-1) ? lua_tocfunction(L,-1) : NULL; 
      lua_pop(L,2);
      u = *((void**)lua_touserdata(L,1));
      tolua_clone(L,u,func);
    }
  }
  lua_pushboolean(L,func!=0);
  return 1;
}
Example #3
0
/* Take ownership
*/
static int tolua_bnd_takeownership (lua_State* L)
{
	lua_CFunction func = 0;
	if (lua_isuserdata(L,1))
	{
		if (lua_getmetatable(L,1))        /* if metatable? */
		{
			void* u;
			lua_pushstring(L,".collector");
   lua_rawget(L,-2);
			func = lua_tocfunction(L,-1);    /* it may be NULL; it is ok */
			lua_pop(L,2);
	  u = *((void**)lua_touserdata(L,1));
			/* force garbage collection to avoid C to reuse a to-be-collected address */
			lua_setgcthreshold(L,0);
			tolua_clone(L,u,func);
		}
	}
	lua_pushboolean(L,func!=0);
	return 1;
}