search for: setcar

Displaying 20 results from an estimated 38 matches for "setcar".

2010 May 06
1
R on kdeedu-svn library problem
...$SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:143: undefined reference to `Rf_allocVector' $SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:143: undefined reference to `Rf_protect' $SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:144: undefined reference to `SETCAR' $SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:147: undefined reference to `R_GlobalEnv' $SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:147: undefined reference to `CDR' $SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:147: undefined reference to `CDR&...
2008 Mar 29
0
"Writing R Extensions": bad example with CAR / CDR as lvalues (PR#11054)
...probably have spotted immediatly) that the example is taken from a code snipped that imports Rinternals.h with defined USE_RINTERNALS, while I followed the manual's advice to not define USE_RINTERNALS for extensions. Maybe you could add a note in this section of the manual that one should use SETCAR and SETCDR instead. A more illustrative example would be even better. Just in case you want to use it as example, here is my code. I hope it is correct in your expert eyes. /* Remove the variable with name s from the environment ev, i.e. construct the call: rm( list=s, envir=ev ) */...
2008 Mar 31
1
(PR#11054) "Writing R Extensions": bad example with CAR /
...mmediatly) that the example is taken from a code snipped that imports > Rinternals.h with defined USE_RINTERNALS, while I followed the manual's advice > to not define USE_RINTERNALS for extensions. > > Maybe you could add a note in this section of the manual that one should use > SETCAR and SETCDR instead. A more illustrative example would be even better. > > > Just in case you want to use it as example, here is my code. I hope it is > correct in your expert eyes. > > /* Remove the variable with name s from the environment ev, > i.e. construct the call:...
2017 Apr 30
1
`match.call` and dots substitution
...uted by `..n` where `n` is the position in dots. When they are scalars they are substituted with the scalar. It appears this is done in 'R-3.4.0:src/main/unique.c at 1319' in `subDots`: while (TYPEOF(t) == PROMSXP) t = PREXPR(t); if( isSymbol(t) || isLanguage(t) ) SETCAR(b, installDDVAL(i)); else SETCAR(b, t); I'm not sure why it is necessary to use `installDDVAL`, which creates the `..n` symbols, instead of duplicating the language object and attaching that to the matched call. Certainly from a user perspective I would prefer to see: ## fun1(...
2017 Mar 03
2
Control statements with condition with greater than one should give error (not just warning) [PATCH]
...or.messages" @@ -248,9 +249,9 @@ char *p; #ifdef HAVE_RL_COMPLETION_MATCHES + PROTECT(v = val = allocList(22)); +#else PROTECT(v = val = allocList(21)); -#else - PROTECT(v = val = allocList(20)); #endif SET_TAG(v, install("prompt")); @@ -289,6 +290,10 @@ SETCAR(v, ScalarLogical(0)); /* no checking */ v = CDR(v); + SET_TAG(v, install("check.condition")); + SETCAR(v, ScalarLogical(0)); /* no checking */ + v = CDR(v); + p = getenv("R_KEEP_PKG_SOURCE"); R_KeepSource = (p && (strcmp(p, "yes") == 0)...
2008 Apr 24
1
Calling R functions with multiple arguments from C
...#39;ve modified. I've read that discussion, but still got stuck. Could anybody point me in the right direction? SEXP foo(SEXP fn, SEXP elmt1, SEXP elmt2, SEXP rho) { SEXP R_fcall, args, ans,s; PROTECT( args = s = allocList(2)); PROTECT( R_fcall = lang2(fn, R_NilValue) ); SETCAR(s,elmt1); SET_TAG(s,install("x")); s = CDR(s); SETCAR(s,elmt2); SET_TAG(s,install("y")); SETCADR( R_fcall, args); PROTECT( ans = eval(R_fcall, rho) ); UNPROTECT(3); return ans; } foo.func <- function(x,y)match.call() >.Call("fo...
2009 Jan 08
1
Callbacks seems to get GCed.
...{ {NULL} }; R_CallMethodDef callMethods[] = { {"set_callback1", (DL_FUNC) &set_callback1, 1}, {"set_callback2", (DL_FUNC) &set_callback2, 1}, {NULL} }; void r_trigger_callback1() { int errorOccurred; SEXP f = NULL; f = allocVector(LANGSXP, 1); SETCAR(f, callback1); PROTECT(f); R_tryEval(f, R_GlobalEnv, &errorOccurred); UNPROTECT(1); } void r_trigger_callback2() { int errorOccurred; SEXP f = NULL; f = allocVector(LANGSXP, 1); SETCAR(f, callback2); PROTECT(f); R_tryEval(f, R_GlobalEnv, &errorOccurred); UNPR...
2019 Jul 13
2
Mitigating Stalls Caused by Call Deparse on Error
...ngs(); ???? } ?} - +/* + * Return the traceback without deparsing the calls + */ ?attribute_hidden -SEXP R_GetTraceback(int skip) +SEXP R_GetTracebackParsed(int skip) ?{ ???? int nback = 0, ns; ???? RCNTXT *c; @@ -1467,7 +1469,9 @@ ??? ???? if (skip > 0) ??? ??? ?skip--; ??? ???? else { -?? ??? ?SETCAR(t, deparse1m(c->call, 0, DEFAULTDEPARSE)); +??????????????? // Extra paranoid PROTECTS +?? ??? ?SETCAR(t, PROTECT(duplicate(c->call))); +??????????????? UNPROTECT(1); ??? ??? ?if (c->srcref && !isNull(c->srcref)) { ??? ??? ???? SEXP sref; ??? ??? ???? if (c->srcref == R_InBCI...
2008 Jun 18
2
embedding R in c++ (Qt) application
...R from a Qt-GUI-application (C++). I've been able to link with R libraries, but I'm having a hard time to understand the C-coding examples. I'm a C++, not a C programmer (never used malloc before), and many of the R-specific functions/keywords/macros (for instance (UN)PROTECT, SETCAR, all the data types (SEXP, CHARSXP etc..) ) don't mean anything to me. The section on the SEXP type in the R-internals doc didn't tell me much. How can I create such objects containing my data? how can I extract numbers or strings from SEXPs? Can you suggest me a helpfile/documentat...
2004 Aug 18
3
R as shared library
...) and the following code: /* override to call apache library write routine */ ptr_R_WriteConsole = Rapache_WriteConsole; /* load source(). I assume this is appropriate. I could always move this to the code that handles the requst */ PROTECT(R_source_fun = allocVector(LANGSXP, 2)); SETCAR(R_source_fun, Rf_install("source")); SETCAR(CDR(R_source_fun), R_source_arg = NEW_CHARACTER(1)); Then each request is serviced by the following code: /* r is apache request, r->filename is url translated to apsolute path to filename */ SET_STRING_ELT(R_source_arg, 0, COPY_...
2017 Mar 03
0
Control statements with condition with greater than one should give error (not just warning) [PATCH]
..._RL_COMPLETION_MATCHES > + PROTECT(v = val = allocList(22)); > +#else > PROTECT(v = val = allocList(21)); > -#else > - PROTECT(v = val = allocList(20)); > #endif > SET_TAG(v, install("prompt")); > @@ -289,6 +290,10 @@ > SETCAR(v, ScalarLogical(0)); /* no checking */ > v = CDR(v); > + SET_TAG(v, install("check.condition")); > + SETCAR(v, ScalarLogical(0)); /* no checking */ > + v = CDR(v); > + > p = getenv("R_KEEP_PKG_SOURCE"); > R_KeepSource =...
2019 Jul 14
2
[External] Mitigating Stalls Caused by Call Deparse on Error
...rsing the calls > + */ > ?attribute_hidden > -SEXP R_GetTraceback(int skip) > +SEXP R_GetTracebackParsed(int skip) > ?{ > ???? int nback = 0, ns; > ???? RCNTXT *c; > @@ -1467,7 +1469,9 @@ > ??? ???? if (skip > 0) > ??? ??? ?skip--; > ??? ???? else { > -?? ??? ?SETCAR(t, deparse1m(c->call, 0, DEFAULTDEPARSE)); > +??????????????? // Extra paranoid PROTECTS > +?? ??? ?SETCAR(t, PROTECT(duplicate(c->call))); > +??????????????? UNPROTECT(1); > ??? ??? ?if (c->srcref && !isNull(c->srcref)) { > ??? ??? ???? SEXP sref; > ??? ??? ??...
2015 Oct 30
0
match.call enhancements in 3.2.2
...ippet from that function: >??? for(a = dots, b = rval, i = 1; i <= len; a = CDR(a), b = CDR(b), i++) { >??? ??? SET_TAG(b, TAG(a)); >??? ??? t = CAR(a); >??? ??? while (TYPEOF(t) == PROMSXP) >??? ??? ??? t = PREXPR(t); >??? ??? if( isSymbol(t) || isLanguage(t) ) >??? ??? ??? SETCAR(b, installDDVAL(i));?? // <-- HERE >??? ??? else >??? ??? ??? SETCAR(b, t); >??? } The `installDDVAL(i)` generates the `..X` symbols.? I'm sure there is a very good reason why this is done, but then it does lead to the issues above. Am I just doing something wrong? My workaround (h...
2010 Sep 09
0
calling Rf_initEmbeddedR error
...oad SEXP fun; PROTECT(e = allocVector(LANGSXP, 3)); fun = findFun(install("hreg"), R_GlobalEnv); if(fun == R_NilValue) // -----> success { UNPROTECT(1); throw std::range_error("R Function not found"); } SETCAR(e, fun); UNPROTECT(1); // End R R_dot_Last(); Rf_endEmbeddedR(0); R_gc(); ///////////////////////////// // Init R(second) Rf_initEmbeddedR(Argc2, Argv2); // R package load e = R_NilValue; r = R_NilValue; PROTECT(e = lang2(install(&quot...
2017 Mar 03
2
Control statements with condition with greater than one should give error (not just warning) [PATCH]
...(v = val = allocList(22)); > > +#else > > PROTECT(v = val = allocList(21)); > > -#else > > - PROTECT(v = val = allocList(20)); > > #endif > > > SET_TAG(v, install("prompt")); > > @@ -289,6 +290,10 @@ > > SETCAR(v, ScalarLogical(0)); /* no checking */ > > v = CDR(v); > > > + SET_TAG(v, install("check.condition")); > > + SETCAR(v, ScalarLogical(0)); /* no checking */ > > + v = CDR(v); > > + > > p = getenv("R_KEEP_PKG_SOUR...
2019 Jul 16
1
[External] Mitigating Stalls Caused by Call Deparse on Error
...ck(int skip) >>> +SEXP R_GetTracebackParsed(int skip) >>> { >>> int nback = 0, ns; >>> RCNTXT *c; >>> @@ -1467,7 +1469,9 @@ >>> if (skip > 0) >>> skip--; >>> else { >>> - SETCAR(t, deparse1m(c->call, 0, DEFAULTDEPARSE)); >>> + // Extra paranoid PROTECTS >>> + SETCAR(t, PROTECT(duplicate(c->call))); >>> + UNPROTECT(1); >>> if (c->srcref && !isNull(c->srcref)) { >>>...
2019 Jul 14
0
[External] Mitigating Stalls Caused by Call Deparse on Error
...rsing the calls > + */ > ?attribute_hidden > -SEXP R_GetTraceback(int skip) > +SEXP R_GetTracebackParsed(int skip) > ?{ > ???? int nback = 0, ns; > ???? RCNTXT *c; > @@ -1467,7 +1469,9 @@ > ??? ???? if (skip > 0) > ??? ??? ?skip--; > ??? ???? else { > -?? ??? ?SETCAR(t, deparse1m(c->call, 0, DEFAULTDEPARSE)); > +??????????????? // Extra paranoid PROTECTS > +?? ??? ?SETCAR(t, PROTECT(duplicate(c->call))); > +??????????????? UNPROTECT(1); > ??? ??? ?if (c->srcref && !isNull(c->srcref)) { > ??? ??? ???? SEXP sref; > ??? ??? ??...
2004 Oct 08
2
R-2.0.0 findVar and findFun question
Dear all, when working on a project with embedded R, I found out that R-2.0.0 causes a problem where older versions worked OK. Rf_findVar(...) causes the following error when used to find a generic function (such as print): fun = Rf_findVar(...); R_tryEval(fun, ...); Error in function (object, ...) : Invalid generic function in usemethod Alternatively, using Rf_findFun(...) seems OK in this
2019 Jul 15
0
[External] Mitigating Stalls Caused by Call Deparse on Error
...e_hidden >> -SEXP R_GetTraceback(int skip) >> +SEXP R_GetTracebackParsed(int skip) >> ?{ >> ???? int nback = 0, ns; >> ???? RCNTXT *c; >> @@ -1467,7 +1469,9 @@ >> ??? ???? if (skip > 0) >> ??? ??? ?skip--; >> ??? ???? else { >> -?? ??? ?SETCAR(t, deparse1m(c->call, 0, DEFAULTDEPARSE)); >> +??????????????? // Extra paranoid PROTECTS >> +?? ??? ?SETCAR(t, PROTECT(duplicate(c->call))); >> +??????????????? UNPROTECT(1); >> ??? ??? ?if (c->srcref && !isNull(c->srcref)) { >> ??? ??? ???? SEXP s...
2015 Aug 25
0
Child thread libR.so
...off */ aperm_function = findFun(install("aperm"), R_GlobalEnv); if (aperm_function == NULL || aperm_function == R_NilValue || aperm_function == R_UnboundValue) { aperm_function = NULL; } else { aperm_expression = PROTECT(allocVector(LANGSXP, 2)); SETCAR(aperm_expression, aperm_function); } } ---------- SNIP ---------------- This now behaves appropriately from a child thread in my custom front end. thank you again Simon, Ryan > Ryan, > > if you read the piece you quoted from more carefully, you'll notice it says "Rf_initial...