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
* 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
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
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
(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.
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
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
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;
}
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;
public:
BotInterp(Bot *, String);
- void ScriptLog(SCM);
+ SCM ScriptLog();
void Execute(String);
void LoadScript(String);
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)
#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
#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)
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
SCM args;
};
-SCM scm_apply_wrapper(void *);
+SCM lazy_apply_wrapper(void *);
+SCM empty_handler(void *, SCM, SCM);
class Interp {
public:
{
SCM_DEVAL_P = 1;
SCM_RECORD_POSITIONS_P = 1;
+ SCM_BACKTRACE_P = 1;
SCM_RESET_DEBUG_MODE;
}
#endif
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