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

Class implementing CR's 'pointer protection stack'. More...

#include <ProtectStack.h>

List of all members.

Classes

class  Scope
 Object constraining lifetime of ProtectStack entries. More...

Static Public Member Functions

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 restoreSize (size_t new_size)
 Restore PPS to a previous size.
static size_t size ()
 Current size of 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 protected objects.

Friends

class GCNode

Detailed Description

Class implementing CR's 'pointer protection stack'.

All members of this class are static.


Member Function Documentation

static unsigned int CXXR::ProtectStack::protect ( RObject node)
inlinestatic

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().
static void CXXR::ProtectStack::reprotect ( RObject node,
unsigned int  index 
)
inlinestatic

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 ProtectStack::Scope as the corresponding protect.

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).
static void CXXR::ProtectStack::restoreSize ( 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 available, since the use of the ProtectStack::Scope class is preferable.
static size_t CXXR::ProtectStack::size ( )
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 restoreSize(), and may cease to be public in future.
static void CXXR::ProtectStack::unprotect ( unsigned int  count = 1)
inlinestatic

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 ProtectStack::Scope as the corresponding protect.

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

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::ProtectStack::visitRoots ( GCNode::const_visitor v)
inlinestatic

Conduct a const visitor to protected objects.

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

Parameters:
vPointer to the const_visitor object.

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