Allow null values to be cast to int and string

This commit is contained in:
John Wiegley 2010-05-30 03:19:09 -06:00
parent 4f3b39e22c
commit d5ea3080a7

View file

@ -1075,8 +1075,27 @@ void value_t::in_place_cast(type_t cast_type)
}
switch (type()) {
case VOID:
switch (cast_type) {
case INTEGER:
set_long(0L);
return;
case AMOUNT:
set_amount(0L);
return;
case STRING:
set_string("");
return;
default:
break;
}
break;
case BOOLEAN:
switch (cast_type) {
case INTEGER:
set_long(as_boolean() ? 1L : 0L);
return;
case AMOUNT:
set_amount(as_boolean() ? 1L : 0L);
return;