Skip to content

Commit 0c1edd3

Browse files
committed
Add print wrappers for debugging
1 parent 2aaa7c5 commit 0c1edd3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

crates/harp/src/utils.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,3 +649,16 @@ pub fn push_rds(x: SEXP, path: &str, context: &str) {
649649
// This is meant for internal use so report errors loudly
650650
res.unwrap();
651651
}
652+
653+
pub fn r_print(x: impl Into<SEXP>) {
654+
unsafe {
655+
Rf_PrintValue(x.into());
656+
}
657+
}
658+
659+
pub fn r_printf(x: &str) {
660+
let c_str = std::ffi::CString::new(x).unwrap();
661+
unsafe {
662+
libr::Rprintf(c_str.as_ptr());
663+
}
664+
}

crates/libr/src/r.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ functions_variadic::generate! {
355355
pub fn Rf_error(arg1: *const std::ffi::c_char, ...) -> !;
356356

357357
pub fn Rf_errorcall(arg1: SEXP, arg2: *const std::ffi::c_char, ...) -> !;
358+
359+
pub fn Rprintf(x: *const std::ffi::c_char, ...);
358360
}
359361

360362
constant_globals::generate! {

0 commit comments

Comments
 (0)