X-Git-Url: http://git.vpit.fr/?p=perl%2Fscripts%2Fxchat.git;a=blobdiff_plain;f=Xchat%2FXPI.pm;h=0733175382a71dde90c6e0d775e1af8a7d818fa6;hp=6811e63b3bc0355bc355b7841b77eb343aa51f54;hb=HEAD;hpb=dd329bf05f9a50bd10d79e522334761f9785d7ab diff --git a/Xchat/XPI.pm b/Xchat/XPI.pm index 6811e63..0733175 100644 --- a/Xchat/XPI.pm +++ b/Xchat/XPI.pm @@ -7,6 +7,9 @@ use Tie::RefHash; use Xchat; +use lib Xchat::get_info('xchatdir'); +use Xchat::XPI::Utils qw; + our $VERSION = '0.05'; use constant { COLOR_TAG => "\00307" }; @@ -23,7 +26,7 @@ sub new { $class = ref($class) || $class; my %opts = @_; - my ($caller, $file) = (caller 0)[0, 1]; + my $caller = (caller 0)[0]; unless (defined $opts{tag}) { $opts{tag} = ($caller =~ /([^:]*):*$/) ? $1 : 'UNKNOWN'; @@ -53,19 +56,17 @@ sub new { *$ph->{$_} = $opts{$_} for @attributes; *$ph->{buf} = ''; - my $internal_pkg = Xchat::Embed::file2pkg($file); - no warnings 'redefine'; - local *Xchat::Embed::find_pkg = sub { $internal_pkg, $caller }; - local *HexChat::Embed::find_pkg = sub { $internal_pkg, $caller }; - Xchat::register(@opts{qw}, sub { - $ph->flush; - if (*$ph->{atexit_id}) { - my @callbacks = sort { *$ph->{atexit}{$b} <=> *$ph->{atexit}{$a} } - keys %{*$ph->{atexit}}; - $_->($ph) for @callbacks; - } - undef $ph; - }); + called_from_script { + Xchat::register(@opts{qw}, sub { + $ph->flush; + if (*$ph->{atexit_id}) { + my @callbacks = sort { *$ph->{atexit}{$b} <=> *$ph->{atexit}{$a} } + keys %{*$ph->{atexit}}; + $_->($ph) for @callbacks; + } + undef $ph; + }) + }; $ph->add_atexit($opts{unload}) if $opts{unload}; $ph->print("\002", $ph->name, ' v', $ph->version,