Skip to content

Commit

Permalink
resolve SET_FORMALS(), SET_BODY(), SET_CLOENV()
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Sep 1, 2024
1 parent 072539a commit ed1b8f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/rlang/fn.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ r_obj* r_fn_body(r_obj* fn) {
}
static inline
void r_fn_poke_body(r_obj* fn, r_obj* body) {
SET_BODY(fn, body);
RLANG_SET_BODY(fn, body);
}

static inline
Expand All @@ -21,15 +21,15 @@ r_obj* r_fn_env(r_obj* fn) {
}
static inline
void r_fn_poke_env(r_obj* fn, r_obj* env) {
SET_CLOENV(fn, env);
RLANG_SET_CLOENV(fn, env);
}

static inline
r_obj* r_new_function(r_obj* formals, r_obj* body, r_obj* env) {
SEXP fn = Rf_allocSExp(R_TYPE_closure);
SET_FORMALS(fn, formals);
SET_BODY(fn, body);
SET_CLOENV(fn, env);
RLANG_SET_FORMALS(fn, formals);
RLANG_SET_BODY(fn, body);
RLANG_SET_CLOENV(fn, env);
return fn;
}

Expand Down
3 changes: 3 additions & 0 deletions src/rlang/rlang-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,8 @@ struct r_lazy {
#define RLANG_ASSERT(condition) ((void)sizeof(char[1 - 2*!(condition)]))

#define RLANG_SET_ENCLOS(x, v) SETCDR(x, v)
#define RLANG_SET_FORMALS(x, v) SETCAR(x, v)
#define RLANG_SET_BODY(x, v) SETCDR(x, v)
#define RLANG_SET_CLOENV(x, v) SET_TAG(x, v)

#endif

0 comments on commit ed1b8f7

Please sign in to comment.