X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4940fad595cbddbcfa32102b953120f25d95b8d6..0957451c250c6ebbe0ae4d68a6a45c402b6d5f56:/src/bindings/lua/lua_platf.cpp diff --git a/src/bindings/lua/lua_platf.cpp b/src/bindings/lua/lua_platf.cpp index c371d70083..9d52127c65 100644 --- a/src/bindings/lua/lua_platf.cpp +++ b/src/bindings/lua/lua_platf.cpp @@ -22,7 +22,7 @@ extern "C" { XBT_LOG_NEW_DEFAULT_CATEGORY(lua_platf, "Lua bindings (platform module)"); -#define PLATF_MODULE_NAME "simgrid.platf" +#define PLATF_MODULE_NAME "simgrid.engine" #define AS_FIELDNAME "__simgrid_as" /* ********************************************************************************* */ @@ -484,9 +484,17 @@ int console_AS_open(lua_State *L) { 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");