Change pattern functions to call user function with keyword args (#6772)

* Change pattern functions to call user function with keyword args

* Fix KCL code to use unlabeled syntax

* Update generated output
This commit is contained in:
Jonathan Tran
2025-05-08 14:43:50 -04:00
committed by GitHub
parent 90cb26c6d9
commit b65ea8e0a9
8 changed files with 92 additions and 31 deletions

View File

@ -16,7 +16,7 @@ use serde::Serialize;
use uuid::Uuid;
use super::{
args::Arg,
args::{Arg, KwArgs},
utils::{point_3d_to_mm, point_to_mm},
};
use crate::{
@ -427,9 +427,18 @@ async fn make_transform<T: GeometryTrait>(
ty: NumericType::count(),
meta: vec![source_range.into()],
};
let transform_fn_args = vec![Arg::synthetic(repetition_num)];
let kw_args = KwArgs {
unlabeled: Some(Arg::new(repetition_num, source_range)),
labeled: Default::default(),
};
let transform_fn_args = Args::new_kw(
kw_args,
source_range,
ctxt.clone(),
exec_state.pipe_value().map(|v| Arg::new(v.clone(), source_range)),
);
let transform_fn_return = transform
.call(None, exec_state, ctxt, transform_fn_args, source_range)
.call_kw(None, exec_state, ctxt, transform_fn_args, source_range)
.await?;
// Unpack the returned transform object.