Mercurial > pidgin
diff libpurple/plugins/perl/perl-common.c @ 22696:3a41eb457605
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Purple::Request:: functions as well. This allows the callbacks to be
specified both as coderefs or as strings (name of the callback function).
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 23 Apr 2008 02:29:39 +0000 |
parents | 678461486949 |
children | ab5b9acebde3 |
line wrap: on
line diff
--- a/libpurple/plugins/perl/perl-common.c Tue Apr 22 16:47:11 2008 +0000 +++ b/libpurple/plugins/perl/perl-common.c Wed Apr 23 02:29:39 2008 +0000 @@ -616,3 +616,26 @@ return NULL; } + +SV *purple_perl_sv_from_fun(PurplePlugin *plugin, SV *callback) +{ + SV *sv = NULL; + + if (SvTYPE(callback) == SVt_RV) { + SV *cbsv = SvRV(callback); + + if (SvTYPE(cbsv) == SVt_PVCV) { + sv = newSVsv(callback); + } + } else if (SvTYPE(callback) == SVt_PV) { + PurplePerlScript *gps; + + gps = (PurplePerlScript *)PURPLE_PLUGIN_LOADER_INFO(plugin); + sv = newSVpvf("%s::%s", gps->package, SvPV_nolen(callback)); + } else { + purple_debug_warning("perl", "Callback not a valid type, only strings and coderefs allowed.\n"); + } + + return sv; +} +