return VAR_IO;
}
else {
- croak("Type must be one of 'SCALAR', 'ARRAY', 'HASH', 'CODE', or 'IO'");
+ croak("Type must be one of 'SCALAR', 'ARRAY', 'HASH', 'CODE', or 'IO', not '%s'", vartype);
}
}
void _deconstruct_variable_hash(HV *variable, varspec_t *varspec)
{
HE *val;
- STRLEN len;
val = hv_fetch_ent(variable, name_key, 0, name_hash);
if (!val)
croak("The 'name' key is required in variable specs");
- varspec->name = sv_2mortal(newSVhe(val));
+ varspec->name = sv_2mortal(newSVsv(HeVAL(val)));
val = hv_fetch_ent(variable, type_key, 0, type_hash);
if (!val)
croak("The 'type' key is required in variable specs");
- varspec->type = string_to_vartype(HePV(val, len));
+ varspec->type = string_to_vartype(SvPV_nolen(HeVAL(val)));
}
int _valid_for_type(SV *value, vartype_t type)
switch (type) {
case VAR_SCALAR:
- return sv_type == SVt_NULL ||
- sv_type == SVt_IV ||
- sv_type == SVt_NV ||
- sv_type == SVt_PV ||
- sv_type == SVt_RV;
+ return SvROK(value) ? SvOK(SvRV(value)) : SvOK(value);
case VAR_ARRAY:
return sv_type == SVt_PVAV;
case VAR_HASH: