File Coverage

blib/lib/SOAP/WSDL/XSD/Typelib/Builtin/anySimpleType.pm
Criterion Covered Total %
statement 42 42 100.0
branch 8 8 100.0
condition 5 5 100.0
subroutine 13 13 100.0
pod 0 6 0.0
total 68 74 91.8


line stmt bran cond sub pod time code
1             package SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType;
2 84     84   1539 use strict;
  84         161  
  84         2952  
3 84     84   452 use warnings;
  84         212  
  84         2831  
4 84     84   1631 use Class::Std::Fast::Storable constructor => 'none', cache => 1;
  84         20266  
  84         641  
5 84     84   458350 use SOAP::WSDL::XSD::Typelib::Builtin::anyType;
  84         239  
  84         2532  
6 84     84   481 use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anyType);
  84         182  
  84         36228  
7              
8             my %value_of :ATTR(:get :init_arg :default<()>);
9              
10             # don't you never dare to play with this !
11             our $___value = \%value_of;
12              
13             ## use $_[n] for speed - we get called zillions of times...
14             # and we don't need to return the last value...
15 72     72 0 13486 sub set_value { $value_of{ ${ $_[0] } } = $_[1] }
  72         4646  
16              
17             # Default attribute handling
18             # TODO add something for handling default attributes
19 1     1 0 37 sub attr {
20             }
21              
22             # use $_[n] for speed.
23             # This is less readable, but notably faster.
24             #
25             # use postfix-if for speed. This is slightly faster, as it saves
26             # perl from creating a pad (variable context).
27             #
28             # The methods below may get called zillions of times, so
29             # every little statement matters...
30              
31             sub serialize {
32 7   100 7 0 2415 $_[1] ||= {};
33 7 100       12 if (not defined $value_of{ ${$_[0]} }) {
  7         27  
34 3         6 return $_[0]->start_tag({ %{ $_[1] }, nil => 1 }, undef);
  3         17  
35             }
36 4         24 return join q{}
37 4         24 , $_[0]->start_tag($_[1], $value_of{ ${$_[0]} })
38 4         10 , $value_of{ ${$_[0]} }
39             , $_[0]->end_tag($_[1]);
40             }
41              
42             sub as_string :STRINGIFY {
43 91 100   91 0 45999 return defined($value_of { ${ $_[0] } }) ? $value_of { ${ $_[0] } } : q{};
  91         427  
  89         819  
44 84     84   523 }
  84         154  
  84         542  
45              
46             sub as_bool :BOOLIFY {
47 15     15 0 1136 return $value_of { ${ $_[0] } };
  15         93  
48 84     84   18349 }
  84         192  
  84         427  
49              
50             my $OBJECT_CACHE_REF = Class::Std::Fast::OBJECT_CACHE_REF();
51              
52             sub new {
53 200     200 0 66293 my $self = pop @{ $OBJECT_CACHE_REF->{ $_[0] } };
  200         990  
54 200 100       1121 $self = bless \(my $o = Class::Std::Fast::ID()), $_[0]
55             if not defined $self;
56             $value_of{ $$self } = $_[1]->{ value }
57 200 100 100     8969 if (($#_) && exists $_[1]->{ value });
58 200         788 return $self;
59             }
60              
61             Class::Std::initialize(); # make :BOOLIFY overloading serializable
62              
63             1;