Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The process list of MSG is now a swag instead of a fifo.
[simgrid.git] / src / bindings / lua / simgrid_lua.c
index 5464bbf..1f78abc 100644 (file)
@@ -9,6 +9,8 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua, bindings, "Lua Bindings");
 
+lua_State *simgrid_lua_state;
+
 #define TASK_MODULE_NAME "simgrid.Task"
 #define HOST_MODULE_NAME "simgrid.Host"
 // Surf ( bypass XML )
@@ -410,31 +412,33 @@ static int gras_generate(lua_State * L)
  **********************************/
 static int trace_start(lua_State *L)
 {
+#ifdef HAVE_TRACING
   TRACE_start();
+#endif
   return 1;
 }
 
 static int trace_category(lua_State * L)
 {
-  /* _XBT_GNUC_UNUSED to pass compilation in paranoid mode without tracing
-   * support, where TRACE_category(x) is preprocessed to nothing. */
-  const char *category _XBT_GNUC_UNUSED = luaL_checkstring(L, 1);
-  TRACE_category(category);
+#ifdef HAVE_TRACING
+  TRACE_category(luaL_checkstring(L, 1));
+#endif
   return 1;
 }
 
 static int trace_set_task_category(lua_State *L)
 {
-  /* _XBT_GNUC_UNUSED as above */
-  m_task_t tk _XBT_GNUC_UNUSED = checkTask(L, -2);
-  const char *category _XBT_GNUC_UNUSED = luaL_checkstring(L, -1);
-  TRACE_msg_set_task_category(tk, category);
+#ifdef HAVE_TRACING
+  TRACE_msg_set_task_category(checkTask(L, -2), luaL_checkstring(L, -1));
+#endif
   return 1;
 }
 
 static int trace_end(lua_State *L)
 {
+#ifdef HAVE_TRACING
   TRACE_end();
+#endif
   return 1;
 }
 //***********Register Methods *******************************************//
@@ -562,11 +566,17 @@ static int create_environment(lua_State * L)
   const char *file = luaL_checkstring(L, 1);
   DEBUG1("Loading environment file %s", file);
   MSG_create_environment(file);
-  smx_host_t *hosts = SIMIX_host_get_table();
-  int i;
-  for (i = 0; i < SIMIX_host_get_number(); i++) {
-    DEBUG1("We have an host %s", SIMIX_host_get_name(hosts[i]));
+
+/*
+  xbt_dict_t hosts = SIMIX_host_get_dict();
+  smx_host_t host;
+  xbt_dict_cursor_t c;
+  const char *name;
+
+  xbt_dict_foreach(hosts, c, name, host) {
+    DEBUG1("We have an host %s", SIMIX_host_get_name(host));
   }
+*/
 
   return 0;
 }
@@ -608,6 +618,8 @@ static int msg_register_platform(lua_State * L)
 {
   /* Tell Simgrid we dont wanna use its parser */
   surf_parse = console_parse_platform;
+  surf_parse_reset_callbacks();
+  surf_config_models_setup(NULL);
   MSG_create_environment(NULL);
   return 0;
 }
@@ -619,6 +631,8 @@ static int msg_register_platform(lua_State * L)
 static int sd_register_platform(lua_State * L)
 {
   surf_parse = console_parse_platform_wsL07;
+  surf_parse_reset_callbacks();
+  surf_config_models_setup(NULL);
   SD_create_environment(NULL);
   return 0;
 }
@@ -630,6 +644,8 @@ static int gras_register_platform(lua_State * L)
 {
   /* Tell Simgrid we dont wanna use surf parser */
   surf_parse = console_parse_platform;
+  surf_parse_reset_callbacks();
+  surf_config_models_setup(NULL);
   gras_create_environment(NULL);
   return 0;
 }
@@ -682,7 +698,6 @@ static const luaL_Reg simgrid_funcs[] = {
 /*                       module management functions                                 */
 /* ********************************************************************************* */
 
-extern const char *xbt_ctx_factory_to_use;      /*Hack: let msg load directly the right factory */
 
 #define LUA_MAX_ARGS_COUNT 10   /* maximum amount of arguments we can get from lua on command line */
 #define TEST
@@ -690,7 +705,6 @@ int luaopen_simgrid(lua_State * L);     // Fuck gcc: we don't need that prototyp
 int luaopen_simgrid(lua_State * L)
 {
 
-  //xbt_ctx_factory_to_use = "lua";
   char **argv = 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? */