Re: [Rd] Heap access across multiple calls from R to C++

2023-05-27 Thread pikappa.devel
@r-project.org Subject: Re: [Rd] Heap access across multiple calls from R to C++ On 24 May 2023 at 09:09, Ivan Krylov wrote: | On Wed, 24 May 2023 02:08:25 +0200 | wrote: | > Is there a better way to do this? | | The .Call() interface (where functions take an arbitrary number of | nativ

Re: [Rd] Heap access across multiple calls from R to C++

2023-05-24 Thread Dirk Eddelbuettel
On 24 May 2023 at 09:09, Ivan Krylov wrote: | On Wed, 24 May 2023 02:08:25 +0200 | wrote: | > Is there a better way to do this? | | The .Call() interface (where functions take an arbitrary number of | native R objects and return a native R object) combined with external | pointers is likely to

Re: [Rd] Heap access across multiple calls from R to C++

2023-05-23 Thread Ivan Krylov
On Wed, 24 May 2023 02:08:25 +0200 wrote: > initialize = function() { > > .C("make_native_obj", self$native_obj) > > }) > extern "C" void make_native_obj(double *obj) { > > auto native_obj = new NativeObjStruct(); > > memcpy(obj, &native_obj, sizeof(obj)); > > } > Is there a

[Rd] Heap access across multiple calls from R to C++

2023-05-23 Thread pikappa.devel
Dear all, I have a question about maintaining state in native code during the lifetime of an object of R6Class type. The background is the following. I have a class derived from the standard model class of the R port of Keras, and I want to perform some calculations in native code using a third