summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-12-09 20:54:47 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-12-09 20:54:47 +0000
commit5dcd6833242a88cbf0fdbcfa6a25fbe3bad77426 (patch)
tree2f9431cda59df10bcb6f80e2e5e662beead43e73 /src
parent8d98e80a6b914c6e1708b2ccc5cfd49e0ed43584 (diff)
downloadirssi-5dcd6833242a88cbf0fdbcfa6a25fbe3bad77426.zip
fixes, perl should work correctly now :)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@982 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/perl/common/Channel.xs17
-rw-r--r--src/perl/common/Core.xs16
-rw-r--r--src/perl/common/Ignore.xs27
-rw-r--r--src/perl/common/Log.xs43
-rw-r--r--src/perl/common/Query.xs6
-rw-r--r--src/perl/common/Rawlog.xs20
-rw-r--r--src/perl/common/Server.xs29
-rw-r--r--src/perl/common/Window.xs27
-rw-r--r--src/perl/common/typemap26
-rwxr-xr-xsrc/perl/get-signals.pl12
-rw-r--r--src/perl/irc/Bans.xs16
-rw-r--r--src/perl/irc/Dcc.xs32
-rw-r--r--src/perl/irc/Flood.xs16
-rw-r--r--src/perl/irc/Irc.pm2
-rw-r--r--src/perl/irc/Irc.xs123
-rw-r--r--src/perl/irc/IrcServer.xs27
-rw-r--r--src/perl/irc/Netsplit.xs37
-rw-r--r--src/perl/irc/Notifylist.xs20
-rw-r--r--src/perl/irc/typemap18
-rw-r--r--src/perl/perl-common.c242
-rw-r--r--src/perl/perl-common.h25
-rw-r--r--src/perl/perl.c41
22 files changed, 407 insertions, 415 deletions
diff --git a/src/perl/common/Channel.xs b/src/perl/common/Channel.xs
index 2cd7986b..47e0a37a 100644
--- a/src/perl/common/Channel.xs
+++ b/src/perl/common/Channel.xs
@@ -63,12 +63,6 @@ MODULE = Irssi PACKAGE = Irssi::Channel PREFIX = channel_
#*******************************
void
-init(channel)
- Irssi::Channel channel
-CODE:
- perl_channel_fill_hash(hvref(ST(0)), channel);
-
-void
channel_destroy(channel)
Irssi::Channel channel
@@ -119,14 +113,3 @@ PPCODE:
XPUSHs(sv_2mortal(irssi_bless((NICK_REC *) tmp->data)));
}
g_slist_free(list);
-
-#*******************************
-MODULE = Irssi PACKAGE = Irssi::Nick
-#*******************************
-
-void
-init(nick)
- Irssi::Nick nick
-CODE:
- perl_nick_fill_hash(hvref(ST(0)), nick);
-
diff --git a/src/perl/common/Core.xs b/src/perl/common/Core.xs
index 55732b4f..1fc7fb9d 100644
--- a/src/perl/common/Core.xs
+++ b/src/perl/common/Core.xs
@@ -329,19 +329,3 @@ CODE:
signal = g_strconcat("command ", cmd, NULL);
perl_signal_remove(signal, func);
g_free(signal);
-
-#*******************************
-MODULE = Irssi PACKAGE = Irssi::Command PREFIX = command_
-#*******************************
-
-void
-init(cmd)
- Irssi::Command cmd
-PREINIT:
- HV *hv;
-CODE:
- hv = hvref(ST(0));
- if (hv != NULL) {
- hv_store(hv, "category", 8, new_pv(cmd->category), 0);
- hv_store(hv, "cmd", 3, new_pv(cmd->cmd), 0);
- }
diff --git a/src/perl/common/Ignore.xs b/src/perl/common/Ignore.xs
index aab0db8b..89fb00ba 100644
--- a/src/perl/common/Ignore.xs
+++ b/src/perl/common/Ignore.xs
@@ -41,33 +41,6 @@ MODULE = Irssi PACKAGE = Irssi::Ignore PREFIX = ignore_
#*******************************
void
-init(ignore)
- Irssi::Ignore ignore
-PREINIT:
- HV *hv;
- AV *av;
- char **tmp;
-CODE:
- hv = hvref(ST(0));
- if (hv != NULL) {
- hv_store(hv, "mask", 4, new_pv(ignore->mask), 0);
- hv_store(hv, "servertag", 9, new_pv(ignore->servertag), 0);
- av = newAV();
- for (tmp = ignore->channels; *tmp != NULL; tmp++) {
- av_push(av, new_pv(*tmp));
- }
- hv_store(hv, "channels", 8, newRV_noinc((SV*)av), 0);
- hv_store(hv, "pattern", 7, new_pv(ignore->pattern), 0);
-
- hv_store(hv, "level", 5, newSViv(ignore->level), 0);
- hv_store(hv, "except_level", 12, newSViv(ignore->except_level), 0);
-
- hv_store(hv, "regexp", 6, newSViv(ignore->regexp), 0);
- hv_store(hv, "fullword", 8, newSViv(ignore->fullword), 0);
- XPUSHs(sv_2mortal(newRV_noinc((SV*)hv)));
- }
-
-void
ignore_add_rec(rec)
Irssi::Ignore rec
diff --git a/src/perl/common/Log.xs b/src/perl/common/Log.xs
index fbef4b72..5821ebaa 100644
--- a/src/perl/common/Log.xs
+++ b/src/perl/common/Log.xs
@@ -25,32 +25,6 @@ MODULE = Irssi PACKAGE = Irssi::Log PREFIX = log_
#*******************************
void
-init(log)
- Irssi::Log log
-PREINIT:
- HV *hv, *stash;
- AV *av;
- GSList *tmp;
-CODE:
- hv = hvref(ST(0));
- if (hv != NULL) {
- hv_store(hv, "fname", 5, new_pv(log->fname), 0);
- hv_store(hv, "opened", 6, newSViv(log->opened), 0);
- hv_store(hv, "level", 5, newSViv(log->level), 0);
- hv_store(hv, "last", 4, newSViv(log->last), 0);
- hv_store(hv, "autoopen", 8, newSViv(log->autoopen), 0);
- hv_store(hv, "failed", 6, newSViv(log->failed), 0);
- hv_store(hv, "temp", 4, newSViv(log->temp), 0);
-
- stash = gv_stashpv("Irssi::LogItem", 0);
- av = newAV();
- for (tmp = log->items; tmp != NULL; tmp = tmp->next) {
- av_push(av, sv_2mortal(new_bless(tmp->data, stash)));
- }
- hv_store(hv, "items", 4, newRV_noinc((SV*)av), 0);
- }
-
-void
log_item_add(log, type, name, server)
Irssi::Log log
int type
@@ -89,20 +63,3 @@ log_start_logging(log)
void
log_stop_logging(log)
Irssi::Log log
-
-#*******************************
-MODULE = Irssi PACKAGE = Irssi::LogItem
-#*******************************
-
-void
-init(item)
- Irssi::LogItem item
-PREINIT:
- HV *hv;
-CODE:
- hv = hvref(ST(0));
- if (hv != NULL) {
- hv_store(hv, "type", 4, newSViv(item->type), 0);
- hv_store(hv, "name", 4, new_pv(item->name), 0);
- hv_store(hv, "servertag", 9, new_pv(item->servertag), 0);
- }
diff --git a/src/perl/common/Query.xs b/src/perl/common/Query.xs
index 47758229..135c6877 100644
--- a/src/perl/common/Query.xs
+++ b/src/perl/common/Query.xs
@@ -44,12 +44,6 @@ MODULE = Irssi PACKAGE = Irssi::Query PREFIX = query_
#*******************************
void
-init(query)
- Irssi::Query query
-CODE:
- perl_query_fill_hash(hvref(ST(0)), query);
-
-void
query_destroy(query)
Irssi::Query query
diff --git a/src/perl/common/Rawlog.xs b/src/perl/common/Rawlog.xs
index c9a37d56..34ace267 100644
--- a/src/perl/common/Rawlog.xs
+++ b/src/perl/common/Rawlog.xs
@@ -32,26 +32,6 @@ MODULE = Irssi PACKAGE = Irssi::Rawlog PREFIX = rawlog_
#*******************************
void
-init(rawlog)
- Irssi::Rawlog rawlog
-PREINIT:
- HV *hv;
- AV *av;
- GSList *tmp;
-CODE:
- hv = hvref(ST(0));
- if (hv != NULL) {
- hv_store(hv, "logging", 7, newSViv(rawlog->logging), 0);
- hv_store(hv, "nlines", 6, newSViv(rawlog->nlines), 0);
-
- av = newAV();
- for (tmp = rawlog->lines; tmp != NULL; tmp = tmp->next) {
- av_push(av, new_pv(tmp->data));
- }
- hv_store(hv, "lines", 5, newRV_noinc((SV*)av), 0);
- }
-
-void
rawlog_destroy(rawlog)
Irssi::Rawlog rawlog
diff --git a/src/perl/common/Server.xs b/src/perl/common/Server.xs
index 3ae1142b..aebc8e43 100644
--- a/src/perl/common/Server.xs
+++ b/src/perl/common/Server.xs
@@ -39,12 +39,6 @@ server_find_chatnet(chatnet)
MODULE = Irssi PACKAGE = Irssi::Server PREFIX = server_
#*******************************
-void
-init(server)
- Irssi::Server server
-CODE:
- perl_server_fill_hash(hvref(ST(0)), server);
-
Irssi::Server
server_connect(conn)
Irssi::Connect conn
@@ -140,29 +134,6 @@ CODE:
MODULE = Irssi PACKAGE = Irssi::Connect PREFIX = server_
#*******************************
-void
-init(conn)
- Irssi::Connect conn
-CODE:
- perl_connect_fill_hash(hvref(ST(0)), conn);
-
Irssi::Server
server_connect(conn)
Irssi::Connect conn
-
-#*******************************
-MODULE = Irssi PACKAGE = Irssi::Reconnect
-#*******************************
-
-void
-init(reconnect)
- Irssi::Reconnect reconnect
-PREINIT:
- HV *hv;
-CODE:
- hv = hvref(ST(0));
- if (hv != NULL) {
- perl_reconnect_fill_hash(hv, reconnect->conn);
- hv_store(hv, "tag", 3, newSViv(reconnect->tag), 0);
- hv_store(hv, "next_connect", 12, newSViv(reconnect->next_connect), 0);
- }
diff --git a/src/perl/common/Window.xs b/src/perl/common/Window.xs
index f1b5437e..8d7b31b3 100644
--- a/src/perl/common/Window.xs
+++ b/src/perl/common/Window.xs
@@ -105,8 +105,8 @@ void
print(server, channel, str, level)
Irssi::Server server
char *channel
- int level
char *str
+ int level
CODE:
printtext(server, channel, level, str);
@@ -132,31 +132,6 @@ MODULE = Irssi PACKAGE = Irssi::Window PREFIX=window_
#*******************************
void
-init(window)
- Irssi::Window window
-PREINIT:
- HV *hv;
-CODE:
- hv = hvref(ST(0));
- if (hv != NULL) {
- hv_store(hv, "refnum", 6, newSViv(window->refnum), 0);
- hv_store(hv, "name", 4, new_pv(window->name), 0);
-
- if (window->active)
- hv_store(hv, "active", 6, irssi_bless(window->active), 0);
- if (window->active_server)
- hv_store(hv, "active_server", 13, irssi_bless(window->active_server), 0);
-
- hv_store(hv, "lines", 5, newSViv(window->lines), 0);
-
- hv_store(hv, "level", 5, newSViv(window->level), 0);
- hv_store(hv, "new_data", 8, newSViv(window->new_data), 0);
- hv_store(hv, "last_color", 10, newSViv(window->last_color), 0);
- hv_store(hv, "last_timestamp", 14, newSViv(window->last_timestamp), 0);
- hv_store(hv, "last_line", 9, newSViv(window->last_line), 0);
- }
-
-void
items(window)
Irssi::Window window
PREINIT:
diff --git a/src/perl/common/typemap b/src/perl/common/typemap
index 7b90681d..76bcd17d 100644
--- a/src/perl/common/typemap
+++ b/src/perl/common/typemap
@@ -2,19 +2,19 @@ TYPEMAP
Irssi::Chatnet T_IrssiObj
Irssi::Server T_IrssiObj
Irssi::Connect T_IrssiObj
-Irssi::Reconnect T_PTROBJ
+Irssi::Reconnect T_PlainObj
Irssi::Channel T_IrssiObj
Irssi::Query T_IrssiObj
-Irssi::Command T_PTROBJ
+Irssi::Command T_PlainObj
Irssi::Nick T_IrssiObj
-Irssi::Ignore T_PTROBJ
-Irssi::Log T_PTROBJ
-Irssi::LogItem T_PTROBJ
-Irssi::Rawlog T_PTROBJ
-Irssi::Module T_PTROBJ
-Irssi::Theme T_PTROBJ
-Irssi::Keyinfo T_PTROBJ
-Irssi::Window T_PTROBJ
+Irssi::Ignore T_PlainObj
+Irssi::Log T_PlainObj
+Irssi::LogItem T_PlainObj
+Irssi::Rawlog T_PlainObj
+Irssi::Module T_PlainObj
+Irssi::Theme T_PlainObj
+Irssi::Keyinfo T_PlainObj
+Irssi::Window T_PlainObj
Irssi::Windowitem T_IrssiObj
INPUT
@@ -22,8 +22,14 @@ INPUT
T_IrssiObj
$var = irssi_ref_object($arg)
+T_PlainObj
+ $var = irssi_ref_object($arg)
+
OUTPUT
T_IrssiObj
$arg = irssi_bless((SERVER_REC *)$var);
+T_PlainObj
+ $arg = irssi_bless_plain(\"$type\", $var);
+
diff --git a/src/perl/get-signals.pl b/src/perl/get-signals.pl
index 65355d3d..17a60902 100755
--- a/src/perl/get-signals.pl
+++ b/src/perl/get-signals.pl
@@ -31,14 +31,14 @@ while (<STDIN>) {
s/MODULE_REC[^,]*/Irssi::Module/g;
# irc
- s/BAN_REC[^,]*/Irssi::Ban/g;
- s/NETSPLIT_REC[^,]*/Irssi::Netsplit/g;
- s/NETSPLIT_SERVER_REC[^,]*/Irssi::Netsplitserver/g;
+ s/BAN_REC[^,]*/Irssi::Irc::Ban/g;
+ s/NETSPLIT_REC[^,]*/Irssi::Irc::Netsplit/g;
+ s/NETSPLIT_SERVER_REC[^,]*/Irssi::Irc::Netsplitserver/g;
# irc modules
- s/DCC_REC[^,]*/Irssi::Dcc/g;
- s/AUTOIGNORE_REC[^,]*/Irssi::Autoignore/g;
- s/NOTIFYLIST_REC[^,]*/Irssi::Notifylist/g;
+ s/DCC_REC[^,]*/Irssi::Irc::Dcc/g;
+ s/AUTOIGNORE_REC[^,]*/Irssi::Irc::Autoignore/g;
+ s/NOTIFYLIST_REC[^,]*/Irssi::Irc::Notifylist/g;
# fe-common
s/THEME_REC[^,]*/Irssi::Theme/g;
diff --git a/src/perl/irc/Bans.xs b/src/perl/irc/Bans.xs
index c89ff4c5..5412018d 100644
--- a/src/perl/irc/Bans.xs
+++ b/src/perl/irc/Bans.xs
@@ -22,19 +22,3 @@ void
ban_remove(channel, ban)
Irssi::Irc::Channel channel
char *ban
-
-#*******************************
-MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Ban
-#*******************************
-
-void
-init(ban)
- Irssi::Irc::Ban ban
-PREINIT:
- HV *hv;
-PPCODE:
- hv = newHV();
- hv_store(hv, "ban", 3, new_pv(ban->ban), 0);
- hv_store(hv, "setby", 5, new_pv(ban->setby), 0);
- hv_store(hv, "time", 4, newSViv(ban->time), 0);
- XPUSHs(sv_2mortal(newRV_noinc((SV*)hv)));
diff --git a/src/perl/irc/Dcc.xs b/src/perl/irc/Dcc.xs
index 0bbd1166..4a68f4e1 100644
--- a/src/perl/irc/Dcc.xs
+++ b/src/perl/irc/Dcc.xs
@@ -46,35 +46,3 @@ void
dcc_chat_send(dcc, data)
Irssi::Irc::Dcc dcc
char *data
-
-void
-init(dcc)
- Irssi::Irc::Dcc dcc
-PREINIT:
- HV *hv, *stash;
-PPCODE:
- hv = newHV();
- hv_store(hv, "type", 4, new_pv((char *) dcc_type2str(dcc->type)), 0);
- hv_store(hv, "created", 7, newSViv(dcc->created), 0);
-
- hv_store(hv, "server", 6, irssi_bless(dcc->server), 0);
- hv_store(hv, "nick", 4, new_pv(dcc->nick), 0);
-
- stash = gv_stashpv("Irssi::Irc::Dcc", 0);
- hv_store(hv, "chat", 4, new_bless(dcc->chat, stash), 0);
-
- hv_store(hv, "ircnet", 6, new_pv(dcc->ircnet), 0);
- hv_store(hv, "mynick", 6, new_pv(dcc->mynick), 0);
-
- hv_store(hv, "arg", 3, new_pv(dcc->arg), 0);
- hv_store(hv, "file", 4, new_pv(dcc->file), 0);
-
- hv_store(hv, "addr", 4, new_pv(dcc->addrstr), 0);
- hv_store(hv, "port", 4, newSViv(dcc->port), 0);
-
- hv_store(hv, "size", 4, newSViv(dcc->size), 0);
- hv_store(hv, "transfd", 7, newSViv(dcc->transfd), 0);
- hv_store(hv, "skipped", 7, newSViv(dcc->skipped), 0);
- hv_store(hv, "starttime", 9, newSViv(dcc->starttime), 0);
- XPUSHs(sv_2mortal(newRV_noinc((SV*)hv)));
-
diff --git a/src/perl/irc/Flood.xs b/src/perl/irc/Flood.xs
index d6b70672..5a92e442 100644
--- a/src/perl/irc/Flood.xs
+++ b/src/perl/irc/Flood.xs
@@ -11,19 +11,3 @@ autoignore_remove(server, mask, level)
Irssi::Irc::Server server
char *mask
int level
-
-#*******************************
-MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Autoignore
-#*******************************
-
-void
-init(ai)
- Irssi::Irc::Autoignore ai
-PREINIT:
- HV *hv;
-PPCODE:
- hv = newHV();
- hv_store(hv, "nick", 4, new_pv(ai->nick), 0);
- hv_store(hv, "timeleft", 8, newSViv(ai->timeleft), 0);
- hv_store(hv, "level", 5, newSViv(ai->level), 0);
- XPUSHs(sv_2mortal(newRV_noinc((SV*)hv)));
diff --git a/src/perl/irc/Irc.pm b/src/perl/irc/Irc.pm
index a7c77742..ee2d034a 100644
--- a/src/perl/irc/Irc.pm
+++ b/src/perl/irc/Irc.pm
@@ -18,5 +18,7 @@ require DynaLoader;
bootstrap Irssi::Irc $VERSION;
+Irssi::Irc::init();
+
1;
diff --git a/src/perl/irc/Irc.xs b/src/perl/irc/Irc.xs
index f70e9a22..58c417aa 100644
--- a/src/perl/irc/Irc.xs
+++ b/src/perl/irc/Irc.xs
@@ -1,9 +1,132 @@
#include "module.h"
+static void perl_irc_connect_fill_hash(HV *hv, IRC_SERVER_CONNECT_REC *conn)
+{
+ perl_connect_fill_hash(hv, (SERVER_CONNECT_REC *) conn);
+ hv_store(hv, "alternate_nick", 14, new_pv(conn->alternate_nick), 0);
+}
+
+static void perl_irc_server_fill_hash(HV *hv, IRC_SERVER_REC *server)
+{
+ perl_server_fill_hash(hv, server);
+
+ hv_store(hv, "real_address", 12, new_pv(server->real_address), 0);
+ hv_store(hv, "usermode", 8, new_pv(server->usermode), 0);
+ hv_store(hv, "userhost", 8, new_pv(server->userhost), 0);
+}
+
+static void perl_ban_fill_hash(HV *hv, BAN_REC *ban)
+{
+ hv_store(hv, "ban", 3, new_pv(ban->ban), 0);
+ hv_store(hv, "setby", 5, new_pv(ban->setby), 0);
+ hv_store(hv, "time", 4, newSViv(ban->time), 0);
+}
+
+static void perl_dcc_fill_hash(HV *hv, DCC_REC *dcc)
+{
+ HV *stash;
+
+ hv_store(hv, "type", 4, new_pv((char *) dcc_type2str(dcc->type)), 0);
+ hv_store(hv, "created", 7, newSViv(dcc->created), 0);
+
+ hv_store(hv, "server", 6, irssi_bless(dcc->server), 0);
+ hv_store(hv, "nick", 4, new_pv(dcc->nick), 0);
+
+ stash = gv_stashpv("Irssi::Irc::Dcc", 0);
+ hv_store(hv, "chat", 4, new_bless(dcc->chat, stash), 0);
+
+ hv_store(hv, "ircnet", 6, new_pv(dcc->ircnet), 0);
+ hv_store(hv, "mynick", 6, new_pv(dcc->mynick), 0);
+
+ hv_store(hv, "arg", 3, new_pv(dcc->arg), 0);
+ hv_store(hv, "file", 4, new_pv(dcc->file), 0);
+
+ hv_store(hv, "addr", 4, new_pv(dcc->addrstr), 0);
+ hv_store(hv, "port", 4, newSViv(dcc->port), 0);
+
+ hv_store(hv, "size", 4, newSViv(dcc->size), 0);
+ hv_store(hv, "transfd", 7, newSViv(dcc->transfd), 0);
+ hv_store(hv, "skipped", 7, newSViv(dcc->skipped), 0);
+ hv_store(hv, "starttime", 9, newSViv(dcc->starttime), 0);
+}
+
+static void perl_netsplit_fill_hash(HV *hv, NETSPLIT_REC *netsplit)
+{
+ HV *stash;
+
+ hv_store(hv, "nick", 4, new_pv(netsplit->nick), 0);
+ hv_store(hv, "address", 7, new_pv(netsplit->address), 0);
+ hv_store(hv, "destroy", 7, newSViv(netsplit->destroy), 0);
+
+ stash = gv_stashpv("Irssi::Irc::Netsplitserver", 0);
+ hv_store(hv, "server", 6, new_bless(netsplit->server, stash), 0);
+ /*FIXME: add GSList *channels;*/
+}
+
+static void perl_netsplit_server_fill_hash(HV *hv, NETSPLIT_SERVER_REC *rec)
+{
+ hv_store(hv, "server", 6, new_pv(rec->server), 0);
+ hv_store(hv, "destserver", 10, new_pv(rec->destserver), 0);
+ hv_store(hv, "count", 5, newSViv(rec->count), 0);
+}
+
+static void perl_autoignore_fill_hash(HV *hv, AUTOIGNORE_REC *ai)
+{
+ hv_store(hv, "nick", 4, new_pv(ai->nick), 0);
+ hv_store(hv, "timeleft", 8, newSViv(ai->timeleft), 0);
+ hv_store(hv, "level", 5, newSViv(ai->level), 0);
+}
+
+static void perl_notifylist_fill_hash(HV *hv, NOTIFYLIST_REC *notify)
+{
+ AV *av;
+ char **tmp;
+
+ hv_store(hv, "mask", 4, new_pv(notify->mask), 0);
+ hv_store(hv, "away_check", 10, newSViv(notify->away_check), 0);
+ hv_store(hv, "idle_check_time", 15, newSViv(notify->idle_check_time), 0);
+
+ av = newAV();
+ for (tmp = notify->ircnets; *tmp != NULL; tmp++) {
+ av_push(av, new_pv(*tmp));
+ }
+ hv_store(hv, "ircnets", 7, newRV_noinc((SV*)av), 0);
+}
+
+static PLAIN_OBJECT_INIT_REC irc_plains[] = {
+ { "Irssi::Irc::Ban", (PERL_OBJECT_FUNC) perl_ban_fill_hash },
+ { "Irssi::Irc::Dcc", (PERL_OBJECT_FUNC) perl_dcc_fill_hash },
+ { "Irssi::Irc::Netsplit", (PERL_OBJECT_FUNC) perl_netsplit_fill_hash },
+ { "Irssi::Irc::Netsplitserver", (PERL_OBJECT_FUNC) perl_netsplit_server_fill_hash },
+ { "Irssi::Irc::Autoignore", (PERL_OBJECT_FUNC) perl_autoignore_fill_hash },
+ { "Irssi::Irc::Notifylist", (PERL_OBJECT_FUNC) perl_notifylist_fill_hash },
+
+ { NULL, NULL }
+};
+
MODULE = Irssi::Irc PACKAGE = Irssi::Irc
PROTOTYPES: ENABLE
+void
+init()
+PREINIT:
+ static int initialized = FALSE;
+ int chat_type;
+CODE:
+ if (initialized) return;
+ initialized = TRUE;
+
+ chat_type = chat_protocol_lookup("IRC");
+
+ irssi_add_object(module_get_uniq_id("SERVER CONNECT", 0),
+ chat_type, "Irssi::Irc::Connect",
+ (PERL_OBJECT_FUNC) perl_irc_connect_fill_hash);
+ irssi_add_object(module_get_uniq_id("SERVER", 0),
+ chat_type, "Irssi::Irc::Server",
+ (PERL_OBJECT_FUNC) perl_irc_server_fill_hash);
+ irssi_add_plains(irc_plains);
+
INCLUDE: Bans.xs
INCLUDE: IrcServer.xs
INCLUDE: IrcChannel.xs
diff --git a/src/perl/irc/IrcServer.xs b/src/perl/irc/IrcServer.xs
index c39abaa4..9ee76c2f 100644
--- a/src/perl/irc/IrcServer.xs
+++ b/src/perl/irc/IrcServer.xs
@@ -27,36 +27,9 @@ send_raw_split(server, cmd, nickarg, max_nicks)
CODE:
irc_send_cmd_split(server, cmd, nickarg, max_nicks);
-void
-init(server)
- Irssi::Irc::Server server
-PREINIT:
- HV *hv;
-CODE:
- hv = hvref(ST(0));
- if (hv != NULL) {
- perl_server_fill_hash(hv, server);
-
- hv_store(hv, "real_address", 12, new_pv(server->real_address), 0);
- hv_store(hv, "usermode", 8, new_pv(server->usermode), 0);
- hv_store(hv, "userhost", 8, new_pv(server->userhost), 0);
- }
-
MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Connect PREFIX = irc_server_
Irssi::Irc::Server
irc_server_connect(conn)
Irssi::Irc::Connect conn
-
-void
-init(conn)
- Irssi::Irc::Connect conn
-PREINIT:
- HV *hv;
-CODE:
- hv = hvref(ST(0));
- if (hv != NULL) {
- perl_connect_fill_hash(hv, conn);
- hv_store(hv, "alternate_nick", 14, new_pv(conn->alternate_nick), 0);
- }
diff --git a/src/perl/irc/Netsplit.xs b/src/perl/irc/Netsplit.xs
index a7669b43..c6d7c6e8 100644
--- a/src/perl/irc/Netsplit.xs
+++ b/src/perl/irc/Netsplit.xs
@@ -12,40 +12,3 @@ netsplit_find_channel(server, nick, address, channel)
char *nick
char *address
char *channel
-
-
-#*******************************
-MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Netsplit
-#*******************************
-
-void
-init(netsplit)
- Irssi::Irc::Netsplit netsplit
-PREINIT:
- HV *hv, *stash;
-PPCODE:
- hv = newHV();
- hv_store(hv, "nick", 4, new_pv(netsplit->nick), 0);
- hv_store(hv, "address", 7, new_pv(netsplit->address), 0);
- hv_store(hv, "destroy", 7, newSViv(netsplit->destroy), 0);
-
- stash = gv_stashpv("Irssi::Irc::Netsplitserver", 0);
- hv_store(hv, "server", 6, new_bless(netsplit->server, stash), 0);
- /*FIXME: add GSList *channels;*/
- XPUSHs(sv_2mortal(newRV_noinc((SV*)hv)));
-
-#*******************************
-MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Netsplitserver
-#*******************************
-
-void
-init(rec)
- Irssi::Irc::Netsplitserver rec
-PREINIT:
- HV *hv;
-PPCODE:
- hv = newHV();
- hv_store(hv, "server", 6, new_pv(rec->server), 0);
- hv_store(hv, "destserver", 10, new_pv(rec->destserver), 0);
- hv_store(hv, "count", 5, newSViv(rec->count), 0);
- XPUSHs(sv_2mortal(newRV_noinc((SV*)hv)));
diff --git a/src/perl/irc/Notifylist.xs b/src/perl/irc/Notifylist.xs
index 3ef75c04..2f830639 100644
--- a/src/perl/irc/Notifylist.xs
+++ b/src/perl/irc/Notifylist.xs
@@ -45,26 +45,6 @@ notifylist_ison_server(server, nick)
MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Notifylist PREFIX = notifylist_
#*******************************
-void
-init(notify)
- Irssi::Irc::Notifylist notify
-PREINIT:
- HV *hv;
- AV *av;
- char **tmp;
-PPCODE:
- hv = newHV();
- hv_store(hv, "mask", 4, new_pv(notify->mask), 0);
- hv_store(hv, "away_check", 10, newSViv(notify->away_check), 0);
- hv_store(hv, "idle_check_time", 15, newSViv(notify->idle_check_time), 0);
-
- av = newAV();
- for (tmp = notify->ircnets; *tmp != NULL; tmp++) {
- av_push(av, new_pv(*tmp));
- }
- hv_store(hv, "ircnets", 7, newRV_noinc((SV*)av), 0);
- XPUSHs(sv_2mortal(newRV_noinc((SV*)hv)));
-
int
notifylist_ircnets_match(rec, ircnet)
Irssi::Irc::Notifylist rec
diff --git a/src/perl/irc/typemap b/src/perl/irc/typemap
index 8bec8f9f..928eceb6 100644
--- a/src/perl/irc/typemap
+++ b/src/perl/irc/typemap
@@ -5,20 +5,26 @@ Irssi::Irc::Channel T_IrssiObj
Irssi::Irc::Query T_IrssiObj
Irssi::Irc::Nick T_IrssiObj
-Irssi::Irc::Ban T_PTROBJ
-Irssi::Irc::Dcc T_PTROBJ
-Irssi::Irc::Netsplit T_PTROBJ
-Irssi::Irc::Netsplitserver T_PTROBJ
-Irssi::Irc::Autoignore T_PTROBJ
-Irssi::Irc::Notifylist T_PTROBJ
+Irssi::Irc::Ban T_PlainObj
+Irssi::Irc::Dcc T_PlainObj
+Irssi::Irc::Netsplit T_PlainObj
+Irssi::Irc::Netsplitserver T_PlainObj
+Irssi::Irc::Autoignore T_PlainObj
+Irssi::Irc::Notifylist T_PlainObj
INPUT
T_IrssiObj
$var = irssi_ref_object($arg)
+T_PlainObj
+ $var = irssi_ref_object($arg)
+
OUTPUT
T_IrssiObj
$arg = irssi_bless((SERVER_REC *)$var);
+T_PlainObj
+ $arg = irssi_bless_plain(\"$type\", $var);
+
diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c
index df4fd222..b81a95a5 100644
--- a/src/perl/perl-common.c
+++ b/src/perl/perl-common.c
@@ -32,6 +32,12 @@
#include "signals.h"
#include "settings.h"
+#include "commands.h"
+#include "ignore.h"
+#include "log.h"
+#include "rawlog.h"
+#include "servers-reconnect.h"
+
#include "chat-protocols.h"
#include "servers.h"
#include "channels.h"
@@ -43,7 +49,12 @@
#include "fe-common/core/formats.h"
#include "fe-common/core/printtext.h"
-static GHashTable *perl_stashes;
+typedef struct {
+ char *stash;
+ PERL_OBJECT_FUNC fill_func;
+} PERL_OBJECT_REC;
+
+static GHashTable *iobject_stashes, *plain_stashes;
/* returns the package who called us */
char *perl_get_package(void)
@@ -52,46 +63,35 @@ char *perl_get_package(void)
return SvPV(perl_eval_pv("caller", TRUE), n_a);
}
-static void object_fill_values(SV *sv, const char *stash)
+SV *irssi_bless_iobject(int type, int chat_type, void *object)
{
- dSP;
- char str[100];
-
- ENTER;
- SAVETMPS;
+ PERL_OBJECT_REC *rec;
+ HV *stash, *hv;
- PUSHMARK(SP);
- XPUSHs(sv_mortalcopy(sv));
- PUTBACK;
+ rec = g_hash_table_lookup(iobject_stashes,
+ GINT_TO_POINTER(type | (chat_type << 24)));
+ g_return_val_if_fail(rec != NULL, newSViv(GPOINTER_TO_INT(object)));
- g_snprintf(str, sizeof(str), "%s::init", stash);
- perl_call_method(str, G_DISCARD);
- SPAGAIN;
+ stash = gv_stashpv(rec->stash, 1);
- PUTBACK;
- FREETMPS;
- LEAVE;
+ hv = newHV();
+ hv_store(hv, "_irssi", 6, newSViv(GPOINTER_TO_INT(object)), 0);
+ rec->fill_func(hv, object);
+ return sv_bless(newRV_noinc((SV*)hv), stash);
}
-SV *irssi_bless_object(int type, int chat_type, void *object)
+SV *irssi_bless_plain(const char *stash, void *object)
{
- char *str;
- HV *stash, *hv;
- SV *sv;
-
- str = g_hash_table_lookup(perl_stashes,
- GINT_TO_POINTER(type | (chat_type << 24)));
- g_return_val_if_fail(str != NULL, newSViv(GPOINTER_TO_INT(object)));
+ PERL_OBJECT_FUNC fill_func;
+ HV *hv;
- stash = gv_stashpv(str, 1);
+ fill_func = g_hash_table_lookup(plain_stashes, stash);
hv = newHV();
hv_store(hv, "_irssi", 6, newSViv(GPOINTER_TO_INT(object)), 0);
-
- sv = sv_bless(newRV_noinc((SV*)hv), stash);
- object_fill_values(sv, str);
- return sv;
-
+ if (fill_func != NULL)
+ fill_func(hv, object);
+ return sv_bless(newRV_noinc((SV*)hv), gv_stashpv(stash, 1));
}
void *irssi_ref_object(SV *o)
@@ -109,11 +109,34 @@ void *irssi_ref_object(SV *o)
return GINT_TO_POINTER(SvIV(*sv));
}
-void irssi_add_object(int type, int chat_type, const char *stash)
+void irssi_add_object(int type, int chat_type, const char *stash,
+ PERL_OBJECT_FUNC func)
+{
+ PERL_OBJECT_REC *rec;
+ void *hash;
+
+ hash = GINT_TO_POINTER(type | (chat_type << 24));
+ rec = g_hash_table_lookup(iobject_stashes, hash);
+ if (rec == NULL) {
+ rec = g_new(PERL_OBJECT_REC, 1);
+ rec->stash = g_strdup(stash);
+ g_hash_table_insert(iobject_stashes, hash, rec);
+ }
+ rec->fill_func = func;
+}
+
+void irssi_add_plain(const char *stash, PERL_OBJECT_FUNC func)
+{
+ if (g_hash_table_lookup(plain_stashes, stash) == NULL)
+ g_hash_table_insert(plain_stashes, g_strdup(stash), func);
+}
+
+void irssi_add_plains(PLAIN_OBJECT_INIT_REC *objects)
{
- g_hash_table_insert(perl_stashes,
- GINT_TO_POINTER(type | (chat_type << 24)),
- g_strdup(stash));
+ while (objects->name != NULL) {
+ irssi_add_plain(objects->name, objects->fill_func);
+ objects++;
+ }
}
void perl_connect_fill_hash(HV *hv, SERVER_CONNECT_REC *conn)
@@ -262,6 +285,103 @@ void perl_nick_fill_hash(HV *hv, NICK_REC *nick)
hv_store(hv, "voice", 5, newSViv(nick->voice), 0);
}
+void perl_command_fill_hash(HV *hv, COMMAND_REC *cmd)
+{
+ hv_store(hv, "category", 8, new_pv(cmd->category), 0);
+ hv_store(hv, "cmd", 3, new_pv(cmd->cmd), 0);
+}
+
+void perl_ignore_fill_hash(HV *hv, IGNORE_REC *ignore)
+{
+ AV *av;
+ char **tmp;
+
+ hv_store(hv, "mask", 4, new_pv(ignore->mask), 0);
+ hv_store(hv, "servertag", 9, new_pv(ignore->servertag), 0);
+ av = newAV();
+ for (tmp = ignore->channels; *tmp != NULL; tmp++) {
+ av_push(av, new_pv(*tmp));
+ }
+ hv_store(hv, "channels", 8, newRV_noinc((SV*)av), 0);
+ hv_store(hv, "pattern", 7, new_pv(ignore->pattern), 0);
+
+ hv_store(hv, "level", 5, newSViv(ignore->level), 0);
+ hv_store(hv, "except_level", 12, newSViv(ignore->except_level), 0);
+
+ hv_store(hv, "regexp", 6, newSViv(ignore->regexp), 0);
+ hv_store(hv, "fullword", 8, newSViv(ignore->fullword), 0);
+}
+
+void perl_log_fill_hash(HV *hv, LOG_REC *log)
+{
+ HV *stash;
+ AV *av;
+ GSList *tmp;
+
+ hv_store(hv, "fname", 5, new_pv(log->fname), 0);
+ hv_store(hv, "opened", 6, newSViv(log->opened), 0);
+ hv_store(hv, "level", 5, newSViv(log->level), 0);
+ hv_store(hv, "last", 4, newSViv(log->last), 0);
+ hv_store(hv, "autoopen", 8, newSViv(log->autoopen), 0);
+ hv_store(hv, "failed", 6, newSViv(log->failed), 0);
+ hv_store(hv, "temp", 4, newSViv(log->temp), 0);
+
+ stash = gv_stashpv("Irssi::LogItem", 0);
+ av = newAV();
+ for (tmp = log->items; tmp != NULL; tmp = tmp->next) {
+ av_push(av, sv_2mortal(new_bless(tmp->data, stash)));
+ }
+ hv_store(hv, "items", 4, newRV_noinc((SV*)av), 0);
+}
+
+void perl_log_item_fill_hash(HV *hv, LOG_ITEM_REC *item)
+{
+ hv_store(hv, "type", 4, newSViv(item->type), 0);
+ hv_store(hv, "name", 4, new_pv(item->name), 0);
+ hv_store(hv, "servertag", 9, new_pv(item->servertag), 0);
+}
+
+void perl_rawlog_fill_hash(HV *hv, RAWLOG_REC *rawlog)
+{
+ AV *av;
+ GSList *tmp;
+
+ hv_store(hv, "logging", 7, newSViv(rawlog->logging), 0);
+ hv_store(hv, "nlines", 6, newSViv(rawlog->nlines), 0);
+
+ av = newAV();
+ for (tmp = rawlog->lines; tmp != NULL; tmp = tmp->next) {
+ av_push(av, new_pv(tmp->data));
+ }
+ hv_store(hv, "lines", 5, newRV_noinc((SV*)av), 0);
+}
+
+void perl_reconnect_fill_hash(HV *hv, RECONNECT_REC *reconnect)
+{
+ perl_connect_fill_hash(hv, reconnect->conn);
+ hv_store(hv, "tag", 3, newSViv(reconnect->tag), 0);
+ hv_store(hv, "next_connect", 12, newSViv(reconnect->next_connect), 0);
+}
+
+void perl_window_fill_hash(HV *hv, WINDOW_REC *window)
+{
+ hv_store(hv, "refnum", 6, newSViv(window->refnum), 0);
+ hv_store(hv, "name", 4, new_pv(window->name), 0);
+
+ if (window->active)
+ hv_store(hv, "active", 6, irssi_bless(window->active), 0);
+ if (window->active_server)
+ hv_store(hv, "active_server", 13, irssi_bless(window->active_server), 0);
+
+ hv_store(hv, "lines", 5, newSViv(window->lines), 0);
+
+ hv_store(hv, "level", 5, newSViv(window->level), 0);
+ hv_store(hv, "new_data", 8, newSViv(window->new_data), 0);
+ hv_store(hv, "last_color", 10, newSViv(window->last_color), 0);
+ hv_store(hv, "last_timestamp", 14, newSViv(window->last_timestamp), 0);
+ hv_store(hv, "last_line", 9, newSViv(window->last_line), 0);
+}
+
void printformat_perl(TEXT_DEST_REC *dest, char *format, char **arglist)
{
THEME_REC *theme;
@@ -317,25 +437,30 @@ static void perl_register_protocol(CHAT_PROTOCOL_REC *rec)
/* window items: channel, query */
type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL");
g_snprintf(stash, sizeof(stash), "Irssi::%s::Channel", name);
- irssi_add_object(type, chat_type, stash);
+ irssi_add_object(type, chat_type, stash,
+ (PERL_OBJECT_FUNC) perl_channel_fill_hash);
type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY");
g_snprintf(stash, sizeof(stash), "Irssi::%s::Query", name);
- irssi_add_object(type, chat_type, stash);
+ irssi_add_object(type, chat_type, stash,
+ (PERL_OBJECT_FUNC) perl_query_fill_hash);
/* channel nicks */
type = module_get_uniq_id("NICK", 0);
g_snprintf(stash, sizeof(stash), "Irssi::%s::Nick", name);
- irssi_add_object(type, chat_type, stash);
+ irssi_add_object(type, chat_type, stash,
+ (PERL_OBJECT_FUNC) perl_nick_fill_hash);
/* server specific */
type = module_get_uniq_id("SERVER", 0);
g_snprintf(stash, sizeof(stash), "Irssi::%s::Server", name);
- irssi_add_object(type, chat_type, stash);
+ irssi_add_object(type, chat_type, stash,
+ (PERL_OBJECT_FUNC) perl_server_fill_hash);
type = module_get_uniq_id("SERVER CONNECT", 0);
g_snprintf(stash, sizeof(stash), "Irssi::%s::Connect", name);
- irssi_add_object(type, chat_type, stash);
+ irssi_add_object(type, chat_type, stash,
+ (PERL_OBJECT_FUNC) perl_connect_fill_hash);
/* register ISAs */
for (n = 0; n < sizeof(items)/sizeof(items[0]); n++) {
@@ -347,10 +472,16 @@ static void perl_register_protocol(CHAT_PROTOCOL_REC *rec)
g_free(name);
}
+static void free_iobject_hash(void *key, PERL_OBJECT_REC *rec)
+{
+ g_free(rec->stash);
+ g_free(rec);
+}
+
static int perl_free_protocol(void *key, void *value, void *chat_type)
{
if ((GPOINTER_TO_INT(key) >> 24) == GPOINTER_TO_INT(chat_type)) {
- g_free(value);
+ free_iobject_hash(key, value);
return TRUE;
}
@@ -359,15 +490,10 @@ static int perl_free_protocol(void *key, void *value, void *chat_type)
static void perl_unregister_protocol(CHAT_PROTOCOL_REC *rec)
{
- g_hash_table_foreach_remove(perl_stashes, (GHRFunc) perl_free_protocol,
+ g_hash_table_foreach_remove(iobject_stashes, (GHRFunc) perl_free_protocol,
GINT_TO_POINTER(rec->id));
}
-static void free_perl_stash(void *key, char *value)
-{
- g_free(value);
-}
-
static void sig_protocol_created(CHAT_PROTOCOL_REC *rec)
{
perl_register_protocol(rec);
@@ -380,8 +506,23 @@ static void sig_protocol_destroyed(CHAT_PROTOCOL_REC *rec)
void perl_common_init(void)
{
- perl_stashes = g_hash_table_new((GHashFunc) g_direct_hash,
+ static PLAIN_OBJECT_INIT_REC core_plains[] = {
+ { "Irssi::Command", (PERL_OBJECT_FUNC) perl_command_fill_hash },
+ { "Irssi::Ignore", (PERL_OBJECT_FUNC) perl_ignore_fill_hash },
+ { "Irssi::Log", (PERL_OBJECT_FUNC) perl_log_fill_hash },
+ { "Irssi::LogItem", (PERL_OBJECT_FUNC) perl_log_item_fill_hash },
+ { "Irssi::Rawlog", (PERL_OBJECT_FUNC) perl_rawlog_fill_hash },
+ { "Irssi::Reconnect", (PERL_OBJECT_FUNC) perl_rawlog_fill_hash },
+ { "Irssi::Window", (PERL_OBJECT_FUNC) perl_window_fill_hash },
+
+ { NULL, NULL }
+ };
+
+ iobject_stashes = g_hash_table_new((GHashFunc) g_direct_hash,
(GCompareFunc) g_direct_equal);
+ plain_stashes = g_hash_table_new((GHashFunc) g_str_hash,
+ (GCompareFunc) g_str_equal);
+ irssi_add_plains(core_plains);
g_slist_foreach(chat_protocols, (GFunc) perl_register_protocol, NULL);
signal_add("chat protocol created", (SIGNAL_FUNC) sig_protocol_created);
@@ -390,8 +531,11 @@ void perl_common_init(void)
void perl_common_deinit(void)
{
- g_hash_table_foreach(perl_stashes, (GHFunc) free_perl_stash, NULL);
- g_hash_table_destroy(perl_stashes);
+ g_hash_table_foreach(iobject_stashes, (GHFunc) free_iobject_hash, NULL);
+ g_hash_table_destroy(iobject_stashes);
+
+ g_hash_table_foreach(plain_stashes, (GHFunc) g_free, NULL);
+ g_hash_table_destroy(plain_stashes);
signal_remove("chat protocol created", (SIGNAL_FUNC) sig_protocol_created);
signal_remove("chat protocol destroyed", (SIGNAL_FUNC) sig_protocol_destroyed);
diff --git a/src/perl/perl-common.h b/src/perl/perl-common.h
index 71e508b0..cdbd7e2e 100644
--- a/src/perl/perl-common.h
+++ b/src/perl/perl-common.h
@@ -1,32 +1,43 @@
#ifndef __PERL_COMMON_H
#define __PERL_COMMON_H
+/* helper defines */
#define new_pv(a) \
(newSVpv((a) == NULL ? "" : (a), (a) == NULL ? 0 : strlen(a)))
#define new_bless(obj, stash) \
sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(obj))), stash)
+#define push_bless(obj, stash) \
+ XPUSHs(sv_2mortal(new_bless(obj, stash)))
+
#define is_hvref(o) \
((o) && SvROK(o) && SvRV(o) && (SvTYPE(SvRV(o)) == SVt_PVHV))
#define hvref(o) \
(is_hvref(o) ? (HV *)SvRV(o) : NULL)
-#define push_bless(obj, stash) \
- XPUSHs(sv_2mortal(new_bless(obj, stash)))
+typedef void (*PERL_OBJECT_FUNC) (HV *hv, void *object);
-#define irssi_bless(object) \
- ((object) == NULL ? &PL_sv_undef : \
- irssi_bless_object((object)->type, (object)->chat_type, object))
+typedef struct {
+ char *name;
+ PERL_OBJECT_FUNC fill_func;
+} PLAIN_OBJECT_INIT_REC;
/* returns the package who called us */
char *perl_get_package(void);
-SV *irssi_bless_object(int type, int chat_type, void *object);
+#define irssi_bless(object) \
+ ((object) == NULL ? &PL_sv_undef : \
+ irssi_bless_iobject((object)->type, (object)->chat_type, object))
+SV *irssi_bless_iobject(int type, int chat_type, void *object);
+SV *irssi_bless_plain(const char *stash, void *object);
void *irssi_ref_object(SV *o);
-void irssi_add_object(int type, int chat_type, const char *stash);
+void irssi_add_object(int type, int chat_type, const char *stash,
+ PERL_OBJECT_FUNC func);
+void irssi_add_plain(const char *stash, PERL_OBJECT_FUNC func);
+void irssi_add_plains(PLAIN_OBJECT_INIT_REC *objects);
void perl_common_init(void);
void perl_common_deinit(void);
diff --git a/src/perl/perl.c b/src/perl/perl.c
index b4639ef9..e9fb27cb 100644
--- a/src/perl/perl.c
+++ b/src/perl/perl.c
@@ -170,6 +170,8 @@ static void irssi_perl_start(void)
perl_parse(irssi_perl_interp, xs_init, 3, args, NULL);
perl_eval_pv(eval_file_code, TRUE);
+
+ perl_common_init();
}
static int signal_destroy_hash(void *key, GSList **list, const char *package)
@@ -295,6 +297,9 @@ static void irssi_perl_stop(void)
g_slist_free(perl_scripts);
perl_scripts = NULL;
+ /* perl-common stuff */
+ perl_common_deinit();
+
/* perl interpreter */
perl_destruct(irssi_perl_interp);
perl_free(irssi_perl_interp);
@@ -373,6 +378,34 @@ static void cmd_run(const char *data)
LEAVE;
}
+static void cmd_perl(const char *data)
+{
+ dSP;
+ GString *code;
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK(SP);
+
+ code = g_string_new("use Irssi;\n");
+ g_string_append(code, data);
+ perl_eval_pv(code->str, G_NOARGS|G_EVAL|G_DISCARD);
+ g_string_free(code, TRUE);
+
+ SPAGAIN;
+
+ if (SvTRUE(ERRSV)) {
+ STRLEN n_a;
+
+ signal_emit("gui dialog", 2, "error", SvPV(ERRSV, n_a));
+ }
+
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+}
+
static void cmd_unload(const char *data)
{
char *name;
@@ -604,8 +637,7 @@ static int perl_get_args(int signal, SV **args, va_list va)
args[n] = irssi_bless((SERVER_REC *) arg);
} else {
/* blessed object */
- stash = gv_stashpv(rec->args[n], 0);
- args[n] = new_bless(arg, stash);
+ args[n] = irssi_bless_plain(rec->args[n], arg);
}
}
return n;
@@ -724,24 +756,23 @@ void perl_init(void)
perl_scripts = NULL;
command_bind("run", NULL, (SIGNAL_FUNC) cmd_run);
command_bind_first("unload", NULL, (SIGNAL_FUNC) cmd_unload);
+ command_bind("perl", NULL, (SIGNAL_FUNC) cmd_perl);
command_bind("perlflush", NULL, (SIGNAL_FUNC) cmd_perlflush);
signal_grabbed = siglast_grabbed = FALSE;
PL_perl_destruct_level = 1;
irssi_perl_start();
-
- perl_common_init();
irssi_perl_autorun();
}
void perl_deinit(void)
{
irssi_perl_stop();
- perl_common_deinit();
if (signal_grabbed) signal_remove("signal", (SIGNAL_FUNC) sig_signal);
if (siglast_grabbed) signal_remove("last signal", (SIGNAL_FUNC) sig_lastsignal);
command_unbind("run", (SIGNAL_FUNC) cmd_run);
command_unbind("unload", (SIGNAL_FUNC) cmd_unload);
+ command_unbind("perl", (SIGNAL_FUNC) cmd_perl);
command_unbind("perlflush", (SIGNAL_FUNC) cmd_perlflush);
}