#include "cln/object.h"
#include "cln/V.h"
-#include "cln/abort.h"
-#include <stdlib.h>
+#include "cln/exception.h"
+#include <cstdlib>
namespace cln {
template <class T>
class cl_GV_inner {
protected:
- uintL len; // number of elements
+ uintC len; // number of elements
public:
- uintL length () const; // number of elements
+ uintC length () const; // number of elements
cl_GV_vectorops<T>* vectorops; // get/set element
const cl_GV_index<T> operator[] (unsigned long index);
const cl_GV_constindex<T> operator[] (unsigned long index) const;
const cl_GV_constindex<T> operator[] (int index) const;
public: /* ugh */
// Constructor.
- cl_GV_inner (uintL l, cl_GV_vectorops<T>* ops) : len (l), vectorops (ops) {}
+ cl_GV_inner (uintC l, cl_GV_vectorops<T>* ops) : len (l), vectorops (ops) {}
public:
// Destructor.
~cl_GV_inner ();
// Ability to place an object at a given address.
- void* operator new (size_t size, cl_GV_inner* ptr) { (void)size; return ptr; }
+ void* operator new (size_t size, void* ptr) { (void)size; return ptr; }
private:
// No default constructor, copy constructor, assignment operator, new.
cl_GV_inner ();
// through [].
public:
cl_GV_inner<T>* vec;
- uintL index;
+ uintC index;
operator T () const;
// Constructor:
- cl_GV_index (cl_GV_inner<T>* v, uintL i) : vec (v), index (i) {}
+ cl_GV_index (cl_GV_inner<T>* v, uintC i) : vec (v), index (i) {}
// Assignment operator.
void operator= (const T& x) const;
#if (defined(__sparc__) || defined(__sparc64__) || defined(__mips__) || defined(__mips64__)) && !defined(__GNUC__) // maybe an SGI CC and Sun CC bug?
// through []. It lacks the assignment operator.
public:
const cl_GV_inner<T>* vec;
- uintL index;
+ uintC index;
operator T () const;
// Constructor:
- cl_GV_constindex (const cl_GV_inner<T>* v, uintL i) : vec (v), index (i) {}
+ cl_GV_constindex (const cl_GV_inner<T>* v, uintC i) : vec (v), index (i) {}
private:
// No default constructor, assignment operator.
cl_GV_constindex ();
template <class T>
struct cl_GV_vectorops {
- const T (*element) (const cl_GV_inner<T>* vec, uintL index);
- void (*set_element) (cl_GV_inner<T>* vec, uintL index, const T& x);
+ const T (*element) (const cl_GV_inner<T>* vec, uintC index);
+ void (*set_element) (cl_GV_inner<T>* vec, uintC index, const T& x);
void (*do_delete) (cl_GV_inner<T>* vec);
- void (*copy_elements) (const cl_GV_inner<T>* srcvec, uintL srcindex, cl_GV_inner<T>* destvec, uintL destindex, uintL count);
+ void (*copy_elements) (const cl_GV_inner<T>* srcvec, uintC srcindex, cl_GV_inner<T>* destvec, uintC destindex, uintC count);
};
// All member functions are inline.
template <class T>
-inline uintL cl_GV_inner<T>::length () const
+inline uintC cl_GV_inner<T>::length () const
{
return len;
}
inline cl_GV_index<T>::operator T () const
{
#ifndef CL_GV_NO_RANGECHECKS
- if (!(index < vec->len)) cl_abort();
+ if (!(index < vec->len)) throw runtime_exception();
#endif
return vec->vectorops->element(vec,index);
}
inline void cl_GV_index<T>::operator= (const T& x) const
{
#ifndef CL_GV_NO_RANGECHECKS
- if (!(index < vec->len)) cl_abort();
+ if (!(index < vec->len)) throw runtime_exception();
#endif
vec->vectorops->set_element(vec,index,x);
}
inline cl_GV_constindex<T>::operator T () const
{
#ifndef CL_GV_NO_RANGECHECKS
- if (!(index < vec->len)) cl_abort();
+ if (!(index < vec->len)) throw runtime_exception();
#endif
return vec->vectorops->element(vec,index);
}
struct cl_GV : public BASE {
public:
// Length.
- uintL length () const
+ uintC length () const
{
- return ((const cl_heap_GV<T> *) pointer)->v.length();
+ return ((const cl_heap_GV<T> *) this->pointer)->v.length();
}
// Reference. Forbid modification of `const cl_GV&' arguments.
const cl_GV_constindex<T> operator[] (unsigned long index) const
{
- return ((const cl_heap_GV<T> *) pointer)->v[index];
+ return ((const cl_heap_GV<T> *) this->pointer)->v[index];
}
const cl_GV_index<T> operator[] (unsigned long index)
{
- return ((cl_heap_GV<T> *) pointer)->v[index];
+ return ((cl_heap_GV<T> *) this->pointer)->v[index];
}
const cl_GV_constindex<T> operator[] (long index) const
{ return operator[]((unsigned long)index); }
cl_GV& operator= (const cl_GV&);
// Copy a piece of a vector into another vector.
// (Both vectors must be of the same type. Overlapping not allowed.)
- static void copy_elements (const cl_GV& src, uintL srcindex, cl_GV& dest, uintL destindex, uintL count)
+ static void copy_elements (const cl_GV& src, uintC srcindex, cl_GV& dest, uintC destindex, uintC count)
{
const cl_heap_GV<T> * hsrc = (const cl_heap_GV<T> *) src.pointer;
cl_heap_GV<T> * hdest = (cl_heap_GV<T> *) dest.pointer;
if (!(hsrc->v.vectorops == hdest->v.vectorops))
- cl_abort();
+ throw runtime_exception();
hsrc->v.vectorops->copy_elements(&hsrc->v,srcindex,&hdest->v,destindex,count);
}
// Private pointer manipulations.
template <class T, class BASE>
inline CL_GV(T,BASE)::operator cl_heap_GV<T>* () const
{
- cl_heap_GV<T>* hpointer = (cl_heap_GV<T>*)pointer;
+ cl_heap_GV<T>* hpointer = (cl_heap_GV<T>*)this->pointer;
cl_inc_refcount(*this);
return hpointer;
}