1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Updated perl API version. Fixed irssi to behave better if the API doesn't

match (doesn't crash).


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1985 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-11-11 22:39:56 +00:00 committed by cras
parent 571f3acaf8
commit ea03650b3f
6 changed files with 21 additions and 15 deletions

View File

@ -1,5 +1,7 @@
#include "module.h" #include "module.h"
static int initialized = FALSE;
MODULE = Irssi PACKAGE = Irssi MODULE = Irssi PACKAGE = Irssi
PROTOTYPES: ENABLE PROTOTYPES: ENABLE
@ -7,12 +9,16 @@ PROTOTYPES: ENABLE
void void
init() init()
CODE: CODE:
if (initialized) return;
perl_api_version_check("Irssi"); perl_api_version_check("Irssi");
initialized = TRUE;
perl_settings_init(); perl_settings_init();
void void
deinit() deinit()
CODE: CODE:
if (!initialized) return;
perl_settings_deinit(); perl_settings_deinit();
BOOT: BOOT:

View File

@ -21,5 +21,5 @@ extern PerlInterpreter *my_perl; /* must be called my_perl or some perl implemen
#define MODULE_NAME "perl/core" #define MODULE_NAME "perl/core"
/* Change this every time when some API changes between irssi's perl module /* Change this every time when some API changes between irssi's perl module
and irssi's perl libraries. */ (or irssi itself) and irssi's perl libraries. */
#define IRSSI_PERL_API_VERSION 20011021 #define IRSSI_PERL_API_VERSION 20011111

View File

@ -141,6 +141,9 @@ void perl_scripts_init(void)
/* Destroy all perl scripts and deinitialize perl interpreter */ /* Destroy all perl scripts and deinitialize perl interpreter */
void perl_scripts_deinit(void) void perl_scripts_deinit(void)
{ {
if (my_perl == NULL)
return;
/* destroy all scripts */ /* destroy all scripts */
while (perl_scripts != NULL) while (perl_scripts != NULL)
perl_script_destroy(perl_scripts->data); perl_script_destroy(perl_scripts->data);
@ -417,7 +420,7 @@ static void sig_script_error(PERL_SCRIPT_REC *script, const char *error)
} }
} }
static void sig_autorun() static void sig_autorun(void)
{ {
signal_remove("irssi init finished", (SIGNAL_FUNC) sig_autorun); signal_remove("irssi init finished", (SIGNAL_FUNC) sig_autorun);

View File

@ -41,14 +41,9 @@ int perl_get_api_version(void);
/* Checks that the API version is correct. */ /* Checks that the API version is correct. */
#define perl_api_version_check(library) \ #define perl_api_version_check(library) \
if (perl_get_api_version() != IRSSI_PERL_API_VERSION) { \ if (perl_get_api_version() != IRSSI_PERL_API_VERSION) { \
char *str; \ die("Version of perl module (%d) doesn't match the " \
str = g_strdup_printf("Version of perl module (%d) " \ "version of "library" library (%d)", \
"doesn't match the version of " \ perl_get_api_version(), IRSSI_PERL_API_VERSION); \
library" library (%d)", \
perl_get_api_version(), \
IRSSI_PERL_API_VERSION); \
signal_emit("gui dialog", 2, "error", str); \
g_free(str); \
return; \ return; \
} }

View File

@ -1,5 +1,7 @@
#include "module.h" #include "module.h"
static int initialized = FALSE;
static void perl_main_window_fill_hash(HV *hv, MAIN_WINDOW_REC *window) static void perl_main_window_fill_hash(HV *hv, MAIN_WINDOW_REC *window)
{ {
hv_store(hv, "active", 6, plain_bless(window->active, "Irssi::UI::Window"), 0); hv_store(hv, "active", 6, plain_bless(window->active, "Irssi::UI::Window"), 0);
@ -87,8 +89,6 @@ PROTOTYPES: ENABLE
void void
init() init()
PREINIT:
static int initialized = FALSE;
CODE: CODE:
if (initialized) return; if (initialized) return;
perl_api_version_check("Irssi::TextUI"); perl_api_version_check("Irssi::TextUI");
@ -100,6 +100,7 @@ CODE:
void void
deinit() deinit()
CODE: CODE:
if (!initialized) return;
perl_statusbar_deinit(); perl_statusbar_deinit();
MODULE = Irssi::TextUI PACKAGE = Irssi MODULE = Irssi::TextUI PACKAGE = Irssi

View File

@ -1,5 +1,7 @@
#include "module.h" #include "module.h"
static int initialized = FALSE;
static void perl_process_fill_hash(HV *hv, PROCESS_REC *process) static void perl_process_fill_hash(HV *hv, PROCESS_REC *process)
{ {
hv_store(hv, "id", 2, newSViv(process->id), 0); hv_store(hv, "id", 2, newSViv(process->id), 0);
@ -70,8 +72,6 @@ PROTOTYPES: ENABLE
void void
init() init()
PREINIT:
static int initialized = FALSE;
CODE: CODE:
if (initialized) return; if (initialized) return;
perl_api_version_check("Irssi::UI"); perl_api_version_check("Irssi::UI");
@ -83,6 +83,7 @@ CODE:
void void
deinit() deinit()
CODE: CODE:
if (!initialized) return;
perl_themes_deinit(); perl_themes_deinit();
BOOT: BOOT: