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, 2012-2022 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
189
|
use v5.26; |
|
15
|
|
|
|
|
53
|
|
7
|
15
|
|
|
15
|
|
83
|
use Object::Pad 0.66 ':experimental(init_expr)'; |
|
15
|
|
|
|
|
189
|
|
|
15
|
|
|
|
|
111
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Tangence::Meta::Struct 0.30; |
10
|
|
|
|
|
|
|
class Tangence::Meta::Struct :strict(params); |
11
|
|
|
|
|
|
|
|
12
|
15
|
|
|
15
|
|
5599
|
use Carp; |
|
15
|
|
|
|
|
34
|
|
|
15
|
|
|
|
|
9352
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
C - structure representing one C structure |
17
|
|
|
|
|
|
|
type |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This data structure stores information about one L structure type. |
22
|
|
|
|
|
|
|
Once constructed and defined, such objects are immutable. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 new |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$struct = Tangence::Meta::Struct->new( name => $name ) |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Returns a new instance representing the given name. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
12
|
|
|
12
|
1
|
42
|
field $name :param :reader; |
|
12
|
|
|
|
|
82
|
|
39
|
555
|
|
|
555
|
1
|
876
|
field $defined :reader { 0 }; |
|
555
|
|
|
|
|
1255
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
field @fields; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 define |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$struct->define( %args ) |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Provides a definition for the structure. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=over 8 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item fields => ARRAY |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
ARRAY reference containing metadata about the structure's fields, as instances |
54
|
|
|
|
|
|
|
of L. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=back |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
68
|
|
|
|
|
118
|
method define ( %args ) |
|
68
|
|
|
|
|
143
|
|
|
68
|
|
|
|
|
99
|
|
61
|
68
|
|
|
68
|
1
|
167
|
{ |
62
|
68
|
50
|
|
|
|
204
|
$defined and croak "Cannot define $name twice"; |
63
|
|
|
|
|
|
|
|
64
|
68
|
|
|
|
|
105
|
$defined++; |
65
|
68
|
|
|
|
|
100
|
@fields = @{ $args{fields} }; |
|
68
|
|
|
|
|
240
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 ACCESSORS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 defined |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$defined = $struct->defined |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Returns true if a definition of the structure has been provided using |
77
|
|
|
|
|
|
|
C. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 name |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$name = $struct->name |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Returns the name of the structure |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 fields |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
@fields = $struct->fields |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns a list of the fields defined on the structure, in their order of |
94
|
|
|
|
|
|
|
definition. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
method fields |
99
|
553
|
|
|
553
|
1
|
1022
|
{ |
100
|
553
|
50
|
|
|
|
1036
|
$self->defined or croak $self->name . " is not yet defined"; |
101
|
553
|
|
|
|
|
1414
|
return @fields; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Paul Evans |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
0x55AA; |