Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
compile Lua bindings as C++ code
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 7 Feb 2016 11:10:41 +0000 (12:10 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 7 Feb 2016 11:14:23 +0000 (12:14 +0100)
src/bindings/lua/lua_debug.cpp [moved from src/bindings/lua/lua_debug.c with 98% similarity]
src/bindings/lua/lua_host.cpp [moved from src/bindings/lua/lua_host.c with 100% similarity]
src/bindings/lua/lua_platf.cpp [moved from src/bindings/lua/lua_platf.c with 100% similarity]
src/bindings/lua/lua_utils.h
src/bindings/lua/simgrid_lua.cpp [moved from src/bindings/lua/simgrid_lua.c with 99% similarity]
tools/cmake/DefinePackages.cmake

similarity index 98%
rename from src/bindings/lua/lua_debug.c
rename to src/bindings/lua/lua_debug.cpp
index 4dbe8c0..ef795da 100644 (file)
  *
  */
  /* SimGrid Lua debug functions                                             */
+extern "C" {
 #include <lauxlib.h>
+}
 #include "lua_utils.h"
 #include "xbt.h"
-#include "xbt/log.h"
-
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_debug, bindings, "Lua helper functions");
 
@@ -221,7 +221,7 @@ int sglua_memory_writer(lua_State* L, const void* source, size_t size,
   sglua_buffer_t buffer = (sglua_buffer_t) userdata;
   while (buffer->capacity < buffer->size + size) {
     buffer->capacity *= 2;
-    buffer->data = xbt_realloc(buffer->data, buffer->capacity);
+    buffer->data = (char*)xbt_realloc(buffer->data, buffer->capacity);
   }
   memcpy(buffer->data + buffer->size, source, size);
   buffer->size += size;
index 5f9f75f..2eea739 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef LUA_UTILS_H
 #define LUA_UTILS_H
 
+extern "C" {
+
 #include <lua.h>
 
 /**
@@ -30,4 +32,6 @@ void* sglua_checkudata_debug(lua_State* L, int ud, const char* tname);
 const char* sglua_get_spaces(int length);
 int sglua_memory_writer(lua_State* L, const void* source, size_t size, void* userdata);
 
+}
+
 #endif  /* LUA_UTILS_H */
similarity index 99%
rename from src/bindings/lua/simgrid_lua.c
rename to src/bindings/lua/simgrid_lua.cpp
index e3ed161..40c9c8d 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua, bindings, "Lua Bindings");
 
+extern "C" {
 int luaopen_simgrid(lua_State *L);
 static void sglua_register_c_functions(lua_State *L);
+}
 
 /* ********************************************************************************* */
 /*                                  simgrid API                                      */
index db533c0..b52a896 100644 (file)
@@ -523,10 +523,10 @@ list(APPEND JMSG_JAVA_SRC ${JTRACE_JAVA_SRC})
 
 set(LUA_SRC
   src/bindings/lua/factories/host.lua
-  src/bindings/lua/lua_host.c
-  src/bindings/lua/lua_platf.c
-  src/bindings/lua/lua_debug.c
-  src/bindings/lua/simgrid_lua.c
+  src/bindings/lua/lua_host.cpp
+  src/bindings/lua/lua_platf.cpp
+  src/bindings/lua/lua_debug.cpp
+  src/bindings/lua/simgrid_lua.cpp
   )
 
 set(TRACING_SRC