From a452bffe579b1326fe635c2a229fe4b86362e1db Mon Sep 17 00:00:00 2001 From: CGMossa Date: Sun, 8 Oct 2023 00:03:11 +0200 Subject: [PATCH 1/2] Use `R_ParseEvalString` in test (#188) * Remove unnecessary `tasks.json` file! * Since all supported versions have `R_ParseEvalString`, then we should use it! --- .vscode/tasks.json | 18 ------------------ src/lib.rs | 12 ++---------- 2 files changed, 2 insertions(+), 28 deletions(-) delete mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 62016596..00000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "type": "cargo", - "subcommand": "test", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - } - ] -} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index eea9dff9..cd882a0a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -137,19 +137,11 @@ mod tests { fn test_eval() { start_R(); unsafe { - // In an ideal world, we would do the following. - // let res = R_ParseEvalString(cstr!("1"), R_NilValue); - // But R_ParseEvalString is only in recent packages. - - let s = Rf_protect(Rf_mkString(cstr!("1"))); - let mut status: ParseStatus = 0; - let status_ptr = &mut status as *mut ParseStatus; - let ps = Rf_protect(R_ParseVector(s, -1, status_ptr, R_NilValue)); - let val = Rf_eval(VECTOR_ELT(ps, 0), R_GlobalEnv); + let val = Rf_protect(R_ParseEvalString(cstr!("1"), R_NilValue)); Rf_PrintValue(val); assert_eq!(TYPEOF(val) as u32, REALSXP); assert_eq!(*REAL(val), 1.); - Rf_unprotect(2); + Rf_unprotect(1); } } } From bcfeb7200416347cf0c400cece7d6561206c46d4 Mon Sep 17 00:00:00 2001 From: CGMossa Date: Sun, 8 Oct 2023 00:13:57 +0200 Subject: [PATCH 2/2] Ignore constants (#185) * Clippy suggestions * These two now appears in warnings, as there are rust equivalent ones. * Update bindings [skip ci] * These two now appears in warnings, as there are rust equivalent ones. * Update bindings [skip ci] --------- Co-authored-by: CGMossa --- bindings/bindings-linux-aarch64-R4.2.rs | 2 -- bindings/bindings-linux-aarch64-R4.3.rs | 2 -- bindings/bindings-linux-aarch64-R4.4-devel.rs | 2 -- bindings/bindings-linux-x86_64-R4.2.rs | 2 -- bindings/bindings-linux-x86_64-R4.3.rs | 2 -- bindings/bindings-linux-x86_64-R4.4-devel.rs | 2 -- bindings/bindings-macos-aarch64-R4.3.rs | 2 -- bindings/bindings-macos-x86_64-R4.2.rs | 2 -- bindings/bindings-macos-x86_64-R4.3.rs | 2 -- bindings/bindings-macos-x86_64-R4.4-devel.rs | 2 -- bindings/bindings-windows-x86_64-R4.2.rs | 2 -- bindings/bindings-windows-x86_64-R4.3.rs | 2 -- bindings/bindings-windows-x86_64-R4.4-devel.rs | 2 -- build.rs | 4 +++- 14 files changed, 3 insertions(+), 27 deletions(-) diff --git a/bindings/bindings-linux-aarch64-R4.2.rs b/bindings/bindings-linux-aarch64-R4.2.rs index 3a40e59e..0c40d277 100644 --- a/bindings/bindings-linux-aarch64-R4.2.rs +++ b/bindings/bindings-linux-aarch64-R4.2.rs @@ -146,10 +146,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/bindings/bindings-linux-aarch64-R4.3.rs b/bindings/bindings-linux-aarch64-R4.3.rs index dd7de2e7..277c54ed 100644 --- a/bindings/bindings-linux-aarch64-R4.3.rs +++ b/bindings/bindings-linux-aarch64-R4.3.rs @@ -147,10 +147,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/bindings/bindings-linux-aarch64-R4.4-devel.rs b/bindings/bindings-linux-aarch64-R4.4-devel.rs index 0305d666..64034519 100644 --- a/bindings/bindings-linux-aarch64-R4.4-devel.rs +++ b/bindings/bindings-linux-aarch64-R4.4-devel.rs @@ -147,10 +147,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/bindings/bindings-linux-x86_64-R4.2.rs b/bindings/bindings-linux-x86_64-R4.2.rs index 9e3925ce..817edb4a 100644 --- a/bindings/bindings-linux-x86_64-R4.2.rs +++ b/bindings/bindings-linux-x86_64-R4.2.rs @@ -146,10 +146,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/bindings/bindings-linux-x86_64-R4.3.rs b/bindings/bindings-linux-x86_64-R4.3.rs index a6eaadb8..cdbe9f62 100644 --- a/bindings/bindings-linux-x86_64-R4.3.rs +++ b/bindings/bindings-linux-x86_64-R4.3.rs @@ -147,10 +147,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/bindings/bindings-linux-x86_64-R4.4-devel.rs b/bindings/bindings-linux-x86_64-R4.4-devel.rs index 0aa46117..a7844500 100644 --- a/bindings/bindings-linux-x86_64-R4.4-devel.rs +++ b/bindings/bindings-linux-x86_64-R4.4-devel.rs @@ -147,10 +147,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/bindings/bindings-macos-aarch64-R4.3.rs b/bindings/bindings-macos-aarch64-R4.3.rs index f1245aa3..4abe7c46 100644 --- a/bindings/bindings-macos-aarch64-R4.3.rs +++ b/bindings/bindings-macos-aarch64-R4.3.rs @@ -149,10 +149,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/bindings/bindings-macos-x86_64-R4.2.rs b/bindings/bindings-macos-x86_64-R4.2.rs index edb792eb..784bf473 100644 --- a/bindings/bindings-macos-x86_64-R4.2.rs +++ b/bindings/bindings-macos-x86_64-R4.2.rs @@ -148,10 +148,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/bindings/bindings-macos-x86_64-R4.3.rs b/bindings/bindings-macos-x86_64-R4.3.rs index 85f224f3..223ec11c 100644 --- a/bindings/bindings-macos-x86_64-R4.3.rs +++ b/bindings/bindings-macos-x86_64-R4.3.rs @@ -149,10 +149,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/bindings/bindings-macos-x86_64-R4.4-devel.rs b/bindings/bindings-macos-x86_64-R4.4-devel.rs index e1771660..0e5676cd 100644 --- a/bindings/bindings-macos-x86_64-R4.4-devel.rs +++ b/bindings/bindings-macos-x86_64-R4.4-devel.rs @@ -149,10 +149,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/bindings/bindings-windows-x86_64-R4.2.rs b/bindings/bindings-windows-x86_64-R4.2.rs index cddfbbd4..6757c3b6 100644 --- a/bindings/bindings-windows-x86_64-R4.2.rs +++ b/bindings/bindings-windows-x86_64-R4.2.rs @@ -65,10 +65,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/bindings/bindings-windows-x86_64-R4.3.rs b/bindings/bindings-windows-x86_64-R4.3.rs index c8ee0b87..0facca69 100644 --- a/bindings/bindings-windows-x86_64-R4.3.rs +++ b/bindings/bindings-windows-x86_64-R4.3.rs @@ -66,10 +66,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/bindings/bindings-windows-x86_64-R4.4-devel.rs b/bindings/bindings-windows-x86_64-R4.4-devel.rs index 0d953359..43c6c872 100644 --- a/bindings/bindings-windows-x86_64-R4.4-devel.rs +++ b/bindings/bindings-windows-x86_64-R4.4-devel.rs @@ -66,10 +66,8 @@ pub const HAVE_EXPM1: u32 = 1; pub const HAVE_HYPOT: u32 = 1; pub const HAVE_LOG1P: u32 = 1; pub const HAVE_WORKING_LOG1P: u32 = 1; -pub const M_2PI: f64 = 6.283185307179586; pub const M_SQRT_3: f64 = 1.7320508075688772; pub const M_SQRT_32: f64 = 5.656854249492381; -pub const M_LOG10_2: f64 = 0.3010299956639812; pub const M_SQRT_PI: f64 = 1.772453850905516; pub const M_1_SQRT_2PI: f64 = 0.3989422804014327; pub const M_SQRT_2dPI: f64 = 0.7978845608028654; diff --git a/build.rs b/build.rs index 167db9ec..eee5c1b5 100644 --- a/build.rs +++ b/build.rs @@ -499,7 +499,9 @@ fn generate_bindings(r_paths: &InstallationPaths, version_info: &RVersionInfo) { .blocklist_item("M_2_PI") .blocklist_item("M_2_SQRTPI") .blocklist_item("M_SQRT2") - .blocklist_item("M_SQRT1_2"); + .blocklist_item("M_SQRT1_2") + .blocklist_item("M_2PI") + .blocklist_item("M_LOG10_2"); // `VECTOR_PTR` is deprecated, use `DATAPTR` and friends instead let bindgen_builder = bindgen_builder.blocklist_item("VECTOR_PTR");