Skip to content
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

Dynamic databinding variable expressions #550

Merged
merged 12 commits into from
Jan 24, 2024

Conversation

Dakror
Copy link
Contributor

@Dakror Dakror commented Dec 7, 2023

Prompted by the submission of #547 here is my branch for fully dynamic expressions to access array indices in databinding addresses.

This is done by enabling a fast-path for the pre-existing fixed addresses, and a stack based index resolution of dynamic addresses.

I did not submit this PR earlier because i feared another CSS Variables incident with a giant PR destined to fail.

@mikke89
Copy link
Owner

mikke89 commented Dec 11, 2023

Very nice, I like it!

Are there any limitations to this approach compared to #547? I'm curious whether it works on the left-hand side of data-value, data-checked, and data-event assignment expressions.

Does it properly report variable names of nested addresses? E.g. will the expression arrays.c[arrays.b[i1] - 19].val be re-evaluated if i1 is dirty?

@Dakror
Copy link
Contributor Author

Dakror commented Dec 14, 2023

Indeed i needed to fix it tracking the embedded variables. But now it works.
Left-hand sides are not supported yet, the new instruction is read-only.

@mikke89
Copy link
Owner

mikke89 commented Jan 14, 2024

Hey, did you get a chance to take a look at expressions on left-hand side/assignments?

I wonder if we still need something like #547, or if there is another way to approach that on top of this PR. Any thoughts?

@Dakror
Copy link
Contributor Author

Dakror commented Jan 14, 2024

Left-hand side is definitely doable. Would you want to merge this first and go for dynamic assignment in a separate PR or all in one?

@mikke89
Copy link
Owner

mikke89 commented Jan 14, 2024

I don't mind either way. I'll start reviewing this code now, and you can decide if you want to reuse this, or make a new PR. If you add everything here, it would be nice if you keep the commits clean, or do an interactive rebase at the end.

@Dakror
Copy link
Contributor Author

Dakror commented Jan 14, 2024

If you're starting your review i'll hold of on adding assignment support, so i dont have too many headaches at once :D

Copy link
Owner

@mikke89 mikke89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I very much like what you achieve with only changes within the data expression code. Well done! The feature seems very useful, so thanks for making the PR.

I have some suggestions here, most of which are relatively small.

Tests/Source/UnitTests/DataBinding.cpp Show resolved Hide resolved
Source/Core/DataExpression.cpp Show resolved Hide resolved
Source/Core/DataExpression.cpp Show resolved Hide resolved
Source/Core/DataExpression.cpp Outdated Show resolved Hide resolved
Source/Core/DataExpression.cpp Outdated Show resolved Hide resolved
Source/Core/DataExpression.cpp Show resolved Hide resolved
Source/Core/DataExpression.cpp Outdated Show resolved Hide resolved
Tests/Source/UnitTests/DataBinding.cpp Show resolved Hide resolved
Source/Core/DataExpression.cpp Outdated Show resolved Hide resolved
Source/Core/DataExpression.cpp Show resolved Hide resolved
@Dakror Dakror requested a review from mikke89 January 20, 2024 13:48
Copy link
Owner

@mikke89 mikke89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Just a couple of small comments :)

Do you want me to merge this PR once these are addressed, and open a new PR for assignment support?

Source/Core/DataExpression.cpp Show resolved Hide resolved
Source/Core/DataExpression.cpp Outdated Show resolved Hide resolved
@mikke89 mikke89 merged commit b8f8e2e into mikke89:master Jan 24, 2024
18 checks passed
@mikke89
Copy link
Owner

mikke89 commented Jan 24, 2024

Awesome work, thanks a lot! That's a very neat feature :) And I'm very happy with the implementation, and particularly that it could be implemented entirely in the parser, nice.

Only missing piece now is expression support in assignments.

@Dakror Dakror deleted the variable-indexing branch January 25, 2024 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data binding enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants