1- package attributes ;
1+ package attributes 0.37 ;
22
3- our $VERSION = 0.36 ;
3+ use v5.40 ;
44
5- @EXPORT_OK = qw( get reftype) ;
6- @EXPORT = ();
7- %EXPORT_TAGS = (ALL => [@EXPORT , @EXPORT_OK ]);
5+ our @EXPORT_OK = qw( get reftype) ;
6+ our @EXPORT = ();
7+ our %EXPORT_TAGS = (ALL => [@EXPORT , @EXPORT_OK ]);
88
9- use strict;
9+ # Older versions of this module provided a `reftype` in attributes.xs, and
10+ # there may exist code out there that relies on being able to find it.
11+ *reftype = \&builtin::reftype;
1012
1113sub croak {
1214 require Carp;
@@ -28,27 +30,24 @@ my %msg = (
2830 const => ' Useless use of attribute "const"' ,
2931);
3032
31- sub _modify_attrs_and_deprecate {
32- my $svtype = shift ;
33+ my sub modify_attrs_and_deprecate ($svtype , @args ) {
3334 # After we've removed a deprecated attribute from the XS code, we need to
3435 # remove it here, else it ends up in @badattrs. (If we do the deprecation in
3536 # XS, we can't control the warning based on *our* caller's lexical settings,
3637 # and the warned line is in this package)
3738 grep {
3839 $deprecated {$svtype } && / $deprecated {$svtype }/ ? do {
39- require warnings;
4040 warnings::warnif(' deprecated' , " Attribute \" $1 \" is deprecated, " .
4141 " and will disappear in Perl 5.28" );
4242 0;
4343 } : $svtype eq ' CODE' && exists $msg {$_ } ? do {
44- require warnings;
4544 warnings::warnif(
4645 ' misc' ,
4746 $msg {$_ }
4847 );
4948 0;
5049 } : 1
51- } _modify_attrs(@_ );
50+ } _modify_attrs(@args );
5251}
5352
5453sub import {
@@ -64,7 +63,7 @@ sub import {
6463 if defined $home_stash && $home_stash ne ' ' ;
6564 my @badattrs ;
6665 if ($pkgmeth ) {
67- my @pkgattrs = _modify_attrs_and_deprecate ($svtype , $svref , @attrs );
66+ my @pkgattrs = modify_attrs_and_deprecate ($svtype , $svref , @attrs );
6867 @badattrs = $pkgmeth -> ($home_stash , $svref , @pkgattrs );
6968 if (!@badattrs && @pkgattrs ) {
7069 require warnings;
@@ -82,7 +81,7 @@ sub import {
8281 }
8382 }
8483 else {
85- @badattrs = _modify_attrs_and_deprecate ($svtype , $svref , @attrs );
84+ @badattrs = modify_attrs_and_deprecate ($svtype , $svref , @attrs );
8685 }
8786 if (@badattrs ) {
8887 croak " Invalid $svtype attribute" .
@@ -92,13 +91,11 @@ sub import {
9291 }
9392}
9493
95- sub get ($ ) {
96- @_ == 1 && ref $_ [0] or
94+ sub get :prototype( $) ( $svref ) {
95+ ref $svref or
9796 croak ' Usage: ' .__PACKAGE__ .' ::get $ref' ;
98- my $svref = shift ;
9997 my $svtype = uc reftype($svref );
100- my $stash = _guess_stash($svref );
101- $stash = caller unless defined $stash ;
98+ my $stash = _guess_stash($svref ) // scalar caller ;
10299 my $pkgmeth ;
103100 $pkgmeth = UNIVERSAL::can($stash , " FETCH_${svtype} _ATTRIBUTES" )
104101 if defined $stash && $stash ne ' ' ;
@@ -113,7 +110,6 @@ sub require_version { goto &UNIVERSAL::VERSION }
113110require XSLoader;
114111XSLoader::load();
115112
116- 1;
117113__END__
118114#The POD goes here
119115
@@ -295,9 +291,11 @@ Otherwise, only L<built-in attributes|"Built-in Attributes"> will be returned.
295291
296292=item reftype
297293
298- This routine expects a single parameter--a reference to a subroutine or
299- variable. It returns the built-in type of the referenced variable,
300- ignoring any package into which it might have been blessed.
294+ This is an alias to L<builtin::reftype|builtin/reftype> . It is maintained
295+ here for backward compatibility for any code that expected to be able to call
296+ it from this module. Newly-written code should use the function from the
297+ L<builtin> module directly.
298+
301299This can be useful for determining the I<type > value which forms part of
302300the method names described in L<"Package-specific Attribute Handling"> below.
303301
0 commit comments