#include "simgrid/s4u/Host.hpp"
#include <lauxlib.h>
-XBT_LOG_NEW_DEFAULT_CATEGORY(lua_host, "Lua Host module");
+constexpr char HOST_MODULE_NAME[] = "simgrid.host";
+constexpr char HOST_FIELDNAME[] = "__simgrid_host";
-#define HOST_MODULE_NAME "simgrid.host"
-#define HOST_FIELDNAME "__simgrid_host"
/* ********************************************************************************* */
/* simgrid.host API */
/* ********************************************************************************* */
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");
*/
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;
}
/* 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 */