diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-10-22 10:36:44 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-10-22 13:39:33 +0200 |
commit | 543340fb1f5a45921c194b482b7bb51f98c5722e (patch) | |
tree | 1c5ba640b844e7815b4ee105d93c49bbb30d3c6e /cpan | |
parent | 0de1010603c15b1a365c5442011e03772e8806df (diff) | |
download | perl-543340fb1f5a45921c194b482b7bb51f98c5722e.tar.gz |
Minor refactor of ExtUtils::Constant::ProxySubs.
Use a lexical in place of repeated lc()'s in WriteConstants.
Require ExtUtils::Constant::ProxySubs early, to avoid leaving empty files if it
fails for any reason.
Diffstat (limited to 'cpan')
-rw-r--r-- | cpan/ExtUtils-Constant/lib/ExtUtils/Constant.pm | 4 | ||||
-rw-r--r-- | cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/cpan/ExtUtils-Constant/lib/ExtUtils/Constant.pm b/cpan/ExtUtils-Constant/lib/ExtUtils/Constant.pm index 96e495bf5e..0dc925873d 100644 --- a/cpan/ExtUtils-Constant/lib/ExtUtils/Constant.pm +++ b/cpan/ExtUtils-Constant/lib/ExtUtils/Constant.pm @@ -494,6 +494,9 @@ sub WriteConstants { croak "Module name not specified" unless length $ARGS{NAME}; + # Do this before creating (empty) files, in case it fails: + require ExtUtils::Constant::ProxySubs if $ARGS{PROXYSUBS}; + my $c_fh = $ARGS{C_FH}; if (!$c_fh) { if ($] <= 5.008) { @@ -522,7 +525,6 @@ sub WriteConstants { # names. if ($ARGS{PROXYSUBS}) { - require ExtUtils::Constant::ProxySubs; $ARGS{C_FH} = $c_fh; $ARGS{XS_FH} = $xs_fh; ExtUtils::Constant::ProxySubs->WriteConstants(%ARGS); diff --git a/cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm b/cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm index 1dcfd06a25..e7c9e9a7cc 100644 --- a/cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm +++ b/cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm @@ -367,10 +367,13 @@ EOBOOT die "Can't find structure definition for type $type" unless defined $struct; - my $struct_type = $type ? lc($type) . '_s' : 'notfound_s'; + my $lc_type = $type ? lc($type) : 'notfound'; + my $struct_type = $lc_type . '_s'; + my $array_name = 'values_for_' . $lc_type; + $iterator{$type} = 'value_for_' . $lc_type; + print $c_fh "struct $struct_type $struct;\n"; - my $array_name = 'values_for_' . ($type ? lc $type : 'notfound'); print $xs_fh <<"EOBOOT"; static const struct $struct_type $array_name\[] = @@ -403,8 +406,6 @@ EOBOOT # Terminate the list with a NULL print $xs_fh " { NULL, 0", (", 0" x $number_of_args), " } };\n"; - $iterator{$type} = "value_for_" . ($type ? lc $type : 'notfound'); - print $xs_fh <<"EOBOOT"; const struct $struct_type *$iterator{$type} = $array_name; EOBOOT |