50 #define RBOOL(x) Rboolean(x)
57 #if __GNUC__ == 4 && __GNUC_MINOR__ >= 3 && defined(__GNUC_STDC_INLINE__) && !defined(C99_INLINE_SEMANTICS)
58 #define C99_INLINE_SEMANTICS 1
62 #if __APPLE_CC__ > 5400 && !defined(C99_INLINE_SEMANTICS) && __STDC_VERSION__ >= 199901L
63 #define C99_INLINE_SEMANTICS 1
77 # if defined(__GNUC_STDC_INLINE__) || defined(__GNUC_GNU_INLINE__)
78 # define INLINE_FUN extern __attribute__((gnu_inline)) inline
80 # define INLINE_FUN extern R_INLINE
84 #if C99_INLINE_SEMANTICS
88 # define INLINE_FUN extern inline
91 # define INLINE_FUN inline
106 R_len_t Rf_length(
SEXP s);
117 INLINE_FUN
SEXP Rf_elt(
SEXP list,
int i)
122 if ((i < 0) || (i > Rf_length(list)))
125 for (j = 0; j < i; j++)
126 result =
CDR(result);
133 INLINE_FUN
SEXP Rf_lastElt(
SEXP list)
135 SEXP result = R_NilValue;
136 while (list != R_NilValue) {
148 return CONS(s, R_NilValue);
155 s = CONS(s, Rf_list1(t));
164 s = CONS(s, Rf_list2(t, u));
173 s = CONS(s, Rf_list3(t, u, v));
181 s = CONS(s, Rf_list4(t, u, v, w));
195 while (
CDR(r) != R_NilValue)
209 return LCONS(s, R_NilValue);
215 s = LCONS(s, Rf_list1(t));
223 s = LCONS(s, Rf_list2(t, u));
231 s = LCONS(s, Rf_list3(t, u, v));
239 s = LCONS(s, Rf_list4(t, u, v, w));
247 s = LCONS(s, Rf_list5(t, u, v, w, x));
256 INLINE_FUN Rboolean Rf_conformable(
SEXP x,
SEXP y)
262 if ((n = Rf_length(x)) != Rf_length(y))
264 for (i = 0; i < n; i++)
273 INLINE_FUN Rboolean Rf_inherits(
SEXP s,
const char *name)
279 nclass = Rf_length(klass);
280 for (i = 0; i < nclass; i++) {
281 if (!strcmp(CHAR(
STRING_ELT(klass, i)), name))
288 INLINE_FUN Rboolean Rf_isValidString(
SEXP x)
295 INLINE_FUN Rboolean Rf_isValidStringF(
SEXP x)
297 return RBOOL(Rf_isValidString(x) && CHAR(
STRING_ELT(x, 0))[0]);
300 INLINE_FUN Rboolean Rf_isUserBinop(
SEXP s)
304 if (strlen(str) >= 2 && str[0] ==
'%' && str[strlen(str)-1] ==
'%')
310 INLINE_FUN Rboolean Rf_isFunction(
SEXP s)
317 INLINE_FUN Rboolean Rf_isPrimitive(
SEXP s)
323 INLINE_FUN Rboolean Rf_isList(
SEXP s)
329 INLINE_FUN Rboolean Rf_isNewList(
SEXP s)
334 INLINE_FUN Rboolean Rf_isPairList(
SEXP s)
346 INLINE_FUN Rboolean Rf_isVectorList(
SEXP s)
357 INLINE_FUN Rboolean Rf_isVectorAtomic(
SEXP s)
372 INLINE_FUN Rboolean Rf_isFrame(
SEXP s)
378 for (i = 0; i < Rf_length(klass); i++)
379 if (!strcmp(CHAR(
STRING_ELT(klass, i)),
"data.frame"))
return TRUE;
384 INLINE_FUN Rboolean Rf_isLanguage(
SEXP s)
389 INLINE_FUN Rboolean Rf_isMatrix(
SEXP s)
402 INLINE_FUN Rboolean Rf_isArray(
SEXP s)
415 INLINE_FUN Rboolean Rf_isTs(
SEXP s)
420 INLINE_FUN Rboolean Rf_isInteger(
SEXP s)
422 return RBOOL(
TYPEOF(s) ==
INTSXP && !Rf_inherits(s,
"factor"));
425 INLINE_FUN Rboolean Rf_isFactor(
SEXP s)
427 return RBOOL(
TYPEOF(s) ==
INTSXP && Rf_inherits(s,
"factor"));
430 INLINE_FUN
int Rf_nlevels(
SEXP f)
441 INLINE_FUN Rboolean Rf_isNumeric(
SEXP s)
445 if (Rf_inherits(s,
"factor"))
return FALSE;
455 INLINE_FUN Rboolean Rf_isNumber(
SEXP s)
459 if (Rf_inherits(s,
"factor"))
return FALSE;
470 INLINE_FUN
SEXP Rf_ScalarLogical(
int x)
473 if (x == NA_LOGICAL)
LOGICAL(ans)[0] = NA_LOGICAL;
474 else LOGICAL(ans)[0] = (x != 0);
478 INLINE_FUN
SEXP Rf_ScalarInteger(
int x)
485 INLINE_FUN
SEXP Rf_ScalarReal(
double x)
493 INLINE_FUN
SEXP Rf_ScalarComplex(Rcomplex x)
500 INLINE_FUN
SEXP Rf_ScalarString(
SEXP x)
510 INLINE_FUN
SEXP Rf_ScalarRaw(Rbyte x)
521 INLINE_FUN Rboolean Rf_isVectorizable(
SEXP s)
523 if (s == R_NilValue)
return TRUE;
524 else if (Rf_isNewList(s)) {
528 for (i = 0 ; i < n; i++)
533 else if (Rf_isList(s)) {
534 for ( ; s != R_NilValue; s =
CDR(s))
554 INLINE_FUN
SEXP mkNamed(
SEXPTYPE TYP,
const char **names)
559 for (n = 0; strlen(names[n]) > 0; n++) {}
562 for (i = 0; i < n; i++)
573 INLINE_FUN
SEXP Rf_mkString(
const char *s)