+# Process "MODULE = Foo ..." lines and update global state accordingly
+sub _process_module_xs_line {
+ my ($self, $module, $pkg, $prefix) = @_;
+
+ ($self->{Module_cname} = $module) =~ s/\W/_/g;
+
+ $self->{Package} = defined($pkg) ? $pkg : '';
+ $self->{Prefix} = quotemeta( defined($prefix) ? $prefix : '' );
+
+ ($self->{Packid} = $self->{Package}) =~ tr/:/_/;
+
+ $self->{Packprefix} = $self->{Package};
+ $self->{Packprefix} .= "::" if $self->{Packprefix} ne "";
+
+ $self->{lastline} = "";
+}
+
+# Skip any embedded POD sections
+sub _maybe_skip_pod {
+ my ($self) = @_;
+
+ while ($self->{lastline} =~ /^=/) {
+ while ($self->{lastline} = readline($self->{FH})) {
+ last if ($self->{lastline} =~ /^=cut\s*$/);
+ }
+ $self->death("Error: Unterminated pod") unless defined $self->{lastline};
+ $self->{lastline} = readline($self->{FH});
+ chomp $self->{lastline};
+ $self->{lastline} =~ s/^\s+$//;
+ }
+}
+
+# This chunk of code strips out (and parses) embedded TYPEMAP blocks
+# which support a HEREdoc-alike block syntax.
+sub _maybe_parse_typemap_block {
+ my ($self) = @_;
+
+ # This is special cased from the usual paragraph-handler logic
+ # due to the HEREdoc-ish syntax.
+ if ($self->{lastline} =~ /^TYPEMAP\s*:\s*<<\s*(?:(["'])(.+?)\1|([^\s'"]+?))\s*;?\s*$/)
+ {
+ my $end_marker = quotemeta(defined($1) ? $2 : $3);
+
+ # Scan until we find $end_marker alone on a line.
+ my @tmaplines;
+ while (1) {
+ $self->{lastline} = readline($self->{FH});
+ $self->death("Error: Unterminated TYPEMAP section") if not defined $self->{lastline};
+ last if $self->{lastline} =~ /^$end_marker\s*$/;
+ push @tmaplines, $self->{lastline};
+ }
+
+ my $tmap = ExtUtils::Typemaps->new(
+ string => join("", @tmaplines),
+ lineno_offset => 1 + ($self->current_line_number() || 0),
+ fake_filename => $self->{filename},
+ );
+ $self->{typemap}->merge(typemap => $tmap, replace => 1);
+
+ $self->{lastline} = "";
+ }
+}
+