Add method to generate the prototype lookup hash
authorSteffen Mueller <smueller@cpan.org>
Fri, 11 Feb 2011 15:50:12 +0000 (16:50 +0100)
committerSteffen Mueller <smueller@cpan.org>
Tue, 12 Jul 2011 18:54:48 +0000 (20:54 +0200)
Akin to the methods in the parent commit that generate the lookup hash
for TYPEMAP/INPUT/OUTPUT, this method will generate the lookup has for
typemap's prototypes as required by ExtUtils::ParseXS at this time.

dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm

index dc9e5b9..c2f0687 100644 (file)
@@ -653,6 +653,38 @@ sub _get_outputmap_hash {
   return \%rv;
 }
 
+=head2 _get_prototype_hash
+
+Returns a hash mapping the C types of the typemap to their
+corresponding prototypes.
+
+  {
+    'char **' => '$',
+    'bool_t' => '$',
+    'AV *' => '$',
+    'InputStream' => '$',
+    'double' => '$',
+    # ...
+  }
+
+This is documented because it is used by C<ExtUtils::ParseXS>,
+but it's not intended for general consumption. May be removed
+at any time.
+
+=cut
+
+sub _get_prototype_hash {
+  my $self = shift;
+  my $lookup  = $self->{typemap_lookup};
+  my $storage = $self->{typemap_section};
+
+  my %rv;
+  foreach my $ctype (keys %$lookup) {
+    $rv{$ctype} = $storage->[ $lookup->{$ctype} ]->proto || '$';
+  }
+
+  return \%rv;
+}