CXXR (C++ R)
Rinternals.h
Go to the documentation of this file.
1 /*CXXR $Id: Rinternals.h 1348 2013-02-25 17:49:03Z arr $
2  *CXXR
3  *CXXR This file is part of CXXR, a project to refactor the R interpreter
4  *CXXR into C++. It may consist in whole or in part of program code and
5  *CXXR documentation taken from the R project itself, incorporated into
6  *CXXR CXXR (and possibly MODIFIED) under the terms of the GNU General Public
7  *CXXR Licence.
8  *CXXR
9  *CXXR CXXR is Copyright (C) 2008-13 Andrew R. Runnalls, subject to such other
10  *CXXR copyrights and copyright restrictions as may be stated below.
11  *CXXR
12  *CXXR CXXR is not part of the R project, and bugs and other issues should
13  *CXXR not be reported via r-bugs or other R project channels; instead refer
14  *CXXR to the CXXR website.
15  *CXXR */
16 
17 /*
18  * R : A Computer Language for Statistical Data Analysis
19  * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
20  * Copyright (C) 1999-2010 The R Core Team.
21  *
22  * This program is free software; you can redistribute it and/or modify
23  * it under the terms of the GNU Lesser General Public License as published by
24  * the Free Software Foundation; either version 2.1 of the License, or
25  * (at your option) any later version.
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  *
32  * You should have received a copy of the GNU Lesser General Public License
33  * along with this program; if not, a copy is available at
34  * http://www.r-project.org/Licenses/
35  */
36 
56 #ifndef R_INTERNALS_H_
57 #define R_INTERNALS_H_
58 
59 #ifdef __cplusplus
60 # include <cstdio>
61 # ifdef __SUNPRO_CC
62 using std::FILE;
63 # endif
64 # include <climits>
65 #else
66 # include <stdio.h>
67 # include <limits.h> /* for INT_MAX */
68 #endif
69 
70 #include <R_ext/Arith.h>
71 #include <R_ext/Error.h>
72 #include <R_ext/Memory.h>
73 #include <R_ext/PrtUtil.h>
74 #include <R_ext/Utils.h>
75 
76 #include <R_ext/libextern.h>
77 
78 #include "CXXR/Closure.h"
79 #include "CXXR/ComplexVector.h"
80 #include "CXXR/DotInternal.h"
81 #include "CXXR/GCRoot.h"
82 #include "CXXR/Environment.h"
83 #include "CXXR/Expression.h"
84 #include "CXXR/ExpressionVector.h"
85 #include "CXXR/ExternalPointer.h"
86 #include "CXXR/IntVector.h"
87 #include "CXXR/ListVector.h"
88 #include "CXXR/LogicalVector.h"
89 #include "CXXR/PairList.h"
90 #include "CXXR/Promise.h"
91 #include "CXXR/ProtectStack.h"
92 #include "CXXR/RawVector.h"
93 #include "CXXR/RealVector.h"
94 #include "CXXR/S4Object.h"
95 #include "CXXR/String.h"
96 #include "CXXR/StringVector.h"
97 #include "CXXR/Symbol.h"
98 #include "CXXR/WeakRef.h"
99 /* used for detecting PROTECT issues in memory.c */
100 #define NEWSXP 30 /* fresh node creaed in new page */
101 #define FREESXP 31 /* node released by GC */
102 
103 
104 #ifdef __cplusplus
105 extern "C" {
106 
107 #endif
108 
109 
110 #define CHAR(x) R_CHAR(x)
111 const char *(R_CHAR)(SEXP x);
112 
113 /* Various tests with macro versions below */
114 Rboolean (Rf_isNull)(SEXP s);
115 Rboolean (Rf_isSymbol)(SEXP s);
116 Rboolean (Rf_isLogical)(SEXP s);
117 Rboolean (Rf_isReal)(SEXP s);
118 Rboolean (Rf_isComplex)(SEXP s);
119 Rboolean (Rf_isExpression)(SEXP s);
120 Rboolean (Rf_isEnvironment)(SEXP s);
121 Rboolean (Rf_isString)(SEXP s);
122 Rboolean (Rf_isObject)(SEXP s);
123 
124 /* Accessor functions. Many are declared using () to avoid the macro
125  definitions in the USE_RINTERNALS section (phased out in CXXR).
126  The function STRING_ELT is used as an argument to arrayAssign even
127  if the macro version is in use.
128 */
129 
130 /* General Cons Cell Attributes */
131 SEXP (ATTRIB)(SEXP x);
132 Rboolean (OBJECT)(SEXP x);
133 int (MARK)(SEXP x);
134 SEXPTYPE (TYPEOF)(SEXP x);
135 int (NAMED)(SEXP x);
136 void (SET_NAMED)(SEXP x, int v);
137 void SET_ATTRIB(SEXP x, SEXP v);
138 void DUPLICATE_ATTRIB(SEXP to, SEXP from);
139 
140 /* S4 object testing */
141 Rboolean (IS_S4_OBJECT)(SEXP x);
142 void (SET_S4_OBJECT)(SEXP x);
143 void (UNSET_S4_OBJECT)(SEXP x);
144 
145 /* Vector Access Functions */
146 int (LENGTH)(SEXP x);
147 int (TRUELENGTH)(SEXP x);
148 void (SETLENGTH)(SEXP x, int v);
149 void (SET_TRUELENGTH)(SEXP x, int v);
150 int (LEVELS)(SEXP x);
151 int (SETLEVELS)(SEXP x, int v);
152 
153 int *(LOGICAL)(SEXP x);
154 int *(INTEGER)(SEXP x);
155 Rbyte *(RAW)(SEXP x);
156 double *(REAL)(SEXP x);
157 Rcomplex *(COMPLEX)(SEXP x);
158 SEXP (STRING_ELT)(SEXP x, int i);
159 SEXP (VECTOR_ELT)(SEXP x, int i);
160 void SET_STRING_ELT(SEXP x, int i, SEXP v);
161 SEXP SET_VECTOR_ELT(SEXP x, int i, SEXP v);
162 
163 /* List Access Functions */
164 /* These also work for ... objects */
165 #define CONS(a, b) Rf_cons((a), (b)) /* data lists */
166 #define LCONS(a, b) Rf_lcons((a), (b)) /* language lists */
167 SEXP (TAG)(SEXP e);
168 SEXP (CAR)(SEXP e);
169 SEXP (CDR)(SEXP e);
170 SEXP (CAAR)(SEXP e);
171 SEXP (CDAR)(SEXP e);
172 SEXP (CADR)(SEXP e);
173 SEXP (CDDR)(SEXP e);
174 SEXP (CADDR)(SEXP e);
175 SEXP (CADDDR)(SEXP e);
176 SEXP (CAD4R)(SEXP e);
177 int (MISSING)(SEXP x);
178 void (SET_MISSING)(SEXP x, int v);
179 void SET_TAG(SEXP x, SEXP y);
180 SEXP SETCAR(SEXP x, SEXP y);
181 SEXP SETCDR(SEXP x, SEXP y);
182 SEXP SETCADR(SEXP x, SEXP y);
183 SEXP SETCADDR(SEXP x, SEXP y);
184 SEXP SETCADDDR(SEXP x, SEXP y);
185 SEXP SETCAD4R(SEXP e, SEXP y);
186 
187 /* Closure Access Functions */
188 SEXP (FORMALS)(SEXP x);
189 SEXP (BODY)(SEXP x);
190 SEXP (CLOENV)(SEXP x);
191 Rboolean (RDEBUG)(SEXP x);
192 int (RSTEP)(SEXP x);
193 int (RTRACE)(SEXP x);
194 void (SET_RDEBUG)(SEXP x, Rboolean v);
195 void (SET_RSTEP)(SEXP x, int v);
196 void (SET_RTRACE)(SEXP x, int v);
197 void SET_CLOENV(SEXP x, SEXP v);
198 
199 /* Symbol Access Functions */
200 SEXP (PRINTNAME)(SEXP x);
201 SEXP (SYMVALUE)(SEXP x);
202 SEXP (INTERNAL)(SEXP x);
203 Rboolean (DDVAL)(SEXP x);
204 void (SET_DDVAL)(SEXP x, int v);
205 void SET_PRINTNAME(SEXP x, SEXP v);
206 void SET_SYMVALUE(SEXP x, SEXP v);
207 void SET_INTERNAL(SEXP x, SEXP v);
208 
209 /* Environment Access Functions */
210 SEXP (FRAME)(SEXP x);
211 SEXP (ENCLOS)(SEXP x);
212 
213 /* Promise Access Functions */
214 /* First five have macro versions in Defn.h */
215 SEXP (PRCODE)(SEXP x);
216 SEXP (PRENV)(SEXP x);
217 SEXP (PRVALUE)(SEXP x);
218 void SET_PRVALUE(SEXP x, SEXP v);
219 void SET_PRSEEN(SEXP x, int v);
220 
221 /* Hashing Functions */
222 int (HASHVALUE)(SEXP x);
223 
224 /* External pointer access macros */
225 /* (only for backwards compatibility in CXXR) */
226 #define EXTPTR_PTR(x) R_ExternalPtrAddr(x)
227 #define EXTPTR_PROT(x) R_ExternalPtrProtected(x)
228 #define EXTPTR_TAG(x) R_ExternalPtrTag(x)
229 
230 #define isByteCode(x) (TYPEOF(x)==BCODESXP)
231 
232 /* Pointer Protection and Unprotection */
233 #define PROTECT(s) Rf_protect(s)
234 #define UNPROTECT(n) Rf_unprotect(n)
235 #define UNPROTECT_PTR(s) Rf_unprotect_ptr(s)
236 
237 /* We sometimes need to coerce a protected value and place the new
238  coerced value under protection. For these cases PROTECT_WITH_INDEX
239  saves an index of the protection location that can be used to
240  replace the protected value using REPROTECT. */
241 #define PROTECT_WITH_INDEX(x,i) R_ProtectWithIndex(x,i)
242 #define REPROTECT(x,i) R_Reprotect(x,i)
243 
244 /* Evaluation Environment */
245 LibExtern SEXP R_GlobalEnv; /* The "global" environment */
246 
247 LibExtern SEXP R_EmptyEnv; /* An empty environment at the root of the
248  environment tree */
249 LibExtern SEXP R_BaseEnv; /* The base environment; formerly R_NilValue */
250 LibExtern SEXP R_BaseNamespace; /* The (fake) namespace for base */
251 LibExtern SEXP R_NamespaceRegistry;/* Registry for registered namespaces */
252 
253 LibExtern SEXP R_Srcref; /* Current srcref, for debuggers */
254 
255 /* Note that NULL will in turn typically expand to (void*)0 in C, and
256  * simply to 0 in C++.
257  */
258 #define R_NilValue NULL
259 
260 LibExtern SEXP R_UnboundValue; /* Unbound marker */
261 LibExtern SEXP R_MissingArg; /* Missing argument marker */
262 
263 /* Symbol Table Shortcuts */
264 LibExtern SEXP R_Bracket2Symbol; /* "[[" */
265 LibExtern SEXP R_BracketSymbol; /* "[" */
266 LibExtern SEXP R_BraceSymbol; /* "{" */
267 LibExtern SEXP R_ClassSymbol; /* "class" */
268 LibExtern SEXP R_DeviceSymbol; /* ".Device" */
269 LibExtern SEXP R_DimNamesSymbol; /* "dimnames" */
270 LibExtern SEXP R_DimSymbol; /* "dim" */
271 LibExtern SEXP R_DollarSymbol; /* "$" */
272 LibExtern SEXP R_DotsSymbol; /* "..." */
273 LibExtern SEXP R_DropSymbol; /* "drop" */
274 LibExtern SEXP R_LastvalueSymbol; /* ".Last.value" */
275 LibExtern SEXP R_LevelsSymbol; /* "levels" */
276 LibExtern SEXP R_ModeSymbol; /* "mode" */
277 LibExtern SEXP R_NameSymbol; /* "name" */
278 LibExtern SEXP R_NamesSymbol; /* "names" */
279 LibExtern SEXP R_NaRmSymbol; /* "na.rm" */
280 LibExtern SEXP R_PackageSymbol; /* "package" */
281 LibExtern SEXP R_QuoteSymbol; /* "quote" */
282 LibExtern SEXP R_RowNamesSymbol; /* "row.names" */
283 LibExtern SEXP R_SeedsSymbol; /* ".Random.seed" */
284 LibExtern SEXP R_SourceSymbol; /* "source" */
285 LibExtern SEXP R_TspSymbol; /* "tsp" */
286 
287 LibExtern SEXP R_dot_defined; /* ".defined" */
288 LibExtern SEXP R_dot_Method; /* ".Method" */
289 LibExtern SEXP R_dot_target; /* ".target" */
290 
291 /* Missing Values - others from Arith.h */
292 #define NA_STRING R_NaString
293 LibExtern SEXP R_NaString; /* NA_STRING as a CHARSXP */
294 LibExtern SEXP R_BlankString; /* "" as a CHARSXP */
295 
296 /* srcref related functions */
297 SEXP R_GetCurrentSrcref(int);
298 SEXP R_GetSrcFilename(SEXP);
299 
300 /*--- FUNCTIONS ------------------------------------------------------ */
301 
302 /* Type Coercions of all kinds */
303 
304 SEXP Rf_asChar(SEXP);
305 SEXP Rf_coerceVector(SEXP, SEXPTYPE);
306 SEXP Rf_PairToVectorList(SEXP x);
307 SEXP Rf_VectorToPairList(SEXP x);
308 SEXP Rf_asCharacterFactor(SEXP x);
309 int Rf_asLogical(SEXP x);
310 int Rf_asInteger(SEXP x);
311 double Rf_asReal(SEXP x);
312 Rcomplex Rf_asComplex(SEXP x);
313 
314 
315 
316 /* Other Internally Used Functions, excluding those which are inline-able*/
317 
318 char * Rf_acopy_string(const char *);
319 SEXP Rf_alloc3DArray(SEXPTYPE, int, int, int);
320 SEXP Rf_allocArray(SEXPTYPE, SEXP);
321 SEXP Rf_allocMatrix(SEXPTYPE, int, int);
322 SEXP Rf_allocList(unsigned int);
323 SEXP Rf_allocS4Object(void);
325 SEXP Rf_allocVector(SEXPTYPE, R_len_t);
326 int Rf_any_duplicated(SEXP x, Rboolean from_last);
327 int Rf_any_duplicated3(SEXP x, SEXP incomp, Rboolean from_last);
328 SEXP Rf_arraySubscript(int, SEXP, SEXP, SEXP (*)(SEXP,SEXP),
329  SEXP (*)(SEXP, int), SEXP);
330 SEXP Rf_classgets(SEXP, SEXP);
332 void Rf_copyMatrix(SEXP, SEXP, Rboolean);
334 void Rf_copyVector(SEXP, SEXP);
335 SEXP Rf_CreateTag(SEXP);
336 void Rf_defineVar(SEXP, SEXP, SEXP);
337 SEXP Rf_dimgets(SEXP, SEXP);
338 SEXP Rf_dimnamesgets(SEXP, SEXP);
339 SEXP Rf_DropDims(SEXP);
340 SEXP Rf_duplicate(SEXP);
341 SEXP Rf_duplicated(SEXP, Rboolean);
343 SEXP Rf_findFun(SEXP, SEXP);
344 SEXP Rf_findVar(SEXP, SEXP);
345 SEXP Rf_findVarInFrame(SEXP, SEXP);
346 SEXP Rf_findVarInFrame3(SEXP, SEXP, Rboolean);
348 SEXP Rf_GetArrayDimnames(SEXP);
349 SEXP Rf_GetColNames(SEXP);
350 void Rf_GetMatrixDimnames(SEXP, SEXP*, SEXP*, const char**, const char**);
351 SEXP Rf_GetOption(SEXP, SEXP); /* pre-2.13.0 compatibility */
352 SEXP Rf_GetOption1(SEXP);
353 int Rf_GetOptionDigits(void);
354 int Rf_GetOptionWidth(void);
355 SEXP Rf_GetRowNames(SEXP);
356 void Rf_gsetVar(SEXP, SEXP, SEXP);
357 SEXP Rf_install(const char *);
358 Rboolean Rf_isFree(SEXP);
359 Rboolean Rf_isOrdered(SEXP);
360 Rboolean Rf_isUnordered(SEXP);
361 Rboolean Rf_isUnsorted(SEXP, Rboolean);
362 SEXP Rf_lengthgets(SEXP, R_len_t);
363 SEXP R_lsInternal(SEXP, Rboolean);
364 SEXP Rf_match(SEXP, SEXP, int);
365 SEXP Rf_matchE(SEXP, SEXP, int, SEXP);
366 SEXP Rf_namesgets(SEXP, SEXP);
367 SEXP Rf_mkChar(const char *);
368 SEXP Rf_mkCharLen(const char *, int);
369 Rboolean Rf_NonNullStringMatch(SEXP, SEXP);
370 int Rf_ncols(SEXP);
371 int Rf_nrows(SEXP);
372 SEXP Rf_nthcdr(SEXP, int);
373 
374 Rboolean Rf_pmatch(SEXP, SEXP, Rboolean);
375 Rboolean Rf_psmatch(const char *, const char *, Rboolean);
376 void Rf_PrintValue(SEXP);
379 void Rf_setSVector(SEXP*, int, SEXP);
380 void Rf_setVar(SEXP, SEXP, SEXP);
381 SEXPTYPE Rf_str2type(const char *);
382 Rboolean Rf_StringBlank(SEXP);
383 SEXP Rf_substitute(SEXP,SEXP);
384 const char * Rf_translateChar(SEXP);
385 const char * Rf_translateChar0(SEXP);
386 const char * Rf_translateCharUTF8(SEXP);
387 const char * Rf_type2char(SEXPTYPE);
388 SEXP Rf_type2str(SEXPTYPE);
389 void Rf_unprotect(int);
390 void Rf_unprotect_ptr(SEXP);
391 
392 void R_ProtectWithIndex(SEXP, PROTECT_INDEX *);
393 void R_Reprotect(SEXP, PROTECT_INDEX);
394 SEXP R_tryEval(SEXP, SEXP, int *);
395 SEXP R_tryEvalSilent(SEXP, SEXP, int *);
396 const char *R_curErrorBuf();
397 
398 Rboolean Rf_isS4(SEXP);
399 SEXP Rf_asS4(SEXP, Rboolean, int);
400 SEXP Rf_S3Class(SEXP);
401 int Rf_isBasicClass(const char *);
402 
403 cetype_t Rf_getCharCE(SEXP);
404 SEXP Rf_mkCharCE(const char *, cetype_t);
405 SEXP Rf_mkCharLenCE(const char *, int, cetype_t);
406 const char *Rf_reEnc(const char *x, cetype_t ce_in, cetype_t ce_out, int subst);
407 
408  /* return(.) NOT reached : for -Wall */
409 #define error_return(msg) { Rf_error(msg); return R_NilValue; }
410 #define errorcall_return(cl,msg){ Rf_errorcall(cl, msg); return R_NilValue; }
411 
412 #ifdef __MAIN__
413 #undef extern
414 #undef LibExtern
415 #endif
416 
417 /* External pointer interface */
418 SEXP R_MakeExternalPtr(void *p, SEXP tag, SEXP prot);
419 void *R_ExternalPtrAddr(SEXP s);
422 void R_ClearExternalPtr(SEXP s);
423 void R_SetExternalPtrAddr(SEXP s, void *p);
424 void R_SetExternalPtrTag(SEXP s, SEXP tag);
426 
427 /* Finalization interface */
428 void R_RegisterFinalizer(SEXP s, SEXP fun);
429 void R_RegisterCFinalizer(SEXP s, R_CFinalizer_t fun);
430 void R_RegisterFinalizerEx(SEXP s, SEXP fun, Rboolean onexit);
431 void R_RegisterCFinalizerEx(SEXP s, R_CFinalizer_t fun, Rboolean onexit);
432 
433 /* Weak reference interface */
434 SEXP R_MakeWeakRef(SEXP key, SEXP val, SEXP fin, Rboolean onexit);
435 SEXP R_MakeWeakRefC(SEXP key, SEXP val, R_CFinalizer_t fin, Rboolean onexit);
436 SEXP R_WeakRefKey(SEXP w);
437 SEXP R_WeakRefValue(SEXP w);
438 void R_RunWeakRefFinalizer(SEXP w);
439 
440 SEXP R_ClosureExpr(SEXP);
441 void R_initialize_bcode(void);
442 #define BODY_EXPR(e) R_ClosureExpr(e)
443 
444 /* Protected evaluation */
445 Rboolean R_ToplevelExec(void (*fun)(void *), void *data);
446 
447 /* Environment and Binding Features */
448 void R_RestoreHashCount(SEXP rho);
449 Rboolean R_IsPackageEnv(SEXP rho);
450 SEXP R_PackageEnvName(SEXP rho);
451 SEXP R_FindPackageEnv(SEXP info);
452 Rboolean R_IsNamespaceEnv(SEXP rho);
453 SEXP R_NamespaceEnvSpec(SEXP rho);
454 SEXP R_FindNamespace(SEXP info);
455 void R_LockEnvironment(SEXP env, Rboolean bindings);
456 Rboolean R_EnvironmentIsLocked(SEXP env);
457 void R_LockBinding(SEXP sym, SEXP env);
458 void R_unLockBinding(SEXP sym, SEXP env);
459 void R_MakeActiveBinding(SEXP sym, SEXP fun, SEXP env);
460 Rboolean R_BindingIsLocked(SEXP sym, SEXP env);
461 Rboolean R_BindingIsActive(SEXP sym, SEXP env);
462 Rboolean R_HasFancyBindings(SEXP rho);
463 
464 
465 /* ../main/errors.c : */
466 /* needed for R_load/savehistory handling in front ends */
467 void Rf_errorcall(SEXP, const char *, ...);
468 void Rf_warningcall(SEXP, const char *, ...);
469 void Rf_warningcall_immediate(SEXP, const char *, ...);
470 
471 /* Save/Load Interface */
472 #define R_XDR_DOUBLE_SIZE 8
473 #define R_XDR_INTEGER_SIZE 4
474 
475 void R_XDREncodeDouble(double d, void *buf);
476 double R_XDRDecodeDouble(void *buf);
477 void R_XDREncodeInteger(int i, void *buf);
478 int R_XDRDecodeInteger(void *buf);
479 
480 typedef void *R_pstream_data_t;
481 
482 typedef enum {
483  R_pstream_any_format,
484  R_pstream_ascii_format,
485  R_pstream_binary_format,
486  R_pstream_xdr_format
487 } R_pstream_format_t;
488 
489 typedef struct R_outpstream_st *R_outpstream_t;
490 struct R_outpstream_st {
491  R_pstream_data_t data;
492  R_pstream_format_t type;
493  int version;
494  void (*OutChar)(R_outpstream_t, int);
495  void (*OutBytes)(R_outpstream_t, const void *, int);
496  SEXP (*OutPersistHookFunc)(SEXP, SEXP);
497  SEXP OutPersistHookData;
498 };
499 
500 typedef struct R_inpstream_st *R_inpstream_t;
501 struct R_inpstream_st {
502  R_pstream_data_t data;
503  R_pstream_format_t type;
504  int (*InChar)(R_inpstream_t);
505  void (*InBytes)(R_inpstream_t, void *, int);
506  SEXP (*InPersistHookFunc)(SEXP, SEXP);
507  SEXP InPersistHookData;
508 };
509 
510 void R_InitInPStream(R_inpstream_t stream, R_pstream_data_t data,
511  R_pstream_format_t type,
512  int (*inchar)(R_inpstream_t),
513  void (*inbytes)(R_inpstream_t, void *, int),
514  SEXP (*phook)(SEXP, SEXP), SEXP pdata);
515 void R_InitOutPStream(R_outpstream_t stream, R_pstream_data_t data,
516  R_pstream_format_t type, int version,
517  void (*outchar)(R_outpstream_t, int),
518  void (*outbytes)(R_outpstream_t, const void *, int),
519  SEXP (*phook)(SEXP, SEXP), SEXP pdata);
520 
521 void R_InitFileInPStream(R_inpstream_t stream, FILE *fp,
522  R_pstream_format_t type,
523  SEXP (*phook)(SEXP, SEXP), SEXP pdata);
524 void R_InitFileOutPStream(R_outpstream_t stream, FILE *fp,
525  R_pstream_format_t type, int version,
526  SEXP (*phook)(SEXP, SEXP), SEXP pdata);
527 
528 #ifdef NEED_CONNECTION_PSTREAMS
529 /* The connection interface is not yet available to packages. To
530  allow limited use of connection pointers this defines the opaque
531  pointer type. */
532 #ifndef HAVE_RCONNECTION_TYPEDEF
533 typedef struct Rconn *Rconnection;
534 #define HAVE_RCONNECTION_TYPEDEF
535 #endif
536 void R_InitConnOutPStream(R_outpstream_t stream, Rconnection con,
537  R_pstream_format_t type, int version,
538  SEXP (*phook)(SEXP, SEXP), SEXP pdata);
539 void R_InitConnInPStream(R_inpstream_t stream, Rconnection con,
540  R_pstream_format_t type,
541  SEXP (*phook)(SEXP, SEXP), SEXP pdata);
542 #endif
543 
544 void R_Serialize(SEXP s, R_outpstream_t ops);
545 SEXP R_Unserialize(R_inpstream_t ips);
546 
547 /* slot management (in attrib.c) */
548 SEXP R_do_slot(SEXP obj, SEXP name);
549 SEXP R_do_slot_assign(SEXP obj, SEXP name, SEXP value);
550 int R_has_slot(SEXP obj, SEXP name);
551 
552 /* class definition, new objects (objects.c) */
553 SEXP R_do_MAKE_CLASS(const char *what);
554 SEXP R_getClassDef (const char *what);
555 SEXP R_do_new_object(SEXP class_def);
556 /* supporting a C-level version of is(., .) : */
557 int R_check_class_and_super(SEXP x, const char **valid, SEXP rho);
558 int R_check_class_etc (SEXP x, const char **valid);
559 
560 /* preserve objects across GCs */
561 void R_PreserveObject(SEXP);
562 void R_ReleaseObject(SEXP);
563 
564 /* Shutdown actions */
565 void R_dot_Last(void); /* in main.c */
566 void R_RunExitFinalizers(void); /* in memory.c */
567 
568 /* Replacements for popen and system */
569 #ifdef HAVE_POPEN
570 FILE *R_popen(const char *, const char *);
571 #endif
572 int R_system(const char *);
573 
574 /* R_compute_identical: C version of identical() function
575  The third arg to R_compute_identical() consists of bitmapped flags for non-default options:
576  currently all default to TRUE, so the flag is set for FALSE values:
577  1 = !NUM_EQ
578  2 = !SINGLE_NA
579  4 = !ATTR_AS_SET
580  8 = !IGNORE_BYTECODE
581 */
582 Rboolean R_compute_identical(SEXP, SEXP, int);
583 
584 /* These Rf_ macros are retained for backwards compatibility, but
585  * their use is deprecated within CXXR. In particular header files
586  * should always use the Rf_ prefix explicitly, and not rely on these
587  * macros to paste it in.
588  */
589 
590 #ifndef R_NO_REMAP
591 #define acopy_string Rf_acopy_string
592 #define alloc3DArray Rf_alloc3DArray
593 #define allocArray Rf_allocArray
594 #define allocList Rf_allocList
595 #define allocMatrix Rf_allocMatrix
596 #define allocS4Object Rf_allocS4Object
597 #define allocSExp Rf_allocSExp
598 #define allocVector Rf_allocVector
599 #define any_duplicated Rf_any_duplicated
600 #define any_duplicated3 Rf_any_duplicated3
601 #define arraySubscript Rf_arraySubscript
602 #define asChar Rf_asChar
603 #define asCharacterFactor Rf_asCharacterFactor
604 #define asComplex Rf_asComplex
605 #define asInteger Rf_asInteger
606 #define asLogical Rf_asLogical
607 #define asReal Rf_asReal
608 #define asS4 Rf_asS4
609 #define classgets Rf_classgets
610 #define coerceVector Rf_coerceVector
611 #define conformable Rf_conformable
612 #define cons Rf_cons
613 #define copyMatrix Rf_copyMatrix
614 #define copyMostAttrib Rf_copyMostAttrib
615 #define copyVector Rf_copyVector
616 #define CreateTag Rf_CreateTag
617 #define defineVar Rf_defineVar
618 #define dimgets Rf_dimgets
619 #define dimnamesgets Rf_dimnamesgets
620 #define DropDims Rf_DropDims
621 #define duplicate Rf_duplicate
622 #define duplicated Rf_duplicated
623 #define elt Rf_elt
624 #define errorcall Rf_errorcall
625 #define eval Rf_eval
626 #define findFun Rf_findFun
627 #define findVar Rf_findVar
628 #define findVarInFrame Rf_findVarInFrame
629 #define findVarInFrame3 Rf_findVarInFrame3
630 #define GetArrayDimnames Rf_GetArrayDimnames
631 #define getAttrib Rf_getAttrib
632 #define getCharCE Rf_getCharCE
633 #define GetColNames Rf_GetColNames
634 #define GetMatrixDimnames Rf_GetMatrixDimnames
635 #define GetOption1 Rf_GetOption1
636 #define GetOptionDigits Rf_GetOptionDigits
637 #define GetOptionWidth Rf_GetOptionWidth
638 #define GetOption Rf_GetOption
639 #define GetRowNames Rf_GetRowNames
640 #define gsetVar Rf_gsetVar
641 #define inherits Rf_inherits
642 #define install Rf_install
643 #define isArray Rf_isArray
644 #define isBasicClass Rf_isBasicClass
645 #define isComplex Rf_isComplex
646 #define isEnvironment Rf_isEnvironment
647 #define isExpression Rf_isExpression
648 #define isFactor Rf_isFactor
649 #define isFrame Rf_isFrame
650 #define isFree Rf_isFree
651 #define isFunction Rf_isFunction
652 #define isInteger Rf_isInteger
653 #define isLanguage Rf_isLanguage
654 #define isList Rf_isList
655 #define isLogical Rf_isLogical
656 #define isSymbol Rf_isSymbol
657 #define isMatrix Rf_isMatrix
658 #define isNewList Rf_isNewList
659 #define isNull Rf_isNull
660 #define isNumeric Rf_isNumeric
661 #define isNumber Rf_isNumber
662 #define isObject Rf_isObject
663 #define isOrdered Rf_isOrdered
664 #define isPairList Rf_isPairList
665 #define isPrimitive Rf_isPrimitive
666 #define isReal Rf_isReal
667 #define isS4 Rf_isS4
668 #define isString Rf_isString
669 #define isTs Rf_isTs
670 #define isUnordered Rf_isUnordered
671 #define isUnsorted Rf_isUnsorted
672 #define isUserBinop Rf_isUserBinop
673 #define isValidString Rf_isValidString
674 #define isValidStringF Rf_isValidStringF
675 #define isVector Rf_isVector
676 #define isVectorAtomic Rf_isVectorAtomic
677 #define isVectorizable Rf_isVectorizable
678 #define isVectorList Rf_isVectorList
679 #define lang1 Rf_lang1
680 #define lang2 Rf_lang2
681 #define lang3 Rf_lang3
682 #define lang4 Rf_lang4
683 #define lang5 Rf_lang5
684 #define lang6 Rf_lang6
685 #define lastElt Rf_lastElt
686 #define lcons Rf_lcons
687 
688 #ifndef __cplusplus
689 /* Under gcc, this macro can play havoc with some standard C++ header
690  * files. Consequently, the alternative approach is taken of defining
691  * length as an inline function within the namespace CXXR. The
692  * relevant definition is at the end of this file.
693  */
694 #define length Rf_length
695 #endif
696 
697 #define lengthgets Rf_lengthgets
698 #define list1 Rf_list1
699 #define list2 Rf_list2
700 #define list3 Rf_list3
701 #define list4 Rf_list4
702 #define list5 Rf_list5
703 #define listAppend Rf_listAppend
704 #define match Rf_match
705 #define matchE Rf_matchE
706 #define mkChar Rf_mkChar
707 #define mkCharCE Rf_mkCharCE
708 #define mkCharLen Rf_mkCharLen
709 #define mkCharLenCE Rf_mkCharLenCE
710 #define mkNamed Rf_mkNamed
711 #define mkString Rf_mkString
712 #define namesgets Rf_namesgets
713 #define ncols Rf_ncols
714 #define nlevels Rf_nlevels
715 #define NonNullStringMatch Rf_NonNullStringMatch
716 #define nrows Rf_nrows
717 #define nthcdr Rf_nthcdr
718 #define PairToVectorList Rf_PairToVectorList
719 #define pmatch Rf_pmatch
720 #define psmatch Rf_psmatch
721 #define PrintValue Rf_PrintValue
722 #define protect Rf_protect
723 #define reEnc Rf_reEnc
724 #define rownamesgets Rf_rownamesgets
725 #define S3Class Rf_S3Class
726 #define ScalarComplex Rf_ScalarComplex
727 #define ScalarInteger Rf_ScalarInteger
728 #define ScalarLogical Rf_ScalarLogical
729 #define ScalarReal Rf_ScalarReal
730 #define ScalarString Rf_ScalarString
731 #define ScalarRaw Rf_ScalarRaw
732 #define setAttrib Rf_setAttrib
733 #define setSVector Rf_setSVector
734 #define setVar Rf_setVar
735 #define str2type Rf_str2type
736 #define StringBlank Rf_StringBlank
737 #define substitute Rf_substitute
738 #define translateChar Rf_translateChar
739 #define translateChar0 Rf_translateChar0
740 #define translateCharUTF8 Rf_translateCharUTF8
741 #define type2char Rf_type2char
742 #define type2str Rf_type2str
743 #define unprotect Rf_unprotect
744 #define unprotect_ptr Rf_unprotect_ptr
745 #define VectorToPairList Rf_VectorToPairList
746 #define warningcall Rf_warningcall
747 #define warningcall_immediate Rf_warningcall_immediate
748 #endif /* R_NO_REMAP */
749 
750 #if defined(CALLED_FROM_DEFN_H) && !defined(__MAIN__) && (defined(COMPILING_R) || ( __GNUC__ && !defined(__INTEL_COMPILER) ))
751 #include "Rinlinedfuns.h"
752 #else
753 /* need remapped names here for use with R_NO_REMAP */
754 
755 /*
756  These are the inlinable functions that are provided in Rinlinedfuns.h
757  It is *essential* that these do not appear in any other header file,
758  with or without the Rf_ prefix.
759 */
760 Rboolean Rf_conformable(SEXP, SEXP);
761 SEXP Rf_elt(SEXP, int);
762 Rboolean Rf_inherits(SEXP, const char *);
763 Rboolean Rf_isArray(SEXP);
764 Rboolean Rf_isFactor(SEXP);
765 Rboolean Rf_isFrame(SEXP);
766 Rboolean Rf_isFunction(SEXP);
767 Rboolean Rf_isInteger(SEXP);
768 Rboolean Rf_isLanguage(SEXP);
769 Rboolean Rf_isList(SEXP);
770 Rboolean Rf_isMatrix(SEXP);
771 Rboolean Rf_isNewList(SEXP);
772 Rboolean Rf_isNumber(SEXP);
773 Rboolean Rf_isNumeric(SEXP);
774 Rboolean Rf_isPairList(SEXP);
775 Rboolean Rf_isPrimitive(SEXP);
776 Rboolean Rf_isTs(SEXP);
777 Rboolean Rf_isUserBinop(SEXP);
778 Rboolean Rf_isValidString(SEXP);
779 Rboolean Rf_isValidStringF(SEXP);
780 Rboolean Rf_isVector(SEXP);
781 Rboolean Rf_isVectorAtomic(SEXP);
782 Rboolean Rf_isVectorList(SEXP);
783 Rboolean Rf_isVectorizable(SEXP);
784 SEXP Rf_lang1(SEXP);
785 SEXP Rf_lang2(SEXP, SEXP);
786 SEXP Rf_lang3(SEXP, SEXP, SEXP);
787 SEXP Rf_lang4(SEXP, SEXP, SEXP, SEXP);
788 SEXP Rf_lang5(SEXP, SEXP, SEXP, SEXP, SEXP);
789 SEXP Rf_lang6(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
790 SEXP Rf_lastElt(SEXP);
792 R_len_t Rf_length(SEXP);
793 SEXP Rf_list1(SEXP);
794 SEXP Rf_list2(SEXP, SEXP);
795 SEXP Rf_list3(SEXP, SEXP, SEXP);
796 SEXP Rf_list4(SEXP, SEXP, SEXP, SEXP);
797 SEXP Rf_list5(SEXP, SEXP, SEXP, SEXP, SEXP);
798 SEXP Rf_listAppend(SEXP, SEXP);
799 SEXP Rf_mkNamed(SEXPTYPE, const char **);
800 SEXP Rf_mkString(const char *);
801 int Rf_nlevels(SEXP);
802 SEXP Rf_ScalarComplex(Rcomplex);
803 SEXP Rf_ScalarInteger(int);
804 SEXP Rf_ScalarLogical(int);
805 SEXP Rf_ScalarRaw(Rbyte);
806 SEXP Rf_ScalarReal(double);
807 SEXP Rf_ScalarString(SEXP);
808 #endif
809 
810 #ifdef __cplusplus
811 } // extern "C"
812 
813 namespace CXXR {
821  inline R_len_t length(RObject* s)
822  {
823  return Rf_length(s);
824  }
825 }
826 #endif
827 
828 #endif /* R_INTERNALS_H_ */