sv.h

来自「MSYS在windows下模拟了一个类unix的终端」· C头文件 代码 · 共 1,102 行 · 第 1/3 页

H
1,102
字号
#define BmUSEFUL(sv)	((XPVBM*)  SvANY(sv))->xbm_useful#define BmPREVIOUS(sv)	((XPVBM*)  SvANY(sv))->xbm_previous#define FmLINES(sv)	((XPVFM*)  SvANY(sv))->xfm_lines#define LvTYPE(sv)	((XPVLV*)  SvANY(sv))->xlv_type#define LvTARG(sv)	((XPVLV*)  SvANY(sv))->xlv_targ#define LvTARGOFF(sv)	((XPVLV*)  SvANY(sv))->xlv_targoff#define LvTARGLEN(sv)	((XPVLV*)  SvANY(sv))->xlv_targlen#define IoIFP(sv)	((XPVIO*)  SvANY(sv))->xio_ifp#define IoOFP(sv)	((XPVIO*)  SvANY(sv))->xio_ofp#define IoDIRP(sv)	((XPVIO*)  SvANY(sv))->xio_dirp#define IoANY(sv)	((XPVIO*)  SvANY(sv))->xio_any#define IoLINES(sv)	((XPVIO*)  SvANY(sv))->xio_lines#define IoPAGE(sv)	((XPVIO*)  SvANY(sv))->xio_page#define IoPAGE_LEN(sv)	((XPVIO*)  SvANY(sv))->xio_page_len#define IoLINES_LEFT(sv)((XPVIO*)  SvANY(sv))->xio_lines_left#define IoTOP_NAME(sv)	((XPVIO*)  SvANY(sv))->xio_top_name#define IoTOP_GV(sv)	((XPVIO*)  SvANY(sv))->xio_top_gv#define IoFMT_NAME(sv)	((XPVIO*)  SvANY(sv))->xio_fmt_name#define IoFMT_GV(sv)	((XPVIO*)  SvANY(sv))->xio_fmt_gv#define IoBOTTOM_NAME(sv)((XPVIO*) SvANY(sv))->xio_bottom_name#define IoBOTTOM_GV(sv)	((XPVIO*)  SvANY(sv))->xio_bottom_gv#define IoSUBPROCESS(sv)((XPVIO*)  SvANY(sv))->xio_subprocess#define IoTYPE(sv)	((XPVIO*)  SvANY(sv))->xio_type#define IoFLAGS(sv)	((XPVIO*)  SvANY(sv))->xio_flags/* IoTYPE(sv) is a single character telling the type of I/O connection. */#define IoTYPE_RDONLY	'<'#define IoTYPE_WRONLY	'>'#define IoTYPE_RDWR	'+'#define IoTYPE_APPEND 	'a'#define IoTYPE_PIPE	'|'#define IoTYPE_STD	'-'	/* stdin or stdout */#define IoTYPE_SOCKET	's'#define IoTYPE_CLOSED	' '/*=for apidoc Am|bool|SvTAINTED|SV* svChecks to see if an SV is tainted. Returns TRUE if it is, FALSE ifnot.=for apidoc Am|void|SvTAINTED_on|SV* svMarks an SV as tainted.=for apidoc Am|void|SvTAINTED_off|SV* svUntaints an SV. Be I<very> careful with this routine, as it short-circuitssome of Perl's fundamental security features. XS module authors should notuse this function unless they fully understand all the implications ofunconditionally untainting the value. Untainting should be done in thestandard perl fashion, via a carefully crafted regexp, rather than directlyuntainting variables.=for apidoc Am|void|SvTAINT|SV* svTaints an SV if tainting is enabled=cut*/#define SvTAINTED(sv)	  (SvMAGICAL(sv) && sv_tainted(sv))#define SvTAINTED_on(sv)  STMT_START{ if(PL_tainting){sv_taint(sv);}   }STMT_END#define SvTAINTED_off(sv) STMT_START{ if(PL_tainting){sv_untaint(sv);} }STMT_END#define SvTAINT(sv)			\    STMT_START {			\	if (PL_tainting) {		\	    if (PL_tainted)		\		SvTAINTED_on(sv);	\	}				\    } STMT_END/*=for apidoc Am|char*|SvPV_force|SV* sv|STRLEN lenLike <SvPV> but will force the SV into becoming a string (SvPOK).  You wantforce if you are going to update the SvPVX directly.=for apidoc Am|char*|SvPV|SV* sv|STRLEN lenReturns a pointer to the string in the SV, or a stringified form of the SVif the SV does not contain a string.  Handles 'get' magic.=for apidoc Am|char*|SvPV_nolen|SV* svReturns a pointer to the string in the SV, or a stringified form of the SVif the SV does not contain a string.  Handles 'get' magic.=for apidoc Am|IV|SvIV|SV* svCoerces the given SV to an integer and returns it.=for apidoc Am|NV|SvNV|SV* svCoerce the given SV to a double and return it.=for apidoc Am|UV|SvUV|SV* svCoerces the given SV to an unsigned integer and returns it.=for apidoc Am|bool|SvTRUE|SV* svReturns a boolean indicating whether Perl would evaluate the SV as true orfalse, defined or undefined.  Does not handle 'get' magic.=cut*/#define SvPV_force(sv, lp) sv_pvn_force(sv, &lp)#define SvPV(sv, lp) sv_pvn(sv, &lp)#define SvPV_nolen(sv) sv_pv(sv)#define SvPVutf8_force(sv, lp) sv_pvutf8n_force(sv, &lp)#define SvPVutf8(sv, lp) sv_pvutf8n(sv, &lp)#define SvPVutf8_nolen(sv) sv_pvutf8(sv)#define SvPVbyte_force(sv, lp) sv_pvbyte_force(sv, &lp)#define SvPVbyte(sv, lp) sv_pvbyten(sv, &lp)#define SvPVbyte_nolen(sv) sv_pvbyte(sv)#define SvPVx(sv, lp) sv_pvn(sv, &lp)#define SvPVx_force(sv, lp) sv_pvn_force(sv, &lp)#define SvPVutf8x(sv, lp) sv_pvutf8n(sv, &lp)#define SvPVutf8x_force(sv, lp) sv_pvutf8n_force(sv, &lp)#define SvPVbytex(sv, lp) sv_pvbyten(sv, &lp)#define SvPVbytex_force(sv, lp) sv_pvbyten_force(sv, &lp)#define SvIVx(sv) sv_iv(sv)#define SvUVx(sv) sv_uv(sv)#define SvNVx(sv) sv_nv(sv)#define SvTRUEx(sv) sv_true(sv)#define SvIV(sv) SvIVx(sv)#define SvNV(sv) SvNVx(sv)#define SvUV(sv) SvUVx(sv)#define SvTRUE(sv) SvTRUEx(sv)#ifndef CRIPPLED_CC/* redefine some things to more efficient inlined versions *//* Let us hope that bitmaps for UV and IV are the same */#undef SvIV#define SvIV(sv) (SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv))#undef SvUV#define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv))#undef SvNV#define SvNV(sv) (SvNOK(sv) ? SvNVX(sv) : sv_2nv(sv))#undef SvPV#define SvPV(sv, lp) \    ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \     ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv(sv, &lp))#undef SvPV_force#define SvPV_force(sv, lp) \    ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \     ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force(sv, &lp))#undef SvPV_nolen#define SvPV_nolen(sv) \    ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \     ? SvPVX(sv) : sv_2pv_nolen(sv))#undef SvPVutf8#define SvPVutf8(sv, lp) \    ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK|SVf_UTF8) \     ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvutf8(sv, &lp))#undef SvPVutf8_force#define SvPVutf8_force(sv, lp) \    ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == (SVf_POK|SVf_UTF8) \     ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvutf8n_force(sv, &lp))#undef SvPVutf8_nolen#define SvPVutf8_nolen(sv) \    ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK|SVf_UTF8)\     ? SvPVX(sv) : sv_2pvutf8_nolen(sv))#undef SvPVutf8#define SvPVutf8(sv, lp) \    ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK|SVf_UTF8) \     ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvutf8(sv, &lp))#undef SvPVutf8_force#define SvPVutf8_force(sv, lp) \    ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == (SVf_POK|SVf_UTF8) \     ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvutf8n_force(sv, &lp))#undef SvPVutf8_nolen#define SvPVutf8_nolen(sv) \    ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK|SVf_UTF8)\     ? SvPVX(sv) : sv_2pvutf8_nolen(sv))#undef SvPVbyte#define SvPVbyte(sv, lp) \    ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \     ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp))#undef SvPVbyte_force#define SvPVbyte_force(sv, lp) \    ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8|SVf_THINKFIRST)) == (SVf_POK) \     ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvbyte_force(sv, &lp))#undef SvPVbyte_nolen#define SvPVbyte_nolen(sv) \    ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK)\     ? SvPVX(sv) : sv_2pvbyte_nolen(sv))#ifdef __GNUC__#  undef SvIVx#  undef SvUVx#  undef SvNVx#  undef SvPVx#  undef SvPVutf8x#  undef SvPVbytex#  undef SvTRUE#  undef SvTRUEx#  define SvIVx(sv) ({SV *nsv = (SV*)(sv); SvIV(nsv); })#  define SvUVx(sv) ({SV *nsv = (SV*)(sv); SvUV(nsv); })#  define SvNVx(sv) ({SV *nsv = (SV*)(sv); SvNV(nsv); })#  define SvPVx(sv, lp) ({SV *nsv = (sv); SvPV(nsv, lp); })#  define SvPVutf8x(sv, lp) ({SV *nsv = (sv); SvPVutf8(nsv, lp); })#  define SvPVbytex(sv, lp) ({SV *nsv = (sv); SvPVbyte(nsv, lp); })#  define SvTRUE(sv) (						\    !sv								\    ? 0								\    :    SvPOK(sv)						\	?   (({XPV *nxpv = (XPV*)SvANY(sv);			\	     nxpv &&						\	     (nxpv->xpv_cur > 1 ||				\	      (nxpv->xpv_cur && *nxpv->xpv_pv != '0')); })	\	     ? 1						\	     : 0)						\	:							\	    SvIOK(sv)						\	    ? SvIVX(sv) != 0					\	    :   SvNOK(sv)					\		? SvNVX(sv) != 0.0				\		: sv_2bool(sv) )#  define SvTRUEx(sv) ({SV *nsv = (sv); SvTRUE(nsv); })#else /* __GNUC__ */#ifndef USE_THREADS/* These inlined macros use globals, which will require a thread * declaration in user code, so we avoid them under threads */#  undef SvIVx#  undef SvUVx#  undef SvNVx#  undef SvPVx#  undef SvPVutf8x#  undef SvPVbytex#  undef SvTRUE#  undef SvTRUEx#  define SvIVx(sv) ((PL_Sv = (sv)), SvIV(PL_Sv))#  define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv))#  define SvNVx(sv) ((PL_Sv = (sv)), SvNV(PL_Sv))#  define SvPVx(sv, lp) ((PL_Sv = (sv)), SvPV(PL_Sv, lp))#  define SvPVutf8x(sv, lp) ((PL_Sv = (sv)), SvPVutf8(PL_Sv, lp))#  define SvPVbytex(sv, lp) ((PL_Sv = (sv)), SvPVbyte(PL_Sv, lp))#  define SvTRUE(sv) (						\    !sv								\    ? 0								\    :    SvPOK(sv)						\	?   ((PL_Xpv = (XPV*)SvANY(sv)) &&			\	     (PL_Xpv->xpv_cur > 1 ||				\	      (PL_Xpv->xpv_cur && *PL_Xpv->xpv_pv != '0'))	\	     ? 1						\	     : 0)						\	:							\	    SvIOK(sv)						\	    ? SvIVX(sv) != 0					\	    :   SvNOK(sv)					\		? SvNVX(sv) != 0.0				\		: sv_2bool(sv) )#  define SvTRUEx(sv) ((PL_Sv = (sv)), SvTRUE(PL_Sv))#endif /* !USE_THREADS */#endif /* !__GNU__ */#endif /* !CRIPPLED_CC *//*=for apidoc Am|SV*|newRV_inc|SV* svCreates an RV wrapper for an SV.  The reference count for the original SV isincremented.=cut*/#define newRV_inc(sv)	newRV(sv)/* the following macros update any magic values this sv is associated with *//*=for apidoc Am|void|SvGETMAGIC|SV* svInvokes C<mg_get> on an SV if it has 'get' magic.  This macro evaluates itsargument more than once.=for apidoc Am|void|SvSETMAGIC|SV* svInvokes C<mg_set> on an SV if it has 'set' magic.  This macro evaluates itsargument more than once.=for apidoc Am|void|SvSetSV|SV* dsb|SV* ssvCalls C<sv_setsv> if dsv is not the same as ssv.  May evaluate argumentsmore than once.=for apidoc Am|void|SvSetSV_nosteal|SV* dsv|SV* ssvCalls a non-destructive version of C<sv_setsv> if dsv is not the same asssv. May evaluate arguments more than once.=for apidoc Am|void|SvGROW|SV* sv|STRLEN lenExpands the character buffer in the SV so that it has room for theindicated number of bytes (remember to reserve space for an extra trailingNUL character).  Calls C<sv_grow> to perform the expansion if necessary. Returns a pointer to the character buffer.=cut*/#define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END#define SvSETMAGIC(x) STMT_START { if (SvSMAGICAL(x)) mg_set(x); } STMT_END#define SvSetSV_and(dst,src,finally) \	STMT_START {					\	    if ((dst) != (src)) {			\		sv_setsv(dst, src);			\		finally;				\	    }						\	} STMT_END#define SvSetSV_nosteal_and(dst,src,finally) \	STMT_START {					\	    if ((dst) != (src)) {			\		U32 tMpF = SvFLAGS(src) & SVs_TEMP;	\		SvTEMP_off(src);			\		sv_setsv(dst, src);			\		SvFLAGS(src) |= tMpF;			\		finally;				\	    }						\	} STMT_END#define SvSetSV(dst,src) \		SvSetSV_and(dst,src,/*nothing*/;)#define SvSetSV_nosteal(dst,src) \		SvSetSV_nosteal_and(dst,src,/*nothing*/;)#define SvSetMagicSV(dst,src) \		SvSetSV_and(dst,src,SvSETMAGIC(dst))#define SvSetMagicSV_nosteal(dst,src) \		SvSetSV_nosteal_and(dst,src,SvSETMAGIC(dst))#ifdef DEBUGGING#define SvPEEK(sv) sv_peek(sv)#else#define SvPEEK(sv) ""#endif#define SvIMMORTAL(sv) ((sv)==&PL_sv_undef || (sv)==&PL_sv_yes || (sv)==&PL_sv_no)#define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)#define isGV(sv) (SvTYPE(sv) == SVt_PVGV)#define SvGROW(sv,len) (SvLEN(sv) < (len) ? sv_grow(sv,len) : SvPVX(sv))#define Sv_Grow sv_grow#define CLONEf_COPY_STACKS 1#define CLONEf_KEEP_PTR_TABLE 2

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?