diff --git a/node-graph/gcore/src/logic.rs b/node-graph/gcore/src/logic.rs index ee9d9c84..c131a0ec 100644 --- a/node-graph/gcore/src/logic.rs +++ b/node-graph/gcore/src/logic.rs @@ -28,21 +28,23 @@ fn string_concatenate(_: impl Ctx, #[implementations(String)] first: String, sec } #[node_macro::node(category("Text"))] -fn string_replace(_: impl Ctx, #[implementations(String)] string: String, from: TextArea, to: TextArea) -> String { +fn string_replace(_: impl Ctx, string: String, from: TextArea, to: TextArea) -> String { string.replace(&from, &to) } #[node_macro::node(category("Text"))] -fn string_slice(_: impl Ctx, #[implementations(String)] string: String, start: f64, end: f64) -> String { +fn string_slice(_: impl Ctx, string: String, start: f64, end: f64) -> String { let start = if start < 0. { string.len() - start.abs() as usize } else { start as usize }; let end = if end <= 0. { string.len() - end.abs() as usize } else { end as usize }; let n = end.saturating_sub(start); string.char_indices().skip(start).take(n).map(|(_, c)| c).collect() } +// TODO: Return u32, u64, or usize instead of f64 after #1621 is resolved and has allowed us to implement automatic type conversion in the node graph for nodes with generic type inputs. +// TODO: (Currently automatic type conversion only works for concrete types, via the Graphene preprocessor and not the full Graphene type system.) #[node_macro::node(category("Text"))] -fn string_length(_: impl Ctx, #[implementations(String)] string: String) -> u32 { - string.chars().count() as u32 +fn string_length(_: impl Ctx, string: String) -> f64 { + string.chars().count() as f64 } #[node_macro::node(category("Math: Logic"))] diff --git a/node-graph/gcore/src/vector/algorithms/instance.rs b/node-graph/gcore/src/vector/algorithms/instance.rs index 9ddb290e..9e40093b 100644 --- a/node-graph/gcore/src/vector/algorithms/instance.rs +++ b/node-graph/gcore/src/vector/algorithms/instance.rs @@ -103,7 +103,8 @@ async fn instance_position(ctx: impl Ctx + ExtractVarArgs) -> DVec2 { Default::default() } -// TODO: Make this return a u32 instead of an f64, but we ned to improve math-related compatibility with integer types first. +// TODO: Return u32, u64, or usize instead of f64 after #1621 is resolved and has allowed us to implement automatic type conversion in the node graph for nodes with generic type inputs. +// TODO: (Currently automatic type conversion only works for concrete types, via the Graphene preprocessor and not the full Graphene type system.) #[node_macro::node(category("Instancing"), path(graphene_core::vector))] async fn instance_index(ctx: impl Ctx + ExtractIndex, _primary: (), loop_level: u32) -> f64 { let Some(index_iter) = ctx.try_index() else { return 0. }; diff --git a/node-graph/gcore/src/vector/vector_nodes.rs b/node-graph/gcore/src/vector/vector_nodes.rs index 2ce63502..e5db8416 100644 --- a/node-graph/gcore/src/vector/vector_nodes.rs +++ b/node-graph/gcore/src/vector/vector_nodes.rs @@ -1923,9 +1923,11 @@ fn point_inside(_: impl Ctx, source: Table, point: DVec2) -> bool { source.into_iter().any(|row| row.element.check_point_inside_shape(row.transform, point)) } +// TODO: Return u32, u64, or usize instead of f64 after #1621 is resolved and has allowed us to implement automatic type conversion in the node graph for nodes with generic type inputs. +// TODO: (Currently automatic type conversion only works for concrete types, via the Graphene preprocessor and not the full Graphene type system.) #[node_macro::node(category("General"), path(graphene_core::vector))] -async fn count_elements(_: impl Ctx, #[implementations(Table, Table, Table>, Table>, Table, Table)] source: Table) -> u64 { - source.len() as u64 +async fn count_elements(_: impl Ctx, #[implementations(Table, Table, Table>, Table>, Table, Table)] source: Table) -> f64 { + source.len() as f64 } #[node_macro::node(category("Vector: Measure"), path(graphene_core::vector))]