diff --git a/var/tmp/source/LAWALSH/Types-Core-0.1.4/Types-Core-0.1.4/Changes b/var/tmp/source/LAWALSH/Types-Core-0.1.4/Types-Core-0.1.4/Changes
deleted file mode 100644
index e69de29b..00000000
@@ -4,7 +4,7 @@
"LAWALSH (LAWALSH@cpan.org)"
],
"dynamic_config" : 1,
- "generated_by" : "ExtUtils::MakeMaker version 6.82, CPAN::Meta::Converter version 2.132830",
+ "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150005",
"license" : [
"unknown"
],
@@ -22,7 +22,7 @@
"prereqs" : {
"build" : {
"requires" : {
- "ExtUtils::MakeMaker" : "v6.8.2"
+ "ExtUtils::MakeMaker" : "6.86"
}
},
"configure" : {
@@ -32,11 +32,12 @@
},
"runtime" : {
"requires" : {
- "Xporter" : "v0.0.7",
- "mem" : "v0.4.3"
+ "Xporter" : "v0.0.8",
+ "mem" : "v0.4.5"
}
}
},
"release_status" : "stable",
- "version" : "v0.1.4"
+ "version" : "v0.1.5",
+ "x_serialization_backend" : "JSON::PP version 2.27300"
}
@@ -3,21 +3,22 @@ abstract: 'Ease-of-use functions for perl core Types'
author:
- 'LAWALSH (LAWALSH@cpan.org)'
build_requires:
- ExtUtils::MakeMaker: v6.8.2
+ ExtUtils::MakeMaker: '6.86'
configure_requires:
- ExtUtils::MakeMaker: 0
+ ExtUtils::MakeMaker: '0'
dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.82, CPAN::Meta::Converter version 2.132830'
+generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150005'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
+ version: '1.4'
name: Types-Core
no_index:
directory:
- t
- inc
requires:
- Xporter: v0.0.7
- mem: v0.4.3
-version: v0.1.4
+ Xporter: v0.0.8
+ mem: v0.4.5
+version: v0.1.5
+x_serialization_backend: 'CPAN::Meta::YAML version 0.016'
@@ -8,8 +8,8 @@ WriteMakefile(
VERSION_FROM => 'lib/Types/Core.pm', # finds \$VERSION
AUTHOR => 'LAWALSH (LAWALSH@cpan.org)',
ABSTRACT => 'Ease-of-use functions for perl core Types',
- BUILD_REQUIRES=> { 'ExtUtils::MakeMaker' => '6.8.2', },
+ BUILD_REQUIRES=> { 'ExtUtils::MakeMaker' => '6.86', },
PREREQ_PM => {
- 'mem' => '0.4.3',Xporter => '0.0.7',
+ 'mem' => '0.4.5',Xporter => '0.0.8',
},
);
@@ -9,17 +9,21 @@ Types::Core - Core types defined as tests and literals (ease of use)
=head1 VERSION
-Version "0.1.4";
+Version "0.1.5";
=cut
+
{ package Types::Core;
use strict;
+ use warnings;
use mem;
- our $VERSION='0.1.4';
-
+ our $VERSION='0.1.5';
+# 0.1.5 - Added code and test case to handle type-named classes
+# - use Scalar::Utils for blessed and 'ref' if available.
+#
# 0.1.4 - Add BUILD_REQ for more modern Ext:MM
# 0.1.3 - investigate fails on perl 5.12.x:
# - changed prototypes on single arg tests to use '$' instead of '*';
@@ -53,26 +57,18 @@ Version "0.1.4";
# 0.0.2 - Export EhV by default (EXPORT_OK doesn't work reliably)
#}}}
- our (@TYPES, %TYPES, @EXPORT, @EXPORT_OK);
- use mem(@TYPES=qw(ARRAY CODE GLOB HASH IO REF SCALAR));
- use mem(%TYPES=&{sub () { map { ($_, $_) } @TYPES }});
- use mem(@EXPORT=(@TYPES,qw(EhV )),
- @EXPORT_OK=qw(typ blessed));
-
- #use P;
- #use Dbg(1,1,1);
- #TPe "types::EXPORT=%s",\@EXPORT;
-
+ our (@TYPES, @EXPORT, @EXPORT_OK, %type_lens);
+ BEGIN {
+ @TYPES = qw(ARRAY CODE GLOB HASH IO REF SCALAR);
+ %type_lens = map { ($_, length $_ ) } @TYPES;
+# @EXPORT = (@TYPES, q(EhV)); @EXPORT_OK = ( qw(typ blessed) );
+ }
+ use mem(@EXPORT=(@TYPES,qw(EhV )),
+ @EXPORT_OK=qw(typ blessed));
- # NOTE: this module should not "use P" (literally _use_)
- # or "P" can't "use" this mod.
- # but this mod makes use of P via direct call later on
- # eval 'use P;'; # this module should not "use P", or P can't use this mod.
+ # MAINT NOTE: this module must not "use P" (literally _use_)
+ # as "P" needs to use this mod (or dup the functionality)
- # see if we have this short-cut available
- #
- eval { require Scalar::Util };
- my $scalar_util_available = !$@;
sub subProto($) { my $subref = $_[0];
use B ();
@@ -84,29 +80,44 @@ Version "0.1.4";
use constant shortest_type => 'REF';
use constant last_let_offset => length(shortest_type)-1;
+ our $Use_Scalar_Util;
+
BEGIN {
- if ($scalar_util_available) {
- Scalar::Util->import('reftype') or die "Unexpected problem w/import: $@";
+ # see if we have some short-cuts available
+ #
+ eval { require Scalar::Util };
+ $Use_Scalar_Util = !$@;
+
+ if ($Use_Scalar_Util) {
eval '# line ' . __LINE__ .' '. __FILE__ .'
- sub _type ($) { reftype $_[0] }
- sub _isatype ($$) { (typ($_[0])//"") eq ($_[1]//"") ? $_[0] : undef }';
+ sub _type ($) { Scalar::Util::reftype $_[0] }
+ sub _isatype ($$) { (typ($_[0])//"") eq ($_[1]//"") ? $_[0] : undef };
+ sub blessed ($) { Scalar::Util::blessed($_[0]) ? $_[0] : undef }';
$@ && die "_isatype eval(1): $@";
} else {
- #old _type-> ($_[0] =~ m{^(?:[\w+]=)?([A-Z]+)\(})[0] }
+
eval '# line ' . __LINE__ .' '. __FILE__ .'
- sub _type ($) {
+ sub _type ($) { my $start;
my $end = index $_[0], "(";
- $end > '.last_let_offset.' || return undef; #shortest type=REF)
- substr $_[0], (rindex $_[0], "=", $end) + 1, $end
+ return undef unless $end > '. &last_let_offset .';
+ substr $_[0], $start=1+rindex($_[0], "=", $end), $end-$start;
}
sub _isatype($$) {
my ($var, $type) = @_;
- ref $var && (1 + index($var, $type)) ? $var : undef;
- }'; #end of eval
+ ref $var && (1 + index($var, $type."(" )) ? $var : undef;
+ }
+
+ sub blessed ($) { my $arg = $_[0]; my $tp;
+ my $ra = ref $arg;
+ $ra && !exists $type_lens{$ra} ? $arg : do {
+ my $len = $type_lens{$ra};
+ $ra."=" eq substr ("$arg", 0, $len+1) ? $arg : undef };
+ }
+ '; #end of eval
$@ && die "_isatype eval(2): $@";
}
}
@@ -287,9 +298,6 @@ with C<EhV>).
}
- sub blessed ($) { my $arg = $_[0];
- ref $arg && ! exists $TYPES{ref $arg} ? $arg : undef
- }
use Xporter;
1}