diff options
author | Andy Lester <andy@petdance.com> | 2006-06-11 17:44:34 -0500 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-06-12 10:07:18 +0000 |
commit | 42d0e0b77a1ef47b81ab3e346a1a4dc0af5b9bec (patch) | |
tree | 7011adacbdf7230ca54109588b961d605d72fae6 | |
parent | be8e71aa96b3d344129617fadcaca7d958882caa (diff) | |
download | perl-42d0e0b77a1ef47b81ab3e346a1a4dc0af5b9bec.tar.gz |
Proper use of enums
Message-ID: <20060612034434.GA21588@petdance.com>
p4raw-id: //depot/perl@28381
-rw-r--r-- | embed.fnc | 2 | ||||
-rw-r--r-- | gv.c | 1 | ||||
-rw-r--r-- | op.c | 10 | ||||
-rw-r--r-- | perlio.c | 3 | ||||
-rw-r--r-- | pod/perlapi.pod | 2 | ||||
-rw-r--r-- | pp.c | 1 | ||||
-rw-r--r-- | proto.h | 2 | ||||
-rw-r--r-- | sv.c | 10 | ||||
-rw-r--r-- | sv.h | 2 |
9 files changed, 19 insertions, 14 deletions
@@ -862,7 +862,7 @@ Apd |int |sv_unmagic |NN SV* sv|int type Apdmb |void |sv_unref |NN SV* sv Apd |void |sv_unref_flags |NN SV* sv|U32 flags Apd |void |sv_untaint |NN SV* sv -Apd |void |sv_upgrade |NN SV* sv|U32 mt +Apd |void |sv_upgrade |NN SV* sv|svtype new_type Apdmb |void |sv_usepvn |NN SV* sv|NULLOK char* ptr|STRLEN len Apd |void |sv_usepvn_flags|NN SV* sv|NULLOK char* ptr|STRLEN len\ |U32 flags @@ -204,6 +204,7 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi) case SVt_PVIO: Perl_croak(aTHX_ "Cannot convert a reference to %s to typeglob", sv_reftype(has_constant, 0)); + default: NOOP; } SvRV_set(gv, NULL); SvROK_off(gv); @@ -6071,24 +6071,24 @@ Perl_ck_rvconst(pTHX_ register OP *o) /* Is it a constant from cv_const_sv()? */ if (SvROK(kidsv) && SvREADONLY(kidsv)) { SV * const rsv = SvRV(kidsv); - const int svtype = SvTYPE(rsv); + const svtype type = SvTYPE(rsv); const char *badtype = NULL; switch (o->op_type) { case OP_RV2SV: - if (svtype > SVt_PVMG) + if (type > SVt_PVMG) badtype = "a SCALAR"; break; case OP_RV2AV: - if (svtype != SVt_PVAV) + if (type != SVt_PVAV) badtype = "an ARRAY"; break; case OP_RV2HV: - if (svtype != SVt_PVHV) + if (type != SVt_PVHV) badtype = "a HASH"; break; case OP_RV2CV: - if (svtype != SVt_PVCV) + if (type != SVt_PVCV) badtype = "a CODE"; break; } @@ -1431,8 +1431,9 @@ PerlIO_layer_from_ref(pTHX_ SV *sv) return PerlIO_find_layer(aTHX_ STR_WITH_LEN("Code"), 0); case SVt_PVGV: return PerlIO_find_layer(aTHX_ STR_WITH_LEN("Glob"), 0); + default: + return NULL; } - return NULL; } PerlIO_list_t * diff --git a/pod/perlapi.pod b/pod/perlapi.pod index d852746a79..ca9dfa301d 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -5891,7 +5891,7 @@ Upgrade an SV to a more complex form. Generally adds a new body type to the SV, then copies across as much information as possible from the old body. You generally want to use the C<SvUPGRADE> macro wrapper. See also C<svtype>. - void sv_upgrade(SV* sv, U32 mt) + void sv_upgrade(SV* sv, svtype new_type) =for hackers Found in file sv.c @@ -239,6 +239,7 @@ PP(pp_rv2sv) case SVt_PVFM: case SVt_PVIO: DIE(aTHX_ "Not a SCALAR reference"); + default: NOOP; } } else { @@ -2356,7 +2356,7 @@ PERL_CALLCONV void Perl_sv_unref_flags(pTHX_ SV* sv, U32 flags) PERL_CALLCONV void Perl_sv_untaint(pTHX_ SV* sv) __attribute__nonnull__(pTHX_1); -PERL_CALLCONV void Perl_sv_upgrade(pTHX_ SV* sv, U32 mt) +PERL_CALLCONV void Perl_sv_upgrade(pTHX_ SV* sv, svtype new_type) __attribute__nonnull__(pTHX_1); /* PERL_CALLCONV void Perl_sv_usepvn(pTHX_ SV* sv, char* ptr, STRLEN len) @@ -1120,12 +1120,12 @@ You generally want to use the C<SvUPGRADE> macro wrapper. See also C<svtype>. */ void -Perl_sv_upgrade(pTHX_ register SV *sv, U32 new_type) +Perl_sv_upgrade(pTHX_ register SV *sv, svtype new_type) { dVAR; void* old_body; void* new_body; - const U32 old_type = SvTYPE(sv); + const svtype old_type = SvTYPE(sv); const struct body_details *new_type_details; const struct body_details *const old_type_details = bodies_by_type + old_type; @@ -1496,6 +1496,7 @@ Perl_sv_setiv(pTHX_ register SV *sv, IV i) case SVt_PVIO: Perl_croak(aTHX_ "Can't coerce %s to integer in %s", sv_reftype(sv,0), OP_DESC(PL_op)); + default: NOOP; } (void)SvIOK_only(sv); /* validate number */ SvIV_set(sv, i); @@ -1596,6 +1597,7 @@ Perl_sv_setnv(pTHX_ register SV *sv, NV num) case SVt_PVIO: Perl_croak(aTHX_ "Can't coerce %s to number in %s", sv_reftype(sv,0), OP_NAME(PL_op)); + default: NOOP; } SvNV_set(sv, num); (void)SvNOK_only(sv); /* validate number */ @@ -3348,7 +3350,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags) dVAR; register U32 sflags; register int dtype; - register int stype; + register svtype stype; if (sstr == dstr) return; @@ -3483,7 +3485,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags) if (stype == SVt_PVLV) SvUPGRADE(dstr, SVt_PVNV); else - SvUPGRADE(dstr, (U32)stype); + SvUPGRADE(dstr, (svtype)stype); } /* dstr may have been upgraded. */ @@ -266,7 +266,7 @@ perform the upgrade if necessary. See C<svtype>. #endif #define SVTYPEMASK 0xff -#define SvTYPE(sv) ((sv)->sv_flags & SVTYPEMASK) +#define SvTYPE(sv) (svtype)((sv)->sv_flags & SVTYPEMASK) /* Sadly there are some parts of the core that have pointers to already-freed SV heads, and rely on being able to tell that they are now free. So mark |