CXXR (C++ R)
|
Class used to implement indirect flow of control in R. More...
#include <Bailout.hpp>
Public Member Functions | |
Bailout () | |
Default constructor. | |
virtual void | throwException ()=0 |
Throw the corresponding C++ exception. | |
Public Member Functions inherited from CXXR::RObject | |
virtual const PairList * | attributes () const |
Get object attributes. | |
virtual void | clearAttributes () |
Remove all attributes. | |
virtual RObject * | clone () const |
Return pointer to a copy of this object. | |
void | copyAttribute (const Symbol *name, const RObject *source) |
Copy an attribute from one RObject to another. | |
void | copyAttributes (const RObject *source, bool copyS4) |
Copy attributes from one RObject to another. | |
virtual RObject * | evaluate (Environment *env) |
Evaluate object in a specified Environment. | |
virtual RObject * | getAttribute (const Symbol *name) const |
Get the value a particular attribute. | |
virtual bool | hasAttributes () const |
Has this object any attributes? | |
bool | hasClass () const |
Has this object the class attribute? | |
bool | isS4Object () const |
Is this an S4 object? | |
void | maybeTraceMemory (const RObject *src) |
Carry out memory tracing. | |
void | maybeTraceMemory (const RObject *src1, const RObject *src2) |
Carry out memory tracing. | |
void | maybeTraceMemory (const RObject *src1, const RObject *src2, const RObject *src3) |
Carry out memory tracing. | |
bool | memoryTraced () const |
Is copying etc. of this object being traced? | |
virtual unsigned int | packGPBits () const |
Reproduce the gp bits field used in CR. | |
virtual void | setAttribute (const Symbol *name, RObject *value) |
Set or remove an attribute. | |
void | setAttributes (const PairList *new_attributes) |
Replace the attributes of an object. | |
void | setMemoryTracing (bool on) |
Enable/disable tracing of copying etc. | |
void | setS4Object (bool on) |
Set the status of this RObject as an S4 object. | |
SEXPTYPE | sexptype () const |
Get an object's SEXPTYPE. | |
virtual const char * | typeName () const |
Name within R of this type of object. | |
virtual void | unpackGPBits (unsigned int gpbits) |
Interpret the gp bits field used in CR. | |
void | detachReferents () |
Null out all references from this node to other nodes. | |
void | visitReferents (const_visitor *v) const |
Conduct a visitor to the nodes referred to by this one. | |
Public Member Functions inherited from CXXR::GCNode | |
void | expose () const |
Record that construction of a node is complete. | |
bool | isExposed () const |
Has this node been exposed to garbage collection? | |
Public Member Functions inherited from CXXR::HeterogeneousListBase::Link | |
Link () | |
Default constructor. | |
Link (HeterogeneousListBase *list) | |
Appending constructor. | |
void | freeLink () |
Detach Link from any list. |
Additional Inherited Members | |
Static Public Member Functions inherited from CXXR::RObject | |
template<class T > | |
static T * | clone (const T *pattern) |
Return a pointer to a copy of an object. | |
Static Public Member Functions inherited from CXXR::GCNode | |
static void * | operator new (size_t bytes) |
Allocate memory. | |
static void * | operator new (size_t, void *where) |
Placement new for GCNode. | |
static void | operator delete (void *p, size_t bytes) |
Deallocate memory. | |
static bool | check () |
Integrity check. | |
template<class T > | |
static T * | expose (T *node) |
Record that construction of a node is complete. | |
static void | gc () |
Initiate a garbage collection. | |
static void | gclite () |
Lightweight garbage collection. | |
static void | maybeCheckExposed (const GCNode *node) |
Subject to configuration, check that a GCNode is exposed. | |
static size_t | numNodes () |
Number of GCNode objects in existence. | |
Public Attributes inherited from CXXR::RObject | |
unsigned char | m_named |
unsigned | m_missing: 2 |
unsigned | m_argused: 2 |
bool | m_active_binding: 1 |
bool | m_binding_locked: 1 |
Protected Member Functions inherited from CXXR::RObject | |
RObject (SEXPTYPE stype=CXXSXP) | |
RObject (const RObject &pattern) | |
Copy constructor. | |
Protected Member Functions inherited from CXXR::GCNode | |
virtual | ~GCNode () |
Protected Member Functions inherited from CXXR::HeterogeneousListBase::Link | |
virtual | ~Link () |
Class used to implement indirect flow of control in R.
Classes derived from this abstract base class are used in implementing R functions such as 'return' and 'break' that result in an indirect flow of control, with the intention that in the most common cases the overhead of throwing and propagating a C++ exception can be avoided.
An R function such as 'return' is implemented so that it creates an object of a class inheriting from Bailout. The basic idea is that this object is then passed as a return value up the chain from called function to caller, until it reaches the intended destination of the indirect flow of control.
However, this passing up the call chain happens only if the caller has indicated, by wrapping its call in a BailoutContext, that it is able to propagate the Bailout object correctly. If that is not the case, then the called function will invoke the throwException() method of the Bailout object, which - as the name suggests - will complete the indirect flow of control by throwing a C++ exception.