---
name: "ModPerl::Code"
section: "3pm"
platform: "linux"
package: "libapache2-mod-perl2"
version: "2.0.13-2+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/ModPerl::Code"
---

# ModPerl::Code(3pm)

Perl Interface for $class Constants

## NAME

$class\\::Const - Perl Interface for $class Constants

## SYNOPSIS

## CONSTANTS

EOF

```
        my $groups = $data{$class};
        for my $group (sort keys %$groups) {
            print $fh <<"EOF";
```

### ":$group"

```
  use $class\::Const -compile qw(:$group);
```

The `":$group"` group is for XXX constants.

EOF

```
            for my $const (sort @{ $groups->{$group} }) {
                print $fh "=head3 C<$class\::$const>\n\n\n";
            }
        }
        print $fh "=cut\n";
    }
}
```

sub generate\_constants\_lookup\_doc {\
     my ($data) = `@_`;

```
    foreach my $class (sort keys %$Apache2::ConstantsTable) {
        my $groups = $Apache2::ConstantsTable->{$class};
        my $constants = [sort map { @$_ } values %$groups];
        constants_lookup_code_doc($constants, $class, $data);
    }
}
```

sub generate\_constants\_group\_lookup\_doc {\
     my ($data) = `@_`;

```
    foreach my $class (sort keys %$Apache2::ConstantsTable) {
        my $groups = $Apache2::ConstantsTable->{$class};
        constants_group_lookup_code_doc($class, $groups, $data);
    }
}
```

sub constants\_group\_lookup\_code\_doc {\
     my ($class, `$groups`, `$data`) = `@_`;\
     my `@tags`;\
     my `@code`;

```
    while (my ($group, $constants) = each %$groups) {
        $data->{$class}{$group} = [
            map {
                my @ifdef = constants_ifdef($_);
                s/^($constant_prefixes)_?//o;
                $seen_const{$class}{$_}++;
                $_;
            } @$constants
        ];
    }
}
```

sub constants\_lookup\_code\_doc {\
     my ($constants, `$class`, `$data`) = `@_`;

```
    my (%switch, %alias);
    %alias = %shortcuts;
    my $postfix = lc $class;
    my $package = $class . '::';
    my $package_len = length $package;
    my $func = canon_func(qw(constants lookup), $postfix);
    for (@$constants) {
        if (s/^($constant_prefixes)(_)?//o) {
            $alias{$_} = join $2 || "", $1, $_;
        }
        else {
            $alias{$_} ||= $_;
        }
        next unless /^([A-Z])/;
        push @{ $switch{$1} }, $_;
    }
    for my $key (sort keys %switch) {
        my $names = $switch{$key};
        for my $name (@$names) {
            my @ifdef = constants_ifdef($alias{$name});
            push @{ $data->{$class}{other} }, $name
                unless $seen_const{$class}{$name}
        }
    }
}
```

sub generate\_exports {\
     my ($self, `$c_fh`) = `@_`;\
     require ModPerl::WrapXS;\
     ModPerl::WrapXS-\>generate\_exports($c\_fh); }

\# src/modules/perl/\*.c files needed to build APR/APR::\* outside # of mod\_perl.so sub src\_apr\_ext {\
     return map { "modperl\_$\_" } (qw(error bucket),\
                                   map { "common\_$\_" } qw(util log)); }

1; \_\_END\_\_

## NAME

ModPerl::Code - Generate mod\_perl glue code

## SYNOPSIS

```
  use ModPerl::Code ();
  my $code = ModPerl::Code->new;
  $code->generate;
```

## DESCRIPTION

This module provides functionality for generating mod\_perl glue code. Reason this code is generated rather than written by hand include:

- consistency

  - thin and clean glue code

  - enable/disable features (without #ifdefs)

  - adapt to changes in Apache

  - experiment with different approaches to gluing

  ## AUTHOR

Doug MacEachern
