r51267 - in /branches/upstream/libscope-upper-perl/current: Changes META.yml Makefile.PL README Upper.xs lib/Scope/Upper.pm t/13-reap-ctl.t t/23-localize-ctl.t t/99-kwalitee.t t/lib/Scope/Upper/TestGenerator.pm

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Tue Jan 19 20:03:49 UTC 2010


Author: jawnsy-guest
Date: Tue Jan 19 20:02:54 2010
New Revision: 51267

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=51267
Log:
[svn-upgrade] Integrating new upstream version, libscope-upper-perl (0.10)

Modified:
    branches/upstream/libscope-upper-perl/current/Changes
    branches/upstream/libscope-upper-perl/current/META.yml
    branches/upstream/libscope-upper-perl/current/Makefile.PL
    branches/upstream/libscope-upper-perl/current/README
    branches/upstream/libscope-upper-perl/current/Upper.xs
    branches/upstream/libscope-upper-perl/current/lib/Scope/Upper.pm
    branches/upstream/libscope-upper-perl/current/t/13-reap-ctl.t
    branches/upstream/libscope-upper-perl/current/t/23-localize-ctl.t
    branches/upstream/libscope-upper-perl/current/t/99-kwalitee.t
    branches/upstream/libscope-upper-perl/current/t/lib/Scope/Upper/TestGenerator.pm

Modified: branches/upstream/libscope-upper-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscope-upper-perl/current/Changes?rev=51267&op=diff
==============================================================================
--- branches/upstream/libscope-upper-perl/current/Changes (original)
+++ branches/upstream/libscope-upper-perl/current/Changes Tue Jan 19 20:02:54 2010
@@ -1,4 +1,10 @@
 Revision history for Scope-Upper
+
+0.10    2010-01-18 23:50 UTC
+        + Fix : Properly handle given/when on 5.10.
+        + Fix : Some stack inconsistencies were fixed, though they were unlikely
+                to have an impact on your real-life code.
+        + Fix : Work around Kwalitee test misfailures.
 
 0.09    2009-05-17 20:20 UTC
         + Add : The new SU_THREADSAFE constant can be used to know whether the

Modified: branches/upstream/libscope-upper-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscope-upper-perl/current/META.yml?rev=51267&op=diff
==============================================================================
--- branches/upstream/libscope-upper-perl/current/META.yml (original)
+++ branches/upstream/libscope-upper-perl/current/META.yml Tue Jan 19 20:02:54 2010
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Scope-Upper
-version:            0.09
+version:            0.10
 abstract:           Act on upper scopes.
 author:
     - Vincent Pit <perl at profvince.com>
@@ -9,9 +9,13 @@
 configure_requires:
     ExtUtils::MakeMaker:  0
 build_requires:
+    base:                 0
+    Exporter:             0
     ExtUtils::MakeMaker:  0
     Test::More:           0
+    XSLoader:             0
 requires:
+    base:      0
     Exporter:  0
     perl:      5.006
     XSLoader:  0
@@ -24,7 +28,8 @@
     directory:
         - t
         - inc
-generated_by:       ExtUtils::MakeMaker version 6.50
+generated_by:       ExtUtils::MakeMaker version 6.56
 meta-spec:
     url:      http://module-build.sourceforge.net/META-spec-v1.4.html
     version:  1.4
+dynamic_config:     1

Modified: branches/upstream/libscope-upper-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscope-upper-perl/current/Makefile.PL?rev=51267&op=diff
==============================================================================
--- branches/upstream/libscope-upper-perl/current/Makefile.PL (original)
+++ branches/upstream/libscope-upper-perl/current/Makefile.PL Tue Jan 19 20:02:54 2010
@@ -15,6 +15,17 @@
 
 my $dist = 'Scope-Upper';
 
+(my $name = $dist) =~ s{-}{::}g;
+
+(my $file = $dist) =~ s{-}{/}g;
+$file = "lib/$file.pm";
+
+my %PREREQ_PM = (
+ 'Exporter' => 0,
+ 'XSLoader' => 0,
+ 'base'     => 0,
+);
+
 my %META = (
  configure_requires => {
   'ExtUtils::MakeMaker' => 0,
@@ -22,7 +33,9 @@
  build_requires => {
   'ExtUtils::MakeMaker' => 0,
   'Test::More'          => 0,
+  %PREREQ_PM,
  },
+ dynamic_config => 1,
  resources => {
   bugtracker => "http://rt.cpan.org/NoAuth/ReportBug.html?Queue=$dist",
   homepage   => "http://search.cpan.org/dist/$dist/",
@@ -32,26 +45,23 @@
 );
 
 WriteMakefile(
-    NAME             => 'Scope::Upper',
-    AUTHOR           => 'Vincent Pit <perl at profvince.com>',
-    LICENSE          => 'perl',
-    VERSION_FROM     => 'lib/Scope/Upper.pm',
-    ABSTRACT_FROM    => 'lib/Scope/Upper.pm',
-    PL_FILES         => {},
-    @DEFINES,
-    PREREQ_PM        => {
-        'Exporter' => 0,
-        'XSLoader' => 0,
-    },
-    MIN_PERL_VERSION => 5.006,
-    META_MERGE       => \%META,
-    dist             => {
-        PREOP    => 'pod2text lib/Scope/Upper.pm > $(DISTVNAME)/README',
-        COMPRESS => 'gzip -9f', SUFFIX => 'gz'
-    },
-    clean            => {
-        FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt"
-    },
+ NAME             => $name,
+ AUTHOR           => 'Vincent Pit <perl at profvince.com>',
+ LICENSE          => 'perl',
+ VERSION_FROM     => $file,
+ ABSTRACT_FROM    => $file,
+ PL_FILES         => {},
+ @DEFINES,
+ PREREQ_PM        => \%PREREQ_PM,
+ MIN_PERL_VERSION => 5.006,
+ META_MERGE       => \%META,
+ dist             => {
+  PREOP    => "pod2text $file > \$(DISTVNAME)/README",
+  COMPRESS => 'gzip -9f', SUFFIX => 'gz'
+ },
+ clean            => {
+  FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt"
+ },
 );
 
 package MY;
@@ -59,6 +69,6 @@
 sub postamble {
  return <<'POSTAMBLE';
 testdeb: all
-	PERL_DL_NONLAZY=1 PERLDB_OPTS="NonStop=1" prove --exec='$(PERL) -d -T -I$(INST_LIB) -I$(INST_ARCHLIB)' $(TEST_FILES)
+	PERL_DL_NONLAZY=1 PERLDB_OPTS="NonStop=1" $(FULLPERLRUN) -MTAP::Harness -e 'TAP::Harness->new({verbosity => q{$(VERBOSE)}, lib => [ q{$(INST_LIB)}, q{$(INST_ARCHLIB)} ], switches => [ q{-d} ]})->runtests(@ARGV)' $(TEST_FILES)
 POSTAMBLE
 }

Modified: branches/upstream/libscope-upper-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscope-upper-perl/current/README?rev=51267&op=diff
==============================================================================
--- branches/upstream/libscope-upper-perl/current/README (original)
+++ branches/upstream/libscope-upper-perl/current/README Tue Jan 19 20:02:54 2010
@@ -2,7 +2,7 @@
     Scope::Upper - Act on upper scopes.
 
 VERSION
-    Version 0.09
+    Version 0.10
 
 SYNOPSIS
         package X;
@@ -170,7 +170,7 @@
          # not reached
         }->();
 
-    will righteously set $num to 26.
+    will rightfully set $num to 26.
 
 CONSTANTS
   "SU_THREADSAFE"
@@ -322,6 +322,11 @@
 SEE ALSO
     Alias, Hook::Scope, Scope::Guard, Guard.
 
+    Continuation::Escape is a thin wrapper around Scope::Upper that gives
+    you a continuation passing style interface to "unwind". It's easier to
+    use, but it requires you to have control over the scope where you want
+    to return.
+
 AUTHOR
     Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.
 
@@ -348,7 +353,7 @@
     Thanks to Shawn M. Moore for motivation.
 
 COPYRIGHT & LICENSE
-    Copyright 2008-2009 Vincent Pit, all rights reserved.
+    Copyright 2008,2009,2010 Vincent Pit, all rights reserved.
 
     This program is free software; you can redistribute it and/or modify it
     under the same terms as Perl itself.

Modified: branches/upstream/libscope-upper-perl/current/Upper.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscope-upper-perl/current/Upper.xs?rev=51267&op=diff
==============================================================================
--- branches/upstream/libscope-upper-perl/current/Upper.xs (original)
+++ branches/upstream/libscope-upper-perl/current/Upper.xs Tue Jan 19 20:02:54 2010
@@ -42,6 +42,10 @@
 
 #ifndef SvPV_nolen_const
 # define SvPV_nolen_const(S) SvPV_nolen(S)
+#endif
+
+#ifndef SvREFCNT_inc_simple_void
+# define SvREFCNT_inc_simple_void(sv) SvREFCNT_inc(sv)
 #endif
 
 #ifndef HvNAME_get
@@ -176,7 +180,7 @@
  Newx(ud, 1, su_ud_adelete);
  ud->av  = av;
  ud->idx = idx;
- SvREFCNT_inc(av);
+ SvREFCNT_inc_simple_void(av);
 
  SAVEDESTRUCTOR_X(su_adelete, ud);
 }
@@ -285,8 +289,12 @@
 
  dSP;
 
- SU_D(PerlIO_printf(Perl_debug_log, "%p: @@@ call at %d (save is %d)\n",
-                                     ud, PL_scopestack_ix, PL_savestack_ix));
+ SU_D({
+  PerlIO_printf(Perl_debug_log,
+                "%p: @@@ call\n%p: depth=%2d scope_ix=%2d save_ix=%2d\n",
+                 ud, ud, SU_UD_DEPTH(ud), PL_scopestack_ix, PL_savestack_ix);
+ });
+
  ENTER;
  SAVETMPS;
 
@@ -324,35 +332,33 @@
 
 STATIC void su_reap(pTHX_ void *ud) {
 #define su_reap(U) su_reap(aTHX_ (U))
- SU_D(PerlIO_printf(Perl_debug_log, "%p: === reap at %d (save is %d)\n",
-                                     ud, PL_scopestack_ix, PL_savestack_ix));
+ SU_D({
+  PerlIO_printf(Perl_debug_log,
+                "%p: === reap\n%p: depth=%2d scope_ix=%2d save_ix=%2d\n",
+                 ud, ud, SU_UD_DEPTH(ud), PL_scopestack_ix, PL_savestack_ix);
+ });
+
  SAVEDESTRUCTOR_X(su_call, ud);
- SU_D(PerlIO_printf(Perl_debug_log, "%p: savestack is now at %d, base at %d\n",
-                                     ud, PL_savestack_ix,
-                                         PL_scopestack[PL_scopestack_ix]));
 }
 
 /* ... Localize & localize array/hash element .............................. */
 
 typedef struct {
  su_ud_common ci;
- SV *sv;
- SV *val;
- SV *elem;
+ SV    *sv;
+ SV    *val;
+ SV    *elem;
+ svtype type;
 } su_ud_localize;
 
-STATIC void su_localize(pTHX_ void *ud_) {
-#define su_localize(U) su_localize(aTHX_ (U))
- su_ud_localize *ud = (su_ud_localize *) ud_;
- SV *sv   = ud->sv;
- SV *val  = ud->val;
- SV *elem = ud->elem;
- GV *gv;
+STATIC void su_ud_localize_init(pTHX_ su_ud_localize *ud, SV *sv, SV *val, SV *elem) {
+#define su_ud_localize_init(UD, S, V, E) su_ud_localize_init(aTHX_ (UD), (S), (V), (E))
  UV deref = 0;
  svtype t = SVt_NULL;
 
+ SvREFCNT_inc_simple_void(sv);
+
  if (SvTYPE(sv) >= SVt_PVGV) {
-  gv = (GV *) sv;
   if (!val || !SvROK(val)) { /* local *x; or local *x = $val; */
    t = SVt_PVGV;
   } else {                   /* local *x = \$val; */
@@ -385,14 +391,55 @@
     t = SvTYPE(val);
    }
   }
-  gv = gv_fetchpvn_flags(s, l, GV_ADDMULTI, SVt_PVGV);
+  SvREFCNT_dec(sv);
+  sv = newSVpvn(s, l);
+ }
+
+ switch (t) {
+  case SVt_PVAV:
+  case SVt_PVHV:
+  case SVt_PVCV:
+  case SVt_PVGV:
+   deref = 0;
+  default:
+   break;
+ }
+ /* When deref is set, val isn't NULL */
+
+ ud->sv   = sv;
+ ud->val  = val ? newSVsv(deref ? SvRV(val) : val) : NULL;
+ ud->elem = SvREFCNT_inc(elem);
+ ud->type = t;
+}
+
+STATIC void su_localize(pTHX_ void *ud_) {
+#define su_localize(U) su_localize(aTHX_ (U))
+ su_ud_localize *ud = (su_ud_localize *) ud_;
+ SV *sv   = ud->sv;
+ SV *val  = ud->val;
+ SV *elem = ud->elem;
+ svtype t = ud->type;
+ GV *gv;
+
+ if (SvTYPE(sv) >= SVt_PVGV) {
+  gv = (GV *) sv;
+ } else {
+#ifdef gv_fetchsv
+  gv = gv_fetchsv(sv, GV_ADDMULTI, SVt_PVGV);
+#else
+  STRLEN len;
+  const char *name = SvPV_const(sv, len);
+  gv = gv_fetchpvn_flags(name, len, GV_ADDMULTI, SVt_PVGV);
+#endif
  }
 
  SU_D({
-  SV *z = newSV_type(t);
-  PerlIO_printf(Perl_debug_log, "%p: === localize a %s at %d (save is %d)\n",
-                                 ud, sv_reftype(z, 0),
-                                     PL_scopestack_ix, PL_savestack_ix);
+  SV *z = newSV(0);
+  SvUPGRADE(z, t);
+  PerlIO_printf(Perl_debug_log, "%p: === localize a %s\n",ud, sv_reftype(z, 0));
+  PerlIO_printf(Perl_debug_log,
+                "%p: depth=%2d scope_ix=%2d save_ix=%2d\n",
+                 ud, SU_UD_DEPTH(ud), PL_scopestack_ix, PL_savestack_ix);
   SvREFCNT_dec(z);
  });
 
@@ -421,14 +468,8 @@
    break;
   default:
    gv = (GV *) save_scalar(gv);
-   if (deref) /* val != NULL */
-    val = SvRV(val);
    break;
  }
-
- SU_D(PerlIO_printf(Perl_debug_log, "%p: savestack is now at %d, base at %d\n",
-                                     ud, PL_savestack_ix,
-                                         PL_scopestack[PL_scopestack_ix]));
 
  if (val)
   SvSetMagicSV((SV *) gv, val);
@@ -455,54 +496,103 @@
  I32 depth, base, mark, *origin;
  depth = SU_UD_DEPTH(ud);
 
- SU_D(PerlIO_printf(Perl_debug_log, "%p: --- pop %s at %d from %d to %d [%d]\n",
-                                     ud, SU_CXNAME,
-                                         PL_scopestack_ix, PL_savestack_ix,
-                                         PL_scopestack[PL_scopestack_ix],
-                                         depth));
+ SU_D(
+  PerlIO_printf(Perl_debug_log,
+   "%p: --- pop a %s\n"
+   "%p: leave scope     at depth=%2d scope_ix=%2d cur_top=%2d cur_base=%2d\n",
+    ud, SU_CXNAME,
+    ud, depth, PL_scopestack_ix,PL_savestack_ix,PL_scopestack[PL_scopestack_ix])
+ );
 
  origin = SU_UD_ORIGIN(ud);
  mark   = origin[depth];
  base   = origin[depth - 1];
 
- SU_D(PerlIO_printf(Perl_debug_log, "%p: clean from %d down to %d\n",
-                                     ud, mark, base));
+ SU_D(PerlIO_printf(Perl_debug_log,
+                    "%p: original scope was %*c top=%2d     base=%2d\n",
+                     ud,                24, ' ',    mark,        base));
 
  if (base < mark) {
+  SU_D(PerlIO_printf(Perl_debug_log, "%p: clear leftovers\n", ud));
   PL_savestack_ix = mark;
   leave_scope(base);
  }
  PL_savestack_ix = base;
- if (--depth > 0) {
-  SU_UD_DEPTH(ud) = depth;
-  SU_D(PerlIO_printf(Perl_debug_log, "%p: save new destructor at %d [%d]\n",
-                                      ud, PL_savestack_ix, depth));
+
+ SU_UD_DEPTH(ud) = --depth;
+
+ if (depth > 0) {
+  I32 i = 1;
+
   SAVEDESTRUCTOR_X(su_pop, ud);
-  SU_D(PerlIO_printf(Perl_debug_log, "%p: pop end at at %d [%d]\n",
-                                      ud, PL_savestack_ix, depth));
+
+  /* Skip depths corresponding to scopes for which leave_scope() might not be
+   * called. */
+  while (depth > 1 && PL_scopestack_ix >= i) {
+   I32 j = PL_scopestack[PL_scopestack_ix - i];
+
+   if (j < PL_savestack_ix)
+    break;
+
+   SU_D(PerlIO_printf(Perl_debug_log,
+    "%p: skip scope%*cat depth=%2d scope_ix=%2d new_top=%2d >= cur_base=%2d\n",
+     ud,           6, ' ',   depth, PL_scopestack_ix - i, j, PL_savestack_ix));
+
+   SU_UD_DEPTH(ud) = --depth;
+
+   ++i;
+  }
+
+  SU_D(PerlIO_printf(Perl_debug_log,
+         "%p: set destructor  at depth=%2d scope_ix=%2d save_ix=%2d\n",
+          ud,                        depth, PL_scopestack_ix, PL_savestack_ix));
  } else {
   SU_UD_HANDLER(ud)(aTHX_ ud);
  }
-}
+
+ SU_D(PerlIO_printf(Perl_debug_log,
+                    "%p: --- end pop: cur_top=%2d == cur_base=%2d\n",
+                     ud, PL_savestack_ix, PL_scopestack[PL_scopestack_ix]));
+}
+
+/* --- Global data --------------------------------------------------------- */
+
+#define MY_CXT_KEY __PACKAGE__ "::_guts" XS_VERSION
+
+typedef struct {
+ int stack_placeholder;
+ I32 cxix;
+ I32 items;
+ SV  **savesp;
+ OP  fakeop;
+} my_cxt_t;
+
+START_MY_CXT
 
 /* --- Initialize the stack and the action userdata ------------------------ */
 
 STATIC I32 su_init(pTHX_ I32 cxix, void *ud, I32 size) {
 #define su_init(L, U, S) su_init(aTHX_ (L), (U), (S))
- I32 i, depth = 0, *origin;
-
- LEAVE;
-
- if (cxix >= cxstack_ix) {
-  SU_UD_HANDLER(ud)(aTHX_ ud);
-  goto done;
- }
+ I32 i, depth = 1, *origin;
 
  SU_D(PerlIO_printf(Perl_debug_log, "%p: ### init for cx %d\n", ud, cxix));
 
  for (i = cxstack_ix; i > cxix; --i) {
   PERL_CONTEXT *cx = cxstack + i;
   switch (CxTYPE(cx)) {
+#if SU_HAS_PERL(5, 10, 0)
+   case CXt_BLOCK:
+    SU_D(PerlIO_printf(Perl_debug_log, "%p: cx %d is block\n", ud, i));
+    /* Given and when blocks are actually followed by a simple block, so skip
+     * it if needed. */
+    if (cxix > 0) { /* Implies i > 0 */
+     PERL_CONTEXT *next = cx - 1;
+     if (CxTYPE(next) == CXt_GIVEN || CxTYPE(next) == CXt_WHEN)
+      --cxix;
+    }
+    depth++;
+    break;
+#endif
 #if SU_HAS_PERL(5, 11, 0)
    case CXt_LOOP_FOR:
    case CXt_LOOP_PLAIN:
@@ -515,7 +605,7 @@
     depth += 2;
     break;
    default:
-    SU_D(PerlIO_printf(Perl_debug_log, "%p: cx %d is normal\n", ud, i));
+    SU_D(PerlIO_printf(Perl_debug_log, "%p: cx %d is other\n", ud, i));
     depth++;
     break;
   }
@@ -532,42 +622,36 @@
  }
  origin[depth] = PL_savestack_ix;
 
- SU_D({
-  PerlIO_printf(Perl_debug_log, "%p: d=%d s=%d x=%d c=%d o=%d\n", ud,
-                depth, 0, PL_scopestack_ix - 1, PL_savestack_ix, origin[depth]);
-  for (i = depth - 1; i >= 0; --i) {
-   I32 x = PL_scopestack_ix  - depth + i;
-   PerlIO_printf(Perl_debug_log, "%p: d=%d s=%d x=%d c=%d o=%d\n", ud,
-                                  i, depth - i, x, PL_scopestack[x], origin[i]);
-  }
- });
-
  SU_UD_ORIGIN(ud) = origin;
  SU_UD_DEPTH(ud)  = depth;
 
- SU_D(PerlIO_printf(Perl_debug_log, "%p: set original destructor at %d [%d]\n",
-                                     ud, PL_savestack_ix, depth));
+ SU_D(PerlIO_printf(Perl_debug_log,
+        "%p: set original destructor at depth=%2d scope_ix=%2d save_ix=%2d\n",
+         ud,                     depth, PL_scopestack_ix - 1, PL_savestack_ix));
+
+ /* Make sure the first destructor fires by pushing enough fake slots on the
+  * stack. */
+ if (PL_savestack_ix + 3 <= PL_scopestack[PL_scopestack_ix - 1]) {
+  dMY_CXT;
+  do {
+   save_int(&MY_CXT.stack_placeholder);
+  } while (PL_savestack_ix + 3 <= PL_scopestack[PL_scopestack_ix - 1]);
+ }
 
  SAVEDESTRUCTOR_X(su_pop, ud);
 
-done:
- ENTER;
+ SU_D({
+  for (i = 0; i <= depth; ++i) {
+   I32 j = PL_scopestack_ix  - i;
+   PerlIO_printf(Perl_debug_log,
+                 "%p: depth=%2d scope_ix=%2d saved_floor=%2d new_floor=%2d\n",
+                  ud,        i, j, origin[depth - i],
+                                   i == 0 ? PL_savestack_ix : PL_scopestack[j]);
+  }
+ });
 
  return depth;
 }
-
-/* --- Global data --------------------------------------------------------- */
-
-#define MY_CXT_KEY __PACKAGE__ "::_guts" XS_VERSION
-
-typedef struct {
- I32 cxix;
- I32 items;
- SV  **savesp;
- OP  fakeop;
-} my_cxt_t;
-
-START_MY_CXT
 
 /* --- Unwind stack -------------------------------------------------------- */
 
@@ -622,18 +706,21 @@
 
 #define SU_SKIP_DB(C) \
  STMT_START {         \
-  I32 i = 1;          \
-  PERL_CONTEXT *cx = cxstack + (C); \
-  do {                              \
-   if (CxTYPE(cx) == CXt_BLOCK && (C) >= i) { \
-    --cx;                                     \
-    if (CxTYPE(cx) == CXt_SUB && cx->blk_sub.cv == GvCV(PL_DBsub)) { \
-     (C) -= i + 1;                 \
-     break;                        \
-    }                              \
-   } else                          \
-    break;                         \
-  } while (++i <= SU_SKIP_DB_MAX); \
+  I32 skipped = 0;    \
+  PERL_CONTEXT *base = cxstack;      \
+  PERL_CONTEXT *cx   = base + (C);   \
+  while (cx >= base && (C) > skipped && CxTYPE(cx) == CXt_BLOCK) \
+   --cx, ++skipped;                  \
+  if (cx >= base && (C) > skipped) { \
+   switch (CxTYPE(cx)) {  \
+    case CXt_SUB:         \
+     if (skipped <= SU_SKIP_DB_MAX && cx->blk_sub.cv == GvCV(PL_DBsub)) \
+      (C) -= skipped + 1; \
+      break;              \
+    default:              \
+     break;               \
+   }                      \
+  }                       \
  } STMT_END
 
 #define SU_GET_CONTEXT(A, B)   \
@@ -718,10 +805,14 @@
 BOOT:
 {
  HV *stash;
+
  MY_CXT_INIT;
+ MY_CXT.stack_placeholder = 0;
+
  stash = gv_stashpv(__PACKAGE__, 1);
  newCONSTSUB(stash, "TOP",           newSViv(0));
  newCONSTSUB(stash, "SU_THREADSAFE", newSVuv(SU_THREADSAFE));
+
  newXSproto("Scope::Upper::unwind", XS_Scope__Upper_unwind, file, NULL);
 }
 
@@ -897,17 +988,19 @@
 PROTOTYPE: $$;$
 PREINIT:
  I32 cxix;
+ I32 size = 3;
  su_ud_localize *ud;
 CODE:
  SU_GET_CONTEXT(2, 2);
  Newx(ud, 1, su_ud_localize);
  SU_UD_ORIGIN(ud)  = NULL;
  SU_UD_HANDLER(ud) = su_localize;
- SvREFCNT_inc(sv);
- ud->sv   = sv;
- ud->val  = newSVsv(val);
- ud->elem = NULL;
- su_init(cxix, ud, 3);
+ su_ud_localize_init(ud, sv, val, NULL);
+#if !SU_HAS_PERL(5, 8, 9)
+ if (ud->type >= SVt_PVGV)
+  size = 6;
+#endif
+ su_init(cxix, ud, size);
 
 void
 localize_elem(SV *sv, SV *elem, SV *val, ...)
@@ -920,11 +1013,7 @@
  Newx(ud, 1, su_ud_localize);
  SU_UD_ORIGIN(ud)  = NULL;
  SU_UD_HANDLER(ud) = su_localize;
- SvREFCNT_inc(sv);
- ud->sv   = sv;
- ud->val  = newSVsv(val);
- SvREFCNT_inc(elem);
- ud->elem = elem;
+ su_ud_localize_init(ud, sv, val, elem);
  su_init(cxix, ud, 4);
 
 void
@@ -932,15 +1021,16 @@
 PROTOTYPE: $$;$
 PREINIT:
  I32 cxix;
+ I32 size = 4;
  su_ud_localize *ud;
 CODE:
  SU_GET_CONTEXT(2, 2);
  Newx(ud, 1, su_ud_localize);
  SU_UD_ORIGIN(ud)  = NULL;
  SU_UD_HANDLER(ud) = su_localize;
- SvREFCNT_inc(sv);
- ud->sv   = sv;
- ud->val  = NULL;
- SvREFCNT_inc(elem);
- ud->elem = elem;
- su_init(cxix, ud, 4);
+ su_ud_localize_init(ud, sv, NULL, elem);
+#if !SU_HAS_PERL(5, 8, 9)
+ if (ud->type >= SVt_PVGV)
+  size = 6;
+#endif
+ su_init(cxix, ud, size);

Modified: branches/upstream/libscope-upper-perl/current/lib/Scope/Upper.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscope-upper-perl/current/lib/Scope/Upper.pm?rev=51267&op=diff
==============================================================================
--- branches/upstream/libscope-upper-perl/current/lib/Scope/Upper.pm (original)
+++ branches/upstream/libscope-upper-perl/current/lib/Scope/Upper.pm Tue Jan 19 20:02:54 2010
@@ -9,13 +9,13 @@
 
 =head1 VERSION
 
-Version 0.09
+Version 0.10
 
 =cut
 
 our $VERSION;
 BEGIN {
- $VERSION = '0.09';
+ $VERSION = '0.10';
 }
 
 =head1 SYNOPSIS
@@ -209,7 +209,7 @@
      # not reached
     }->();
 
-will righteously set C<$num> to C<26>.
+will rightfully set C<$num> to C<26>.
 
 =head1 CONSTANTS
 
@@ -378,6 +378,9 @@
 
 L<Alias>, L<Hook::Scope>, L<Scope::Guard>, L<Guard>.
 
+L<Continuation::Escape> is a thin wrapper around L<Scope::Upper> that gives you a continuation passing style interface to L</unwind>.
+It's easier to use, but it requires you to have control over the scope where you want to return.
+
 =head1 AUTHOR
 
 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
@@ -404,7 +407,7 @@
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2008-2009 Vincent Pit, all rights reserved.
+Copyright 2008,2009,2010 Vincent Pit, all rights reserved.
 
 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
 

Modified: branches/upstream/libscope-upper-perl/current/t/13-reap-ctl.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscope-upper-perl/current/t/13-reap-ctl.t?rev=51267&op=diff
==============================================================================
--- branches/upstream/libscope-upper-perl/current/t/13-reap-ctl.t (original)
+++ branches/upstream/libscope-upper-perl/current/t/13-reap-ctl.t Tue Jan 19 20:02:54 2010
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 38 + 4 * 7;
+use Test::More tests => 38 + 30 + 4 * 7;
 
 use Scope::Upper qw/reap UP HERE/;
 
@@ -120,6 +120,133 @@
  };
  is $x, 1, 'die - reap inside eval [ok - x]';
  is $y, 1, 'die - reap inside eval [ok - y]';
+}
+
+SKIP:
+{
+ skip 'Perl 5.10 required to test given/when' => 30 if $] < 5.010;
+
+ eval <<' GIVEN_TEST_1';
+  use feature 'switch';
+  local $y;
+  {
+   local $x = 1;
+   given (1) {
+    local $x = 2;
+    when (1) {
+     local $x = 3;
+     reap \&check => UP;
+     is $x, 3,     'given/when - reap at given [not yet - x]';
+     is $y, undef, 'given/when - reap at given [not yet - y]';
+    }
+    fail 'not reached';
+   }
+   is $x, 1, 'given/when - reap at given [ok - x]';
+   is $y, 1, 'given/when - reap at given [ok - y]';
+  }
+ GIVEN_TEST_1
+ fail $@ if $@;
+
+ eval <<' GIVEN_TEST_2';
+  use feature 'switch';
+  local $y;
+  {
+   local $x = 1;
+   given (1) {
+    local $x = 2;
+    when (1) {
+     local $x = 3;
+     reap \&check => UP;
+     is $x, 3,     'given/when/continue - reap at given [not yet 1 - x]';
+     is $y, undef, 'given/when/continue - reap at given [not yet 1 - y]';
+     continue;
+    }
+    is $x, 2,     'given/when/continue - reap at given [not yet 2 - x]';
+    is $y, undef, 'given/when/continue - reap at given [not yet 2 - y]';
+   }
+   is $x, 1, 'given/when/continue - reap at given [ok - x]';
+   is $y, 1, 'given/when/continue - reap at given [ok - y]';
+  }
+ GIVEN_TEST_2
+ fail $@ if $@;
+
+ eval <<' GIVEN_TEST_3';
+  use feature 'switch';
+  local $y;
+  {
+   local $x = 1;
+   given (1) {
+    local $x = 2;
+    default {
+     local $x = 3;
+     reap \&check => UP;
+     is $x, 3,     'given/default - reap at given [not yet - x]';
+     is $y, undef, 'given/default - reap at given [not yet - y]';
+    }
+    fail 'not reached';
+   }
+   is $x, 1, 'given/default - reap at given [ok - x]';
+   is $y, 1, 'given/default - reap at given [ok - y]';
+  }
+ GIVEN_TEST_3
+ fail $@ if $@;
+
+ eval <<' GIVEN_TEST_4';
+  use feature 'switch';
+  local $y;
+  {
+   local $x = 1;
+   given (1) {
+    local $x = 2;
+    default {
+     local $x = 3;
+     reap \&check => UP;
+     is $x, 3,     'given/default/continue - reap at given [not yet 1 - x]';
+     is $y, undef, 'given/default/continue - reap at given [not yet 1 - y]';
+     continue;
+    }
+    is $x, 2,     'given/default/continue - reap at given [not yet 2 - x]';
+    is $y, undef, 'given/default/continue - reap at given [not yet 2 - y]';
+   }
+   is $x, 1, 'given/default/continue - reap at given [ok - x]';
+   is $y, 1, 'given/default/continue - reap at given [ok - y]';
+  }
+ GIVEN_TEST_4
+ fail $@ if $@;
+
+ eval <<' GIVEN_TEST_5';
+  use feature 'switch';
+  local $y;
+  {
+   local $x = 1;
+   given (1) {
+    local $x = 2;
+    default {
+     local $x = 3;
+     given (2) {
+      local $x = 4;
+      when (2) {
+       local $x = 5;
+       reap \&check => UP UP;
+       is $x, 5,     'given/default/given/when - reap at default [not yet 1 - x]';
+       is $y, undef, 'given/default/given/when - reap at default [not yet 1 - y]';
+       continue;
+      }
+      is $x, 4,     'given/default/given/when - reap at default [not yet 2 - x]';
+      is $y, undef, 'given/default/given/when - reap at default [not yet 2 - y]';
+     }
+     is $x, 3,     'given/default/given/when - reap at default [not yet 3 - x]';
+     is $y, undef, 'given/default/given/when - reap at default [not yet 3 - y]';
+     continue;
+    }
+    is $x, 2, 'given/default/given/when - reap at default [ok 1 - x]';
+    is $y, 1, 'given/default/given/when - reap at default [ok 1 - y]';
+   }
+   is $x, 1, 'given/default/given/when - reap at default [ok 2 - x]';
+   is $y, 1, 'given/default/given/when - reap at default [ok 2 - y]';
+  }
+ GIVEN_TEST_5
+ fail $@ if $@;
 }
 
 $y = undef;

Modified: branches/upstream/libscope-upper-perl/current/t/23-localize-ctl.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscope-upper-perl/current/t/23-localize-ctl.t?rev=51267&op=diff
==============================================================================
--- branches/upstream/libscope-upper-perl/current/t/23-localize-ctl.t (original)
+++ branches/upstream/libscope-upper-perl/current/t/23-localize-ctl.t Tue Jan 19 20:02:54 2010
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 44;
+use Test::More tests => 44 + 30;
 
 use Scope::Upper qw/localize UP HERE/;
 
@@ -131,19 +131,19 @@
     {
      local $x = 3;
      localize '$y' => 1 => UP UP UP UP;
-     is $x, 3,     'die - reap outside eval [not yet 1 - x]';
-     is $y, undef, 'die - reap outside eval [not yet 1 - y]';
-    }
-    is $x, 2,     'die - reap outside eval [not yet 2 - x]';
-    is $y, undef, 'die - reap outside eval [not yet 2 - y]';
+     is $x, 3,     'die - localize outside eval [not yet 1 - x]';
+     is $y, undef, 'die - localize outside eval [not yet 1 - y]';
+    }
+    is $x, 2,     'die - localize outside eval [not yet 2 - x]';
+    is $y, undef, 'die - localize outside eval [not yet 2 - y]';
     die;
    }
   };
-  is $x, 1,     'die - reap outside eval [not yet 3 - x]';
-  is $y, undef, 'die - reap outside eval [not yet 3 - y]';
+  is $x, 1,     'die - localize outside eval [not yet 3 - x]';
+  is $y, undef, 'die - localize outside eval [not yet 3 - y]';
  } # should trigger here
- is $x, 1, 'die - reap outside eval [ok - x]';
- is $y, 1, 'die - reap outside eval [ok - y]';
+ is $x, 1, 'die - localize outside eval [ok - x]';
+ is $y, 1, 'die - localize outside eval [ok - y]';
 }
 
 $y = undef;
@@ -155,16 +155,16 @@
    {
     local $x = 3;
     localize '$y' => 1 => UP UP UP;
-    is $x, 3,     'die - reap at eval [not yet 1 - x]';
-    is $y, undef, 'die - reap at eval [not yet 1 - y]';
-   }
-   is $x, 2,     'die - reap at eval [not yet 2 - x]';
-   is $y, undef, 'die - reap at eval [not yet 2 - y]';
+    is $x, 3,     'die - localize at eval [not yet 1 - x]';
+    is $y, undef, 'die - localize at eval [not yet 1 - y]';
+   }
+   is $x, 2,     'die - localize at eval [not yet 2 - x]';
+   is $y, undef, 'die - localize at eval [not yet 2 - y]';
    die;
   }
  }; # should trigger here
- is $x, 1, 'die - reap at eval [ok - x]';
- is $y, 1, 'die - reap at eval [ok - y]';
+ is $x, 1, 'die - localize at eval [ok - x]';
+ is $y, 1, 'die - localize at eval [ok - y]';
 }
 
 $y = undef;
@@ -176,14 +176,141 @@
    {
     local $x = 3;
     localize '$y' => 1 => UP UP;
-    is $x, 3,     'die - reap inside eval [not yet 1 - x]';
-    is $y, undef, 'die - reap inside eval [not yet 1 - y]';
-   }
-   is $x, 2,     'die - reap inside eval [not yet 2 - x]';
-   is $y, undef, 'die - reap inside eval [not yet 2 - y]';
+    is $x, 3,     'die - localize inside eval [not yet 1 - x]';
+    is $y, undef, 'die - localize inside eval [not yet 1 - y]';
+   }
+   is $x, 2,     'die - localize inside eval [not yet 2 - x]';
+   is $y, undef, 'die - localize inside eval [not yet 2 - y]';
    die;
   } # should trigger here
  };
- is $x, 1,     'die - reap inside eval [ok - x]';
- is $y, undef, 'die - reap inside eval [ok - y]';
-}
+ is $x, 1,     'die - localize inside eval [ok - x]';
+ is $y, undef, 'die - localize inside eval [ok - y]';
+}
+
+SKIP:
+{
+ skip 'Perl 5.10 required to test given/when' => 30 if $] < 5.010;
+
+ eval <<' GIVEN_TEST_1';
+  use feature 'switch';
+  local $y;
+  {
+   local $x = 1;
+   given (1) {
+    local $x = 2;
+    when (1) {
+     local $x = 3;
+     localize '$y' => 1 => UP UP;
+     is $x, 3,     'given/when - localize at given [not yet - x]';
+     is $y, undef, 'given/when - localize at given [not yet - y]';
+    }
+    fail 'not reached';
+   }
+   is $x, 1, 'given/when - localize at given [ok - x]';
+   is $y, 1, 'given/when - localize at given [ok - y]';
+  }
+ GIVEN_TEST_1
+ fail $@ if $@;
+
+ eval <<' GIVEN_TEST_2';
+  use feature 'switch';
+  local $y;
+  {
+   local $x = 1;
+   given (1) {
+    local $x = 2;
+    when (1) {
+     local $x = 3;
+     localize '$y' => 1 => UP UP;
+     is $x, 3,     'given/when/continue - localize at given [not yet 1 - x]';
+     is $y, undef, 'given/when/continue - localize at given [not yet 1 - y]';
+     continue;
+    }
+    is $x, 2,     'given/when/continue - localize at given [not yet 2 - x]';
+    is $y, undef, 'given/when/continue - localize at given [not yet 2 - y]';
+   }
+   is $x, 1, 'given/when/continue - localize at given [ok - x]';
+   is $y, 1, 'given/when/continue - localize at given [ok - y]';
+  }
+ GIVEN_TEST_2
+ fail $@ if $@;
+
+ eval <<' GIVEN_TEST_3';
+  use feature 'switch';
+  local $y;
+  {
+   local $x = 1;
+   given (1) {
+    local $x = 2;
+    default {
+     local $x = 3;
+     localize '$y' => 1 => UP UP;
+     is $x, 3,     'given/default - localize at given [not yet - x]';
+     is $y, undef, 'given/default - localize at given [not yet - y]';
+    }
+    fail 'not reached';
+   }
+   is $x, 1, 'given/default - localize at given [ok - x]';
+   is $y, 1, 'given/default - localize at given [ok - y]';
+  }
+ GIVEN_TEST_3
+ fail $@ if $@;
+
+ eval <<' GIVEN_TEST_4';
+  use feature 'switch';
+  local $y;
+  {
+   local $x = 1;
+   given (1) {
+    local $x = 2;
+    default {
+     local $x = 3;
+     localize '$y' => 1 => UP UP;
+     is $x, 3,     'given/default/continue - localize at given [not yet 1 - x]';
+     is $y, undef, 'given/default/continue - localize at given [not yet 1 - y]';
+     continue;
+    }
+    is $x, 2,     'given/default/continue - localize at given [not yet 2 - x]';
+    is $y, undef, 'given/default/continue - localize at given [not yet 2 - y]';
+   }
+   is $x, 1, 'given/default/continue - localize at given [ok - x]';
+   is $y, 1, 'given/default/continue - localize at given [ok - y]';
+  }
+ GIVEN_TEST_4
+ fail $@ if $@;
+
+ eval <<' GIVEN_TEST_5';
+  use feature 'switch';
+  local $y;
+  {
+   local $x = 1;
+   given (1) {
+    local $x = 2;
+    default {
+     local $x = 3;
+     given (2) {
+      local $x = 4;
+      when (2) {
+       local $x = 5;
+       localize '$y' => 1 => UP UP UP;
+       is $x, 5,     'given/default/given/when - localize at default [not yet 1 - x]';
+       is $y, undef, 'given/default/given/when - localize at default [not yet 1 - y]';
+       continue;
+      }
+      is $x, 4,     'given/default/given/when - localize at default [not yet 2 - x]';
+      is $y, undef, 'given/default/given/when - localize at default [not yet 2 - y]';
+     }
+     is $x, 3,     'given/default/given/when - localize at default [not yet 3 - x]';
+     is $y, undef, 'given/default/given/when - localize at default [not yet 3 - y]';
+     continue;
+    }
+    is $x, 2, 'given/default/given/when - localize at default [ok 1 - x]';
+    is $y, 1, 'given/default/given/when - localize at default [ok 1 - y]';
+   }
+   is $x, 1,     'given/default/given/when - localize at default [ok 2 - x]';
+   is $y, undef, 'given/default/given/when - localize at default [ok 2 - y]';
+  }
+ GIVEN_TEST_5
+ fail $@ if $@;
+}

Modified: branches/upstream/libscope-upper-perl/current/t/99-kwalitee.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscope-upper-perl/current/t/99-kwalitee.t?rev=51267&op=diff
==============================================================================
--- branches/upstream/libscope-upper-perl/current/t/99-kwalitee.t (original)
+++ branches/upstream/libscope-upper-perl/current/t/99-kwalitee.t Tue Jan 19 20:02:54 2010
@@ -5,5 +5,17 @@
 
 use Test::More;
 
-eval { require Test::Kwalitee; Test::Kwalitee->import() };
-plan( skip_all => 'Test::Kwalitee not installed; skipping' ) if $@;
+eval { require Test::Kwalitee; };
+plan(skip_all => 'Test::Kwalitee not installed') if $@;
+
+SKIP: {
+ eval { Test::Kwalitee->import(); };
+ if (my $err = $@) {
+  1 while chomp $err;
+  require Test::Builder;
+  my $Test = Test::Builder->new;
+  my $plan = $Test->has_plan;
+  $Test->skip_all($err) if not defined $plan or $plan eq 'no_plan';
+  skip $err => $plan - $Test->current_test;
+ }
+}

Modified: branches/upstream/libscope-upper-perl/current/t/lib/Scope/Upper/TestGenerator.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libscope-upper-perl/current/t/lib/Scope/Upper/TestGenerator.pm?rev=51267&op=diff
==============================================================================
--- branches/upstream/libscope-upper-perl/current/t/lib/Scope/Upper/TestGenerator.pm (original)
+++ branches/upstream/libscope-upper-perl/current/t/lib/Scope/Upper/TestGenerator.pm Tue Jan 19 20:02:54 2010
@@ -24,6 +24,14 @@
  [ 'for (1) {', '}' ],
  [ 'eval q[',   '];' ],
 );
+
+sub import {
+ if ($] >= 5.010001) {
+  push @blocks, [ 'given (1) {', '}' ];
+  require feature;
+  feature->import('switch');
+ }
+}
 
 @blocks = map [ map "$_\n", @$_ ], @blocks;
 




More information about the Pkg-perl-cvs-commits mailing list