summaryrefslogtreecommitdiff
path: root/cpan
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-20 09:29:13 +0200
committerNicholas Clark <nick@ccl4.org>2010-10-21 08:42:18 +0200
commitc565ab54dc649bb62cd4d57149d7b2abb21df5f3 (patch)
treea197ea0834407aa29b35c8a504b86b3181594aa4 /cpan
parentad23561230a77db6d7024a31d7c63e91e40f439b (diff)
downloadperl-c565ab54dc649bb62cd4d57149d7b2abb21df5f3.tar.gz
Add an option autoload to PROXYSUBS, to generate an AUTOLOAD subroutine.
Like croak_on_error, this is only useful with the Proxy Constant Subroutine code, as that adds all known constants to the symbol table at compile time. The (obvious) additional restriction is that directly implementing AUTOLOAD is only useful if the package wishes to perform no other autoloading, and to treat all autoload requests as (failed) constant lookups (with errors describing them as such).
Diffstat (limited to 'cpan')
-rw-r--r--cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm32
1 files changed, 25 insertions, 7 deletions
diff --git a/cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm b/cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm
index 635cf48c3c..4f31f8ea02 100644
--- a/cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm
+++ b/cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm
@@ -171,9 +171,17 @@ sub WriteConstants {
$options = {} unless ref $options;
my $explosives = $options->{croak_on_read};
my $croak_on_error = $options->{croak_on_error};
- # Until someone patches this (with test cases):
- carp ("PROXYSUBS options 'croak_on_read' and 'croak_on_error' cannot be used together")
- if $explosives && $croak_on_error;
+ my $autoload = $options->{autoload};
+ {
+ my $exclusive = 0;
+ ++$exclusive if $explosives;
+ ++$exclusive if $croak_on_error;
+ ++$exclusive if $autoload;
+
+ # Until someone patches this (with test cases):
+ carp ("PROXYSUBS options 'autoload', 'croak_on_read' and 'croak_on_error' cannot be used together")
+ if $exclusive > 1;
+ }
# Strictly it requires Perl_caller_cx
carp ("PROXYSUBS options 'croak_on_error' requires v5.13.5 or later")
if $croak_on_error && $^V < v5.13.5;
@@ -526,18 +534,28 @@ EOBOOT
EOBOOT
}
- if ($croak_on_error) {
- print $xs_fh <<"EOC";
+ if ($croak_on_error || $autoload) {
+ print $xs_fh $croak_on_error ? <<"EOC" : <<'EOA';
void
$xs_subname(sv)
+ INPUT:
+ SV * sv;
PREINIT:
const PERL_CONTEXT *cx = caller_cx(0, NULL);
/* cx is NULL if we've been called from the top level. PL_curcop isn't
ideal, but it's much cheaper than other ways of not going SEGV. */
const COP *cop = cx ? cx->blk_oldcop : PL_curcop;
- INPUT:
- SV * sv;
+EOC
+
+void
+AUTOLOAD()
+ PROTOTYPE: DISABLE
+ PREINIT:
+ SV *sv = newSVpvn_flags(SvPVX(cv), SvCUR(cv), SVs_TEMP | SvUTF8(cv));
+ const COP *cop = PL_curcop;
+EOA
+ print $xs_fh <<"EOC";
PPCODE:
#ifndef SYMBIAN
HV *${c_subname}_missing = get_missing_hash(aTHX);