Merge branch 'prettyprint'

This commit is contained in:
Clement Farabet
2013-02-13 20:54:56 -05:00
3 changed files with 20 additions and 2 deletions

View File

@ -1,6 +1,6 @@
SET(src DiskFile.c File.c MemoryFile.c PipeFile.c Storage.c Tensor.c Timer.c utils.c init.c TensorOperator.c TensorMath.c random.c)
SET(luasrc init.lua File.lua Tensor.lua CmdLine.lua Tester.lua test/test.lua)
# Necessary do generate wrapper
ADD_TORCH_WRAP(tensormathwrap TensorMath.lua)
ADD_TORCH_WRAP(randomwrap random.lua)

12
utils.c
View File

@ -57,7 +57,16 @@ int torch_islongargs(lua_State *L, int index)
return 0;
}
static int torch_isatty(lua_State *L)
{
#ifdef LUA_WIN
lua_pushboolean(L, 0);
#else
FILE **fp = (FILE **) luaL_checkudata(L, -1, LUA_FILEHANDLE);
lua_pushboolean(L, isatty(fileno(*fp)));
#endif
return 1;
}
static int torch_lua_tic(lua_State* L)
{
@ -158,6 +167,7 @@ static int torch_setnumthreads(lua_State *L)
static const struct luaL_Reg torch_utils__ [] = {
{"getdefaulttensortype", torch_lua_getdefaulttensortype},
{"isatty", torch_isatty},
{"tic", torch_lua_tic},
{"toc", torch_lua_toc},
{"setnumthreads", torch_setnumthreads},

View File

@ -4,6 +4,14 @@
#include "luaT.h"
#include "TH.h"
#include <lua.h>
#include <lualib.h>
#ifdef LUA_WIN
#else
#include <unistd.h>
#endif
THLongStorage* torch_checklongargs(lua_State *L, int index);
int torch_islongargs(lua_State *L, int index);