[Rd] R_MakeExternalPtr

2005-10-24 Thread TB
Hi,

I'm using R_MakeExternalPtr() to store handles to (COM) objects in a SEXP.

The code basically is

sexp = R_MakeExternalPtr(handle,R_NilValue,R_NilValue);
R_RegisterCFinalizerEx(...);

After creating the sexp, LENGTH(sexp) returns some quite large integer
value. It seems like an "unitialized" value.

Can I safely assume, that an SEXP of type EXTPTRSXP can only contain a
single pointer value and never represent a vector (an array) of pointers? Or
should I maybe explicitly add something like

SETLENGTH(sexp,1);

Best wishes from sunny Austria,

Thomas Baier

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R_MakeExternalPtr

2005-10-24 Thread TB
Brian,

Prof Brian Ripley  wrote:
> This is one of those undocumented things (AFAIK): LENGTH applies only
> to 'vectors'.  So don't use t and definitely don't set it for others.
> The macro expands to
> 
> #define LENGTH(x)   (((VECSEXP) (x))->vecsxp.length)
> 
> What is a vector here?  Something which gets actually allocated by
> allocVector() AFAICS, that is an atomic or generic vector or an
> expression.  OTOH, an EXTPTRSXP is stored in a cons cell.
> 
> There is also a function length(), which is safer.

Thanks for your message. Things are much clearer now to me.

Can I safely assume that INTSXP, REALSXP, LGLSXP, STRSXP, CPLXSXP and VECSXP
are
vectors (while EXTPTRSXP is not).

Thomas

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Call R From VC++

2006-06-08 Thread TB
Shilpi,

shilpi harpavat  wrote:

> I want to write an independent C++ application that
> can call any R functions and output it as an
> c++object.
> I tried to use The documentation for Linking R DLL
> with VC++ But with no success.
> When I link R.dll it says Invalid or corrupt file
> Any help greatly aprrciated.

An alternative to directly accessing R.dll from VC++
is to use COM. See http://cran.r-project.org/contrib/extra/dcom/
for a (D)COM server or use the package rcom for another (D)COM
server implementing the same COM interfaces.

Thomas

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel