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

Minor adjustments to enable use in alloc environments without std. #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 6 additions & 5 deletions macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ keywords = ["fsm", "hsm", "statechart", "state-machine", "embedded"]
proc-macro = true

[dependencies]
hashbrown = "0.14"
syn = { version = "1.0.107", features = [
"full",
"quote",
"extra-traits",
"visit",
"visit-mut",
"full",
"quote",
"extra-traits",
"visit",
"visit-mut",
] }
quote = "1.0.23"
proc-macro2 = "1.0.50"
Expand Down
2 changes: 1 addition & 1 deletion macro/src/analyze.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use hashbrown::HashMap;

use proc_macro_error::abort;
use syn::parse::Parser;
Expand Down
12 changes: 6 additions & 6 deletions macro/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ fn codegen_state_impl_state(ir: &Ir) -> ItemImpl {
shared_storage: &'fut mut #shared_storage_type,
#event_ident: &'fut <#shared_storage_type as statig::IntoStateMachine>::Event<'_>,
#context_ident: &'fut mut <#shared_storage_type as statig::IntoStateMachine>::Context<'_>
) -> core::pin::Pin<std::boxed::Box<dyn core::future::Future<Output = statig::Response<Self>> + 'fut + Send>> {
) -> core::pin::Pin<Box<dyn core::future::Future<Output = statig::Response<Self>> + 'fut + Send>> {
Box::pin(async move {
match self {
#(#call_handler_arms),*
Expand All @@ -229,7 +229,7 @@ fn codegen_state_impl_state(ir: &Ir) -> ItemImpl {
&'fut mut self,
shared_storage: &'fut mut #shared_storage_type,
#context_ident: &'fut mut <#shared_storage_type as statig::IntoStateMachine>::Context<'_>
) -> core::pin::Pin<std::boxed::Box<dyn core::future::Future<Output = ()> + 'fut + Send>> {
) -> core::pin::Pin<Box<dyn core::future::Future<Output = ()> + 'fut + Send>> {
Box::pin(async move {
match self {
#(#call_entry_action_arms),*
Expand All @@ -241,7 +241,7 @@ fn codegen_state_impl_state(ir: &Ir) -> ItemImpl {
&'fut mut self,
shared_storage: &'fut mut #shared_storage_type,
#context_ident: &'fut mut <#shared_storage_type as statig::IntoStateMachine>::Context<'_>
) -> core::pin::Pin<std::boxed::Box<dyn core::future::Future<Output = ()> + 'fut + Send>> {
) -> core::pin::Pin<Box<dyn core::future::Future<Output = ()> + 'fut + Send>> {
Box::pin(async move {
match self {
#(#call_exit_action_arms),*
Expand Down Expand Up @@ -378,7 +378,7 @@ fn codegen_superstate_impl_superstate(ir: &Ir) -> ItemImpl {
shared_storage: &'fut mut #shared_storage_type,
#event_ident: &'fut <#shared_storage_type as statig::IntoStateMachine>::Event<'_>,
#context_ident: &'fut mut <#shared_storage_type as statig::IntoStateMachine>::Context<'_>
) -> core::pin::Pin<std::boxed::Box<dyn core::future::Future<Output = statig::Response<<#shared_storage_type as statig::IntoStateMachine>::State>> + 'fut + Send>> {
) -> core::pin::Pin<Box<dyn core::future::Future<Output = statig::Response<<#shared_storage_type as statig::IntoStateMachine>::State>> + 'fut + Send>> {
Box::pin(async move {
match self {
#(#call_handler_arms),*
Expand All @@ -390,7 +390,7 @@ fn codegen_superstate_impl_superstate(ir: &Ir) -> ItemImpl {
&'fut mut self,
shared_storage: &'fut mut #shared_storage_type,
#context_ident: &'fut mut <#shared_storage_type as statig::IntoStateMachine>::Context<'_>
) -> core::pin::Pin<std::boxed::Box<dyn core::future::Future<Output = ()> + 'fut + Send>> {
) -> core::pin::Pin<Box<dyn core::future::Future<Output = ()> + 'fut + Send>> {
Box::pin(async move {
match self {
#(#call_entry_action_arms),*
Expand All @@ -402,7 +402,7 @@ fn codegen_superstate_impl_superstate(ir: &Ir) -> ItemImpl {
&'fut mut self,
shared_storage: &'fut mut #shared_storage_type,
#context_ident: &'fut mut <#shared_storage_type as statig::IntoStateMachine>::Context<'_>
) -> core::pin::Pin<std::boxed::Box<dyn core::future::Future<Output = ()> + 'fut + Send>> {
) -> core::pin::Pin<Box<dyn core::future::Future<Output = ()> + 'fut + Send>> {
Box::pin(async move {
match self {
#(#call_exit_action_arms),*
Expand Down
4 changes: 2 additions & 2 deletions macro/src/lower.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::HashMap;
use std::ops::Deref;
use core::ops::Deref;
use hashbrown::HashMap;

use proc_macro2::Span;
use proc_macro_error::abort;
Expand Down
2 changes: 1 addition & 1 deletion statig/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ default = ["macro"]
macro = ["statig_macro"]
serde = ["dep:serde"]
bevy = ["dep:bevy_ecs"]
async = ["std"]
async = []
std = []
3 changes: 3 additions & 0 deletions statig/src/awaitable/state.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
extern crate alloc;
use alloc::boxed::Box;

use core::future::Future;
use core::pin::Pin;

Expand Down
3 changes: 3 additions & 0 deletions statig/src/awaitable/superstate.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
extern crate alloc;
use alloc::boxed::Box;

use core::cmp::Ordering;
use core::future::Future;
use core::pin::Pin;
Expand Down