Reimplemented 'print', channeled it through PrintBuffer
This commit is contained in:
@@ -1,24 +1,33 @@
|
||||
/////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Pretty-print routine.
|
||||
// print, pprint, and tostring
|
||||
//
|
||||
// The pretty-printer can be called from C++ or Lua.
|
||||
// This module implements the heart of the lua 'print', lua 'pprint', and lua
|
||||
// 'tostring' functions. Note that we have to override the lua builtins 'print'
|
||||
// and 'tostring' for two reasons:
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
// * We need to suppress the printing of table addresses, for determinism.
|
||||
// * We need to channel the output to a PrintBuffer in the world model.
|
||||
//
|
||||
// Note that the actual lua 'print' and 'pprint' routines aren't defined in this
|
||||
// module, they're in the World module, because they send their output into the
|
||||
// PrintBuffer of the world model. But all the tricky code to implement 'print'
|
||||
// and 'pprint' are in this module.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PPRINT_HPP
|
||||
#define PPRINT_HPP
|
||||
|
||||
#include "luastack.hpp"
|
||||
|
||||
// Output a simple value to a stream.
|
||||
// Atomic print to a stream.
|
||||
//
|
||||
// If the value is a string, number, boolean, or nil, it is
|
||||
// quoted and output to the stream, and this function returns
|
||||
// true. Otherwise, this function returns false and nothing
|
||||
// is sent to the stream.
|
||||
// This prints an atomic value to a stream. If you give it a table,
|
||||
// it just prints "table". This routine is the heart of the lua
|
||||
// primitives 'print' and 'tostring'.
|
||||
//
|
||||
bool string_quote(LuaStack &LS, LuaSlot val, std::ostream *os);
|
||||
void atomic_print(LuaStack &LS, LuaSlot val, std::ostream *os);
|
||||
|
||||
// Pretty print to a stream.
|
||||
//
|
||||
@@ -30,17 +39,4 @@ bool string_quote(LuaStack &LS, LuaSlot val, std::ostream *os);
|
||||
//
|
||||
void pprint(LuaStack &LS, LuaSlot val, bool indent, std::ostream *os);
|
||||
|
||||
// The following lua interfaces to this code are included:
|
||||
//
|
||||
// pprint(expr, expr, expr...)
|
||||
//
|
||||
// - pretty print the specified expression to stdout.
|
||||
//
|
||||
// string.pprint(expr, indent)
|
||||
//
|
||||
// - pretty print the specified expression, return the result as a string.
|
||||
//
|
||||
int lfn_pprint_pprint(lua_State *L);
|
||||
int lfn_string_pprint(lua_State *L);
|
||||
|
||||
#endif // PPRINT_HPP
|
||||
Reference in New Issue
Block a user