diff options
author | Timo Sirainen <cras@irssi.org> | 2001-02-17 10:35:35 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-02-17 10:35:35 +0000 |
commit | abe4ddb52ab32cb7e6aaee98a25e93f769a3aa46 (patch) | |
tree | 18f744255342648f9443de36e5b1eee098c9abe2 /src/perl | |
parent | f1205c10e0d6ef29065c96d788c35c4e23ed4860 (diff) | |
download | irssi-abe4ddb52ab32cb7e6aaee98a25e93f769a3aa46.zip |
/LOAD module tries to load "module_core" instead. If it wasn't found,
it fallbacks to "module" again. If it is found, it tries to load several
other modules too, like irc_module, fe_module and fe_irc_module.
Split perl module to perl_core and fe_perl. Removed "_common" from some
fe_common modules.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1228 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/perl')
-rw-r--r-- | src/perl/Makefile.am | 25 | ||||
-rw-r--r-- | src/perl/module.h | 3 | ||||
-rw-r--r-- | src/perl/perl-common.c | 18 | ||||
-rw-r--r-- | src/perl/perl-common.h | 2 | ||||
-rw-r--r-- | src/perl/perl-fe.c | 76 | ||||
-rw-r--r-- | src/perl/perl.c | 52 |
6 files changed, 115 insertions, 61 deletions
diff --git a/src/perl/Makefile.am b/src/perl/Makefile.am index 906fad79..5c31d908 100644 --- a/src/perl/Makefile.am +++ b/src/perl/Makefile.am @@ -2,11 +2,14 @@ LIBTOOL = $(PERL_LIBTOOL) moduledir = $(libdir)/irssi/modules -module_LTLIBRARIES = $(module_lib) -noinst_LTLIBRARIES = $(static_lib) -EXTRA_LTLIBRARIES = libperl.la libperl_static.la +module_LTLIBRARIES = $(perl_module_lib) $(perl_module_fe_lib) +noinst_LTLIBRARIES = $(perl_static_lib) $(perl_static_fe_lib) +EXTRA_LTLIBRARIES = \ + libperl_core.la libfe_perl.la \ + libperl_static.la libfe_perl_static.la -libperl_la_LDFLAGS = -avoid-version -rpath $(moduledir) +libperl_core_la_LDFLAGS = -avoid-version -rpath $(moduledir) +libfe_perl_la_LDFLAGS = -avoid-version -rpath $(moduledir) perl.c: perl-signals-list.h @@ -22,7 +25,9 @@ perl_sources = \ perl-signals.c \ xsinit.c -libperl_la_DEPENDENCIES = .libs/libperl_orig.a .libs/DynaLoader.a +perl_fe_sources = perl-fe.c + +libperl_core_la_DEPENDENCIES = .libs/libperl_orig.a .libs/DynaLoader.a .libs/libperl_orig.a: if [ ! -d .libs ]; then mkdir .libs; fi @@ -33,12 +38,18 @@ libperl_la_DEPENDENCIES = .libs/libperl_orig.a .libs/DynaLoader.a rm -f .libs/DynaLoader.a $(LN_S) $(DYNALOADER_A) .libs/DynaLoader.a -libperl_la_SOURCES = \ +libperl_core_la_SOURCES = \ $(perl_sources) libperl_static_la_SOURCES = \ $(perl_sources) +libfe_perl_la_SOURCES = \ + $(perl_fe_sources) + +libfe_perl_static_la_SOURCES = \ + $(perl_fe_sources) + perl-signals-list.h: $(top_srcdir)/docs/signals.txt $(srcdir)/get-signals.pl cat $(top_srcdir)/docs/signals.txt | $(perlpath) $(srcdir)/get-signals.pl > perl-signals-list.h @@ -96,4 +107,4 @@ install-exec-local: clean-generic: rm -f common/Irssi.c irc/Irc.c -libperl_la_LIBADD = $(PERL_LDFLAGS) +libperl_core_la_LIBADD = $(PERL_LDFLAGS) diff --git a/src/perl/module.h b/src/perl/module.h index 4e1d9b2f..46fb4548 100644 --- a/src/perl/module.h +++ b/src/perl/module.h @@ -15,3 +15,6 @@ #include "common.h" #define MODULE_NAME "irssi-perl" + +extern GSList *perl_scripts; +extern PerlInterpreter *my_perl; /* must be called my_perl or some perl implementations won't work */ diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c index 7d53446b..bcbbae25 100644 --- a/src/perl/perl-common.c +++ b/src/perl/perl-common.c @@ -568,16 +568,6 @@ static void perl_unregister_protocol(CHAT_PROTOCOL_REC *rec) GINT_TO_POINTER(rec->id)); } -static void sig_protocol_created(CHAT_PROTOCOL_REC *rec) -{ - perl_register_protocol(rec); -} - -static void sig_protocol_destroyed(CHAT_PROTOCOL_REC *rec) -{ - perl_unregister_protocol(rec); -} - void perl_common_init(void) { static PLAIN_OBJECT_INIT_REC core_plains[] = { @@ -602,8 +592,8 @@ void perl_common_init(void) use_protocols = NULL; g_slist_foreach(chat_protocols, (GFunc) perl_register_protocol, NULL); - signal_add("chat protocol created", (SIGNAL_FUNC) sig_protocol_created); - signal_add("chat protocol destroyed", (SIGNAL_FUNC) sig_protocol_destroyed); + signal_add("chat protocol created", (SIGNAL_FUNC) perl_register_protocol); + signal_add("chat protocol destroyed", (SIGNAL_FUNC) perl_unregister_protocol); } void perl_common_deinit(void) @@ -617,6 +607,6 @@ void perl_common_deinit(void) g_slist_foreach(use_protocols, (GFunc) g_free, NULL); g_slist_free(use_protocols); - signal_remove("chat protocol created", (SIGNAL_FUNC) sig_protocol_created); - signal_remove("chat protocol destroyed", (SIGNAL_FUNC) sig_protocol_destroyed); + signal_remove("chat protocol created", (SIGNAL_FUNC) perl_register_protocol); + signal_remove("chat protocol destroyed", (SIGNAL_FUNC) perl_unregister_protocol); } diff --git a/src/perl/perl-common.h b/src/perl/perl-common.h index d01d014b..e6519681 100644 --- a/src/perl/perl-common.h +++ b/src/perl/perl-common.h @@ -1,8 +1,6 @@ #ifndef __PERL_COMMON_H #define __PERL_COMMON_H -extern PerlInterpreter *my_perl; /* must be called my_perl or some perl implementations won't work */ - /* helper defines */ #define new_pv(a) \ (newSVpv((a) == NULL ? "" : (a), (a) == NULL ? 0 : strlen(a))) diff --git a/src/perl/perl-fe.c b/src/perl/perl-fe.c new file mode 100644 index 00000000..f7ace310 --- /dev/null +++ b/src/perl/perl-fe.c @@ -0,0 +1,76 @@ +/* + perl-fe.c : irssi + + Copyright (C) 2001 Timo Sirainen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "module.h" +#include "signals.h" + +#include "fe-common/core/themes.h" +#include "fe-common/core/formats.h" + +#include "perl-common.h" + +static void perl_unregister_theme(const char *package) +{ + FORMAT_REC *formats; + int n; + + formats = g_hash_table_lookup(default_formats, package); + if (formats == NULL) return; + + for (n = 0; formats[n].def != NULL; n++) { + g_free(formats[n].tag); + g_free(formats[n].def); + } + g_free(formats); + theme_unregister_module(package); +} + +static void sig_script_destroy(const char *type, const char *name, + const char *package) +{ + if (strcmp(type, "PERL") == 0) + perl_unregister_theme(package); +} + +static void sig_perl_stop(void) +{ + GSList *tmp; + char *package; + + /* themes */ + for (tmp = perl_scripts; tmp != NULL; tmp = tmp->next) { + package = g_strdup_printf("Irssi::Script::%s", + (char *) tmp->data); + perl_unregister_theme(package); + g_free(package); + } +} + +void fe_perl_init(void) +{ + signal_add("script destroy", (SIGNAL_FUNC) sig_script_destroy); + signal_add("perl stop", (SIGNAL_FUNC) sig_perl_stop); +} + +void fe_perl_deinit(void) +{ + signal_remove("script destroy", (SIGNAL_FUNC) sig_script_destroy); + signal_remove("perl stop", (SIGNAL_FUNC) sig_perl_stop); +} diff --git a/src/perl/perl.c b/src/perl/perl.c index 072737b6..6239b9ed 100644 --- a/src/perl/perl.c +++ b/src/perl/perl.c @@ -1,7 +1,7 @@ /* perl.c : irssi - Copyright (C) 1999 Timo Sirainen + Copyright (C) 1999-2001 Timo Sirainen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,9 +23,6 @@ #include "commands.h" #include "misc.h" -#include "fe-common/core/themes.h" -#include "fe-common/core/formats.h" - #include "perl-common.h" #include "perl-signals.h" @@ -43,7 +40,7 @@ typedef struct { } PERL_SOURCE_REC; static GSList *perl_sources; -static GSList *perl_scripts; +GSList *perl_scripts; PerlInterpreter *my_perl; static void perl_source_destroy(PERL_SOURCE_REC *rec) @@ -99,22 +96,6 @@ static void irssi_perl_start(void) perl_common_init(); } -static void perl_unregister_theme(const char *package) -{ - FORMAT_REC *formats; - int n; - - formats = g_hash_table_lookup(default_formats, package); - if (formats == NULL) return; - - for (n = 0; formats[n].def != NULL; n++) { - g_free(formats[n].tag); - g_free(formats[n].def); - } - g_free(formats); - theme_unregister_module(package); -} - static int perl_script_destroy(const char *name) { GSList *tmp, *next, *item; @@ -122,11 +103,14 @@ static int perl_script_destroy(const char *name) int package_len; item = gslist_find_string(perl_scripts, name); - if (item == NULL) return FALSE; + if (item == NULL) + return FALSE; package = g_strdup_printf("Irssi::Script::%s", name); package_len = strlen(package); + signal_emit("script destroy", 3, "PERL", name, package); + perl_signals_package_destroy(package); /* timeouts and input waits */ @@ -138,9 +122,6 @@ static int perl_script_destroy(const char *name) perl_source_destroy(rec); } - /* theme */ - perl_unregister_theme(package); - g_free(package); g_free(item->data); perl_scripts = g_slist_remove(perl_scripts, item->data); @@ -149,23 +130,15 @@ static int perl_script_destroy(const char *name) static void irssi_perl_stop(void) { - GSList *tmp; char *package; + signal_emit("perl stop", 0); perl_signals_stop(); /* timeouts and input waits */ while (perl_sources != NULL) perl_source_destroy(perl_sources->data); - /* themes */ - for (tmp = perl_scripts; tmp != NULL; tmp = tmp->next) { - package = g_strdup_printf("Irssi::Script::%s", - (char *) tmp->data); - perl_unregister_theme(package); - g_free(package); - } - /* scripts list */ g_slist_foreach(perl_scripts, (GFunc) g_free, NULL); g_slist_free(perl_scripts); @@ -221,14 +194,13 @@ static void cmd_run(const char *data) script_fix_name(name); perl_script_destroy(name); - perl_scripts = g_slist_append(perl_scripts, g_strdup(name)); ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(new_pv(fname))); g_free(fname); - XPUSHs(sv_2mortal(new_pv(name))); g_free(name); + XPUSHs(sv_2mortal(new_pv(name))); PUTBACK; retcount = perl_call_pv("Irssi::Load::eval_file", @@ -250,6 +222,10 @@ static void cmd_run(const char *data) PUTBACK; FREETMPS; LEAVE; + + perl_scripts = g_slist_append(perl_scripts, g_strdup(name)); + signal_emit("script new", 2, "PERL", name); + g_free(name); } static void cmd_perl(const char *data) @@ -403,7 +379,7 @@ static void irssi_perl_autorun(void) g_free(path); } -void perl_init(void) +void perl_core_init(void) { perl_scripts = NULL; command_bind("run", NULL, (SIGNAL_FUNC) cmd_run); @@ -417,7 +393,7 @@ void perl_init(void) irssi_perl_autorun(); } -void perl_deinit(void) +void perl_core_deinit(void) { perl_signals_deinit(); irssi_perl_stop(); |