MCPcopy Create free account
hub / github.com/apache/arrow / to_r6

Function to_r6

r/src/arrow_cpp11.h:403–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401
402template <typename T>
403SEXP to_r6(const std::shared_ptr<T>& ptr, const char* r6_class_name) {
404 if (ptr == nullptr) return R_NilValue;
405
406 cpp11::external_pointer<std::shared_ptr<T>> xp(new std::shared_ptr<T>(ptr));
407 SEXP r6_class = Rf_install(r6_class_name);
408
409// R_existsVarInFrame doesn't exist before R 4.2, so we need to fall back to
410// Rf_findVarInFrame3 if it is not defined.
411#if R_VERSION >= R_Version(4, 2, 0)
412 if (!R_existsVarInFrame(arrow::r::ns::arrow, r6_class)) {
413 cpp11::stop("No arrow R6 class named '%s'", r6_class_name);
414 }
415#else
416 if (Rf_findVarInFrame3(arrow::r::ns::arrow, r6_class, FALSE) == R_UnboundValue) {
417 cpp11::stop("No arrow R6 class named '%s'", r6_class_name);
418 }
419#endif
420
421 // make call: <symbol>$new(<x>)
422 SEXP call = PROTECT(Rf_lang3(R_DollarSymbol, r6_class, arrow::r::symbols::new_));
423 SEXP call2 = PROTECT(Rf_lang2(call, xp));
424
425 // and then eval in arrow::
426 SEXP r6 = PROTECT(Rf_eval(call2, arrow::r::ns::arrow));
427
428 UNPROTECT(3);
429 return r6;
430}
431
432/// This trait defines a single static function which returns the name of the R6 class
433/// which corresponds to T. By default, this is just the c++ class name with any

Callers 3

from_datumFunction · 0.85
vec_to_ArrayFunction · 0.85
fs___FileSystemFromUriFunction · 0.85

Calls 1

stopFunction · 0.85

Tested by

no test coverage detected