File: Caller.xs

package info (click to toggle)
libdevel-caller-perl 2.03-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 60 kB
  • ctags: 12
  • sloc: perl: 316; makefile: 52
file content (37 lines) | stat: -rw-r--r-- 759 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* -*- C -*- */
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

MODULE = Devel::Caller                PACKAGE = Devel::Caller

SV*
_context_cv(context)
SV* context;
  CODE:
    PERL_CONTEXT *cx = INT2PTR(PERL_CONTEXT *, SvIV(context));
    CV *cur_cv;

    if (cx->cx_type != CXt_SUB)
        croak("cx_type is %d not CXt_SUB\n", cx->cx_type);

    cur_cv = cx->blk_sub.cv;
    if (!cur_cv)
        croak("Context has no CV!\n");

    RETVAL = (SV*) newRV_inc( (SV*) cur_cv );
  OUTPUT:
    RETVAL

SV*
_context_op(context)
SV* context;
  CODE:
    PERL_CONTEXT *cx = INT2PTR(PERL_CONTEXT*, SvIV(context));
    OP *op = cx->blk_oldcop->op_next;
    SV *rv = newSV(0);
    sv_setref_iv(rv, "B::OP", PTR2IV(op));
    RETVAL = rv;
  OUTPUT:
    RETVAL