CXXR (C++ R) API
Static Public Member Functions | Protected Member Functions | Friends
CXXR::GCStackRootBase Class Reference

Untemplated base class for GCStackRoot. More...

#include <GCStackRoot.h>

Inheritance diagram for CXXR::GCStackRootBase:
Inheritance graph
[legend]

List of all members.

Static Public Member Functions

static void ppsRestoreSize (size_t new_size)
 Restore PPS to a previous size.
static size_t ppsSize ()
 Current size of PPS.
static unsigned int protect (RObject *node)
 Push a node pointer onto the PPS.
static void reprotect (RObject *node, unsigned int index)
 Change the target of a pointer on the PPS.
static void unprotect (unsigned int count=1)
 Pop pointers from the PPS.
static void unprotectPtr (RObject *node)
static void visitRoots (GCNode::const_visitor *v)
 Conduct a const visitor to all 'root' GCNode objects.
static void visitRoots (GCNode::const_visitor *v)
 Conduct a const visitor to protected objects.

Protected Member Functions

 GCStackRootBase (const GCNode *node)
 GCStackRootBase (const GCStackRootBase &source)
GCStackRootBaseoperator= (const GCStackRootBase &source)
void redirect (const GCNode *node)
 Change the node protected by this GCStackRootBase.
const GCNodeptr () const
 Access the encapsulated pointer.
 GCStackRootBase (const GCNode *node)
 Primary constructor.
 GCStackRootBase (const GCStackRootBase &source)
 Copy constructor.
GCStackRootBaseoperator= (const GCStackRootBase &source)
void retarget (const GCNode *node)
 Change the node protected by this GCStackRootBase.
const GCNodeptr () const
 Access the encapsulated pointer.

Friends

class GCNode

Detailed Description

Untemplated base class for GCStackRoot.

The preferred method for C++ code to protect a GCNode from the garbage collector is to use the templated class GCStackRoot, of which this is the untemplated base class, or class GCRoot.

However, GCStackRoot is not usable by C code, which should continue to use PROTECT(), UNPROTECT() etc. as in CR. However, these functions have been reimplemented to manipulate a C pointer protection stack (as we shall call it, despite the fact that it's implemented in C++) encapsulated as a static member within GCStackRootBase.

The preferred method for C++ code to protect a GCNode from the garbage collector is to use the templated class GCStackRoot, of which this is the untemplated base class, or class GCRoot.

However, GCStackRoot is not usable by C code, which should continue to use PROTECT(), UNPROTECT() etc. as in CR, which are implemented in CXXR via class ProtectStack.


Constructor & Destructor Documentation

CXXR::GCStackRootBase::GCStackRootBase ( const GCNode node)
inlineprotected

Primary constructor.

Parameters:
nodePointer to be encapsulated by the GCStackRootBase.
CXXR::GCStackRootBase::GCStackRootBase ( const GCStackRootBase source)
inlineprotected

Copy constructor.

Parameters:
sourcePattern for the copy.

Member Function Documentation

static void CXXR::GCStackRootBase::ppsRestoreSize ( size_t  new_size)
static

Restore PPS to a previous size.

Restore the C pointer protection stack to a previous size by popping elements off the top.

Parameters:
new_sizeThe size to which the stack is to be restored. Must not be greater than the current size.
Note:
In future this method will probably cease to be public, and be accessible only by a class encapsulating R contexts.
static size_t CXXR::GCStackRootBase::ppsSize ( )
inlinestatic

Current size of PPS.

Returns:
the current size of the C pointer protection stack.
Note:
This method is intended for use in conjunction with ppsRestoreSize(), and like it may cease to be public in future.
static unsigned int CXXR::GCStackRootBase::protect ( RObject node)
static

Push a node pointer onto the PPS.

Push a node pointer onto the C pointer protection stack.

Parameters:
nodePointer to the node to be protected from the garbage collector.
Returns:
Index of the stack cell thus created, for subsequent use with reprotect().
const GCNode* CXXR::GCStackRootBase::ptr ( ) const
inlineprotected

Access the encapsulated pointer.

Returns:
the GCNode pointer encapsulated by this object.
const GCNode* CXXR::GCStackRootBase::ptr ( ) const
inlineprotected

Access the encapsulated pointer.

Returns:
the GCNode pointer encapsulated by this object.
void CXXR::GCStackRootBase::redirect ( const GCNode node)
inlineprotected

Change the node protected by this GCStackRootBase.

Parameters:
nodePointer to the node now to be protected, or a null pointer.
static void CXXR::GCStackRootBase::reprotect ( RObject node,
unsigned int  index 
)
static

Change the target of a pointer on the PPS.

Change the node that a particular cell in the C pointer protection stack protects. As a consistency check, it is required that the reprotect takes place within the same Context as the corresponding protect. (CR does not apply this check.)

Parameters:
nodePointer to the node now to be protected from the garbage collector by the designated stack cell. (Not necessarily a different node from the one currently protected.)
indexIndex (as returned by protect() ) of the stack cell to be retargeted to node. Must be less than the current size of the C pointer protection stack (checked).
void CXXR::GCStackRootBase::retarget ( const GCNode node)
inlineprotected

Change the node protected by this GCStackRootBase.

Parameters:
nodePointer to the node now to be protected, or a null pointer.
static void CXXR::GCStackRootBase::unprotect ( unsigned int  count = 1)
static

Pop pointers from the PPS.

Pop cells from the C pointer protection stack. As a consistency check, it is required that the unprotect takes place within the same Context as the corresponding protect. (CR does not apply this check.)

Parameters:
countNumber of cells to be popped. Must not be larger than the current size of the C pointer protection stack.
static void CXXR::GCStackRootBase::unprotectPtr ( RObject node)
static

Removes from the C pointer protection stack the uppermost stack cell containing a pointer to a specified node, and drops all the stack cells above it by one place.

Parameters:
nodePointer to the node whose cell is to be removed from the C pointer protection stack.
Deprecated:
Utterly.
static void CXXR::GCStackRootBase::visitRoots ( GCNode::const_visitor v)
static

Conduct a const visitor to protected objects.

Conduct a GCNode::const_visitor object to each node pointed to by a GCStackRootBase.

Parameters:
vPointer to the const_visitor object.
static void CXXR::GCStackRootBase::visitRoots ( GCNode::const_visitor v)
static

Conduct a const visitor to all 'root' GCNode objects.

Conduct a GCNode::const_visitor object to each root GCNode and each node on the C pointer protection stack.

Parameters:
vPointer to the const_visitor object.

The documentation for this class was generated from the following files: