HCoop
/
clinton
/
bobotpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[project @ 2005-05-31 05:59:57 by unknown_lamer]
[clinton/bobotpp.git]
/
source
/
BotInterp.C
diff --git
a/source/BotInterp.C
b/source/BotInterp.C
index
00e774a
..
815c9bf
100644
(file)
--- a/
source/BotInterp.C
+++ b/
source/BotInterp.C
@@
-35,8
+35,8
@@
extern "C"
BotInterp::BotInterp(Bot *b, String fn)
: bot(b), counter(0)
{
BotInterp::BotInterp(Bot *b, String fn)
: bot(b), counter(0)
{
- logPort = scm_open_file(Utils::str
ing2SCM
(fn),
- Utils::str
ing2SCM
("a"));
+ logPort = scm_open_file(Utils::str
2scm
(fn),
+ Utils::str
2scm
("a"));
scm_gc_protect_object(logPort);
}
scm_gc_protect_object(logPort);
}
@@
-61,11
+61,20
@@
BotInterp::ScriptLog(SCM throw_args)
scm_flush(logPort);
}
scm_flush(logPort);
}
+namespace
+{
+ bool hptr_lt (const Hook* h, const Hook* h1)
+ // Hook Pointer less than
+ // Used to sort the Hooks list
+ { return *h < *h1; }
+}
+
bool
bool
-BotInterp::AddHook(int hooktype, SCM regex, SCM function, int pri, bool fall) {
+BotInterp::AddHook(int hooktype, SCM regex, SCM function, int pri, bool fall,
+ String name) {
if (scm_string_p(regex) == SCM_BOOL_F)
return false;
if (scm_string_p(regex) == SCM_BOOL_F)
return false;
- String rx = Utils::
scm2String(regex).toUpper(
);
+ String rx = Utils::
to_upper (Utils::scm2str (regex)
);
SCM r = scm_make_regexp(regex,
scm_listify (gh_lookup("regexp/icase"),
SCM_UNDEFINED));
SCM r = scm_make_regexp(regex,
scm_listify (gh_lookup("regexp/icase"),
SCM_UNDEFINED));
@@
-74,21
+83,22
@@
BotInterp::AddHook(int hooktype, SCM regex, SCM function, int pri, bool fall) {
// First, we check if an hook doesn't exist yet
std::list<Hook *>::iterator it = hooksMap[hooktype].begin();
std::list<Hook *>::iterator it2 = hooksMap[hooktype].end();
// First, we check if an hook doesn't exist yet
std::list<Hook *>::iterator it = hooksMap[hooktype].begin();
std::list<Hook *>::iterator it2 = hooksMap[hooktype].end();
+
for ( ; it != it2; ++it)
// It exists, we replace it.
for ( ; it != it2; ++it)
// It exists, we replace it.
- if ((*it)->regex_str == rx) {
+ if ((*it)->regex_str == rx
&& (*it)->name == name
) {
scm_gc_unprotect_object((*it)->function);
scm_gc_unprotect_object (r);
(*it)->function = function;
(*it)->priority = pri;
(*it)->fallthru = fall;
scm_gc_unprotect_object((*it)->function);
scm_gc_unprotect_object (r);
(*it)->function = function;
(*it)->priority = pri;
(*it)->fallthru = fall;
- hooksMap[hooktype].sort ();
+ hooksMap[hooktype].sort (
hptr_lt
);
return true;
}
// It does not exist, we create it
hooksMap[hooktype].push_back (new Hook(hooktype, rx, r,
return true;
}
// It does not exist, we create it
hooksMap[hooktype].push_back (new Hook(hooktype, rx, r,
- function, pri, fall));
- hooksMap[hooktype].sort ();
+ function, pri, fall
, name
));
+ hooksMap[hooktype].sort (
hptr_lt
);
return true;
}
return true;
}
@@
-103,7
+113,7
@@
BotInterp::RunHooks(int hooktype, String match, SCM args)
wrapper_data wd;
wd.args = args;
for ( ; it != it2; ++it) {
wrapper_data wd;
wd.args = args;
for ( ; it != it2; ++it) {
- if (scm_regexp_exec((*it)->regex, Utils::str
ing2SCM
(match),
+ if (scm_regexp_exec((*it)->regex, Utils::str
2scm
(match),
SCM_UNDEFINED, SCM_UNDEFINED) != SCM_BOOL_F)
{
wd.func = (*it)->function;
SCM_UNDEFINED, SCM_UNDEFINED) != SCM_BOOL_F)
{
wd.func = (*it)->function;
@@
-153,7
+163,7
@@
BotInterp::RunTimers(int now)
std::list<Timer *>::iterator it = timersList.begin();
std::list<Timer *>::iterator it2 = timersList.end();
std::list<Timer *>::iterator it3;
std::list<Timer *>::iterator it = timersList.begin();
std::list<Timer *>::iterator it2 = timersList.end();
std::list<Timer *>::iterator it3;
- Timer *t;
+
struct wrapper_data wd;
wd.args = scm_listify (SCM_UNDEFINED);
struct wrapper_data wd;
wd.args = scm_listify (SCM_UNDEFINED);