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

Comparing Devel-FindRef/FindRef.xs (file contents):
Revision 1.11 by root, Fri Jul 11 17:59:19 2008 UTC vs.
Revision 1.13 by root, Sat Jul 19 01:38:57 2008 UTC

42MODULE = Devel::FindRef PACKAGE = Devel::FindRef 42MODULE = Devel::FindRef PACKAGE = Devel::FindRef
43 43
44PROTOTYPES: ENABLE 44PROTOTYPES: ENABLE
45 45
46SV * 46SV *
47ptr2ref (IV ptr) 47ptr2ref (UV ptr)
48 CODE: 48 CODE:
49 RETVAL = newRV_inc (INT2PTR (SV *, ptr)); 49 RETVAL = newRV_inc (INT2PTR (SV *, ptr));
50 OUTPUT:
51 RETVAL
52
53UV
54ref2ptr (SV *rv)
55 CODE:
56 RETVAL = PTR2UV (SvRV (rv));
50 OUTPUT: 57 OUTPUT:
51 RETVAL 58 RETVAL
52 59
53void 60void
54find_ (SV *target) 61find_ (SV *target)
151 { 158 {
152 AV *pad = (AV *)AvARRAY (padlist)[depth]; 159 AV *pad = (AV *)AvARRAY (padlist)[depth];
153 160
154 av_push (excl, newSVuv (PTR2UV (pad))); /* exclude pads themselves from being found */ 161 av_push (excl, newSVuv (PTR2UV (pad))); /* exclude pads themselves from being found */
155 162
163 /* The 0th pad slot is @_ */
164 if (AvARRAY (pad)[0] == targ)
165 res_pair ("the argument array for");
166
156 for (i = AvFILLp (pad) + 1; i--; ) 167 for (i = AvFILLp (pad) + 1; --i; )
157 if (AvARRAY (pad)[i] == targ) 168 if (AvARRAY (pad)[i] == targ)
158 { 169 {
159 /* Values from constant functions are stored in the pad without any name */ 170 /* Values from constant functions are stored in the pad without any name */
160 SV *name_sv = AvARRAY (AvARRAY (padlist)[0])[i]; 171 SV *name_sv = AvARRAY (AvARRAY (padlist)[0])[i];
161 172
204 if (rmagical) 215 if (rmagical)
205 SvRMAGICAL_on (sv); 216 SvRMAGICAL_on (sv);
206 } 217 }
207 } 218 }
208 219
220 if (targ == (SV*)PL_main_cv)
221 res_text ("the main body of the program");
222
209 EXTEND (SP, 2); 223 EXTEND (SP, 2);
210 PUSHs (sv_2mortal (newRV_noinc ((SV *)about))); 224 PUSHs (sv_2mortal (newRV_noinc ((SV *)about)));
211 PUSHs (sv_2mortal (newRV_noinc ((SV *)excl))); 225 PUSHs (sv_2mortal (newRV_noinc ((SV *)excl)));
212} 226}
213 227

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines