Example #1
0
/* method: GetBasePtr of class  Object */
static int tolua_Object_Object_GetBasePtr00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
 !tolua_isusertype(tolua_S,1,"const Object",0,&tolua_err) || 
 !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
 goto tolua_lerror;
 else
#endif
 {
  const Object* self = (const Object*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
 if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBasePtr'",NULL);
#endif
 {
  void* tolua_ret = (void*)  self->GetBasePtr();
 tolua_pushuserdata(tolua_S,(void*)tolua_ret);
 }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'GetBasePtr'.",&tolua_err);
 return 0;
#endif
}
Example #2
0
	void LuaEngineEx::copyBetweenLuaStates(lua_State *from, lua_State *to, int index)
	{
		switch (lua_type(from, index))
		{
		case LUA_TBOOLEAN:
			lua_pushboolean(to, lua_toboolean(from, index));
			break;
		case LUA_TNUMBER:
		{
							lua_Number num = lua_tonumber(from, index);
							lua_pushnumber(to, num);
		}
			break;
		case LUA_TSTRING:
		{
							size_t len;
							const char *s = lua_tolstring(from, index, &len);
							lua_pushlstring(to, s, len);
		}
			break;
		case LUA_TLIGHTUSERDATA:
			lua_pushlightuserdata(to, lua_touserdata(from, index));
			break;
		case LUA_TUSERDATA:
			// any issues??
			tolua_pushuserdata(to, lua_touserdata(from, index));
			break;
		case LUA_TNIL:
			lua_pushnil(to);
			break;
		case LUA_TTABLE:
			lua_newtable(to);
			lua_pushnil(from);		// start iteration
			while (lua_next(from, -2))
			{
				unsigned int val_i = lua_gettop(from);
				unsigned int key_i = val_i - 1;

				copyBetweenLuaStates(from, to, key_i);
				copyBetweenLuaStates(from, to, val_i);

				lua_rawset(to, -3);		// without __newIndex trigger
				lua_pop(from, 1);		// next round, pop out the value
			}
			// end iteration
			break;
		case LUA_TFUNCTION:
			// todo
			break;
		case LUA_TTHREAD:
			// doesn't support
			break;
		}
	}
Example #3
0
static int tolua_CCGUI_CCUtil_emptydata00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertable(tolua_S,1,"CCUtil",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  {
   void* tolua_ret = (void*)  CCUtil::emptydata();
   tolua_pushuserdata(tolua_S,(void*)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'emptydata'.",&tolua_err);
 return 0;
#endif
}
Example #4
0
TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v)
{
 lua_pushnumber(L,index);
 tolua_pushuserdata(L,v);
 lua_settable(L,lo);
}