You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/12/10 09:51:36 UTC

[GitHub] [arrow] romainfrancois commented on a change in pull request #11919: ARROW-14804: [R] import_from_c() / export_to_c() methods should accept external pointers

romainfrancois commented on a change in pull request #11919:
URL: https://github.com/apache/arrow/pull/11919#discussion_r766524355



##########
File path: r/src/py-to-r.cpp
##########
@@ -21,6 +21,38 @@
 
 #include <arrow/c/bridge.h>
 
+// [[arrow::export]]
+double external_pointer_addr_double(SEXP external_pointer) {
+  // potentially lossy conversion to double needed for the current
+  // implementation of import/export to Python
+  return reinterpret_cast<uintptr_t>(R_ExternalPtrAddr(external_pointer));

Review comment:
       Can this be something like ?
   
   ```c
   double out;
   void* ptr = R_ExternalPtrAddr(external_pointer);
   memcpy(&out, R_ExternalPtrAddr(external_pointer), sizeof(double));
   return out;
   ```

##########
File path: r/src/py-to-r.cpp
##########
@@ -21,6 +21,38 @@
 
 #include <arrow/c/bridge.h>
 
+// [[arrow::export]]
+double external_pointer_addr_double(SEXP external_pointer) {
+  // potentially lossy conversion to double needed for the current
+  // implementation of import/export to Python
+  return reinterpret_cast<uintptr_t>(R_ExternalPtrAddr(external_pointer));

Review comment:
       It seems to be what is done in `external_pointer_addr_integer64()` below. Maybe if this returned a `cpp11::doubles` ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org