Change tabs to two spaces.

This commit is contained in:
Lymia Aluysia
2017-01-18 08:43:21 -06:00
parent d7f5f0dc3b
commit d2c635f739
329 changed files with 41307 additions and 41496 deletions
+105 -105
View File
@@ -16,8 +16,8 @@
#include <util/atomic.hpp>
#ifdef HAVE_FAST_ATOMIC
/// Using intrusive_ptr where possible? (as opposed to smart_ptr)
#define USE_INTRUSIVE_PTR
/// Using intrusive_ptr where possible? (as opposed to smart_ptr)
#define USE_INTRUSIVE_PTR
#endif
// Use slightly less fancy template stuff, so msvc7.1 doesn't crash with an internal compiler error
@@ -26,16 +26,16 @@
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#ifdef USE_INTRUSIVE_PTR
#include <boost/intrusive_ptr.hpp>
#include <boost/intrusive_ptr.hpp>
#endif
// Can't do using namespace boost;
// because boost::shared_ptr conflicts with std::tr1::shared_ptr
// and some boost headers do include boost/shared_ptr themselves
#if _HAS_TR1
using std::tr1::shared_ptr;
using std::tr1::shared_ptr;
#else
using boost::shared_ptr;
using boost::shared_ptr;
#endif
using boost::intrusive_ptr;
using boost::scoped_ptr;
@@ -45,123 +45,123 @@ using boost::dynamic_pointer_cast;
// ----------------------------------------------------------------------------- : Declaring
/// Declares the type TypeP as a shared_ptr<Type>
#define DECLARE_SHARED_POINTER_TYPE(Type) \
class Type; \
typedef shared_ptr<Type> Type##P;
#define DECLARE_SHARED_POINTER_TYPE(Type) \
class Type; \
typedef shared_ptr<Type> Type##P;
// ----------------------------------------------------------------------------- : Creating
/// Wrap a newly allocated pointer in an shared_ptr
/** Usage:
* return shared(new T(stuff)));
*/
* return shared(new T(stuff)));
*/
template <typename T>
inline shared_ptr<T> shared(T* ptr) {
return shared_ptr<T>(ptr);
return shared_ptr<T>(ptr);
}
// ----------------------------------------------------------------------------- : Intrusive pointers
#ifdef USE_INTRUSIVE_PTR
/// Declares the type TypeP as a intrusive_ptr<Type>
#define DECLARE_POINTER_TYPE(Type) \
class Type; \
typedef intrusive_ptr<Type> Type##P;
/// Declares the type TypeP as a intrusive_ptr<Type>
#define DECLARE_POINTER_TYPE(Type) \
class Type; \
typedef intrusive_ptr<Type> Type##P;
/// Wrap a newly allocated pointer in an intrusive_ptr
/** Usage:
* return intrusive(new T(stuff)));
*/
template <typename T>
inline intrusive_ptr<T> intrusive(T* ptr) {
return intrusive_ptr<T>(ptr);
}
/// Wrap a newly allocated pointer in an intrusive_ptr
/** Usage:
* return intrusive(new T(stuff)));
*/
template <typename T>
inline intrusive_ptr<T> intrusive(T* ptr) {
return intrusive_ptr<T>(ptr);
}
// ----------------------------------------------------------------------------- : Intrusive pointer base
template <typename T> class IntrusivePtrBase;
template <typename T> void intrusive_ptr_add_ref(IntrusivePtrBase<T>*);
template <typename T> void intrusive_ptr_release(IntrusivePtrBase<T>*);
/// Base class for objects wishing to use intrusive_ptrs.
/** There is no implicit virtual destructor, objects are destructed as type T
* Usage:
* @code
* DECLARE_POINTER_TYPE(MyClass);
* class MyClass : public IntrusivePtrBase<MyClass> { ... }
* @endcode
*/
template <typename T> class IntrusivePtrBase {
public:
inline IntrusivePtrBase() : ref_count(0) {}
// don't copy construct the reference count!
inline IntrusivePtrBase(const IntrusivePtrBase&) : ref_count(0) {}
// don't assign the reference count!
inline void operator = (const IntrusivePtrBase&) { }
protected:
/// Delete this object, can be overloaded
inline void destroy() {
delete static_cast<T*>(this);
}
private:
AtomicInt ref_count;
friend void intrusive_ptr_add_ref <> (IntrusivePtrBase*);
friend void intrusive_ptr_release <> (IntrusivePtrBase*);
};
// ----------------------------------------------------------------------------- : Intrusive pointer base
template <typename T> class IntrusivePtrBase;
template <typename T> void intrusive_ptr_add_ref(IntrusivePtrBase<T>*);
template <typename T> void intrusive_ptr_release(IntrusivePtrBase<T>*);
/// Base class for objects wishing to use intrusive_ptrs.
/** There is no implicit virtual destructor, objects are destructed as type T
* Usage:
* @code
* DECLARE_POINTER_TYPE(MyClass);
* class MyClass : public IntrusivePtrBase<MyClass> { ... }
* @endcode
*/
template <typename T> class IntrusivePtrBase {
public:
inline IntrusivePtrBase() : ref_count(0) {}
// don't copy construct the reference count!
inline IntrusivePtrBase(const IntrusivePtrBase&) : ref_count(0) {}
// don't assign the reference count!
inline void operator = (const IntrusivePtrBase&) { }
protected:
/// Delete this object, can be overloaded
inline void destroy() {
delete static_cast<T*>(this);
}
private:
AtomicInt ref_count;
friend void intrusive_ptr_add_ref <> (IntrusivePtrBase*);
friend void intrusive_ptr_release <> (IntrusivePtrBase*);
};
template <typename T> void intrusive_ptr_add_ref(IntrusivePtrBase<T>* p) {
++(p->ref_count);
}
template <typename T> void intrusive_ptr_release(IntrusivePtrBase<T>* p) {
if (--p->ref_count == 0) {
static_cast<T*>(p)->destroy();
}
}
// ----------------------------------------------------------------------------- : Intrusive pointer base : virtual
/// IntrusivePtrBase with a virtual destructor
class IntrusivePtrVirtualBase : public IntrusivePtrBase<IntrusivePtrVirtualBase> {
public:
virtual ~IntrusivePtrVirtualBase() {}
};
// ----------------------------------------------------------------------------- : Intrusive pointer base : with delete
/// Base class for objects wishing to use intrusive_ptrs, using a manual delete function
class IntrusivePtrBaseWithDelete : public IntrusivePtrBase<IntrusivePtrBaseWithDelete> {
public:
virtual ~IntrusivePtrBaseWithDelete() {}
protected:
/// Delete this object
virtual void destroy() {
delete this;
}
template <typename T> friend void intrusive_ptr_release(IntrusivePtrBase<T>*);
};
template <typename T> void intrusive_ptr_add_ref(IntrusivePtrBase<T>* p) {
++(p->ref_count);
}
template <typename T> void intrusive_ptr_release(IntrusivePtrBase<T>* p) {
if (--p->ref_count == 0) {
static_cast<T*>(p)->destroy();
}
}
// ----------------------------------------------------------------------------- : Intrusive pointer base : virtual
/// IntrusivePtrBase with a virtual destructor
class IntrusivePtrVirtualBase : public IntrusivePtrBase<IntrusivePtrVirtualBase> {
public:
virtual ~IntrusivePtrVirtualBase() {}
};
// ----------------------------------------------------------------------------- : Intrusive pointer base : with delete
/// Base class for objects wishing to use intrusive_ptrs, using a manual delete function
class IntrusivePtrBaseWithDelete : public IntrusivePtrBase<IntrusivePtrBaseWithDelete> {
public:
virtual ~IntrusivePtrBaseWithDelete() {}
protected:
/// Delete this object
virtual void destroy() {
delete this;
}
template <typename T> friend void intrusive_ptr_release(IntrusivePtrBase<T>*);
};
#else
#define DECLARE_POINTER_TYPE DECLARE_SHARED_POINTER_TYPE
#define intrusive_ptr shared_ptr
template <typename T> class IntrusivePtrBase {};
/// IntrusivePtrBase with a virtual destructor
class IntrusivePtrVirtualBase : public IntrusivePtrBase<IntrusivePtrVirtualBase> {
public:
virtual ~IntrusivePtrVirtualBase() {}
};
class IntrusivePtrBaseWithDelete : public IntrusivePtrBase<IntrusivePtrBaseWithDelete> {
public:
virtual ~IntrusivePtrBaseWithDelete() {}
protected:
/// Delete this object
virtual void destroy() {
delete this;
}
};
#define DECLARE_POINTER_TYPE DECLARE_SHARED_POINTER_TYPE
#define intrusive_ptr shared_ptr
template <typename T> class IntrusivePtrBase {};
/// IntrusivePtrBase with a virtual destructor
class IntrusivePtrVirtualBase : public IntrusivePtrBase<IntrusivePtrVirtualBase> {
public:
virtual ~IntrusivePtrVirtualBase() {}
};
class IntrusivePtrBaseWithDelete : public IntrusivePtrBase<IntrusivePtrBaseWithDelete> {
public:
virtual ~IntrusivePtrBaseWithDelete() {}
protected:
/// Delete this object
virtual void destroy() {
delete this;
}
};
#endif
/// Pointer to 'anything'