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.12 by root, Sat Jul 19 01:17:12 2008 UTC vs.
Revision 1.14 by root, Mon Dec 1 13:22:43 2008 UTC

40 GvNAME (sv) ? GvNAME (sv) : "<anonymous>")) 40 GvNAME (sv) ? GvNAME (sv) : "<anonymous>"))
41 41
42MODULE = Devel::FindRef PACKAGE = Devel::FindRef 42MODULE = Devel::FindRef PACKAGE = Devel::FindRef
43 43
44PROTOTYPES: ENABLE 44PROTOTYPES: ENABLE
45
46SV *
47ptr2ref (UV ptr)
48 CODE:
49 RETVAL = newRV_inc (INT2PTR (SV *, ptr));
50 OUTPUT:
51 RETVAL
52
53UV
54ref2ptr (SV *rv)
55 CODE:
56 RETVAL = PTR2UV (SvRV (rv));
57 OUTPUT:
58 RETVAL
59 45
60void 46void
61find_ (SV *target) 47find_ (SV *target)
62 PPCODE: 48 PPCODE:
63{ 49{
112 mg = mg->mg_moremagic; 98 mg = mg->mg_moremagic;
113 } 99 }
114 } 100 }
115 } 101 }
116 102
117 if (SvROK (sv)) 103 if (SvROK (sv) && !SvWEAKREF (sv))
118 { 104 {
119 if (sv != target && SvRV (sv) == targ && !SvWEAKREF (sv)) 105 if (sv != target && SvRV (sv) == targ && !SvWEAKREF (sv))
120 res_pair ("referenced by"); 106 res_pair ("referenced by");
121 } 107 }
122 else 108 else
158 { 144 {
159 AV *pad = (AV *)AvARRAY (padlist)[depth]; 145 AV *pad = (AV *)AvARRAY (padlist)[depth];
160 146
161 av_push (excl, newSVuv (PTR2UV (pad))); /* exclude pads themselves from being found */ 147 av_push (excl, newSVuv (PTR2UV (pad))); /* exclude pads themselves from being found */
162 148
149 /* The 0th pad slot is @_ */
150 if (AvARRAY (pad)[0] == targ)
151 res_pair ("the argument array for");
152
163 for (i = AvFILLp (pad) + 1; i--; ) 153 for (i = AvFILLp (pad) + 1; --i; )
164 if (AvARRAY (pad)[i] == targ) 154 if (AvARRAY (pad)[i] == targ)
165 { 155 {
166 /* Values from constant functions are stored in the pad without any name */ 156 /* Values from constant functions are stored in the pad without any name */
167 SV *name_sv = AvARRAY (AvARRAY (padlist)[0])[i]; 157 SV *name_sv = AvARRAY (AvARRAY (padlist)[0])[i];
168 158
211 if (rmagical) 201 if (rmagical)
212 SvRMAGICAL_on (sv); 202 SvRMAGICAL_on (sv);
213 } 203 }
214 } 204 }
215 205
206 if (targ == (SV*)PL_main_cv)
207 res_text ("the main body of the program");
208
216 EXTEND (SP, 2); 209 EXTEND (SP, 2);
217 PUSHs (sv_2mortal (newRV_noinc ((SV *)about))); 210 PUSHs (sv_2mortal (newRV_noinc ((SV *)about)));
218 PUSHs (sv_2mortal (newRV_noinc ((SV *)excl))); 211 PUSHs (sv_2mortal (newRV_noinc ((SV *)excl)));
219} 212}
220 213
214SV *
215ptr2ref (UV ptr)
216 CODE:
217 RETVAL = newRV_inc (INT2PTR (SV *, ptr));
218 OUTPUT:
219 RETVAL
220
221UV
222ref2ptr (SV *rv)
223 CODE:
224 RETVAL = PTR2UV (SvRV (rv));
225 OUTPUT:
226 RETVAL
227
228U32
229_refcnt (SV *rv)
230 CODE:
231 RETVAL = SvREFCNT (SvRV (rv));
232 OUTPUT:
233 RETVAL

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines