[uim-commit] r1618 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Tue Sep 27 13:18:27 PDT 2005
Author: yamaken
Date: 2005-09-27 13:18:25 -0700 (Tue, 27 Sep 2005)
New Revision: 1618
Modified:
branches/r5rs/sigscheme/debug.c
branches/r5rs/sigscheme/operations-siod.c
branches/r5rs/sigscheme/sigscheme.c
branches/r5rs/sigscheme/sigscheme.h
Log:
* sigscheme/sigscheme.h
- (enum ScmDebugCategory): New type
- (SigScm_DebugCategories, SigScm_SetDebugCategories,
SigScm_CategorizedDebug): New function decl
* sigscheme/debug.c
- (debug_mask): New static variable
- (SigScm_DebugCategories, SigScm_SetDebugCategories,
SigScm_CategorizedDebug): New function
* sigscheme/operations-siod.c
- (SCM_DBG_SIOD_V0, SCM_DBG_SIOD_V1, SCM_DBG_SIOD_V2,
SCM_DBG_SIOD_V3, SCM_DBG_SIOD_V4, SCM_DBG_SIOD_V5): New macro
- (sscm_debug_mask_tbl): New static variable
- (SigScm_SetVerboseLevel): Add SigScheme-native debugging
categories configuration
* sigscheme/sigscheme.c
- (SigScm_Initialize_internal): Add initizlizations for the debug
message control
Modified: branches/r5rs/sigscheme/debug.c
===================================================================
--- branches/r5rs/sigscheme/debug.c 2005-09-27 18:14:45 UTC (rev 1617)
+++ branches/r5rs/sigscheme/debug.c 2005-09-27 20:18:25 UTC (rev 1618)
@@ -94,6 +94,7 @@
/*=======================================
Variable Declarations
=======================================*/
+static debug_mask;
#if SCM_USE_SRFI38
static write_ss_context *write_ss_ctx; /* misc info in priting shared structures */
#endif
@@ -119,6 +120,26 @@
/*=======================================
Function Implementations
=======================================*/
+int SigScm_DebugCategories(void)
+{
+ return debug_mask;
+}
+
+void SigScm_SetDebugCategories(int categories)
+{
+ debug_mask = categories;
+}
+
+void SigScm_CategorizedDebug(int category, const char *msg, ...)
+{
+ va_list va;
+
+ va_start(va, msg);
+ if (debug_mask & category)
+ SigScm_Debug(msg, va);
+ va_end(va);
+}
+
void SigScm_Debug(const char *msg, ...)
{
va_list va;
Modified: branches/r5rs/sigscheme/operations-siod.c
===================================================================
--- branches/r5rs/sigscheme/operations-siod.c 2005-09-27 18:14:45 UTC (rev 1617)
+++ branches/r5rs/sigscheme/operations-siod.c 2005-09-27 20:18:25 UTC (rev 1618)
@@ -48,10 +48,33 @@
/*=======================================
File Local Macro Declarations
=======================================*/
+/*
+ * SIOD's verbose-level compatible debug message printing control:
+ * Search 'siod_verbose_level' in slib.c to know further detail.
+ *
+ * Extra control:
+ * v0: suppress all printing even if normal 'write' or 'display'
+ * v1: print each result of repl
+ * v2: print the "> " prompt
+ */
+#define SCM_DBG_SIOD_V0 SCM_DBG_NONE
+#define SCM_DBG_SIOD_V1 (SCM_DBG_ERRMSG | SCM_DBG_BACKTRACE)
+#define SCM_DBG_SIOD_V2 SCM_DBG_SIOD_V1
+#define SCM_DBG_SIOD_V3 (SCM_DBG_SIOD_V2 | SCM_DBG_FILE)
+#define SCM_DBG_SIOD_V4 (SCM_DBG_SIOD_V3 | SCM_DBG_GC)
+#define SCM_DBG_SIOD_V5 (SCM_DBG_SIOD_V4 | SCM_DBG_PARSER)
/*=======================================
Variable Declarations
=======================================*/
+static int sscm_debug_mask_tbl[] = {
+ SCM_DBG_SIOD_V0,
+ SCM_DBG_SIOD_V1,
+ SCM_DBG_SIOD_V2,
+ SCM_DBG_SIOD_V3,
+ SCM_DBG_SIOD_V4,
+ SCM_DBG_SIOD_V5
+};
static long sscm_verbose_level = 0;
/*=======================================
@@ -160,5 +183,12 @@
void SigScm_SetVerboseLevel(long level)
{
+ if (level < 0)
+ SigScm_Error("SigScm_SetVerboseLevel : negative number has given\n");
+
sscm_verbose_level = level;
+
+ if (level > 5)
+ level = 5;
+ SigScm_SetDebugCategories(sscm_debug_mask_tbl[level]);
}
Modified: branches/r5rs/sigscheme/sigscheme.c
===================================================================
--- branches/r5rs/sigscheme/sigscheme.c 2005-09-27 18:14:45 UTC (rev 1617)
+++ branches/r5rs/sigscheme/sigscheme.c 2005-09-27 20:18:25 UTC (rev 1618)
@@ -92,6 +92,8 @@
static void SigScm_Initialize_internal(void)
{
+ SigScm_SetDebugCategories(SCM_DBG_ERRMSG | SCM_DBG_BACKTRACE);
+
/*=======================================================================
Etc Variable Initialization
=======================================================================*/
@@ -435,6 +437,7 @@
Scm_RegisterFuncEvaledList("verbose" , ScmOp_verbose);
/* datas.c */
scm_return_value = SCM_NULL;
+ SigScm_SetVerboseLevel(2);
#endif
}
Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h 2005-09-27 18:14:45 UTC (rev 1617)
+++ branches/r5rs/sigscheme/sigscheme.h 2005-09-27 20:18:25 UTC (rev 1618)
@@ -123,6 +123,23 @@
/* type declaration */
#include "sigschemetype.h"
+enum ScmDebugCategory {
+ SCM_DBG_NONE = 0,
+ SCM_DBG_ERRMSG = 1 << 0, /* the "Error: foo bar" style msgs */
+ SCM_DBG_BACKTRACE = 1 << 1,
+ SCM_DBG_GC = 1 << 2,
+ SCM_DBG_FILE = 1 << 3, /* file loading */
+ SCM_DBG_PARSER = 1 << 4, /* print each parsed expression + misc */
+ SCM_DBG_MACRO = 1 << 5,
+ SCM_DBG_ARGS = 1 << 6, /* number of arguments, type and so on */
+ SCM_DBG_EVAL = 1 << 7, /* evaluation-related things */
+ SCM_DBG_CONTINUATION = 1 << 8,
+ SCM_DBG_EXCEPTION = 1 << 9,
+ SCM_DBG_EXPERIMENTAL = 1 << 10, /* developed but experimental features */
+ SCM_DBG_DEVEL = 1 << 11, /* under development */
+ SCM_DBG_OTHER = 1 << 30 /* all other messages */
+};
+
/*=======================================
Variable Declarations
=======================================*/
@@ -545,6 +562,9 @@
void SigScm_ShowBacktrace(void);
/* debug.c */
+int SigScm_DebugCategories(void);
+void SigScm_SetDebugCategories(int categories);
+void SigScm_CategorizedDebug(int category, const char *msg, ...);
void SigScm_Debug(const char *msg, ...);
void SigScm_Display(ScmObj obj);
void SigScm_WriteToPort(ScmObj port, ScmObj obj);
More information about the uim-commit
mailing list