When parsing typemaps from strings, we used to print in-string
line numbers and <string> as the file name. In case of embedded
typemaps in XS code, we really want to refer back to the line
number and name of the XS file. This is now possible.
sub _init {
my $self = shift;
if (defined $self->{string}) {
sub _init {
my $self = shift;
if (defined $self->{string}) {
- $self->_parse(\($self->{string}));
+ $self->_parse(\($self->{string}), $self->{lineno_offset}, $self->{fake_filename});
delete $self->{string};
}
elsif (defined $self->{file} and -e $self->{file}) {
delete $self->{string};
}
elsif (defined $self->{file} and -e $self->{file}) {
. $self->{file} . "' for reading: $!";
local $/ = undef;
my $string = <$fh>;
. $self->{file} . "' for reading: $!";
local $/ = undef;
my $string = <$fh>;
- $self->_parse(\$string, $self->{file});
+ $self->_parse(\$string, $self->{lineno_offset}, $self->{file});
sub _parse {
my $self = shift;
my $stringref = shift;
sub _parse {
my $self = shift;
my $stringref = shift;
+ my $lineno_offset = shift;
+ $lineno_offset = 0 if not defined $lineno_offset;
my $filename = shift;
$filename = '<string>' if not defined $filename;
my $filename = shift;
$filename = '<string>' if not defined $filename;
# TODO order of sections, multiple sections of same type
# Heavily influenced by ExtUtils::ParseXS
my $section = 'typemap';
# TODO order of sections, multiple sections of same type
# Heavily influenced by ExtUtils::ParseXS
my $section = 'typemap';
+ my $lineno = $lineno_offset;
my $junk = "";
my $current = \$junk;
my @input_expr;
my $junk = "";
my $current = \$junk;
my @input_expr;