/* 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. */
/* SimGrid Lua bindings */
/* 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. */
/* SimGrid Lua bindings */
/* ********************************************************************************* */
/* simgrid.host API */
/* ********************************************************************************* */
/* ********************************************************************************* */
/* simgrid.host API */
/* ********************************************************************************* */
- * This function is called from C and helps to verify that a specific
- * userdatum on the stack is in fact a sg_host_t.
- *
- * \param L a Lua state
- * \param index an index in the Lua stack
- * \return the C host corresponding to this Lua host
+ * @param L a Lua state
+ * @param index an index in the Lua stack
+ * @return the C host corresponding to this Lua host
luaL_checktype(L, index, LUA_TTABLE);
lua_getfield(L, index, HOST_FIELDNAME);
luaL_checktype(L, index, LUA_TTABLE);
lua_getfield(L, index, HOST_FIELDNAME);
- pi = (sg_host_t *) luaL_checkudata(L, lua_gettop(L), HOST_MODULE_NAME);
- if (pi == NULL)
- XBT_ERROR("luaL_checkudata() returned NULL");
- ht = *pi;
- if (!ht)
- luaL_error(L, "null Host");
+ sg_host_t *pi = (sg_host_t *) luaL_checkudata(L, lua_gettop(L), HOST_MODULE_NAME);
*
* - Argument 1 (string): name of a host
* - Return value (host): the corresponding host will be pushed onto the stack
*
* - Argument 1 (string): name of a host
* - Return value (host): the corresponding host will be pushed onto the stack
static int l_host_get_by_name(lua_State * L)
{
const char *name = luaL_checkstring(L, 1);
static int l_host_get_by_name(lua_State * L)
{
const char *name = luaL_checkstring(L, 1);
lua_newtable(L); /* table */
sg_host_t *lua_host = (sg_host_t *) lua_newuserdata(L, sizeof(sg_host_t)); /* table userdatum */
*lua_host = host;
luaL_getmetatable(L, HOST_MODULE_NAME); /* table userdatum metatable */
lua_setmetatable(L, -2); /* table userdatum */
lua_newtable(L); /* table */
sg_host_t *lua_host = (sg_host_t *) lua_newuserdata(L, sizeof(sg_host_t)); /* table userdatum */
*lua_host = host;
luaL_getmetatable(L, HOST_MODULE_NAME); /* table userdatum metatable */
lua_setmetatable(L, -2); /* table userdatum */
*
* - Argument 1 (host): a host
* - Return value (string): name of this host
*/
static int l_host_get_name(lua_State * L)
{
*
* - Argument 1 (host): a host
* - Return value (string): name of this host
*/
static int l_host_get_name(lua_State * L)
{
- sg_host_t ht = sglua_check_host(L, 1);
- lua_pushstring(L, sg_host_get_name(ht));
+ auto const* ht = sglua_check_host(L, 1);
+ lua_pushstring(L, ht->get_cname());
{"destroy", l_host_destroy},
// Bypass XML Methods
{"set_property", console_host_set_property},
{"destroy", l_host_destroy},
// Bypass XML Methods
{"set_property", console_host_set_property},
* simgrid.host.method(my_host, args) */
lua_setfield(L, -2, "__index"); /* simgrid simgrid.host mt */
* simgrid.host.method(my_host, args) */
lua_setfield(L, -2, "__index"); /* simgrid simgrid.host mt */