| 1 | # Copyright (c) 1997-2007 Graham Barr <gbarr@pobox.com>. All rights reserved. | ||
| 2 | # This program is free software; you can redistribute it and/or | ||
| 3 | # modify it under the same terms as Perl itself. | ||
| 4 | # | ||
| 5 | # Maintained since 2013 by Paul Evans <leonerd@leonerd.org.uk> | ||
| 6 | # Since 2015 unauthorized by Reini Urban for cperl (binary names, utf8, lexical $_, ...) | ||
| 7 | |||
| 8 | package Scalar::Util; | ||
| 9 | |||
| 10 | use strict; | ||
| 11 | use warnings; | ||
| 12 | require Exporter; | ||
| 13 | |||
| 14 | our @ISA = qw(Exporter); | ||
| 15 | our @EXPORT_OK = qw( | ||
| 16 | blessed refaddr reftype weaken unweaken isweak | ||
| 17 | |||
| 18 | dualvar isdual isvstring looks_like_number openhandle readonly set_prototype | ||
| 19 | tainted | ||
| 20 | ); | ||
| 21 | our $VERSION = "1.50_11"; | ||
| 22 | $VERSION = eval $VERSION; | ||
| 23 | |||
| 24 | require List::Util; # List::Util loads the XS | ||
| 25 | List::Util->VERSION( $VERSION ); # Ensure we got the right XS version (RT#100863) | ||
| 26 | |||
| 27 | our @EXPORT_FAIL; | ||
| 28 | |||
| 29 | unless (defined &weaken) { | ||
| 30 | push @EXPORT_FAIL, qw(weaken); | ||
| 31 | } | ||
| 32 | unless (defined &isweak) { | ||
| 33 | push @EXPORT_FAIL, qw(isweak isvstring); | ||
| 34 | } | ||
| 35 | unless (defined &isvstring) { | ||
| 36 | push @EXPORT_FAIL, qw(isvstring); | ||
| 37 | } | ||
| 38 | |||
| 39 | sub export_fail { | ||
| 40 | if (grep { /^(?:weaken|isweak)$/ } @_ ) { | ||
| 41 | require Carp; | ||
| 42 | Carp::croak("Weak references are not implemented in the version of perl"); | ||
| 43 | } | ||
| 44 | |||
| 45 | if (grep { /^isvstring$/ } @_ ) { | ||
| 46 | require Carp; | ||
| 47 | Carp::croak("Vstrings are not implemented in the version of perl"); | ||
| 48 | } | ||
| 49 | |||
| 50 | @_; | ||
| 51 | } | ||
| 52 | |||
| 53 | # set_prototype has been moved to Sub::Util with a different interface | ||
| 54 | sub set_prototype(&$) | ||
| 55 | { | ||
| 56 | my ( $code, $proto ) = @_; | ||
| 57 | return Sub::Util::set_prototype( $proto, $code ); | ||
| 58 | } | ||
| 59 | |||
| 60 | 1; | ||
| 61 | |||
| 62 | __END__ |