CXXR (C++ R)
Defn.h
Go to the documentation of this file.
1 /*CXXR $Id: Defn.h 1378 2013-04-26 13:39:20Z 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) 1998--2011 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 General Public License as published by
24  * the Free Software Foundation; either version 2 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 General Public License for more details.
31  *
32  * You should have received a copy of the GNU 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 DEFN_H_
57 #define DEFN_H_
58 
59 #include "CXXR/BuiltInFunction.h"
60 #include "CXXR/Evaluator.h"
61 #include "CXXR/errors.h"
62 
63 /* seems unused */
64 #define COUNTING
65 
66 /* probably no longer needed */
67 #define NEW_CONDITION_HANDLING
68 
69 #ifdef HAVE_VISIBILITY_ATTRIBUTE
70 # define attribute_visible __attribute__ ((visibility ("default")))
71 # define attribute_hidden __attribute__ ((visibility ("hidden")))
72 #else
73 # define attribute_visible
74 # define attribute_hidden
75 #endif
76 
77 /* In CR, extern0 is defined as attribute_hidden if this file is
78  * #included from main.c, and as extern otherwise. In CXXR it always
79  * maps to extern attribute_hidden.
80  */
81 # define extern0 extern attribute_hidden
82 
83 
84 #define MAXELTSIZE 8192 /* Used as a default for string buffer sizes,
85  and occasionally as a limit. */
86 
87 #include <R_ext/Complex.h>
88 
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
92 
93 void Rf_CoercionWarning(int);/* warning code */
94 int Rf_LogicalFromInteger(int, int*);
95 int Rf_LogicalFromReal(double, int*);
96 int Rf_LogicalFromComplex(Rcomplex, int*);
97 int Rf_IntegerFromLogical(int, int*);
98 int Rf_IntegerFromReal(double, int*);
99 int Rf_IntegerFromComplex(Rcomplex, int*);
100 double Rf_RealFromLogical(int, int*);
101 double Rf_RealFromInteger(int, int*);
102 double Rf_RealFromComplex(Rcomplex, int*);
103 Rcomplex Rf_ComplexFromLogical(int, int*);
104 Rcomplex Rf_ComplexFromInteger(int, int*);
105 Rcomplex Rf_ComplexFromReal(double, int*);
106 
107 #ifdef __cplusplus
108 } /* extern "C" */
109 #endif
110 
111 #define CALLED_FROM_DEFN_H 1
112 #include <Rinternals.h> /*-> Arith.h, Boolean.h, Complex.h, Error.h,
113  Memory.h, PrtUtil.h, Utils.h */
114 #undef CALLED_FROM_DEFN_H
115 extern0 SEXP R_CommentSymbol; /* "comment" */
116 extern0 SEXP R_DotEnvSymbol; /* ".Environment" */
117 extern0 SEXP R_ExactSymbol; /* "exact" */
118 extern0 SEXP R_RecursiveSymbol; /* "recursive" */
119 extern0 SEXP R_SrcfileSymbol; /* "srcfile" */
120 extern0 SEXP R_WholeSrcrefSymbol; /* "wholeSrcref" */
121 extern0 SEXP R_SrcrefSymbol; /* "srcref" */
122 extern0 SEXP R_TmpvalSymbol; /* "*tmp*" */
123 extern0 SEXP R_UseNamesSymbol; /* "use.names" */
124 extern0 SEXP R_DoubleColonSymbol; /* "::" */
125 extern0 SEXP R_TripleColonSymbol; /* ":::" */
126 extern0 SEXP R_ConnIdSymbol; /* "conn_id" */
127 extern0 SEXP R_DevicesSymbol; /* ".Devices" */
128 
129 extern0 SEXP R_dot_Generic; /* ".Generic" */
130 extern0 SEXP R_dot_Methods; /* ".Methods" */
131 extern0 SEXP R_dot_Group; /* ".Group" */
132 extern0 SEXP R_dot_Class; /* ".Class" */
133 extern0 SEXP R_dot_GenericCallEnv; /* ".GenericCallEnv" */
134 extern0 SEXP R_dot_GenericDefEnv; /* ".GenericDefEnv" */
135 
136 
137 #define BYTES_MASK (1<<1)
138 #define HASHASH_MASK 1
139 /**** HASHASH uses the first bit -- see HASHASH_MASK defined below */
140 
141 int IS_BYTES(SEXP x);
142 void SET_BYTES(SEXP x);
143 int IS_ASCII(SEXP x);
144 /* macros and declarations for managing CHARSXP cache */
145 /* Not implemented within CXXR: */
146 /*#define USE_ATTRIB_FIELD_FOR_CHARSXP_CACHE_CHAINS */
147 #ifdef USE_ATTRIB_FIELD_FOR_CHARSXP_CACHE_CHAINS
148 # define CXHEAD(x) (x)
149 # define CXTAIL(x) ATTRIB(x)
150 SEXP (SET_CXTAIL)(SEXP x, SEXP y);
151 #else
152 # define CXHEAD(x) CAR(x)
153 # define CXTAIL(x) CDR(x)
154 #endif /* USE_ATTRIB_FIELD_FOR_CHARSXP_CACHE_CHAINS */
155 
156 
157 #include "Internal.h" /* do_FOO */
158 
159 #include "Errormsg.h"
160 
161 #ifdef __cplusplus
162 extern "C" {
163 #endif
164 
165 extern void R_ProcessEvents(void);
166 
167 #ifdef __cplusplus
168 } /* extern "C" */
169 #endif
170 
171 #ifdef R_USE_SIGNALS
172 #ifdef Win32
173 # include <psignal.h>
174 #else
175 # include <signal.h>
176 # include <setjmp.h>
177 #endif
178 #endif
179 
180 #ifdef Unix
181 # define OSTYPE "unix"
182 # define FILESEP "/"
183 #endif /* Unix */
184 
185 #ifdef Win32
186 # define OSTYPE "windows"
187 # define FILESEP "/"
188 #endif /* Win32 */
189 
190 #ifdef HAVE_F77_UNDERSCORE
191 # define F77_SYMBOL(x) x ## _
192 # define F77_QSYMBOL(x) #x "_"
193 #else
194 # define F77_SYMBOL(x) x
195 # define F77_QSYMBOL(x) #x
196 #endif
197 
198 /* Heap and Pointer Protection Stack Sizes. */
199 
200 /* These are all required by C99 */
201 #ifdef HAVE_INTTYPES_H
202 # include <inttypes.h>
203 #endif
204 /* According to POSIX inttypes.h should include stdint.h,
205  but let's be sure. */
206 #ifdef HAVE_STDINT_H
207 # include <stdint.h>
208 #endif
209 #ifdef HAVE_LIMITS_H
210 # include <limits.h>
211 #endif
212 
213 #if defined HAVE_DECL_SIZE_MAX && HAVE_DECL_SIZE_MAX
214  typedef size_t R_size_t;
215 #ifdef __cplusplus
216 # define R_SIZE_T_MAX std::numeric_limits<size_t>::max()
217 #else
218 # define R_SIZE_T_MAX SIZE_MAX
219 #endif /* __cplusplus */
220 #else
221 # error SIZE_MAX is required for C99
222 #endif
223 
224 
225 #define Mega 1048576. /* 1 Mega Byte := 2^20 (= 1048576) Bytes */
226 #define Giga 1073741824. /* 1 Giga Byte := 2^30 Bytes */
227 
228 /* R_PPSSIZE The pointer protection stack size */
229 /* R_NSIZE The number of cons cells */
230 /* R_VSIZE The vector heap size in bytes */
231 /* These values are defaults and can be overridden in config.h
232  The maxima and minima are in startup.c */
233 
234 #ifndef R_PPSSIZE
235 #define R_PPSSIZE 50000L
236 #endif
237 #ifndef R_NSIZE
238 #define R_NSIZE 350000L
239 #endif
240 #ifndef R_VSIZE
241 #define R_VSIZE 16000000L
242 #endif
243 
244 /* some commonly needed headers */
245 #include <math.h>
246 #include <stdlib.h>
247 #include <string.h>
248 
249 #ifdef __cplusplus
250 extern "C" {
251 #endif
252 
253 /* declare substitutions */
254 #if !defined(strdup) && defined(HAVE_DECL_STRDUP) && !HAVE_DECL_STRDUP
255 extern char *strdup(const char *s1);
256 #endif
257 #if !defined(strncascmp) && defined(HAVE_DECL_STRNCASECMP) && !HAVE_DECL_STRNCASECMP
258 extern int strncasecmp(const char *s1, const char *s2, size_t n);
259 #endif
260 
261 /* Glibc manages to not define this in -pedantic -ansi */
262 #if defined(HAVE_PUTENV) && !defined(putenv) && defined(HAVE_DECL_PUTENV) && !HAVE_DECL_PUTENV
263 extern int putenv(char *string);
264 #endif
265 
266 
267 /* Maximal length in bytes of an entire path name.
268  POSIX has required this to be at least 255/256, and X/Open at least 1024.
269  Solaris has 1024, Linux glibc has 4192.
270  File names are limited to FILENAME_MAX bytes (usually the same as PATH_MAX)
271  or NAME_MAX (often 255/256).
272  */
273 #if !defined(PATH_MAX)
274 # if defined(HAVE_SYS_PARAM_H)
275 # include <sys/param.h>
276 # endif
277 # if !defined(PATH_MAX)
278 # if defined(MAXPATHLEN)
279 /* Try BSD name */
280 # define PATH_MAX MAXPATHLEN
281 # elif defined(Win32)
282 /* seems this is now defined by MinGW to be 259, whereas FILENAME_MAX
283  and MAX_PATH are 260. It is not clear that this really is in bytes,
284  but might be chars for the Unicode interfaces.
285 */
286 # define PATH_MAX 260
287 # else
288 /* quite possibly unlimited, so we make this large, and test when used */
289 # define PATH_MAX 5000
290 # endif
291 # endif
292 #endif
293 
294 #ifdef HAVE_POSIX_SETJMP
295 # define SIGJMP_BUF sigjmp_buf
296 # define SIGSETJMP(x,s) sigsetjmp(x,s)
297 # define SIGLONGJMP(x,i) siglongjmp(x,i)
298 # define JMP_BUF sigjmp_buf
299 # define SETJMP(x) sigsetjmp(x,0)
300 # define LONGJMP(x,i) siglongjmp(x,i)
301 #else
302 # define SIGJMP_BUF jmp_buf
303 # define SIGSETJMP(x,s) setjmp(x)
304 # define SIGLONGJMP(x,i) longjmp(x,i)
305 # define JMP_BUF jmp_buf
306 # define SETJMP(x) setjmp(x)
307 # define LONGJMP(x,i) longjmp(x,i)
308 #endif
309 
310 #ifdef __cplusplus
311 
312 /* There is much more in Rinternals.h, including function versions
313  * of the Promise and Hasking groups.
314  */
315 
316 /* Vector Heap Structure */
317 typedef struct {
318  union {
319  SEXP backpointer;
320  double align;
321  } u;
322 } VECREC, *VECP;
323 
324 /* Vector Heap Macros */
325 
326 // This doesn't seem to be used anywhere:
327 //#define BACKPOINTER(v) ((v).u.backpointer)
328 
329 inline size_t BYTE2VEC(int n)
330 {
331  return (n > 0) ? (n - 1)/sizeof(VECREC) + 1 : 0;
332 }
333 
334 inline size_t INT2VEC(int n)
335 {
336  return (n > 0) ? (n*sizeof(int) - 1)/sizeof(VECREC) + 1 : 0;
337 }
338 
339 inline size_t FLOAT2VEC(int n)
340 {
341  return (n > 0) ? (n*sizeof(double) - 1)/sizeof(VECREC) + 1 : 0;
342 }
343 
344 inline size_t COMPLEX2VEC(int n)
345 {
346  return (n > 0) ? (n*sizeof(Rcomplex) - 1)/sizeof(VECREC) + 1 : 0;
347 }
348 
349 inline size_t PTR2VEC(int n)
350 {
351  return (n > 0) ? (n*sizeof(SEXP) - 1)/sizeof(VECREC) + 1 : 0;
352 }
353 
354 /* Bindings */
355 /* use the same bits (15 and 14) in symbols and bindings */
356 #define ACTIVE_BINDING_MASK (1<<15)
357 #define BINDING_LOCK_MASK (1<<14)
358 #define SPECIAL_BINDING_MASK (ACTIVE_BINDING_MASK | BINDING_LOCK_MASK)
359 
360 #else /* if not __cplusplus */
361 
362 typedef SEXP R_bcstack_t;
363 
364 #endif // __cplusplus
365 
366 /* Miscellaneous Definitions */
367 #define streql(s, t) (!strcmp((s), (t)))
368 
369 /* Arithmetic and Relation Operators */
370 typedef enum {
371  PLUSOP = 1,
372  MINUSOP,
373  TIMESOP,
374  DIVOP,
375  POWOP,
376  MODOP,
377  IDIVOP
378 } ARITHOP_TYPE;
379 
380 typedef enum {
381  EQOP = 1,
382  NEOP,
383  LTOP,
384  LEOP,
385  GEOP,
386  GTOP
387 } RELOP_TYPE;
388 
389 /* File Handling */
390 /*
391 #define R_EOF 65535
392 */
393 #define R_EOF -1
394 
395 
396 /*--- Global Variables ---------------------------------------------------- */
397 
398 #include <R_ext/libextern.h>
399 
400 /* In CR, if this file is included from main.c, 'INI_as(v)' expands to
401  * '= v', and 'extern0' expands to 'attribute_hidden'; otherwise
402  * 'INI_as(v)' expands to nothing and 'extern0' expands to 'extern'.
403  */
404 # define INI_as(v)
405 #define extern0 extern attribute_hidden
406 
407 LibExtern Rboolean R_interrupts_suspended INI_as(FALSE);
408 LibExtern int R_interrupts_pending INI_as(0);
409 
410 /* R Home Directory */
411 LibExtern char *R_Home; /* Root of the R tree */
412 
413 /* Memory Management */
414 extern0 R_size_t R_VSize INI_as(R_VSIZE);/* Size of the vector heap */
415 extern0 SEXP R_NHeap; /* Start of the cons cell heap */
416 extern0 SEXP R_FreeSEXP; /* Cons cell free list */
417 LibExtern int R_Is_Running; /* for Windows memory manager */
418 
419 /* Evaluation Environment */
420 extern0 Rboolean R_Visible; /* Value visibility flag */
421 extern0 int R_BrowseLines INI_as(0); /* lines/per call in browser */
422 
423 extern0 Rboolean R_KeepSource INI_as(FALSE); /* options(keep.source) */
424 extern0 int R_WarnLength INI_as(1000); /* Error/warning max length */
425 extern0 int R_nwarnings INI_as(50);
426 extern uintptr_t R_CStackLimit INI_as((uintptr_t)-1); /* C stack limit */
427 extern uintptr_t R_CStackStart INI_as((uintptr_t)-1); /* Initial stack address */
428 extern0 int R_CStackDir INI_as(1); /* C stack direction */
429 
430 /* File Input/Output */
431 LibExtern Rboolean R_Interactive INI_as(TRUE); /* TRUE during interactive use*/
432 extern0 Rboolean R_Quiet INI_as(FALSE); /* Be as quiet as possible */
433 extern Rboolean R_Slave INI_as(FALSE); /* Run as a slave process */
434 extern0 Rboolean R_Verbose INI_as(FALSE); /* Be verbose */
435 /* extern int R_Console; */ /* Console active flag */
436 /* IoBuffer R_ConsoleIob; : --> ./IOStuff.h */
437 /* R_Consolefile is used in the internet module */
438 extern FILE* R_Consolefile INI_as(NULL); /* Console output file */
439 extern FILE* R_Outputfile INI_as(NULL); /* Output file */
440 extern0 int R_ErrorCon INI_as(2); /* Error connection */
441 LibExtern char *R_TempDir INI_as(NULL); /* Name of per-session dir */
442 extern0 char *Sys_TempDir INI_as(NULL); /* Name of per-session dir
443  if set by R itself */
444 extern0 char R_StdinEnc[31] INI_as(""); /* Encoding assumed for stdin */
445 
446 /* Objects Used In Parsing */
447 extern0 int R_ParseError INI_as(0); /* Line where parse error occurred */
448 extern0 int R_ParseErrorCol; /* Column of start of token where parse error occurred */
449 extern0 SEXP R_ParseErrorFile; /* Source file where parse error was seen */
450 #define PARSE_ERROR_SIZE 256 /* Parse error messages saved here */
451 extern0 char R_ParseErrorMsg[PARSE_ERROR_SIZE] INI_as("");
452 #define PARSE_CONTEXT_SIZE 256 /* Recent parse context kept in a circular buffer */
453 extern0 char R_ParseContext[PARSE_CONTEXT_SIZE] INI_as("");
454 extern0 int R_ParseContextLast INI_as(0); /* last character in context buffer */
455 extern0 int R_ParseContextLine; /* Line in file of the above */
456 
457 /* Image Dump/Restore */
458 extern int R_DirtyImage INI_as(0); /* Current image dirty */
459 
460 /* History */
461 LibExtern char *R_HistoryFile; /* Name of the history file */
462 LibExtern int R_HistorySize; /* Size of the history file */
463 LibExtern int R_RestoreHistory; /* restore the history file? */
464 extern void R_setupHistory(void);
465 
466 /* Warnings/Errors */
467 extern0 int R_CollectWarnings INI_as(0); /* the number of warnings */
468 #ifdef __cplusplus
469 extern CXXR::GCRoot<> R_Warnings; /* the warnings and their calls */
470 #endif
471 extern0 int R_ShowErrorMessages INI_as(1); /* show error messages? */
472 #ifdef __cplusplus
473 extern CXXR::GCRoot<> R_HandlerStack; /* Condition handler stack */
474 extern CXXR::GCRoot<> R_RestartStack; /* Stack of available restarts */
475 #endif
476 extern0 Rboolean R_warn_partial_match_dollar INI_as(FALSE);
477 extern0 Rboolean R_warn_partial_match_attr INI_as(FALSE);
478 extern0 Rboolean R_ShowWarnCalls INI_as(FALSE);
479 extern0 Rboolean R_ShowErrorCalls INI_as(FALSE);
480 extern0 int R_NShowCalls INI_as(50);
481 
482 LibExtern Rboolean utf8locale INI_as(FALSE); /* is this a UTF-8 locale? */
483 LibExtern Rboolean mbcslocale INI_as(FALSE); /* is this a MBCS locale? */
484 extern0 Rboolean latin1locale INI_as(FALSE); /* is this a Latin-1 locale? */
485 #ifdef Win32
486 LibExtern unsigned int localeCP INI_as(1252); /* the locale's codepage */
487 extern0 Rboolean WinUTF8out INI_as(FALSE); /* Use UTF-8 for output */
488 extern0 void WinCheckUTF8(void);
489 #endif
490 
491 extern0 char OutDec INI_as('.'); /* decimal point used for output */
492 extern0 Rboolean R_DisableNLinBrowser INI_as(FALSE);
493 
494 /* Initialization of the R environment when it is embedded */
495 extern int Rf_initEmbeddedR(int argc, char **argv);
496 
497 /* GUI type */
498 
499 extern const char *R_GUIType INI_as("unknown");
500 extern Rboolean R_isForkedChild INI_as(FALSE); /* was this forked? */
501 
502 extern double cpuLimit INI_as(-1.0);
503 extern double cpuLimit2 INI_as(-1.0);
504 extern double cpuLimitValue INI_as(-1.0);
505 extern double elapsedLimit INI_as(-1.0);
506 extern double elapsedLimit2 INI_as(-1.0);
507 extern double elapsedLimitValue INI_as(-1.0);
508 
509 void resetTimeLimits(void);
510 
511 extern0 int R_jit_enabled INI_as(0);
512 extern0 int R_compile_pkgs INI_as(0);
513 extern SEXP R_cmpfun(SEXP);
514 extern void R_init_jit_enabled(void);
515 LibExtern int R_num_math_threads INI_as(1);
516 LibExtern int R_max_num_math_threads INI_as(1);
517 
518 /* Pointer type and utilities for dispatch in the methods package */
519 typedef SEXP (*R_stdGen_ptr_t)(SEXP, SEXP, SEXP); /* typedef */
520 R_stdGen_ptr_t R_get_standardGeneric_ptr(void); /* get method */
521 R_stdGen_ptr_t R_set_standardGeneric_ptr(R_stdGen_ptr_t, SEXP); /* set method */
522 LibExtern SEXP R_MethodsNamespace;
523 SEXP R_deferred_default_method(void);
524 SEXP R_set_prim_method(SEXP fname, SEXP op, SEXP code_vec, SEXP fundef,
525  SEXP mlist);
526 SEXP do_set_prim_method(SEXP op, const char *code_string, SEXP fundef,
527  SEXP mlist);
528 void R_set_quick_method_check(R_stdGen_ptr_t);
529 SEXP R_primitive_methods(SEXP op);
530 SEXP R_primitive_generic(SEXP op);
531 
532 /* smallest decimal exponent, needed in format.c, set in Init_R_Machine */
533 extern0 int R_dec_min_exponent INI_as(-308);
534 
535 /* structure for caching machine accuracy values */
536 typedef struct {
537  int ibeta, it, irnd, ngrd, machep, negep, iexp, minexp, maxexp;
538  double eps, epsneg, xmin, xmax;
539 } AccuracyInfo;
540 
541 LibExtern AccuracyInfo R_AccuracyInfo;
542 
543 extern0 unsigned int max_contour_segments INI_as(25000);
544 
545 extern0 Rboolean known_to_be_latin1 INI_as(FALSE);
546 extern0 Rboolean known_to_be_utf8 INI_as(FALSE);
547 
548 #ifdef __MAIN__
549 # undef extern
550 # undef extern0
551 # undef LibExtern
552 #endif
553 #undef INI_as
554 
555 #define checkArity(a,b) Rf_checkArityCall(a,b,call)
556 
557 /*--- FUNCTIONS ------------------------------------------------------ */
558 
559 /* These Rf_ macros are retained for backwards compatibility, but
560  * their use is deprecated within CXXR. In particular CXXR's own
561  * header files should always use the Rf_ prefix explicitly, and not
562  * rely on these macros to paste it in.
563  */
564 
565 #ifndef R_NO_REMAP
566 # define allocCharsxp Rf_allocCharsxp
567 # define begincontext Rf_begincontext
568 # define check1arg Rf_check1arg
569 # define CleanEd Rf_CleanEd
570 # define CoercionWarning Rf_CoercionWarning
571 # define ComplexFromInteger Rf_ComplexFromInteger
572 # define ComplexFromLogical Rf_ComplexFromLogical
573 # define ComplexFromReal Rf_ComplexFromReal
574 # define ComplexFromString Rf_ComplexFromString
575 # define copyListMatrix Rf_copyListMatrix
576 # define copyMostAttribNoTs Rf_copyMostAttribNoTs
577 # define CustomPrintValue Rf_CustomPrintValue
578 # define DataFrameClass Rf_DataFrameClass
579 # define ddfindVar Rf_ddfindVar
580 # define deparse1 Rf_deparse1
581 # define deparse1line Rf_deparse1line
582 # define deparse1s Rf_deparse1s
583 # define DispatchGroup Rf_DispatchGroup
584 # define DispatchOrEval Rf_DispatchOrEval
585 # define dynamicfindVar Rf_dynamicfindVar
586 # define EncodeRaw Rf_EncodeRaw
587 # define EncodeString Rf_EncodeString
588 # define EnsureString Rf_EnsureString
589 # define envlength Rf_envlength
590 # define ErrorMessage Rf_ErrorMessage
591 # define evalListKeepMissing Rf_evalListKeepMissing
592 # define factorsConform Rf_factorsConform
593 # define findcontext Rf_findcontext
594 # define findVar1 Rf_findVar1
595 # define FrameClassFix Rf_FrameClassFix
596 # define framedepth Rf_framedepth
597 # define frameSubscript Rf_frameSubscript
598 # define get1index Rf_get1index
599 # define getVar Rf_getVar
600 # define getVarInFrame Rf_getVarInFrame
601 # define InitArithmetic Rf_InitArithmetic
602 # define InitColors Rf_InitColors
603 # define InitConnections Rf_InitConnections
604 # define InitEd Rf_InitEd
605 # define InitFunctionHashing Rf_InitFunctionHashing
606 # define InitGlobalEnv Rf_InitGlobalEnv
607 # define InitGraphics Rf_InitGraphics
608 # define InitMemory Rf_InitMemory
609 # define InitNames Rf_InitNames
610 # define InitOptions Rf_InitOptions
611 # define InitStringHash Rf_InitStringHash
612 # define InitTempDir Rf_InitTempDir
613 # define initStack Rf_initStack
614 # define IntegerFromComplex Rf_IntegerFromComplex
615 # define IntegerFromLogical Rf_IntegerFromLogical
616 # define IntegerFromReal Rf_IntegerFromReal
617 # define IntegerFromString Rf_IntegerFromString
618 # define internalTypeCheck Rf_internalTypeCheck
619 # define isValidName Rf_isValidName
620 # define ItemName Rf_ItemName
621 # define jump_to_toplevel Rf_jump_to_toplevel
622 # define KillAllDevices Rf_KillAllDevices
623 # define levelsgets Rf_levelsgets
624 # define LogicalFromComplex Rf_LogicalFromComplex
625 # define LogicalFromInteger Rf_LogicalFromInteger
626 # define LogicalFromReal Rf_LogicalFromReal
627 # define LogicalFromString Rf_LogicalFromString
628 # define mainloop Rf_mainloop
629 # define makeSubscript Rf_makeSubscript
630 # define markKnown Rf_markKnown
631 # define mat2indsub Rf_mat2indsub
632 # define matchArg Rf_matchArg
633 # define matchArgExact Rf_matchArgExact
634 # define matchArgs Rf_matchArgs
635 # define matchPar Rf_matchPar
636 # define Mbrtowc Rf_mbrtowc
637 # define mbtoucs Rf_mbtoucs
638 # define mkCLOSXP Rf_mkCLOSXP
639 # define mkFalse Rf_mkFalse
640 # define mkPROMISE Rf_mkPROMISE
641 # define mkQUOTE Rf_mkQUOTE
642 # define mkTrue Rf_mkTrue
643 # define NewEnvironment Rf_NewEnvironment
644 # define OneIndex Rf_OneIndex
645 # define onintr Rf_onintr
646 # define onsigusr1 Rf_onsigusr1
647 # define onsigusr2 Rf_onsigusr2
648 # define parse Rf_parse
649 # define PrintDefaults Rf_PrintDefaults
650 # define PrintGreeting Rf_PrintGreeting
651 # define PrintValueEnv Rf_PrintValueEnv
652 # define PrintValueRec Rf_PrintValueRec
653 # define PrintVersion Rf_PrintVersion
654 # define PrintVersion_part_1 Rf_PrintVersion_part_1
655 # define PrintVersionString Rf_PrintVersionString
656 # define PrintWarnings Rf_PrintWarnings
657 # define promiseArgs Rf_promiseArgs
658 # define RealFromComplex Rf_RealFromComplex
659 # define RealFromInteger Rf_RealFromInteger
660 # define RealFromLogical Rf_RealFromLogical
661 # define RealFromString Rf_RealFromString
662 # define Seql Rf_Seql
663 # define Scollate Rf_Scollate
664 # define sortVector Rf_sortVector
665 # define SrcrefPrompt Rf_SrcrefPrompt
666 # define ssort Rf_ssort
667 # define StringFromComplex Rf_StringFromComplex
668 # define StringFromInteger Rf_StringFromInteger
669 # define StringFromLogical Rf_StringFromLogical
670 # define StringFromReal Rf_StringFromReal
671 # define strIsASCII Rf_strIsASCII
672 # define strmat2intmat Rf_strmat2intmat
673 # define substituteList Rf_substituteList
674 # define tsConform Rf_tsConform
675 # define tspgets Rf_tspgets
676 # define type2symbol Rf_type2symbol
677 # define unbindVar Rf_unbindVar
678 # define usemethod Rf_usemethod
679 # define ucstomb Rf_ucstomb
680 # define ucstoutf8 Rf_ucstoutf8
681 # define utf8toucs Rf_utf8toucs
682 # define utf8towcs Rf_utf8towcs
683 # define vectorIndex Rf_vectorIndex
684 # define vectorSubscript Rf_vectorSubscript
685 # define warningcall Rf_warningcall
686 # define WarningMessage Rf_WarningMessage
687 # define wcstoutf8 Rf_wcstoutf8
688 # define wtransChar Rf_wtransChar
689 #endif /* R_NO_REMAP */
690 
691 /* Platform Dependent Gui Hooks */
692 
693 #define R_CONSOLE 1
694 #define R_FILE 2
695 #define R_TEXT 3
696 
697 /* The maximum length of input line which will be asked for,
698  in bytes, including the terminator */
699 #define CONSOLE_BUFFER_SIZE 4096
700 int R_ReadConsole(const char *, unsigned char *, int, int);
701 void R_WriteConsole(const char *, int); /* equivalent to R_WriteConsoleEx(a, b, 0) */
702 void R_WriteConsoleEx(const char *, int, int);
703 void R_ResetConsole(void);
704 void R_FlushConsole(void);
705 void R_ClearerrConsole(void);
706 void R_Busy(int);
707 int R_ShowFiles(int, const char **, const char **, const char *,
708  Rboolean, const char *);
709 int R_EditFiles(int, const char **, const char **, const char *);
710 int R_ChooseFile(int, char *, int);
711 char *R_HomeDir(void);
712 Rboolean R_FileExists(const char *);
713 Rboolean R_HiddenFile(const char *);
714 double R_FileMtime(const char *);
715 
716 /* environment cell access */
717 R_varloc_t R_findVarLocInFrame(SEXP, SEXP);
718 SEXP R_GetVarLocValue(R_varloc_t);
719 SEXP R_GetVarLocSymbol(R_varloc_t);
720 Rboolean R_GetVarLocMISSING(R_varloc_t);
721 void R_SetVarLocValue(R_varloc_t, SEXP);
722 
723 /* deparse option bits: change do_dump if more are added */
724 
725 #define KEEPINTEGER 1
726 #define QUOTEEXPRESSIONS 2
727 #define SHOWATTRIBUTES 4
728 #define USESOURCE 8
729 #define WARNINCOMPLETE 16
730 #define DELAYPROMISES 32
731 #define KEEPNA 64
732 #define S_COMPAT 128
733 /* common combinations of the above */
734 #define SIMPLEDEPARSE 0
735 #define DEFAULTDEPARSE 65 /* KEEPINTEGER | KEEPNA, used for calls */
736 #define FORSOURCING 95 /* not DELAYPROMISES, used in edit.c */
737 
738 /* Coercion functions */
739 int Rf_LogicalFromString(SEXP, int*);
740 int Rf_IntegerFromString(SEXP, int*);
741 double Rf_RealFromString(SEXP, int*);
742 Rcomplex Rf_ComplexFromString(SEXP, int*);
743 SEXP Rf_StringFromLogical(int, int*);
744 SEXP Rf_StringFromInteger(int, int*);
745 SEXP Rf_StringFromReal(double, int*);
746 SEXP Rf_StringFromComplex(Rcomplex, int*);
747 SEXP Rf_EnsureString(SEXP);
748 
749 /* Other Internally Used Functions */
750 
751 SEXP Rf_allocCharsxp(R_len_t);
752 SEXP Rf_append(SEXP, SEXP); /* apparently unused now */
753 void Rf_check1arg(SEXP, SEXP, const char *);
754 void Rf_checkArityCall(SEXP, SEXP, SEXP);
755 void R_check_locale(void);
756 void Rf_CleanEd(void);
757 void Rf_copyListMatrix(SEXP, SEXP, Rboolean);
758 void Rf_copyMostAttribNoTs(SEXP, SEXP);
759 double currentTime(void);
760 void Rf_CustomPrintValue(SEXP, SEXP);
761 void Rf_DataFrameClass(SEXP);
762 SEXP Rf_ddfindVar(SEXP, SEXP);
763 SEXP Rf_deparse1(SEXP,Rboolean,int);
764 SEXP Rf_deparse1line(SEXP,Rboolean);
765 SEXP Rf_deparse1s(SEXP call);
766 int Rf_DispatchOrEval(SEXP, SEXP, const char *, SEXP, SEXP, SEXP*, int, int);
767 int Rf_DispatchGroup(const char *, SEXP,SEXP,SEXP,SEXP,SEXP*);
768 SEXP duplicated(SEXP, Rboolean);
769 SEXP duplicated3(SEXP, SEXP, Rboolean);
770 int any_duplicated(SEXP, Rboolean);
771 int any_duplicated3(SEXP, SEXP, Rboolean);
772 int Rf_envlength(SEXP);
773 SEXP Rf_evalListKeepMissing(SEXP, SEXP);
774 int Rf_factorsConform(SEXP, SEXP);
775 SEXP Rf_findVar1(SEXP, SEXP, SEXPTYPE, int);
776 void Rf_FrameClassFix(SEXP);
777 SEXP Rf_frameSubscript(int, SEXP, SEXP);
778 int Rf_get1index(SEXP, SEXP, int, int, int, SEXP);
779 SEXP Rf_getVar(SEXP, SEXP);
780 SEXP Rf_getVarInFrame(SEXP, SEXP);
781 void Rf_InitArithmetic(void);
782 void Rf_InitColors(void);
783 void Rf_InitConnections(void);
784 void Rf_InitEd(void);
785 void Rf_InitFunctionHashing(void);
786 void Rf_InitGlobalEnv(void);
787 Rboolean R_current_trace_state(void);
788 Rboolean R_has_methods(SEXP);
789 void R_InitialData(void);
790 
791 #ifdef __cplusplus
792 } // extern "C"
793 std::pair<bool, SEXP> R_possible_dispatch(SEXP, SEXP, SEXP, SEXP, Rboolean);
794 extern "C" {
795 #endif
796 
797 void Rf_InitGraphics(void);
798 void Rf_InitMemory(void);
799 void Rf_InitNames(void);
800 void Rf_InitOptions(void);
801 void Rf_InitStringHash(void);
802 void Init_R_Variables(SEXP);
803 void Rf_InitTempDir(void);
804 void Rf_initStack(void);
805 void Rf_internalTypeCheck(SEXP, SEXP, SEXPTYPE);
806 Rboolean isMethodsDispatchOn(void);
807 int Rf_isValidName(const char *);
808 void Rf_KillAllDevices(void);
809 SEXP Rf_levelsgets(SEXP, SEXP);
810 void Rf_mainloop(void);
811 SEXP Rf_makeSubscript(SEXP, SEXP, int *, SEXP);
812 SEXP Rf_markKnown(const char *, SEXP);
813 SEXP Rf_mat2indsub(SEXP, SEXP, SEXP);
814 SEXP Rf_matchArg(SEXP, SEXP*);
815 SEXP Rf_matchArgExact(SEXP, SEXP*);
816 SEXP Rf_matchArgs(SEXP, SEXP, SEXP);
817 SEXP Rf_matchPar(const char *, SEXP*);
818 SEXP Rf_mkCLOSXP(SEXP, SEXP, SEXP);
819 SEXP Rf_mkFalse(void);
821 SEXP Rf_mkQUOTE(SEXP);
822 SEXP Rf_mkTrue(void);
823 SEXP Rf_NewEnvironment(SEXP, SEXP, SEXP);
824 void Rf_onintr(void);
825 RETSIGTYPE Rf_onsigusr1(int);
826 RETSIGTYPE Rf_onsigusr2(int);
827 int Rf_OneIndex(SEXP, SEXP, int, int, SEXP*, int, SEXP);
828 SEXP Rf_parse(FILE*, int);
829 void Rf_PrintDefaults(void);
830 void Rf_PrintGreeting(void);
831 void Rf_PrintValueEnv(SEXP, SEXP);
832 void Rf_PrintValueRec(SEXP, SEXP);
833 void Rf_PrintVersion(char *);
834 void Rf_PrintVersionString(char *);
835 void Rf_PrintWarnings(void);
836 void PrintVersion_part_1(char *);
837 void process_site_Renviron(void);
838 void process_system_Renviron(void);
839 void process_user_Renviron(void);
840 SEXP Rf_promiseArgs(SEXP, SEXP);
841 void Rcons_vprintf(const char *, va_list);
842 SEXP R_data_class(SEXP , Rboolean);
843 SEXP R_data_class2(SEXP);
844 char *R_LibraryFileName(const char *, char *, size_t);
845 SEXP R_LoadFromFile(FILE*, int);
846 SEXP R_NewHashedEnv(SEXP, SEXP);
847 extern int R_Newhashpjw(const char *);
848 FILE* R_OpenLibraryFile(const char *);
849 SEXP R_Primitive(const char *);
850 void R_RestoreGlobalEnv(void);
851 void R_RestoreGlobalEnvFromFile(const char *, Rboolean);
852 void R_SaveGlobalEnv(void);
853 void R_SaveGlobalEnvToFile(const char *);
854 void R_SaveToFile(SEXP, FILE*, int);
855 void R_SaveToFileV(SEXP, FILE*, int, int);
856 Rboolean R_seemsOldStyleS4Object(SEXP object);
857 int R_SetOptionWarn(int);
858 int R_SetOptionWidth(int);
859 void R_Suicide(const char *);
860 void R_getProcTime(double *data);
861 int R_isMissing(SEXP symbol, SEXP rho);
862 void Rf_sortVector(SEXP, Rboolean);
863 void Rf_SrcrefPrompt(const char *, SEXP);
864 #ifdef __cplusplus
865 void Rf_ssort(CXXR::StringVector*,int);
866 #endif
867 SEXP Rf_strmat2intmat(SEXP, SEXP, SEXP);
868 SEXP Rf_substituteList(SEXP, SEXP);
869 Rboolean Rf_tsConform(SEXP,SEXP);
870 SEXP Rf_tspgets(SEXP, SEXP);
871 SEXP Rf_type2symbol(SEXPTYPE);
872 void Rf_unbindVar(SEXP, SEXP);
873 #ifdef ALLOW_OLD_SAVE
874 void unmarkPhase(void);
875 #endif
876 SEXP R_LookupMethod(SEXP, SEXP, SEXP, SEXP);
877 int Rf_usemethod(const char *, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP*);
878 SEXP vectorIndex(SEXP, SEXP, int, int, int, SEXP);
879 SEXP Rf_vectorSubscript(int, SEXP, int*, SEXP (*)(SEXP,SEXP),
880  SEXP (*)(SEXP, int), SEXP, SEXP);
881 
882 /* ../main/bind.c */
883 SEXP Rf_ItemName(SEXP, int);
884 
885 /* ../main/errors.c : */
886 void Rf_ErrorMessage(SEXP, int, ...);
887 void Rf_WarningMessage(SEXP, R_WARNING, ...);
888 SEXP R_GetTraceback(int);
889 
890 R_size_t R_GetMaxVSize(void);
891 void R_SetMaxVSize(R_size_t);
892 R_size_t R_GetMaxNSize(void);
893 void R_SetMaxNSize(R_size_t);
894 R_size_t R_Decode2Long(char *p, int *ierr);
895 void R_SetPPSize(R_size_t);
896 
897 /* ../main/devices.c, used in memory.c, gnuwin32/extra.c */
898 #define R_MaxDevices 64
899 
900 /* ../../main/printutils.c : */
901 typedef enum {
902  Rprt_adj_left = 0,
903  Rprt_adj_right = 1,
904  Rprt_adj_centre = 2,
905  Rprt_adj_none = 3
906 } Rprt_adj;
907 
908 int Rstrlen(SEXP, int);
909 const char *Rf_EncodeRaw(Rbyte);
910 const char *Rf_EncodeString(SEXP, int, int, Rprt_adj);
911 const char *EncodeReal2(double, int, int, int);
912 
913 
914 /* main/sort.c */
915 void orderVector1(int *indx, int n, SEXP key, Rboolean nalast,
916  Rboolean decreasing, SEXP rho);
917 
918 /* main/subset.c */
919 SEXP R_subset3_dflt(SEXP, SEXP, SEXP);
920 
921 /* main/subassign.c */
922 SEXP R_subassign3_dflt(SEXP, SEXP, SEXP, SEXP);
923 
924 #include <wchar.h>
925 
926 /* main/util.c */
927 void UNIMPLEMENTED_TYPE(const char *s, SEXP x);
928 void UNIMPLEMENTED_TYPEt(const char *s, SEXPTYPE t);
929 Rboolean Rf_strIsASCII(const char *str);
930 int utf8clen(char c);
931 
932 typedef unsigned short ucs2_t;
933 size_t mbcsToUcs2(const char *in, ucs2_t *out, int nout, int enc);
934 /* size_t mbcsMblen(char *in);
935 size_t ucs2ToMbcs(ucs2_t *in, char *out);
936 size_t ucs2Mblen(ucs2_t *in); */
937 size_t Rf_utf8toucs(wchar_t *wc, const char *s);
938 size_t Rf_utf8towcs(wchar_t *wc, const char *s, size_t n);
939 size_t Rf_ucstomb(char *s, const unsigned int wc);
940 size_t Rf_ucstoutf8(char *s, const unsigned int wc);
941 size_t Rf_mbtoucs(unsigned int *wc, const char *s, size_t n);
942 size_t Rf_wcstoutf8(char *s, const wchar_t *wc, size_t n);
943 
944 const wchar_t *Rf_wtransChar(SEXP x); /* from sysutils.c */
945 
946 #define mbs_init(x) memset(x, 0, sizeof(mbstate_t))
947 size_t Rf_mbrtowc(wchar_t *wc, const char *s, size_t n, mbstate_t *ps);
948 Rboolean mbcsValid(const char *str);
949 Rboolean utf8Valid(const char *str);
950 char *Rf_strchr(const char *s, int c);
951 char *Rf_strrchr(const char *s, int c);
952 
953 #ifdef Win32
954 void R_fixslash(char *s);
955 void R_fixbackslash(char *s);
956 wchar_t *filenameToWchar(const SEXP fn, const Rboolean expand);
957 
958 #if defined(SUPPORT_UTF8_WIN32)
959 #define mbrtowc(a,b,c,d) Rmbrtowc(a,b)
960 #define wcrtomb(a,b,c) Rwcrtomb(a,b)
961 #define mbstowcs(a,b,c) Rmbstowcs(a,b,c)
962 #define wcstombs(a,b,c) Rwcstombs(a,b,c)
963 size_t Rmbrtowc(wchar_t *wc, const char *s);
964 size_t Rwcrtomb(char *s, const wchar_t wc);
965 size_t Rmbstowcs(wchar_t *wc, const char *s, size_t n);
966 size_t Rwcstombs(char *s, const wchar_t *wc, size_t n);
967 #endif
968 #endif
969 
970 FILE *RC_fopen(const SEXP fn, const char *mode, const Rboolean expand);
971 int Rf_Seql(SEXP a, SEXP b);
972 int Scollate(SEXP a, SEXP b);
973 
974 double R_strtod4(const char *str, char **endptr, char dec, Rboolean NA);
975 double R_strtod(const char *str, char **endptr);
976 double R_atof(const char *str);
977 
978 /* unix/sys-std.c, main/options.c */
979 void set_rl_word_breaks(const char *str);
980 
981 /* From localecharset.c */
982 extern const char *locale2charset(const char *);
983 
984 /* Localization */
985 
986 #ifdef ENABLE_NLS
987 #include <libintl.h>
988 #ifdef Win32
989 #define _(String) libintl_gettext (String)
990 #undef gettext /* needed for graphapp */
991 #else
992 #define _(String) gettext (String)
993 #endif
994 #define gettext_noop(String) String
995 #define N_(String) gettext_noop (String)
996 #else /* not NLS */
997 #define _(String) (String)
998 #define N_(String) String
999 #define ngettext(String, StringP, N) (N > 1 ? StringP: String)
1000 #endif
1001 
1002 
1003 /* Macros for suspending interrupts: also in GraphicsDevice.h */
1004 #define BEGIN_SUSPEND_INTERRUPTS do { \
1005  Rboolean __oldsusp__ = R_interrupts_suspended; \
1006  R_interrupts_suspended = TRUE;
1007 #define END_SUSPEND_INTERRUPTS R_interrupts_suspended = __oldsusp__; \
1008  if (R_interrupts_pending && ! R_interrupts_suspended) \
1009  onintr(); \
1010 } while(0)
1011 
1012 
1013 #ifdef __GNUC__
1014 # undef alloca
1015 # define alloca(x) __builtin_alloca((x))
1016 #else
1017 # ifdef HAVE_ALLOCA_H
1018 # include <alloca.h>
1019 # endif
1020 # if !HAVE_DECL_ALLOCA
1021 extern void *alloca(size_t);
1022 # endif
1023 #endif
1024 
1025 
1026 /*
1027  * 2007/06/06 arr:
1028  * Function prototypes that don't appear to be defined anywhere else:
1029  */
1030 
1031 Rboolean R_access_X11(void); /* from src/unix/X11.c */
1032 SEXP R_execMethod(SEXP op, SEXP rho);
1033 double R_getClockIncrement();
1034 SEXP do_gpregexpr(SEXP pat, SEXP vec, int igcase_opt, int useBytes);
1035 SEXP do_pgsub(SEXP pat, SEXP rep, SEXP vec,
1036  int global, int igcase_opt, int useBytes);
1037 const wchar_t *wtransChar(SEXP x);
1038 
1039 #ifdef __cplusplus
1040 } /* extern "C" */
1041 #endif
1042 #endif /* DEFN_H_ */
1043 /*
1044  *- Local Variables:
1045  *- page-delimiter: "^/\\*---"
1046  *- End:
1047  */