Hack for "true" and "false" used as enum element values
This is not a full solution by far, but should address the most common case. This also allows "cpp_enum" unit test to pass.
This commit is contained in:
parent
2a4bc0e7e5
commit
44d68197d6
3 changed files with 14 additions and 4 deletions
|
|
@ -51,7 +51,6 @@ FAILING_CPP_TESTS := \
|
||||||
cpp_basic_global_var_class \
|
cpp_basic_global_var_class \
|
||||||
cpp_basic_template_class \
|
cpp_basic_template_class \
|
||||||
cpp_basic_template_function \
|
cpp_basic_template_function \
|
||||||
cpp_enum \
|
|
||||||
c_backend_cpp_natural_std_string \
|
c_backend_cpp_natural_std_string \
|
||||||
c_backend_cpp_exception \
|
c_backend_cpp_exception \
|
||||||
default_args \
|
default_args \
|
||||||
|
|
|
||||||
|
|
@ -63,10 +63,10 @@ int main(int argc, const char *argv[]) {
|
||||||
play_state t;
|
play_state t;
|
||||||
|
|
||||||
t = PLAY;
|
t = PLAY;
|
||||||
assert(t == true);
|
assert(t == 1);
|
||||||
|
|
||||||
t = STOP;
|
t = STOP;
|
||||||
assert(t == false);
|
assert(t == 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1774,6 +1774,17 @@ ready:
|
||||||
Append(cvalue, "'");
|
Append(cvalue, "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Boolean constants can't appear in C code neither, so replace them with their values in the simplest possible case. This is not exhaustive, of course,
|
||||||
|
// but better than nothing and doing the right thing is not simple at all as we'd need to really parse the expression, just textual substitution wouldn't
|
||||||
|
// be enough (consider e.g. an enum element called "very_true" and another one using it as its value).
|
||||||
|
if (Cmp(value, "true") == 0) {
|
||||||
|
Clear(cvalue);
|
||||||
|
Append(cvalue, "1");
|
||||||
|
} else if (Cmp(value, "false") == 0) {
|
||||||
|
Clear(cvalue);
|
||||||
|
Append(cvalue, "0");
|
||||||
|
}
|
||||||
|
|
||||||
Printv(f_wrappers_types, " = ", cvalue, NIL);
|
Printv(f_wrappers_types, " = ", cvalue, NIL);
|
||||||
|
|
||||||
Delete(cvalue);
|
Delete(cvalue);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue