Releases: yutannihilation/savvy
v0.6.3 (2024-05-05)
Release Notes
New features
-
New types
NumericSexp
andNumericScalar
are added to handle both integer
and double. You can get a slice viaas_slice_*()
or an iterator via
iter_*()
.#[savvy] fn times_two(x: NumericSexp) -> savvy::Result<Sexp> { let mut out = OwnedIntegerSexp::new(x.len())?; for (i, v) in x.iter_i32().enumerate() { let v = v?; // The item of iter_i32() is Result because the conversion can fail. if v.is_na() { out[i] = i32::na(); } else { out[i] = v * 2; } } out.into() }
You can also use
.into_typed()
to handle integer and double differently.#[savvy] fn times_two(x: NumericSexp) -> savvy::Result<savvy::Sexp> { match x.into_typed() { NumericTypedSexp::Integer(i) => times_two_int(i), NumericTypedSexp::Real(r) => times_two_real(r), } }
-
Savvy now provides
r_stdout()
andr_stderr()
to be used with interfaces
that requirestd::io::Write
. Also, you can usesavvy::log::env_logger()
to
output logs to R's stderr. Here's an example usage:use savvy::savvy_init; use savvy_ffi::DllInfo; #[savvy_init] fn init_logger(dll_info: *mut DllInfo) -> savvy::Result<()> { savvy::log::env_logger().init(); Ok(()) }
Breaking changes
-
AltList
now losesnames
argument ininto_altrep()
for consistency.
Please useset_names()
on the resultedSexp
object.let mut out = v.into_altrep()?; out.set_names(["one", "two"])?; Ok(out)
Download savvy-cli 0.6.3
File | Platform | Checksum |
---|---|---|
savvy-cli-aarch64-apple-darwin.tar.xz | Apple Silicon macOS | checksum |
savvy-cli-x86_64-apple-darwin.tar.xz | Intel macOS | checksum |
savvy-cli-x86_64-pc-windows-msvc.zip | x64 Windows | checksum |
savvy-cli-aarch64-unknown-linux-gnu.tar.xz | ARM64 Linux | checksum |
savvy-cli-x86_64-unknown-linux-gnu.tar.xz | x64 Linux | checksum |
v0.6.2 (2024-05-04)
Release Notes
New features
-
New macro
#[savvy_init]
makes the function executed when the DLL is loaded
by R. This is useful for initializaing resources. See the guide for more details.Example:
use std::sync::OnceLock; static GLOBAL_FOO: OnceLock<Foo> = OnceLock::new(); #[savvy_init] fn init_global_foo(dll_info: *mut DllInfo) -> savvy::Result<()> { GLOBAL_FOO.get_or_init(|| Foo::new()); Ok(()) }
-
Savvy now experimentally supports ALTREP. See the guide for more details.
Example:
struct MyAltInt(Vec<i32>); impl MyAltInt { fn new(x: Vec<i32>) -> Self { Self(x) } } impl savvy::IntoExtPtrSexp for MyAltInt {} impl AltInteger for MyAltInt { const CLASS_NAME: &'static str = "MyAltInt"; const PACKAGE_NAME: &'static str = "TestPackage"; fn length(&mut self) -> usize { self.0.len() } fn elt(&mut self, i: usize) -> i32 { self.0[i] } }
Download savvy-cli 0.6.2
File | Platform | Checksum |
---|---|---|
savvy-cli-aarch64-apple-darwin.tar.xz | Apple Silicon macOS | checksum |
savvy-cli-x86_64-apple-darwin.tar.xz | Intel macOS | checksum |
savvy-cli-x86_64-pc-windows-msvc.zip | x64 Windows | checksum |
savvy-cli-aarch64-unknown-linux-gnu.tar.xz | ARM64 Linux | checksum |
savvy-cli-x86_64-unknown-linux-gnu.tar.xz | x64 Linux | checksum |
v0.6.1 (2024-04-26)
Release Notes
Minor improvements
- Now savvy no longer uses
SETLENGTH
, which is a so-called "non-API" thing.
Download savvy-cli 0.6.1
File | Platform | Checksum |
---|---|---|
savvy-cli-aarch64-apple-darwin.tar.xz | Apple Silicon macOS | checksum |
savvy-cli-x86_64-apple-darwin.tar.xz | Intel macOS | checksum |
savvy-cli-x86_64-pc-windows-msvc.zip | x64 Windows | checksum |
savvy-cli-aarch64-unknown-linux-gnu.tar.xz | ARM64 Linux | checksum |
savvy-cli-x86_64-unknown-linux-gnu.tar.xz | x64 Linux | checksum |
v0.6.0 (2024-04-20)
Release Notes
Breaking changes
-
savvy-cli test
now parses test modules marked with#[cfg(savvy_test)]
instead of#[cfg(test)]
. The purpose of this change is to letcargo test
run for the tests unrelated to a real R sessions. -
Savvy now generates different names of Rust functions and C functions;
previously, the original function name is used for the FFI functions, but now
it'ssavvy_{original}_ffi
. This change shouldn't affect ordinary users.This change was necessary to let
#[savvy]
preserve the original function so
that we can write unit tests on the function easily. One modification is that
the function is made public. For more details, please read the Testing section
in the guide. -
The generated R wrapper file is now named as
000-wrappers.R
instead of
wrappers.R
. This makes the file is loaded first so that you can override
some of the R functions (e.g., aprint()
method for an enum) in another R
file. The old wrapper filewrappers.R
is automatically deleted bysavvy-cli update
New features
-
Added a function
eval_parse_text()
, which is an equivalent to R's idiom
eval(parse(text = ))
. This is mainly for testing purposes. -
Added a function
is_r_identical()
, which is an equivalent to R's
identical()
. This is mainly for testing purposes. -
Added a function
assert_eq_r_code()
if the first argument has the same data
as the result of the R code of the second argument.Example:
let mut x = savvy::OwnedRealSexp::new(3)?; x[1] = 1.0; x[2] = 2.0; assert_eq_r_code(x, "c(0.0, 1.0, 2.0)");
-
savvy-cli test
now picks[dev-dependencies]
from the crate'sCargo.toml
as the dependencies to be used for testing. -
savvy-cli test
got--features
argument to add features to be used for
testing.
Download savvy-cli 0.6.0
File | Platform | Checksum |
---|---|---|
savvy-cli-aarch64-apple-darwin.tar.xz | Apple Silicon macOS | checksum |
savvy-cli-x86_64-apple-darwin.tar.xz | Intel macOS | checksum |
savvy-cli-x86_64-pc-windows-msvc.zip | x64 Windows | checksum |
savvy-cli-aarch64-unknown-linux-gnu.tar.xz | ARM64 Linux | checksum |
savvy-cli-x86_64-unknown-linux-gnu.tar.xz | x64 Linux | checksum |
v0.5.3 (2024-04-16)
Release Notes
New features
-
Savvy now catches crash not only on the debug build, but also on the release
build ifpanic = "unwind"
. Instead, nowsavvy-cli init
generates a
Cargo.toml
with a release profile ofpanic = "abort"
. You need to modify
this setting if you really want to catch panics on the release build. -
savvy-cli update
now ensures.Rbuildignore
contains^src/rust/.cargo$
and^src/rust/target$
. -
savvy-cli test
now uses OS's cache dir instead of the.savvy
directory.
Fixed bugs
- Now
savvy-cli test
works for other crates than savvy.
Download savvy-cli 0.5.3
File | Platform | Checksum |
---|---|---|
savvy-cli-aarch64-apple-darwin.tar.xz | Apple Silicon macOS | checksum |
savvy-cli-x86_64-apple-darwin.tar.xz | Intel macOS | checksum |
savvy-cli-x86_64-pc-windows-msvc.zip | x64 Windows | checksum |
savvy-cli-aarch64-unknown-linux-gnu.tar.xz | ARM64 Linux | checksum |
savvy-cli-x86_64-unknown-linux-gnu.tar.xz | x64 Linux | checksum |
v0.5.2 (2024-04-14)
Release Notes
New features
-
Now savvy's debug build (when
DEBUG
envvar is set totrue
, i.e.,
devtools::load_all()
), panic doesn't crash R session and shows bactrace.
This is useful for investigating what's the cause of the panic.Please keep in mind that, in Rust, panic is an unrecoverable error. So,
not crashing doesn't mean you are saved. -
savvy-cli test
no longer relies on the savvy R package.
Fixed bugs
-
Fixed a bug in
try_from_iter()
when the actual length is different than the
size reported bysize_hint()
. -
savvy-cli test
now uses the local crate as the path dependency, instead of
using the savvy crate fixedly.
Download savvy-cli 0.5.2
File | Platform | Checksum |
---|---|---|
savvy-cli-aarch64-apple-darwin.tar.xz | Apple Silicon macOS | checksum |
savvy-cli-x86_64-apple-darwin.tar.xz | Intel macOS | checksum |
savvy-cli-x86_64-pc-windows-msvc.zip | x64 Windows | checksum |
savvy-cli-aarch64-unknown-linux-gnu.tar.xz | ARM64 Linux | checksum |
savvy-cli-x86_64-unknown-linux-gnu.tar.xz | x64 Linux | checksum |
v0.5.1 (2024-04-13)
Release Notes
New features
-
An experimental new subcommand
savvy-cli test
runs tests by extracting and
wrapping the test code with a temporary R package. This is because savvy
always requires a real R session, which meanscargo test
doesn't work. Note
that this relies on the savvy R package. Please install it before trying this.install.packages("savvy", repos = c("https://yutannihilation.r-universe.dev", "https://cloud.r-project.org"))
-
savvy-cli init
now generatesMakevars
that supports debug build when
DEBUG
envvar is set totrue
(i.e., indevtools::load_all()
).
Download savvy-cli 0.5.1
File | Platform | Checksum |
---|---|---|
savvy-cli-aarch64-apple-darwin.tar.xz | Apple Silicon macOS | checksum |
savvy-cli-x86_64-apple-darwin.tar.xz | Intel macOS | checksum |
savvy-cli-x86_64-pc-windows-msvc.zip | x64 Windows | checksum |
savvy-cli-aarch64-unknown-linux-gnu.tar.xz | ARM64 Linux | checksum |
savvy-cli-x86_64-unknown-linux-gnu.tar.xz | x64 Linux | checksum |
v0.5.0 (2024-04-05)
Release Notes
Breaking change
-
To support enum properly (the details follow), now savvy requires to put
#[savvy]
macro also onstruct
.#[savvy] // NEW! struct Person { pub name: String, } #[savvy] impl Person {
This might be a bit inconvenient on the one hand, but, on the other hand,
several good things are introduced by this change! See the New Features
section.
New features
-
Now
#[savvy]
macro supports enum to express the possible options for a
parameter. This is useful when you want to let users specify some option
without fear of typo. See the guide for more details.Example:
/// @export #[savvy] enum LineType { Solid, Dashed, Dotted, } /// @export #[savvy] fn plot_line(x: IntegerSexp, y: IntegerSexp, line_type: &LineType) -> savvy::Result<()> { match line_type { LineType::Solid => { ... }, LineType::Dashed => { ... }, LineType::Dotted => { ... }, } }
plot_line(x, y, LineType$Solid)
-
Savvy now allows
impl
definition over multiple files. It had been a headache
that it wouldn't compile when you specified#[savvy]
onimpl
of a same
struct multiple times. But now, you can split theimpl
not only within a
same file but also over multiple files.Note that, in general, if you specify a
#[savvy]
function or struct in other
file thanlib.rs
, you need to export the objects by*
. This is because
#[savvy]
defines additional functions other than the original ones and these
also need to be exported. Since you don't know the names of such
auto-generated functions,*
is the solution.mod foo; pub use foo::*;
-
OwnedListSexp
andListSexp
gainsunchecked_*()
variants of theset
and
get
methods for a fast but unsafe operation. Thanks @daniellga!
Download savvy-cli 0.5.0
File | Platform | Checksum |
---|---|---|
savvy-cli-aarch64-apple-darwin.tar.xz | Apple Silicon macOS | checksum |
savvy-cli-x86_64-apple-darwin.tar.xz | Intel macOS | checksum |
savvy-cli-x86_64-pc-windows-msvc.zip | x64 Windows | checksum |
savvy-cli-aarch64-unknown-linux-gnu.tar.xz | ARM64 Linux | checksum |
savvy-cli-x86_64-unknown-linux-gnu.tar.xz | x64 Linux | checksum |
v0.4.2 (2024-04-01)
Release Notes
New features
-
OwnedIntegerSexp
and etc now havetry_from_iter()
method for constructing
a new instance from an iterator.Example:
#[savvy] fn filter_integer_odd(x: IntegerSexp) -> savvy::Result<Sexp> { // is_na() is to propagate NAs let iter = x.iter().copied().filter(|i| i.is_na() || *i % 2 == 0); let out = OwnedIntegerSexp::try_from_iter(iter)?; out.into() }
-
OwnedIntegerSexp
and etc now havetry_from_slice()
method for constructing
a new instance from a slice or vec. This conversion is and has been possible
viatry_from()
, but this method was added for discoverability. -
OwnedIntegerSexp
and etc now havetry_from_scalar()
method for
constructing a new instance from a scalar value (e.g.i32
). This conversion
is and has been possible viatry_from()
, but this method was added for
discoverability. -
savvy-cli update
andsavvy-cli init
now tries to parse the Rust files
actually declared bymod
keyword.
Download savvy-cli 0.4.2
File | Platform | Checksum |
---|---|---|
savvy-cli-aarch64-apple-darwin.tar.xz | Apple Silicon macOS | checksum |
savvy-cli-x86_64-apple-darwin.tar.xz | Intel macOS | checksum |
savvy-cli-x86_64-pc-windows-msvc.zip | x64 Windows | checksum |
savvy-cli-aarch64-unknown-linux-gnu.tar.xz | ARM64 Linux | checksum |
savvy-cli-x86_64-unknown-linux-gnu.tar.xz | x64 Linux | checksum |
v0.4.1 (2024-03-30)
Release Notes
Breaking changes
Sexp
losesis_environment()
method becuase this isn't useful, considering
savvy doesn't support environment.
New features
-
get_dim()
andset_dim()
are now available also onSexp
. -
Now savvy allows to consume the value behind an external pointer. i.e.,
T
instead of&T
or&mut T
as the argument. After getting consumed, the
pointer is null, so any function call on the already-consumed R object results
in an error. See the guide for more details.Example:
struct Value {}; struct Wrapper { inner: Value } #[savvy] impl Value { fn new() -> Self { Self {} } } #[savvy] impl Wrapper { fn new(value: Value) -> Self { Self { inner: value } } }
v <- Value$new() w <- Wrapper$new(v) # value is consumed here. w <- Wrapper$new(v) #> Error: This external pointer is already consumed or deleted
-
Sexp
now hasassert_integer()
etc to verify the type of the underlying
SEXP is as expected.
Download savvy-cli 0.4.1
File | Platform | Checksum |
---|---|---|
savvy-cli-aarch64-apple-darwin.tar.xz | Apple Silicon macOS | checksum |
savvy-cli-x86_64-apple-darwin.tar.xz | Intel macOS | checksum |
savvy-cli-x86_64-pc-windows-msvc.zip | x64 Windows | checksum |
savvy-cli-aarch64-unknown-linux-gnu.tar.xz | ARM64 Linux | checksum |
savvy-cli-x86_64-unknown-linux-gnu.tar.xz | x64 Linux | checksum |