static int l_host_get_by_name(lua_State * L)
{
const char *name = luaL_checkstring(L, 1);
+ lua_remove(L, 1); /* remove the args from the stack */
XBT_DEBUG("Getting host by name...");
sg_host_t host = sg_host_by_name(name);
if (host == nullptr)
lua_setmetatable(L, -2); /* table userdatum */
lua_setfield(L, -2, HOST_FIELDNAME); /* table -- put the userdata as field of the table */
- /* remove the args from the stack */
- lua_remove(L, 1);
return 1;
}
s_sg_platf_AS_cbarg_t AS;
AS.id = id;
AS.routing = mode_int;
- sg_platf_new_AS_begin(&AS);
+ simgrid::s4u::As *new_as = sg_platf_new_AS_begin(&AS);
- return 0;
+ /* Build a Lua representation of the new AS on the stack */
+ lua_newtable(L);
+ simgrid::s4u::As **lua_as = (simgrid::s4u::As **) lua_newuserdata(L, sizeof(simgrid::s4u::As *)); /* table userdatum */
+ *lua_as = new_as;
+ luaL_getmetatable(L, PLATF_MODULE_NAME); /* table userdatum metatable */
+ lua_setmetatable(L, -2); /* table userdatum */
+ lua_setfield(L, -2, AS_FIELDNAME); /* table -- put the userdata as field of the table */
+
+ return 1;
}
int console_AS_seal(lua_State *L) {
XBT_DEBUG("Sealing AS");
* @param AS_id name of this autonomous system. Must be unique in the platform
* @param wanted_routing_type one of Full, Floyd, Dijkstra or similar. Full list in the variable routing_models, in src/surf/surf_routing.c
*/
-void sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS)
+simgrid::s4u::As * sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS)
{
if (!surf_parse_models_setup_already_called) {
/* Initialize the surf models. That must be done after we got all config, and before we need the models.
simgrid::surf::asCreatedCallbacks(new_as);
if (TRACE_is_enabled())
sg_instr_AS_begin(AS);
+
+ return new_as;
}
/**
XBT_PUBLIC(void) sg_platf_begin(void); // Start a new platform
XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
-XBT_PUBLIC(void) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
+XBT_PUBLIC(simgrid::s4u::As*) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
XBT_PUBLIC(void) sg_platf_new_AS_seal(void); // That AS is fully described
XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); // Add an host to the currently described AS