comparison libpurple/plugins/perl/perl.c @ 23648:ab5b9acebde3

Update the Perl plugin loader to work with Perl 5.10. I don't think this will break compiling with older versions (note that Perl micro versions are not binary compatible). Update the win32 build to use (and require and upgrade to Perl 5.10). Fixes #5137
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 28 Jul 2008 00:52:54 +0000
parents 3cc856ca2338
children d1d32f318ce9
comparison
equal deleted inserted replaced
23647:d48d333e6ef5 23648:ab5b9acebde3
65 #endif 65 #endif
66 66
67 #undef group 67 #undef group
68 68
69 /* perl module support */ 69 /* perl module support */
70 #ifdef _WIN32
71 EXTERN_C void boot_Win32CORE (pTHX_ CV* cv);
72 #endif
73
70 #ifdef OLD_PERL 74 #ifdef OLD_PERL
71 extern void boot_DynaLoader _((CV * cv)); 75 extern void boot_DynaLoader _((CV * cv));
72 #else 76 #else
73 extern void boot_DynaLoader _((pTHX_ CV * cv)); /* perl is so wacky */ 77 extern void boot_DynaLoader _((pTHX_ CV * cv)); /* perl is so wacky */
74 #endif 78 #endif
125 #else 129 #else
126 xs_init(pTHX) 130 xs_init(pTHX)
127 #endif 131 #endif
128 { 132 {
129 char *file = __FILE__; 133 char *file = __FILE__;
134 dXSUB_SYS;
130 135
131 /* This one allows dynamic loading of perl modules in perl scripts by 136 /* This one allows dynamic loading of perl modules in perl scripts by
132 * the 'use perlmod;' construction */ 137 * the 'use perlmod;' construction */
133 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); 138 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
139 #ifdef _WIN32
140 newXS("Win32CORE::bootstrap", boot_Win32CORE, file);
141 #endif
134 } 142 }
135 143
136 static void 144 static void
137 perl_init(void) 145 perl_init(void)
138 { 146 {
238 } 246 }
239 247
240 static gboolean 248 static gboolean
241 probe_perl_plugin(PurplePlugin *plugin) 249 probe_perl_plugin(PurplePlugin *plugin)
242 { 250 {
243 /* XXX This would be much faster if I didn't create a new 251
244 * PerlInterpreter every time I probed a plugin */ 252 char *args[] = {"", plugin->path };
245 253 char **argv = args;
246 PerlInterpreter *prober = perl_alloc(); 254 int argc = 2;
247 char *argv[] = {"", plugin->path }; 255 PerlInterpreter *prober;
248 gboolean status = TRUE; 256 gboolean status = TRUE;
249 HV *plugin_info; 257 HV *plugin_info;
258
259 PERL_SYS_INIT(&argc, &argv);
260
261 /* XXX This would be much faster if we didn't create a new
262 * PerlInterpreter every time we probe a plugin */
263 prober = perl_alloc();
264
250 PERL_SET_CONTEXT(prober); 265 PERL_SET_CONTEXT(prober);
266
251 PL_perl_destruct_level = 1; 267 PL_perl_destruct_level = 1;
252 perl_construct(prober); 268 perl_construct(prober);
253 269
254 perl_parse(prober, xs_init, 2, argv, NULL); 270 perl_parse(prober, xs_init, argc, argv, NULL);
255 271
256 perl_run(prober); 272 perl_run(prober);
257 273
258 plugin_info = perl_get_hv("PLUGIN_INFO", FALSE); 274 plugin_info = perl_get_hv("PLUGIN_INFO", FALSE);
259 275
576 NULL, /**< exts */ 592 NULL, /**< exts */
577 probe_perl_plugin, /**< probe */ 593 probe_perl_plugin, /**< probe */
578 load_perl_plugin, /**< load */ 594 load_perl_plugin, /**< load */
579 unload_perl_plugin, /**< unload */ 595 unload_perl_plugin, /**< unload */
580 destroy_perl_plugin, /**< destroy */ 596 destroy_perl_plugin, /**< destroy */
581 597
582 /* padding */ 598 /* padding */
583 NULL, 599 NULL,
584 NULL, 600 NULL,
585 NULL, 601 NULL,
586 NULL 602 NULL