Add START and END constants to std (#6270)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -257,7 +257,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
shell(firstSketch, faces = [END], thickness = 0.25)"#;
|
||||
|
||||
let ExecTestResults { program, exec_ctxt, .. } = parse_execute(new).await.unwrap();
|
||||
|
||||
@ -288,7 +288,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25) "#;
|
||||
shell(firstSketch, faces = [END], thickness = 0.25) "#;
|
||||
|
||||
let new = r#"// Remove the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
@ -300,7 +300,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
shell(firstSketch, faces = [END], thickness = 0.25)"#;
|
||||
|
||||
let ExecTestResults { program, exec_ctxt, .. } = parse_execute(old).await.unwrap();
|
||||
|
||||
@ -333,7 +333,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25) "#;
|
||||
shell(firstSketch, faces = [END], thickness = 0.25) "#;
|
||||
|
||||
let new = r#"// Remove the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
@ -345,7 +345,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
shell(firstSketch, faces = [END], thickness = 0.25)"#;
|
||||
|
||||
let ExecTestResults { program, exec_ctxt, .. } = parse_execute(old).await.unwrap();
|
||||
|
||||
@ -380,7 +380,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25) "#;
|
||||
shell(firstSketch, faces = [END], thickness = 0.25) "#;
|
||||
|
||||
let new = r#"@foo(whatever = 42)
|
||||
@baz
|
||||
@ -394,7 +394,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
shell(firstSketch, faces = [END], thickness = 0.25)"#;
|
||||
|
||||
let ExecTestResults { program, exec_ctxt, .. } = parse_execute(old).await.unwrap();
|
||||
|
||||
@ -428,7 +428,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
shell(firstSketch, faces = [END], thickness = 0.25)"#;
|
||||
|
||||
let ExecTestResults {
|
||||
program, mut exec_ctxt, ..
|
||||
@ -465,7 +465,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
shell(firstSketch, faces = [END], thickness = 0.25)"#;
|
||||
|
||||
let ExecTestResults {
|
||||
program, mut exec_ctxt, ..
|
||||
|
@ -143,13 +143,23 @@ impl From<KclError> for ParseResult {
|
||||
}
|
||||
}
|
||||
|
||||
const STR_DEPRECATIONS: [(&str, &str); 6] = [
|
||||
const STR_DEPRECATIONS: [(&str, &str); 16] = [
|
||||
("XY", "XY"),
|
||||
("XZ", "XZ"),
|
||||
("YZ", "YZ"),
|
||||
("-XY", "-XY"),
|
||||
("-XZ", "-XZ"),
|
||||
("-YZ", "-YZ"),
|
||||
("xy", "XY"),
|
||||
("xz", "XZ"),
|
||||
("yz", "YZ"),
|
||||
("-xy", "-XY"),
|
||||
("-xz", "-XZ"),
|
||||
("-yz", "-YZ"),
|
||||
("START", "START"),
|
||||
("start", "START"),
|
||||
("END", "END"),
|
||||
("end", "END"),
|
||||
];
|
||||
const FN_DEPRECATIONS: [(&str, &str); 3] = [("pi", "PI"), ("e", "E"), ("tau", "TAU")];
|
||||
const CONST_DEPRECATIONS: [(&str, &str); 4] = [
|
||||
|
@ -132,7 +132,7 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
///
|
||||
/// shell(
|
||||
/// firstSketch,
|
||||
/// faces = ['end'],
|
||||
/// faces = [END],
|
||||
/// thickness = 0.25,
|
||||
/// )
|
||||
/// |> appearance(
|
||||
@ -160,7 +160,7 @@ pub async fn appearance(exec_state: &mut ExecState, args: Args) -> Result<KclVal
|
||||
///
|
||||
/// shell(
|
||||
/// firstSketch,
|
||||
/// faces = ['end'],
|
||||
/// faces = [END],
|
||||
/// thickness = 0.25,
|
||||
/// )
|
||||
/// ```
|
||||
|
@ -828,11 +828,11 @@ pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result
|
||||
/// |> close(%)
|
||||
/// |> extrude(length = 65)
|
||||
///
|
||||
/// const thing1 = startSketchOn(case, 'end')
|
||||
/// const thing1 = startSketchOn(case, END)
|
||||
/// |> circle(center = [-size / 2, -size / 2], radius = 25)
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
/// const thing2 = startSketchOn(case, 'end')
|
||||
/// const thing2 = startSketchOn(case, END)
|
||||
/// |> circle(center = [size / 2, -size / 2], radius = 25)
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
@ -856,7 +856,7 @@ pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result
|
||||
/// |> close(%)
|
||||
/// |> extrude(length = 65)
|
||||
///
|
||||
/// const thing1 = startSketchOn(case, 'end')
|
||||
/// const thing1 = startSketchOn(case, END)
|
||||
/// |> circle(center =[-size / 2, -size / 2], radius = 25)
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
|
@ -38,7 +38,7 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// // Remove the end face for the extrusion.
|
||||
/// shell(
|
||||
/// firstSketch,
|
||||
/// faces = ['end'],
|
||||
/// faces = [END],
|
||||
/// thickness = 0.25,
|
||||
/// )
|
||||
/// ```
|
||||
@ -56,7 +56,7 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// // Remove the start face for the extrusion.
|
||||
/// shell(
|
||||
/// firstSketch,
|
||||
/// faces = ['start'],
|
||||
/// faces = [START],
|
||||
/// thickness = 0.25,
|
||||
/// )
|
||||
/// ```
|
||||
@ -92,7 +92,7 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// // Remove a tagged face and the end face for the extrusion.
|
||||
/// shell(
|
||||
/// firstSketch,
|
||||
/// faces = [myTag, 'end'],
|
||||
/// faces = [myTag, END],
|
||||
/// thickness = 0.25,
|
||||
/// )
|
||||
/// ```
|
||||
@ -108,16 +108,16 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> close()
|
||||
/// |> extrude(length = 65)
|
||||
///
|
||||
/// thing1 = startSketchOn(case, 'end')
|
||||
/// thing1 = startSketchOn(case, END)
|
||||
/// |> circle( center = [-size / 2, -size / 2], radius = 25 )
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
/// thing2 = startSketchOn(case, 'end')
|
||||
/// thing2 = startSketchOn(case, END)
|
||||
/// |> circle( center = [size / 2, -size / 2], radius = 25 )
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
/// // We put "case" in the shell function to shell the entire object.
|
||||
/// shell(case, faces = ['start'], thickness = 5)
|
||||
/// shell(case, faces = [START], thickness = 5)
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
@ -131,16 +131,16 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> close()
|
||||
/// |> extrude(length = 65)
|
||||
///
|
||||
/// thing1 = startSketchOn(case, 'end')
|
||||
/// thing1 = startSketchOn(case, END)
|
||||
/// |> circle( center = [-size / 2, -size / 2], radius = 25 )
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
/// thing2 = startSketchOn(case, 'end')
|
||||
/// thing2 = startSketchOn(case, END)
|
||||
/// |> circle( center = [size / 2, -size / 2], radius = 25 )
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
/// // We put "thing1" in the shell function to shell the end face of the object.
|
||||
/// shell(thing1, faces = ['end'], thickness = 5)
|
||||
/// shell(thing1, faces = [END], thickness = 5)
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
@ -156,16 +156,16 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> close()
|
||||
/// |> extrude(length = 65)
|
||||
///
|
||||
/// thing1 = startSketchOn(case, 'end')
|
||||
/// thing1 = startSketchOn(case, END)
|
||||
/// |> circle( center = [-size / 2, -size / 2], radius = 25 )
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
/// thing2 = startSketchOn(case, 'end')
|
||||
/// thing2 = startSketchOn(case, END)
|
||||
/// |> circle( center = [size / 2, -size / 2], radius = 25)
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
/// // We put "thing1" and "thing2" in the shell function to shell the end face of the object.
|
||||
/// shell([thing1, thing2], faces = ['end'], thickness = 5)
|
||||
/// shell([thing1, thing2], faces = [END], thickness = 5)
|
||||
/// ```
|
||||
#[stdlib {
|
||||
name = "shell",
|
||||
@ -291,11 +291,11 @@ pub async fn hollow(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// |> close()
|
||||
/// |> extrude(length = 65)
|
||||
///
|
||||
/// thing1 = startSketchOn(case, 'end')
|
||||
/// thing1 = startSketchOn(case, END)
|
||||
/// |> circle( center = [-size / 2, -size / 2], radius = 25 )
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
/// thing2 = startSketchOn(case, 'end')
|
||||
/// thing2 = startSketchOn(case, END)
|
||||
/// |> circle( center = [size / 2, -size / 2], radius = 25 )
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
|
@ -251,7 +251,7 @@ pub async fn line(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kc
|
||||
/// ```no_run
|
||||
/// triangle = startSketchOn(XZ)
|
||||
/// |> startProfileAt([0, 0], %)
|
||||
/// // The 'end' argument means it ends at exactly [10, 0].
|
||||
/// // The END argument means it ends at exactly [10, 0].
|
||||
/// // This is an absolute measurement, it is NOT relative to
|
||||
/// // the start of the sketch.
|
||||
/// |> line(endAbsolute = [10, 0])
|
||||
@ -1005,7 +1005,7 @@ pub async fn start_sketch_on(exec_state: &mut ExecState, args: Args) -> Result<K
|
||||
///
|
||||
/// example = extrude(exampleSketch, length = 5)
|
||||
///
|
||||
/// exampleSketch002 = startSketchOn(example, 'end')
|
||||
/// exampleSketch002 = startSketchOn(example, END)
|
||||
/// |> startProfileAt([1, 1], %)
|
||||
/// |> line(end = [8, 0])
|
||||
/// |> line(end = [0, 8])
|
||||
@ -1014,7 +1014,7 @@ pub async fn start_sketch_on(exec_state: &mut ExecState, args: Args) -> Result<K
|
||||
///
|
||||
/// example002 = extrude(exampleSketch002, length = 5)
|
||||
///
|
||||
/// exampleSketch003 = startSketchOn(example002, 'end')
|
||||
/// exampleSketch003 = startSketchOn(example002, END)
|
||||
/// |> startProfileAt([2, 2], %)
|
||||
/// |> line(end = [6, 0])
|
||||
/// |> line(end = [0, 6])
|
||||
@ -1098,7 +1098,7 @@ pub async fn start_sketch_on(exec_state: &mut ExecState, args: Args) -> Result<K
|
||||
///
|
||||
/// example = revolve(exampleSketch, axis = Y, angle = 180)
|
||||
///
|
||||
/// exampleSketch002 = startSketchOn(example, 'end')
|
||||
/// exampleSketch002 = startSketchOn(example, END)
|
||||
/// |> startProfileAt([4.5, -5], %)
|
||||
/// |> line(end = [0, 5])
|
||||
/// |> line(end = [5, 0])
|
||||
|
@ -1728,7 +1728,7 @@ thk = 5
|
||||
hole_diam = 5
|
||||
// define a rectangular shape func
|
||||
fn rectShape(pos, w, l) {
|
||||
rr = startSketchOn('xy')
|
||||
rr = startSketchOn(XY)
|
||||
|> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] - (l / 2)], tag = $edge1)
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] + l / 2], tag = $edge2)
|
||||
|
Reference in New Issue
Block a user