File Coverage

blib/lib/Tangence/Meta/Method.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 3 3 100.0
total 23 23 100.0


line stmt bran cond sub pod time code
1             # You may distribute under the terms of either the GNU General Public License
2             # or the Artistic License (the same terms as Perl itself)
3             #
4             # (C) Paul Evans, 2011-2024 -- leonerd@leonerd.org.uk
5              
6 15     15   230 use v5.26;
  15         147  
7 15     15   96 use warnings;
  15         35  
  15         1094  
8 15     15   101 use Object::Pad 0.800 ':experimental(adjust_params)';
  15         133  
  15         872  
9              
10             package Tangence::Meta::Method 0.33;
11             class Tangence::Meta::Method :strict(params);
12              
13             =head1 NAME
14              
15             C - structure representing one C method
16              
17             =head1 DESCRIPTION
18              
19             This data structure object stores information about one L class
20             method. Once constructed, such objects are immutable.
21              
22             =cut
23              
24             =head1 CONSTRUCTOR
25              
26             =cut
27              
28             =head2 new
29              
30             $method = Tangence::Meta::Method->new( %args )
31              
32             Returns a new instance initialised by the given arguments.
33              
34             =over 8
35              
36             =item class => Tangence::Meta::Class
37              
38             Reference to the containing class
39              
40             =item name => STRING
41              
42             Name of the method
43              
44             =item arguments => ARRAY
45              
46             Optional ARRAY reference containing arguments as
47             L references.
48              
49             =item ret => STRING
50              
51             Optional string giving the return value type as a L
52             reference
53              
54             =back
55              
56             =cut
57              
58 1     1 1 1298 field $class :param :weak :reader;
  1         8  
59 4     4 1 14302 field $name :param :reader;
  4         51  
60             field @arguments;
61 62     62 1 1914 field $ret :param :reader;
  62         2324  
62              
63             ADJUST :params (
64             :$arguments = undef,
65             ) {
66             @arguments = $arguments->@* if $arguments;
67             }
68              
69             =head1 ACCESSORS
70              
71             =cut
72              
73             =head2 class
74              
75             $class = $method->class
76              
77             Returns the class the method is a member of
78              
79             =cut
80              
81             =head2 name
82              
83             $name = $method->name
84              
85             Returns the name of the class
86              
87             =cut
88              
89             =head2 arguments
90              
91             @arguments = $method->arguments
92              
93             Return the arguments in a list of L references.
94              
95             =cut
96              
97             method arguments { @arguments }
98              
99             =head2 argtype
100              
101             @argtypes = $method->argtypes
102              
103             Return the argument types in a list of L references.
104              
105             =cut
106              
107             method argtypes
108             {
109             return map { $_->type } @arguments;
110             }
111              
112             =head2 ret
113              
114             $ret = $method->ret
115              
116             Returns the return type as a L reference or C if
117             the method does not return a value.
118              
119             =cut
120              
121             =head1 AUTHOR
122              
123             Paul Evans
124              
125             =cut
126              
127             0x55AA;