You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by do...@apache.org on 2002/05/23 21:49:07 UTC
cvs commit: modperl-2.0/lib/ModPerl TypeMap.pm
dougm 02/05/23 12:49:07
Modified: lib/ModPerl TypeMap.pm
Log:
support typedefs which are not structure pointers
Revision Changes Path
1.17 +23 -9 modperl-2.0/lib/ModPerl/TypeMap.pm
Index: TypeMap.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/ModPerl/TypeMap.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- TypeMap.pm 14 May 2002 03:12:55 -0000 1.16
+++ TypeMap.pm 23 May 2002 19:49:07 -0000 1.17
@@ -11,7 +11,12 @@
sub new {
my $class = shift;
- my $self = bless { INCLUDE => [] }, $class;
+
+ my $self = bless {
+ INCLUDE => [],
+ struct => [],
+ typedef => [],
+ }, $class;
$self->{function_map} = ModPerl::FunctionMap->new,
$self->{structure_map} = ModPerl::StructureMap->new,
@@ -46,15 +51,19 @@
my($type, $class) = (split /\s*\|\s*/, $_)[0,1];
$class ||= 'UNDEFINED';
- if ($type =~ s/^struct\s+(.*)/$1/) {
- push @aliases,
- $type, "const $type", "$type *", "const $type *",
- "struct $type *", "const struct $type *",
- "$type **";
+ if ($type =~ s/^(struct|typedef)\s+(.*)/$2/) {
+ my $typemap = $1;
+ push @aliases, $type;
+
+ if ($typemap eq 'struct') {
+ push @aliases, "const $type", "$type *", "const $type *",
+ "struct $type *", "const struct $type *",
+ "$type **";
+ }
my $cname = $class;
- if ($cname =~ s/::/__/) {
- push @{ $self->{typedefs} }, [$type, $cname];
+ if ($cname =~ s/::/__/g) {
+ push @{ $self->{$typemap} }, [$type, $cname];
}
}
elsif ($type =~ /_t$/) {
@@ -408,9 +417,14 @@
$code .= qq{\#include "$_"\n}
}
- for my $t (@{ $self->{typedefs} }) {
+ for my $t (@{ $self->{struct} }) {
next if $seen{ $t->[1] }++;
$code .= "typedef $t->[0] * $t->[1];\n";
+ }
+
+ for my $t (@{ $self->{typedef} }) {
+ next if $seen{ $t->[1] }++;
+ $code .= "typedef $t->[0] $t->[1];\n";
}
$self->h_wrap('typedefs', $code);