- /* Get the command line arguments from the lua interpreter */
- char **argv = xbt_malloc(sizeof(char *) * LUA_MAX_ARGS_COUNT);
- int argc = 1;
- argv[0] = (char *) "/usr/bin/lua"; /* Lie on the argv[0] so that the stack dumping facilities find the right binary. FIXME: what if lua is not in that location? */
-
- lua_getglobal(L, "arg");
- /* if arg is a null value, it means we use lua only as a script to init platform
- * else it should be a table and then take arg in consideration
- */
- if (lua_istable(L, -1)) {
- int done = 0;
- while (!done) {
- argc++;
- lua_pushinteger(L, argc - 2);
- lua_gettable(L, -2);
- if (lua_isnil(L, -1)) {
- done = 1;
- } else {
- xbt_assert(lua_isstring(L, -1),
- "argv[%d] got from lua is no string", argc - 1);
- xbt_assert(argc < LUA_MAX_ARGS_COUNT,
- "Too many arguments, please increase LUA_MAX_ARGS_COUNT in %s before recompiling SimGrid if you insist on having more than %d args on command line",
- __FILE__, LUA_MAX_ARGS_COUNT - 1);
- argv[argc - 1] = (char *) luaL_checkstring(L, -1);
- lua_pop(L, 1);
- XBT_DEBUG("Got command line argument %s from lua", argv[argc - 1]);
- }
- }
- argv[argc--] = NULL;
-
- /* Initialize the MSG core */
- XBT_DEBUG("Still %d arguments on command line", argc); // FIXME: update the lua's arg table to reflect the changes from SimGrid
- }
- MSG_init(&argc, argv);
- MSG_process_set_data_cleanup((void_f_pvoid_t) lua_close);
-
- /* Keep the context mechanism informed of our lua world today */
- sglua_maestro_state = L;
-
- /* initialize access to my tables by children Lua states */
- lua_newtable(L);
- lua_setfield(L, LUA_REGISTRYINDEX, "simgrid.maestro_tables");
-