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

Function r6_to_pointer

r/src/arrow_cpp11.h:204–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202
203template <typename Pointer>
204Pointer r6_to_pointer(SEXP self) {
205 if (!Rf_inherits(self, "ArrowObject")) {
206 std::string type_name = arrow::util::nameof<
207 cpp11::decay_t<typename std::remove_pointer<Pointer>::type>>();
208 cpp11::stop("Invalid R object for %s, must be an ArrowObject", type_name.c_str());
209 }
210
211// R_UnboundValue and Rf_findVarInFrame are non-API as of R 4.6
212#if R_VERSION >= R_Version(4, 6, 0)
213 SEXP xp = R_NilValue;
214 if (R_existsVarInFrame(self, arrow::r::symbols::xp)) {
215 xp = R_getVar(arrow::r::symbols::xp, self, FALSE);
216 }
217 if (xp == R_NilValue) {
218 cpp11::stop("Invalid: self$`.:xp:.` is NULL");
219 }
220#elif R_VERSION >= R_Version(4, 5, 0)
221 SEXP xp = R_getVarEx(arrow::r::symbols::xp, self, FALSE, R_UnboundValue);
222 if (xp == R_UnboundValue || xp == R_NilValue) {
223 cpp11::stop("Invalid: self$`.:xp:.` is NULL");
224 }
225#else
226 SEXP xp = Rf_findVarInFrame(self, arrow::r::symbols::xp);
227 if (xp == R_UnboundValue || xp == R_NilValue) {
228 cpp11::stop("Invalid: self$`.:xp:.` is NULL");
229 }
230#endif
231
232 void* p = R_ExternalPtrAddr(xp);
233 if (p == nullptr) {
234 SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
235 cpp11::stop("Invalid <%s>, external pointer to null", CHAR(STRING_ELT(klass, 0)));
236 }
237 return reinterpret_cast<Pointer>(p);
238}
239
240template <typename T>
241void r6_reset_pointer(SEXP r6) {

Callers

nothing calls this directly

Calls 1

stopFunction · 0.85

Tested by

no test coverage detected