Skip to content

Commit

Permalink
style: format
Browse files Browse the repository at this point in the history
  • Loading branch information
strasdat committed Mar 8, 2024
1 parent 9c9e47e commit c94ce06
Show file tree
Hide file tree
Showing 36 changed files with 273 additions and 141 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["actor", "compute", "graph", "pipeline"]
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/farm-ng/hollywood/"
version = "0.4.0"
version = "0.5.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -21,7 +21,7 @@ drawille = "0.3.0"
eframe = {version = "0.26", features = ["wgpu"], optional = true}
env_logger = {version = "0.11.1", optional = true}
grid = "0.13.0"
hollywood_macros = {version = "0.4.0", path = "hollywood_macros"}
hollywood_macros = {version = "0.5.0", path = "hollywood_macros"}
# hollywood intends to use only very basic features of nalgebra, hence
# future versions of nalgebra before the major < 1.0 release are likely to work
nalgebra = ">= 0.32, <1.0"
Expand Down
7 changes: 4 additions & 3 deletions examples/egui.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::time::Duration;

use hollywood::actors::egui::{
EguiActor, EguiAppFromBuilder, GenericEguiBuilder, Stream,
};
use hollywood::actors::egui::EguiActor;
use hollywood::actors::egui::EguiAppFromBuilder;
use hollywood::actors::egui::GenericEguiBuilder;
use hollywood::actors::egui::Stream;
use hollywood::compute::Context;
use hollywood::core::request::RequestMessage;
use hollywood::core::*;
Expand Down
12 changes: 7 additions & 5 deletions examples/moving_average.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use hollywood::actors::printer::PrinterProp;
use hollywood::actors::{Periodic, Printer};
use hollywood::actors::Periodic;
use hollywood::actors::Printer;
use hollywood::compute::Context;
use hollywood::core::{FromPropState, NullState};
use hollywood::core::FromPropState;
use hollywood::core::NullState;

use hollywood::example_actors::moving_average::{
MovingAverage, MovingAverageProp, MovingAverageState,
};
use hollywood::example_actors::moving_average::MovingAverage;
use hollywood::example_actors::moving_average::MovingAverageProp;
use hollywood::example_actors::moving_average::MovingAverageState;

///
pub async fn run_moving_average_example() {
Expand Down
3 changes: 2 additions & 1 deletion examples/nudge.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use hollywood::actors::printer::PrinterProp;
use hollywood::actors::{Nudge, Printer};
use hollywood::actors::Nudge;
use hollywood::actors::Printer;
use hollywood::compute::Context;
use hollywood::core::*;

Expand Down
10 changes: 7 additions & 3 deletions examples/one_dim_robot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ use hollywood::core::*;

use hollywood::example_actors::one_dim_robot::draw::DrawState;
use hollywood::example_actors::one_dim_robot::filter::FilterState;
use hollywood::example_actors::one_dim_robot::{
DrawActor, Filter, NamedFilterState, Robot, Sim, SimState, Stamped,
};
use hollywood::example_actors::one_dim_robot::DrawActor;
use hollywood::example_actors::one_dim_robot::Filter;
use hollywood::example_actors::one_dim_robot::NamedFilterState;
use hollywood::example_actors::one_dim_robot::Robot;
use hollywood::example_actors::one_dim_robot::Sim;
use hollywood::example_actors::one_dim_robot::SimState;
use hollywood::example_actors::one_dim_robot::Stamped;

async fn run_robot_example() {
let pipeline = Context::configure(&mut |context| {
Expand Down
3 changes: 2 additions & 1 deletion examples/print_ticks.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use hollywood::actors::printer::PrinterProp;
use hollywood::actors::{Periodic, Printer};
use hollywood::actors::Periodic;
use hollywood::actors::Printer;
use hollywood::compute::Context;
use hollywood::core::*;

Expand Down
8 changes: 6 additions & 2 deletions examples/zip.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use hollywood::actors::periodic;
use hollywood::actors::printer::PrinterProp;
use hollywood::actors::zip::{Tuple2, Zip2State, ZipPair};
use hollywood::actors::{periodic, Printer, Zip2};
use hollywood::actors::zip::Tuple2;
use hollywood::actors::zip::Zip2State;
use hollywood::actors::zip::ZipPair;
use hollywood::actors::Printer;
use hollywood::actors::Zip2;
use hollywood::compute::Context;
use hollywood::core::*;

Expand Down
2 changes: 1 addition & 1 deletion hollywood_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["actor", "compute", "graph", "pipeline"]
license = "Apache-2.0"
readme = "../README.md"
repository = "https://github.com/farm-ng/hollywood/tree/main/hollywood_macros"
version = "0.4.0"
version = "0.5.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
Expand Down
2 changes: 1 addition & 1 deletion hollywood_macros/src/actors.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod zip;
pub mod zip;
19 changes: 12 additions & 7 deletions hollywood_macros/src/actors/zip.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use syn::{parse::Parse, parse::ParseStream, parse2, LitInt, Result};
use quote::format_ident;
use quote::quote;
use syn::parse::Parse;
use syn::parse::ParseStream;
use syn::parse2;
use syn::LitInt;
use syn::Result;

struct ZipInput {
num_fields: usize,
Expand Down Expand Up @@ -156,9 +161,9 @@ pub(crate) fn zip_state_n_impl(input: TokenStream) -> TokenStream {
let heap_item = format_ident!("item{}_heap", i);
let item = format_ident!("Item{}", i); // Corrected this line
let pair = quote! { ZipPair<#i, Key, #item> };
quote! {
quote! {
/// Heap for the Xth inbound channel.
pub #heap_item: std::collections::BinaryHeap<std::cmp::Reverse<#pair>>
pub #heap_item: std::collections::BinaryHeap<std::cmp::Reverse<#pair>>
}
});

Expand Down Expand Up @@ -245,7 +250,7 @@ pub(crate) fn zip_inbound_message_n_impl(input: TokenStream) -> TokenStream {
Key: Ord + Clone + Debug + Sync + Send + 'static,
#( #type_with_bounds_seq ),*
> {
#(
#(
/// Inbound message for the Xth inbound channel.
#type_seq(ZipPair<#i_seq, Key, #type_seq>)
),*
Expand Down Expand Up @@ -406,9 +411,9 @@ pub(crate) fn zip_inbound_n_impl(input: TokenStream) -> TokenStream {
+ Sync + Send + 'static,
#( #type_with_bounds_seq ),*
> {
#(
#(
/// Inbound channel for the Xth inbound channel.
pub #item_seq5: #channel
pub #item_seq5: #channel
),*
}

Expand Down
27 changes: 21 additions & 6 deletions hollywood_macros/src/core.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
use convert_case::{Case, Casing};
use convert_case::Case;
use convert_case::Casing;
use proc_macro2::TokenStream;
use quote::quote;
use syn::{
parse::Parse, parse::ParseStream, parse2, Error, Fields, Generics, Ident, Item, ItemEnum,
ItemStruct, Path, PathArguments, Result, Token, Type, TypePath,
};
use syn::parse::Parse;
use syn::parse::ParseStream;
use syn::parse2;
use syn::Error;
use syn::Fields;
use syn::Generics;
use syn::Ident;
use syn::Item;
use syn::ItemEnum;
use syn::ItemStruct;
use syn::Path;
use syn::PathArguments;
use syn::Result;
use syn::Token;
use syn::Type;
use syn::TypePath;

/// Documentation is in the hollywood crate.
pub(crate) fn actor_outputs_impl(_attr: TokenStream, item: TokenStream) -> TokenStream {
Expand Down Expand Up @@ -142,7 +155,9 @@ pub(crate) fn actor_requests_impl(_attr: TokenStream, item: TokenStream) -> Toke
}
});

let field0 = fields.first().expect("Request struct must have at least one field");
let field0 = fields
.first()
.expect("Request struct must have at least one field");
let m_type = is_request_type(&field0.ty).unwrap()[2];

let gen = quote! {
Expand Down
3 changes: 2 additions & 1 deletion src/actors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ pub use periodic::Periodic;

/// Generic printer actor.
pub mod printer;
pub use printer::{Printer, PrinterProp};
pub use printer::Printer;
pub use printer::PrinterProp;

/// Nudge actor.
pub mod nudge;
Expand Down
6 changes: 4 additions & 2 deletions src/actors/egui.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::compute::{CancelRequest, Context};
use crate::compute::CancelRequest;
use crate::compute::Context;
use crate::core::*;
use std::fmt::Debug;

use self::request::{IsRequestMessage, RequestMessage};
use self::request::IsRequestMessage;
use self::request::RequestMessage;

/// The inbound message for the egui actor.
#[derive(Clone, Debug, Default)]
Expand Down
16 changes: 10 additions & 6 deletions src/actors/nudge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ use crate::compute::context::Context;
use crate::core::connection::ConnectionEnum;
use crate::core::NullState;

use crate::core::actor::ActorNode;
use crate::core::actor::FromPropState;
use crate::core::actor::GenericActor;
use crate::core::inbound::ForwardMessage;
use crate::core::inbound::NullInbound;
use crate::core::inbound::NullMessage;
use crate::core::outbound::Activate;
use crate::core::outbound::OutboundChannel;
use crate::core::outbound::OutboundHub;
use crate::core::request::NullRequest;
use crate::core::{
actor::{ActorNode, FromPropState, GenericActor},
inbound::{ForwardMessage, NullInbound, NullMessage},
outbound::{Activate, OutboundChannel, OutboundHub},
runner::Runner,
};
use crate::core::runner::Runner;

/// Prop for the nudge actor.
#[derive(Clone, Debug, Default)]
Expand Down
16 changes: 10 additions & 6 deletions src/actors/periodic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ use async_trait::async_trait;
use crate::compute::context::Context;
use crate::core::connection::ConnectionEnum;

use crate::core::actor::ActorNode;
use crate::core::actor::FromPropState;
use crate::core::actor::GenericActor;
use crate::core::inbound::ForwardMessage;
use crate::core::inbound::NullInbound;
use crate::core::inbound::NullMessage;
use crate::core::outbound::Activate;
use crate::core::outbound::OutboundChannel;
use crate::core::outbound::OutboundHub;
use crate::core::request::NullRequest;
use crate::core::{
actor::{ActorNode, FromPropState, GenericActor},
inbound::{ForwardMessage, NullInbound, NullMessage},
outbound::{Activate, OutboundChannel, OutboundHub},
runner::Runner,
};
use crate::core::runner::Runner;

/// A periodic actor.
///
Expand Down
19 changes: 14 additions & 5 deletions src/actors/printer.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
use std::fmt::{Debug, Display};
use std::fmt::Debug;
use std::fmt::Display;

use hollywood_macros::actor_inputs;

use crate::core::{
request::NullRequest, Actor, ActorBuilder, DefaultRunner, FromPropState, InboundChannel,
InboundHub, InboundMessage, InboundMessageNew, NullOutbound, NullState, OnMessage,
};
use crate::core::request::NullRequest;
use crate::core::Actor;
use crate::core::ActorBuilder;
use crate::core::DefaultRunner;
use crate::core::FromPropState;
use crate::core::InboundChannel;
use crate::core::InboundHub;
use crate::core::InboundMessage;
use crate::core::InboundMessageNew;
use crate::core::NullOutbound;
use crate::core::NullState;
use crate::core::OnMessage;

/// Configuration properties for the printer actor.
#[derive(Clone, Debug)]
Expand Down
10 changes: 8 additions & 2 deletions src/compute/context.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
use std::marker::PhantomData;
use std::sync::Arc;

use crate::compute::{CancelRequest, Pipeline, Topology};
use crate::core::{ActorNode, InboundChannel, InboundMessage, OutboundChannel, OutboundConnection};
use crate::compute::CancelRequest;
use crate::compute::Pipeline;
use crate::compute::Topology;
use crate::core::ActorNode;
use crate::core::InboundChannel;
use crate::core::InboundMessage;
use crate::core::OutboundChannel;
use crate::core::OutboundConnection;

/// The context of the compute graph which is used to configure the network topology.
///
Expand Down
12 changes: 8 additions & 4 deletions src/compute/pipeline.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use std::mem::swap;

use crate::compute::{Context, Topology};
use crate::core::{
ActorNode, InboundMessage, InboundMessageNew, NullOutbound, NullProp, NullState,
};
use crate::compute::Context;
use crate::compute::Topology;
use crate::core::ActorNode;
use crate::core::InboundMessage;
use crate::core::InboundMessageNew;
use crate::core::NullOutbound;
use crate::core::NullProp;
use crate::core::NullState;

/// Message to request stop execution of the compute pipeline.
#[derive(Debug, Clone)]
Expand Down
8 changes: 4 additions & 4 deletions src/compute/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::collections::BTreeSet;

use petgraph::stable_graph::StableDiGraph;

use crate::{
core::{InboundChannel, InboundMessage, OutboundChannel},
introspect::flow_graph::FlowGraph,
};
use crate::core::InboundChannel;
use crate::core::InboundMessage;
use crate::core::OutboundChannel;
use crate::introspect::flow_graph::FlowGraph;

// A node in a compute graph.
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
Expand Down
25 changes: 17 additions & 8 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
/// Actor
pub mod actor;
pub use actor::Actor;
pub(crate) use actor::ActorNode;
pub use actor::{Actor, FromPropState};
pub use actor::FromPropState;

/// Actor builder
pub mod actor_builder;
Expand All @@ -12,19 +13,26 @@ pub use actor_builder::ActorBuilder;
/// Inbound
pub mod inbound;

pub use inbound::{
InboundChannel, InboundHub, InboundMessage, InboundMessageNew, NullInbound, NullMessage,
OnMessage,
};
pub use inbound::InboundChannel;
pub use inbound::InboundHub;
pub use inbound::InboundMessage;
pub use inbound::InboundMessageNew;
pub use inbound::NullInbound;
pub use inbound::NullMessage;
pub use inbound::OnMessage;

/// Outbound
pub mod outbound;
pub use outbound::Activate;
pub use outbound::NullOutbound;
pub use outbound::OutboundChannel;
pub(crate) use outbound::OutboundConnection;
pub use outbound::{Activate, NullOutbound, OutboundChannel, OutboundHub};
pub use outbound::OutboundHub;

/// Request
pub mod request;
pub use request::{NullRequest, RequestHub};
pub use request::NullRequest;
pub use request::RequestHub;

/// Connection
pub mod connection;
Expand All @@ -35,4 +43,5 @@ pub use runner::DefaultRunner;

/// State
pub mod value;
pub use value::{NullProp, NullState};
pub use value::NullProp;
pub use value::NullState;
Loading

0 comments on commit c94ce06

Please sign in to comment.