From 3dec0df7951ffda61c8da3d3f9bba563c7a49e98 Mon Sep 17 00:00:00 2001 From: pixel Date: Thu, 22 Jul 2004 23:38:31 +0000 Subject: Adding 'printer' feature --- lib/BLua.cc | 6 +++++- lib/generic.cc | 43 ++++++++++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/BLua.cc b/lib/BLua.cc index 95519a1..cf0caa4 100644 --- a/lib/BLua.cc +++ b/lib/BLua.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: BLua.cc,v 1.18 2004-05-01 11:48:57 pixel Exp $ */ +/* $Id: BLua.cc,v 1.19 2004-07-22 23:38:32 pixel Exp $ */ #include @@ -512,6 +512,10 @@ int Lua::setmetatable(int i) { return lua_setmetatable(L, i); } +int Lua::sethook(lua_Hook func, int mask, int count) { + return lua_sethook(L, func, mask, count); +} + void LuaObject::push(Lua * L) throw (GeneralException) { if (pushed && wantdestruct) { throw GeneralException("Error: object is owned by the LUA script and can not be pushed."); diff --git a/lib/generic.cc b/lib/generic.cc index fb55cc4..f69aba3 100644 --- a/lib/generic.cc +++ b/lib/generic.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: generic.cc,v 1.8 2003-12-04 04:09:02 pixel Exp $ */ +/* $Id: generic.cc,v 1.9 2004-07-22 23:38:32 pixel Exp $ */ #include #include @@ -30,46 +30,59 @@ #endif char verbosity = 0; - -char * heads[] = {"EE", "--", "WW", "II"}; +static char * heads[] = {"EE", "--", "WW", "II"}; +printer_t * printer = 0; void Base::printm(int level, const ugly_string & m, ...) { va_list ap; + bool display = true; if (verbosity < level) { return; } - if (level >= 0) { - fprintf(stderr, "(%s) ", heads[level]); - } + va_start(ap, m); + + if (printer) + display = printer->printm(level, m.p, ap); + + if (display) { + if (level >= 0) { + fprintf(stderr, "(%s) ", heads[level]); + } - va_start(ap, m); #ifdef HAVE_GMP - gmp_vfprintf(stderr, m.p, ap); + gmp_vfprintf(stderr, m.p, ap); #else - vfprintf(stderr, m.p, ap); + vfprintf(stderr, m.p, ap); #endif + } va_end(ap); } void Base::printm(int level, const char * m, ...) { va_list ap; + bool display = true; if (verbosity < level) { return; } - if (level >= 0) { - fprintf(stderr, "(%s) ", heads[level]); - } - va_start(ap, m); + if (printer) + display = printer->printm(level, m, ap); + + if (display) { + if (level >= 0) { + fprintf(stderr, "(%s) ", heads[level]); + } + #ifdef HAVE_GMP - gmp_vfprintf(stderr, m, ap); + gmp_vfprintf(stderr, m, ap); #else - vfprintf(stderr, m, ap); + vfprintf(stderr, m, ap); #endif + } va_end(ap); } -- cgit v1.2.3