Skip to content

Commit afde119

Browse files
authored
Merge pull request #145 from shikokuchuo/master
Fix non-API calls for closures
2 parents 8d6f7c3 + 903a78a commit afde119

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ Package: yaml
22
Type: Package
33
Title: Methods to Convert R Data to YAML and Back
44
Date: 2023-11-28
5-
Version: 2.3.8
5+
Version: 2.3.9
66
Suggests: RUnit
77
Author: Shawn P Garbett [aut], Jeremy Stephens [aut, cre], Kirill Simonov [aut], Yihui Xie [ctb],
88
Zhuoer Dong [ctb], Hadley Wickham [ctb], Jeffrey Horner [ctb], reikoch [ctb],
99
Will Beasley [ctb], Brendan O'Connor [ctb], Gregory R. Warnes [ctb],
10-
Michael Quinn [ctb], Zhian N. Kamvar [ctb]
10+
Michael Quinn [ctb], Zhian N. Kamvar [ctb], Charlie Gao [ctb]
1111
Maintainer: Shawn Garbett <shawn.garbett@vumc.org>
1212
License: BSD_3_clause + file LICENSE
1313
Description: Implements the 'libyaml' 'YAML' 1.1 parser and emitter

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.8
1+
2.3.9

src/r_emit.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ typedef struct {
1111
size_t capa;
1212
} s_emitter_output;
1313

14+
#if R_VERSION < R_Version(4, 5, 0)
15+
16+
# define R_ClosureFormals(x) FORMALS(x)
17+
# define R_ClosureBody(x) BODY(x)
18+
# define R_ClosureEnv(x) CLOENV(x)
19+
20+
static inline SEXP R_mkClosure(SEXP formals, SEXP body, SEXP env) {
21+
SEXP fun = Rf_allocSExp(CLOSXP);
22+
SET_FORMALS(fun, formals);
23+
SET_BODY(fun, body);
24+
SET_CLOENV(fun, env);
25+
return fun;
26+
}
27+
28+
#endif
29+
1430
static SEXP Ryaml_deparse_function(SEXP s_obj)
1531
{
1632
SEXP s_new_obj = NULL, s_call = NULL, s_result = NULL, s_chr = NULL;
@@ -20,10 +36,7 @@ static SEXP Ryaml_deparse_function(SEXP s_obj)
2036
/* Copy function without any attributes */
2137
if (TYPEOF(s_obj) == CLOSXP) {
2238
PROTECT(s_obj);
23-
PROTECT(s_new_obj = allocSExp(CLOSXP));
24-
SET_FORMALS(s_new_obj, FORMALS(s_obj));
25-
SET_BODY(s_new_obj, BODY(s_obj));
26-
SET_CLOENV(s_new_obj, CLOENV(s_obj));
39+
PROTECT(s_new_obj = R_mkClosure(R_ClosureFormals(s_obj), R_ClosureBody(s_obj), R_ClosureEnv(s_obj)));
2740
SET_OBJECT(s_new_obj, OBJECT(s_obj));
2841
UNPROTECT(2);
2942
s_obj = s_new_obj;

src/r_ext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <limits.h>
1313
#include "R.h"
1414
#include "Rdefines.h"
15+
#include "Rversion.h"
1516
#include "R_ext/Rdynload.h"
1617
#include "R_ext/Parse.h"
1718
#include "R_ext/Print.h"

0 commit comments

Comments
 (0)