1 #define ST(off) stack_base[ax + (off)]
4 #define XS(name) void name(CV* cv)
6 #define XS(name) void name(cv) CV* cv;
11 I32 ax = mark - stack_base + 1; \
14 #define XSANY CvXSUBANY(cv)
16 #define dXSI32 I32 ix = XSANY.any_i32
18 #define XSRETURN(off) stack_sp = stack_base + ax + ((off) - 1); return
20 /* Simple macros to put new mortal values onto the stack. */
21 /* Typically used to return values from XS functions. */
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)
29 #define XSRETURN_IV(v) STMT_START { XST_mIV(0,v); XSRETURN(1); } STMT_END
30 #define XSRETURN_NV(v) STMT_START { XST_mNV(0,v); XSRETURN(1); } STMT_END
31 #define XSRETURN_PV(v) STMT_START { XST_mPV(0,v); XSRETURN(1); } STMT_END
32 #define XSRETURN_NO STMT_START { XST_mNO(0); XSRETURN(1); } STMT_END
33 #define XSRETURN_YES STMT_START { XST_mYES(0); XSRETURN(1); } STMT_END
34 #define XSRETURN_UNDEF STMT_START { XST_mUNDEF(0); XSRETURN(1); } STMT_END
35 #define XSRETURN_EMPTY STMT_START { XSRETURN(0); } STMT_END
37 #define newXSproto(a,b,c,d) sv_setpv((SV*)newXS(a,b,c), d)
40 # define XS_VERSION_BOOTCHECK \
42 char vn[255], *module = SvPV(ST(0),na); \
43 if (items >= 2) /* version supplied as bootstrap arg */ \
46 sprintf(vn,"%s::XS_VERSION", module); \
47 Sv = perl_get_sv(vn, FALSE); /* XXX GV_ADDWARN */ \
48 if (!Sv || !SvOK(Sv)) { \
49 sprintf(vn,"%s::VERSION", module); \
50 Sv = perl_get_sv(vn, FALSE); /* XXX GV_ADDWARN */ \
53 if (!Sv || !SvOK(Sv)) \
54 croak("%s object can't find $%s::XS_VERSION or $%s::VERSION", \
55 module, module, module); \
56 else if (strNE(XS_VERSION, SvPV(Sv, na))) \
57 croak("%s object version %s does not match $%s %s", \
58 module, XS_VERSION, vn, SvPV(Sv, na)); \
61 # define XS_VERSION_BOOTCHECK