1ModPerl::Code(3) User Contributed Perl Documentation ModPerl::Code(3)
2
3
4
6 $class\::Const - Perl Interface for $class Constants
7
10 EOF
11
12 my $groups = $data{$class};
13 for my $group (sort keys %$groups) {
14 print $fh <<"EOF";
15
16 ":$group"
17 use $class\::Const -compile qw(:$group);
18
19 The ":$group" group is for XXX constants.
20
21 EOF
22
23 for my $const (sort @{ $groups->{$group} }) {
24 print $fh "=head3 C<$class\::$const>\n\n\n";
25 }
26 }
27
28 print $fh "=cut\n";
29 }
30 }
31
32 sub generate_constants_lookup_doc {
33 my ($data) = @_;
34
35 while (my ($class, $groups) = each %$Apache2::ConstantsTable) {
36 my $constants = [map { @$_ } values %$groups];
37
38 constants_lookup_code_doc($constants, $class, $data);
39 }
40 }
41
42 sub generate_constants_group_lookup_doc {
43 my ($data) = @_;
44
45 while (my ($class, $groups) = each %$Apache2::ConstantsTable) {
46 constants_group_lookup_code_doc($class, $groups, $data);
47 }
48 }
49
50 sub constants_group_lookup_code_doc {
51 my ($class, $groups, $data) = @_;
52 my @tags;
53 my @code;
54
55 while (my ($group, $constants) = each %$groups) {
56 $data->{$class}{$group} = [
57 map {
58 my @ifdef = constants_ifdef($_);
59 s/^($constant_prefixes)_?//o;
60 $seen_const{$class}{$_}++;
61 $_;
62 } @$constants
63 ];
64 }
65 }
66
67 sub constants_lookup_code_doc {
68 my ($constants, $class, $data) = @_;
69
70 my (%switch, %alias);
71
72 %alias = %shortcuts;
73
74 my $postfix = lc $class;
75 my $package = $class . '::';
76 my $package_len = length $package;
77
78 my $func = canon_func(qw(constants lookup), $postfix);
79
80 for (@$constants) {
81 if (s/^($constant_prefixes)(_)?//o) {
82 $alias{$_} = join $2 || "", $1, $_;
83 }
84 else {
85 $alias{$_} ||= $_;
86 }
87 next unless /^([A-Z])/;
88 push @{ $switch{$1} }, $_;
89 }
90
91 for my $key (sort keys %switch) {
92 my $names = $switch{$key};
93 for my $name (@$names) {
94 my @ifdef = constants_ifdef($alias{$name});
95 push @{ $data->{$class}{other} }, $name
96 unless $seen_const{$class}{$name}
97 }
98 }
99 }
100
101 sub generate_exports {
102 my ($self, $c_fh) = @_;
103 require ModPerl::WrapXS;
104 ModPerl::WrapXS->generate_exports($c_fh); }
105
106 # src/modules/perl/*.c files needed to build APR/APR::* outside # of
107 mod_perl.so sub src_apr_ext {
108 return map { "modperl_$_" } (qw(error bucket),
109 map { "common_$_" } qw(util log)); }
110
111 1; __END__
112
114 ModPerl::Code - Generate mod_perl glue code
115
117 use ModPerl::Code ();
118 my $code = ModPerl::Code->new;
119 $code->generate;
120
122 This module provides functionality for generating mod_perl glue code.
123 Reason this code is generated rather than written by hand include:
124
125 consistency
126 thin and clean glue code
127 enable/disable features (without #ifdefs)
128 adapt to changes in Apache
129 experiment with different approaches to gluing
130
132 Doug MacEachern
133
134
135
136perl v5.10.1 2007-12-31 ModPerl::Code(3)