Expose strerror to Lua

develop
lethosor 2015-03-10 16:32:43 -04:00
parent 1591e67bf2
commit 016f67e83f
2 changed files with 7 additions and 0 deletions

@ -1909,6 +1909,10 @@ and are only documented here for completeness:
Lists files/directories in a directory. Lists files/directories in a directory.
Returns: *file_names* or empty table if not found. Identical to ``dfhack.filesystem.listdir(path)``. Returns: *file_names* or empty table if not found. Identical to ``dfhack.filesystem.listdir(path)``.
* ``dfhack.internal.strerror(errno)``
Wraps strerror() - returns a string describing a platform-specific error code
Core interpreter context Core interpreter context
======================== ========================

@ -24,6 +24,7 @@ distribution.
#include "Internal.h" #include "Internal.h"
#include <cstring>
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
@ -2102,11 +2103,13 @@ static void *checkaddr(lua_State *L, int idx, bool allow_null = false)
static uint32_t getImageBase() { return Core::getInstance().p->getBase(); } static uint32_t getImageBase() { return Core::getInstance().p->getBase(); }
static int getRebaseDelta() { return Core::getInstance().vinfo->getRebaseDelta(); } static int getRebaseDelta() { return Core::getInstance().vinfo->getRebaseDelta(); }
static int8_t getModstate() { return Core::getInstance().getModstate(); } static int8_t getModstate() { return Core::getInstance().getModstate(); }
static std::string internal_strerror(int n) { return strerror(n); }
static const LuaWrapper::FunctionReg dfhack_internal_module[] = { static const LuaWrapper::FunctionReg dfhack_internal_module[] = {
WRAP(getImageBase), WRAP(getImageBase),
WRAP(getRebaseDelta), WRAP(getRebaseDelta),
WRAP(getModstate), WRAP(getModstate),
WRAPN(strerror, internal_strerror),
{ NULL, NULL } { NULL, NULL }
}; };