-
Notifications
You must be signed in to change notification settings - Fork 10
Merge v0.6.0 changes into main #39
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This refactoring also does the following: * Removes the introspection feature option (this feature is no longer optional) * Changes lower_case_states option to lower_case_methods and applies the option to both state handlers and actions. Additionally, this now uses convert_case to turn the actions into more Rust-like snake_case. * Breaks some of the very long methods involved in this refactoring into smaller chunks. All current tests pass. However, it is likely that the refactoring is incomplete since it hasn't been tested with state parameters or branching control flow yet. Next step is to add tests covering these cases and fix any bugs found.
These don't compile because the generated code is incorrect, so they're currently commented out in lib.rs. Also, the state variable test needs comments translated into asserts once the generator is fixed.
These changes should have been included when adding the state parameter tests since they don't compile without them.
This is currently only applied to methods and variables that use state names, but should eventually be extended to apply to all names that use user-provided names as components.
This overhauls state contexts to be consistent with the new state representation. It also fixes several issues related to state variables and event parameters, which rely on state contexts. Known issue: Many features do not work with initial states, such as state variables. The workaround is to create a trivial initial state with an enter event handler that transitions into the true initial state. Note that this issue existed before the refactor. Likely issue: The new state and state context representation is untested with the state history feature. I tried to proactively refactor this but it's likely to contain issues. I also did not test this feature before the refactor, so I'm not sure what the status of this feature is.
The default name `e` collides too easily with user-provided variables. Also, this value was hardcoded many places in the generator.
Or at least as close to everywhere as I can manage!
Note that this test revealed an open parser bug, documented briefly in the comments.
Refactor Rust backend to use simpler state representation
Also some minor cleanup of nearby generated code.
Fix continue terminator
Without the parens, this can be interpreted as a bitwise complement when applied to an expression like `x < 10`.
Refactor and fix state contexts in Rust backend
…ler into issue_17
This restores and fixes some code that Mark added before the termination tracking stuff.
Manually revert termination tracking work.
…ler into fix-state-stack
Fix and test state history/stack feature
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About to create a new release for v0.6.0.
This release includes a lot of work on the Rust back-end:
New feature: the current state of the machine is stored as a value of a simple enum type, which can be accessed to determine the state of a running machine.
New feature: a new
follow_rust_naming
feature option has been added and enabled by default. This option significantly improves the conformance of generated code with Rust naming conventions and style guidelines.Temporary feature: a new
generate_hook_methods
feature has been added that generates "hook" methods that are invoked on each transition or change-state. This feature will be removed and replaced in v0.7.0 by the much more comprehensiveruntime_support
feature currently available in the runtime-support branch.Completed feature: hierarchical state machines. This enables defining states as children of other states. Event handlers on child states may defer to the corresponding handler on a parent state by terminating the child handler with the "continue" terminator
:>
. The parent handler will be immediately invoked after a child handler that terminates in:>
, if the child handler does not otherwise transition or return.Completed feature: change-state transitions. Change-states (
->>
) are transitions that do not trigger the usual exit/enter events. Previously, this feature only worked for simple states (states without variables, parameters, or enter event arguments). Now it works in all expected scenarios.Completed feature: state stacks/history. This feature enables pushing states (with corresponding state variables and arguments) to a stack. These states can later be returned to by a "pop transition" using the syntax
-> $$[-]
. This pops a state from the stack and restores the machine to that state.Refactors and simplifies the generated code, particularly the representation of states and the initialization of state contexts.
More names in the generated code are now customizable via the
config.yaml
interface.Significantly improved test coverage and corresponding bug fixes:
?!
) now work as expected.