Files
integration/luprex/core/cpp/pprint.hpp

37 lines
1.3 KiB
C++
Raw Normal View History

//////////////////////////////////////////////////////////////////////////////////
//
// print, pprint, and tostring
//
// 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"
#include <ostream>
// Atomic print to a stream.
2021-09-08 01:32:08 -04:00
//
// This prints an atomic value to a stream. If you give it a table,
2021-12-15 23:03:43 -05:00
// it just prints "<table>". This routine is the heart of the lua
// primitives 'print' and 'tostring'.
2021-09-08 01:32:08 -04:00
//
void atomic_print(LuaStack &LS, LuaSlot val, bool quote, std::ostream *os);
2021-09-08 01:32:08 -04:00
// Pretty print to a stream.
//
void pprint(LuaStack &LS, LuaSlot val, bool indent, std::ostream *os);
#endif // PPRINT_HPP