This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
This is patch.2b1e to perl5.002beta1. This is simply
[perl5.git] / XSUB.h
CommitLineData
4633a7c4 1#define ST(off) stack_base[ax + (off)]
a0d0e21e
LW
2
3#ifdef CAN_PROTOTYPE
4#define XS(name) void name(CV* cv)
5#else
6#define XS(name) void name(cv) CV* cv;
7#endif
8
9#define dXSARGS \
10 dSP; dMARK; \
11 I32 ax = mark - stack_base + 1; \
12 I32 items = sp - mark
13
14#define XSANY CvXSUBANY(cv)
15
16#define dXSI32 I32 ix = XSANY.any_i32
17
18#define XSRETURN(off) stack_sp = stack_base + ax + ((off) - 1); return
19
748a9306
LW
20/* Simple macros to put new mortal values onto the stack. */
21/* Typically used to return values from XS functions. */
4633a7c4
LW
22#define XST_mIV(i,v) (ST(i) = sv_2mortal(newSViv(v)) )
23#define XST_mNV(i,v) (ST(i) = sv_2mortal(newSVnv(v)) )
24#define XST_mPV(i,v) (ST(i) = sv_2mortal(newSVpv(v,0)))
25#define XST_mNO(i) (ST(i) = &sv_no )
26#define XST_mYES(i) (ST(i) = &sv_yes )
27#define XST_mUNDEF(i) (ST(i) = &sv_undef)
748a9306 28
4633a7c4
LW
29#define XSRETURN_IV(v) do { XST_mIV(0,v); XSRETURN(1); } while (0)
30#define XSRETURN_NV(v) do { XST_mNV(0,v); XSRETURN(1); } while (0)
31#define XSRETURN_PV(v) do { XST_mPV(0,v); XSRETURN(1); } while (0)
32#define XSRETURN_NO do { XST_mNO(0); XSRETURN(1); } while (0)
33#define XSRETURN_YES do { XST_mYES(0); XSRETURN(1); } while (0)
34#define XSRETURN_UNDEF do { XST_mUNDEF(0); XSRETURN(1); } while (0)
35#define XSRETURN_EMPTY do { XSRETURN(0); } while (0)
382b8d97
PM
36
37#define newXSproto(a,b,c,d) sv_setpv(newXS(a,b,c), d)