Re: [Rcpp-devel] Modules + Attributes for extensions

2018-03-08 Thread fernandohtoledo
Dear All,

So, after some more digging on the web and studying pointed packages
and documents I did achieve my goal. For those who may have the same
needs, I suggest you take a look on how RcppR6 deal and propose.
Anyway, many thanks to Ralf and Sergei.

Cheers,
FH

-Original Message-
From: fernandohtol...@gmail.com
To: rcpp-devel@lists.r-forge.r-project.org
Subject: Re: [Rcpp-devel] Modules + Attributes for extensions
Date: Wed, 07 Mar 2018 12:02:34 -0600

Dear Sergei,

You got my question... however:

I followed what is shown in RcppBDT as well as in Rcpp Extending
Vignette i.e., include RcppCommon.h, define the class, include Rcpp.h.
But, how the implement as/wrap? 

I also turn available the extensions trough the "depends" attribute. It
works and recognize my class...

What I can't understand (implement) is how to define an as
taking MyClass as input from R as well as the wrap(MyClass) which is
supposed to return an instance of MyClass to R.

I did try the Rcpp::XPtr approach for wrapping too but, then what I get
in the R side is and externalptr, not an instance of MyClass.

Any clue or example to point me? I will appreciate :)

Cheers,
FH

-Original Message-
From: Serguei Sokol <serguei.so...@gmail.com>
Reply-to: serguei.so...@gmail.com
To: fernandohtol...@gmail.com, rcpp-devel@lists.r-forge.r-project.org
Subject: Re: [Rcpp-devel] Modules + Attributes for extensions
Date: Wed, 7 Mar 2018 16:57:20 +0100

Le 07/03/2018 à 15:59, fernandohtol...@gmail.com a écrit :
> Dear Ralf and others,
> 
> Thanks for your reply. I did looked for the references you pointed
> before. Unfortunately, there is nothing new in the Extending vignette
> than what can be found in Dirk's book chapter. Basically, all the
> others implement custom as/wrap for third part classes to SEXP
> fundamental types.
> 
> Perhaps, I didn't state the question clearly... : Given my own class
> exposed through Modules, how to retrieve it from the C++ side?

(Supposing I understood well your question...)

For this part of problem, you have to declare your classes in your
original package (say mypack) in a separate file say
mypack/inst/include/mypack.h
Then in a package which will extend it (say otherpack) you will
delcare in its DESCRIPTION
LinkingTo: mypack

It will allow you to put in your otherpack/src/*.cpp files
#include  So you'll be able to use/extend mypack classes.


> How to
> allow perspective users to extend a package taking exposed class and
> defining new Rccp functions that uses those exposed class as argument
> or return?

As to taking objects instantiated from your classes as arguments in R
session,
it's indeed a matter of custom as()/wrap() custom definition.
Or you can use XPtr hook to passe just pointers to your objects
and de-referencing them appropriately in the Rcpp code.

Best,
Serguei.

> 
> My main difficulty is that! I will appreciate your points over that?
> 
> Cheers,
> FH
> 
> -Original Message-
> From: Ralf Stubner <ralf.stub...@r-institute.com>
> To: rcpp-devel@lists.r-forge.r-project.org
> Subject: Re: [Rcpp-devel] Modules + Attributes for extensions
> Date: Tue, 6 Mar 2018 14:41:32 +0100
> 
> On 06.03.2018 00:08, fernandohtol...@gmail.com wrote:
> > I
> > will also appreciate if someone point me an R package in which
> > custom
> > as/wrap are defined!
> 
> The reference: http://dirk.eddelbuettel.com/code/rcpp/Rcpp-extending.
> pd
> f
> Also very useful:
> http://gallery.rcpp.org/articles/custom-templated-wrap-and-as-for-sea
> mi
> ngless-interfaces/
> 
> Simple example: RcppBDT
> More complex examples: RcppArmadillo, RcppEigen, RcppGSL
> 
> Greetings
> Ralf
> 
> ___
> Rcpp-devel mailing list
> Rcpp-devel@lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-dev
> el
> ___
> Rcpp-devel mailing list
> Rcpp-devel@lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-dev
> el
> 


___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] Modules + Attributes for extensions

2018-03-07 Thread fernandohtoledo
Dear Sergei,

You got my question... however:

I followed what is shown in RcppBDT as well as in Rcpp Extending
Vignette i.e., include RcppCommon.h, define the class, include Rcpp.h.
But, how the implement as/wrap? 

I also turn available the extensions trough the "depends" attribute. It
works and recognize my class...

What I can't understand (implement) is how to define an as
taking MyClass as input from R as well as the wrap(MyClass) which is
supposed to return an instance of MyClass to R.

I did try the Rcpp::XPtr approach for wrapping too but, then what I get
in the R side is and externalptr, not an instance of MyClass.

Any clue or example to point me? I will appreciate :)

Cheers,
FH

-Original Message-
From: Serguei Sokol <serguei.so...@gmail.com>
Reply-to: serguei.so...@gmail.com
To: fernandohtol...@gmail.com, rcpp-devel@lists.r-forge.r-project.org
Subject: Re: [Rcpp-devel] Modules + Attributes for extensions
Date: Wed, 7 Mar 2018 16:57:20 +0100

Le 07/03/2018 à 15:59, fernandohtol...@gmail.com a écrit :
> Dear Ralf and others,
> 
> Thanks for your reply. I did looked for the references you pointed
> before. Unfortunately, there is nothing new in the Extending vignette
> than what can be found in Dirk's book chapter. Basically, all the
> others implement custom as/wrap for third part classes to SEXP
> fundamental types.
> 
> Perhaps, I didn't state the question clearly... : Given my own class
> exposed through Modules, how to retrieve it from the C++ side?

(Supposing I understood well your question...)

For this part of problem, you have to declare your classes in your
original package (say mypack) in a separate file say
mypack/inst/include/mypack.h
Then in a package which will extend it (say otherpack) you will
delcare in its DESCRIPTION
LinkingTo: mypack

It will allow you to put in your otherpack/src/*.cpp files
#include  So you'll be able to use/extend mypack classes.


> How to
> allow perspective users to extend a package taking exposed class and
> defining new Rccp functions that uses those exposed class as argument
> or return?

As to taking objects instantiated from your classes as arguments in R
session,
it's indeed a matter of custom as()/wrap() custom definition.
Or you can use XPtr hook to passe just pointers to your objects
and de-referencing them appropriately in the Rcpp code.

Best,
Serguei.

> 
> My main difficulty is that! I will appreciate your points over that?
> 
> Cheers,
> FH
> 
> -Original Message-
> From: Ralf Stubner <ralf.stub...@r-institute.com>
> To: rcpp-devel@lists.r-forge.r-project.org
> Subject: Re: [Rcpp-devel] Modules + Attributes for extensions
> Date: Tue, 6 Mar 2018 14:41:32 +0100
> 
> On 06.03.2018 00:08, fernandohtol...@gmail.com wrote:
> > I
> > will also appreciate if someone point me an R package in which
> > custom
> > as/wrap are defined!
> 
> The reference: http://dirk.eddelbuettel.com/code/rcpp/Rcpp-extending.
> pd
> f
> Also very useful:
> http://gallery.rcpp.org/articles/custom-templated-wrap-and-as-for-sea
> mi
> ngless-interfaces/
> 
> Simple example: RcppBDT
> More complex examples: RcppArmadillo, RcppEigen, RcppGSL
> 
> Greetings
> Ralf
> 
> ___
> Rcpp-devel mailing list
> Rcpp-devel@lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-dev
> el
> ___
> Rcpp-devel mailing list
> Rcpp-devel@lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-dev
> el
> 


___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] Modules + Attributes for extensions

2018-03-07 Thread Serguei Sokol

Le 07/03/2018 à 15:59, fernandohtol...@gmail.com a écrit :

Dear Ralf and others,

Thanks for your reply. I did looked for the references you pointed
before. Unfortunately, there is nothing new in the Extending vignette
than what can be found in Dirk's book chapter. Basically, all the
others implement custom as/wrap for third part classes to SEXP
fundamental types.

Perhaps, I didn't state the question clearly... : Given my own class
exposed through Modules, how to retrieve it from the C++ side?

(Supposing I understood well your question...)

For this part of problem, you have to declare your classes in your
original package (say mypack) in a separate file say 
mypack/inst/include/mypack.h
Then in a package which will extend it (say otherpack) you will
delcare in its DESCRIPTION
LinkingTo: mypack

It will allow you to put in your otherpack/src/*.cpp files
#include  So you'll be able to use/extend mypack classes.



How to
allow perspective users to extend a package taking exposed class and
defining new Rccp functions that uses those exposed class as argument
or return?

As to taking objects instantiated from your classes as arguments in R session,
it's indeed a matter of custom as()/wrap() custom definition.
Or you can use XPtr hook to passe just pointers to your objects
and de-referencing them appropriately in the Rcpp code.

Best,
Serguei.



My main difficulty is that! I will appreciate your points over that?

Cheers,
FH

-Original Message-
From: Ralf Stubner <ralf.stub...@r-institute.com>
To: rcpp-devel@lists.r-forge.r-project.org
Subject: Re: [Rcpp-devel] Modules + Attributes for extensions
Date: Tue, 6 Mar 2018 14:41:32 +0100

On 06.03.2018 00:08, fernandohtol...@gmail.com wrote:

I
will also appreciate if someone point me an R package in which custom
as/wrap are defined!


The reference: http://dirk.eddelbuettel.com/code/rcpp/Rcpp-extending.pd
f
Also very useful:
http://gallery.rcpp.org/articles/custom-templated-wrap-and-as-for-seami
ngless-interfaces/

Simple example: RcppBDT
More complex examples: RcppArmadillo, RcppEigen, RcppGSL

Greetings
Ralf

___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel



___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] Modules + Attributes for extensions

2018-03-07 Thread fernandohtoledo
Dear Ralf and others,

Thanks for your reply. I did looked for the references you pointed
before. Unfortunately, there is nothing new in the Extending vignette
than what can be found in Dirk's book chapter. Basically, all the
others implement custom as/wrap for third part classes to SEXP
fundamental types.

Perhaps, I didn't state the question clearly... : Given my own class
exposed through Modules, how to retrieve it from the C++ side? How to
allow perspective users to extend a package taking exposed class and
defining new Rccp functions that uses those exposed class as argument
or return?

My main difficulty is that! I will appreciate your points over that?

Cheers,
FH

-Original Message-
From: Ralf Stubner <ralf.stub...@r-institute.com>
To: rcpp-devel@lists.r-forge.r-project.org
Subject: Re: [Rcpp-devel] Modules + Attributes for extensions
Date: Tue, 6 Mar 2018 14:41:32 +0100

On 06.03.2018 00:08, fernandohtol...@gmail.com wrote:
> I
> will also appreciate if someone point me an R package in which custom
> as/wrap are defined!

The reference: http://dirk.eddelbuettel.com/code/rcpp/Rcpp-extending.pd
f
Also very useful:
http://gallery.rcpp.org/articles/custom-templated-wrap-and-as-for-seami
ngless-interfaces/

Simple example: RcppBDT
More complex examples: RcppArmadillo, RcppEigen, RcppGSL

Greetings
Ralf

___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] Modules + Attributes for extensions

2018-03-06 Thread Ralf Stubner
On 06.03.2018 00:08, fernandohtol...@gmail.com wrote:
> I
> will also appreciate if someone point me an R package in which custom
> as/wrap are defined!

The reference: http://dirk.eddelbuettel.com/code/rcpp/Rcpp-extending.pdf
Also very useful:
http://gallery.rcpp.org/articles/custom-templated-wrap-and-as-for-seamingless-interfaces/

Simple example: RcppBDT
More complex examples: RcppArmadillo, RcppEigen, RcppGSL

Greetings
Ralf

-- 
Ralf Stubner
Senior Software Engineer / Trainer

R Institute GmbH
Dortustraße 48
14467 Potsdam

T: +49 331 23 70 81 66
F: +49 331 23 70 81 67
M: +49 162 20 91 196

Mail: ralf.stub...@r-institute.com

Sitz: Potsdam
Register: AG Potsdam HRB 27966 P
Ust.-IdNr.: DE300072622
Geschäftsführer: Prof. Dr. Dr. Karl-Kuno Kunze



smime.p7s
Description: S/MIME Cryptographic Signature
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel