Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

marshal: Rcpp::sourceCpp() #4

Open
HenrikBengtsson opened this issue Apr 6, 2022 · 1 comment
Open

marshal: Rcpp::sourceCpp() #4

HenrikBengtsson opened this issue Apr 6, 2022 · 1 comment

Comments

@HenrikBengtsson
Copy link
Collaborator

HenrikBengtsson commented Apr 6, 2022

From https://future.futureverse.org/articles/future-4-non-exportable-objects.html#package-rcpp:

Rcpp::sourceCpp(code = "
#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
int my_length(NumericVector x) {
    return x.size();
}
")

This produces:

my_length()

which holds an external reference pointer.

Can such an object be marshalled?

@HenrikBengtsson
Copy link
Collaborator Author

HenrikBengtsson commented Oct 22, 2022

Most likely not possible without Rcpp adding support for this. The generated my_length() function has no references whatsoever to the source code, or to Rcpp for that matter;

> my_length
function (x) 
.Call(<pointer: 0x7f3f12609550>, x)

> str(my_length)
function (x) 

> as.list(body(my_length))
[[1]]
.Call

[[2]]
<pointer: 0x7f3f12609550>
attr(,"class")
[1] "NativeSymbol"

[[3]]
x

> ptr <- body(my_length)[[2]]
> ptr
<pointer: 0x7f3f12609550>
attr(,"class")
[1] "NativeSymbol"
> str(ptr)
Class 'NativeSymbol' <externalptr> 

@HenrikBengtsson HenrikBengtsson transferred this issue from another repository Oct 22, 2022
@HenrikBengtsson HenrikBengtsson transferred this issue from another repository Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant