Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #193 from Takishipp/signals
[simgrid.git] / src / bindings / lua / simgrid_lua.cpp
index 40c9c8d..846d2b0 100644 (file)
@@ -8,18 +8,15 @@
 
 #include "lua_private.h"
 #include "lua_utils.h"
-#include "xbt.h"
-#include "simgrid/msg.h"
-#include "simgrid/simdag.h"
-#include "surf/surfxml_parse.h"
-#include <lauxlib.h>
+#include "src/surf/xml/platf.hpp"
 
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua, bindings, "Lua Bindings");
+XBT_LOG_NEW_DEFAULT_CATEGORY(lua, "Lua Bindings");
 
 extern "C" {
+#include <lauxlib.h>
+
 int luaopen_simgrid(lua_State *L);
-static void sglua_register_c_functions(lua_State *L);
 }
 
 /* ********************************************************************************* */
@@ -72,7 +69,7 @@ static int critical(lua_State* L) {
  * @brief Dumps a lua table with XBT_DEBUG
  *
  * This function can be called from within lua via "simgrid.dump(table)". It will
- * then dump the table via XBT_DEBUG 
+ * then dump the table via XBT_DEBUG
  */
 static int dump(lua_State* L) {
   int argc = lua_gettop(L);
@@ -81,7 +78,7 @@ static int dump(lua_State* L) {
     if (lua_istable(L, i)) {
       lua_pushnil(L); /* table nil */
 
-      //lua_next pops the topmost element from the stack and 
+      //lua_next pops the topmost element from the stack and
       //gets the next pair from the table at the specified index
       while (lua_next(L, i)) { /* table key val  */
         // we need to copy here, as a cast from "Number" to "String"
@@ -107,31 +104,13 @@ static const luaL_Reg simgrid_functions[] = {
   {"info", info},
   {"critical", critical},
   {"error", error},
-  {NULL, NULL}
+  {nullptr, nullptr}
 };
 
 /* ********************************************************************************* */
 /*                           module management functions                             */
 /* ********************************************************************************* */
 
-/**
- * \brief Opens the simgrid Lua module.
- *
- * This function is called automatically by the Lua interpreter when some
- * Lua code requires the "simgrid" module.
- *
- * \param L the Lua state
- */
-int luaopen_simgrid(lua_State *L)
-{
-  XBT_DEBUG("luaopen_simgrid *****");
-
-  sglua_register_c_functions(L);
-
-  return 1;
-}
-
-
 /**
  * \brief Makes the core functions available to the Lua world.
  * \param L a Lua world
@@ -145,12 +124,20 @@ static void sglua_register_core_functions(lua_State *L)
 }
 
 /**
- * \brief Creates the simgrid module and make it available to Lua.
- * \param L a Lua world
+ * \brief Opens the simgrid Lua module.
+ *
+ * This function is called automatically by the Lua interpreter when some
+ * Lua code requires the "simgrid" module.
+ *
+ * \param L the Lua state
  */
-static void sglua_register_c_functions(lua_State *L)
+int luaopen_simgrid(lua_State *L)
 {
+  XBT_DEBUG("luaopen_simgrid *****");
+
   sglua_register_core_functions(L);
   sglua_register_host_functions(L);
   sglua_register_platf_functions(L);
+
+  return 1;
 }