Bug - Expressions

- Fixed a bug that confused left and right operands.
- Fixed a bug where E9::coerce was dropping data.
This commit is contained in:
Paul Beckingham 2011-09-05 14:11:10 -04:00
parent 60c45b5035
commit 59d184e2db

View file

@ -508,29 +508,24 @@ void E9::operator_match (
{ {
result._type = Arg::type_bool; result._type = Arg::type_bool;
// TODO The problem is that description/dom -> <description>/string and we lose the original value.
if (eval_match (left, right, case_sensitive)) if (eval_match (left, right, case_sensitive))
{ {
// std::cout << "# operator_match description match\n";
result._value = "true"; result._value = "true";
} }
else if (left._raw == "description") else if (left._raw == "description")
{ {
// std::cout << "# operator_match escalation\n";
std::map <std::string, std::string> annotations; std::map <std::string, std::string> annotations;
task.getAnnotations (annotations); task.getAnnotations (annotations);
std::map <std::string, std::string>::iterator a; std::map <std::string, std::string>::iterator a;
for (a = annotations.begin (); a != annotations.end (); ++a) for (a = annotations.begin (); a != annotations.end (); ++a)
{ {
// Clone 'right', override _value. // Clone 'left', override _value.
Arg alternate (right); Arg alternate (left);
alternate._value = a->second; alternate._value = a->second;
if (eval_match (left, alternate, case_sensitive)) if (eval_match (alternate, right, case_sensitive))
{ {
// std::cout << "# operator_match annotation match\n";
result._value = "true"; result._value = "true";
break; break;
} }
@ -565,11 +560,11 @@ void E9::operator_nomatch (
std::map <std::string, std::string>::iterator a; std::map <std::string, std::string>::iterator a;
for (a = annotations.begin (); a != annotations.end (); ++a) for (a = annotations.begin (); a != annotations.end (); ++a)
{ {
// Clone 'right', override _value. // Clone 'left', override _value.
Arg alternate (right); Arg alternate (left);
alternate._value = a->second; alternate._value = a->second;
if (eval_match (left, alternate, case_sensitive)) if (eval_match (alternate, right, case_sensitive))
{ {
result._value = "false"; result._value = "false";
break; break;
@ -613,19 +608,27 @@ const Arg E9::coerce (const Arg& input, const Arg::type type)
if (type == Arg::type_bool) if (type == Arg::type_bool)
{ {
result._type = Arg::type_bool; result._raw = input._raw;
result._value = get_bool (input) ? "true" : "false"; result._value = get_bool (input) ? "true" : "false";
result._type = Arg::type_bool;
result._category = input._category;
} }
if (type == Arg::type_string) else if (type == Arg::type_string)
{ {
// TODO Convert date? // TODO Convert date?
result._raw = input._raw;
result._value = input._value; result._value = input._value;
result._type = Arg::type_string; result._type = Arg::type_string;
result._category = input._category;
} }
// TODO Date // TODO Date
// TODO Duration // TODO Duration
else
{
result = input;
}
return result; return result;
} }