s_object * RS_PostgreSQL_closeConnection(Con_Handle * conHandle) { S_EVALUATOR RS_DBI_connection * con; PGconn *my_connection; s_object *status; con = RS_DBI_getConnection(conHandle); if (con->num_res > 0) { RS_DBI_errorMessage("close the pending result sets before closing this connection", RS_DBI_ERROR); } /* make sure we first free the conParams and postgresql connection from * the RS-RBI connection object. */ if (con->conParams) { RS_PostgreSQL_freeConParams(con->conParams); con->conParams = (RS_PostgreSQL_conParams *) NULL; } my_connection = (PGconn *) con->drvConnection; PQfinish(my_connection); con->drvConnection = (void *) NULL; RS_DBI_freeConnection(conHandle); MEM_PROTECT(status = NEW_LOGICAL((Sint) 1)); LGL_EL(status, 0) = TRUE; MEM_UNPROTECT(1); return status; }
SEXP RGDAL_GetGeoTransform(SEXP sxpDataset) { GDALDataset *pDataset = getGDALDatasetPtr(sxpDataset); SEXP sxpGeoTrans = allocVector(REALSXP, 6); SEXP ceFail = NEW_LOGICAL(1); LOGICAL_POINTER(ceFail)[0] = FALSE; installErrorHandler(); CPLErr err = pDataset->GetGeoTransform(REAL(sxpGeoTrans)); if (err == CE_Failure) { REAL(sxpGeoTrans)[0] = 0; // x-origin ul REAL(sxpGeoTrans)[1] = 1; // x-resolution (pixel width) REAL(sxpGeoTrans)[2] = 0; // x-oblique REAL(sxpGeoTrans)[3] = (double) pDataset->GetRasterYSize(); // y-origin ul; 091028 REAL(sxpGeoTrans)[4] = 0; // y-oblique REAL(sxpGeoTrans)[5] = -1; // y-resolution (pixel height); 091028 added sign LOGICAL_POINTER(ceFail)[0] = TRUE; } setAttrib(sxpGeoTrans, install("CE_Failure"), ceFail); uninstallErrorHandlerAndTriggerError(); return(sxpGeoTrans); }
/* * TODO: This is not needed anymore now that the 'cirl' slot has been * replaced by the 'cnirl' slot which is guaranteed to hold a * CompressedNormalIRangesList object (instead of just a CompressedIRangesList * object for the old slot). Hence the validity method for GappedRanges * should just check that all the elements in 'x@cnirl' are of length >= 1 * (which can be done in R with elementLengths()). * * We assume that 'x@cnirl' is already a valid CompressedIRangesList object. * Here we only check that its elements are normal and of length >= 1. * ans_type: a single integer specifying the type of answer to return: * 0: 'ans' is a string describing the first validity failure or NULL; * 1: 'ans' is logical vector with TRUE values for valid elements in 'x'. */ SEXP valid_GappedRanges(SEXP x, SEXP ans_type) { SEXP cnirl, ans; cachedCompressedIRangesList cached_cnirl; int x_length, ans_type0, i; cachedIRanges cached_ir; const char *errmsg; char string_buf[80]; cnirl = GET_SLOT(x, install("cnirl")); cached_cnirl = _cache_CompressedIRangesList(cnirl); x_length = _get_cachedCompressedIRangesList_length(&cached_cnirl); ans_type0 = INTEGER(ans_type)[0]; if (ans_type0 == 1) PROTECT(ans = NEW_LOGICAL(x_length)); else ans = R_NilValue; for (i = 0; i < x_length; i++) { cached_ir = _get_cachedCompressedIRangesList_elt(&cached_cnirl, i); errmsg = is_valid_GappedRanges_elt(&cached_ir); if (ans_type0 == 1) { LOGICAL(ans)[i] = errmsg == NULL; continue; } if (errmsg != NULL) { snprintf(string_buf, sizeof(string_buf), "element %d is invalid (%s)", i + 1, errmsg); return mkString(string_buf); } } if (ans_type0 == 1) UNPROTECT(1); return ans; }
SEXP RClosureTable_callWithName(R_ObjectTableAction handlerType, const char * const name, R_ObjectTable *tb) { SEXP obj, fun, val, e; int errorOccurred = FALSE; obj = (SEXP) tb->privateData; fun = RClosureTable_getFunction(obj, handlerType); if(!fun || fun == R_NilValue) { return(NEW_LOGICAL(1)); } PROTECT(e = allocVector(LANGSXP,2)); SETCAR(e, fun); SETCAR(CDR(e), val = NEW_CHARACTER(1)); SET_STRING_ELT(val, 0, COPY_TO_USER_STRING(name)); #ifndef TRY_EVAL val = eval(e, R_GlobalEnv); #else val = R_tryEval(e, NULL, &errorOccurred); #endif if(errorOccurred) { UNPROTECT(1); return(R_UnboundValue); } UNPROTECT(1); return(val); }
USER_OBJECT_ RS_PerlClear(USER_OBJECT_ obj) { SV *sv; int n; USER_OBJECT_ ans; dTHX; ans = NEW_LOGICAL(1); sv = RS_PerlGetSV(obj); if(sv == NULL) return(ans); switch(SvTYPE(sv)) { case SVt_PVHV: hv_clear((HV*) sv); break; case SVt_PVAV: av_clear((AV*) sv); break; default: n = 1; break; } LOGICAL_DATA(ans)[0] = TRUE; return(ans); }
/* * 'mode' controls how empty list elements should be represented: * 0 -> integer(0); 1 -> NULL; 2 -> NA */ SEXP _new_LIST_from_IntAEAE(const IntAEAE *aeae, int mode) { int nelt, i; SEXP ans, ans_elt; const IntAE *ae; nelt = _IntAEAE_get_nelt(aeae); PROTECT(ans = NEW_LIST(nelt)); for (i = 0; i < nelt; i++) { ae = aeae->elts[i]; if (_IntAE_get_nelt(ae) != 0 || mode == 0) { PROTECT(ans_elt = _new_INTEGER_from_IntAE(ae)); } else if (mode == 1) { continue; } else { // Not sure new LOGICALs are initialized with NAs, // need to check! If not, then LOGICAL(ans_elt)[0] must // be set to NA but I don't know how to do this :-/ PROTECT(ans_elt = NEW_LOGICAL(1)); } SET_VECTOR_ELT(ans, i, ans_elt); UNPROTECT(1); } UNPROTECT(1); return ans; }
USER_OBJECT_ RS_discardPerlForeignReference(USER_OBJECT_ obj) { const char *key; USER_OBJECT_ ans = NEW_LOGICAL(1); #ifndef USE_NEW_PERL_REFERENCES if(IS_CHARACTER(obj)) { key = CHAR_DEREF(STRING_ELT(obj, 0)); } else { key = CHAR_DEREF(STRING_ELT(VECTOR_ELT(obj, 0), 0)); } LOGICAL_DATA(ans)[0] = discardPerlForeignReference(key, NULL); #else SV *el; dTHX; el = getForeignPerlReference(obj); if(el) { SvREFCNT_dec(obj); LOGICAL_DATA(ans)[0] = 1; } #endif return(ans); }
SEXP checkCRSArgs(SEXP args) { SEXP res; projPJ pj; PROTECT(res = NEW_LIST(2)); SET_VECTOR_ELT(res, 0, NEW_LOGICAL(1)); SET_VECTOR_ELT(res, 1, NEW_CHARACTER(1)); LOGICAL_POINTER(VECTOR_ELT(res, 0))[0] = FALSE; if (!(pj = pj_init_plus(CHAR(STRING_ELT(args, 0))))) { SET_STRING_ELT(VECTOR_ELT(res, 1), 0, COPY_TO_USER_STRING(pj_strerrno(*pj_get_errno_ref()))); UNPROTECT(1); return(res); } SET_STRING_ELT(VECTOR_ELT(res, 1), 0, COPY_TO_USER_STRING(pj_get_def(pj, 0))); LOGICAL_POINTER(VECTOR_ELT(res, 0))[0] = TRUE; UNPROTECT(1); return(res); }
int source(char *file){ SEXP expr, s, f, p; int errorOccurred; /* Find source function */ s = Rf_findFun(Rf_install("source"), R_GlobalEnv); PROTECT(s); /* Make file argument */ PROTECT(f = NEW_CHARACTER(1)); SET_STRING_ELT(f, 0, COPY_TO_USER_STRING(file)); /* Make print.eval argument */ PROTECT(p = NEW_LOGICAL(1)); LOGICAL_DATA(p)[0] = (verbose)? TRUE : FALSE; /* expression source(f,print.eval=p) */ PROTECT(expr = allocVector(LANGSXP,3)); SETCAR(expr,s); SETCAR(CDR(expr),f); SETCAR(CDR(CDR(expr)), p); SET_TAG(CDR(CDR(expr)), Rf_install("print.eval")); errorOccurred=0; R_tryEval(expr,NULL,&errorOccurred); UNPROTECT(4); return errorOccurred; }
SEXP SP_PREFIX(Polygon_validate_c)(SEXP obj) { int pc=0; int n; SEXP coords, labpt, ans; coords = GET_SLOT(obj, install("coords")); n = INTEGER_POINTER(getAttrib(coords, R_DimSymbol))[0]; if (NUMERIC_POINTER(coords)[0] != NUMERIC_POINTER(coords)[n-1] || NUMERIC_POINTER(coords)[n] != NUMERIC_POINTER(coords)[(2*n)-1]) { PROTECT(ans = NEW_CHARACTER(1)); pc++; SET_STRING_ELT(ans, 0, COPY_TO_USER_STRING("ring not closed")); UNPROTECT(pc); return(ans); } labpt = GET_SLOT(obj, install("labpt")); if (!R_FINITE(NUMERIC_POINTER(labpt)[0]) || !R_FINITE(NUMERIC_POINTER(labpt)[1])) { PROTECT(ans = NEW_CHARACTER(1)); pc++; SET_STRING_ELT(ans, 0, COPY_TO_USER_STRING("infinite label point")); UNPROTECT(pc); return(ans); } PROTECT(ans = NEW_LOGICAL(1)); pc++; LOGICAL_POINTER(ans)[0] = TRUE; UNPROTECT(pc); return(ans); }
SEXP SP_PREFIX(SpatialPolygons_validate_c)(SEXP obj) { int pc=0; int i, n; SEXP pls, ans; char *cls="Polygons"; PROTECT(pls = GET_SLOT(obj, install("polygons"))); pc++; n = length(pls); for (i=0; i<n; i++) { if (strcmp(CHAR(STRING_ELT(getAttrib(VECTOR_ELT(pls, i), R_ClassSymbol), 0)), cls) != 0) { PROTECT(ans = NEW_CHARACTER(1)); pc++; SET_STRING_ELT(ans, 0, COPY_TO_USER_STRING("polygons slot contains non-Polygons object")); UNPROTECT(pc); return(ans); } } if (n != length(GET_SLOT(obj, install("plotOrder")))) { PROTECT(ans = NEW_CHARACTER(1)); pc++; SET_STRING_ELT(ans, 0, COPY_TO_USER_STRING("plotOrder and polygons differ in length")); UNPROTECT(pc); return(ans); } PROTECT(ans = NEW_LOGICAL(1)); pc++; LOGICAL_POINTER(ans)[0] = TRUE; UNPROTECT(pc); return(ans); }
USER_OBJECT_ RS_GGOBI(getDisplayOptions)(USER_OBJECT_ which) { USER_OBJECT_ ans, names; gint NumOptions = 8; DisplayOptions *options; if (GET_LENGTH(which) == 0) options = GGOBI(getDefaultDisplayOptions)(); else { displayd *display = toDisplay(which); g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT); options = &(display->options); } g_return_val_if_fail(options != NULL, NULL_USER_OBJECT); PROTECT(ans = NEW_LOGICAL(NumOptions)); PROTECT(names = NEW_CHARACTER(NumOptions)); LOGICAL_DATA(ans)[DOPT_POINTS] = options->points_show_p; SET_STRING_ELT(names, DOPT_POINTS, COPY_TO_USER_STRING("Show points")); LOGICAL_DATA(ans)[DOPT_AXES] = options->axes_show_p; SET_STRING_ELT(names, DOPT_AXES, COPY_TO_USER_STRING("Show axes")); LOGICAL_DATA(ans)[DOPT_AXESLAB] = options->axes_label_p; SET_STRING_ELT(names, DOPT_AXESLAB, COPY_TO_USER_STRING("Show tour axes")); LOGICAL_DATA(ans)[DOPT_AXESVALS] = options->axes_values_p; SET_STRING_ELT(names, DOPT_AXESVALS, COPY_TO_USER_STRING("Show axes labels")); LOGICAL_DATA(ans)[DOPT_EDGES_U] = options->edges_undirected_show_p; SET_STRING_ELT(names, DOPT_EDGES_U, COPY_TO_USER_STRING("Undirected edges")); LOGICAL_DATA(ans)[DOPT_EDGES_A] = options->edges_arrowheads_show_p; SET_STRING_ELT(names, DOPT_EDGES_A, COPY_TO_USER_STRING("Arrowheads")); LOGICAL_DATA(ans)[DOPT_EDGES_D] = options->edges_directed_show_p; SET_STRING_ELT(names, DOPT_EDGES_D, COPY_TO_USER_STRING("Directed edges")); LOGICAL_DATA(ans)[DOPT_WHISKERS] = options->whiskers_show_p; SET_STRING_ELT(names, DOPT_WHISKERS, COPY_TO_USER_STRING("Show whiskers")); /* unused LOGICAL_DATA(ans)[5] = options->missings_show_p; SET_STRING_ELT(names, 5, COPY_TO_USER_STRING("Missing Values")); LOGICAL_DATA(ans)[8] = options->axes_center_p; SET_STRING_ELT(names, 8, COPY_TO_USER_STRING("Center axes")); LOGICAL_DATA(ans)[9] = options->double_buffer_p; SET_STRING_ELT(names, 9, COPY_TO_USER_STRING("Double buffer")); LOGICAL_DATA(ans)[10] = options->link_p; SET_STRING_ELT(names, 10, COPY_TO_USER_STRING("Link")); */ SET_NAMES(ans, names); UNPROTECT(2); return(ans); }
SEXP RS_DBI_createNamedList(char **names, SEXPTYPE *types, int *lengths, int n) { SEXP output, output_names, obj = R_NilValue; int num_elem; int j; PROTECT(output = NEW_LIST(n)); PROTECT(output_names = NEW_CHARACTER(n)); for(j = 0; j < n; j++){ num_elem = lengths[j]; switch((int)types[j]){ case LGLSXP: PROTECT(obj = NEW_LOGICAL(num_elem)); break; case INTSXP: PROTECT(obj = NEW_INTEGER(num_elem)); break; case REALSXP: PROTECT(obj = NEW_NUMERIC(num_elem)); break; case STRSXP: PROTECT(obj = NEW_CHARACTER(num_elem)); break; case VECSXP: PROTECT(obj = NEW_LIST(num_elem)); break; default: error("unsupported data type"); } SET_ELEMENT(output, (int)j, obj); SET_CHR_EL(output_names, j, mkChar(names[j])); } SET_NAMES(output, output_names); UNPROTECT(n+2); return(output); }
SEXP do_mchoice_equals(SEXP x, SEXP y) { int x_len = LENGTH(x); /* length of x vector */ int y_len = LENGTH(y); /* length of y vector */ SEXP ans; /* Logical return vector */ int nfound = 0; /* number of matches found */ int i,j, comp; /* iterators */ size_t slen; char *str_ptr; /* copy of the x string element */ const char *str; S_EVALUATOR if(!IS_INTEGER(y) || y_len == 0) PROBLEM "y must be an integer vector of at least length one." ERROR; PROTECT(ans = NEW_LOGICAL(x_len)); for(i=0; i < x_len; ++i) { nfound = 0; str = translateCharUTF8(STRING_ELT(x, i)); slen = strlen(str) + 1; /* if length of x element is zero or NA no posible match */ if(STRING_ELT(x, i) == NA_STRING) { SET_NA_LGL(LOGICAL_POINTER(ans)[i]); continue; } if(slen == 0) { LOGICAL_POINTER(ans)[i] = 0; continue; } str_ptr = Hmisc_AllocStringBuffer((slen) * sizeof(char), &cbuff); strncpy(str_ptr, str, slen); str_ptr[slen] = '\0'; while(str_ptr != NULL && nfound < y_len) { comp = get_next_mchoice(&str_ptr); for(j=0; j < y_len; j++) { if(comp == INTEGER_POINTER(y)[j]) { nfound++; break; } } } if(nfound < y_len) LOGICAL_POINTER(ans)[i] = 0; else LOGICAL_POINTER(ans)[i] = 1; } Hmisc_FreeStringBuffer(&cbuff); UNPROTECT(1); return(ans); }
USER_OBJECT_ asRLogical(Rboolean val) { USER_OBJECT_ ans; ans = NEW_LOGICAL(1); LOGICAL_DATA(ans)[0] = val; return(ans); }
/*#define DEBUG*/ SEXP nortek_checksum(SEXP buf, SEXP key) { /* http://www.nortek-as.com/en/knowledge-center/forum/current-profilers-and-current-meters/367698326 */ /* R CMD SHLIB bitwise.c library(oce) f <- "/Users/kelley/data/archive/sleiwex/2008/moorings/m06/vector1943/194301.vec" ## dir will change; times are odd buf <- readBin(f, what="raw", n=1e4) vvd.start <- matchBytes(buf, 0xa5, 0x10) ok <- NULL;dyn.load("~/src/R-kelley/oce/src/bitwise.so");for(i in 1:200) {ok <- c(ok, .Call("nortek_checksum",buf[vvd.start[i]+0:23], c(0xb5, 0x8c)))} */ int i, n; short check_value; int *resp; unsigned char *bufp, *keyp; SEXP res; PROTECT(key = AS_RAW(key)); PROTECT(buf = AS_RAW(buf)); bufp = (unsigned char*)RAW_POINTER(buf); keyp = (unsigned char*)RAW_POINTER(key); #ifdef DEBUG Rprintf("buf[0]=0x%02x\n",bufp[0]); Rprintf("buf[1]=0x%02x\n",bufp[1]); Rprintf("buf[2]=0x%02x\n",bufp[2]); Rprintf("key[0]=0x%02x\n", keyp[0]); Rprintf("key[1]=0x%02x\n", keyp[1]); #endif n = LENGTH(buf); check_value = (((short)keyp[0]) << 8) | (short)keyp[1]; #ifdef DEBUG Rprintf("check_value= %d\n", check_value); Rprintf("n=%d\n", n); #endif short *sbufp = (short*) bufp; for (i = 0; i < (n - 2)/2; i++) { #ifdef DEBUG Rprintf("i=%d buf=0x%02x\n", i, sbufp[i]); #endif check_value += sbufp[i]; #ifdef DEBUG Rprintf("after, check_value=%d\n", check_value); #endif } short checksum; checksum = (((short)bufp[n-1]) << 8) | (short)bufp[n-2]; #ifdef DEBUG Rprintf("CHECK AGAINST 0x%02x 0x%02x\n", bufp[n-2], bufp[n-1]); Rprintf("CHECK AGAINST %d\n", checksum); #endif PROTECT(res = NEW_LOGICAL(1)); resp = LOGICAL_POINTER(res); *resp = check_value == checksum; UNPROTECT(3); return(res); }
SEXP R_getFunctionAttributes_logical( #ifdef NEW_LLVM_ATTRIBUTES_SETUP llvm::AttributeSet attr #else llvm::Attributes attr #endif ) { SEXP ans, names; /* Get the number correct. */ int i = 0, n = 28; #ifdef NEW_LLVM_ATTRIBUTES_SETUP n = 27; #endif PROTECT(ans = NEW_LOGICAL(n)); PROTECT(names = NEW_CHARACTER(n)); #ifndef NEW_LLVM_ATTRIBUTES_SETUP SET_EL( AddressSafety) #endif SET_EL( Alignment) SET_EL( AlwaysInline) SET_EL( ByVal) SET_EL( InlineHint) SET_EL( InReg) SET_EL( MinSize) SET_EL( Naked) SET_EL( Nest) SET_EL( NoAlias) SET_EL( NoCapture) SET_EL( NoImplicitFloat) SET_EL( NoInline) SET_EL( NonLazyBind) SET_EL( NoRedZone) SET_EL( NoReturn) SET_EL( NoUnwind) SET_EL( OptimizeForSize) SET_EL( ReadNone) SET_EL( ReadOnly) SET_EL( ReturnsTwice) SET_EL( SExt) SET_EL( StackAlignment) SET_EL( StackProtect) SET_EL( StackProtectReq) SET_EL( StructRet) SET_EL( UWTable) SET_EL( ZExt ) SET_NAMES(ans, names); UNPROTECT(2); return(ans); }
SEXP RGDAL_CPL_RECODE_ICONV(void) { SEXP ans; PROTECT(ans=NEW_LOGICAL(1)); #ifdef CPL_RECODE_ICONV LOGICAL_POINTER(ans)[0] = TRUE; #else /* CPL_RECODE_ICONV */ LOGICAL_POINTER(ans)[0] = FALSE; #endif /* CPL_RECODE_ICONV */ UNPROTECT(1); return(ans); }
SEXP isnull(SEXP pointer) { void *ptr = R_ExternalPtrAddr(pointer); SEXP rvalue = PROTECT(NEW_LOGICAL(1)); if (ptr==NULL) { LOGICAL_DATA(rvalue)[0] = (Rboolean)TRUE; } else { LOGICAL_DATA(rvalue)[0] = (Rboolean)FALSE; } UNPROTECT(1); return(rvalue); }
void RS_DBI_allocOutput(SEXP output, RMySQLFields* flds, int num_rec, int expand) { SEXP names, s_tmp; int j; int num_fields; SEXPTYPE *fld_Sclass; PROTECT(output); num_fields = flds->num_fields; if(expand){ for(j = 0; j < (int) num_fields; j++){ /* Note that in R-1.2.3 (at least) we need to protect SET_LENGTH */ s_tmp = LST_EL(output,j); PROTECT(SET_LENGTH(s_tmp, num_rec)); SET_ELEMENT(output, j, s_tmp); UNPROTECT(1); } UNPROTECT(1); return; } fld_Sclass = flds->Sclass; for(j = 0; j < (int) num_fields; j++){ switch((int)fld_Sclass[j]){ case LGLSXP: SET_ELEMENT(output, j, NEW_LOGICAL(num_rec)); break; case STRSXP: SET_ELEMENT(output, j, NEW_CHARACTER(num_rec)); break; case INTSXP: SET_ELEMENT(output, j, NEW_INTEGER(num_rec)); break; case REALSXP: SET_ELEMENT(output, j, NEW_NUMERIC(num_rec)); break; case VECSXP: SET_ELEMENT(output, j, NEW_LIST(num_rec)); break; default: error("unsupported data type"); } } PROTECT(names = NEW_CHARACTER((int) num_fields)); for(j = 0; j< (int) num_fields; j++){ SET_CHR_EL(names,j, mkChar(flds->name[j])); } SET_NAMES(output, names); UNPROTECT(2); return; }
SEXP PROJ4NADsInstalled(void) { SEXP ans; #ifdef OSGEO4W PROTECT(ans=NEW_LOGICAL(1)); LOGICAL_POINTER(ans)[0] = TRUE; #else FILE *fp; PROTECT(ans=NEW_LOGICAL(1)); fp = pj_open_lib("conus", "rb"); if (fp == NULL) LOGICAL_POINTER(ans)[0] = FALSE; else { LOGICAL_POINTER(ans)[0] = TRUE; fclose(fp); } #endif /* OSGEO4W */ UNPROTECT(1); return(ans); }
SEXP isSameRef(USER_OBJECT_ x, USER_OBJECT_ y) { SEXP ans; void *a, *b; ans = NEW_LOGICAL(1); a = R_ExternalPtrAddr(x); b = R_ExternalPtrAddr(y); INTEGER_DATA(ans)[0] = (a == b); return(ans); }
SEXP RGDAL_GDALCheckVersion(void) { SEXP ans; PROTECT(ans=NEW_LOGICAL(1)); installErrorHandler(); LOGICAL_POINTER(ans)[0] = GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, NULL); uninstallErrorHandlerAndTriggerError(); UNPROTECT(1); return(ans); }
///////////////////////// // Return a logical vector if entries are in the event list SEXP isInEventList(SEXP eventList, SEXP entryNums) { TEventList* el = checkForEventListWrapper(eventList); SEXP l; PROTECT(l = NEW_LOGICAL( GET_LENGTH(entryNums) ) ); for ( unsigned int i = 0; i < GET_LENGTH(entryNums); ++i ) { LOGICAL(l)[i] = el->Contains( INTEGER(entryNums)[i] ) == 1; } UNPROTECT(1); return l; }
SEXP isGDALObjPtrNULL(SEXP sxpObj) { SEXP sxpHandle = getObjHandle(sxpObj); SEXP res; PROTECT(res = NEW_LOGICAL(1)); LOGICAL_POINTER(res)[0] = FALSE; void *extPtr = R_ExternalPtrAddr(sxpHandle); if (extPtr == NULL) LOGICAL_POINTER(res)[0] = TRUE; UNPROTECT(1); return(res); }
SEXP rph_tree_isNode(SEXP treeP, SEXP nodeName) { TreeNode *tr, *n; SEXP result; int *resultP, i; tr = rph_tree_new(treeP); for (i=0; i<tr->nnodes; i++) { n = (TreeNode*)lst_get_ptr(tr->nodes, i); if (strcmp(n->name, CHARACTER_VALUE(nodeName))==0) break; } PROTECT(result = NEW_LOGICAL(1)); resultP = LOGICAL_POINTER(result); resultP[0] = (i < tr->nnodes); UNPROTECT(1); return result; }
s_object * RS_PostgreSQL_closeManager(Mgr_Handle * mgrHandle) { S_EVALUATOR RS_DBI_manager * mgr; s_object *status; mgr = RS_DBI_getManager(mgrHandle); if (mgr->num_con) { RS_DBI_errorMessage("There are opened connections -- close them first", RS_DBI_ERROR); } RS_DBI_freeManager(mgrHandle); MEM_PROTECT(status = NEW_LOGICAL((Sint) 1)); LGL_EL(status, 0) = TRUE; MEM_UNPROTECT(1); return status; }
/** This is called when we have reset all the variables in the different splots within a display. The intent is that this will recompute everything, including the positions of the points/glyphs. Currently this is not doing that. Need to call some other method. */ USER_OBJECT_ RS_GGOBI(updateDisplay)(USER_OBJECT_ dpy, USER_OBJECT_ ggobiId) { USER_OBJECT_ ans = NEW_LOGICAL(1); ggobid *gg; displayd *display; gg = toGGobi(ggobiId); g_return_val_if_fail(GGOBI_IS_GGOBI(gg), NULL_USER_OBJECT); display = toDisplay(dpy); g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT); display_tailpipe(display, FULL, gg); LOGICAL_DATA(ans)[0] = TRUE; return(ans); }
/* only until we have a bitset or something smaller than char */ SEXP _new_LOGICAL_from_CharAE(const CharAE *ae) { int nelt, i, *ans_elt; SEXP ans; const char *elt; nelt = _CharAE_get_nelt(ae); PROTECT(ans = NEW_LOGICAL(nelt)); for (i = 0, ans_elt = LOGICAL(ans), elt = ae->elts; i < nelt; i++, ans_elt++, elt++) { *ans_elt = *elt; } UNPROTECT(1); return ans; }
/** Recompute each sheet in a workbook and all cells in each of these sheets. */ USER_OBJECT_ RGnumeric_recalcWorkbook(USER_OBJECT_ workbookRef, USER_OBJECT_ all) { Workbook *book; USER_OBJECT_ ans; book = RGnumeric_resolveWorkbookReference(workbookRef); if(LOGICAL_DATA(all)[0]) workbook_recalc_all(book); else workbook_recalc(book); ans = NEW_LOGICAL(1); LOGICAL_DATA(ans)[0] = TRUE; return(ans); }