1 #define ST(off) stack_base[ax + (off)]
5 #define XS(name) void name(CPerlObj* pPerl, CV* cv)
7 #define XS(name) void name(CV* cv)
10 #define XS(name) void name(cv) CV* cv;
13 #if defined(WIN32) && defined(__GNUC__)
14 #define STRINGIFY_THINGY(x) #x
15 #define FORCE_ARG_STRING(x) STRINGIFY_THINGY(x)
17 #define FORCE_ARG_STRING(x) x
22 I32 ax = mark - stack_base + 1; \
25 #define XSANY CvXSUBANY(cv)
27 #define dXSI32 I32 ix = XSANY.any_i32
29 #define XSRETURN(off) \
31 stack_sp = stack_base + ax + ((off) - 1); \
35 /* Simple macros to put new mortal values onto the stack. */
36 /* Typically used to return values from XS functions. */
37 #define XST_mIV(i,v) (ST(i) = sv_2mortal(newSViv(v)) )
38 #define XST_mNV(i,v) (ST(i) = sv_2mortal(newSVnv(v)) )
39 #define XST_mPV(i,v) (ST(i) = sv_2mortal(newSVpv(v,0)))
40 #define XST_mNO(i) (ST(i) = &sv_no )
41 #define XST_mYES(i) (ST(i) = &sv_yes )
42 #define XST_mUNDEF(i) (ST(i) = &sv_undef)
44 #define XSRETURN_IV(v) STMT_START { XST_mIV(0,v); XSRETURN(1); } STMT_END
45 #define XSRETURN_NV(v) STMT_START { XST_mNV(0,v); XSRETURN(1); } STMT_END
46 #define XSRETURN_PV(v) STMT_START { XST_mPV(0,v); XSRETURN(1); } STMT_END
47 #define XSRETURN_NO STMT_START { XST_mNO(0); XSRETURN(1); } STMT_END
48 #define XSRETURN_YES STMT_START { XST_mYES(0); XSRETURN(1); } STMT_END
49 #define XSRETURN_UNDEF STMT_START { XST_mUNDEF(0); XSRETURN(1); } STMT_END
50 #define XSRETURN_EMPTY STMT_START { XSRETURN(0); } STMT_END
52 #define newXSproto(a,b,c,d) sv_setpv((SV*)newXS(a,b,c), d)
55 # define XS_VERSION_BOOTCHECK \
57 char *xs_version = FORCE_ARG_STRING(XS_VERSION); \
58 char *vn = "", *module = SvPV(ST(0),na); \
59 if (items >= 2) /* version supplied as bootstrap arg */ \
62 /* XXX GV_ADDWARN */ \
63 Sv = perl_get_sv(form("%s::%s", module, \
64 vn = "XS_VERSION"), FALSE); \
65 if (!Sv || !SvOK(Sv)) \
66 Sv = perl_get_sv(form("%s::%s", module, \
67 vn = "VERSION"), FALSE); \
69 if (Sv && (!SvOK(Sv) || strNE(xs_version, SvPV(Sv, na)))) \
70 croak("%s object version %s does not match $%s::%s %_", \
71 module, xs_version, module, vn, Sv); \
74 # define XS_VERSION_BOOTCHECK