📄 sv.h
字号:
/*=for apidoc Am|U32|SvNIOK|SV* svReturns a U32 value indicating whether the SV contains a number, integer ordouble.=for apidoc Am|U32|SvNIOKp|SV* svReturns a U32 value indicating whether the SV contains a number, integer ordouble. Checks the B<private> setting. Use C<SvNIOK>.=for apidoc Am|void|SvNIOK_off|SV* svUnsets the NV/IV status of an SV.=for apidoc Am|U32|SvOK|SV* svReturns a U32 value indicating whether the value is an SV. It also tellswhether the value is defined or not.=for apidoc Am|U32|SvIOKp|SV* svReturns a U32 value indicating whether the SV contains an integer. Checksthe B<private> setting. Use C<SvIOK>.=for apidoc Am|U32|SvNOKp|SV* svReturns a U32 value indicating whether the SV contains a double. Checks theB<private> setting. Use C<SvNOK>.=for apidoc Am|U32|SvPOKp|SV* svReturns a U32 value indicating whether the SV contains a character string.Checks the B<private> setting. Use C<SvPOK>.=for apidoc Am|U32|SvIOK|SV* svReturns a U32 value indicating whether the SV contains an integer.=for apidoc Am|void|SvIOK_on|SV* svTells an SV that it is an integer.=for apidoc Am|void|SvIOK_off|SV* svUnsets the IV status of an SV.=for apidoc Am|void|SvIOK_only|SV* svTells an SV that it is an integer and disables all other OK bits.=for apidoc Am|void|SvIOK_only_UV|SV* svTells and SV that it is an unsigned integer and disables all other OK bits.=for apidoc Am|bool|SvIOK_UV|SV* svReturns a boolean indicating whether the SV contains an unsigned integer.=for apidoc Am|bool|SvUOK|SV* svReturns a boolean indicating whether the SV contains an unsigned integer.=for apidoc Am|bool|SvIOK_notUV|SV* svReturns a boolean indicating whether the SV contains a signed integer.=for apidoc Am|U32|SvNOK|SV* svReturns a U32 value indicating whether the SV contains a double.=for apidoc Am|void|SvNOK_on|SV* svTells an SV that it is a double.=for apidoc Am|void|SvNOK_off|SV* svUnsets the NV status of an SV.=for apidoc Am|void|SvNOK_only|SV* svTells an SV that it is a double and disables all other OK bits.=for apidoc Am|U32|SvPOK|SV* svReturns a U32 value indicating whether the SV contains a characterstring.=for apidoc Am|void|SvPOK_on|SV* svTells an SV that it is a string.=for apidoc Am|void|SvPOK_off|SV* svUnsets the PV status of an SV.=for apidoc Am|void|SvPOK_only|SV* svTells an SV that it is a string and disables all other OK bits.Will also turn off the UTF-8 status.=for apidoc Am|bool|SvVOK|SV* svReturns a boolean indicating whether the SV contains a v-string.=for apidoc Am|U32|SvOOK|SV* svReturns a U32 indicating whether the SvIVX is a valid offset value forthe SvPVX. This hack is used internally to speed up removal of charactersfrom the beginning of a SvPV. When SvOOK is true, then the start of theallocated string buffer is really (SvPVX - SvIVX).=for apidoc Am|U32|SvROK|SV* svTests if the SV is an RV.=for apidoc Am|void|SvROK_on|SV* svTells an SV that it is an RV.=for apidoc Am|void|SvROK_off|SV* svUnsets the RV status of an SV.=for apidoc Am|SV*|SvRV|SV* svDereferences an RV to return the SV.=for apidoc Am|IV|SvIVX|SV* svReturns the raw value in the SV's IV slot, without checks or conversions.Only use when you are sure SvIOK is true. See also C<SvIV()>.=for apidoc Am|UV|SvUVX|SV* svReturns the raw value in the SV's UV slot, without checks or conversions.Only use when you are sure SvIOK is true. See also C<SvUV()>.=for apidoc Am|NV|SvNVX|SV* svReturns the raw value in the SV's NV slot, without checks or conversions.Only use when you are sure SvNOK is true. See also C<SvNV()>.=for apidoc Am|char*|SvPVX|SV* svReturns a pointer to the physical string in the SV. The SV must contain astring.=for apidoc Am|STRLEN|SvCUR|SV* svReturns the length of the string which is in the SV. See C<SvLEN>.=for apidoc Am|STRLEN|SvLEN|SV* svReturns the size of the string buffer in the SV, not including any partattributable to C<SvOOK>. See C<SvCUR>.=for apidoc Am|char*|SvEND|SV* svReturns a pointer to the last character in the string which is in the SV.See C<SvCUR>. Access the character as *(SvEND(sv)).=for apidoc Am|HV*|SvSTASH|SV* svReturns the stash of the SV.=for apidoc Am|void|SvIV_set|SV* sv|IV valSet the value of the IV pointer in sv to val. It is possible to performthe same function of this macro with an lvalue assignment to C<SvIVX>.With future Perls, however, it will be more efficient to use C<SvIV_set> instead of the lvalue assignment to C<SvIVX>.=for apidoc Am|void|SvNV_set|SV* sv|NV valSet the value of the NV pointer in sv to val. See C<SvIV_set>.=for apidoc Am|void|SvPV_set|SV* sv|char* valSet the value of the PV pointer in sv to val. See C<SvIV_set>.=for apidoc Am|void|SvUV_set|SV* sv|UV valSet the value of the UV pointer in sv to val. See C<SvIV_set>.=for apidoc Am|void|SvRV_set|SV* sv|SV* valSet the value of the RV pointer in sv to val. See C<SvIV_set>.=for apidoc Am|void|SvMAGIC_set|SV* sv|MAGIC* valSet the value of the MAGIC pointer in sv to val. See C<SvIV_set>.=for apidoc Am|void|SvSTASH_set|SV* sv|HV* valSet the value of the STASH pointer in sv to val. See C<SvIV_set>.=for apidoc Am|void|SvCUR_set|SV* sv|STRLEN lenSet the current length of the string which is in the SV. See C<SvCUR>and C<SvIV_set>.=for apidoc Am|void|SvLEN_set|SV* sv|STRLEN lenSet the actual length of the string which is in the SV. See C<SvIV_set>.=cut*/#define SvNIOK(sv) (SvFLAGS(sv) & (SVf_IOK|SVf_NOK))#define SvNIOKp(sv) (SvFLAGS(sv) & (SVp_IOK|SVp_NOK))#define SvNIOK_off(sv) (SvFLAGS(sv) &= ~(SVf_IOK|SVf_NOK| \ SVp_IOK|SVp_NOK|SVf_IVisUV))#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)#define assert_not_ROK(sv) ({assert(!SvROK(sv) || !SvRV(sv));}),#define assert_not_glob(sv) ({assert(!isGV_with_GP(sv));}),#else#define assert_not_ROK(sv) #define assert_not_glob(sv) #endif#define SvOK(sv) ((SvTYPE(sv) == SVt_BIND) \ ? (SvFLAGS(SvRV(sv)) & SVf_OK) \ : (SvFLAGS(sv) & SVf_OK))#define SvOK_off(sv) (assert_not_ROK(sv) assert_not_glob(sv) \ SvFLAGS(sv) &= ~(SVf_OK| \ SVf_IVisUV|SVf_UTF8), \ SvOOK_off(sv))#define SvOK_off_exc_UV(sv) (assert_not_ROK(sv) \ SvFLAGS(sv) &= ~(SVf_OK| \ SVf_UTF8), \ SvOOK_off(sv))#define SvOKp(sv) (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK))#define SvIOKp(sv) (SvFLAGS(sv) & SVp_IOK)#define SvIOKp_on(sv) (assert_not_glob(sv) SvRELEASE_IVX(sv), \ SvFLAGS(sv) |= SVp_IOK)#define SvNOKp(sv) (SvFLAGS(sv) & SVp_NOK)#define SvNOKp_on(sv) (assert_not_glob(sv) SvFLAGS(sv) |= SVp_NOK)#define SvPOKp(sv) (SvFLAGS(sv) & SVp_POK)#define SvPOKp_on(sv) (assert_not_ROK(sv) assert_not_glob(sv) \ SvFLAGS(sv) |= SVp_POK)#define SvIOK(sv) (SvFLAGS(sv) & SVf_IOK)#define SvIOK_on(sv) (assert_not_glob(sv) SvRELEASE_IVX(sv), \ SvFLAGS(sv) |= (SVf_IOK|SVp_IOK))#define SvIOK_off(sv) (SvFLAGS(sv) &= ~(SVf_IOK|SVp_IOK|SVf_IVisUV))#define SvIOK_only(sv) (SvOK_off(sv), \ SvFLAGS(sv) |= (SVf_IOK|SVp_IOK))#define SvIOK_only_UV(sv) (assert_not_glob(sv) SvOK_off_exc_UV(sv), \ SvFLAGS(sv) |= (SVf_IOK|SVp_IOK))#define SvIOK_UV(sv) ((SvFLAGS(sv) & (SVf_IOK|SVf_IVisUV)) \ == (SVf_IOK|SVf_IVisUV))#define SvUOK(sv) SvIOK_UV(sv)#define SvIOK_notUV(sv) ((SvFLAGS(sv) & (SVf_IOK|SVf_IVisUV)) \ == SVf_IOK)#define SvIsUV(sv) (SvFLAGS(sv) & SVf_IVisUV)#define SvIsUV_on(sv) (SvFLAGS(sv) |= SVf_IVisUV)#define SvIsUV_off(sv) (SvFLAGS(sv) &= ~SVf_IVisUV)#define SvNOK(sv) (SvFLAGS(sv) & SVf_NOK)#define SvNOK_on(sv) (assert_not_glob(sv) \ SvFLAGS(sv) |= (SVf_NOK|SVp_NOK))#define SvNOK_off(sv) (SvFLAGS(sv) &= ~(SVf_NOK|SVp_NOK))#define SvNOK_only(sv) (SvOK_off(sv), \ SvFLAGS(sv) |= (SVf_NOK|SVp_NOK))/*=for apidoc Am|U32|SvUTF8|SV* svReturns a U32 value indicating whether the SV contains UTF-8 encoded data.Call this after SvPV() in case any call to string overloading updates theinternal flag.=for apidoc Am|void|SvUTF8_on|SV *svTurn on the UTF-8 status of an SV (the data is not changed, just the flag).Do not use frivolously.=for apidoc Am|void|SvUTF8_off|SV *svUnsets the UTF-8 status of an SV.=for apidoc Am|void|SvPOK_only_UTF8|SV* svTells an SV that it is a string and disables all other OK bits,and leaves the UTF-8 status as it was.=cut *//* Ensure the return value of this macro does not clash with the GV_ADD* flagsin gv.h: */#define SvUTF8(sv) (SvFLAGS(sv) & SVf_UTF8)#define SvUTF8_on(sv) (SvFLAGS(sv) |= (SVf_UTF8))#define SvUTF8_off(sv) (SvFLAGS(sv) &= ~(SVf_UTF8))#define SvPOK(sv) (SvFLAGS(sv) & SVf_POK)#define SvPOK_on(sv) (assert_not_ROK(sv) assert_not_glob(sv) \ SvFLAGS(sv) |= (SVf_POK|SVp_POK))#define SvPOK_off(sv) (SvFLAGS(sv) &= ~(SVf_POK|SVp_POK))#define SvPOK_only(sv) (assert_not_ROK(sv) assert_not_glob(sv) \ SvFLAGS(sv) &= ~(SVf_OK| \ SVf_IVisUV|SVf_UTF8), \ SvFLAGS(sv) |= (SVf_POK|SVp_POK))#define SvPOK_only_UTF8(sv) (assert_not_ROK(sv) assert_not_glob(sv) \ SvFLAGS(sv) &= ~(SVf_OK| \ SVf_IVisUV), \ SvFLAGS(sv) |= (SVf_POK|SVp_POK))#define SvVOK(sv) (SvMAGICAL(sv) \ && mg_find(sv,PERL_MAGIC_vstring))/* returns the vstring magic, if any */#define SvVSTRING_mg(sv) (SvMAGICAL(sv) \ ? mg_find(sv,PERL_MAGIC_vstring) : NULL)#define SvOOK(sv) (SvFLAGS(sv) & SVf_OOK)#define SvOOK_on(sv) ((void)SvIOK_off(sv), SvFLAGS(sv) |= SVf_OOK)#define SvOOK_off(sv) ((void)(SvOOK(sv) && sv_backoff(sv)))#define SvFAKE(sv) (SvFLAGS(sv) & SVf_FAKE)#define SvFAKE_on(sv) (SvFLAGS(sv) |= SVf_FAKE)#define SvFAKE_off(sv) (SvFLAGS(sv) &= ~SVf_FAKE)#define SvROK(sv) (SvFLAGS(sv) & SVf_ROK)#define SvROK_on(sv) (SvFLAGS(sv) |= SVf_ROK)#define SvROK_off(sv) (SvFLAGS(sv) &= ~(SVf_ROK))#define SvMAGICAL(sv) (SvFLAGS(sv) & (SVs_GMG|SVs_SMG|SVs_RMG))#define SvMAGICAL_on(sv) (SvFLAGS(sv) |= (SVs_GMG|SVs_SMG|SVs_RMG))#define SvMAGICAL_off(sv) (SvFLAGS(sv) &= ~(SVs_GMG|SVs_SMG|SVs_RMG))#define SvGMAGICAL(sv) (SvFLAGS(sv) & SVs_GMG)#define SvGMAGICAL_on(sv) (SvFLAGS(sv) |= SVs_GMG)#define SvGMAGICAL_off(sv) (SvFLAGS(sv) &= ~SVs_GMG)#define SvSMAGICAL(sv) (SvFLAGS(sv) & SVs_SMG)#define SvSMAGICAL_on(sv) (SvFLAGS(sv) |= SVs_SMG)#define SvSMAGICAL_off(sv) (SvFLAGS(sv) &= ~SVs_SMG)#define SvRMAGICAL(sv) (SvFLAGS(sv) & SVs_RMG)#define SvRMAGICAL_on(sv) (SvFLAGS(sv) |= SVs_RMG)#define SvRMAGICAL_off(sv) (SvFLAGS(sv) &= ~SVs_RMG)#define SvAMAGIC(sv) (SvROK(sv) && (SvFLAGS(SvRV(sv)) & SVf_AMAGIC))#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)# define SvAMAGIC_on(sv) ({ SV * const kloink = sv; \ assert(SvROK(kloink)); \ SvFLAGS(SvRV(kloink)) |= SVf_AMAGIC; \ })# define SvAMAGIC_off(sv) ({ SV * const kloink = sv; \ if(SvROK(kloink)) \ SvFLAGS(SvRV(kloink)) &= ~SVf_AMAGIC;\ })#else# define SvAMAGIC_on(sv) (SvFLAGS(SvRV(sv)) |= SVf_AMAGIC)# define SvAMAGIC_off(sv) \ (SvROK(sv) && (SvFLAGS(SvRV(sv)) &= ~SVf_AMAGIC))#endif/*=for apidoc Am|char*|SvGAMAGIC|SV* svReturns true if the SV has get magic or overloading. If either is true thenthe scalar is active data, and has the potential to return a new value everytime it is accessed. Hence you must be careful to only read it once per userlogical operation and work with that returned value. If neither is true thenthe scalar's value cannot change unless written to.=cut*/#define SvGAMAGIC(sv) (SvGMAGICAL(sv) || SvAMAGIC(sv))#define Gv_AMG(stash) (PL_amagic_generation && Gv_AMupdate(stash))#define SvWEAKREF(sv) ((SvFLAGS(sv) & (SVf_ROK|SVprv_WEAKREF)) \ == (SVf_ROK|SVprv_WEAKREF))#define SvWEAKREF_on(sv) (SvFLAGS(sv) |= (SVf_ROK|SVprv_WEAKREF))#define SvWEAKREF_off(sv) (SvFLAGS(sv) &= ~(SVf_ROK|SVprv_WEAKREF))#define SvPCS_IMPORTED(sv) ((SvFLAGS(sv) & (SVf_ROK|SVprv_PCS_IMPORTED)) \ == (SVf_ROK|SVprv_PCS_IMPORTED))#define SvPCS_IMPORTED_on(sv) (SvFLAGS(sv) |= (SVf_ROK|SVprv_PCS_IMPORTED))#define SvPCS_IMPORTED_off(sv) (SvFLAGS(sv) &= ~(SVf_ROK|SVprv_PCS_IMPORTED))#define SvTHINKFIRST(sv) (SvFLAGS(sv) & SVf_THINKFIRST)#define SvPADSTALE(sv) (SvFLAGS(sv) & SVs_PADSTALE)#define SvPADSTALE_on(sv) (SvFLAGS(sv) |= SVs_PADSTALE)#define SvPADSTALE_off(sv) (SvFLAGS(sv) &= ~SVs_PADSTALE)#define SvPADTMP(sv) (SvFLAGS(sv) & SVs_PADTMP)#define SvPADTMP_on(sv) (SvFLAGS(sv) |= SVs_PADTMP)#define SvPADTMP_off(sv) (SvFLAGS(sv) &= ~SVs_PADTMP)#define SvPADMY(sv) (SvFLAGS(sv) & SVs_PADMY)#define SvPADMY_on(sv) (SvFLAGS(sv) |= SVs_PADMY)#define SvTEMP(sv) (SvFLAGS(sv) & SVs_TEMP)#define SvTEMP_on(sv) (SvFLAGS(sv) |= SVs_TEMP)#define SvTEMP_off(sv) (SvFLAGS(sv) &= ~SVs_TEMP)#define SvOBJECT(sv) (SvFLAGS(sv) & SVs_OBJECT)#define SvOBJECT_on(sv) (SvFLAGS(sv) |= SVs_OBJECT)#define SvOBJECT_off(sv) (SvFLAGS(sv) &= ~SVs_OBJECT)#define SvREADONLY(sv) (SvFLAGS(sv) & SVf_READONLY)#define SvREADONLY_on(sv) (SvFLAGS(sv) |= SVf_READONLY)#define SvREADONLY_off(sv) (SvFLAGS(sv) &= ~SVf_READONLY)#define SvSCREAM(sv) ((SvFLAGS(sv) & (SVp_SCREAM|SVp_POK)) == (SVp_SCREAM|SVp_POK))#define SvSCREAM_on(sv) (SvFLAGS(sv) |= SVp_SCREAM)#define SvSCREAM_off(sv) (SvFLAGS(sv) &= ~SVp_SCREAM)#define SvCOMPILED(sv) (SvFLAGS(sv) & SVpfm_COMPILED)#define SvCOMPILED_on(sv) (SvFLAGS(sv) |= SVpfm_COMPILED)#define SvCOMPILED_off(sv) (SvFLAGS(sv) &= ~SVpfm_COMPILED)#define SvEVALED(sv) (SvFLAGS(sv) & SVrepl_EVAL)#define SvEVALED_on(sv) (SvFLAGS(sv) |= SVrepl_EVAL)#define SvEVALED_off(sv) (SvFLAGS(sv) &= ~SVrepl_EVAL)#if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)# define SvVALID(sv) ({ SV *const thwacke = (SV *) (sv); \ if (SvFLAGS(thwacke) & SVpbm_VALID) \ assert(!isGV_with_GP(thwacke)); \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -