From: Steffen Mueller Date: Mon, 24 Jun 2013 05:59:30 +0000 (+0200) Subject: Document and clean up -s option to xsubpp X-Git-Tag: upstream/5.20.0~2929 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=39150c421f7908f607a13e109b15e5150d16269d;p=platform%2Fupstream%2Fperl.git Document and clean up -s option to xsubpp At the same time, discourage its use. It's an obscure option that, most of the time, does the opposite of what people actually need. If nothing else, it should be a feature of XS instead of xsubpp. But it exists, so documenting it with a warning is the right thing to do. --- diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm index b75be2b..8cf9831 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm @@ -179,18 +179,11 @@ sub process_file { $self->{typemap} = process_typemaps( $args{typemap}, $pwd ); - # Since at this point we're ready to begin printing to the output file and - # reading from the input file, I want to get as much data as possible into - # the proto-object $self. That means assigning to $self and elements of - # %args referenced below this point. - # HOWEVER: This resulted in an error when I tried: - # $args{'s'} ---> $self->{s}. - # Use of uninitialized value in quotemeta at - # .../blib/lib/ExtUtils/ParseXS.pm line 733 - + # Move more settings from parameters to object foreach my $datum ( qw| argtypes except inout optimize | ) { $self->{$datum} = $args{$datum}; } + $self->{strip_c_func_prefix} = $args{s}; # Identify the version of xsubpp used print <"; } } - $self->{func_name} =~ s/^\Q$args{'s'}// - if exists $args{'s'}; + my $strip = $self->{strip_c_func_prefix}; + $self->{func_name} =~ s/^\Q$strip// + if defined $strip; $self->{func_name} = 'XSFUNCTION' if $self->{interface}; print "$self->{func_name}($self->{func_args});\n"; } diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp b/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp index 7006fcb..e2ac71a 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp @@ -16,7 +16,7 @@ use Getopt::Long; my %args = (); -my $usage = "Usage: xsubpp [-v] [-csuffix csuffix] [-except] [-prototypes] [-noversioncheck] [-nolinenumbers] [-nooptimize] [-noinout] [-noargtypes] [-s pattern] [-typemap typemap]... file.xs\n"; +my $usage = "Usage: xsubpp [-v] [-csuffix csuffix] [-except] [-prototypes] [-noversioncheck] [-nolinenumbers] [-nooptimize] [-noinout] [-noargtypes] [-strip|s pattern] [-typemap typemap]... file.xs\n"; Getopt::Long::Configure qw(no_auto_abbrev no_ignore_case); @@ -33,7 +33,7 @@ GetOptions(\%args, qw(hiertype! v typemap=s@ output=s - s=s + s|strip=s csuffix=s )) or die $usage; @@ -145,6 +145,22 @@ Currently doesn't do anything at all. This flag has been a no-op for many versions of perl, at least as far back as perl5.003_07. It's allowed here for backwards compatibility. +=item B<-s=...> or B<-strip=...> + +I + +If specified, the given string will be stripped off from the beginning +of the C function name in the generated XS functions (if it starts with that prefix). +This only applies to XSUBs without C or C blocks. +For example, the XS: + + void foo_bar(int i); + +when C is invoked with C<-s foo_> will install a C +function in Perl, but really call C in C. Most of the time, +this is the opposite of what you want and failure modes are somewhat +obscure, so please avoid this option where possible. + =back =head1 ENVIRONMENT