… | |
… | |
40 | GvNAME (sv) ? GvNAME (sv) : "<anonymous>")) |
40 | GvNAME (sv) ? GvNAME (sv) : "<anonymous>")) |
41 | |
41 | |
42 | MODULE = Devel::FindRef PACKAGE = Devel::FindRef |
42 | MODULE = Devel::FindRef PACKAGE = Devel::FindRef |
43 | |
43 | |
44 | PROTOTYPES: ENABLE |
44 | PROTOTYPES: ENABLE |
45 | |
|
|
46 | SV * |
|
|
47 | ptr2ref (UV ptr) |
|
|
48 | CODE: |
|
|
49 | RETVAL = newRV_inc (INT2PTR (SV *, ptr)); |
|
|
50 | OUTPUT: |
|
|
51 | RETVAL |
|
|
52 | |
|
|
53 | UV |
|
|
54 | ref2ptr (SV *rv) |
|
|
55 | CODE: |
|
|
56 | RETVAL = PTR2UV (SvRV (rv)); |
|
|
57 | OUTPUT: |
|
|
58 | RETVAL |
|
|
59 | |
45 | |
60 | void |
46 | void |
61 | find_ (SV *target) |
47 | find_ (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 | |
|
|
214 | SV * |
|
|
215 | ptr2ref (UV ptr) |
|
|
216 | CODE: |
|
|
217 | RETVAL = newRV_inc (INT2PTR (SV *, ptr)); |
|
|
218 | OUTPUT: |
|
|
219 | RETVAL |
|
|
220 | |
|
|
221 | UV |
|
|
222 | ref2ptr (SV *rv) |
|
|
223 | CODE: |
|
|
224 | RETVAL = PTR2UV (SvRV (rv)); |
|
|
225 | OUTPUT: |
|
|
226 | RETVAL |
|
|
227 | |
|
|
228 | U32 |
|
|
229 | _refcnt (SV *rv) |
|
|
230 | CODE: |
|
|
231 | RETVAL = SvREFCNT (SvRV (rv)); |
|
|
232 | OUTPUT: |
|
|
233 | RETVAL |