ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Guard/Guard.xs
(Generate patch)

Comparing Guard/Guard.xs (file contents):
Revision 1.4 by root, Sat Dec 13 19:43:27 2008 UTC vs.
Revision 1.10 by root, Sun Jul 19 04:43:47 2009 UTC

1#define PERL_NO_GET_CONTEXT 1#define PERL_NO_GET_CONTEXT
2 2
3#include "EXTERN.h" 3#include "EXTERN.h"
4#include "perl.h" 4#include "perl.h"
5#include "XSUB.h" 5#include "XSUB.h"
6
7#ifndef SvSTASH_set
8# define SvSTASH_set(x,a) SvSTASH(x) = (a)
9#endif
10
11#ifndef PERL_MAGIC_ext
12# define PERL_MAGIC_ext '~'
13#endif
6 14
7static HV *guard_stash; 15static HV *guard_stash;
8 16
9static SV * 17static SV *
10guard_get_cv (pTHX_ SV *cb_sv) 18guard_get_cv (pTHX_ SV *cb_sv)
31 PUSHSTACKi (PERLSI_DESTROY); 39 PUSHSTACKi (PERLSI_DESTROY);
32 40
33 PUSHMARK (SP); 41 PUSHMARK (SP);
34 PUTBACK; 42 PUTBACK;
35 call_sv (cb, G_VOID | G_DISCARD | G_EVAL); 43 call_sv (cb, G_VOID | G_DISCARD | G_EVAL);
36 SPAGAIN;
37 44
38 if (SvTRUE (ERRSV)) 45 if (SvTRUE (ERRSV))
39 { 46 {
47 SPAGAIN;
48
40 PUSHMARK (SP); 49 PUSHMARK (SP);
41 PUTBACK; 50 PUTBACK;
42 call_sv (get_sv ("Guard::DIED", 1), G_VOID | G_DISCARD | G_EVAL | G_KEEPERR); 51 call_sv (get_sv ("Guard::DIED", 1), G_VOID | G_DISCARD | G_EVAL | G_KEEPERR);
43 SPAGAIN;
44 52
45 sv_setpvn (ERRSV, "", 0); 53 sv_setpvn (ERRSV, "", 0);
46 } 54 }
47 55
48 if (saveerr) 56 if (saveerr)
53 PL_diehook = savedie; 61 PL_diehook = savedie;
54 SvREFCNT_dec (oldhook); 62 SvREFCNT_dec (oldhook);
55 } 63 }
56 64
57 POPSTACK; 65 POPSTACK;
58 PUTBACK;
59} 66}
60 67
61static void 68static void
62scope_guard_cb (pTHX_ void *cv) 69scope_guard_cb (pTHX_ void *cv)
63{ 70{
66 73
67static int 74static int
68guard_free (pTHX_ SV *cv, MAGIC *mg) 75guard_free (pTHX_ SV *cv, MAGIC *mg)
69{ 76{
70 exec_guard_cb (aTHX_ mg->mg_obj); 77 exec_guard_cb (aTHX_ mg->mg_obj);
78
79 return 0;
71} 80}
72 81
73static MGVTBL guard_vtbl = { 82static MGVTBL guard_vtbl = {
74 0, 0, 0, 0, 83 0, 0, 0, 0,
75 guard_free 84 guard_free
77 86
78MODULE = Guard PACKAGE = Guard 87MODULE = Guard PACKAGE = Guard
79 88
80BOOT: 89BOOT:
81 guard_stash = gv_stashpv ("Guard", 1); 90 guard_stash = gv_stashpv ("Guard", 1);
82 91 CvNODEBUG_on (get_cv ("Guard::scope_guard", 0)); /* otherwise calling scope can be the debugger */
83void
84CLONE (...)
85 PROTOTYPE: @
86 CODE:
87 guard_stash = gv_stashpv ("Guard", 1);
88 92
89void 93void
90scope_guard (SV *block) 94scope_guard (SV *block)
91 PROTOTYPE: & 95 PROTOTYPE: &
92 CODE: 96 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines