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

Add platform independent reversible code #263

Open
tolauwae opened this issue Sep 24, 2024 · 0 comments
Open

Add platform independent reversible code #263

tolauwae opened this issue Sep 24, 2024 · 0 comments
Labels
refactor Refactoring of the code

Comments

@tolauwae
Copy link
Member

tolauwae commented Sep 24, 2024

def_prim_reverse(chip_digital_write) {
for (IOStateElement state : external_state) {
if (!state.output) {
continue;
}
if (state.key[0] == 'p') {
invoke_primitive(m, "chip_digital_write", stoi(state.key.substr(1)),
(uint32_t)state.value);
}
}
}

This code will likely be the same for all chip_digital_write primitives, regardless of platform. Since you are just invoking the primitive.

(in fact this will the strategy for most primitives)

I think we can generalize this and move to a reversibility file to avoid code duplication. In will make implementing the reversibility for other primitives easier as well.

Originally posted by @tolauwae in #250 (comment)

@tolauwae tolauwae added the refactor Refactoring of the code label Sep 24, 2024
@tolauwae tolauwae moved this to Scheduled in WARDuino Roadmap Sep 24, 2024
@tolauwae tolauwae changed the title Reduce duplicate code in reversible primitives Add platform independent reversible code Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Refactoring of the code
Projects
Status: Scheduled
Development

No branches or pull requests

1 participant