[Rcpp-devel] object '.pointer' not found

Romain Francois romain at r-enthusiasts.com
Thu Dec 2 22:41:07 CET 2010


Le 02/12/10 22:27, Andrew Redd a écrit :
> I realized that one again I responded off list.  But yes my problem was
> fixed. I found the hard way that classes now require explicit constructors.
> Thanks,
> Andrew

I guess you mean that it is required to explicitely expose them ? That's 
true. This has indeed changed, and if you feel the vignette does not 
make it clear, we can update it (a patch to the Rnw is welcome BTW).

I did also send emails to the mailing list while I was applying these 
changes.

explicit constructor has another meaning in C++ that has nothing to do 
with this.

> On Thu, Dec 2, 2010 at 1:42 PM, Romain Francois
> <romain at r-enthusiasts.com <mailto:romain at r-enthusiasts.com>> wrote:
>
>     Hmm. Actually my toy example was not right (it is getting late in
>     france, I think I've had enough screen time for one day). This works
>     for me :
>
>     require(inline)
>     require(Rcpp)
>     fx <- cxxfunction(, "", includes = '
>
>         class Foo {
>         public:
>             Foo() : x(2.0){}
>             Foo(double x_) : x(x_){}
>             double foo(){ return 0.0 ; }
>
>         private:
>             double x ;
>         } ;
>
>         RCPP_MODULE(bar){
>
>             class_<Foo>("Foo")
>                 .constructor()
>                 .constructor<double>()
>                 .method( "foo", &Foo::foo ) ;
>         }
>
>
>     ', plugin = "Rcpp" )
>     m <- Module( "bar", getDynLib(fx), mustStart = TRUE )
>     Foo <- m$Foo
>     new( Foo )
>
>     Does the example work for you ?
>
>     Romain
>
>     Le 02/12/10 21:34, Romain Francois a écrit :
>
>         Apparently, creation of the object works, but the show method
>         for the
>         class has a problem, so you should be able to do:
>
>         obj <- new(Module("GPU_BAYES",'gpuBayes')$data3)
>
>         Can you confirm ? (I only tried on a toy example)
>
>         but then when you print the object, it bombs out. I'm narrowing this
>         down, probably because of some oversight in the initialize method.
>
>         Romain
>
>         Le 02/12/10 20:36, Romain Francois a écrit :
>
>             That's odd that it only happens for your package. Guess #2
>             is that it
>             might be a namespace issue. Can you try adding:
>
>             import(methods)
>             import(Rcpp)
>
>             to your NAMESPACE file
>
>             Romain
>
>             Le 02/12/10 20:31, Andrew Redd a écrit :
>
>                 That exposes the data3 class, but does not solve the
>                 pointer problem.
>
>                 On Thu, Dec 2, 2010 at 12:24 PM, Romain Francois
>                 <romain at r-enthusiasts.com
>                 <mailto:romain at r-enthusiasts.com>
>                 <mailto:romain at r-enthusiasts.com
>                 <mailto:romain at r-enthusiasts.com>>> wrote:
>
>                 Le 02/12/10 20:05, Andrew Redd a écrit :
>
>                 I updated to the new Rcpp 0.8.9 then added a new
>                 function to my
>                 class.
>                 It compiles fine the Module is found and loads the class
>                 definition
>                 seems to be there, but when I try to create a instance
>                 of the
>                 class I
>                 get the error:
>
>                 R> new(Module("GPU_BAYES",'gpuBayes')$data3)
>                 Error in get(".pointer", envir = env) : object
>                 '.pointer' not found
>
>                 Any Ideas what might be wrong here? That's a rather vague
>                 error. The
>                 traceback gives
>
>                  > traceback()
>                 3: get(".pointer", envir = env)
>                 2: function (object)
>                 standardGeneric("show")(<S4 object of class "Rcpp_data3">)
>                 1: function (object)
>                 standardGeneric("show")(<S4 object of class "Rcpp_data3">)
>
>
>                 Thanks,
>                 Andrew
>
>
>                 In the Rcpp-modules vignette, that has been considerably
>                 updated in
>                 the last version of Rcpp (part of the 8661 new lines of
>                 code), we
>                 suggest to have this in your .onLoad:
>
>                 # grab the namespace
>                 NAMESPACE <- environment()
>
>                 .onLoad <- function(libname, pkgname){
>                 # load the module and store it in our namespace
>                 yada <- Module( "GPU_BAYES" )
>                 populate( yada, NAMESPACE )
>                 }
>
>                 and the "data3" class is directly exposed in the
>                 namespace of your
>                 package, so that you can do:
>
>                 new( data3 )
>
>                 Does that work ?
>
>
>                 Otherwise, maybe you can try adding mustStart = TRUE to
>                 the call to
>                 Module.

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/hovakS : RcppGSL initial release
|- http://bit.ly/iaxTdO : parser 0.0-12
`- http://bit.ly/gnCl01 : Rcpp 0.8.9




More information about the Rcpp-devel mailing list