From 5da6c63cddd2a0c8255c1891e527f60636be184d Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 30 Oct 2000 22:52:51 +0000 Subject: [PATCH] Moved the ISA defines from .pm to irssi code, so that non-irc protocols would work also without a specific .pm file. Also you don't need to use Irssi::Irc anymore if you don't need IRC specific functions. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@800 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/perl/irc/Irc.pm | 7 ------- src/perl/perl-common.c | 16 ++++++++++++++-- src/perl/perl.c | 6 +++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/perl/irc/Irc.pm b/src/perl/irc/Irc.pm index 79cf88c5..a7c77742 100644 --- a/src/perl/irc/Irc.pm +++ b/src/perl/irc/Irc.pm @@ -18,12 +18,5 @@ require DynaLoader; bootstrap Irssi::Irc $VERSION; -@Irssi::Irc::Chatnet::ISA = qw(Irssi::Chatnet); -@Irssi::Irc::Server::ISA = qw(Irssi::Server); -@Irssi::Irc::ServerConnect::ISA = qw(Irssi::ServerConnect); -@Irssi::Irc::ServerSetup::ISA = qw(Irssi::ServerSetup); -@Irssi::Irc::Channel::ISA = qw(Irssi::Channel); -@Irssi::Irc::Query::ISA = qw(Irssi::Query); - 1; diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c index ee4bc3c7..d20d3ab4 100644 --- a/src/perl/perl-common.c +++ b/src/perl/perl-common.c @@ -159,8 +159,13 @@ void perl_query_fill_hash(HV *hv, QUERY_REC *query) static void perl_register_protocol(CHAT_PROTOCOL_REC *rec) { - char *name, stash[100]; - int type, chat_type; + static char *items[] = { + "Chatnet", + "Server", "ServerConnect", "ServerSetup", + "Channel", "Query" + }; + char *name, stash[100], code[100]; + int type, chat_type, n; chat_type = chat_protocol_lookup(rec->name); g_return_if_fail(chat_type >= 0); @@ -186,6 +191,13 @@ static void perl_register_protocol(CHAT_PROTOCOL_REC *rec) g_snprintf(stash, sizeof(stash), "Irssi::%s::Connect", name); irssi_add_stash(type, chat_type, stash); + /* register ISAs */ + for (n = 0; n < sizeof(items)/sizeof(items[0]); n++) { + g_snprintf(code, sizeof(code), + "@Irssi::%s::%s::ISA = qw(Irssi::%s);", + name, items[n], items[n]); + perl_eval_pv(code, TRUE); + } g_free(name); } diff --git a/src/perl/perl.c b/src/perl/perl.c index 3ade4b72..89220843 100644 --- a/src/perl/perl.c +++ b/src/perl/perl.c @@ -154,7 +154,7 @@ static void irssi_perl_start(void) "\n" " eval {$package->handler;};\n" " die $@ if $@;\n" - "}"; + "}\n"; first_signals = g_hash_table_new((GHashFunc) g_direct_hash, (GCompareFunc) g_direct_equal); @@ -663,8 +663,6 @@ static void irssi_perl_autorun(void) void perl_init(void) { - perl_common_init(); - perl_scripts = NULL; command_bind("run", NULL, (SIGNAL_FUNC) cmd_run); command_bind_first("unload", NULL, (SIGNAL_FUNC) cmd_unload); @@ -673,6 +671,8 @@ void perl_init(void) PL_perl_destruct_level = 1; irssi_perl_start(); + + perl_common_init(); irssi_perl_autorun(); }