File Coverage

blib/lib/Convert/Binary/C.pm
Criterion Covered Total %
statement 34 34 100.0
branch 9 10 90.0
condition 3 3 100.0
subroutine 6 6 100.0
pod n/a
total 52 53 98.1


line stmt bran cond sub pod time code
1             ################################################################################
2             #
3             # MODULE: Convert::Binary::C
4             #
5             ################################################################################
6             #
7             # DESCRIPTION: Convert::Binary::C Perl extension module
8             #
9             ################################################################################
10             #
11             # Copyright (c) 2002-2024 Marcus Holland-Moritz. All rights reserved.
12             # This program is free software; you can redistribute it and/or modify
13             # it under the same terms as Perl itself.
14             #
15             ################################################################################
16              
17             package Convert::Binary::C;
18              
19 61     61   2745257 use strict;
  61         128  
  61         2649  
20 61     61   442 use DynaLoader;
  61         258  
  61         1719  
21 61     61   300 use Carp;
  61         113  
  61         4894  
22 61     61   340 use vars qw( @ISA $VERSION $AUTOLOAD );
  61         195  
  61         36510  
23              
24             @ISA = qw(DynaLoader);
25              
26             $VERSION = '0.86';
27              
28             bootstrap Convert::Binary::C $VERSION;
29              
30             # Unfortunately, XS AUTOLOAD isn't supported
31             # by stable perl distributions before 5.8.0.
32              
33             sub AUTOLOAD
34             {
35 6227     6227   20494035 my $self = shift;
36 6227         12894 my $opt = $AUTOLOAD;
37 6227 50       20222 ref $self or croak "$self is not an object";
38 6227         44213 $opt =~ s/.*://;
39 6227 100       27447 $opt =~ /^[A-Z]/ or croak "Invalid method $opt called";
40 6226 100       16793 @_ <= 1 or croak "$opt cannot take more than one argument";
41 6225 100 100     16435 unless (@_ or defined wantarray) {
42 21         2362 carp "Useless use of $opt in void context";
43 21         180 return;
44             }
45 6204         9549 my @warn;
46             {
47 6204     4   8778 local $SIG{__WARN__} = sub { push @warn, $_[0] };
  6204         47272  
  4         27  
48 6204         12166 $opt = eval { $self->configure( $opt, @_ ) };
  6204         77435  
49             }
50 6204         15629 for my $w (@warn) {
51 4         35 $w =~ s/\s+at.*?C\.pm.*//s;
52 4         582 carp $w;
53             }
54 6204 100       14814 if ($@) {
55 210         1898 $@ =~ s/\s+at.*?C\.pm.*//s;
56 210         28499 croak $@;
57             }
58 5994         23020 $opt;
59             }
60              
61             1;
62              
63             __END__