Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / bindings / lua / lua_debug.cpp
index 171b847..ddf1fb4 100644 (file)
@@ -1,21 +1,20 @@
-/* Copyright (c) 2010-2016. The SimGrid Team.
- * All rights reserved.                                                     
+/* Copyright (c) 2010-2017. The SimGrid Team.
+ * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-
 /*
  * This file contains functions that aid users to debug their lua scripts; for instance,
  * tables can be easily output and values are represented in a human-readable way. (For instance,
- * a NULL value becomes the string "nil").
+ * a nullptr value becomes the string "nil").
  *
  */
  /* SimGrid Lua debug functions                                             */
 extern "C" {
 #include <lauxlib.h>
 }
-#include "lua_utils.h"
+#include "lua_utils.hpp"
 #include "xbt.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(lua_debug, "Lua bindings (helper functions)");
@@ -40,7 +39,7 @@ const char* sglua_tostring(lua_State* L, int index) {
       snprintf(buff, 4, "nil");
       break;
 
-    case LUA_TNUMBER: 
+    case LUA_TNUMBER:
       snprintf(buff, 64, "%.3f", lua_tonumber(L, index));
       break;
 
@@ -84,7 +83,7 @@ static int sglua_dump_table(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
       while (lua_next(L, -1)) { /* table key val  */
         // we need to copy here, as a cast from "Number" to "String"
@@ -190,7 +189,7 @@ void* sglua_checkudata_debug(lua_State* L, int ud, const char* tname)
 
   int has_mt = lua_getmetatable(L, ud);
   XBT_DEBUG("Checking the userdata: has metatable ? %d", has_mt);
-  const void* actual_mt = NULL;
+  const void* actual_mt = nullptr;
   if (has_mt) {
     actual_mt = lua_topointer(L, -1);
     lua_pop(L, 1);
@@ -198,8 +197,8 @@ void* sglua_checkudata_debug(lua_State* L, int ud, const char* tname)
   XBT_DEBUG("Checking the task's metatable: expected %p, found %p", correct_mt, actual_mt);
   sglua_stack_dump(L, "my_checkudata: ");
 
-  if (p == NULL || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2))
-    XBT_ERROR("Error: Userdata is NULL, couldn't find metatable or top of stack does not equal element below it.");
+  if (p == nullptr || not lua_getmetatable(L, ud) || not lua_rawequal(L, -1, -2))
+    XBT_ERROR("Error: Userdata is nullptr, couldn't find metatable or top of stack does not equal element below it.");
   lua_pop(L, 2);
   return p;
 }
@@ -210,10 +209,10 @@ void* sglua_checkudata_debug(lua_State* L, int ud, const char* tname)
  * This function is a valid lua_Writer that writes into a memory buffer passed
  * as userdata.
  *
- * @param L a lua state
- * @param source some data
- * @param sz number of bytes of data
- * @param user_data the memory buffer to write
+ * @param L        a lua state
+ * @param source   some data
+ * @param size     number of bytes of data
+ * @param userdata the memory buffer to write
  */
 int sglua_memory_writer(lua_State* L, const void* source, size_t size,
     void* userdata) {