Update XChat to r1519
This commit is contained in:
parent
11b73bc8a7
commit
095d32556c
@ -3,7 +3,7 @@ package IRC;
|
|||||||
sub IRC::register {
|
sub IRC::register {
|
||||||
my ($script_name, $version, $callback) = @_;
|
my ($script_name, $version, $callback) = @_;
|
||||||
my $package = caller;
|
my $package = caller;
|
||||||
$callback = Xchat::Embed::fix_callback( $package, $callback) if $callback;
|
$callback = Xchat::Embed::fix_callback( $package, undef, $callback) if $callback;
|
||||||
Xchat::register( $script_name, $version, undef, $callback );
|
Xchat::register( $script_name, $version, undef, $callback );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ sub IRC::add_command_handler {
|
|||||||
my ($command, $callback) = @_;
|
my ($command, $callback) = @_;
|
||||||
my $package = caller;
|
my $package = caller;
|
||||||
|
|
||||||
$callback = Xchat::Embed::fix_callback( $package, $callback );
|
$callback = Xchat::Embed::fix_callback( $package, undef, $callback );
|
||||||
|
|
||||||
# starting index for word_eol array
|
# starting index for word_eol array
|
||||||
# this is for compatibility with '' as the command
|
# this is for compatibility with '' as the command
|
||||||
@ -30,7 +30,7 @@ sub IRC::add_command_handler {
|
|||||||
sub IRC::add_message_handler {
|
sub IRC::add_message_handler {
|
||||||
my ($message, $callback) = @_;
|
my ($message, $callback) = @_;
|
||||||
my $package = caller;
|
my $package = caller;
|
||||||
$callback = Xchat::Embed::fix_callback( $package, $callback );
|
$callback = Xchat::Embed::fix_callback( $package, undef, $callback );
|
||||||
|
|
||||||
Xchat::hook_server( $message,
|
Xchat::hook_server( $message,
|
||||||
sub {
|
sub {
|
||||||
@ -44,7 +44,7 @@ sub IRC::add_message_handler {
|
|||||||
sub IRC::add_print_handler {
|
sub IRC::add_print_handler {
|
||||||
my ($event, $callback) = @_;
|
my ($event, $callback) = @_;
|
||||||
my $package = caller;
|
my $package = caller;
|
||||||
$callback = Xchat::Embed::fix_callback( $package, $callback );
|
$callback = Xchat::Embed::fix_callback( $package, undef, $callback );
|
||||||
Xchat::hook_print( $event,
|
Xchat::hook_print( $event,
|
||||||
sub {
|
sub {
|
||||||
my @word = @{$_[0]};
|
my @word = @{$_[0]};
|
||||||
@ -58,7 +58,7 @@ sub IRC::add_print_handler {
|
|||||||
sub IRC::add_timeout_handler {
|
sub IRC::add_timeout_handler {
|
||||||
my ($timeout, $callback) = @_;
|
my ($timeout, $callback) = @_;
|
||||||
my $package = caller;
|
my $package = caller;
|
||||||
$callback = Xchat::Embed::fix_callback( $package, $callback );
|
$callback = Xchat::Embed::fix_callback( $package, undef, $callback );
|
||||||
Xchat::hook_timer( $timeout,
|
Xchat::hook_timer( $timeout,
|
||||||
sub {
|
sub {
|
||||||
no strict 'refs';
|
no strict 'refs';
|
||||||
|
@ -74,7 +74,7 @@ our @EXPORT = @{$EXPORT_TAGS{constants}};
|
|||||||
our @EXPORT_OK = @{$EXPORT_TAGS{all}};
|
our @EXPORT_OK = @{$EXPORT_TAGS{all}};
|
||||||
|
|
||||||
sub register {
|
sub register {
|
||||||
my $package = Xchat::Embed::find_pkg();
|
my ($package, $calling_package) = Xchat::Embed::find_pkg();
|
||||||
my $pkg_info = Xchat::Embed::pkg_info( $package );
|
my $pkg_info = Xchat::Embed::pkg_info( $package );
|
||||||
my $filename = $pkg_info->{filename};
|
my $filename = $pkg_info->{filename};
|
||||||
my ($name, $version, $description, $callback) = @_;
|
my ($name, $version, $description, $callback) = @_;
|
||||||
@ -86,6 +86,11 @@ sub register {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$description = "" unless defined $description;
|
$description = "" unless defined $description;
|
||||||
|
if( $callback ) {
|
||||||
|
$callback = Xchat::Embed::fix_callback(
|
||||||
|
$package, $calling_package, $callback
|
||||||
|
);
|
||||||
|
}
|
||||||
$pkg_info->{shutdown} = $callback;
|
$pkg_info->{shutdown} = $callback;
|
||||||
unless( $name && $name =~ /[[:print:]\w]/ ) {
|
unless( $name && $name =~ /[[:print:]\w]/ ) {
|
||||||
$name = "Not supplied";
|
$name = "Not supplied";
|
||||||
@ -124,9 +129,11 @@ sub hook_server {
|
|||||||
my $message = shift;
|
my $message = shift;
|
||||||
my $callback = shift;
|
my $callback = shift;
|
||||||
my $options = shift;
|
my $options = shift;
|
||||||
my $package = Xchat::Embed::find_pkg();
|
my ($package, $calling_package) = Xchat::Embed::find_pkg();
|
||||||
|
|
||||||
$callback = Xchat::Embed::fix_callback( $package, $callback );
|
$callback = Xchat::Embed::fix_callback(
|
||||||
|
$package, $calling_package, $callback
|
||||||
|
);
|
||||||
|
|
||||||
my ($priority, $data) = ( Xchat::PRI_NORM, undef );
|
my ($priority, $data) = ( Xchat::PRI_NORM, undef );
|
||||||
_process_hook_options(
|
_process_hook_options(
|
||||||
@ -148,9 +155,11 @@ sub hook_command {
|
|||||||
my $command = shift;
|
my $command = shift;
|
||||||
my $callback = shift;
|
my $callback = shift;
|
||||||
my $options = shift;
|
my $options = shift;
|
||||||
my $package = Xchat::Embed::find_pkg();
|
my ($package, $calling_package) = Xchat::Embed::find_pkg();
|
||||||
|
|
||||||
$callback = Xchat::Embed::fix_callback( $package, $callback );
|
$callback = Xchat::Embed::fix_callback(
|
||||||
|
$package, $calling_package, $callback
|
||||||
|
);
|
||||||
|
|
||||||
my ($priority, $help_text, $data) = ( Xchat::PRI_NORM, undef, undef );
|
my ($priority, $help_text, $data) = ( Xchat::PRI_NORM, undef, undef );
|
||||||
_process_hook_options(
|
_process_hook_options(
|
||||||
@ -172,9 +181,11 @@ sub hook_print {
|
|||||||
my $event = shift;
|
my $event = shift;
|
||||||
my $callback = shift;
|
my $callback = shift;
|
||||||
my $options = shift;
|
my $options = shift;
|
||||||
my $package = Xchat::Embed::find_pkg();
|
my ($package, $calling_package) = Xchat::Embed::find_pkg();
|
||||||
|
|
||||||
$callback = Xchat::Embed::fix_callback( $package, $callback );
|
$callback = Xchat::Embed::fix_callback(
|
||||||
|
$package, $calling_package, $callback
|
||||||
|
);
|
||||||
|
|
||||||
my ($priority, $run_after, $filter, $data) = ( Xchat::PRI_NORM, 0, 0, undef );
|
my ($priority, $run_after, $filter, $data) = ( Xchat::PRI_NORM, 0, 0, undef );
|
||||||
_process_hook_options(
|
_process_hook_options(
|
||||||
@ -247,9 +258,11 @@ sub hook_print {
|
|||||||
sub hook_timer {
|
sub hook_timer {
|
||||||
return undef unless @_ >= 2;
|
return undef unless @_ >= 2;
|
||||||
my ($timeout, $callback, $data) = @_;
|
my ($timeout, $callback, $data) = @_;
|
||||||
my $package = Xchat::Embed::find_pkg();
|
my ($package, $calling_package) = Xchat::Embed::find_pkg();
|
||||||
|
|
||||||
$callback = Xchat::Embed::fix_callback( $package, $callback );
|
$callback = Xchat::Embed::fix_callback(
|
||||||
|
$package, $calling_package, $callback
|
||||||
|
);
|
||||||
|
|
||||||
if(
|
if(
|
||||||
ref( $data ) eq 'HASH' && exists( $data->{data} )
|
ref( $data ) eq 'HASH' && exists( $data->{data} )
|
||||||
@ -272,8 +285,10 @@ sub hook_fd {
|
|||||||
my $fileno = fileno $fd;
|
my $fileno = fileno $fd;
|
||||||
return undef unless defined $fileno; # no underlying fd for this handle
|
return undef unless defined $fileno; # no underlying fd for this handle
|
||||||
|
|
||||||
my $package = Xchat::Embed::find_pkg();
|
my ($package, $calling_package) = Xchat::Embed::find_pkg();
|
||||||
$callback = Xchat::Embed::fix_callback( $package, $callback );
|
$callback = Xchat::Embed::fix_callback(
|
||||||
|
$package, $calling_package, $callback
|
||||||
|
);
|
||||||
|
|
||||||
my ($flags, $data) = (Xchat::FD_READ, undef);
|
my ($flags, $data) = (Xchat::FD_READ, undef);
|
||||||
_process_hook_options(
|
_process_hook_options(
|
||||||
|
@ -259,7 +259,7 @@ sub find_external_pkg {
|
|||||||
return @frame if $frame[0] !~ /(?:^IRC$|^Xchat)/;
|
return @frame if $frame[0] !~ /(?:^IRC$|^Xchat)/;
|
||||||
$level++;
|
$level++;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub find_pkg {
|
sub find_pkg {
|
||||||
@ -281,7 +281,7 @@ sub find_pkg {
|
|||||||
if( $frame[0] or $frame[1] ) {
|
if( $frame[0] or $frame[1] ) {
|
||||||
my $calling_package = $frame[0];
|
my $calling_package = $frame[0];
|
||||||
if( defined( my $owner = $owner_package{ $calling_package } ) ) {
|
if( defined( my $owner = $owner_package{ $calling_package } ) ) {
|
||||||
return $owner;
|
return ($owner, $calling_package);
|
||||||
}
|
}
|
||||||
|
|
||||||
$location = $frame[1] ? $frame[1] : "package $frame[0]";
|
$location = $frame[1] ? $frame[1] : "package $frame[0]";
|
||||||
@ -294,10 +294,16 @@ sub find_pkg {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# convert function names into code references
|
||||||
sub fix_callback {
|
sub fix_callback {
|
||||||
my ($package, $callback) = @_;
|
my ($package, $calling_package, $callback) = @_;
|
||||||
|
|
||||||
unless( ref $callback ) {
|
unless( ref $callback ) {
|
||||||
|
unless( $callback =~ /::/ ) {
|
||||||
|
my $prefix = defined $calling_package ? $calling_package : $package;
|
||||||
|
$callback =~ s/^/${prefix}::/;
|
||||||
|
}
|
||||||
|
|
||||||
no strict 'subs';
|
no strict 'subs';
|
||||||
$callback = \&{$callback};
|
$callback = \&{$callback};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user