X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dccf1b41e9c7b5a696f01abceaa2779fe65f154f..df078bae24388cc0dd63b2bbafe05897a0dd45f8:/src/bindings/lua/lua_debug.cpp diff --git a/src/bindings/lua/lua_debug.cpp b/src/bindings/lua/lua_debug.cpp index 79b1bc5c06..854e1adb4a 100644 --- a/src/bindings/lua/lua_debug.cpp +++ b/src/bindings/lua/lua_debug.cpp @@ -1,10 +1,9 @@ -/* Copyright (c) 2010-2016. The SimGrid Team. - * All rights reserved. +/* Copyright (c) 2010-2018. 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, @@ -12,10 +11,8 @@ * */ /* SimGrid Lua debug functions */ -extern "C" { #include -} -#include "lua_utils.h" +#include "lua_utils.hpp" #include "xbt.h" XBT_LOG_NEW_DEFAULT_CATEGORY(lua_debug, "Lua bindings (helper functions)"); @@ -40,7 +37,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 +81,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" @@ -172,13 +169,13 @@ void sglua_stack_dump(lua_State* L, const char* msg) } /** - * \brief Like luaL_checkudata, with additional debug logs. + * @brief Like luaL_checkudata, with additional debug logs. * * This function is for debugging purposes only. * - * \param L a lua state - * \param ud index of the userdata to check in the stack - * \param tname key of the metatable of this userdata in the registry + * @param L a lua state + * @param ud index of the userdata to check in the stack + * @param tname key of the metatable of this userdata in the registry */ void* sglua_checkudata_debug(lua_State* L, int ud, const char* tname) { @@ -198,7 +195,7 @@ 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 == nullptr || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2)) + 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; @@ -215,13 +212,12 @@ void* sglua_checkudata_debug(lua_State* L, int ud, const char* tname) * @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) { - - sglua_buffer_t buffer = (sglua_buffer_t) userdata; +int sglua_memory_writer(lua_State* L, const void* source, size_t size, void* userdata) +{ + sglua_buffer_t buffer = static_cast(userdata); while (buffer->capacity < buffer->size + size) { buffer->capacity *= 2; - buffer->data = (char*)xbt_realloc(buffer->data, buffer->capacity); + buffer->data = static_cast(xbt_realloc(buffer->data, buffer->capacity)); } memcpy(buffer->data + buffer->size, source, size); buffer->size += size;