-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defines not possible to evaluate #44
Comments
Thinking this through, it's a bit tricky to represent. Maybe something like this could work? # defines
[
{
"conditional": { "condition": "ifndef", "expression": "IM_COL32_R_SHIFT" },
"true_case": {
{
"conditional": { "condition": "ifdef", "expression": "IMGUI_USE_BGRA_PACKED_COLOR" },
"true_case": {
"defines": [
{ "name": "IM_COL32_R_SHIFT", "content": "16" },
{ "name": "IM_COL32_G_SHIFT", "content": "8" },
{ "name": "IM_COL32_B_SHIFT", "content": "0" },
{ "name": "IM_COL32_A_SHIFT", "content": "24" },
{ "name": "IM_COL32_A_MASK", "content": "0xFF000000" },
],
},
"false_case": {
"defines": [
{ "name": "IM_COL32_R_SHIFT", "content": "0" },
{ "name": "IM_COL32_G_SHIFT", "content": "8" },
{ "name": "IM_COL32_B_SHIFT", "content": "16" },
{ "name": "IM_COL32_A_SHIFT", "content": "24" },
{ "name": "IM_COL32_A_MASK", "content": "0xFF000000" },
],
},
}
},
},
] This would be a special case only for defines, since this is the only section where it gets weird.
|
I have to admit I'd not really considered the case of evaluating conditional prerequisites on defines themselves, only on other declarations (my assumption being that other languages likely didn't support defines, or wouldn't want to import the C ones as they are mostly fairly C-specific... Internally the DOM representation of ifdefs is closer to the representation you propose here, so it's definitely not impossible to implement, but I'm slightly nervous about trying to expose that in the JSON because it feels like it will make everything much more complex - consistency would suggest that other declarations should be handled in a similar way, but then we end up needing to wrap everything in conditional blocks... (and also start caring about declaration ordering in the JSON, too) From what I can see the only case where this is actually an issue right now is the |
Due to how the
"conditionals"
field is constructed, there are ambiguous situations that arise when evaluating them.Given this series of defines, we can see that we expect both to pass. However only the first will be, if we update our list of defines after the condition evaluates to true.
You can see how that series of defines would result in the same data as these, even though they have different behavior.
This happens in practice for the
IM_COL32_(R|G|B|A)_SHIFT
defines:The text was updated successfully, but these errors were encountered: