46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
|
|
/////////////////////////////////////////////////////////
|
||
|
|
//
|
||
|
|
// Pretty-print routine.
|
||
|
|
//
|
||
|
|
// The pretty-printer can be called from C++ or Lua.
|
||
|
|
//
|
||
|
|
/////////////////////////////////////////////////////////
|
||
|
|
|
||
|
|
#ifndef PRINT_HPP
|
||
|
|
#define PRINT_HPP
|
||
|
|
|
||
|
|
#include "luastack.hpp"
|
||
|
|
|
||
|
|
// This file provides these functions for lua.
|
||
|
|
//
|
||
|
|
// They direct all output to std::cout
|
||
|
|
//
|
||
|
|
extern "C" {
|
||
|
|
void luai_writestring(const char *s, size_t len);
|
||
|
|
void luai_writeline();
|
||
|
|
}
|
||
|
|
|
||
|
|
// Pretty print to a stream.
|
||
|
|
//
|
||
|
|
// If indent is >=0, the output is indented. If indent<0, then
|
||
|
|
// the output is emitted without newlines or indentation.
|
||
|
|
//
|
||
|
|
// Maxlen specifies the maximum number of characters output. If
|
||
|
|
// this is exceeded, then the printout is truncated.
|
||
|
|
//
|
||
|
|
void pprint(LuaStack &LS, LuaSlot val, int indent, int maxlen, std::ostream *os);
|
||
|
|
|
||
|
|
// The following lua interfaces to this code are included:
|
||
|
|
//
|
||
|
|
// pprint(expr)
|
||
|
|
//
|
||
|
|
// - pretty print the specified expression to stdout.
|
||
|
|
//
|
||
|
|
// string.pprint(expr, indent, maxlen)
|
||
|
|
//
|
||
|
|
// - pretty print the specified expression, return the result as a string.
|
||
|
|
//
|
||
|
|
void pprint_pprint(lua_State *L);
|
||
|
|
void string_pprint(lua_State *L);
|
||
|
|
|
||
|
|
#endif // PRINT_HPP
|