CXXR (C++ R)
Classes | Namespaces | Typedefs | Functions
RObject.h File Reference

($Id: RObject.h 1351 2013-03-08 15:12:28Z arr $)

Class CXXR::RObject and associated C interface functions. More...

#include "R_ext/Boolean.h"
#include "CXXR/SEXPTYPE.h"
#include <boost/serialization/access.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/nvp.hpp>
#include "CXXR/GCNode_PtrS11n.hpp"
#include "CXXR/RHandle.hpp"
#include "CXXR/uncxxr.h"
Include dependency graph for RObject.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CXXR::RObject
 Replacement for CR's SEXPREC. More...
struct  CXXR::RObject::DoNothing
 Class of function object that does nothing to an RObject. More...

Namespaces

namespace  CXXR
 Namespace for the CXXR project.

Typedefs

typedef CXXR::RObjectSEXP
 Pointer to an RObject.

Functions

SEXP ATTRIB (SEXP x)
 Get the attributes of a CXXR::RObject.
void DUPLICATE_ATTRIB (SEXP to, SEXP from)
 Replace the attributes of to by those of from.
Rboolean IS_S4_OBJECT (SEXP x)
 Is this an S4 object?
int LEVELS (SEXP x)
 (For use only in serialization.)
int NAMED (SEXP x)
 Get object copying status.
Rboolean OBJECT (SEXP x)
 Does an object have a class attribute?
int SETLEVELS (SEXP x, int v)
 (For use only in deserialization.)
void SET_ATTRIB (SEXP x, SEXP v)
 Replace an object's attributes.
void SET_NAMED (SEXP x, int v)
 Set object copying status.
void SET_S4_OBJECT (SEXP x)
SEXPTYPE TYPEOF (SEXP x)
 Get object's SEXPTYPE.
void UNSET_S4_OBJECT (SEXP x)
void Rf_copyMostAttrib (SEXP inp, SEXP ans)
 Copy attributes, with some exceptions.
SEXP Rf_getAttrib (SEXP vec, SEXP name)
 Access a named attribute.
Rboolean Rf_isNull (SEXP s)
 Is this the null object pointer?
Rboolean Rf_isObject (SEXP s)
 Does an object have a class attribute?
SEXP Rf_setAttrib (SEXP vec, SEXP name, SEXP val)
 Set or remove a named attribute.
void maybeTraceMemory1 (SEXP dest, SEXP src)
 C interface to RObject::traceMemory().
void maybeTraceMemory2 (SEXP dest, SEXP src1, SEXP src2)
 C interface to RObject::traceMemory().
const char * Rf_type2char (SEXPTYPE st)
 Name of type within R.

Detailed Description

Class CXXR::RObject and associated C interface functions.


Typedef Documentation

typedef CXXR::RObject* SEXP

Pointer to an RObject.

In CR, almost all interpreter code could access R objects only via the opaque pointer SEXP. In CXXR, C code continues to see SEXP as an opaque pointer, but C++ code sees SEXP defined as 'pointer to RObject'.

Note:
This typedef is provided for compatibility with code inherited from CR. New CXXR code should write RObject* explicitly.

Function Documentation

SEXP ATTRIB ( SEXP  x)

Get the attributes of a CXXR::RObject.

Parameters:
xPointer to the CXXR::RObject whose attributes are required.
Returns:
Pointer to the attributes object of x , or 0 if x is a null pointer.
void DUPLICATE_ATTRIB ( SEXP  to,
SEXP  from 
)

Replace the attributes of to by those of from.

The status of to as an S4 Object is also copied from from .

Parameters:
toPointer to CXXR::RObject.
fromPointer to another CXXR::RObject.
Rboolean IS_S4_OBJECT ( SEXP  x)
inline

Is this an S4 object?

Parameters:
xPointer to CXXR::RObject.
Returns:
true iff x is an S4 object. Returns false if x is 0.
void maybeTraceMemory1 ( SEXP  dest,
SEXP  src 
)

C interface to RObject::traceMemory().

This function provides a C language interface to dest->maybeTraceMemory(src): see the documentation of that method for details.

Parameters:
destNon-null pointer to an RObject.
srcNon-null pointer to an RObject.
void maybeTraceMemory2 ( SEXP  dest,
SEXP  src1,
SEXP  src2 
)

C interface to RObject::traceMemory().

This function provides a C language interface to dest->maybeTraceMemory(src1, src2): see the documentation of that method for details.

Parameters:
destNon-null pointer to an RObject.
src1Non-null pointer to an RObject.
src2Non-null pointer to an RObject.
int NAMED ( SEXP  x)
inline

Get object copying status.

Parameters:
xPointer to CXXR::RObject.
Returns:
Refer to 'R Internals' document. Returns 0 if x is a null pointer.
Rboolean OBJECT ( SEXP  x)
inline

Does an object have a class attribute?

Parameters:
xPointer to a CXXR::RObject.
Returns:
true iff x has a class attribute. Returns false if x is 0.
void Rf_copyMostAttrib ( SEXP  inp,
SEXP  ans 
)

Copy attributes, with some exceptions.

This is called in the case of binary operations to copy most attributes from one of the input arguments to the output. Note that the Dim, Dimnames and Names attributes are not copied: these should have been assigned elsewhere. The function also copies the S4 object status.

Parameters:
inpPointer to the CXXR::RObject from which attributes are to be copied.
ansPointer to the CXXR::RObject to which attributes are to be copied.
Note:
The above documentation is probably incomplete: refer to the source code for further details.
SEXP Rf_getAttrib ( SEXP  vec,
SEXP  name 
)

Access a named attribute.

Parameters:
vecPointer to the CXXR::RObject whose attributes are to be accessed.
nameEither a pointer to the symbol representing the required attribute, or a pointer to a CXXR::StringVector containing the required symbol name as element 0; in the latter case, as a side effect, the corresponding symbol is installed if necessary.
Returns:
Pointer to the requested attribute, or a null pointer if there is no such attribute.
Note:
The above documentation is incomplete: refer to the source code for further details.
Rboolean Rf_isNull ( SEXP  s)
inline

Is this the null object pointer?

Parameters:
sPointer to a CXXR::RObject.
Returns:
TRUE iff the CXXR::RObject pointed to by s is either a null pointer (i.e. == R_NilValue in CXXR), or is a CXXR::RObject with SEXPTYPE NILSXP (should not happen in CXXR).
Rboolean Rf_isObject ( SEXP  s)
inline

Does an object have a class attribute?

Parameters:
sPointer to a CXXR::RObject.
Returns:
TRUE iff the CXXR::RObject pointed to by s has a class attribute.
SEXP Rf_setAttrib ( SEXP  vec,
SEXP  name,
SEXP  val 
)

Set or remove a named attribute.

Parameters:
vecPointer to the CXXR::RObject whose attributes are to be modified.
nameEither a pointer to the symbol representing the required attribute, or a pointer to a CXXR::StringVector containing the required symbol name as element 0; in the latter case, as a side effect, the corresponding symbol is installed if necessary.
valEither the value to which the attribute is to be set, or a null pointer. In the latter case the attribute (if present) is removed.
Returns:
Refer to source code. (Sometimes vec, sometimes val, sometime a null pointer ...)
Note:
The above documentation is probably incomplete: refer to the source code for further details.
const char* Rf_type2char ( SEXPTYPE  st)

Name of type within R.

Translate a SEXPTYPE to the name by which it is known within R.

Parameters:
stThe SEXPTYPE whose name is required.
Returns:
The SEXPTYPE's name within R.
void SET_ATTRIB ( SEXP  x,
SEXP  v 
)

Replace an object's attributes.

Parameters:
xPointer to a CXXR::RObject.
vPointer to a PairList giving the new attributes of x. x should be considered to assume ownership of the 'car' values in v ; they should therefore not be subsequently altered externally.
Note:
Unlike CR, v isn't simply plugged into the attributes field of x : refer to the documentation for RObject::setAttributes() . In particular, do not attempt to modify the attributes by changing v after SET_ATTRIB has been called.
For compatibility with CR, garbage collection is inhibited within this function.
void SET_NAMED ( SEXP  x,
int  v 
)
inline

Set object copying status.

Parameters:
xPointer to CXXR::RObject. The function does nothing if x is a null pointer.
vRefer to 'R Internals' document.
Deprecated:
Ought to be private.
void SET_S4_OBJECT ( SEXP  x)
inline
Deprecated:
Ought to be private.
SEXPTYPE TYPEOF ( SEXP  x)
inline

Get object's SEXPTYPE.

Parameters:
xPointer to CXXR::RObject.
Returns:
SEXPTYPE of x, or NILSXP if x is a null pointer.
void UNSET_S4_OBJECT ( SEXP  x)
inline
Deprecated:
Ought to be private.