From c72ae3bad7ed1899364f613171150f8c01f41022 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 6 Oct 2006 01:15:31 +0000 Subject: [PATCH] use luaL_pushtype --- stepmania/src/LuaManager.cpp | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/stepmania/src/LuaManager.cpp b/stepmania/src/LuaManager.cpp index 6c5ad4b937..c8cf7c2463 100644 --- a/stepmania/src/LuaManager.cpp +++ b/stepmania/src/LuaManager.cpp @@ -557,35 +557,13 @@ bool LuaHelpers::RunAtExpressionS( RString &sStr ) return true; } -/* Like luaL_typerror, but without the special case for argument 1 being "self" - * in method calls, so we give a correct error message after we remove self. */ -static RString GetLuaBindingType( Lua *L, int iArgNo ) -{ - if( lua_isnil(L, iArgNo) ) - return "nil"; - - int iTop = lua_gettop( L ); - if( !lua_getmetatable(L, iArgNo) ) - { - lua_settop( L, iTop ); - return ssprintf( "non-bound %s", lua_typename(L, lua_type(L, iArgNo)) ); - } - - int iMetatable = lua_gettop( L ); - lua_pushstring( L, "type" ); - lua_rawget( L, iMetatable ); - RString sActualType; - LuaHelpers::FromStack( L, sActualType, -1 ); - - lua_settop( L, iTop ); - return sActualType; -} - /* Like luaL_typerror, but without the special case for argument 1 being "self" * in method calls, so we give a correct error message after we remove self. */ int LuaHelpers::TypeError( Lua *L, int iArgNo, const char *szName ) { - RString sType = GetLuaBindingType( L, iArgNo ); + RString sType; + luaL_pushtype( L, iArgNo ); + LuaHelpers::Pop( L, sType ); lua_Debug debug; if( !lua_getstack( L, 0, &debug ) )