X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/784972ebca53b8141424e151c407f1fd004aeb3b..2ef50482d97a960d49f0d6d4389d84ab97d0bdc3:/src/bindings/lua/simgrid_lua.c diff --git a/src/bindings/lua/simgrid_lua.c b/src/bindings/lua/simgrid_lua.c index a9aa62f42a..1cee499512 100644 --- a/src/bindings/lua/simgrid_lua.c +++ b/src/bindings/lua/simgrid_lua.c @@ -25,40 +25,6 @@ int luaopen_simgrid(lua_State *L); static void register_c_functions(lua_State *L); static int run_lua_code(int argc, char **argv); - -/** - * \brief Like luaL_checkudata, with additional debug logs. - * - * This function is for debugging purposes only. - * - * \param L a lua state - * \param ud index of the userdata to check in the stack - * \param tname key of the metatable of this userdata in the registry - */ -static void* my_checkudata(lua_State* L, int ud, const char* tname) -{ - XBT_DEBUG("Checking the userdata: ud = %d", ud); - sglua_stack_dump("my_checkudata: ", L); - void* p = lua_touserdata(L, ud); - lua_getfield(L, LUA_REGISTRYINDEX, tname); - const void* correct_mt = lua_topointer(L, -1); - - int has_mt = lua_getmetatable(L, ud); - XBT_DEBUG("Checking the userdata: has metatable ? %d", has_mt); - const void* actual_mt = NULL; - if (has_mt) { - actual_mt = lua_topointer(L, -1); - lua_pop(L, 1); - } - XBT_DEBUG("Checking the task's metatable: expected %p, found %p", correct_mt, actual_mt); - sglua_stack_dump("my_checkudata: ", L); - - if (p == NULL || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2)) - luaL_typerror(L, ud, tname); - lua_pop(L, 2); - return p; -} - /* ********************************************************************************* */ /* simgrid.task API */ /* ********************************************************************************* */ @@ -317,7 +283,7 @@ static int l_task_gc(lua_State* L) */ static int l_task_tostring(lua_State* L) { - m_task_t task = sglua_checktask(L, 1); + m_task_t task = *((m_task_t*) luaL_checkudata(L, 1, TASK_MODULE_NAME)); lua_pushfstring(L, "Task: %p", task); return 1; }