Parser/Types.pm

filter: Statementstmt 84.8% 67 / 79 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.0% 21 / 25 Podpod 0.0% 0 / 4 totaltotal 81.4% 88 / 108 CC 1 SCAR 1.5
CC
1
Cov
85%
to_name
2.0
to_id
2.0
read_method
2.0
CRAP 1.2
« IDL/Type/List.pm ↑ Summary Parser.pm »
1 package Thrift::Parser::Types;
2  
3 =head1 NAME
4  
5 Thrift::Parser::Types - stores some common type ids
6  
7 =head1 DESCRIPTION
8  
9 This is not documented, as it's behavior will probably change as more type data is incorporated into this from the L<Thrift> libraries.
10  
11 =cut
12  
13 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 6 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 6 ▶use Thrift::Parser::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 6 ▶use Thrift::Parser::Type::Struct;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 6 ▶use Thrift::Parser::Type::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 6 ▶use Thrift::Parser::Type::Enum;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 6 ▶use Thrift::Parser::Type::Container;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 6 ▶use Thrift::Parser::Type::list;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 6 ▶use Thrift::Parser::Type::map;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 6 ▶use Thrift::Parser::Type::set;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 6 ▶use Thrift::Parser::Type::Number;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 6 ▶use Thrift::Parser::Type::byte;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 6 ▶use Thrift::Parser::Type::i16;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 6 ▶use Thrift::Parser::Type::i32;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 6 ▶use Thrift::Parser::Type::i64;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 6 ▶use Thrift::Parser::Type::double;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 6 ▶use Thrift::Parser::Type::string;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 6 ▶use Thrift::Parser::Type::binary;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 6 ▶use Thrift::Parser::Type::bool;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 6 ▶use Thrift::Parser::Type::void;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 6 my %types = (
42 STOP => 0,
43 VOID => 1,
44 BOOL => 2,
45 BYTE => 3,
46 I08 => 3,
47 DOUBLE => 4,
48 I16 => 6,
49 I32 => 8,
50 I64 => 10,
51 STRING => 11,
52 UTF7 => 11,
53 STRUCT => 12,
54 EXCEPTION => 12,
55 MAP => 13,
56 SET => 14,
57 LIST => 15,
58 UTF8 => 16,
59 UTF16 => 17,
60 );
61 6 my %types_by_id = (reverse %types);
62  
63 0 ▶sub to_name {
Subroutine to_name: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my ($class, $id) = @_;
65 0 return $types_by_id{$id};
66 }
67  
68 0 ▶sub to_id {
Subroutine to_id: not called CC=1 SCAR=6.9
Pod undocumented
69 0 my ($class, $name) = @_;
70 0 return $types{uc $name};
71 }
72  
73 0 ▶sub read_method {
Subroutine read_method: not called CC=1 SCAR=6.9
Pod undocumented
74 0 my ($class, $id) = @_;
75  
76 # Grab the name with proper case ('String')
77 0 my $name = lc $class->to_name($id);
78 0 $name =~ s{^(.+)$}{\u$1};
79  
80 0 return 'read' . $name;
81 }
82  
83 0 ▶sub write_method {
Subroutine write_method: not called CC=1 SCAR=6.9
Pod undocumented
84 0 my ($class, $id) = @_;
85  
86 # Grab the name with proper case ('String')
87 0 my $name = lc $class->to_name($id);
88 0 $name =~ s{^(.+)$}{\u$1};
89  
90 0 return 'write' . $name;
91 }
92  
93 =head1 COPYRIGHT
94  
95 Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
96  
97 The full text of the license can be found in the LICENSE file included with this module.
98  
99 =head1 AUTHOR
100  
101 Eric Waters <ewaters@gmail.com>
102  
103 =cut
104  
105 6 1;
106  
107 6 1;
« IDL/Type/List.pm ↑ Summary Parser.pm »