From: Christian Heinrich Date: Tue, 19 Jan 2016 23:35:56 +0000 (+0100) Subject: [Lua] Further removal of unnecessary lua glue code X-Git-Tag: v3_13~1178 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/294c65e4acef286ef87ef040a51b060c82b51f2e [Lua] Further removal of unnecessary lua glue code --- diff --git a/src/bindings/lua/lua_host.c b/src/bindings/lua/lua_host.c index cef6cf865c..11c70ef05f 100644 --- a/src/bindings/lua/lua_host.c +++ b/src/bindings/lua/lua_host.c @@ -160,20 +160,6 @@ static int l_host_get_property_value(lua_State * L) return 1; } -/** - * \brief Makes the current process sleep for a while. - * \param L a Lua state - * \return number of values returned to Lua - * - * - Argument 1 (number): duration of the sleep - */ -static int l_host_sleep(lua_State *L) -{ - int time = luaL_checkinteger(L, 1); - MSG_process_sleep(time); - return 0; -} - /** * \brief Destroys a host. * \param L a Lua state @@ -195,10 +181,8 @@ static const luaL_Reg host_functions[] = { {"at", l_host_at}, {"self", l_host_self}, {"get_prop_value", l_host_get_property_value}, - {"sleep", l_host_sleep}, {"destroy", l_host_destroy}, // Bypass XML Methods - {"set_function", console_set_function}, {"set_property", console_host_set_property}, {NULL, NULL} }; diff --git a/src/bindings/lua/lua_platf.c b/src/bindings/lua/lua_platf.c index f8733f9b46..21507e59e3 100644 --- a/src/bindings/lua/lua_platf.c +++ b/src/bindings/lua/lua_platf.c @@ -528,47 +528,6 @@ int console_AS_close(lua_State *L) { return 0; } -int console_set_function(lua_State *L) { - - const char *host_id ; - const char *function_id; - xbt_dynar_t args; - - if (! lua_istable(L, 1)) { - XBT_ERROR("Bad Arguments to AS.new, Should be a table with named arguments"); - return -1; - } - - // get Host id - lua_pushstring(L, "host"); - lua_gettable(L, -2); - host_id = lua_tostring(L, -1); - lua_pop(L, 1); - - // get Function Name - lua_pushstring(L, "fct"); - lua_gettable(L, -2); - function_id = lua_tostring(L, -1); - lua_pop(L, 1); - - //get args - lua_pushstring(L,"args"); - lua_gettable(L, -2); - args = xbt_str_split_str( lua_tostring(L,-1) , ","); - lua_pop(L, 1); - - msg_host_t host = MSG_host_by_name(host_id); - if (!host) { - XBT_ERROR("no host '%s' found",host_id); - return -1; - } - - // FIXME: use sg_platf_new_process directly (warning: find a way to check hostname) - MSG_set_function(host_id, function_id, args); - - return 0; -} - int console_host_set_property(lua_State *L) { const char* name =""; const char* prop_id = ""; diff --git a/src/bindings/lua/simgrid_lua.c b/src/bindings/lua/simgrid_lua.c index 2a8fb37ef4..a616e6afdc 100644 --- a/src/bindings/lua/simgrid_lua.c +++ b/src/bindings/lua/simgrid_lua.c @@ -17,8 +17,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua, bindings, "Lua Bindings"); -static lua_State* sglua_maestro_state; - int luaopen_simgrid(lua_State *L); static void sglua_register_c_functions(lua_State *L); @@ -97,49 +95,6 @@ int luaopen_simgrid(lua_State *L) { XBT_DEBUG("luaopen_simgrid *****"); - /* 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"); - sglua_register_c_functions(L); return 1;