This repository has been archived by the owner on Jul 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PIFiller.pm
147 lines (92 loc) · 3.28 KB
/
PIFiller.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package PIFiller;
=head1 NAME
PIFiller (pif)
=head1 DESCRIPTION
This class is an abstract class whose subclasses provide methods to
process the PIs for a given template.
Subclasses of this class inherit the PI_handler Perl attribute handler
herein which populates class data with the name of the PI handled and
the coderef of the handler method for later binding to the PIs in a
given template.
=head1 SYNOPSIS
The naming convention is
sub "handle_" . SOME_PI_NAME . "_PI" : PI_handler(SOME_PI_NAME)
So the COLL_LIST PI handler in an implementation of the PIFiller class
would be declared like this
sub handle_COLL_LIST_PI : PI_handler(COLL_LIST)
{
my $self = shift;
...
}
=head1 METHODS
=over 8
=cut
BEGIN
{
if ( $ENV{'HT_DEV'} )
{
require "strict.pm";
strict::import();
}
}
use Attribute::Handlers;
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;
return $self;
}
# ---------------------------------------------------------------------
=item PI_handler : ATTR
Record the occurrence of a PI handler definition in a Action subclass
in the %PI_to_handler_map
PI handlers in subclasses of Root should be declared as described in the SYNOPSIS
Note: this very special subroutine runs very early in the CHECK phase
of compilation. It is called by Perl not by the application as such.
=cut
# ---------------------------------------------------------------------
my %PI_to_handler_map;
sub PI_handler
:ATTR
{
my ($package, $symbol, $PI_handler, $attr, $PI_name, $phase) = @_;
$PI_name = $PI_name->[0] if ( ref($PI_name) eq 'ARRAY' );
$PI_to_handler_map{$PI_name} = $PI_handler;
}
# ---------------------------------------------------------------------
=item get_PI_handler_mapping
Return the map (hash) of PIs to PI handler code references. Each PI
handler must use the special ATTR syntax to define which PI is is
designed to handle.
=cut
# ---------------------------------------------------------------------
sub get_PI_handler_mapping
{
my $self = shift;
my $C = shift;
return \%PI_to_handler_map;
}
1;
__END__
=head1 AUTHOR
Phillip Farber, University of Michigan, [email protected]
=head1 COPYRIGHT
Copyright 2007 ©, The Regents of The University of Michigan, All Rights Reserved
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
=cut