diff options
author | pixel <pixel> | 2004-07-22 23:38:31 +0000 |
---|---|---|
committer | pixel <pixel> | 2004-07-22 23:38:31 +0000 |
commit | 3dec0df7951ffda61c8da3d3f9bba563c7a49e98 (patch) | |
tree | 9b31175f78dd54d1eabf960d5fff83c2fec381ae /lib | |
parent | 7009ed165a9d093ae0a68331803eda32ecbb2b9e (diff) |
Adding 'printer' feature
Diffstat (limited to 'lib')
-rw-r--r-- | lib/BLua.cc | 6 | ||||
-rw-r--r-- | lib/generic.cc | 43 |
2 files changed, 33 insertions, 16 deletions
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 <lualib.h> @@ -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 <stdio.h> #include <stdarg.h> @@ -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); } |