[project @ 2005-06-28 10:08:45 by unknown_lamer]
authorunknown_lamer <unknown>
Tue, 28 Jun 2005 10:08:45 +0000 (10:08 +0000)
committerunknown_lamer <unknown>
Tue, 28 Jun 2005 10:08:45 +0000 (10:08 +0000)
Merged error handling patch from Dale Smith

ChangeLog
NEWS
bobot++.info
source/BotInterp.C
source/BotInterp.H
source/Interp.C
source/Interp.H
source/Main.C
source/Parser.C

index e76f0e3..52aa3f2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2005-06-28  Clinton Ebadi  <clinton@unknownlamer.org>
 
+       * source/Main.C: Merged error handling patch from dsmith
+
+       * source/Parser.C: Merged error handling
+       patch from dsmith
+
+       * source/Interp.H: Merged error handling patch from dsmith
+
+       * source/Interp.C (lazy_handler): Merged error handling patch from
+       dsmith
+
+       * source/BotInterp.H: Merged error handling patch from dsmith
+
+       * source/BotInterp.C: Merged error handling patch from dsmith
+
        * bobot++.texinfo (Low Level Message Functions): Documented
        bot:send-ctcp-reply
 
@@ -14,7 +28,7 @@
        * source/Interp.C (interp_init_helper): Renamed bot:send-CTCP to
        bot:send-ctcp
 
-       * source/ScriptCommands.H: Uncommended sendCTCPReply prototype
+       * source/ScriptCommands.H: Uncommented sendCTCPReply prototype
 
        * source/ScriptCommands.C (sendCTCP): Convert to use Commands::CTCP
        (sendCTCPReply): Added
diff --git a/NEWS b/NEWS
index eea086b..79ad6fd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,15 +22,18 @@ Version 2.1.8:
       etc.)
   + Message Sending
     * Implemented bot:notice
-  + Misc
-    * Added (bobotpp bot) module that modules may use to gain access
-      to the bobot++ functions
     * bot:msg and bot:say may both send to channels and users (instead
       of bot:msg for users and bot:say for channels)
     * Renamed bot:send-CTCP to bot:send-ctcp
     * Added bot:send-ctcp-reply to send a ctcp-reply
+  + Misc
+    * Added (bobotpp bot) module that modules may use to gain access
+      to the bobot++ functions
   + Debugging
-    * The debugging evaluator is now enabled when --debug is passed to the bot
+    * The debugging evaluator is now enabled when --debug is passed to
+      the bot
+    * Merged error handling patch from Dale Smith. This adds detailed
+      errors and backtraces when --debug is passed to Bobot++.
 - Documentation
   + Merged documentation patch from Dale Smith (thanks)
 - Misc
index 79bcf70..80866fb 100644 (file)
@@ -770,6 +770,13 @@ before using these. If you have no idea what these do, read rfc 2812
      command, and `message' is the message (or arguments) of the
      command. Make sure to `bot:ctcp-quote' the message!
 
+ -- Function: bot:send-ctcp-reply to command message
+     `to' is the target of your CTCP reply, `command' is the CTCP
+     command, and `message' is the message (or arguments) of the
+     command. Make sure to `bot:ctcp-quote' the message!
+
+     This is used to reply to a ctcp that the bot has received.
+
 \1f
 File: bobot++.info,  Node: Misc Scripting Stuff,  Prev: Sending Messages,  Up: Scripting
 
@@ -1095,6 +1102,8 @@ Function Index
                                                               (line   7)
 * bot:send-ctcp:                         Low Level Message Functions.
                                                               (line  13)
+* bot:send-ctcp-reply:                   Low Level Message Functions.
+                                                              (line  18)
 * bot:sent-to-me?:                       Misc Scripting Stuff.
                                                               (line 198)
 * bot:server:                            Misc Scripting Stuff.
@@ -1186,9 +1195,9 @@ Node: Scheme User Levels\7f25525
 Node: Sending Messages\7f26659
 Node: High Level Message Functions\7f27275
 Node: Low Level Message Functions\7f28055
-Node: Misc Scripting Stuff\7f28823
-Node: Concept Index\7f35399
-Node: Function Index\7f35618
-Node: Variable Index\7f45606
+Node: Misc Scripting Stuff\7f29130
+Node: Concept Index\7f35706
+Node: Function Index\7f35925
+Node: Variable Index\7f46056
 \1f
 End Tag Table
index 43724c8..01ba996 100644 (file)
@@ -52,13 +52,10 @@ BotInterp::LoadScript(String filename)
   Interp::LoadScript(bot, filename);
 }
 
-void
-BotInterp::ScriptLog(SCM throw_args)
+SCM
+BotInterp::ScriptLog()
 {
-  scm_display_error_message(SCM_CADR (throw_args),
-                            SCM_CADDR (throw_args),
-                            logPort);
-  scm_flush(logPort);
+  return logPort;
 }
 
 namespace
@@ -117,10 +114,10 @@ BotInterp::RunHooks(int hooktype, String match, SCM args)
                         SCM_UNDEFINED, SCM_UNDEFINED) != SCM_BOOL_F)
       {
        wd.func = (*it)->function;
-       result = gh_catch(SCM_BOOL_T, 
-                         (scm_t_catch_body) scm_apply_wrapper,
-                         static_cast<void *> (&wd), 
-                         (scm_t_catch_handler) Interp::ErrorHandler, 0);
+       result = scm_internal_catch(SCM_BOOL_T, 
+                                   (scm_t_catch_body) lazy_apply_wrapper,
+                                   static_cast<void *> (&wd), 
+                                   (scm_t_catch_handler) empty_handler, 0);
        if (! (*it)->fallthru)
          break;
     }
@@ -170,8 +167,9 @@ BotInterp::RunTimers(int now)
   while (it != it2) {
     if ((*it)->when <= now) {
       wd.func = (*it)->function;
-      gh_catch(SCM_BOOL_T, (scm_t_catch_body) scm_apply_wrapper,
-               (void *)&wd, (scm_t_catch_handler) Interp::ErrorHandler, 0);
+      scm_internal_catch(SCM_BOOL_T,
+                    (scm_t_catch_body) lazy_apply_wrapper, (void *)&wd,
+                    (scm_t_catch_handler) empty_handler, 0);
       scm_gc_unprotect_object(wd.func);
       it3 = it;
       ++it3;
index 7f061ba..85644aa 100644 (file)
@@ -105,7 +105,7 @@ class BotInterp {
 public:
   BotInterp(Bot *, String);
 
-  void ScriptLog(SCM);
+  SCM ScriptLog();
 
   void Execute(String);
   void LoadScript(String);
index 94c5045..1107f57 100644 (file)
@@ -56,6 +56,53 @@ scm_apply_wrapper(void *data)
   return SCM_BOOL_T;
 }
 
+static SCM
+lazy_handler(void *data, SCM tag, SCM throw_args)
+{
+  SCM log_port = Interp::bot->botInterp->ScriptLog();
+  SCM eport = scm_set_current_error_port(log_port);
+
+  scm_handle_by_message_noexit((void *)"bobot++", tag, throw_args);
+  scm_force_output(log_port);
+  scm_set_current_error_port(eport);
+  scm_ithrow(tag, throw_args, 1);
+  return SCM_UNSPECIFIED; /* never returns */
+}
+
+SCM
+empty_handler(void *data, SCM tag, SCM args)
+{
+  return SCM_UNSPECIFIED;
+}
+
+
+SCM
+lazy_apply_wrapper(void *data)
+{
+  return scm_internal_lazy_catch(SCM_BOOL_T,
+                                (scm_t_catch_body) scm_apply_wrapper, data,
+                                (scm_t_catch_handler) lazy_handler, 0);
+}
+
+
+static SCM
+lazy_eval_file(char *filename)
+{
+  return scm_internal_lazy_catch(SCM_BOOL_T,
+                                (scm_t_catch_body) scm_c_primitive_load, filename,
+                                (scm_t_catch_handler) lazy_handler, 0);
+}
+
+static SCM
+lazy_eval_string(char *str)
+{
+  return scm_internal_lazy_catch(SCM_BOOL_T,
+                                (scm_t_catch_body) scm_c_eval_string, str,
+                                (scm_t_catch_handler) lazy_handler, 0);
+}
+
+
+
 #define bot_new_procedure(a, b, c, d, e) scm_c_define_gsubr (a, c, d, e, b); scm_c_export (a, 0)
 #define scm_c_define_gsubr(a, b, c, d, e) scm_c_define_gsubr (a, b, c, d, e); scm_c_export (a, 0)
 #define scm_c_define(a, b) scm_c_define (a, b); scm_c_export (a, 0)
@@ -251,7 +298,9 @@ Interp::Execute(Bot *b, String command)
 #endif
   
   bot = b;
-  gh_eval_str_with_catch (command, ErrorHandler);
+  scm_internal_catch(SCM_BOOL_T,
+                    (scm_t_catch_body) lazy_eval_string, (void *) static_cast<const char *> (command),
+                    (scm_t_catch_handler) empty_handler, 0);
   
 #ifdef MULTITHREAD
   // We release the lock
@@ -259,12 +308,6 @@ Interp::Execute(Bot *b, String command)
 #endif
 }
 
-void load_script_helper (void* file)
-{
-  String filename = *static_cast<String*> (file);
-  scm_c_use_module ("guile-user");
-  gh_eval_file_with_catch(filename, Interp::ErrorHandler);
-}
 
 void
 Interp::LoadScript(Bot *b, String filename)
@@ -274,19 +317,13 @@ Interp::LoadScript(Bot *b, String filename)
   pthread_mutex_lock(&mutex);
 #endif
   bot = b;
-  //scm_c_define_module ("", load_script_helper, &filename);
-  gh_eval_file_with_catch(filename, ErrorHandler);
+  scm_internal_catch(SCM_BOOL_T,
+                    (scm_t_catch_body) lazy_eval_file, (void *)static_cast<const char * >(filename),
+                    (scm_t_catch_handler) empty_handler, 0);
 #ifdef MULTITHREAD
   // We release the lock
   pthread_mutex_unlock(&mutex);
 #endif
 }
 
-SCM
-Interp::ErrorHandler(void *data, SCM tag, SCM throw_args)
-{
-  bot->botInterp->ScriptLog(throw_args);
-  return SCM_BOOL_F;
-}
-
 #endif
index 9cdea09..2708d97 100644 (file)
@@ -38,7 +38,8 @@ struct wrapper_data {
   SCM args;
 };
 
-SCM scm_apply_wrapper(void *);
+SCM lazy_apply_wrapper(void *);
+SCM empty_handler(void *, SCM, SCM);
 
 class Interp {
 public:
index d119a74..6bc48df 100644 (file)
@@ -246,6 +246,7 @@ namespace
       {
        SCM_DEVAL_P = 1;
        SCM_RECORD_POSITIONS_P = 1;
+       SCM_BACKTRACE_P = 1;
        SCM_RESET_DEBUG_MODE;
       }
 #endif
index b8eafa3..813813b 100644 (file)
@@ -1051,7 +1051,8 @@ Parser::parseScriptFunction (ServerConnection * cnx,
   struct wrapper_data wd;
   wd.func = scmFunc;
   wd.args = args_list;
-  gh_catch (SCM_BOOL_T, (scm_t_catch_body) scm_apply_wrapper,
-           (void *) &wd, (scm_t_catch_handler) Interp::ErrorHandler, 0);
+  scm_internal_catch (SCM_BOOL_T,
+                     (scm_t_catch_body) lazy_apply_wrapper, (void *) &wd,
+                     (scm_t_catch_handler) empty_handler, 0);
 }
 #endif