X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d8eb62b207b566949a0d9ce649a7b21e226b9168..08f744b9a55745ac1b1dcf0ed2ea735471cd7f89:/src/bindings/lua/lua_host.cpp diff --git a/src/bindings/lua/lua_host.cpp b/src/bindings/lua/lua_host.cpp index 02b55834fe..c9e15239b8 100644 --- a/src/bindings/lua/lua_host.cpp +++ b/src/bindings/lua/lua_host.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -11,13 +11,14 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(lua_host, "Lua Host module"); -#define HOST_MODULE_NAME "simgrid.host" -#define HOST_FIELDNAME "__simgrid_host" +constexpr char HOST_MODULE_NAME[] = "simgrid.host"; +constexpr char HOST_FIELDNAME[] = "__simgrid_host"; + /* ********************************************************************************* */ /* simgrid.host API */ /* ********************************************************************************* */ -/** @brief Ensures that the pointed stack value is an host userdatum and returns it. +/** @brief Ensures that the pointed stack value is a host userdatum and returns it. * * @param L a Lua state * @param index an index in the Lua stack @@ -29,8 +30,7 @@ sg_host_t sglua_check_host(lua_State * L, int index) lua_getfield(L, index, HOST_FIELDNAME); sg_host_t *pi = (sg_host_t *) luaL_checkudata(L, lua_gettop(L), HOST_MODULE_NAME); lua_pop(L, 1); - if (pi == nullptr) - XBT_ERROR("luaL_checkudata() returned nullptr"); + xbt_assert(pi != nullptr, "luaL_checkudata() returned nullptr"); sg_host_t ht = *pi; if (not ht) luaL_error(L, "null Host"); @@ -143,8 +143,8 @@ static int l_host_get_property_value(lua_State * L) */ static int l_host_destroy(lua_State *L) { - //sg_host_t ht = sglua_check_host(L, 1); - //FIXME: not working..__MSG_host_priv_free(MSG_host_priv(ht)); + sg_host_t ht = sglua_check_host(L, 1); + ht->destroy(); return 0; } @@ -208,7 +208,7 @@ void sglua_register_host_functions(lua_State* L) /* metatable.__index = simgrid.host * we put the host functions inside the host userdata itself: - * this allows to write my_host:method(args) for + * this allows one to write my_host:method(args) for * simgrid.host.method(my_host, args) */ lua_setfield(L, -2, "__index"); /* simgrid simgrid.host mt */