Skip to content

Frame v0.7.0

Choose a tag to compare

@walkie walkie released this 01 Nov 21:33
· 461 commits to main since this release
fe481c3

This release includes two major new features and several small improvements and bug fixes.

Runtime system for Rust

The biggest new feature of this release is an optional Frame runtime system for Rust. The runtime system can be used by doing the following:

  1. Compile your Frame spec to Rust with the runtime_support feature enabled.
  2. Include the new frame_runtime crate in your project that uses the generated state machine.

The runtime system provides comprehensive introspection of state machines generated by Frame, and some simple monitoring capabilities that will likely be expanded in the future. More specifically:

  • For any state machine generated by Frame:
    • Enumerate its states, domain variables, events, actions, and edges (potential transitions).
    • Get hierarchy information for states within a machine.
    • For each state: enumerate its parameters and variables, the handlers it defines, and its incoming and outgoing edges.
    • For each edge within the machine: get its kind (transition/change-state), source, target, triggering event, and label.
  • For a currently running state machine:
    • Get the current values of all domain variables.
    • Get the currently active state and the values of its parameters and variables.
    • Register callbacks to be notified of any transitions that occur.
    • For transition notifications, get access to the values of enter/exit arguments.

New configuration system

Frame's configuration system has been overhauled to make it simpler and more flexible to use going forward.

Frame can still be configured using a config.yaml file in the current working directory, but this file is no longer mandatory and no longer needs to contain a complete set of configuration values. Instead, the file may contain only the values the user chooses to override.

A default config.yaml file can be generated by running:

framec --generate-config

This file will contain a complete set of configuration options initialized to the default values.

Additionally, Frame can now be configured through attributes embedded directly in Frame specifications. These attributes use the syntax #[path.to.config.option:type="value"] where path.to.config.option is the full path of the configuration option in config.yaml; type is one of bool, int, or str depending on the type of the configuration option; and value is the value to set it to.

For example, to enable the new runtime_support feature for a particular state machine, one could either set the following option in config.yaml:

codegen:
  rust:
    features:
      runtime_support: true

Or include the following attribute setting at the top of the corresponding .frm file:

#[codegen.rust.features.runtime_support:bool="true"]

An advantage of the attribute interface is that it enables configuring two different state machines in the same project differently.

Other fixes and improvements

  • (Feature) Added configurable style attributes to the output generated by the smcat backend.
  • (Bug fix) Can now directly invoke event handlers from within Frame, even in state machines that require a state context. Note that for now, direct handler invocations must occur as the last step in the calling handler. This constraint may be lifted in the future.
  • (Bug fix) State stacks now push a snapshot of the current state context rather than a reference. This means that changes after a state is pushed will not be reflected when that state is restored later by a pop.
  • (Code cleanup) Fixed or suppressed all outstanding cargo clippy warnings and added clippy to Github Actions to be applied on every push.
  • (Code cleanup) Simplified the visitor interface a bit, enabling the removal of over 3000 lines of code!
  • Lots of new tests!