Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions framec/src/frame_c/visitors/rust_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3786,11 +3786,13 @@ impl AstVisitor for RustVisitor {
} = &call_chain[0]
{
self.this_branch_transitioned = true;
self.add_code(&format!(
"drop({});",
self.config.this_state_context_var_name
));
self.newline();
if self.generate_state_context {
self.add_code(&format!(
"drop({});",
self.config.this_state_context_var_name
));
self.newline();
}
interface_method_call_expr_node.accept(self);
self.add_code(";");
self.newline();
Expand Down
1 change: 1 addition & 0 deletions framec_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod hierarchical;
mod hierarchical_guard;
mod r#match;
mod rust_naming;
mod simple_handler_calls;
mod state_context;
mod state_context_stack;
mod state_params;
Expand Down
27 changes: 27 additions & 0 deletions framec_tests/src/simple_handler_calls.frm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#SimpleHandlerCalls
-interface-
A
B
C
D
E

-machine-
$Init
|A| -> $A ^

|B| -> $B ^

|C| A() ^

|D|
B()
-> $A ^

|E|
D()
C() ^

$A
$B
##
30 changes: 30 additions & 0 deletions framec_tests/src/simple_handler_calls.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//! Test directly invoking event handlers from within other event handlers.
//! This module tests this feature for simple state machines not requiring a
//! state context. See `handler_calls.rs` for more interesting cases.

include!(concat!(env!("OUT_DIR"), "/", "simple_handler_calls.rs"));

#[cfg(test)]
mod tests {
use super::*;

#[test]
/// Test a basic handler call.
fn simple_call() {
let mut sm = SimpleHandlerCalls::new();
sm.c();
assert_eq!(sm.state, SimpleHandlerCallsState::A);
}

#[test]
/// Test that a handler call terminates the current handler.
fn calls_terminate_handler() {
let mut sm = SimpleHandlerCalls::new();
sm.d();
assert_eq!(sm.state, SimpleHandlerCallsState::B);

sm = SimpleHandlerCalls::new();
sm.e();
assert_eq!(sm.state, SimpleHandlerCallsState::B);
}
}