1 |
1 |
/*
|
2 |
2 |
* R : A Computer Language for Statistical Data Analysis
|
|
3 |
* Copyright (C) 1999--2023 The R Core Team.
|
3 |
4 |
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
|
4 |
|
* Copyright (C) 1999-2016 The R Core Team.
|
5 |
5 |
*
|
6 |
|
* This program is free software; you can redistribute it and/or modify
|
|
6 |
* This header file is free software; you can redistribute it and/or modify
|
7 |
7 |
* it under the terms of the GNU Lesser General Public License as published by
|
8 |
8 |
* the Free Software Foundation; either version 2.1 of the License, or
|
9 |
9 |
* (at your option) any later version.
|
10 |
10 |
*
|
|
11 |
* This file is part of R. R is distributed under the terms of the
|
|
12 |
* GNU General Public License, either Version 2, June 1991 or Version 3,
|
|
13 |
* June 2007. See doc/COPYRIGHTS for details of the copyright status of R.
|
|
14 |
*
|
11 |
15 |
* This program is distributed in the hope that it will be useful,
|
12 |
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
... | ... | |
26 |
30 |
#ifndef R_INTERNALS_H_
|
27 |
31 |
#define R_INTERNALS_H_
|
28 |
32 |
|
29 |
|
// Support for NO_C_HEADERS added in R 3.3.0
|
30 |
33 |
#ifdef __cplusplus
|
31 |
|
# ifndef NO_C_HEADERS
|
32 |
|
# include <cstdio>
|
33 |
|
# include <climits>
|
34 |
|
# include <cstddef>
|
35 |
|
# else
|
36 |
|
#warning "use of NO_C_HEADERS is deprecated"
|
37 |
|
# endif
|
|
34 |
# include <cstdio>
|
|
35 |
# include <climits>
|
|
36 |
# include <cstddef>
|
38 |
37 |
extern "C" {
|
39 |
38 |
#else
|
40 |
|
# ifndef NO_C_HEADERS
|
41 |
|
# include <stdio.h>
|
42 |
|
# include <limits.h> /* for INT_MAX */
|
43 |
|
# include <stddef.h> /* for ptrdiff_t */
|
44 |
|
# else
|
45 |
|
#warning "use of NO_C_HEADERS is deprecated"
|
46 |
|
# endif
|
|
39 |
# include <stdio.h>
|
|
40 |
# include <limits.h> /* for INT_MAX */
|
|
41 |
# include <stddef.h> /* for ptrdiff_t, which is required by C99 */
|
47 |
42 |
#endif
|
48 |
43 |
|
49 |
44 |
#include <R_ext/Arith.h>
|
... | ... | |
53 |
48 |
#include <R_ext/Memory.h>
|
54 |
49 |
#include <R_ext/Utils.h>
|
55 |
50 |
#include <R_ext/Print.h>
|
|
51 |
#include <R_ext/Rdynload.h> // for DL_FUNC
|
56 |
52 |
|
57 |
53 |
#include <R_ext/libextern.h>
|
58 |
54 |
|
... | ... | |
74 |
70 |
|
75 |
71 |
#ifdef LONG_VECTOR_SUPPORT
|
76 |
72 |
typedef ptrdiff_t R_xlen_t;
|
77 |
|
typedef struct { R_xlen_t lv_length, lv_truelength; } R_long_vec_hdr_t;
|
78 |
73 |
# define R_XLEN_T_MAX 4503599627370496
|
79 |
74 |
# define R_SHORT_LEN_MAX 2147483647
|
80 |
|
# define R_LONG_VEC_TOKEN -1
|
81 |
75 |
#else
|
82 |
76 |
typedef int R_xlen_t;
|
83 |
77 |
# define R_XLEN_T_MAX R_LEN_T_MAX
|
... | ... | |
100 |
94 |
*/
|
101 |
95 |
#ifndef enum_SEXPTYPE
|
102 |
96 |
/* NOT YET using enum:
|
103 |
|
* 1) The SEXPREC struct below has 'SEXPTYPE type : 5'
|
|
97 |
* 1) The internal SEXPREC struct has 'SEXPTYPE type : 5'
|
104 |
98 |
* (making FUNSXP and CLOSXP equivalent in there),
|
105 |
99 |
* giving (-Wall only ?) warnings all over the place
|
106 |
100 |
* 2) Many switch(type) { case ... } statements need a final `default:'
|
... | ... | |
183 |
177 |
#define TYPE_BITS 5
|
184 |
178 |
#define MAX_NUM_SEXPTYPE (1<<TYPE_BITS)
|
185 |
179 |
|
186 |
|
// ======================= USE_RINTERNALS section
|
187 |
|
#ifdef USE_RINTERNALS
|
188 |
|
/* This is intended for use only within R itself.
|
189 |
|
* It defines internal structures that are otherwise only accessible
|
190 |
|
* via SEXP, and macros to replace many (but not all) of accessor functions
|
191 |
|
* (which are always defined).
|
192 |
|
*/
|
|
180 |
typedef struct SEXPREC *SEXP;
|
193 |
181 |
|
194 |
|
/* Flags */
|
195 |
182 |
|
|
183 |
/* Define SWITCH_TO_NAMED to use the 'NAMED' mechanism instead of
|
|
184 |
reference counting. */
|
|
185 |
#if ! defined(SWITCH_TO_NAMED) && ! defined(SWITCH_TO_REFCNT)
|
|
186 |
# define SWITCH_TO_REFCNT
|
|
187 |
#endif
|
196 |
188 |
|
197 |
|
struct sxpinfo_struct {
|
198 |
|
SEXPTYPE type : TYPE_BITS;/* ==> (FUNSXP == 99) %% 2^5 == 3 == CLOSXP
|
199 |
|
* -> warning: `type' is narrower than values
|
200 |
|
* of its type
|
201 |
|
* when SEXPTYPE was an enum */
|
202 |
|
unsigned int obj : 1;
|
203 |
|
unsigned int named : 2;
|
204 |
|
unsigned int gp : 16;
|
205 |
|
unsigned int mark : 1;
|
206 |
|
unsigned int debug : 1;
|
207 |
|
unsigned int trace : 1; /* functions and memory tracing */
|
208 |
|
unsigned int spare : 1; /* currently unused */
|
209 |
|
unsigned int gcgen : 1; /* old generation number */
|
210 |
|
unsigned int gccls : 3; /* node class */
|
211 |
|
}; /* Tot: 32 */
|
212 |
|
|
213 |
|
struct vecsxp_struct {
|
214 |
|
R_len_t length;
|
215 |
|
R_len_t truelength;
|
216 |
|
};
|
217 |
|
|
218 |
|
struct primsxp_struct {
|
219 |
|
int offset;
|
220 |
|
};
|
221 |
|
|
222 |
|
struct symsxp_struct {
|
223 |
|
struct SEXPREC *pname;
|
224 |
|
struct SEXPREC *value;
|
225 |
|
struct SEXPREC *internal;
|
226 |
|
};
|
227 |
|
|
228 |
|
struct listsxp_struct {
|
229 |
|
struct SEXPREC *carval;
|
230 |
|
struct SEXPREC *cdrval;
|
231 |
|
struct SEXPREC *tagval;
|
232 |
|
};
|
233 |
|
|
234 |
|
struct envsxp_struct {
|
235 |
|
struct SEXPREC *frame;
|
236 |
|
struct SEXPREC *enclos;
|
237 |
|
struct SEXPREC *hashtab;
|
238 |
|
};
|
239 |
|
|
240 |
|
struct closxp_struct {
|
241 |
|
struct SEXPREC *formals;
|
242 |
|
struct SEXPREC *body;
|
243 |
|
struct SEXPREC *env;
|
244 |
|
};
|
245 |
|
|
246 |
|
struct promsxp_struct {
|
247 |
|
struct SEXPREC *value;
|
248 |
|
struct SEXPREC *expr;
|
249 |
|
struct SEXPREC *env;
|
250 |
|
};
|
251 |
|
|
252 |
|
/* Every node must start with a set of sxpinfo flags and an attribute
|
253 |
|
field. Under the generational collector these are followed by the
|
254 |
|
fields used to maintain the collector's linked list structures. */
|
255 |
|
|
256 |
|
/* Define SWITH_TO_REFCNT to use reference counting instead of the
|
257 |
|
'NAMED' mechanism. This uses the R-devel binary layout. The two
|
258 |
|
'named' field bits are used for the REFCNT, so REFCNTMAX is 3. */
|
259 |
|
//#define SWITCH_TO_REFCNT
|
260 |
|
|
261 |
189 |
#if defined(SWITCH_TO_REFCNT) && ! defined(COMPUTE_REFCNT_VALUES)
|
262 |
190 |
# define COMPUTE_REFCNT_VALUES
|
263 |
191 |
#endif
|
264 |
|
#define REFCNTMAX (4 - 1)
|
265 |
|
|
266 |
|
#define SEXPREC_HEADER \
|
267 |
|
struct sxpinfo_struct sxpinfo; \
|
268 |
|
struct SEXPREC *attrib; \
|
269 |
|
struct SEXPREC *gengc_next_node, *gengc_prev_node
|
270 |
|
|
271 |
|
/* The standard node structure consists of a header followed by the
|
272 |
|
node data. */
|
273 |
|
typedef struct SEXPREC {
|
274 |
|
SEXPREC_HEADER;
|
275 |
|
union {
|
276 |
|
struct primsxp_struct primsxp;
|
277 |
|
struct symsxp_struct symsxp;
|
278 |
|
struct listsxp_struct listsxp;
|
279 |
|
struct envsxp_struct envsxp;
|
280 |
|
struct closxp_struct closxp;
|
281 |
|
struct promsxp_struct promsxp;
|
282 |
|
} u;
|
283 |
|
} SEXPREC, *SEXP;
|
284 |
|
|
285 |
|
/* The generational collector uses a reduced version of SEXPREC as a
|
286 |
|
header in vector nodes. The layout MUST be kept consistent with
|
287 |
|
the SEXPREC definition. The standard SEXPREC takes up 7 words on
|
288 |
|
most hardware; this reduced version should take up only 6 words.
|
289 |
|
In addition to slightly reducing memory use, this can lead to more
|
290 |
|
favorable data alignment on 32-bit architectures like the Intel
|
291 |
|
Pentium III where odd word alignment of doubles is allowed but much
|
292 |
|
less efficient than even word alignment. */
|
293 |
|
typedef struct VECTOR_SEXPREC {
|
294 |
|
SEXPREC_HEADER;
|
295 |
|
struct vecsxp_struct vecsxp;
|
296 |
|
} VECTOR_SEXPREC, *VECSEXP;
|
297 |
|
|
298 |
|
typedef union { VECTOR_SEXPREC s; double align; } SEXPREC_ALIGN;
|
299 |
|
|
300 |
|
/* General Cons Cell Attributes */
|
301 |
|
#define ATTRIB(x) ((x)->attrib)
|
302 |
|
#define OBJECT(x) ((x)->sxpinfo.obj)
|
303 |
|
#define MARK(x) ((x)->sxpinfo.mark)
|
304 |
|
#define TYPEOF(x) ((x)->sxpinfo.type)
|
305 |
|
#define NAMED(x) ((x)->sxpinfo.named)
|
306 |
|
#define RTRACE(x) ((x)->sxpinfo.trace)
|
307 |
|
#define LEVELS(x) ((x)->sxpinfo.gp)
|
308 |
|
#define SET_OBJECT(x,v) (((x)->sxpinfo.obj)=(v))
|
309 |
|
#define SET_TYPEOF(x,v) (((x)->sxpinfo.type)=(v))
|
310 |
|
#define SET_NAMED(x,v) (((x)->sxpinfo.named)=(v))
|
311 |
|
#define SET_RTRACE(x,v) (((x)->sxpinfo.trace)=(v))
|
312 |
|
#define SETLEVELS(x,v) (((x)->sxpinfo.gp)=((unsigned short)v))
|
313 |
|
|
314 |
|
#if defined(COMPUTE_REFCNT_VALUES)
|
315 |
|
# define REFCNT(x) ((x)->sxpinfo.named)
|
316 |
|
# define TRACKREFS(x) (TYPEOF(x) == CLOSXP ? TRUE : ! (x)->sxpinfo.spare)
|
317 |
|
#else
|
318 |
|
# define REFCNT(x) 0
|
319 |
|
# define TRACKREFS(x) FALSE
|
|
192 |
#if defined(SWITCH_TO_REFCNT) && ! defined(ADJUST_ENVIR_REFCNTS)
|
|
193 |
# define ADJUST_ENVIR_REFCNTS
|
320 |
194 |
#endif
|
321 |
195 |
|
322 |
|
#ifdef SWITCH_TO_REFCNT
|
323 |
|
# undef NAMED
|
324 |
|
# undef SET_NAMED
|
325 |
|
# define NAMED(x) REFCNT(x)
|
326 |
|
# define SET_NAMED(x, v) do {} while (0)
|
327 |
|
#endif
|
328 |
196 |
|
329 |
|
/* S4 object bit, set by R_do_new_object for all new() calls */
|
330 |
|
#define S4_OBJECT_MASK ((unsigned short)(1<<4))
|
331 |
|
#define IS_S4_OBJECT(x) ((x)->sxpinfo.gp & S4_OBJECT_MASK)
|
332 |
|
#define SET_S4_OBJECT(x) (((x)->sxpinfo.gp) |= S4_OBJECT_MASK)
|
333 |
|
#define UNSET_S4_OBJECT(x) (((x)->sxpinfo.gp) &= ~S4_OBJECT_MASK)
|
334 |
|
|
335 |
|
/* Vector Access Macros */
|
336 |
|
#ifdef LONG_VECTOR_SUPPORT
|
337 |
|
R_len_t NORET R_BadLongVector(SEXP, const char *, int);
|
338 |
|
# define IS_LONG_VEC(x) (SHORT_VEC_LENGTH(x) == R_LONG_VEC_TOKEN)
|
339 |
|
# define SHORT_VEC_LENGTH(x) (((VECSEXP) (x))->vecsxp.length)
|
340 |
|
# define SHORT_VEC_TRUELENGTH(x) (((VECSEXP) (x))->vecsxp.truelength)
|
341 |
|
# define LONG_VEC_LENGTH(x) ((R_long_vec_hdr_t *) (x))[-1].lv_length
|
342 |
|
# define LONG_VEC_TRUELENGTH(x) ((R_long_vec_hdr_t *) (x))[-1].lv_truelength
|
343 |
|
# define XLENGTH(x) (IS_LONG_VEC(x) ? LONG_VEC_LENGTH(x) : SHORT_VEC_LENGTH(x))
|
344 |
|
# define XTRUELENGTH(x) (IS_LONG_VEC(x) ? LONG_VEC_TRUELENGTH(x) : SHORT_VEC_TRUELENGTH(x))
|
345 |
|
# define LENGTH(x) (IS_LONG_VEC(x) ? R_BadLongVector(x, __FILE__, __LINE__) : SHORT_VEC_LENGTH(x))
|
346 |
|
# define TRUELENGTH(x) (IS_LONG_VEC(x) ? R_BadLongVector(x, __FILE__, __LINE__) : SHORT_VEC_TRUELENGTH(x))
|
347 |
|
# define SET_SHORT_VEC_LENGTH(x,v) (SHORT_VEC_LENGTH(x) = (v))
|
348 |
|
# define SET_SHORT_VEC_TRUELENGTH(x,v) (SHORT_VEC_TRUELENGTH(x) = (v))
|
349 |
|
# define SET_LONG_VEC_LENGTH(x,v) (LONG_VEC_LENGTH(x) = (v))
|
350 |
|
# define SET_LONG_VEC_TRUELENGTH(x,v) (LONG_VEC_TRUELENGTH(x) = (v))
|
351 |
|
# define SETLENGTH(x,v) do { \
|
352 |
|
SEXP sl__x__ = (x); \
|
353 |
|
R_xlen_t sl__v__ = (v); \
|
354 |
|
if (IS_LONG_VEC(sl__x__)) \
|
355 |
|
SET_LONG_VEC_LENGTH(sl__x__, sl__v__); \
|
356 |
|
else SET_SHORT_VEC_LENGTH(sl__x__, (R_len_t) sl__v__); \
|
357 |
|
} while (0)
|
358 |
|
# define SET_TRUELENGTH(x,v) do { \
|
359 |
|
SEXP sl__x__ = (x); \
|
360 |
|
R_xlen_t sl__v__ = (v); \
|
361 |
|
if (IS_LONG_VEC(sl__x__)) \
|
362 |
|
SET_LONG_VEC_TRUELENGTH(sl__x__, sl__v__); \
|
363 |
|
else SET_SHORT_VEC_TRUELENGTH(sl__x__, (R_len_t) sl__v__); \
|
364 |
|
} while (0)
|
365 |
|
# define IS_SCALAR(x, type) (TYPEOF(x) == (type) && SHORT_VEC_LENGTH(x) == 1)
|
366 |
|
#else
|
367 |
|
# define SHORT_VEC_LENGTH(x) (((VECSEXP) (x))->vecsxp.length)
|
368 |
|
# define LENGTH(x) (((VECSEXP) (x))->vecsxp.length)
|
369 |
|
# define TRUELENGTH(x) (((VECSEXP) (x))->vecsxp.truelength)
|
370 |
|
# define XLENGTH(x) LENGTH(x)
|
371 |
|
# define XTRUELENGTH(x) TRUELENGTH(x)
|
372 |
|
# define SETLENGTH(x,v) ((((VECSEXP) (x))->vecsxp.length)=(v))
|
373 |
|
# define SET_TRUELENGTH(x,v) ((((VECSEXP) (x))->vecsxp.truelength)=(v))
|
374 |
|
# define SET_SHORT_VEC_LENGTH SETLENGTH
|
375 |
|
# define SET_SHORT_VEC_TRUELENGTH SET_TRUELENGTH
|
376 |
|
# define IS_LONG_VEC(x) 0
|
377 |
|
# define IS_SCALAR(x, type) (TYPEOF(x) == (type) && LENGTH(x) == 1)
|
378 |
|
#endif
|
379 |
|
|
380 |
|
/* Under the generational allocator the data for vector nodes comes
|
381 |
|
immediately after the node structure, so the data address is a
|
382 |
|
known offset from the node SEXP. */
|
383 |
|
#define DATAPTR(x) (((SEXPREC_ALIGN *) (x)) + 1)
|
384 |
|
#define CHAR(x) ((const char *) DATAPTR(x))
|
385 |
|
#define LOGICAL(x) ((int *) DATAPTR(x))
|
386 |
|
#define INTEGER(x) ((int *) DATAPTR(x))
|
387 |
|
#define RAW(x) ((Rbyte *) DATAPTR(x))
|
388 |
|
#define COMPLEX(x) ((Rcomplex *) DATAPTR(x))
|
389 |
|
#define REAL(x) ((double *) DATAPTR(x))
|
390 |
|
#define STRING_ELT(x,i) ((SEXP *) DATAPTR(x))[i]
|
391 |
|
#define VECTOR_ELT(x,i) ((SEXP *) DATAPTR(x))[i]
|
392 |
|
#define STRING_PTR(x) ((SEXP *) DATAPTR(x))
|
393 |
|
#define VECTOR_PTR(x) ((SEXP *) DATAPTR(x))
|
394 |
|
|
395 |
|
/* List Access Macros */
|
396 |
|
/* These also work for ... objects */
|
397 |
|
#define LISTVAL(x) ((x)->u.listsxp)
|
398 |
|
#define TAG(e) ((e)->u.listsxp.tagval)
|
399 |
|
#define CAR(e) ((e)->u.listsxp.carval)
|
400 |
|
#define CDR(e) ((e)->u.listsxp.cdrval)
|
401 |
|
#define CAAR(e) CAR(CAR(e))
|
402 |
|
#define CDAR(e) CDR(CAR(e))
|
403 |
|
#define CADR(e) CAR(CDR(e))
|
404 |
|
#define CDDR(e) CDR(CDR(e))
|
405 |
|
#define CDDDR(e) CDR(CDR(CDR(e)))
|
406 |
|
#define CADDR(e) CAR(CDR(CDR(e)))
|
407 |
|
#define CADDDR(e) CAR(CDR(CDR(CDR(e))))
|
408 |
|
#define CAD4R(e) CAR(CDR(CDR(CDR(CDR(e)))))
|
409 |
|
#define MISSING_MASK 15 /* reserve 4 bits--only 2 uses now */
|
410 |
|
#define MISSING(x) ((x)->sxpinfo.gp & MISSING_MASK)/* for closure calls */
|
411 |
|
#define SET_MISSING(x,v) do { \
|
412 |
|
SEXP __x__ = (x); \
|
413 |
|
int __v__ = (v); \
|
414 |
|
int __other_flags__ = __x__->sxpinfo.gp & ~MISSING_MASK; \
|
415 |
|
__x__->sxpinfo.gp = __other_flags__ | __v__; \
|
416 |
|
} while (0)
|
417 |
|
|
418 |
|
/* Closure Access Macros */
|
419 |
|
#define FORMALS(x) ((x)->u.closxp.formals)
|
420 |
|
#define BODY(x) ((x)->u.closxp.body)
|
421 |
|
#define CLOENV(x) ((x)->u.closxp.env)
|
422 |
|
#define RDEBUG(x) ((x)->sxpinfo.debug)
|
423 |
|
#define SET_RDEBUG(x,v) (((x)->sxpinfo.debug)=(v))
|
424 |
|
#define RSTEP(x) ((x)->sxpinfo.spare)
|
425 |
|
#define SET_RSTEP(x,v) (((x)->sxpinfo.spare)=(v))
|
426 |
|
|
427 |
|
/* Symbol Access Macros */
|
428 |
|
#define PRINTNAME(x) ((x)->u.symsxp.pname)
|
429 |
|
#define SYMVALUE(x) ((x)->u.symsxp.value)
|
430 |
|
#define INTERNAL(x) ((x)->u.symsxp.internal)
|
431 |
|
#define DDVAL_MASK 1
|
432 |
|
#define DDVAL(x) ((x)->sxpinfo.gp & DDVAL_MASK) /* for ..1, ..2 etc */
|
433 |
|
#define SET_DDVAL_BIT(x) (((x)->sxpinfo.gp) |= DDVAL_MASK)
|
434 |
|
#define UNSET_DDVAL_BIT(x) (((x)->sxpinfo.gp) &= ~DDVAL_MASK)
|
435 |
|
#define SET_DDVAL(x,v) ((v) ? SET_DDVAL_BIT(x) : UNSET_DDVAL_BIT(x)) /* for ..1, ..2 etc */
|
436 |
|
|
437 |
|
/* Environment Access Macros */
|
438 |
|
#define FRAME(x) ((x)->u.envsxp.frame)
|
439 |
|
#define ENCLOS(x) ((x)->u.envsxp.enclos)
|
440 |
|
#define HASHTAB(x) ((x)->u.envsxp.hashtab)
|
441 |
|
#define ENVFLAGS(x) ((x)->sxpinfo.gp) /* for environments */
|
442 |
|
#define SET_ENVFLAGS(x,v) (((x)->sxpinfo.gp)=(v))
|
443 |
|
|
444 |
|
#else /* not USE_RINTERNALS */
|
445 |
|
// ======================= not USE_RINTERNALS section
|
446 |
|
|
447 |
|
typedef struct SEXPREC *SEXP;
|
448 |
|
|
449 |
|
#define CHAR(x) R_CHAR(x)
|
|
197 |
#define CHAR(x) R_CHAR(x)
|
450 |
198 |
const char *(R_CHAR)(SEXP x);
|
451 |
199 |
|
452 |
|
/* Various tests with macro versions in the second USE_RINTERNALS section */
|
|
200 |
/* Various tests with macro versions in the internal headers */
|
453 |
201 |
Rboolean (Rf_isNull)(SEXP s);
|
454 |
202 |
Rboolean (Rf_isSymbol)(SEXP s);
|
455 |
203 |
Rboolean (Rf_isLogical)(SEXP s);
|
... | ... | |
460 |
208 |
Rboolean (Rf_isString)(SEXP s);
|
461 |
209 |
Rboolean (Rf_isObject)(SEXP s);
|
462 |
210 |
|
463 |
|
# define IS_SCALAR(x, type) (TYPEOF(x) == (type) && XLENGTH(x) == 1)
|
464 |
|
#endif /* USE_RINTERNALS */
|
465 |
|
|
466 |
211 |
#define IS_SIMPLE_SCALAR(x, type) \
|
467 |
212 |
(IS_SCALAR(x, type) && ATTRIB(x) == R_NilValue)
|
468 |
213 |
|
469 |
|
#define NAMEDMAX 2
|
470 |
|
#define INCREMENT_NAMED(x) do { \
|
|
214 |
#define NAMEDMAX 7
|
|
215 |
#ifdef SWITCH_TO_REFCNT
|
|
216 |
# define INCREMENT_NAMED(x) do { } while (0)
|
|
217 |
# define DECREMENT_NAMED(x) do { } while (0)
|
|
218 |
#else
|
|
219 |
# define INCREMENT_NAMED(x) do { \
|
471 |
220 |
SEXP __x__ = (x); \
|
472 |
221 |
if (NAMED(__x__) != NAMEDMAX) \
|
473 |
222 |
SET_NAMED(__x__, NAMED(__x__) + 1); \
|
474 |
223 |
} while (0)
|
475 |
|
|
476 |
|
#if defined(COMPUTE_REFCNT_VALUES)
|
477 |
|
# define SET_REFCNT(x,v) (REFCNT(x) = (v))
|
478 |
|
# if defined(EXTRA_REFCNT_FIELDS)
|
479 |
|
# define SET_TRACKREFS(x,v) (TRACKREFS(x) = (v))
|
480 |
|
# else
|
481 |
|
# define SET_TRACKREFS(x,v) ((x)->sxpinfo.spare = ! (v))
|
482 |
|
# endif
|
483 |
|
# define DECREMENT_REFCNT(x) do { \
|
484 |
|
SEXP drc__x__ = (x); \
|
485 |
|
if (REFCNT(drc__x__) > 0 && REFCNT(drc__x__) < REFCNTMAX) \
|
486 |
|
SET_REFCNT(drc__x__, REFCNT(drc__x__) - 1); \
|
|
224 |
# define DECREMENT_NAMED(x) do { \
|
|
225 |
SEXP __x__ = (x); \
|
|
226 |
int __n__ = NAMED(__x__); \
|
|
227 |
if (__n__ > 0 && __n__ < NAMEDMAX) \
|
|
228 |
SET_NAMED(__x__, __n__ - 1); \
|
487 |
229 |
} while (0)
|
488 |
|
# define INCREMENT_REFCNT(x) do { \
|
489 |
|
SEXP irc__x__ = (x); \
|
490 |
|
if (REFCNT(irc__x__) < REFCNTMAX) \
|
491 |
|
SET_REFCNT(irc__x__, REFCNT(irc__x__) + 1); \
|
492 |
|
} while (0)
|
493 |
|
#else
|
494 |
|
# define SET_REFCNT(x,v) do {} while(0)
|
495 |
|
# define SET_TRACKREFS(x,v) do {} while(0)
|
496 |
|
# define DECREMENT_REFCNT(x) do {} while(0)
|
497 |
|
# define INCREMENT_REFCNT(x) do {} while(0)
|
498 |
230 |
#endif
|
499 |
231 |
|
500 |
|
#define ENABLE_REFCNT(x) SET_TRACKREFS(x, TRUE)
|
501 |
|
#define DISABLE_REFCNT(x) SET_TRACKREFS(x, FALSE)
|
502 |
|
|
503 |
232 |
/* Macros for some common idioms. */
|
504 |
233 |
#ifdef SWITCH_TO_REFCNT
|
505 |
234 |
# define MAYBE_SHARED(x) (REFCNT(x) > 1)
|
506 |
235 |
# define NO_REFERENCES(x) (REFCNT(x) == 0)
|
507 |
|
# define MARK_NOT_MUTABLE(x) SET_REFCNT(x, REFCNTMAX)
|
508 |
236 |
#else
|
509 |
237 |
# define MAYBE_SHARED(x) (NAMED(x) > 1)
|
510 |
238 |
# define NO_REFERENCES(x) (NAMED(x) == 0)
|
511 |
|
# define MARK_NOT_MUTABLE(x) SET_NAMED(x, NAMEDMAX)
|
512 |
239 |
#endif
|
513 |
240 |
#define MAYBE_REFERENCED(x) (! NO_REFERENCES(x))
|
514 |
241 |
#define NOT_SHARED(x) (! MAYBE_SHARED(x))
|
515 |
242 |
|
516 |
|
/* Complex assignment support */
|
517 |
|
/* temporary definition that will need to be refined to distinguish
|
518 |
|
getter from setter calls */
|
519 |
|
#define IS_GETTER_CALL(call) (CADR(call) == R_TmpvalSymbol)
|
520 |
|
|
521 |
243 |
/* Accessor functions. Many are declared using () to avoid the macro
|
522 |
|
definitions in the USE_RINTERNALS section.
|
|
244 |
definitions in the internal headers.
|
523 |
245 |
The function STRING_ELT is used as an argument to arrayAssign even
|
524 |
246 |
if the macro version is in use.
|
525 |
247 |
*/
|
... | ... | |
531 |
253 |
int (TYPEOF)(SEXP x);
|
532 |
254 |
int (NAMED)(SEXP x);
|
533 |
255 |
int (REFCNT)(SEXP x);
|
534 |
|
void (SET_OBJECT)(SEXP x, int v);
|
535 |
|
void (SET_TYPEOF)(SEXP x, int v);
|
536 |
|
void (SET_NAMED)(SEXP x, int v);
|
537 |
256 |
void SET_ATTRIB(SEXP x, SEXP v);
|
538 |
257 |
void DUPLICATE_ATTRIB(SEXP to, SEXP from);
|
539 |
258 |
void SHALLOW_DUPLICATE_ATTRIB(SEXP to, SEXP from);
|
|
259 |
void (MARK_NOT_MUTABLE)(SEXP x);
|
540 |
260 |
|
541 |
261 |
/* S4 object testing */
|
542 |
262 |
int (IS_S4_OBJECT)(SEXP x);
|
543 |
|
void (SET_S4_OBJECT)(SEXP x);
|
544 |
|
void (UNSET_S4_OBJECT)(SEXP x);
|
545 |
263 |
|
546 |
264 |
/* Vector Access Functions */
|
547 |
265 |
int (LENGTH)(SEXP x);
|
548 |
|
int (TRUELENGTH)(SEXP x);
|
549 |
|
void (SETLENGTH)(SEXP x, int v);
|
550 |
|
void (SET_TRUELENGTH)(SEXP x, int v);
|
551 |
|
R_xlen_t (XLENGTH)(SEXP x);
|
552 |
|
R_xlen_t (XTRUELENGTH)(SEXP x);
|
|
266 |
R_xlen_t (XLENGTH)(SEXP x);
|
|
267 |
R_xlen_t (TRUELENGTH)(SEXP x);
|
553 |
268 |
int (IS_LONG_VEC)(SEXP x);
|
554 |
269 |
int (LEVELS)(SEXP x);
|
555 |
|
int (SETLEVELS)(SEXP x, int v);
|
556 |
270 |
|
557 |
271 |
int *(LOGICAL)(SEXP x);
|
558 |
272 |
int *(INTEGER)(SEXP x);
|
559 |
273 |
Rbyte *(RAW)(SEXP x);
|
560 |
274 |
double *(REAL)(SEXP x);
|
561 |
275 |
Rcomplex *(COMPLEX)(SEXP x);
|
562 |
|
SEXP (STRING_ELT)(SEXP x, R_xlen_t i);
|
|
276 |
const int *(LOGICAL_RO)(SEXP x);
|
|
277 |
const int *(INTEGER_RO)(SEXP x);
|
|
278 |
const Rbyte *(RAW_RO)(SEXP x);
|
|
279 |
const double *(REAL_RO)(SEXP x);
|
|
280 |
const Rcomplex *(COMPLEX_RO)(SEXP x);
|
|
281 |
//SEXP (STRING_ELT)(SEXP x, R_xlen_t i);
|
563 |
282 |
SEXP (VECTOR_ELT)(SEXP x, R_xlen_t i);
|
564 |
283 |
void SET_STRING_ELT(SEXP x, R_xlen_t i, SEXP v);
|
565 |
284 |
SEXP SET_VECTOR_ELT(SEXP x, R_xlen_t i, SEXP v);
|
566 |
285 |
SEXP *(STRING_PTR)(SEXP x);
|
567 |
|
SEXP * NORET (VECTOR_PTR)(SEXP x);
|
|
286 |
const SEXP *(STRING_PTR_RO)(SEXP x);
|
|
287 |
NORET SEXP * (VECTOR_PTR)(SEXP x);
|
568 |
288 |
|
|
289 |
R_xlen_t INTEGER_GET_REGION(SEXP sx, R_xlen_t i, R_xlen_t n, int *buf);
|
|
290 |
R_xlen_t REAL_GET_REGION(SEXP sx, R_xlen_t i, R_xlen_t n, double *buf);
|
|
291 |
R_xlen_t LOGICAL_GET_REGION(SEXP sx, R_xlen_t i, R_xlen_t n, int *buf);
|
|
292 |
R_xlen_t COMPLEX_GET_REGION(SEXP sx, R_xlen_t i, R_xlen_t n, Rcomplex *buf);
|
|
293 |
R_xlen_t RAW_GET_REGION(SEXP sx, R_xlen_t i, R_xlen_t n, Rbyte *buf);
|
|
294 |
|
|
295 |
/* metadata access */
|
|
296 |
int INTEGER_IS_SORTED(SEXP x);
|
|
297 |
int INTEGER_NO_NA(SEXP x);
|
|
298 |
int REAL_IS_SORTED(SEXP x);
|
|
299 |
int REAL_NO_NA(SEXP x);
|
|
300 |
int LOGICAL_IS_SORTED(SEXP x);
|
|
301 |
int LOGICAL_NO_NA(SEXP x);
|
|
302 |
int STRING_IS_SORTED(SEXP x);
|
|
303 |
int STRING_NO_NA(SEXP x);
|
|
304 |
|
569 |
305 |
/* List Access Functions */
|
570 |
306 |
/* These also work for ... objects */
|
571 |
307 |
#define CONS(a, b) cons((a), (b)) /* data lists */
|
572 |
308 |
#define LCONS(a, b) lcons((a), (b)) /* language lists */
|
|
309 |
|
573 |
310 |
SEXP (TAG)(SEXP e);
|
574 |
|
SEXP (CAR)(SEXP e);
|
575 |
311 |
SEXP (CDR)(SEXP e);
|
576 |
312 |
SEXP (CAAR)(SEXP e);
|
577 |
313 |
SEXP (CDAR)(SEXP e);
|
... | ... | |
581 |
317 |
SEXP (CADDR)(SEXP e);
|
582 |
318 |
SEXP (CADDDR)(SEXP e);
|
583 |
319 |
SEXP (CAD4R)(SEXP e);
|
|
320 |
SEXP (CAD5R)(SEXP e);
|
584 |
321 |
int (MISSING)(SEXP x);
|
585 |
|
void (SET_MISSING)(SEXP x, int v);
|
586 |
322 |
void SET_TAG(SEXP x, SEXP y);
|
587 |
323 |
SEXP SETCAR(SEXP x, SEXP y);
|
588 |
324 |
SEXP SETCDR(SEXP x, SEXP y);
|
... | ... | |
591 |
327 |
SEXP SETCADDDR(SEXP x, SEXP y);
|
592 |
328 |
SEXP SETCAD4R(SEXP e, SEXP y);
|
593 |
329 |
|
594 |
|
SEXP CONS_NR(SEXP a, SEXP b);
|
595 |
|
|
596 |
330 |
/* Closure Access Functions */
|
597 |
331 |
SEXP (FORMALS)(SEXP x);
|
598 |
332 |
SEXP (BODY)(SEXP x);
|
... | ... | |
612 |
346 |
SEXP (SYMVALUE)(SEXP x);
|
613 |
347 |
SEXP (INTERNAL)(SEXP x);
|
614 |
348 |
int (DDVAL)(SEXP x);
|
615 |
|
void (SET_DDVAL)(SEXP x, int v);
|
616 |
|
void SET_PRINTNAME(SEXP x, SEXP v);
|
617 |
|
void SET_SYMVALUE(SEXP x, SEXP v);
|
618 |
|
void SET_INTERNAL(SEXP x, SEXP v);
|
619 |
349 |
|
620 |
350 |
/* Environment Access Functions */
|
621 |
351 |
SEXP (FRAME)(SEXP x);
|
622 |
352 |
SEXP (ENCLOS)(SEXP x);
|
623 |
353 |
SEXP (HASHTAB)(SEXP x);
|
624 |
354 |
int (ENVFLAGS)(SEXP x);
|
625 |
|
void (SET_ENVFLAGS)(SEXP x, int v);
|
626 |
|
void SET_FRAME(SEXP x, SEXP v);
|
627 |
|
void SET_ENCLOS(SEXP x, SEXP v);
|
628 |
|
void SET_HASHTAB(SEXP x, SEXP v);
|
629 |
355 |
|
630 |
356 |
/* Promise Access Functions */
|
631 |
|
/* First five have macro versions in Defn.h */
|
632 |
357 |
SEXP (PRCODE)(SEXP x);
|
633 |
358 |
SEXP (PRENV)(SEXP x);
|
634 |
359 |
SEXP (PRVALUE)(SEXP x);
|
635 |
360 |
int (PRSEEN)(SEXP x);
|
636 |
|
void (SET_PRSEEN)(SEXP x, int v);
|
637 |
|
void SET_PRENV(SEXP x, SEXP v);
|
638 |
|
void SET_PRVALUE(SEXP x, SEXP v);
|
639 |
|
void SET_PRCODE(SEXP x, SEXP v);
|
640 |
|
void SET_PRSEEN(SEXP x, int v);
|
641 |
361 |
|
642 |
|
/* Hashing Functions */
|
643 |
|
/* There are macro versions in Defn.h */
|
644 |
|
int (HASHASH)(SEXP x);
|
645 |
|
int (HASHVALUE)(SEXP x);
|
646 |
|
void (SET_HASHASH)(SEXP x, int v);
|
647 |
|
void (SET_HASHVALUE)(SEXP x, int v);
|
648 |
|
|
649 |
|
|
650 |
362 |
/* External pointer access macros */
|
651 |
|
#define EXTPTR_PTR(x) CAR(x)
|
652 |
|
#define EXTPTR_PROT(x) CDR(x)
|
653 |
|
#define EXTPTR_TAG(x) TAG(x)
|
|
363 |
SEXP (EXTPTR_PROT)(SEXP);
|
|
364 |
SEXP (EXTPTR_TAG)(SEXP);
|
|
365 |
void *(EXTPTR_PTR)(SEXP);
|
654 |
366 |
|
655 |
|
/* Bytecode access macros */
|
656 |
|
#define BCODE_CODE(x) CAR(x)
|
657 |
|
#define BCODE_CONSTS(x) CDR(x)
|
658 |
|
#define BCODE_EXPR(x) TAG(x)
|
659 |
|
#define isByteCode(x) (TYPEOF(x)==BCODESXP)
|
660 |
|
|
661 |
367 |
/* Pointer Protection and Unprotection */
|
662 |
368 |
#define PROTECT(s) Rf_protect(s)
|
663 |
369 |
#define UNPROTECT(n) Rf_unprotect(n)
|
... | ... | |
686 |
392 |
LibExtern SEXP R_NilValue; /* The nil object */
|
687 |
393 |
LibExtern SEXP R_UnboundValue; /* Unbound marker */
|
688 |
394 |
LibExtern SEXP R_MissingArg; /* Missing argument marker */
|
|
395 |
LibExtern SEXP R_InBCInterpreter; /* To be found in BC interp. state
|
|
396 |
(marker) */
|
|
397 |
LibExtern SEXP R_CurrentExpression; /* Use current expression (marker) */
|
689 |
398 |
#ifdef __MAIN__
|
690 |
399 |
attribute_hidden
|
691 |
400 |
#else
|
... | ... | |
694 |
403 |
SEXP R_RestartToken; /* Marker for restarted function calls */
|
695 |
404 |
|
696 |
405 |
/* Symbol Table Shortcuts */
|
|
406 |
LibExtern SEXP R_AsCharacterSymbol;/* "as.character" */
|
|
407 |
LibExtern SEXP R_AtsignSymbol; /* "@" */
|
697 |
408 |
LibExtern SEXP R_baseSymbol; // <-- backcompatible version of:
|
698 |
409 |
LibExtern SEXP R_BaseSymbol; // "base"
|
699 |
410 |
LibExtern SEXP R_BraceSymbol; /* "{" */
|
... | ... | |
707 |
418 |
LibExtern SEXP R_DotsSymbol; /* "..." */
|
708 |
419 |
LibExtern SEXP R_DoubleColonSymbol;// "::"
|
709 |
420 |
LibExtern SEXP R_DropSymbol; /* "drop" */
|
|
421 |
LibExtern SEXP R_EvalSymbol; /* "eval" */
|
|
422 |
LibExtern SEXP R_FunctionSymbol; /* "function" */
|
710 |
423 |
LibExtern SEXP R_LastvalueSymbol; /* ".Last.value" */
|
711 |
424 |
LibExtern SEXP R_LevelsSymbol; /* "levels" */
|
712 |
425 |
LibExtern SEXP R_ModeSymbol; /* "mode" */
|
... | ... | |
735 |
448 |
#define NA_STRING R_NaString
|
736 |
449 |
LibExtern SEXP R_NaString; /* NA_STRING as a CHARSXP */
|
737 |
450 |
LibExtern SEXP R_BlankString; /* "" as a CHARSXP */
|
738 |
|
LibExtern SEXP R_BlankScalarString; /* "" as a STRSXP */
|
|
451 |
LibExtern SEXP R_BlankScalarString;/* "" as a STRSXP */
|
739 |
452 |
|
740 |
453 |
/* srcref related functions */
|
741 |
454 |
SEXP R_GetCurrentSrcref(int);
|
... | ... | |
761 |
474 |
typedef struct R_allocator R_allocator_t;
|
762 |
475 |
#endif
|
763 |
476 |
|
|
477 |
|
764 |
478 |
/* Other Internally Used Functions, excluding those which are inline-able*/
|
765 |
479 |
|
766 |
480 |
char * Rf_acopy_string(const char *);
|
767 |
|
void Rf_addMissingVarsToNewEnv(SEXP, SEXP);
|
768 |
481 |
SEXP Rf_alloc3DArray(SEXPTYPE, int, int, int);
|
769 |
482 |
SEXP Rf_allocArray(SEXPTYPE, SEXP);
|
770 |
|
SEXP Rf_allocFormalsList2(SEXP sym1, SEXP sym2);
|
771 |
|
SEXP Rf_allocFormalsList3(SEXP sym1, SEXP sym2, SEXP sym3);
|
772 |
|
SEXP Rf_allocFormalsList4(SEXP sym1, SEXP sym2, SEXP sym3, SEXP sym4);
|
773 |
|
SEXP Rf_allocFormalsList5(SEXP sym1, SEXP sym2, SEXP sym3, SEXP sym4, SEXP sym5);
|
774 |
|
SEXP Rf_allocFormalsList6(SEXP sym1, SEXP sym2, SEXP sym3, SEXP sym4, SEXP sym5, SEXP sym6);
|
775 |
483 |
SEXP Rf_allocMatrix(SEXPTYPE, int, int);
|
776 |
484 |
SEXP Rf_allocList(int);
|
777 |
485 |
SEXP Rf_allocS4Object(void);
|
... | ... | |
780 |
488 |
R_xlen_t Rf_any_duplicated(SEXP x, Rboolean from_last);
|
781 |
489 |
R_xlen_t Rf_any_duplicated3(SEXP x, SEXP incomp, Rboolean from_last);
|
782 |
490 |
SEXP Rf_applyClosure(SEXP, SEXP, SEXP, SEXP, SEXP);
|
783 |
|
SEXP Rf_arraySubscript(int, SEXP, SEXP, SEXP (*)(SEXP,SEXP),
|
784 |
|
SEXP (*)(SEXP, int), SEXP);
|
785 |
491 |
SEXP Rf_classgets(SEXP, SEXP);
|
786 |
492 |
SEXP Rf_cons(SEXP, SEXP);
|
787 |
493 |
void Rf_copyMatrix(SEXP, SEXP, Rboolean);
|
788 |
494 |
void Rf_copyListMatrix(SEXP, SEXP, Rboolean);
|
789 |
495 |
void Rf_copyMostAttrib(SEXP, SEXP);
|
790 |
496 |
void Rf_copyVector(SEXP, SEXP);
|
791 |
|
int Rf_countContexts(int, int);
|
792 |
|
SEXP Rf_CreateTag(SEXP);
|
793 |
497 |
void Rf_defineVar(SEXP, SEXP, SEXP);
|
794 |
498 |
SEXP Rf_dimgets(SEXP, SEXP);
|
795 |
499 |
SEXP Rf_dimnamesgets(SEXP, SEXP);
|
796 |
|
SEXP Rf_DropDims(SEXP);
|
797 |
500 |
SEXP Rf_duplicate(SEXP);
|
798 |
501 |
SEXP Rf_shallow_duplicate(SEXP);
|
|
502 |
SEXP R_duplicate_attr(SEXP);
|
|
503 |
SEXP R_shallow_duplicate_attr(SEXP);
|
799 |
504 |
SEXP Rf_lazy_duplicate(SEXP);
|
800 |
505 |
/* the next really should not be here and is also in Defn.h */
|
801 |
506 |
SEXP Rf_duplicated(SEXP, Rboolean);
|
802 |
|
Rboolean R_envHasNoSpecialSymbols(SEXP);
|
803 |
507 |
SEXP Rf_eval(SEXP, SEXP);
|
804 |
508 |
SEXP Rf_findFun(SEXP, SEXP);
|
805 |
509 |
SEXP Rf_findVar(SEXP, SEXP);
|
806 |
510 |
SEXP Rf_findVarInFrame(SEXP, SEXP);
|
807 |
511 |
SEXP Rf_findVarInFrame3(SEXP, SEXP, Rboolean);
|
|
512 |
Rboolean R_existsVarInFrame(SEXP, SEXP);
|
|
513 |
void R_removeVarFromFrame(SEXP, SEXP);
|
808 |
514 |
SEXP Rf_getAttrib(SEXP, SEXP);
|
809 |
515 |
SEXP Rf_GetArrayDimnames(SEXP);
|
810 |
516 |
SEXP Rf_GetColNames(SEXP);
|
... | ... | |
817 |
523 |
void Rf_gsetVar(SEXP, SEXP, SEXP);
|
818 |
524 |
SEXP Rf_install(const char *);
|
819 |
525 |
SEXP Rf_installChar(SEXP);
|
820 |
|
SEXP Rf_installDDVAL(int i);
|
821 |
|
SEXP Rf_installS3Signature(const char *, const char *);
|
822 |
|
Rboolean Rf_isFree(SEXP);
|
|
526 |
SEXP Rf_installNoTrChar(SEXP);
|
|
527 |
SEXP Rf_installTrChar(SEXP);
|
823 |
528 |
Rboolean Rf_isOrdered(SEXP);
|
824 |
|
Rboolean Rf_isUnmodifiedSpecSym(SEXP sym, SEXP env);
|
825 |
529 |
Rboolean Rf_isUnordered(SEXP);
|
826 |
530 |
Rboolean Rf_isUnsorted(SEXP, Rboolean);
|
827 |
531 |
SEXP Rf_lengthgets(SEXP, R_len_t);
|
... | ... | |
829 |
533 |
SEXP R_lsInternal(SEXP, Rboolean);
|
830 |
534 |
SEXP R_lsInternal3(SEXP, Rboolean, Rboolean);
|
831 |
535 |
SEXP Rf_match(SEXP, SEXP, int);
|
832 |
|
SEXP Rf_matchE(SEXP, SEXP, int, SEXP);
|
833 |
536 |
SEXP Rf_namesgets(SEXP, SEXP);
|
834 |
537 |
SEXP Rf_mkChar(const char *);
|
835 |
538 |
SEXP Rf_mkCharLen(const char *, int);
|
... | ... | |
843 |
546 |
int R_nchar(SEXP string, nchar_type type_,
|
844 |
547 |
Rboolean allowNA, Rboolean keepNA, const char* msg_name);
|
845 |
548 |
|
846 |
|
Rboolean Rf_pmatch(SEXP, SEXP, Rboolean);
|
847 |
|
Rboolean Rf_psmatch(const char *, const char *, Rboolean);
|
|
549 |
SEXP R_ParseEvalString(const char *, SEXP);
|
|
550 |
SEXP R_ParseString(const char *);
|
848 |
551 |
void Rf_PrintValue(SEXP);
|
849 |
552 |
#ifndef INLINE_PROTECT
|
850 |
553 |
SEXP Rf_protect(SEXP);
|
851 |
554 |
#endif
|
852 |
|
void Rf_readS3VarsFromFrame(SEXP, SEXP*, SEXP*, SEXP*, SEXP*, SEXP*, SEXP*);
|
853 |
555 |
SEXP Rf_setAttrib(SEXP, SEXP, SEXP);
|
854 |
|
void Rf_setSVector(SEXP*, int, SEXP);
|
855 |
556 |
void Rf_setVar(SEXP, SEXP, SEXP);
|
856 |
|
SEXP Rf_stringSuffix(SEXP, int);
|
857 |
557 |
SEXPTYPE Rf_str2type(const char *);
|
858 |
558 |
Rboolean Rf_StringBlank(SEXP);
|
859 |
559 |
SEXP Rf_substitute(SEXP,SEXP);
|
|
560 |
SEXP Rf_topenv(SEXP, SEXP);
|
860 |
561 |
const char * Rf_translateChar(SEXP);
|
861 |
|
const char * Rf_translateChar0(SEXP);
|
862 |
562 |
const char * Rf_translateCharUTF8(SEXP);
|
863 |
563 |
const char * Rf_type2char(SEXPTYPE);
|
864 |
564 |
SEXP Rf_type2rstr(SEXPTYPE);
|
... | ... | |
869 |
569 |
#endif
|
870 |
570 |
void Rf_unprotect_ptr(SEXP);
|
871 |
571 |
|
872 |
|
void NORET R_signal_protect_error(void);
|
873 |
|
void NORET R_signal_unprotect_error(void);
|
874 |
|
void NORET R_signal_reprotect_error(PROTECT_INDEX i);
|
875 |
|
|
876 |
572 |
#ifndef INLINE_PROTECT
|
877 |
573 |
void R_ProtectWithIndex(SEXP, PROTECT_INDEX *);
|
878 |
574 |
void R_Reprotect(SEXP, PROTECT_INDEX);
|
879 |
575 |
#endif
|
880 |
576 |
SEXP R_tryEval(SEXP, SEXP, int *);
|
881 |
577 |
SEXP R_tryEvalSilent(SEXP, SEXP, int *);
|
882 |
|
const char *R_curErrorBuf();
|
|
578 |
SEXP R_GetCurrentEnv(void);
|
883 |
579 |
|
884 |
580 |
Rboolean Rf_isS4(SEXP);
|
885 |
581 |
SEXP Rf_asS4(SEXP, Rboolean, int);
|
886 |
582 |
SEXP Rf_S3Class(SEXP);
|
887 |
583 |
int Rf_isBasicClass(const char *);
|
888 |
584 |
|
889 |
|
Rboolean R_cycle_detected(SEXP s, SEXP child);
|
890 |
|
|
|
585 |
/* cetype_t is an identifier reseved by POSIX, but it is
|
|
586 |
well established as public. Could remap by a #define though */
|
891 |
587 |
typedef enum {
|
892 |
588 |
CE_NATIVE = 0,
|
893 |
589 |
CE_UTF8 = 1,
|
... | ... | |
901 |
597 |
SEXP Rf_mkCharCE(const char *, cetype_t);
|
902 |
598 |
SEXP Rf_mkCharLenCE(const char *, int, cetype_t);
|
903 |
599 |
const char *Rf_reEnc(const char *x, cetype_t ce_in, cetype_t ce_out, int subst);
|
|
600 |
const char *Rf_reEnc3(const char *x, const char *fromcode, const char *tocode, int subst);
|
904 |
601 |
|
905 |
|
/* return(.) NOT reached : for -Wall */
|
906 |
|
#define error_return(msg) { Rf_error(msg); return R_NilValue; }
|
907 |
|
#define errorcall_return(cl,msg){ Rf_errorcall(cl, msg); return R_NilValue; }
|
908 |
|
|
909 |
602 |
#ifdef __MAIN__
|
910 |
603 |
#undef extern
|
911 |
604 |
#undef LibExtern
|
... | ... | |
923 |
616 |
void R_SetExternalPtrAddr(SEXP s, void *p);
|
924 |
617 |
void R_SetExternalPtrTag(SEXP s, SEXP tag);
|
925 |
618 |
void R_SetExternalPtrProtected(SEXP s, SEXP p);
|
|
619 |
// Added in R 3.4.0
|
|
620 |
SEXP R_MakeExternalPtrFn(DL_FUNC p, SEXP tag, SEXP prot);
|
|
621 |
DL_FUNC R_ExternalPtrAddrFn(SEXP s);
|
926 |
622 |
|
927 |
623 |
/* Finalization interface */
|
928 |
624 |
typedef void (*R_CFinalizer_t)(SEXP);
|
... | ... | |
941 |
637 |
|
942 |
638 |
SEXP R_PromiseExpr(SEXP);
|
943 |
639 |
SEXP R_ClosureExpr(SEXP);
|
944 |
|
void R_initialize_bcode(void);
|
945 |
|
SEXP R_bcEncode(SEXP);
|
946 |
|
SEXP R_bcDecode(SEXP);
|
947 |
|
#define PREXPR(e) R_PromiseExpr(e)
|
948 |
|
#define BODY_EXPR(e) R_ClosureExpr(e)
|
|
640 |
SEXP R_BytecodeExpr(SEXP e);
|
949 |
641 |
|
950 |
642 |
/* Protected evaluation */
|
951 |
643 |
Rboolean R_ToplevelExec(void (*fun)(void *), void *data);
|
952 |
644 |
SEXP R_ExecWithCleanup(SEXP (*fun)(void *), void *data,
|
953 |
645 |
void (*cleanfun)(void *), void *cleandata);
|
|
646 |
SEXP R_tryCatch(SEXP (*)(void *), void *, /* body closure*/
|
|
647 |
SEXP, /* condition classes (STRSXP) */
|
|
648 |
SEXP (*)(SEXP, void *), void *, /* handler closure */
|
|
649 |
void (*)(void *), void *); /* finally closure */
|
|
650 |
SEXP R_tryCatchError(SEXP (*)(void *), void *, /* body closure*/
|
|
651 |
SEXP (*)(SEXP, void *), void *); /* handler closure */
|
|
652 |
SEXP R_withCallingErrorHandler(SEXP (*)(void *), void *, /* body closure*/
|
|
653 |
SEXP (*)(SEXP, void *), void *); /* handler closure */
|
|
654 |
SEXP R_MakeUnwindCont(void);
|
|
655 |
NORET void R_ContinueUnwind(SEXP cont);
|
|
656 |
SEXP R_UnwindProtect(SEXP (*fun)(void *data), void *data,
|
|
657 |
void (*cleanfun)(void *data, Rboolean jump),
|
|
658 |
void *cleandata, SEXP cont);
|
954 |
659 |
|
955 |
660 |
/* Environment and Binding Features */
|
956 |
|
void R_RestoreHashCount(SEXP rho);
|
|
661 |
SEXP R_NewEnv(SEXP, int, int);
|
957 |
662 |
Rboolean R_IsPackageEnv(SEXP rho);
|
958 |
663 |
SEXP R_PackageEnvName(SEXP rho);
|
959 |
664 |
SEXP R_FindPackageEnv(SEXP info);
|
... | ... | |
967 |
672 |
void R_MakeActiveBinding(SEXP sym, SEXP fun, SEXP env);
|
968 |
673 |
Rboolean R_BindingIsLocked(SEXP sym, SEXP env);
|
969 |
674 |
Rboolean R_BindingIsActive(SEXP sym, SEXP env);
|
|
675 |
SEXP R_ActiveBindingFunction(SEXP sym, SEXP env);
|
970 |
676 |
Rboolean R_HasFancyBindings(SEXP rho);
|
971 |
677 |
|
972 |
678 |
|
973 |
679 |
/* ../main/errors.c : */
|
974 |
680 |
/* needed for R_load/savehistory handling in front ends */
|
975 |
|
#if defined(__GNUC__) && __GNUC__ >= 3
|
976 |
|
void Rf_errorcall(SEXP, const char *, ...) __attribute__((noreturn));
|
977 |
|
#else
|
978 |
|
void Rf_errorcall(SEXP, const char *, ...);
|
979 |
|
#endif
|
|
681 |
NORET void Rf_errorcall(SEXP, const char *, ...);
|
980 |
682 |
void Rf_warningcall(SEXP, const char *, ...);
|
981 |
683 |
void Rf_warningcall_immediate(SEXP, const char *, ...);
|
982 |
684 |
|
... | ... | |
1011 |
713 |
};
|
1012 |
714 |
|
1013 |
715 |
typedef struct R_inpstream_st *R_inpstream_t;
|
|
716 |
#define R_CODESET_MAX 63
|
1014 |
717 |
struct R_inpstream_st {
|
1015 |
718 |
R_pstream_data_t data;
|
1016 |
719 |
R_pstream_format_t type;
|
... | ... | |
1018 |
721 |
void (*InBytes)(R_inpstream_t, void *, int);
|
1019 |
722 |
SEXP (*InPersistHookFunc)(SEXP, SEXP);
|
1020 |
723 |
SEXP InPersistHookData;
|
|
724 |
char native_encoding[R_CODESET_MAX + 1];
|
|
725 |
void *nat2nat_obj;
|
|
726 |
void *nat2utf8_obj;
|
1021 |
727 |
};
|
1022 |
728 |
|
1023 |
729 |
void R_InitInPStream(R_inpstream_t stream, R_pstream_data_t data,
|
... | ... | |
1065 |
771 |
|
1066 |
772 |
void R_Serialize(SEXP s, R_outpstream_t ops);
|
1067 |
773 |
SEXP R_Unserialize(R_inpstream_t ips);
|
|
774 |
SEXP R_SerializeInfo(R_inpstream_t ips);
|
1068 |
775 |
|
1069 |
776 |
/* slot management (in attrib.c) */
|
1070 |
777 |
SEXP R_do_slot(SEXP obj, SEXP name);
|
... | ... | |
1089 |
796 |
void R_PreserveObject(SEXP);
|
1090 |
797 |
void R_ReleaseObject(SEXP);
|
1091 |
798 |
|
|
799 |
SEXP R_NewPreciousMSet(int);
|
|
800 |
void R_PreserveInMSet(SEXP x, SEXP mset);
|
|
801 |
void R_ReleaseFromMSet(SEXP x, SEXP mset);
|
|
802 |
void R_ReleaseMSet(SEXP mset, int keepSize);
|
|
803 |
|
1092 |
804 |
/* Shutdown actions */
|
1093 |
805 |
void R_dot_Last(void); /* in main.c */
|
1094 |
806 |
void R_RunExitFinalizers(void); /* in memory.c */
|
... | ... | |
1106 |
818 |
/* R_compute_identical: C version of identical() function
|
1107 |
819 |
The third arg to R_compute_identical() consists of bitmapped flags for non-default options:
|
1108 |
820 |
currently the first 4 default to TRUE, so the flag is set for FALSE values:
|
1109 |
|
1 = !NUM_EQ
|
1110 |
|
2 = !SINGLE_NA
|
1111 |
|
4 = !ATTR_AS_SET
|
1112 |
|
8 = !IGNORE_BYTECODE
|
1113 |
|
16 = !IGNORE_ENV
|
1114 |
|
Default from R's default: 15
|
|
821 |
1 = !NUM_EQ = IDENT_NUM_AS_BITS
|
|
822 |
2 = !SINGLE_NA = IDENT_NA_AS_BITS
|
|
823 |
4 = !ATTR_AS_SET = IDENT_ATTR_BY_ORDER
|
|
824 |
8 = !IGNORE_BYTECODE = IDENT_USE_BYTECODE
|
|
825 |
16 = !IGNORE_ENV = IDENT_USE_CLOENV
|
|
826 |
32 = !IGNORE_SRCREF = IDENT_USE_SRCREF
|
|
827 |
64 = IDENT_EXTPTR_AS_REF
|
|
828 |
Default from R's default: 16 = IDENT_USE_CLOENV
|
1115 |
829 |
*/
|
|
830 |
#define IDENT_NUM_AS_BITS 1
|
|
831 |
#define IDENT_NA_AS_BITS 2
|
|
832 |
#define IDENT_ATTR_BY_ORDER 4
|
|
833 |
#define IDENT_USE_BYTECODE 8
|
|
834 |
#define IDENT_USE_CLOENV 16
|
|
835 |
#define IDENT_USE_SRCREF 32
|
|
836 |
#define IDENT_EXTPTR_AS_REF 64
|
1116 |
837 |
Rboolean R_compute_identical(SEXP, SEXP, int);
|
1117 |
838 |
|
|
839 |
SEXP R_body_no_src(SEXP x); // body(x) without "srcref" etc, ../main/utils.c
|
|
840 |
|
1118 |
841 |
/* C version of R's indx <- order(..., na.last, decreasing) :
|
1119 |
842 |
e.g. arglist = Rf_lang2(x,y) or Rf_lang3(x,y,z) */
|
1120 |
843 |
void R_orderVector (int *indx, int n, SEXP arglist, Rboolean nalast, Rboolean decreasing);
|
... | ... | |
1146 |
869 |
#define asComplex Rf_asComplex
|
1147 |
870 |
#define asInteger Rf_asInteger
|
1148 |
871 |
#define asLogical Rf_asLogical
|
|
872 |
#define asLogical2 Rf_asLogical2
|
1149 |
873 |
#define asReal Rf_asReal
|
1150 |
874 |
#define asS4 Rf_asS4
|
1151 |
875 |
#define classgets Rf_classgets
|
1152 |
876 |
#define coerceVector Rf_coerceVector
|
1153 |
877 |
#define conformable Rf_conformable
|
1154 |
878 |
#define cons Rf_cons
|
|
879 |
#define fixSubset3Args Rf_fixSubset3Args
|
1155 |
880 |
#define copyListMatrix Rf_copyListMatrix
|
1156 |
881 |
#define copyMatrix Rf_copyMatrix
|
1157 |
882 |
#define copyMostAttrib Rf_copyMostAttrib
|
... | ... | |
1167 |
892 |
#define elt Rf_elt
|
1168 |
893 |
#define errorcall Rf_errorcall
|
1169 |
894 |
#define eval Rf_eval
|
|
895 |
#define ExtractSubset Rf_ExtractSubset
|
1170 |
896 |
#define findFun Rf_findFun
|
|
897 |
#define findFun3 Rf_findFun3
|
|
898 |
#define findFunctionForBody Rf_findFunctionForBody
|
1171 |
899 |
#define findVar Rf_findVar
|
1172 |
900 |
#define findVarInFrame Rf_findVarInFrame
|
1173 |
901 |
#define findVarInFrame3 Rf_findVarInFrame3
|
|
902 |
#define FixupDigits Rf_FixupDigits
|
|
903 |
#define FixupWidth Rf_FixupWidth
|
1174 |
904 |
#define GetArrayDimnames Rf_GetArrayDimnames
|
1175 |
905 |
#define getAttrib Rf_getAttrib
|
1176 |
906 |
#define getCharCE Rf_getCharCE
|
... | ... | |
1184 |
914 |
#define gsetVar Rf_gsetVar
|
1185 |
915 |
#define inherits Rf_inherits
|
1186 |
916 |
#define install Rf_install
|
1187 |
|
#define installChar Rf_installChar
|
|
917 |
#define installChar Rf_installTrChar
|
|
918 |
#define installNoTrChar Rf_installNoTrChar
|
|
919 |
#define installTrChar Rf_installTrChar
|
1188 |
920 |
#define installDDVAL Rf_installDDVAL
|
1189 |
921 |
#define installS3Signature Rf_installS3Signature
|
1190 |
922 |
#define isArray Rf_isArray
|
... | ... | |
1240 |
972 |
#define list3 Rf_list3
|
1241 |
973 |
#define list4 Rf_list4
|
1242 |
974 |
#define list5 Rf_list5
|
|
975 |
#define list6 Rf_list6
|
1243 |
976 |
#define listAppend Rf_listAppend
|
1244 |
977 |
#define match Rf_match
|
1245 |
978 |
#define matchE Rf_matchE
|
... | ... | |
1259 |
992 |
#define pmatch Rf_pmatch
|
1260 |
993 |
#define psmatch Rf_psmatch
|
1261 |
994 |
#define PrintValue Rf_PrintValue
|
|
995 |
#define printwhere Rf_printwhere
|
1262 |
996 |
#define protect Rf_protect
|
1263 |
997 |
#define readS3VarsFromFrame Rf_readS3VarsFromFrame
|
1264 |
998 |
#define reEnc Rf_reEnc
|
|
999 |
#define reEnc3 Rf_reEnc3
|
1265 |
1000 |
#define rownamesgets Rf_rownamesgets
|
1266 |
1001 |
#define S3Class Rf_S3Class
|
1267 |
1002 |
#define ScalarComplex Rf_ScalarComplex
|
... | ... | |
1297 |
1032 |
|
1298 |
1033 |
#endif
|
1299 |
1034 |
|
1300 |
|
#if defined(CALLED_FROM_DEFN_H) && !defined(__MAIN__) && (defined(COMPILING_R) || ( __GNUC__ && !defined(__INTEL_COMPILER) ))
|
1301 |
|
#include "Rinlinedfuns.h"
|
1302 |
|
#else
|
|
1035 |
/* Defining NO_RINLINEDFUNS disables use to simulate platforms where
|
|
1036 |
this is not available */
|
|
1037 |
#if ! (defined(CALLED_FROM_DEFN_H) && !defined(__MAIN__) && (defined(COMPILING_R) || ( __GNUC__ && !defined(__INTEL_COMPILER) )) && (defined(COMPILING_R) || !defined(NO_RINLINEDFUNS)))
|
1303 |
1038 |
/* need remapped names here for use with R_NO_REMAP */
|
1304 |
1039 |
|
1305 |
1040 |
/*
|
1306 |
|
These are the inlinable functions that are provided in Rinlinedfuns.h
|
1307 |
|
It is *essential* that these do not appear in any other header file,
|
1308 |
|
with or without the Rf_ prefix.
|
|
1041 |
These are the public inlinable functions that are provided in
|
|
1042 |
Rinlinedfuns.h It is *essential* that these do not appear in any
|
|
1043 |
other header file, with or without the Rf_ prefix.
|
1309 |
1044 |
*/
|
1310 |
1045 |
SEXP Rf_allocVector(SEXPTYPE, R_xlen_t);
|
1311 |
1046 |
Rboolean Rf_conformable(SEXP, SEXP);
|
... | ... | |
1346 |
1081 |
SEXP Rf_list3(SEXP, SEXP, SEXP);
|
1347 |
1082 |
SEXP Rf_list4(SEXP, SEXP, SEXP, SEXP);
|
1348 |
1083 |
SEXP Rf_list5(SEXP, SEXP, SEXP, SEXP, SEXP);
|
|
1084 |
SEXP Rf_list6(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
|
1349 |
1085 |
SEXP Rf_listAppend(SEXP, SEXP);
|
1350 |
1086 |
SEXP Rf_mkNamed(SEXPTYPE, const char **);
|
1351 |
1087 |
SEXP Rf_mkString(const char *);
|
... | ... | |
1358 |
1094 |
SEXP Rf_ScalarReal(double);
|
1359 |
1095 |
SEXP Rf_ScalarString(SEXP);
|
1360 |
1096 |
R_xlen_t Rf_xlength(SEXP);
|
|
1097 |
R_xlen_t (XLENGTH)(SEXP x);
|
|
1098 |
R_xlen_t (XTRUELENGTH)(SEXP x);
|
|
1099 |
int LENGTH_EX(SEXP x, const char *file, int line);
|
|
1100 |
R_xlen_t XLENGTH_EX(SEXP x);
|
1361 |
1101 |
# ifdef INLINE_PROTECT
|
1362 |
1102 |
SEXP Rf_protect(SEXP);
|
1363 |
1103 |
void Rf_unprotect(int);
|
1364 |
1104 |
void R_ProtectWithIndex(SEXP, PROTECT_INDEX *);
|
1365 |
1105 |
void R_Reprotect(SEXP, PROTECT_INDEX);
|
1366 |
1106 |
# endif
|
1367 |
|
SEXP R_FixupRHS(SEXP x, SEXP y);
|
|
1107 |
SEXP (CAR)(SEXP e);
|
|
1108 |
void *(DATAPTR)(SEXP x);
|
|
1109 |
const void *(DATAPTR_RO)(SEXP x);
|
|
1110 |
const void *(DATAPTR_OR_NULL)(SEXP x);
|
|
1111 |
const int *(LOGICAL_OR_NULL)(SEXP x);
|
|
1112 |
const int *(INTEGER_OR_NULL)(SEXP x);
|
|
1113 |
const double *(REAL_OR_NULL)(SEXP x);
|
|
1114 |
const Rcomplex *(COMPLEX_OR_NULL)(SEXP x);
|
|
1115 |
const Rbyte *(RAW_OR_NULL)(SEXP x);
|
|
1116 |
int (INTEGER_ELT)(SEXP x, R_xlen_t i);
|
|
1117 |
double (REAL_ELT)(SEXP x, R_xlen_t i);
|
|
1118 |
int (LOGICAL_ELT)(SEXP x, R_xlen_t i);
|
|
1119 |
Rcomplex (COMPLEX_ELT)(SEXP x, R_xlen_t i);
|
|
1120 |
Rbyte (RAW_ELT)(SEXP x, R_xlen_t i);
|
|
1121 |
SEXP (STRING_ELT)(SEXP x, R_xlen_t i);
|
|
1122 |
void SET_LOGICAL_ELT(SEXP x, R_xlen_t i, int v);
|
|
1123 |
void SET_INTEGER_ELT(SEXP x, R_xlen_t i, int v);
|
|
1124 |
void SET_REAL_ELT(SEXP x, R_xlen_t i, double v);
|
|
1125 |
void SET_COMPLEX_ELT(SEXP x, R_xlen_t i, Rcomplex v);
|
|
1126 |
void SET_RAW_ELT(SEXP x, R_xlen_t i, Rbyte v);
|
|
1127 |
|
|
1128 |
/* ALTREP support */
|
|
1129 |
SEXP ALTREP_CLASS(SEXP x);
|
|
1130 |
SEXP R_altrep_data1(SEXP x);
|
|
1131 |
SEXP R_altrep_data2(SEXP x);
|
|
1132 |
void R_set_altrep_data1(SEXP x, SEXP v);
|
|
1133 |
void R_set_altrep_data2(SEXP x, SEXP v);
|
|
1134 |
|
|
1135 |
int *LOGICAL0(SEXP x);
|
|
1136 |
int *INTEGER0(SEXP x);
|
|
1137 |
double *REAL0(SEXP x);
|
|
1138 |
Rcomplex *COMPLEX0(SEXP x);
|
|
1139 |
Rbyte *RAW0(SEXP x);
|
1368 |
1140 |
#endif
|
1369 |
1141 |
|
1370 |
|
#ifdef USE_RINTERNALS
|
|
1142 |
int (ALTREP)(SEXP x);
|
1371 |
1143 |
|
1372 |
|
/* Test macros with function versions above */
|
1373 |
|
#undef isNull
|
1374 |
|
#define isNull(s) (TYPEOF(s) == NILSXP)
|
1375 |
|
#undef isSymbol
|
1376 |
|
#define isSymbol(s) (TYPEOF(s) == SYMSXP)
|
1377 |
|
#undef isLogical
|
1378 |
|
#define isLogical(s) (TYPEOF(s) == LGLSXP)
|
1379 |
|
#undef isReal
|
1380 |
|
#define isReal(s) (TYPEOF(s) == REALSXP)
|
1381 |
|
#undef isComplex
|
1382 |
|
#define isComplex(s) (TYPEOF(s) == CPLXSXP)
|
1383 |
|
#undef isExpression
|
1384 |
|
#define isExpression(s) (TYPEOF(s) == EXPRSXP)
|
1385 |
|
#undef isEnvironment
|
1386 |
|
#define isEnvironment(s) (TYPEOF(s) == ENVSXP)
|
1387 |
|
#undef isString
|
1388 |
|
#define isString(s) (TYPEOF(s) == STRSXP)
|
1389 |
|
#undef isObject
|
1390 |
|
#define isObject(s) (OBJECT(s) != 0)
|
|
1144 |
/* ALTREP sorting support */
|
|
1145 |
enum {SORTED_DECR_NA_1ST = -2,
|
|
1146 |
SORTED_DECR = -1,
|
|
1147 |
UNKNOWN_SORTEDNESS = INT_MIN, /*INT_MIN is NA_INTEGER! */
|
|
1148 |
SORTED_INCR = 1,
|
|
1149 |
SORTED_INCR_NA_1ST = 2,
|
|
1150 |
KNOWN_UNSORTED = 0};
|
|
1151 |
#define KNOWN_SORTED(sorted) (sorted == SORTED_DECR || \
|
|
1152 |
sorted == SORTED_INCR || \
|
|
1153 |
sorted == SORTED_DECR_NA_1ST || \
|
|
1154 |
sorted == SORTED_INCR_NA_1ST)
|
1391 |
1155 |
|
1392 |
|
/* macro version of R_CheckStack */
|
1393 |
|
#define R_CheckStack() do { \
|
1394 |
|
void NORET R_SignalCStackOverflow(intptr_t); \
|
1395 |
|
int dummy; \
|
1396 |
|
intptr_t usage = R_CStackDir * (R_CStackStart - (uintptr_t)&dummy); \
|
1397 |
|
if(R_CStackLimit != -1 && usage > ((intptr_t) R_CStackLimit)) \
|
1398 |
|
R_SignalCStackOverflow(usage); \
|
1399 |
|
} while (FALSE)
|
1400 |
|
#endif
|
|
1156 |
#define KNOWN_NA_1ST(sorted) (sorted == SORTED_INCR_NA_1ST || \
|
|
1157 |
sorted == SORTED_DECR_NA_1ST)
|
1401 |
1158 |
|
|
1159 |
#define KNOWN_INCR(sorted) (sorted == SORTED_INCR || \
|
|
1160 |
sorted == SORTED_INCR_NA_1ST)
|
1402 |
1161 |
|
|
1162 |
#define KNOWN_DECR(sorted) (sorted == SORTED_DECR || \
|
|
1163 |
sorted == SORTED_DECR_NA_1ST)
|
|
1164 |
|
|
1165 |
|
|
1166 |
/* Experimental C interface for experimental hash table support
|
|
1167 |
|
|
1168 |
Not in the API (at least not yet) but declared here to allow some
|
|
1169 |
experimenting */
|
|
1170 |
|
|
1171 |
/* try to allow some type checking */
|
|
1172 |
typedef struct { SEXP cell; } R_hashtab_type;
|
|
1173 |
|
|
1174 |
/* hash table types */
|
|
1175 |
#define HT_TYPE_IDENTICAL 0
|
|
1176 |
#define HT_TYPE_ADDRESS 1
|
|
1177 |
|
|
1178 |
/* public C interface */
|
|
1179 |
R_hashtab_type R_asHashtable(SEXP h);
|
|
1180 |
SEXP R_HashtabSEXP(R_hashtab_type h);
|
|
1181 |
int R_isHashtable(SEXP h);
|
|
1182 |
R_hashtab_type R_mkhashtab(int type, int /*K*/);
|
|
1183 |
SEXP R_gethash(R_hashtab_type h, SEXP key, SEXP nomatch);
|
|
1184 |
SEXP R_sethash(R_hashtab_type h, SEXP key, SEXP value);
|
|
1185 |
int R_remhash(R_hashtab_type h, SEXP key);
|
|
1186 |
int R_numhash(R_hashtab_type h);
|
|
1187 |
int R_typhash(R_hashtab_type h);
|
|
1188 |
SEXP R_maphash(R_hashtab_type h, SEXP FUN);
|
|
1189 |
void R_maphashC(R_hashtab_type h, void (*FUN)(SEXP, SEXP, void *), void *data);
|
|
1190 |
void R_clrhash(R_hashtab_type h);
|
|
1191 |
|
|
1192 |
|
|
1193 |
/* stuff that probably shouldn't be in the API but is getting used */
|
|
1194 |
|
|
1195 |
void (SET_TYPEOF)(SEXP x, int v); // used by Rcpp
|
|
1196 |
void (SET_OBJECT)(SEXP x, int v); // used by Rcpp
|
|
1197 |
void (SET_S4_OBJECT)(SEXP x); // used by Rcpp (maybe?)
|
|
1198 |
void (UNSET_S4_OBJECT)(SEXP x); // used by Rcpp (maybe?)
|
|
1199 |
const char *R_curErrorBuf(void); // used by unix */
|
|
1200 |
int (IS_SCALAR)(SEXP x, int type); // used by symengine */
|
|
1201 |
Rboolean Rf_psmatch(const char *, const char *, Rboolean); // used by rgl
|
|
1202 |
|
|
1203 |
/* used in a couple of packages but should probably be dropped */
|
|
1204 |
/* match(.) NOT reached : for -Wall */
|
|
1205 |
#define error_return(msg) { Rf_error(msg); return R_NilValue; }
|
|
1206 |
#define errorcall_return(cl,msg){ Rf_errorcall(cl, msg); return R_NilValue; }
|
|
1207 |
|
|
1208 |
void (SETLENGTH)(SEXP x, R_xlen_t v); // used by data.table and others
|
|
1209 |
void (SET_TRUELENGTH)(SEXP x, R_xlen_t v); // used by data.table and others
|
|
1210 |
int (SETLEVELS)(SEXP x, int v); // used by quotedargs
|
|
1211 |
|
|
1212 |
void (SET_ENVFLAGS)(SEXP x, int v); // used by rlang and others
|
|
1213 |
void SET_FRAME(SEXP x, SEXP v); // used by rlang and others
|
|
1214 |
void SET_ENCLOS(SEXP x, SEXP v); // used by rlang and others
|
|
1215 |
void SET_HASHTAB(SEXP x, SEXP v); // used by rlang and others
|
|
1216 |
|
|
1217 |
void SET_PRENV(SEXP x, SEXP v); // used by dplyr, others
|
|
1218 |
void SET_PRVALUE(SEXP x, SEXP v); // used by dplyr, others
|
|
1219 |
void SET_PRCODE(SEXP x, SEXP v); // used by magrittr, others
|
|
1220 |
|
|
1221 |
void *(STDVEC_DATAPTR)(SEXP x); // used by vroom
|
|
1222 |
|
|
1223 |
/* Growable vector support */ // used by multbxxc
|
|
1224 |
int (IS_GROWABLE)(SEXP x);
|
|
1225 |
void (SET_GROWABLE_BIT)(SEXP x);
|
|
1226 |
|
|
1227 |
// used by quotedargs
|
|
1228 |
#define BCODE_CONSTS(x) CDR(x) // re-enable in Defn.h after removing here
|
|
1229 |
void (SET_NAMED)(SEXP x, int v);
|
|
1230 |
|
|
1231 |
// used by igraph, lazyeval, nseval, rlang
|
|
1232 |
#define PREXPR(e) R_PromiseExpr(e)
|
|
1233 |
|
|
1234 |
// used by rlang
|
|
1235 |
#define BODY_EXPR(e) R_ClosureExpr(e)
|
|
1236 |
|
|
1237 |
// used by BIOC::matter; mightbe reasonable to include in API
|
|
1238 |
SEXP R_tryWrap(SEXP);
|
|
1239 |
|
1403 |
1240 |
#ifdef __cplusplus
|
1404 |
1241 |
}
|
1405 |
1242 |
#endif
|