death
check_conditional_preprocessor_statements
escape_file_for_line_directive
+ report_typemap_failure
);
our @ISA = qw(Exporter);
if ($self->{var_num}) {
my $typemap = $self->{typemap}->get_typemap(ctype => $var_type);
- $self->death("Could not find a typemap for C type '$var_type'")
+ $self->report_typemap_failure($self->{typemap}, $var_type, "death")
if not $typemap and not $is_overridden_typemap;
$self->{proto_arg}->[$self->{var_num}] = ($typemap && $typemap->proto) || "\$";
}
my $typemaps = $self->{typemap};
$type = tidy_type($type);
- $self->blurt("Error: '$type' not in typemap"), return
+ $self->report_typemap_failure($typemaps, $type), return
unless $typemaps->get_typemap(ctype => $type);
($ntype = $type) =~ s/\s*\*/Ptr/g;
# Note: This gruesome bit either needs heavy rethinking or documentation. I vote for the former. --Steffen
if ($expr =~ /DO_ARRAY_ELEM/) {
my $subtypemap = $typemaps->get_typemap(ctype => $subtype);
- $self->blurt("Error: C type '$subtype' not in typemap"), return
+ $self->report_typemap_failure($typemaps, $subtype), return
if not $subtypemap;
my $subinputmap = $typemaps->get_inputmap(xstype => $subtypemap->xstype);
$self->blurt("Error: No INPUT definition for type '$subtype', typekind '" . $subtypemap->xstype . "' found"), return
print "\tSvSETMAGIC($arg);\n" if $do_setmagic;
}
else {
- my $typemap = $typemaps->get_typemap(ctype => $type);
- $self->blurt("Could not find a typemap for C type '$type'"), return
+ my $typemap = $typemaps->get_typemap(ctype => $type);
+ $self->report_typemap_failure($typemaps, $type), return
if not $typemap;
my $outputmap = $typemaps->get_outputmap(xstype => $typemap->xstype);
$self->blurt("Error: No OUTPUT definition for type '$type', typekind '" . $typemap->xstype . "' found"), return
my $expr = $outputmap->cleaned_code;
if ($expr =~ /DO_ARRAY_ELEM/) {
- my $subtypemap = $typemaps->get_typemap(ctype => $subtype);
- $self->blurt("Could not find a typemap for C type '$subtype'"), return
+ my $subtypemap = $typemaps->get_typemap(ctype => $subtype);
+ $self->report_typemap_failure($typemaps, $subtype), return
if not $subtypemap;
my $suboutputmap = $typemaps->get_outputmap(xstype => $subtypemap->xstype);
$self->blurt("Error: No OUTPUT definition for type '$subtype', typekind '" . $subtypemap->xstype . "' found"), return
death
check_conditional_preprocessor_statements
escape_file_for_line_directive
+ report_typemap_failure
);
=head1 NAME
death
check_conditional_preprocessor_statements
escape_file_for_line_directive
+ report_typemap_failure
);
=head1 SUBROUTINES
return $string;
}
+=head2 C<report_typemap_failure>
+
+=over 4
+
+=item * Purpose
+
+Do error reporting for missing typemaps.
+
+=item * Arguments
+
+The C<ExtUtils::ParseXS> object.
+
+An C<ExtUtils::Typemaps> object.
+
+The string that represents the C type that was not found in the typemap.
+
+Optionally, the string C<death> or C<blurt> to choose
+whether the error is immediately fatal or not. Default: C<blurt>
+
+=item * Return Value
+
+Returns nothing. Depending on the arguments, this
+may call C<death> or C<blurt>, the former of which is
+fatal.
+
+=back
+
+=cut
+
+sub report_typemap_failure {
+ my ($self, $tm, $ctype, $error_method) = @_;
+ $error_method ||= 'blurt';
+
+ my @avail_ctypes = $tm->list_mapped_ctypes;
+
+ my $err = "Could not find a typemap for C type '$ctype'.\n"
+ . "The following C types are mapped by the current typemap:\n'"
+ . join("', '", @avail_ctypes) . "'\n";
+
+ $self->$error_method($err);
+ return();
+}
1;