Skip to content

Commit ed9e14d

Browse files
authored
Merge pull request #283 from lionel-/c-api
Make magrittr compliant with C API and release magrittr 2.0.5
2 parents d16aec9 + 3560689 commit ed9e14d

4 files changed

Lines changed: 12 additions & 22 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: magrittr
33
Title: A Forward-Pipe Operator for R
4-
Version: 2.0.4.9000
4+
Version: 2.0.5
55
Authors@R: c(
66
person("Stefan Milton", "Bache", , "stefan@stefanbache.dk", role = c("aut", "cph"),
77
comment = "Original author and creator of magrittr"),

NEWS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# magrittr (development version)
1+
# magrittr 2.0.5
2+
3+
* Fixes for CRAN checks.
4+
25

36
# magrittr 2.0.4
47

cran-comments.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
Fixes part of non-conformant C API calls.
2-
3-
See https://github.com/tidyverse/magrittr/issues/279 for progress, the rest needs some ongoing updates to r-devel.
4-
5-
## R CMD check results
6-
7-
There were no ERRORs, WARNINGs, or NOTEs.
8-
9-
## Downstream dependencies
10-
11-
No failures detected.
1+
Now compliant with C API.

src/utils.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
#define R_NO_REMAP
22
#include <Rinternals.h>
3+
#include <Rversion.h>
34

45

56
SEXP r_unbound_sym = NULL;
6-
SEXP syms_delayed_assign = NULL;
77

88
void r_env_bind_lazy(SEXP env,
99
SEXP sym,
1010
SEXP expr,
1111
SEXP eval_env) {
12+
13+
#if (R_VERSION >= R_Version(4, 6, 0))
14+
R_MakeDelayedBinding(sym, expr, eval_env, env);
15+
#else
1216
SEXP prom = PROTECT(Rf_allocSExp(PROMSXP));
1317
SET_PRENV(prom, eval_env);
1418
SET_PRCODE(prom, expr);
@@ -17,11 +21,7 @@ void r_env_bind_lazy(SEXP env,
1721
Rf_defineVar(sym, prom, env);
1822

1923
UNPROTECT(1);
20-
return;
21-
22-
SEXP call = PROTECT(Rf_lang5(syms_delayed_assign, sym, expr, eval_env, env));
23-
Rf_eval(call, R_BaseEnv);
24-
UNPROTECT(1);
24+
#endif
2525
}
2626

2727

@@ -31,8 +31,6 @@ SEXP syms_inherits = NULL;
3131
SEXP syms_list = NULL;
3232
SEXP syms_rm = NULL;
3333

34-
#include <Rversion.h>
35-
3634
#if (R_VERSION < R_Version(4, 0, 0))
3735
void r__env_unbind(SEXP env, SEXP sym) {
3836
// Check if binding exists to avoid `rm()` warning
@@ -116,7 +114,6 @@ SEXP r_new_environment(SEXP parent, R_len_t size) {
116114

117115
void magrittr_init_utils(SEXP ns) {
118116
r_unbound_sym = Rf_install(".__magrittr_unbound_value__.");
119-
syms_delayed_assign = Rf_install("delayedAssign");
120117
syms_envir = Rf_install("envir");
121118
syms_inherits = Rf_install("inherits");
122119
syms_list = Rf_install("list");

0 commit comments

Comments
 (0)