… | |
… | |
208 | } |
208 | } |
209 | |
209 | |
210 | bool |
210 | bool |
211 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
211 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
212 | { |
212 | { |
213 | if (!perl) |
213 | // INIT and DESTROY must be requested by the runtime |
|
|
214 | |
|
|
215 | if (!perl || !should_invoke [htype]) |
214 | return false; |
216 | return false; |
215 | |
217 | |
216 | if (htype == HOOK_INIT) // first hook ever called |
218 | if (htype == HOOK_INIT) // first hook ever called |
217 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
219 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
218 | else if (htype == HOOK_DESTROY) |
|
|
219 | { |
|
|
220 | // TODO: clear magic |
|
|
221 | hv_clear ((HV *)SvRV ((SV *)term->self)); |
|
|
222 | SvREFCNT_dec ((SV *)term->self); |
|
|
223 | } |
|
|
224 | |
220 | |
225 | if (!should_invoke [htype]) |
|
|
226 | return false; |
|
|
227 | |
|
|
228 | dSP; |
221 | dSP; |
229 | va_list ap; |
222 | va_list ap; |
230 | |
223 | |
231 | va_start (ap, htype); |
224 | va_start (ap, htype); |
232 | |
225 | |
… | |
… | |
269 | FREETMPS; |
262 | FREETMPS; |
270 | LEAVE; |
263 | LEAVE; |
271 | |
264 | |
272 | if (SvTRUE (ERRSV)) |
265 | if (SvTRUE (ERRSV)) |
273 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
266 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
267 | |
|
|
268 | if (htype == HOOK_DESTROY) |
|
|
269 | { |
|
|
270 | // TODO: clear magic |
|
|
271 | hv_clear ((HV *)SvRV ((SV *)term->self)); |
|
|
272 | SvREFCNT_dec ((SV *)term->self); |
|
|
273 | } |
274 | |
274 | |
275 | return count; |
275 | return count; |
276 | } |
276 | } |
277 | |
277 | |
278 | default: |
278 | default: |