diff options
author | Zefram <zefram@fysh.org> | 2010-10-19 09:31:46 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2010-10-21 05:55:28 -0700 |
commit | 20439bc77dfeec46d94a15cf108446039e26c995 (patch) | |
tree | ea8f1eb9a1f1003a110114977d660f97d96a5bc2 /pp_ctl.c | |
parent | 53d84487fbdd2060c1a666eacaef6e34ce4a1483 (diff) | |
download | perl-20439bc77dfeec46d94a15cf108446039e26c995.tar.gz |
full API for cop hint hashes
Expose cop hint hashes as a type COPHH, with a cophh_* API which is a
macro layer over the refcounted_he_* API. The documentation for cophh_*
describes purely API-visible behaviour, whereas the refcounted_he_*
documentation describes the functions mainly in terms of the
implementation. Revise the cop_hints_* API, using the flags parameter
consistently and reimplementing in terms of cophh_*. Use the cophh_*
and cop_hints_* functions consistently where appropriate.
[Modified by the committer to update two calls to
Perl_refcounted_he_fetch recently added to newPMOP.]
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 20 |
1 files changed, 5 insertions, 15 deletions
@@ -194,8 +194,7 @@ PP(pp_regcomp) PM_SETRE(pm, NULL); /* crucial if regcomp aborts */ #endif } else if (PL_curcop->cop_hints_hash) { - SV *ptr = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash, 0, - "regcomp", 7, 0, 0); + SV *ptr = cop_hints_fetch_pvs(PL_curcop, "regcomp", 0); if (ptr && SvIOK(ptr) && SvIV(ptr)) eng = INT2PTR(regexp_engine*,SvIV(ptr)); } @@ -1915,9 +1914,7 @@ PP(pp_caller) } PUSHs(cx->blk_oldcop->cop_hints_hash ? - sv_2mortal(newRV_noinc( - MUTABLE_SV(Perl_refcounted_he_chain_2hv(aTHX_ - cx->blk_oldcop->cop_hints_hash)))) + sv_2mortal(newRV_noinc(MUTABLE_SV(cop_hints_2hv(cx->blk_oldcop, 0)))) : &PL_sv_undef); RETURN; } @@ -3892,25 +3889,18 @@ PP(pp_entereval) } SAVECOMPILEWARNINGS(); PL_compiling.cop_warnings = DUP_WARNINGS(PL_curcop->cop_warnings); - if (PL_compiling.cop_hints_hash) { - Perl_refcounted_he_free(aTHX_ PL_compiling.cop_hints_hash); - } + cophh_free(CopHINTHASH_get(&PL_compiling)); if (Perl_fetch_cop_label(aTHX_ PL_curcop, NULL, NULL)) { /* The label, if present, is the first entry on the chain. So rather than writing a blank label in front of it (which involves an allocation), just use the next entry in the chain. */ PL_compiling.cop_hints_hash - = PL_curcop->cop_hints_hash->refcounted_he_next; + = cophh_copy(PL_curcop->cop_hints_hash->refcounted_he_next); /* Check the assumption that this removed the label. */ assert(Perl_fetch_cop_label(aTHX_ &PL_compiling, NULL, NULL) == NULL); } else - PL_compiling.cop_hints_hash = PL_curcop->cop_hints_hash; - if (PL_compiling.cop_hints_hash) { - HINTS_REFCNT_LOCK; - PL_compiling.cop_hints_hash->refcounted_he_refcnt++; - HINTS_REFCNT_UNLOCK; - } + PL_compiling.cop_hints_hash = cophh_copy(PL_curcop->cop_hints_hash); /* special case: an eval '' executed within the DB package gets lexically * placed in the first non-DB CV rather than the current CV - this * allows the debugger to execute code, find lexicals etc, in the |