Skip to content

Commit

Permalink
Add type to multistep
Browse files Browse the repository at this point in the history
  • Loading branch information
filipemlourenco authored Jan 22, 2025
1 parent 7edd69d commit 4793d96
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/StateMachines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ multistep!(w::Automaton) = (w.multistep = true)
singlestep!(w::Automaton) = (w.multistep = false)

# --- Automaton (state machine) execution
function exec!(w::Automaton, action::Union{Symbol, Nothing} = nothing; context::Any = nothing, multistep = nothing)
function exec!(w::Automaton, action::Union{Symbol, Nothing} = nothing; context::Any = nothing, multistep::Union{Bool, Nothing} = nothing)
w.state = exec(w, w.state, action, context = context, multistep = multistep)
end

exec(w::Automaton; context::Any = nothing, multistep = nothing) = exec(w, w.state, nothing, context = context, multistep = multistep)
exec(w::Automaton, action::Symbol; context::Any = nothing, multistep = nothing) = exec(w, w.state, action, context = context, multistep = multistep)
function exec(w::Automaton, s::State, action::Union{Symbol, Nothing} = nothing; context::Any = nothing, multistep = nothing) :: State
exec(w::Automaton; context::Any = nothing, multistep::Union{Bool, Nothing} = nothing) = exec(w, w.state, nothing, context = context, multistep = multistep)
exec(w::Automaton, action::Symbol; context::Any = nothing, multistep::Union{Bool, Nothing} = nothing) = exec(w, w.state, action, context = context, multistep = multistep)
function exec(w::Automaton, s::State, action::Union{Symbol, Nothing} = nothing; context::Any = nothing, multistep::Union{Bool, Nothing} = nothing) :: State
@assert s in w.states "State not available in the automaton ($s)"

_multistep = isnothing(multistep) ? w.multistep : multistep
Expand Down

0 comments on commit 4793d96

Please sign in to comment.