=cut
# Global Constants
-$XSUBPP_version = "1.929";
+$XSUBPP_version = "1.933";
require 5.002;
sub Q ;
-$FH_string = 'File0000' ;
-*FH = $FH_string ;
+$FH = 'File0000' ;
$usage = "Usage: xsubpp [-v] [-C++] [-except] [-prototypes] [-noversioncheck] [-s pattern] [-typemap typemap]... file.xs\n";
sub PROTOTYPE_handler ()
{
+ my $specified ;
+
+ death("Error: Only 1 PROTOTYPE definition allowed per xsub")
+ if $proto_in_this_xsub ++ ;
+
for (; !/^$BLOCK_re/o; $_ = shift(@line)) {
next unless /\S/;
+ $specified = 1 ;
TrimWhitespace($_) ;
if ($_ eq 'DISABLE') {
$ProtoThisXSUB = 0
$ProtoThisXSUB = C_string($_) ;
}
}
+
+ # If no prototype specified, then assume empty prototype ""
+ $ProtoThisXSUB = 2 unless $specified ;
+
$ProtoUsed = 1 ;
+
}
sub PROTOTYPES_handler ()
TrimWhitespace($_) ;
- # If the filename is enclosed in quotes, remove them.
- s/^'([^']*)'$/$1/ or s/^"([^"]*)"$/$1/ ;
-
death("INCLUDE: filename missing")
unless $_ ;
Line => \@line,
LineNo => \@line_no,
Filename => $filename,
- Handle => $FH_string,
+ Handle => $FH,
}) ;
- ++ $FH_string ;
+ ++ $FH ;
# open the new file
- open ($FH_string, "$_") or death("Cannot open '$_': $!") ;
+ open ($FH, "$_") or death("Cannot open '$_': $!") ;
print Q<<"EOF" ;
#
#
EOF
- *FH = $FH_string ;
$filename = $_ ;
- # Prime the pump by reading the first line
- $lastline = <FH> ;
+ # Prime the pump by reading the first
+ # non-blank line
+
+ # skip leading blank lines
+ while (<$FH>) {
+ last unless /^\s*$/ ;
+ }
+
+ $lastline = $_ ;
$lastline_no = $. ;
}
-- $IncludedFiles{$filename}
unless $isPipe ;
- close FH ;
+ close $FH ;
- *FH = $data->{Handle} ;
+ $FH = $data->{Handle} ;
$filename = $data->{Filename} ;
$lastline = $data->{LastLine} ;
$lastline_no = $data->{LastLineNo} ;
$text;
}
-open(FH, $filename) or die "cannot open $filename: $!\n";
+open($FH, $filename) or die "cannot open $filename: $!\n";
# Identify the version of xsubpp used
print <<EOM ;
EOM
-while (<FH>) {
+while (<$FH>) {
last if ($Module, $Package, $Prefix) =
/^MODULE\s*=\s*([\w:]+)(?:\s+PACKAGE\s*=\s*([\w:]+))?(?:\s+PREFIX\s*=\s*(\S+))?\s*$/;
print $_;
$lastline_no = $.;
-# Read next xsub into @line from ($lastline, <FH>).
+# Read next xsub into @line from ($lastline, <$FH>).
sub fetch_para {
# parse paragraph
@line = ();
@line_no = () ;
if (! defined $lastline) {
return 1 if PopFile() ;
- return 0 ;
+ return 0 ;
}
if ($lastline =~
}
# Read next line and continuation lines
- last unless defined($lastline = <FH>);
+ last unless defined($lastline = <$FH>);
$lastline_no = $.;
my $tmp_line;
$lastline .= $tmp_line
- while ($lastline =~ /\\$/ && defined($tmp_line = <FH>));
+ while ($lastline =~ /\\$/ && defined($tmp_line = <$FH>));
chomp $lastline;
$lastline =~ s/^\s+$//;
undef($wantRETVAL) ;
undef(%arg_list) ;
undef(@proto_arg) ;
+ undef($proto_in_this_xsub) ;
$ProtoThisXSUB = $WantPrototypes ;
$_ = shift(@line);
# Build the prototype string for the xsub
if ($ProtoThisXSUB) {
- if ($ProtoThisXSUB != 1) {
+ if ($ProtoThisXSUB == 2) {
+ # User has specified empty prototype
+ $ProtoXSUB{$pname} = '""'
+ }
+ elsif ($ProtoThisXSUB != 1) {
+ # User has specified a prototype
$ProtoXSUB{$pname} = '"' . $ProtoThisXSUB . '"'
}
else {
# XSANY.any_i32 = $value ;
EOF
print Q<<"EOF" if $proto ;
-# sv_setpv(cv, $ProtoXSUB{$pname}) ;
+# sv_setpv((SV*)cv, $ProtoXSUB{$pname}) ;
EOF
}
}