RAPI
|
00001 /* 00002 * R : A Computer Language for Statistical Data Analysis 00003 * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka 00004 * Copyright (C) 1999-2016 The R Core Team. 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program; if not, a copy is available at 00018 * https://www.R-project.org/Licenses/ 00019 */ 00020 00021 /* This file is installed and available to packages, but only a small 00022 part of the contents is within the API. See chapter 6 of 'Writing 00023 R Extensions'. 00024 */ 00025 00026 #ifndef R_INTERNALS_H_ 00027 #define R_INTERNALS_H_ 00028 00029 // Support for NO_C_HEADERS added in R 3.3.0 00030 #ifdef __cplusplus 00031 # ifndef NO_C_HEADERS 00032 # include <cstdio> 00033 # ifdef __SUNPRO_CC 00034 using std::FILE; 00035 # endif 00036 # include <climits> 00037 # include <cstddef> 00038 # endif 00039 extern "C" { 00040 #else 00041 # ifndef NO_C_HEADERS 00042 # include <stdio.h> 00043 # include <limits.h> /* for INT_MAX */ 00044 # include <stddef.h> /* for ptrdiff_t */ 00045 # endif 00046 #endif 00047 00048 #include <R_ext/Arith.h> 00049 #include <R_ext/Boolean.h> 00050 #include <R_ext/Complex.h> 00051 #include <R_ext/Error.h> // includes NORET macro 00052 #include <R_ext/Memory.h> 00053 #include <R_ext/Utils.h> 00054 #include <R_ext/Print.h> 00055 00056 #include <R_ext/libextern.h> 00057 00058 typedef unsigned char Rbyte; 00059 00060 /* type for length of (standard, not long) vectors etc */ 00061 typedef int R_len_t; 00062 #define R_LEN_T_MAX INT_MAX 00063 00064 /* both config.h and Rconfig.h set SIZEOF_SIZE_T, but Rconfig.h is 00065 skipped if config.h has already been included. */ 00066 #ifndef R_CONFIG_H 00067 # include <Rconfig.h> 00068 #endif 00069 00070 #if ( SIZEOF_SIZE_T > 4 ) 00071 # define LONG_VECTOR_SUPPORT 00072 #endif 00073 00074 #ifdef LONG_VECTOR_SUPPORT 00075 typedef ptrdiff_t R_xlen_t; 00076 typedef struct { R_xlen_t lv_length, lv_truelength; } R_long_vec_hdr_t; 00077 # define R_XLEN_T_MAX 4503599627370496 00078 # define R_SHORT_LEN_MAX 2147483647 00079 # define R_LONG_VEC_TOKEN -1 00080 #else 00081 typedef int R_xlen_t; 00082 # define R_XLEN_T_MAX R_LEN_T_MAX 00083 #endif 00084 00085 #ifndef TESTING_WRITE_BARRIER 00086 # define INLINE_PROTECT 00087 #endif 00088 00089 /* Fundamental Data Types: These are largely Lisp 00090 * influenced structures, with the exception of LGLSXP, 00091 * INTSXP, REALSXP, CPLXSXP and STRSXP which are the 00092 * element types for S-like data objects. 00093 * 00094 * --> TypeTable[] in ../main/util.c for typeof() 00095 */ 00096 00097 /* These exact numeric values are seldom used, but they are, e.g., in 00098 * ../main/subassign.c, and they are serialized. 00099 */ 00100 #ifndef enum_SEXPTYPE 00101 /* NOT YET using enum: 00102 * 1) The SEXPREC struct below has 'SEXPTYPE type : 5' 00103 * (making FUNSXP and CLOSXP equivalent in there), 00104 * giving (-Wall only ?) warnings all over the place 00105 * 2) Many switch(type) { case ... } statements need a final `default:' 00106 * added in order to avoid warnings like [e.g. l.170 of ../main/util.c] 00107 * "enumeration value `FUNSXP' not handled in switch" 00108 */ 00109 typedef unsigned int SEXPTYPE; 00110 00111 #define NILSXP 0 /* nil = NULL */ 00112 #define SYMSXP 1 /* symbols */ 00113 #define LISTSXP 2 /* lists of dotted pairs */ 00114 #define CLOSXP 3 /* closures */ 00115 #define ENVSXP 4 /* environments */ 00116 #define PROMSXP 5 /* promises: [un]evaluated closure arguments */ 00117 #define LANGSXP 6 /* language constructs (special lists) */ 00118 #define SPECIALSXP 7 /* special forms */ 00119 #define BUILTINSXP 8 /* builtin non-special forms */ 00120 #define CHARSXP 9 /* "scalar" string type (internal only)*/ 00121 #define LGLSXP 10 /* logical vectors */ 00122 /* 11 and 12 were factors and ordered factors in the 1990s */ 00123 #define INTSXP 13 /* integer vectors */ 00124 #define REALSXP 14 /* real variables */ 00125 #define CPLXSXP 15 /* complex variables */ 00126 #define STRSXP 16 /* string vectors */ 00127 #define DOTSXP 17 /* dot-dot-dot object */ 00128 #define ANYSXP 18 /* make "any" args work. 00129 Used in specifying types for symbol 00130 registration to mean anything is okay */ 00131 #define VECSXP 19 /* generic vectors */ 00132 #define EXPRSXP 20 /* expressions vectors */ 00133 #define BCODESXP 21 /* byte code */ 00134 #define EXTPTRSXP 22 /* external pointer */ 00135 #define WEAKREFSXP 23 /* weak reference */ 00136 #define RAWSXP 24 /* raw bytes */ 00137 #define S4SXP 25 /* S4, non-vector */ 00138 00139 /* used for detecting PROTECT issues in memory.c */ 00140 #define NEWSXP 30 /* fresh node created in new page */ 00141 #define FREESXP 31 /* node released by GC */ 00142 00143 #define FUNSXP 99 /* Closure or Builtin or Special */ 00144 00145 00146 #else /* NOT YET */ 00147 /*------ enum_SEXPTYPE ----- */ 00148 typedef enum { 00149 NILSXP = 0, /* nil = NULL */ 00150 SYMSXP = 1, /* symbols */ 00151 LISTSXP = 2, /* lists of dotted pairs */ 00152 CLOSXP = 3, /* closures */ 00153 ENVSXP = 4, /* environments */ 00154 PROMSXP = 5, /* promises: [un]evaluated closure arguments */ 00155 LANGSXP = 6, /* language constructs (special lists) */ 00156 SPECIALSXP = 7, /* special forms */ 00157 BUILTINSXP = 8, /* builtin non-special forms */ 00158 CHARSXP = 9, /* "scalar" string type (internal only)*/ 00159 LGLSXP = 10, /* logical vectors */ 00160 INTSXP = 13, /* integer vectors */ 00161 REALSXP = 14, /* real variables */ 00162 CPLXSXP = 15, /* complex variables */ 00163 STRSXP = 16, /* string vectors */ 00164 DOTSXP = 17, /* dot-dot-dot object */ 00165 ANYSXP = 18, /* make "any" args work */ 00166 VECSXP = 19, /* generic vectors */ 00167 EXPRSXP = 20, /* expressions vectors */ 00168 BCODESXP = 21, /* byte code */ 00169 EXTPTRSXP = 22, /* external pointer */ 00170 WEAKREFSXP = 23, /* weak reference */ 00171 RAWSXP = 24, /* raw bytes */ 00172 S4SXP = 25, /* S4 non-vector */ 00173 00174 NEWSXP = 30, /* fresh node creaed in new page */ 00175 FREESXP = 31, /* node released by GC */ 00176 00177 FUNSXP = 99 /* Closure or Builtin */ 00178 } SEXPTYPE; 00179 #endif 00180 00181 /* These are also used with the write barrier on, in attrib.c and util.c */ 00182 #define TYPE_BITS 5 00183 #define MAX_NUM_SEXPTYPE (1<<TYPE_BITS) 00184 00185 // ======================= USE_RINTERNALS section 00186 #ifdef USE_RINTERNALS 00187 /* This is intended for use only within R itself. 00188 * It defines internal structures that are otherwise only accessible 00189 * via SEXP, and macros to replace many (but not all) of accessor functions 00190 * (which are always defined). 00191 */ 00192 00193 /* Flags */ 00194 00195 00196 struct sxpinfo_struct { 00197 SEXPTYPE type : TYPE_BITS;/* ==> (FUNSXP == 99) %% 2^5 == 3 == CLOSXP 00198 * -> warning: `type' is narrower than values 00199 * of its type 00200 * when SEXPTYPE was an enum */ 00201 unsigned int obj : 1; 00202 unsigned int named : 2; 00203 unsigned int gp : 16; 00204 unsigned int mark : 1; 00205 unsigned int debug : 1; 00206 unsigned int trace : 1; /* functions and memory tracing */ 00207 unsigned int spare : 1; /* currently unused */ 00208 unsigned int gcgen : 1; /* old generation number */ 00209 unsigned int gccls : 3; /* node class */ 00210 }; /* Tot: 32 */ 00211 00212 struct vecsxp_struct { 00213 R_len_t length; 00214 R_len_t truelength; 00215 }; 00216 00217 struct primsxp_struct { 00218 int offset; 00219 }; 00220 00221 struct symsxp_struct { 00222 struct SEXPREC *pname; 00223 struct SEXPREC *value; 00224 struct SEXPREC *internal; 00225 }; 00226 00227 struct listsxp_struct { 00228 struct SEXPREC *carval; 00229 struct SEXPREC *cdrval; 00230 struct SEXPREC *tagval; 00231 }; 00232 00233 struct envsxp_struct { 00234 struct SEXPREC *frame; 00235 struct SEXPREC *enclos; 00236 struct SEXPREC *hashtab; 00237 }; 00238 00239 struct closxp_struct { 00240 struct SEXPREC *formals; 00241 struct SEXPREC *body; 00242 struct SEXPREC *env; 00243 }; 00244 00245 struct promsxp_struct { 00246 struct SEXPREC *value; 00247 struct SEXPREC *expr; 00248 struct SEXPREC *env; 00249 }; 00250 00251 /* Every node must start with a set of sxpinfo flags and an attribute 00252 field. Under the generational collector these are followed by the 00253 fields used to maintain the collector's linked list structures. */ 00254 00255 /* Define SWITH_TO_REFCNT to use reference counting instead of the 00256 'NAMED' mechanism. This uses the R-devel binary layout. The two 00257 'named' field bits are used for the REFCNT, so REFCNTMAX is 3. */ 00258 //#define SWITCH_TO_REFCNT 00259 00260 #if defined(SWITCH_TO_REFCNT) && ! defined(COMPUTE_REFCNT_VALUES) 00261 # define COMPUTE_REFCNT_VALUES 00262 #endif 00263 #define REFCNTMAX (4 - 1) 00264 00265 #define SEXPREC_HEADER \ 00266 struct sxpinfo_struct sxpinfo; \ 00267 struct SEXPREC *attrib; \ 00268 struct SEXPREC *gengc_next_node, *gengc_prev_node 00269 00270 /* The standard node structure consists of a header followed by the 00271 node data. */ 00272 typedef struct SEXPREC { 00273 SEXPREC_HEADER; 00274 union { 00275 struct primsxp_struct primsxp; 00276 struct symsxp_struct symsxp; 00277 struct listsxp_struct listsxp; 00278 struct envsxp_struct envsxp; 00279 struct closxp_struct closxp; 00280 struct promsxp_struct promsxp; 00281 } u; 00282 } SEXPREC, *SEXP; 00283 00284 /* The generational collector uses a reduced version of SEXPREC as a 00285 header in vector nodes. The layout MUST be kept consistent with 00286 the SEXPREC definition. The standard SEXPREC takes up 7 words on 00287 most hardware; this reduced version should take up only 6 words. 00288 In addition to slightly reducing memory use, this can lead to more 00289 favorable data alignment on 32-bit architectures like the Intel 00290 Pentium III where odd word alignment of doubles is allowed but much 00291 less efficient than even word alignment. */ 00292 typedef struct VECTOR_SEXPREC { 00293 SEXPREC_HEADER; 00294 struct vecsxp_struct vecsxp; 00295 } VECTOR_SEXPREC, *VECSEXP; 00296 00297 typedef union { VECTOR_SEXPREC s; double align; } SEXPREC_ALIGN; 00298 00299 /* General Cons Cell Attributes */ 00300 #define ATTRIB(x) ((x)->attrib) 00301 #define OBJECT(x) ((x)->sxpinfo.obj) 00302 #define MARK(x) ((x)->sxpinfo.mark) 00303 #define TYPEOF(x) ((x)->sxpinfo.type) 00304 #define NAMED(x) ((x)->sxpinfo.named) 00305 #define RTRACE(x) ((x)->sxpinfo.trace) 00306 #define LEVELS(x) ((x)->sxpinfo.gp) 00307 #define SET_OBJECT(x,v) (((x)->sxpinfo.obj)=(v)) 00308 #define SET_TYPEOF(x,v) (((x)->sxpinfo.type)=(v)) 00309 #define SET_NAMED(x,v) (((x)->sxpinfo.named)=(v)) 00310 #define SET_RTRACE(x,v) (((x)->sxpinfo.trace)=(v)) 00311 #define SETLEVELS(x,v) (((x)->sxpinfo.gp)=((unsigned short)v)) 00312 00313 #if defined(COMPUTE_REFCNT_VALUES) 00314 # define REFCNT(x) ((x)->sxpinfo.named) 00315 # define TRACKREFS(x) (TYPEOF(x) == CLOSXP ? TRUE : ! (x)->sxpinfo.spare) 00316 #else 00317 # define REFCNT(x) 0 00318 # define TRACKREFS(x) FALSE 00319 #endif 00320 00321 #ifdef SWITCH_TO_REFCNT 00322 # undef NAMED 00323 # undef SET_NAMED 00324 # define NAMED(x) REFCNT(x) 00325 # define SET_NAMED(x, v) do {} while (0) 00326 #endif 00327 00328 /* S4 object bit, set by R_do_new_object for all new() calls */ 00329 #define S4_OBJECT_MASK ((unsigned short)(1<<4)) 00330 #define IS_S4_OBJECT(x) ((x)->sxpinfo.gp & S4_OBJECT_MASK) 00331 #define SET_S4_OBJECT(x) (((x)->sxpinfo.gp) |= S4_OBJECT_MASK) 00332 #define UNSET_S4_OBJECT(x) (((x)->sxpinfo.gp) &= ~S4_OBJECT_MASK) 00333 00334 /* Vector Access Macros */ 00335 #ifdef LONG_VECTOR_SUPPORT 00336 # define IS_LONG_VEC(x) (SHORT_VEC_LENGTH(x) == R_LONG_VEC_TOKEN) 00337 # define SHORT_VEC_LENGTH(x) (((VECSEXP) (x))->vecsxp.length) 00338 # define SHORT_VEC_TRUELENGTH(x) (((VECSEXP) (x))->vecsxp.truelength) 00339 # define LONG_VEC_LENGTH(x) ((R_long_vec_hdr_t *) (x))[-1].lv_length 00340 # define LONG_VEC_TRUELENGTH(x) ((R_long_vec_hdr_t *) (x))[-1].lv_truelength 00341 # define XLENGTH(x) (IS_LONG_VEC(x) ? LONG_VEC_LENGTH(x) : SHORT_VEC_LENGTH(x)) 00342 # define XTRUELENGTH(x) (IS_LONG_VEC(x) ? LONG_VEC_TRUELENGTH(x) : SHORT_VEC_TRUELENGTH(x)) 00343 # define LENGTH(x) (IS_LONG_VEC(x) ? R_BadLongVector(x, __FILE__, __LINE__) : SHORT_VEC_LENGTH(x)) 00344 # define TRUELENGTH(x) (IS_LONG_VEC(x) ? R_BadLongVector(x, __FILE__, __LINE__) : SHORT_VEC_TRUELENGTH(x)) 00345 # define SET_SHORT_VEC_LENGTH(x,v) (SHORT_VEC_LENGTH(x) = (v)) 00346 # define SET_SHORT_VEC_TRUELENGTH(x,v) (SHORT_VEC_TRUELENGTH(x) = (v)) 00347 # define SET_LONG_VEC_LENGTH(x,v) (LONG_VEC_LENGTH(x) = (v)) 00348 # define SET_LONG_VEC_TRUELENGTH(x,v) (LONG_VEC_TRUELENGTH(x) = (v)) 00349 # define SETLENGTH(x,v) do { \ 00350 SEXP sl__x__ = (x); \ 00351 R_xlen_t sl__v__ = (v); \ 00352 if (IS_LONG_VEC(sl__x__)) \ 00353 SET_LONG_VEC_LENGTH(sl__x__, sl__v__); \ 00354 else SET_SHORT_VEC_LENGTH(sl__x__, (R_len_t) sl__v__); \ 00355 } while (0) 00356 # define SET_TRUELENGTH(x,v) do { \ 00357 SEXP sl__x__ = (x); \ 00358 R_xlen_t sl__v__ = (v); \ 00359 if (IS_LONG_VEC(sl__x__)) \ 00360 SET_LONG_VEC_TRUELENGTH(sl__x__, sl__v__); \ 00361 else SET_SHORT_VEC_TRUELENGTH(sl__x__, (R_len_t) sl__v__); \ 00362 } while (0) 00363 # define IS_SCALAR(x, type) (TYPEOF(x) == (type) && SHORT_VEC_LENGTH(x) == 1) 00364 #else 00365 # define SHORT_VEC_LENGTH(x) (((VECSEXP) (x))->vecsxp.length) 00366 # define LENGTH(x) (((VECSEXP) (x))->vecsxp.length) 00367 # define TRUELENGTH(x) (((VECSEXP) (x))->vecsxp.truelength) 00368 # define XLENGTH(x) LENGTH(x) 00369 # define XTRUELENGTH(x) TRUELENGTH(x) 00370 # define SETLENGTH(x,v) ((((VECSEXP) (x))->vecsxp.length)=(v)) 00371 # define SET_TRUELENGTH(x,v) ((((VECSEXP) (x))->vecsxp.truelength)=(v)) 00372 # define SET_SHORT_VEC_LENGTH SETLENGTH 00373 # define SET_SHORT_VEC_TRUELENGTH SET_TRUELENGTH 00374 # define IS_LONG_VEC(x) 0 00375 # define IS_SCALAR(x, type) (TYPEOF(x) == (type) && LENGTH(x) == 1) 00376 #endif 00377 00378 /* Under the generational allocator the data for vector nodes comes 00379 immediately after the node structure, so the data address is a 00380 known offset from the node SEXP. */ 00381 #define DATAPTR(x) (((SEXPREC_ALIGN *) (x)) + 1) 00382 #define CHAR(x) ((const char *) DATAPTR(x)) 00383 #define LOGICAL(x) ((int *) DATAPTR(x)) 00384 #define INTEGER(x) ((int *) DATAPTR(x)) 00385 #define RAW(x) ((Rbyte *) DATAPTR(x)) 00386 #define COMPLEX(x) ((Rcomplex *) DATAPTR(x)) 00387 #define REAL(x) ((double *) DATAPTR(x)) 00388 #define STRING_ELT(x,i) ((SEXP *) DATAPTR(x))[i] 00389 #define VECTOR_ELT(x,i) ((SEXP *) DATAPTR(x))[i] 00390 #define STRING_PTR(x) ((SEXP *) DATAPTR(x)) 00391 #define VECTOR_PTR(x) ((SEXP *) DATAPTR(x)) 00392 00393 /* List Access Macros */ 00394 /* These also work for ... objects */ 00395 #define LISTVAL(x) ((x)->u.listsxp) 00396 #define TAG(e) ((e)->u.listsxp.tagval) 00397 #define CAR(e) ((e)->u.listsxp.carval) 00398 #define CDR(e) ((e)->u.listsxp.cdrval) 00399 #define CAAR(e) CAR(CAR(e)) 00400 #define CDAR(e) CDR(CAR(e)) 00401 #define CADR(e) CAR(CDR(e)) 00402 #define CDDR(e) CDR(CDR(e)) 00403 #define CDDDR(e) CDR(CDR(CDR(e))) 00404 #define CADDR(e) CAR(CDR(CDR(e))) 00405 #define CADDDR(e) CAR(CDR(CDR(CDR(e)))) 00406 #define CAD4R(e) CAR(CDR(CDR(CDR(CDR(e))))) 00407 #define MISSING_MASK 15 /* reserve 4 bits--only 2 uses now */ 00408 #define MISSING(x) ((x)->sxpinfo.gp & MISSING_MASK)/* for closure calls */ 00409 #define SET_MISSING(x,v) do { \ 00410 SEXP __x__ = (x); \ 00411 int __v__ = (v); \ 00412 int __other_flags__ = __x__->sxpinfo.gp & ~MISSING_MASK; \ 00413 __x__->sxpinfo.gp = __other_flags__ | __v__; \ 00414 } while (0) 00415 00416 /* Closure Access Macros */ 00417 #define FORMALS(x) ((x)->u.closxp.formals) 00418 #define BODY(x) ((x)->u.closxp.body) 00419 #define CLOENV(x) ((x)->u.closxp.env) 00420 #define RDEBUG(x) ((x)->sxpinfo.debug) 00421 #define SET_RDEBUG(x,v) (((x)->sxpinfo.debug)=(v)) 00422 #define RSTEP(x) ((x)->sxpinfo.spare) 00423 #define SET_RSTEP(x,v) (((x)->sxpinfo.spare)=(v)) 00424 00425 /* Symbol Access Macros */ 00426 #define PRINTNAME(x) ((x)->u.symsxp.pname) 00427 #define SYMVALUE(x) ((x)->u.symsxp.value) 00428 #define INTERNAL(x) ((x)->u.symsxp.internal) 00429 #define DDVAL_MASK 1 00430 #define DDVAL(x) ((x)->sxpinfo.gp & DDVAL_MASK) /* for ..1, ..2 etc */ 00431 #define SET_DDVAL_BIT(x) (((x)->sxpinfo.gp) |= DDVAL_MASK) 00432 #define UNSET_DDVAL_BIT(x) (((x)->sxpinfo.gp) &= ~DDVAL_MASK) 00433 #define SET_DDVAL(x,v) ((v) ? SET_DDVAL_BIT(x) : UNSET_DDVAL_BIT(x)) /* for ..1, ..2 etc */ 00434 00435 /* Environment Access Macros */ 00436 #define FRAME(x) ((x)->u.envsxp.frame) 00437 #define ENCLOS(x) ((x)->u.envsxp.enclos) 00438 #define HASHTAB(x) ((x)->u.envsxp.hashtab) 00439 #define ENVFLAGS(x) ((x)->sxpinfo.gp) /* for environments */ 00440 #define SET_ENVFLAGS(x,v) (((x)->sxpinfo.gp)=(v)) 00441 00442 #else /* not USE_RINTERNALS */ 00443 // ======================= not USE_RINTERNALS section 00444 00445 typedef struct SEXPREC *SEXP; 00446 00447 #define CHAR(x) R_CHAR(x) 00448 00455 const char *(R_CHAR)(SEXP x); 00456 00457 /* Various tests with macro versions in the second USE_RINTERNALS section */ 00458 00466 Rboolean (Rf_isNull)(SEXP s); 00467 00475 Rboolean (Rf_isSymbol)(SEXP s); 00476 00482 Rboolean (Rf_isLogical)(SEXP s); 00483 00488 Rboolean (Rf_isReal)(SEXP s); 00489 00494 Rboolean (Rf_isComplex)(SEXP s); 00495 00500 Rboolean (Rf_isExpression)(SEXP s); 00501 00508 Rboolean (Rf_isEnvironment)(SEXP s); 00509 00515 Rboolean (Rf_isString)(SEXP s); 00516 00524 Rboolean (Rf_isObject)(SEXP s); 00525 00526 # define IS_SCALAR(x, type) (TYPEOF(x) == (type) && XLENGTH(x) == 1) 00527 #endif /* USE_RINTERNALS */ 00528 00529 #define IS_SIMPLE_SCALAR(x, type) \ 00530 (IS_SCALAR(x, type) && ATTRIB(x) == R_NilValue) 00531 00532 #define NAMEDMAX 2 00533 #define INCREMENT_NAMED(x) do { \ 00534 SEXP __x__ = (x); \ 00535 if (NAMED(__x__) != NAMEDMAX) \ 00536 SET_NAMED(__x__, NAMED(__x__) + 1); \ 00537 } while (0) 00538 00539 #if defined(COMPUTE_REFCNT_VALUES) 00540 # define SET_REFCNT(x,v) (REFCNT(x) = (v)) 00541 # if defined(EXTRA_REFCNT_FIELDS) 00542 # define SET_TRACKREFS(x,v) (TRACKREFS(x) = (v)) 00543 # else 00544 # define SET_TRACKREFS(x,v) ((x)->sxpinfo.spare = ! (v)) 00545 # endif 00546 # define DECREMENT_REFCNT(x) do { \ 00547 SEXP drc__x__ = (x); \ 00548 if (REFCNT(drc__x__) > 0 && REFCNT(drc__x__) < REFCNTMAX) \ 00549 SET_REFCNT(drc__x__, REFCNT(drc__x__) - 1); \ 00550 } while (0) 00551 # define INCREMENT_REFCNT(x) do { \ 00552 SEXP irc__x__ = (x); \ 00553 if (REFCNT(irc__x__) < REFCNTMAX) \ 00554 SET_REFCNT(irc__x__, REFCNT(irc__x__) + 1); \ 00555 } while (0) 00556 #else 00557 # define SET_REFCNT(x,v) do {} while(0) 00558 # define SET_TRACKREFS(x,v) do {} while(0) 00559 # define DECREMENT_REFCNT(x) do {} while(0) 00560 # define INCREMENT_REFCNT(x) do {} while(0) 00561 #endif 00562 00563 #define ENABLE_REFCNT(x) SET_TRACKREFS(x, TRUE) 00564 #define DISABLE_REFCNT(x) SET_TRACKREFS(x, FALSE) 00565 00566 /* Macros for some common idioms. */ 00567 #ifdef SWITCH_TO_REFCNT 00568 # define MAYBE_SHARED(x) (REFCNT(x) > 1) 00569 # define NO_REFERENCES(x) (REFCNT(x) == 0) 00570 # define MARK_NOT_MUTABLE(x) SET_REFCNT(x, REFCNTMAX) 00571 #else 00572 # define MAYBE_SHARED(x) (NAMED(x) > 1) 00573 # define NO_REFERENCES(x) (NAMED(x) == 0) 00574 # define MARK_NOT_MUTABLE(x) SET_NAMED(x, NAMEDMAX) 00575 #endif 00576 #define MAYBE_REFERENCED(x) (! NO_REFERENCES(x)) 00577 #define NOT_SHARED(x) (! MAYBE_SHARED(x)) 00578 00579 /* Complex assignment support */ 00580 /* temporary definition that will need to be refined to distinguish 00581 getter from setter calls */ 00582 #define IS_GETTER_CALL(call) (CADR(call) == R_TmpvalSymbol) 00583 00584 /* Accessor functions. Many are declared using () to avoid the macro 00585 definitions in the USE_RINTERNALS section. 00586 The function STRING_ELT is used as an argument to arrayAssign even 00587 if the macro version is in use. 00588 */ 00589 00590 /* General Cons Cell Attributes */ 00591 00599 SEXP (ATTRIB)(SEXP x); 00600 00607 int (OBJECT)(SEXP x); 00608 int (MARK)(SEXP x); 00609 00616 int (TYPEOF)(SEXP x); 00617 00624 int (NAMED)(SEXP x); 00625 int (REFCNT)(SEXP x); 00626 void (SET_OBJECT)(SEXP x, int v); 00627 void (SET_TYPEOF)(SEXP x, int v); 00628 00636 void (SET_NAMED)(SEXP x, int v); 00637 00647 void SET_ATTRIB(SEXP x, SEXP v); 00648 00657 void DUPLICATE_ATTRIB(SEXP to, SEXP from); 00658 void SHALLOW_DUPLICATE_ATTRIB(SEXP to, SEXP from); 00659 00660 /* S4 object testing */ 00661 00668 int (IS_S4_OBJECT)(SEXP x); 00669 void (SET_S4_OBJECT)(SEXP x); 00670 void (UNSET_S4_OBJECT)(SEXP x); 00671 00672 /* Vector Access Functions */ 00673 int (LENGTH)(SEXP x); 00674 int (TRUELENGTH)(SEXP x); 00675 00684 void (SETLENGTH)(SEXP x, int v); 00685 00694 void (SET_TRUELENGTH)(SEXP x, int v); 00695 00703 R_xlen_t (XLENGTH)(SEXP x); 00704 00713 R_xlen_t (XTRUELENGTH)(SEXP x); 00714 int (IS_LONG_VEC)(SEXP x); 00715 int (LEVELS)(SEXP x); 00716 int (SETLEVELS)(SEXP x, int v); 00717 00723 int *(LOGICAL)(SEXP x); 00724 00731 int *(INTEGER)(SEXP x); 00732 00738 Rbyte *(RAW)(SEXP x); 00739 00745 double *(REAL)(SEXP x); 00746 00752 Rcomplex *(COMPLEX)(SEXP x); 00753 00764 SEXP (STRING_ELT)(SEXP x, R_xlen_t i); 00765 00774 SEXP (VECTOR_ELT)(SEXP x, R_xlen_t i); 00775 00784 void SET_STRING_ELT(SEXP x, R_xlen_t i, SEXP v); 00785 00796 SEXP SET_VECTOR_ELT(SEXP x, R_xlen_t i, SEXP v); 00797 SEXP *(STRING_PTR)(SEXP x); 00798 SEXP * NORET (VECTOR_PTR)(SEXP x); 00799 00800 #ifdef LONG_VECTOR_SUPPORT 00801 R_len_t NORET R_BadLongVector(SEXP, const char *, int); 00802 #endif 00803 00804 /* List Access Functions */ 00805 /* These also work for ... objects */ 00806 #define CONS(a, b) cons((a), (b)) /* data lists */ 00807 #define LCONS(a, b) lcons((a), (b)) /* language lists */ 00808 00815 SEXP (TAG)(SEXP e); 00816 00824 SEXP (CAR)(SEXP e); 00831 SEXP (CDR)(SEXP e); 00832 00836 SEXP (CAAR)(SEXP e); 00837 00841 SEXP (CDAR)(SEXP e); 00842 00846 SEXP (CADR)(SEXP e); 00847 00851 SEXP (CDDR)(SEXP e); 00852 00856 SEXP (CDDDR)(SEXP e); 00857 00861 SEXP (CADDR)(SEXP e); 00862 00866 SEXP (CADDDR)(SEXP e); 00867 00871 SEXP (CAD4R)(SEXP e); 00872 int (MISSING)(SEXP x); 00873 void (SET_MISSING)(SEXP x, int v); 00874 00882 void SET_TAG(SEXP x, SEXP y); 00883 00892 SEXP SETCAR(SEXP x, SEXP y); 00893 00901 SEXP SETCDR(SEXP x, SEXP y); 00902 00912 SEXP SETCADR(SEXP x, SEXP y); 00913 00923 SEXP SETCADDR(SEXP x, SEXP y); 00924 00934 SEXP SETCADDDR(SEXP x, SEXP y); 00935 00945 SEXP SETCAD4R(SEXP e, SEXP y); 00946 00947 SEXP CONS_NR(SEXP a, SEXP b); 00948 00949 /* Closure Access Functions */ 00950 00957 SEXP (FORMALS)(SEXP x); 00958 00965 SEXP (BODY)(SEXP x); 00966 00973 SEXP (CLOENV)(SEXP x); 00974 00982 int (RDEBUG)(SEXP x); 00983 int (RSTEP)(SEXP x); 00984 00991 int (RTRACE)(SEXP x); 00992 01000 void (SET_RDEBUG)(SEXP x, int v); 01001 void (SET_RSTEP)(SEXP x, int v); 01002 01010 void (SET_RTRACE)(SEXP x, int v); 01011 void SET_FORMALS(SEXP x, SEXP v); 01012 void SET_BODY(SEXP x, SEXP v); 01013 01022 void SET_CLOENV(SEXP x, SEXP v); 01023 01024 /* Symbol Access Functions */ 01025 01032 SEXP (PRINTNAME)(SEXP x); 01033 01042 SEXP (SYMVALUE)(SEXP x); 01043 01052 SEXP (INTERNAL)(SEXP x); 01053 01061 int (DDVAL)(SEXP x); 01062 void (SET_DDVAL)(SEXP x, int v); 01063 void SET_PRINTNAME(SEXP x, SEXP v); 01064 01075 void SET_SYMVALUE(SEXP x, SEXP v); 01076 01086 void SET_INTERNAL(SEXP x, SEXP v); 01087 01088 /* Environment Access Functions */ 01089 01097 SEXP (FRAME)(SEXP x); 01098 01105 SEXP (ENCLOS)(SEXP x); 01106 SEXP (HASHTAB)(SEXP x); 01107 int (ENVFLAGS)(SEXP x); 01108 void (SET_ENVFLAGS)(SEXP x, int v); 01109 void SET_FRAME(SEXP x, SEXP v); 01110 void SET_ENCLOS(SEXP x, SEXP v); 01111 void SET_HASHTAB(SEXP x, SEXP v); 01112 01113 /* Promise Access Functions */ 01114 /* First five have macro versions in Defn.h */ 01115 01123 SEXP (PRCODE)(SEXP x); 01124 01133 SEXP (PRENV)(SEXP x); 01134 01142 SEXP (PRVALUE)(SEXP x); 01143 int (PRSEEN)(SEXP x); 01144 void (SET_PRSEEN)(SEXP x, int v); 01145 void SET_PRENV(SEXP x, SEXP v); 01146 01158 void SET_PRVALUE(SEXP x, SEXP v); 01159 void SET_PRCODE(SEXP x, SEXP v); 01160 void SET_PRSEEN(SEXP x, int v); 01161 01162 /* Hashing Functions */ 01163 /* There are macro versions in Defn.h */ 01164 int (HASHASH)(SEXP x); 01165 int (HASHVALUE)(SEXP x); 01166 void (SET_HASHASH)(SEXP x, int v); 01167 void (SET_HASHVALUE)(SEXP x, int v); 01168 01169 01170 /* External pointer access macros */ 01171 #define EXTPTR_PTR(x) CAR(x) 01172 #define EXTPTR_PROT(x) CDR(x) 01173 #define EXTPTR_TAG(x) TAG(x) 01174 01175 /* Bytecode access macros */ 01176 #define BCODE_CODE(x) CAR(x) 01177 #define BCODE_CONSTS(x) CDR(x) 01178 #define BCODE_EXPR(x) TAG(x) 01179 #define isByteCode(x) (TYPEOF(x)==BCODESXP) 01180 01181 /* Pointer Protection and Unprotection */ 01182 #define PROTECT(s) Rf_protect(s) 01183 #define UNPROTECT(n) Rf_unprotect(n) 01184 #define UNPROTECT_PTR(s) Rf_unprotect_ptr(s) 01185 01186 /* We sometimes need to coerce a protected value and place the new 01187 coerced value under protection. For these cases PROTECT_WITH_INDEX 01188 saves an index of the protection location that can be used to 01189 replace the protected value using REPROTECT. */ 01190 typedef int PROTECT_INDEX; 01191 #define PROTECT_WITH_INDEX(x,i) R_ProtectWithIndex(x,i) 01192 #define REPROTECT(x,i) R_Reprotect(x,i) 01193 01194 /* Evaluation Environment */ 01195 LibExtern SEXP R_GlobalEnv; /* The "global" environment */ 01196 01197 LibExtern SEXP R_EmptyEnv; /* An empty environment at the root of the 01198 environment tree */ 01199 LibExtern SEXP R_BaseEnv; /* The base environment; formerly R_NilValue */ 01200 LibExtern SEXP R_BaseNamespace; /* The (fake) namespace for base */ 01201 LibExtern SEXP R_NamespaceRegistry;/* Registry for registered namespaces */ 01202 01203 LibExtern SEXP R_Srcref; /* Current srcref, for debuggers */ 01204 01205 /* Special Values */ 01206 LibExtern SEXP R_NilValue; /* The nil object */ 01207 LibExtern SEXP R_UnboundValue; /* Unbound marker */ 01208 LibExtern SEXP R_MissingArg; /* Missing argument marker */ 01209 #ifdef __MAIN__ 01210 attribute_hidden 01211 #else 01212 extern 01213 #endif 01214 SEXP R_RestartToken; /* Marker for restarted function calls */ 01215 01216 /* Symbol Table Shortcuts */ 01217 LibExtern SEXP R_baseSymbol; // <-- backcompatible version of: 01218 LibExtern SEXP R_BaseSymbol; // "base" 01219 LibExtern SEXP R_BraceSymbol; /* "{" */ 01220 LibExtern SEXP R_Bracket2Symbol; /* "[[" */ 01221 LibExtern SEXP R_BracketSymbol; /* "[" */ 01222 LibExtern SEXP R_ClassSymbol; /* "class" */ 01223 LibExtern SEXP R_DeviceSymbol; /* ".Device" */ 01224 LibExtern SEXP R_DimNamesSymbol; /* "dimnames" */ 01225 LibExtern SEXP R_DimSymbol; /* "dim" */ 01226 LibExtern SEXP R_DollarSymbol; /* "$" */ 01227 LibExtern SEXP R_DotsSymbol; /* "..." */ 01228 LibExtern SEXP R_DoubleColonSymbol;// "::" 01229 LibExtern SEXP R_DropSymbol; /* "drop" */ 01230 LibExtern SEXP R_LastvalueSymbol; /* ".Last.value" */ 01231 LibExtern SEXP R_LevelsSymbol; /* "levels" */ 01232 LibExtern SEXP R_ModeSymbol; /* "mode" */ 01233 LibExtern SEXP R_NaRmSymbol; /* "na.rm" */ 01234 LibExtern SEXP R_NameSymbol; /* "name" */ 01235 LibExtern SEXP R_NamesSymbol; /* "names" */ 01236 LibExtern SEXP R_NamespaceEnvSymbol;// ".__NAMESPACE__." 01237 LibExtern SEXP R_PackageSymbol; /* "package" */ 01238 LibExtern SEXP R_PreviousSymbol; /* "previous" */ 01239 LibExtern SEXP R_QuoteSymbol; /* "quote" */ 01240 LibExtern SEXP R_RowNamesSymbol; /* "row.names" */ 01241 LibExtern SEXP R_SeedsSymbol; /* ".Random.seed" */ 01242 LibExtern SEXP R_SortListSymbol; /* "sort.list" */ 01243 LibExtern SEXP R_SourceSymbol; /* "source" */ 01244 LibExtern SEXP R_SpecSymbol; // "spec" 01245 LibExtern SEXP R_TripleColonSymbol;// ":::" 01246 LibExtern SEXP R_TspSymbol; /* "tsp" */ 01247 01248 LibExtern SEXP R_dot_defined; /* ".defined" */ 01249 LibExtern SEXP R_dot_Method; /* ".Method" */ 01250 LibExtern SEXP R_dot_packageName;// ".packageName" 01251 LibExtern SEXP R_dot_target; /* ".target" */ 01252 LibExtern SEXP R_dot_Generic; /* ".Generic" */ 01253 01254 /* Missing Values - others from Arith.h */ 01255 #define NA_STRING R_NaString 01256 LibExtern SEXP R_NaString; /* NA_STRING as a CHARSXP */ 01257 LibExtern SEXP R_BlankString; /* "" as a CHARSXP */ 01258 LibExtern SEXP R_BlankScalarString; /* "" as a STRSXP */ 01259 01260 /* srcref related functions */ 01261 SEXP R_GetCurrentSrcref(int skip); 01262 SEXP R_GetSrcFilename(SEXP srcref); 01263 01264 /*--- FUNCTIONS ------------------------------------------------------ */ 01265 01266 /* Type Coercions of all kinds */ 01267 01268 SEXP Rf_asChar(SEXP x); 01269 SEXP Rf_coerceVector(SEXP v, SEXPTYPE type); 01270 SEXP Rf_PairToVectorList(SEXP x); 01271 SEXP Rf_VectorToPairList(SEXP x); 01272 SEXP Rf_asCharacterFactor(SEXP x); 01273 int Rf_asLogical(SEXP x); 01274 int Rf_asInteger(SEXP x); 01275 double Rf_asReal(SEXP x); 01276 Rcomplex Rf_asComplex(SEXP x); 01277 01278 01279 #ifndef R_ALLOCATOR_TYPE 01280 #define R_ALLOCATOR_TYPE 01281 typedef struct R_allocator R_allocator_t; 01282 #endif 01283 01284 /* Other Internally Used Functions, excluding those which are inline-able*/ 01285 01286 char * Rf_acopy_string(const char * in); 01287 void Rf_addMissingVarsToNewEnv(SEXP, SEXP); 01288 SEXP Rf_alloc3DArray(SEXPTYPE mode, int nrow, int ncol, int nface); 01289 SEXP Rf_allocArray(SEXPTYPE mode, SEXP dims); 01290 SEXP Rf_allocFormalsList2(SEXP sym1, SEXP sym2); 01291 SEXP Rf_allocFormalsList3(SEXP sym1, SEXP sym2, SEXP sym3); 01292 SEXP Rf_allocFormalsList4(SEXP sym1, SEXP sym2, SEXP sym3, SEXP sym4); 01293 SEXP Rf_allocFormalsList5(SEXP sym1, SEXP sym2, SEXP sym3, SEXP sym4, SEXP sym5); 01294 SEXP Rf_allocFormalsList6(SEXP sym1, SEXP sym2, SEXP sym3, SEXP sym4, SEXP sym5, SEXP sym6); 01295 SEXP Rf_allocMatrix(SEXPTYPE mode, int nrow, int ncol); 01296 01307 SEXP Rf_allocList(int n); 01308 01313 SEXP Rf_allocS4Object(void); 01314 01324 SEXP Rf_allocSExp(SEXPTYPE t); 01325 SEXP Rf_allocVector3(SEXPTYPE type, R_xlen_t length, R_allocator_t* allocator); 01326 R_xlen_t Rf_any_duplicated(SEXP x, Rboolean from_last); 01327 R_xlen_t Rf_any_duplicated3(SEXP x, SEXP incomp, Rboolean from_last); 01328 SEXP Rf_applyClosure(SEXP call, SEXP op, SEXP arglist, SEXP rho, SEXP suppliedvars); 01329 SEXP Rf_arraySubscript(int dim, SEXP s, SEXP dims, SEXP (*)(SEXP,SEXP dng), 01330 SEXP (*)(SEXP, int strg), SEXP x); 01331 SEXP Rf_classgets(SEXP vec, SEXP klass); 01332 01344 SEXP Rf_cons(SEXP car, SEXP cdr); 01345 void Rf_copyMatrix(SEXP s, SEXP t, Rboolean byrow); 01346 void Rf_copyListMatrix(SEXP s, SEXP t, Rboolean byrow); 01347 01365 void Rf_copyMostAttrib(SEXP inp, SEXP ans); 01366 void Rf_copyVector(SEXP s, SEXP t); 01367 int Rf_countContexts(int ctxttype, int browser); 01368 SEXP Rf_CreateTag(SEXP x); 01369 void Rf_defineVar(SEXP symbol, SEXP value, SEXP rho); 01370 SEXP Rf_dimgets(SEXP vec, SEXP val); 01371 SEXP Rf_dimnamesgets(SEXP vec, SEXP val); 01372 SEXP Rf_DropDims(SEXP x); 01373 SEXP Rf_duplicate(SEXP s); 01374 SEXP Rf_shallow_duplicate(SEXP s); 01375 SEXP Rf_lazy_duplicate(SEXP s); 01376 /* the next really should not be here and is also in Defn.h */ 01377 SEXP Rf_duplicated(SEXP x, Rboolean from_last); 01378 Rboolean R_envHasNoSpecialSymbols(SEXP env); 01379 01388 SEXP Rf_eval(SEXP e, SEXP rho); 01389 SEXP Rf_findFun(SEXP symbol, SEXP rho); 01390 void Rf_findFunctionForBody(SEXP body); 01391 01405 SEXP Rf_findVar(SEXP symbol, SEXP rho); 01406 SEXP Rf_findVarInFrame(SEXP rho, SEXP symbol); 01407 01425 SEXP Rf_findVarInFrame3(SEXP rho, SEXP symbol, Rboolean doGet); 01426 01444 SEXP Rf_getAttrib(SEXP vec, SEXP name); 01445 SEXP Rf_GetArrayDimnames(SEXP x); 01446 SEXP Rf_GetColNames(SEXP dimnames); 01447 void Rf_GetMatrixDimnames(SEXP x, SEXP* rl, SEXP* cl, const char** rn, const char** cn); 01448 SEXP Rf_GetOption(SEXP tag, SEXP rho); /* pre-2.13.0 compatibility */ 01449 SEXP Rf_GetOption1(SEXP tag); 01450 int Rf_GetOptionDigits(void); 01451 int Rf_GetOptionWidth(void); 01452 SEXP Rf_GetRowNames(SEXP dimnames); 01453 void Rf_gsetVar(SEXP symbol, SEXP value, SEXP rho); 01454 01467 SEXP Rf_install(const char * name); 01468 SEXP Rf_installChar(SEXP charSXP); 01469 SEXP Rf_installDDVAL(int i); 01470 SEXP Rf_installS3Signature(const char *, const char *); 01471 Rboolean Rf_isFree(SEXP val); 01472 Rboolean Rf_isOrdered(SEXP s); 01473 Rboolean Rf_isUnmodifiedSpecSym(SEXP sym, SEXP env); 01474 Rboolean Rf_isUnordered(SEXP s); 01475 Rboolean Rf_isUnsorted(SEXP x, Rboolean strictly); 01476 SEXP Rf_lengthgets(SEXP x, R_len_t len); 01477 SEXP Rf_xlengthgets(SEXP x, R_xlen_t len); 01478 SEXP R_lsInternal(SEXP env, Rboolean all); 01479 SEXP R_lsInternal3(SEXP env, Rboolean all, Rboolean sorted); 01480 SEXP Rf_match(SEXP itable, SEXP ix, int nmatch); 01481 SEXP Rf_matchE(SEXP itable, SEXP ix, int nmatch, SEXP env); 01482 SEXP Rf_namesgets(SEXP vec, SEXP val); 01483 01496 SEXP Rf_mkChar(const char * name); 01497 01515 SEXP Rf_mkCharLen(const char * name, int len); 01516 Rboolean Rf_NonNullStringMatch(SEXP s, SEXP t); 01517 int Rf_ncols(SEXP s); 01518 int Rf_nrows(SEXP s); 01519 SEXP Rf_nthcdr(SEXP s, int n); 01520 01521 // ../main/character.c : 01522 typedef enum {Bytes, Chars, Width} nchar_type; 01523 int R_nchar(SEXP string, nchar_type type_, 01524 Rboolean allowNA, Rboolean keepNA, const char* msg_name); 01525 01526 Rboolean Rf_pmatch(SEXP formal, SEXP tag, Rboolean exact); 01527 Rboolean Rf_psmatch(const char * f, const char * t, Rboolean exact); 01528 void Rf_PrintValue(SEXP s); 01529 #ifndef INLINE_PROTECT 01530 01537 SEXP Rf_protect(SEXP); 01538 #endif 01539 void Rf_readS3VarsFromFrame(SEXP, SEXP*, SEXP*, SEXP*, SEXP*, SEXP*, SEXP*); 01540 01562 SEXP Rf_setAttrib(SEXP vec, SEXP name, SEXP val); 01563 void Rf_setSVector(SEXP* vec, int len, SEXP val); 01564 void Rf_setVar(SEXP symbol, SEXP value, SEXP rho); 01565 SEXP Rf_stringSuffix(SEXP string, int fromIndex); 01566 SEXPTYPE Rf_str2type(const char * s); 01567 Rboolean Rf_StringBlank(SEXP x); 01568 SEXP Rf_substitute(SEXP lang,SEXP rho); 01569 const char * Rf_translateChar(SEXP x); 01570 const char * Rf_translateChar0(SEXP x); 01571 01582 const char * Rf_translateCharUTF8(SEXP x); 01583 01592 const char * Rf_type2char(SEXPTYPE t); 01593 SEXP Rf_type2rstr(SEXPTYPE t); 01594 SEXP Rf_type2str(SEXPTYPE t); 01595 SEXP Rf_type2str_nowarn(SEXPTYPE t); 01596 #ifndef INLINE_PROTECT 01597 01608 void Rf_unprotect(int); 01609 #endif 01610 01620 void Rf_unprotect_ptr(SEXP s); 01621 01622 void NORET R_signal_protect_error(void); 01623 void NORET R_signal_unprotect_error(void); 01624 void NORET R_signal_reprotect_error(PROTECT_INDEX i); 01625 01626 #ifndef INLINE_PROTECT 01627 01640 void R_ProtectWithIndex(SEXP, PROTECT_INDEX *); 01641 01659 void R_Reprotect(SEXP, PROTECT_INDEX); 01660 #endif 01661 SEXP R_tryEval(SEXP e, SEXP env, int * ErrorOccurred); 01662 SEXP R_tryEvalSilent(SEXP e, SEXP env, int * ErrorOccurred); 01663 const char *R_curErrorBuf(); 01664 01665 Rboolean Rf_isS4(SEXP s); 01666 SEXP Rf_asS4(SEXP s, Rboolean flag, int complete); 01667 SEXP Rf_S3Class(SEXP obj); 01668 int Rf_isBasicClass(const char * ss); 01669 01670 Rboolean R_cycle_detected(SEXP s, SEXP child); 01671 01672 typedef enum { 01673 CE_NATIVE = 0, 01674 CE_UTF8 = 1, 01675 CE_LATIN1 = 2, 01676 CE_BYTES = 3, 01677 CE_SYMBOL = 5, 01678 CE_ANY =99 01679 } cetype_t; 01680 01681 cetype_t Rf_getCharCE(SEXP x); 01682 01698 SEXP Rf_mkCharCE(const char * name, cetype_t enc); 01699 01721 SEXP Rf_mkCharLenCE(const char * name, int len, cetype_t enc); 01722 const char *Rf_reEnc(const char *x, cetype_t ce_in, cetype_t ce_out, int subst); 01723 01724 /* return(.) NOT reached : for -Wall */ 01725 #define error_return(msg) { Rf_error(msg); return R_NilValue; } 01726 #define errorcall_return(cl,msg){ Rf_errorcall(cl, msg); return R_NilValue; } 01727 01728 #ifdef __MAIN__ 01729 #undef extern 01730 #undef LibExtern 01731 #endif 01732 01733 /* Calling a function with arguments evaluated */ 01734 SEXP R_forceAndCall(SEXP e, int n, SEXP rho); 01735 01736 /* External pointer interface */ 01737 01749 SEXP R_MakeExternalPtr(void *p, SEXP tag, SEXP prot); 01750 01757 void *R_ExternalPtrAddr(SEXP s); 01758 01765 SEXP R_ExternalPtrTag(SEXP s); 01766 01773 SEXP R_ExternalPtrProtected(SEXP s); 01774 01779 void R_ClearExternalPtr(SEXP s); 01780 01787 void R_SetExternalPtrAddr(SEXP s, void *p); 01788 01795 void R_SetExternalPtrTag(SEXP s, SEXP tag); 01796 01803 void R_SetExternalPtrProtected(SEXP s, SEXP p); 01804 01805 /* Finalization interface */ 01806 typedef void (*R_CFinalizer_t)(SEXP); 01807 void R_RegisterFinalizer(SEXP s, SEXP fun); 01808 void R_RegisterCFinalizer(SEXP s, R_CFinalizer_t fun); 01809 void R_RegisterFinalizerEx(SEXP s, SEXP fun, Rboolean onexit); 01810 void R_RegisterCFinalizerEx(SEXP s, R_CFinalizer_t fun, Rboolean onexit); 01811 void R_RunPendingFinalizers(void); 01812 01813 /* Weak reference interface */ 01814 SEXP R_MakeWeakRef(SEXP key, SEXP val, SEXP fin, Rboolean onexit); 01815 SEXP R_MakeWeakRefC(SEXP key, SEXP val, R_CFinalizer_t fin, Rboolean onexit); 01816 SEXP R_WeakRefKey(SEXP w); 01817 SEXP R_WeakRefValue(SEXP w); 01818 void R_RunWeakRefFinalizer(SEXP w); 01819 01820 SEXP R_PromiseExpr(SEXP p); 01821 SEXP R_ClosureExpr(SEXP p); 01822 void R_initialize_bcode(void); 01823 SEXP R_bcEncode(SEXP bytes); 01824 SEXP R_bcDecode(SEXP code); 01825 void R_registerBC(SEXP bcBytes, SEXP bcode); 01826 Rboolean R_checkConstants(Rboolean abortOnError); 01827 #define PREXPR(e) R_PromiseExpr(e) 01828 #define BODY_EXPR(e) R_ClosureExpr(e) 01829 01830 /* Protected evaluation */ 01831 Rboolean R_ToplevelExec(void (*fun)(void *), void *data); 01832 SEXP R_ExecWithCleanup(SEXP (*fun)(void *), void *data, 01833 void (*cleanfun)(void *), void *cleandata); 01834 01835 /* Environment and Binding Features */ 01836 void R_RestoreHashCount(SEXP rho); 01837 Rboolean R_IsPackageEnv(SEXP rho); 01838 SEXP R_PackageEnvName(SEXP rho); 01839 SEXP R_FindPackageEnv(SEXP info); 01840 Rboolean R_IsNamespaceEnv(SEXP rho); 01841 SEXP R_NamespaceEnvSpec(SEXP rho); 01842 SEXP R_FindNamespace(SEXP info); 01843 void R_LockEnvironment(SEXP env, Rboolean bindings); 01844 Rboolean R_EnvironmentIsLocked(SEXP env); 01845 void R_LockBinding(SEXP sym, SEXP env); 01846 void R_unLockBinding(SEXP sym, SEXP env); 01847 void R_MakeActiveBinding(SEXP sym, SEXP fun, SEXP env); 01848 Rboolean R_BindingIsLocked(SEXP sym, SEXP env); 01849 Rboolean R_BindingIsActive(SEXP sym, SEXP env); 01850 Rboolean R_HasFancyBindings(SEXP rho); 01851 01852 01853 /* ../main/errors.c : */ 01854 /* needed for R_load/savehistory handling in front ends */ 01855 #if defined(__GNUC__) && __GNUC__ >= 3 01856 void Rf_errorcall(SEXP call, const char * format, ...) __attribute__((noreturn)); 01857 #else 01858 void Rf_errorcall(SEXP, const char *, ...); 01859 #endif 01860 void Rf_warningcall(SEXP call, const char * format, ...); 01861 void Rf_warningcall_immediate(SEXP call, const char * format, ...); 01862 01863 /* Save/Load Interface */ 01864 #define R_XDR_DOUBLE_SIZE 8 01865 #define R_XDR_INTEGER_SIZE 4 01866 01867 void R_XDREncodeDouble(double d, void *buf); 01868 double R_XDRDecodeDouble(void *buf); 01869 void R_XDREncodeInteger(int i, void *buf); 01870 int R_XDRDecodeInteger(void *buf); 01871 01872 typedef void *R_pstream_data_t; 01873 01874 typedef enum { 01875 R_pstream_any_format, 01876 R_pstream_ascii_format, 01877 R_pstream_binary_format, 01878 R_pstream_xdr_format, 01879 R_pstream_asciihex_format 01880 } R_pstream_format_t; 01881 01882 typedef struct R_outpstream_st *R_outpstream_t; 01883 struct R_outpstream_st { 01884 R_pstream_data_t data; 01885 R_pstream_format_t type; 01886 int version; 01887 void (*OutChar)(R_outpstream_t, int); 01888 void (*OutBytes)(R_outpstream_t, void *, int); 01889 SEXP (*OutPersistHookFunc)(SEXP, SEXP); 01890 SEXP OutPersistHookData; 01891 }; 01892 01893 typedef struct R_inpstream_st *R_inpstream_t; 01894 struct R_inpstream_st { 01895 R_pstream_data_t data; 01896 R_pstream_format_t type; 01897 int (*InChar)(R_inpstream_t); 01898 void (*InBytes)(R_inpstream_t, void *, int); 01899 SEXP (*InPersistHookFunc)(SEXP, SEXP); 01900 SEXP InPersistHookData; 01901 }; 01902 01903 void R_InitInPStream(R_inpstream_t stream, R_pstream_data_t data, 01904 R_pstream_format_t type, 01905 int (*inchar)(R_inpstream_t), 01906 void (*inbytes)(R_inpstream_t, void *, int), 01907 SEXP (*phook)(SEXP, SEXP), SEXP pdata); 01908 void R_InitOutPStream(R_outpstream_t stream, R_pstream_data_t data, 01909 R_pstream_format_t type, int version, 01910 void (*outchar)(R_outpstream_t, int), 01911 void (*outbytes)(R_outpstream_t, void *, int), 01912 SEXP (*phook)(SEXP, SEXP), SEXP pdata); 01913 01914 void R_InitFileInPStream(R_inpstream_t stream, FILE *fp, 01915 R_pstream_format_t type, 01916 SEXP (*phook)(SEXP, SEXP), SEXP pdata); 01917 void R_InitFileOutPStream(R_outpstream_t stream, FILE *fp, 01918 R_pstream_format_t type, int version, 01919 SEXP (*phook)(SEXP, SEXP), SEXP pdata); 01920 01921 #ifdef NEED_CONNECTION_PSTREAMS 01922 /* The connection interface is not available to packages. To 01923 allow limited use of connection pointers this defines the opaque 01924 pointer type. */ 01925 #ifndef HAVE_RCONNECTION_TYPEDEF 01926 typedef struct Rconn *Rconnection; 01927 #define HAVE_RCONNECTION_TYPEDEF 01928 #endif 01929 void R_InitConnOutPStream(R_outpstream_t stream, Rconnection con, 01930 R_pstream_format_t type, int version, 01931 SEXP (*phook)(SEXP, SEXP), SEXP pdata); 01932 void R_InitConnInPStream(R_inpstream_t stream, Rconnection con, 01933 R_pstream_format_t type, 01934 SEXP (*phook)(SEXP, SEXP), SEXP pdata); 01935 #endif 01936 01937 void R_Serialize(SEXP s, R_outpstream_t ops); 01938 SEXP R_Unserialize(R_inpstream_t ips); 01939 01940 /* slot management (in attrib.c) */ 01941 SEXP R_do_slot(SEXP obj, SEXP name); 01942 SEXP R_do_slot_assign(SEXP obj, SEXP name, SEXP value); 01943 int R_has_slot(SEXP obj, SEXP name); 01944 /* S3-S4 class (inheritance), attrib.c */ 01945 SEXP R_S4_extends(SEXP klass, SEXP useTable); 01946 01947 /* class definition, new objects (objects.c) */ 01948 SEXP R_do_MAKE_CLASS(const char *what); 01949 SEXP R_getClassDef (const char *what); 01950 SEXP R_getClassDef_R(SEXP what); 01951 Rboolean R_has_methods_attached(void); 01952 Rboolean R_isVirtualClass(SEXP class_def, SEXP env); 01953 Rboolean R_extends (SEXP class1, SEXP class2, SEXP env); 01954 SEXP R_do_new_object(SEXP class_def); 01955 /* supporting a C-level version of is(., .) : */ 01956 int R_check_class_and_super(SEXP x, const char **valid, SEXP rho); 01957 int R_check_class_etc (SEXP x, const char **valid); 01958 01959 /* preserve objects across GCs */ 01960 01969 void R_PreserveObject(SEXP object); 01970 01979 void R_ReleaseObject(SEXP object); 01980 01981 /* Shutdown actions */ 01982 void R_dot_Last(void); /* in main.c */ 01983 void R_RunExitFinalizers(void); /* in memory.c */ 01984 01985 /* Replacements for popen and system */ 01986 #ifdef HAVE_POPEN 01987 FILE *R_popen(const char * command, const char * type); 01988 #endif 01989 int R_system(const char * command); 01990 01991 /* R_compute_identical: C version of identical() function 01992 The third arg to R_compute_identical() consists of bitmapped flags for non-default options: 01993 currently the first 4 default to TRUE, so the flag is set for FALSE values: 01994 1 = !NUM_EQ 01995 2 = !SINGLE_NA 01996 4 = !ATTR_AS_SET 01997 8 = !IGNORE_BYTECODE 01998 16 = !IGNORE_ENV 01999 Default from R's default: 16 02000 */ 02001 Rboolean R_compute_identical(SEXP x, SEXP y, int flags); 02002 02003 SEXP R_body_no_src(SEXP x); // body(x) without "srcref" etc, ../main/utils.c 02004 02005 /* C version of R's indx <- order(..., na.last, decreasing) : 02006 e.g. arglist = Rf_lang2(x,y) or Rf_lang3(x,y,z) */ 02007 void R_orderVector (int *indx, int n, SEXP arglist, Rboolean nalast, Rboolean decreasing); 02008 // C version of R's indx <- order(x, na.last, decreasing) : 02009 void R_orderVector1(int *indx, int n, SEXP x, Rboolean nalast, Rboolean decreasing); 02010 02011 #ifndef R_NO_REMAP 02012 #define acopy_string Rf_acopy_string 02013 #define addMissingVarsToNewEnv Rf_addMissingVarsToNewEnv 02014 #define alloc3DArray Rf_alloc3DArray 02015 #define allocArray Rf_allocArray 02016 #define allocFormalsList2 Rf_allocFormalsList2 02017 #define allocFormalsList3 Rf_allocFormalsList3 02018 #define allocFormalsList4 Rf_allocFormalsList4 02019 #define allocFormalsList5 Rf_allocFormalsList5 02020 #define allocFormalsList6 Rf_allocFormalsList6 02021 #define allocList Rf_allocList 02022 #define allocMatrix Rf_allocMatrix 02023 #define allocS4Object Rf_allocS4Object 02024 #define allocSExp Rf_allocSExp 02025 #define allocVector Rf_allocVector 02026 #define allocVector3 Rf_allocVector3 02027 #define any_duplicated Rf_any_duplicated 02028 #define any_duplicated3 Rf_any_duplicated3 02029 #define applyClosure Rf_applyClosure 02030 #define arraySubscript Rf_arraySubscript 02031 #define asChar Rf_asChar 02032 #define asCharacterFactor Rf_asCharacterFactor 02033 #define asComplex Rf_asComplex 02034 #define asInteger Rf_asInteger 02035 #define asLogical Rf_asLogical 02036 #define asReal Rf_asReal 02037 #define asS4 Rf_asS4 02038 #define classgets Rf_classgets 02039 #define coerceVector Rf_coerceVector 02040 #define conformable Rf_conformable 02041 #define cons Rf_cons 02042 #define copyListMatrix Rf_copyListMatrix 02043 #define copyMatrix Rf_copyMatrix 02044 #define copyMostAttrib Rf_copyMostAttrib 02045 #define copyVector Rf_copyVector 02046 #define countContexts Rf_countContexts 02047 #define CreateTag Rf_CreateTag 02048 #define defineVar Rf_defineVar 02049 #define dimgets Rf_dimgets 02050 #define dimnamesgets Rf_dimnamesgets 02051 #define DropDims Rf_DropDims 02052 #define duplicate Rf_duplicate 02053 #define duplicated Rf_duplicated 02054 #define elt Rf_elt 02055 #define errorcall Rf_errorcall 02056 #define eval Rf_eval 02057 #define findFun Rf_findFun 02058 #define findFunctionForBody Rf_findFunctionForBody 02059 #define findVar Rf_findVar 02060 #define findVarInFrame Rf_findVarInFrame 02061 #define findVarInFrame3 Rf_findVarInFrame3 02062 #define GetArrayDimnames Rf_GetArrayDimnames 02063 #define getAttrib Rf_getAttrib 02064 #define getCharCE Rf_getCharCE 02065 #define GetColNames Rf_GetColNames 02066 #define GetMatrixDimnames Rf_GetMatrixDimnames 02067 #define GetOption1 Rf_GetOption1 02068 #define GetOptionDigits Rf_GetOptionDigits 02069 #define GetOptionWidth Rf_GetOptionWidth 02070 #define GetOption Rf_GetOption 02071 #define GetRowNames Rf_GetRowNames 02072 #define gsetVar Rf_gsetVar 02073 #define inherits Rf_inherits 02074 #define install Rf_install 02075 #define installChar Rf_installChar 02076 #define installDDVAL Rf_installDDVAL 02077 #define installS3Signature Rf_installS3Signature 02078 #define isArray Rf_isArray 02079 #define isBasicClass Rf_isBasicClass 02080 #define isComplex Rf_isComplex 02081 #define isEnvironment Rf_isEnvironment 02082 #define isExpression Rf_isExpression 02083 #define isFactor Rf_isFactor 02084 #define isFrame Rf_isFrame 02085 #define isFree Rf_isFree 02086 #define isFunction Rf_isFunction 02087 #define isInteger Rf_isInteger 02088 #define isLanguage Rf_isLanguage 02089 #define isList Rf_isList 02090 #define isLogical Rf_isLogical 02091 #define isSymbol Rf_isSymbol 02092 #define isMatrix Rf_isMatrix 02093 #define isNewList Rf_isNewList 02094 #define isNull Rf_isNull 02095 #define isNumeric Rf_isNumeric 02096 #define isNumber Rf_isNumber 02097 #define isObject Rf_isObject 02098 #define isOrdered Rf_isOrdered 02099 #define isPairList Rf_isPairList 02100 #define isPrimitive Rf_isPrimitive 02101 #define isReal Rf_isReal 02102 #define isS4 Rf_isS4 02103 #define isString Rf_isString 02104 #define isTs Rf_isTs 02105 #define isUnmodifiedSpecSym Rf_isUnmodifiedSpecSym 02106 #define isUnordered Rf_isUnordered 02107 #define isUnsorted Rf_isUnsorted 02108 #define isUserBinop Rf_isUserBinop 02109 #define isValidString Rf_isValidString 02110 #define isValidStringF Rf_isValidStringF 02111 #define isVector Rf_isVector 02112 #define isVectorAtomic Rf_isVectorAtomic 02113 #define isVectorizable Rf_isVectorizable 02114 #define isVectorList Rf_isVectorList 02115 #define lang1 Rf_lang1 02116 #define lang2 Rf_lang2 02117 #define lang3 Rf_lang3 02118 #define lang4 Rf_lang4 02119 #define lang5 Rf_lang5 02120 #define lang6 Rf_lang6 02121 #define lastElt Rf_lastElt 02122 #define lazy_duplicate Rf_lazy_duplicate 02123 #define lcons Rf_lcons 02124 #define length(x) Rf_length(x) 02125 #define lengthgets Rf_lengthgets 02126 #define list1 Rf_list1 02127 #define list2 Rf_list2 02128 #define list3 Rf_list3 02129 #define list4 Rf_list4 02130 #define list5 Rf_list5 02131 #define list6 Rf_list6 02132 #define listAppend Rf_listAppend 02133 #define match Rf_match 02134 #define matchE Rf_matchE 02135 #define mkChar Rf_mkChar 02136 #define mkCharCE Rf_mkCharCE 02137 #define mkCharLen Rf_mkCharLen 02138 #define mkCharLenCE Rf_mkCharLenCE 02139 #define mkNamed Rf_mkNamed 02140 #define mkString Rf_mkString 02141 #define namesgets Rf_namesgets 02142 #define ncols Rf_ncols 02143 #define nlevels Rf_nlevels 02144 #define NonNullStringMatch Rf_NonNullStringMatch 02145 #define nrows Rf_nrows 02146 #define nthcdr Rf_nthcdr 02147 #define PairToVectorList Rf_PairToVectorList 02148 #define pmatch Rf_pmatch 02149 #define psmatch Rf_psmatch 02150 #define PrintValue Rf_PrintValue 02151 #define protect Rf_protect 02152 #define readS3VarsFromFrame Rf_readS3VarsFromFrame 02153 #define reEnc Rf_reEnc 02154 #define rownamesgets Rf_rownamesgets 02155 #define S3Class Rf_S3Class 02156 #define ScalarComplex Rf_ScalarComplex 02157 #define ScalarInteger Rf_ScalarInteger 02158 #define ScalarLogical Rf_ScalarLogical 02159 #define ScalarReal Rf_ScalarReal 02160 #define ScalarString Rf_ScalarString 02161 #define ScalarRaw Rf_ScalarRaw 02162 #define setAttrib Rf_setAttrib 02163 #define setSVector Rf_setSVector 02164 #define setVar Rf_setVar 02165 #define shallow_duplicate Rf_shallow_duplicate 02166 #define str2type Rf_str2type 02167 #define stringSuffix Rf_stringSuffix 02168 #define stringPositionTr Rf_stringPositionTr 02169 #define StringBlank Rf_StringBlank 02170 #define substitute Rf_substitute 02171 #define topenv Rf_topenv 02172 #define translateChar Rf_translateChar 02173 #define translateChar0 Rf_translateChar0 02174 #define translateCharUTF8 Rf_translateCharUTF8 02175 #define type2char Rf_type2char 02176 #define type2rstr Rf_type2rstr 02177 #define type2str Rf_type2str 02178 #define type2str_nowarn Rf_type2str_nowarn 02179 #define unprotect Rf_unprotect 02180 #define unprotect_ptr Rf_unprotect_ptr 02181 #define VectorToPairList Rf_VectorToPairList 02182 #define warningcall Rf_warningcall 02183 #define warningcall_immediate Rf_warningcall_immediate 02184 #define xlength(x) Rf_xlength(x) 02185 #define xlengthgets Rf_xlengthgets 02186 02187 #endif 02188 02189 #if defined(CALLED_FROM_DEFN_H) && !defined(__MAIN__) && (defined(COMPILING_R) || ( __GNUC__ && !defined(__INTEL_COMPILER) )) 02190 #include "Rinlinedfuns.h" 02191 #else 02192 /* need remapped names here for use with R_NO_REMAP */ 02193 02194 /* 02195 These are the inlinable functions that are provided in Rinlinedfuns.h 02196 It is *essential* that these do not appear in any other header file, 02197 with or without the Rf_ prefix. 02198 */ 02199 02213 SEXP Rf_allocVector(SEXPTYPE, R_xlen_t); 02214 Rboolean Rf_conformable(SEXP, SEXP); 02215 SEXP Rf_elt(SEXP, int); 02216 Rboolean Rf_inherits(SEXP, const char *); 02217 Rboolean Rf_isArray(SEXP); 02218 Rboolean Rf_isFactor(SEXP); 02219 Rboolean Rf_isFrame(SEXP); 02220 Rboolean Rf_isFunction(SEXP); 02221 Rboolean Rf_isInteger(SEXP); 02222 Rboolean Rf_isLanguage(SEXP); 02223 Rboolean Rf_isList(SEXP); 02224 Rboolean Rf_isMatrix(SEXP); 02225 Rboolean Rf_isNewList(SEXP); 02226 Rboolean Rf_isNumber(SEXP); 02227 Rboolean Rf_isNumeric(SEXP); 02228 Rboolean Rf_isPairList(SEXP); 02229 Rboolean Rf_isPrimitive(SEXP); 02230 Rboolean Rf_isTs(SEXP); 02231 Rboolean Rf_isUserBinop(SEXP); 02232 Rboolean Rf_isValidString(SEXP); 02233 Rboolean Rf_isValidStringF(SEXP); 02234 02244 Rboolean Rf_isVector(SEXP); 02245 Rboolean Rf_isVectorAtomic(SEXP); 02246 Rboolean Rf_isVectorList(SEXP); 02247 Rboolean Rf_isVectorizable(SEXP); 02248 SEXP Rf_lang1(SEXP); 02249 SEXP Rf_lang2(SEXP, SEXP); 02250 SEXP Rf_lang3(SEXP, SEXP, SEXP); 02251 SEXP Rf_lang4(SEXP, SEXP, SEXP, SEXP); 02252 SEXP Rf_lang5(SEXP, SEXP, SEXP, SEXP, SEXP); 02253 SEXP Rf_lang6(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 02254 SEXP Rf_lastElt(SEXP); 02255 02267 SEXP Rf_lcons(SEXP, SEXP); 02268 R_len_t Rf_length(SEXP); 02269 SEXP Rf_list1(SEXP); 02270 SEXP Rf_list2(SEXP, SEXP); 02271 SEXP Rf_list3(SEXP, SEXP, SEXP); 02272 SEXP Rf_list4(SEXP, SEXP, SEXP, SEXP); 02273 SEXP Rf_list5(SEXP, SEXP, SEXP, SEXP, SEXP); 02274 SEXP Rf_list6(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 02275 SEXP Rf_listAppend(SEXP, SEXP); 02276 SEXP Rf_mkNamed(SEXPTYPE, const char **); 02277 SEXP Rf_mkString(const char *); 02278 int Rf_nlevels(SEXP); 02279 int Rf_stringPositionTr(SEXP, const char *); 02280 SEXP Rf_ScalarComplex(Rcomplex); 02281 SEXP Rf_ScalarInteger(int); 02282 SEXP Rf_ScalarLogical(int); 02283 SEXP Rf_ScalarRaw(Rbyte); 02284 SEXP Rf_ScalarReal(double); 02285 SEXP Rf_ScalarString(SEXP); 02286 R_xlen_t Rf_xlength(SEXP); 02287 # ifdef INLINE_PROTECT 02288 SEXP Rf_protect(SEXP); 02289 void Rf_unprotect(int); 02290 void R_ProtectWithIndex(SEXP, PROTECT_INDEX *); 02291 void R_Reprotect(SEXP, PROTECT_INDEX); 02292 # endif 02293 SEXP R_FixupRHS(SEXP x, SEXP y); 02294 #endif 02295 02296 #ifdef USE_RINTERNALS 02297 02298 /* Test macros with function versions above */ 02299 #undef isNull 02300 #define isNull(s) (TYPEOF(s) == NILSXP) 02301 #undef isSymbol 02302 #define isSymbol(s) (TYPEOF(s) == SYMSXP) 02303 #undef isLogical 02304 #define isLogical(s) (TYPEOF(s) == LGLSXP) 02305 #undef isReal 02306 #define isReal(s) (TYPEOF(s) == REALSXP) 02307 #undef isComplex 02308 #define isComplex(s) (TYPEOF(s) == CPLXSXP) 02309 #undef isExpression 02310 #define isExpression(s) (TYPEOF(s) == EXPRSXP) 02311 #undef isEnvironment 02312 #define isEnvironment(s) (TYPEOF(s) == ENVSXP) 02313 #undef isString 02314 #define isString(s) (TYPEOF(s) == STRSXP) 02315 #undef isObject 02316 #define isObject(s) (OBJECT(s) != 0) 02317 02318 /* macro version of R_CheckStack */ 02319 #define R_CheckStack() do { \ 02320 void NORET R_SignalCStackOverflow(intptr_t); \ 02321 int dummy; \ 02322 intptr_t usage = R_CStackDir * (R_CStackStart - (uintptr_t)&dummy); \ 02323 if(R_CStackLimit != -1 && usage > ((intptr_t) R_CStackLimit)) \ 02324 R_SignalCStackOverflow(usage); \ 02325 } while (FALSE) 02326 #endif 02327 02328 02329 #ifdef __cplusplus 02330 } 02331 #endif 02332 02333 #endif /* R_INTERNALS_H_ */