Skip to content

Commit

Permalink
fix PR
Browse files Browse the repository at this point in the history
  • Loading branch information
gpwclark committed Jan 27, 2025
1 parent bd60a08 commit 42826b9
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 272 deletions.
2 changes: 1 addition & 1 deletion bridge_adapters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ pub fn add_builtin(
let key = env.intern("doc-string");
let s = env.alloc_string(doc_string.to_string());
env.set_global_property(si, key, s);
}
}
1 change: 0 additions & 1 deletion bridge_adapters/src/lisp_adapters/numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ impl<'a> SlFromRef<'a, Value> for u8 {
}
}


impl SlFrom<usize> for Value {
fn sl_from(value: usize, _vm: &mut SloshVm) -> VMResult<Self> {
Ok(to_i56(value as i64))
Expand Down
19 changes: 12 additions & 7 deletions bridge_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ use std::fmt::{Display, Formatter};
use syn::__private::{Span, TokenStream2};
use syn::spanned::Spanned;
use syn::{
parse::Parse, LitStr, Token,
parse_macro_input, AttributeArgs, Error, FnArg, GenericArgument, Generics, Ident, Item,
ItemFn, Lit, Meta, NestedMeta, PathArguments, ReturnType, Type, TypeBareFn, TypePath,
TypeReference, TypeTuple,
parse::Parse, parse_macro_input, AttributeArgs, Error, FnArg, GenericArgument, Generics, Ident,
Item, ItemFn, Lit, LitStr, Meta, NestedMeta, PathArguments, ReturnType, Token, Type,
TypeBareFn, TypePath, TypeReference, TypeTuple,
};
extern crate static_assertions;

Expand Down Expand Up @@ -1657,7 +1656,7 @@ impl Parse for StrRange {
_comma1: input.parse()?,
start: input.parse()?,
_comma2: input.parse()?,
end: input.parse()?
end: input.parse()?,
})
}
}
Expand All @@ -1669,8 +1668,14 @@ pub fn include_str_range(input: proc_macro::TokenStream) -> proc_macro::TokenStr
let content = std::fs::read_to_string(input.file.value()).unwrap();
let lines: Vec<_> = content.lines().collect();

let start_idx = lines.iter().position(|l| l.contains(&input.start.value())).unwrap();
let end_idx = lines.iter().position(|l| l.contains(&input.end.value())).unwrap();
let start_idx = lines
.iter()
.position(|l| l.contains(&input.start.value()))
.unwrap();
let end_idx = lines
.iter()
.position(|l| l.contains(&input.end.value()))
.unwrap();

let selected = lines[start_idx..end_idx].join("\n");

Expand Down
14 changes: 6 additions & 8 deletions builtins/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ fn char_is_whitespace(target: SloshChar) -> VMResult<bool> {
}
}


/// Usage: (str->int string) -> int
///
/// If string is a valid representation of an integer return that int. Error if not.
Expand All @@ -522,12 +521,11 @@ fn char_is_whitespace(target: SloshChar) -> VMResult<bool> {
/// (test::assert-error (str->int "--10"))
#[sl_sh_fn(fn_name = "str->int")]
fn str_to_int(target: &str) -> VMResult<i64> {
target.parse::<i64>().map_err(|_e| {
VMError::new_conversion("Not a valid integer.")
})
target
.parse::<i64>()
.map_err(|_e| VMError::new_conversion("Not a valid integer."))
}

// TODO SL what should this be?
/// Usage: (str->float string) -> float
///
/// If string is a valid representation of a float return that float. Error if not.
Expand All @@ -544,9 +542,9 @@ fn str_to_int(target: &str) -> VMResult<i64> {
/// (test::assert-error (str->float "--10"))
#[sl_sh_fn(fn_name = "str->float")]
fn str_to_float(target: &str) -> VMResult<f64> {
target.parse::<f64>().map_err(|_e| {
VMError::new_conversion("Not a valid float.")
})
target
.parse::<f64>()
.map_err(|_e| VMError::new_conversion("Not a valid float."))
}

pub fn add_str_builtins(env: &mut SloshVm) {
Expand Down
7 changes: 0 additions & 7 deletions scripts/pr-globals.slosh

This file was deleted.

5 changes: 2 additions & 3 deletions slosh_test/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use slosh_test_lib::docs;
use bridge_adapters::add_builtin;
use compile_state::state::SloshVm;
use sl_compiler::load_eval::run_reader;
use sl_compiler::Reader;
use slosh_lib::run;
use std::process;
use slosh_test_lib::docs;
use slvm::{VMError, VMResult, Value};
use std::process;

pub const VERSION_STRING: &str = env!("VERSION_STRING");

Expand All @@ -16,7 +16,6 @@ fn version(vm: &mut SloshVm, registers: &[Value]) -> VMResult<Value> {
Ok(vm.alloc_string(VERSION_STRING.to_string()))
}


fn modify_vm(vm: &mut SloshVm) {
docs::add_builtins(vm);

Expand Down
105 changes: 0 additions & 105 deletions slosh_test_lib/build.rs

This file was deleted.

28 changes: 0 additions & 28 deletions slosh_test_lib/run-tests.slosh

This file was deleted.

13 changes: 9 additions & 4 deletions slosh_test_lib/src/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,17 +676,23 @@ fn build_doc(vm: &mut SloshVm, registers: &[Value]) -> VMResult<Value> {
md.book.push_item(BookItem::Chapter(chapter));
}


// Add a separator and a title for the new autogenerated section.
md.book.push_item(BookItem::Separator);
md.book
.push_item(BookItem::PartTitle("Supplemental Material".to_string()));
{
let mut reader = Reader::from_string(r#"(do (load "core.slosh") (load "sh-color.slosh"))"#.to_string(), vm, "", 1, 0);
let mut reader = Reader::from_string(
r#"(do (load "core.slosh") (load "sh-color.slosh"))"#.to_string(),
vm,
"",
1,
0,
);
_ = run_reader(&mut reader).unwrap();
}
// Transition section!
md.book.push_item(BookItem::Chapter(build_sl_sh_transition_chapter(vm)?));
md.book
.push_item(BookItem::Chapter(build_sl_sh_transition_chapter(vm)?));
let sections = vec![
("Slosh Rust Docs", "slosh-rust-docs/doc/slosh/index.html"),
("All Rust Docs", "all-rust-docs/doc/slosh/index.html"),
Expand Down Expand Up @@ -822,7 +828,6 @@ Example:
#t
",
);

}

#[cfg(test)]
Expand Down
Loading

0 comments on commit 42826b9

Please sign in to comment.