mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
Work around clang 3.1 compile error with static constexpr
There is a bug in clang versions before 3.2 (including the one shipped with Xcode) that makes it give a "conflicting types" compile error when there is a static constexpr function defined outside the class. The way to work around this is either to remove one of the "static" or "constexpr" keywords, or to simply put the definition inline. See: https://stackoverflow.com/a/17494592/2135754 I would try and upgrade Xcode to version 5 to see if the problem is fixed, but the buildbot still runs OS X Lion (10.7) and the last version of Xcode that works on Lion is 4.6.3, so it seems easier to just apply these workarounds for now.
This commit is contained in:
parent
8eeab7a26a
commit
5e0ce969fe
@ -34,15 +34,6 @@ dec_heap(size_t size) {
|
|||||||
#endif // DO_MEMORY_USAGE
|
#endif // DO_MEMORY_USAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the global memory alignment. This is the number of bytes at which
|
|
||||||
* each allocated memory pointer will be aligned.
|
|
||||||
*/
|
|
||||||
constexpr size_t MemoryHook::
|
|
||||||
get_memory_alignment() {
|
|
||||||
return MEMORY_HOOK_ALIGNMENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the operating system page size. This is the minimum granularity
|
* Returns the operating system page size. This is the minimum granularity
|
||||||
* required for calls to mmap_alloc(). Also see round_up_to_page_size().
|
* required for calls to mmap_alloc(). Also see round_up_to_page_size().
|
||||||
|
@ -52,7 +52,9 @@ public:
|
|||||||
|
|
||||||
bool heap_trim(size_t pad);
|
bool heap_trim(size_t pad);
|
||||||
|
|
||||||
constexpr static size_t get_memory_alignment();
|
constexpr static size_t get_memory_alignment() {
|
||||||
|
return MEMORY_HOOK_ALIGNMENT;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void *mmap_alloc(size_t size, bool allow_exec);
|
virtual void *mmap_alloc(size_t size, bool allow_exec);
|
||||||
virtual void mmap_free(void *ptr, size_t size);
|
virtual void mmap_free(void *ptr, size_t size);
|
||||||
|
@ -191,14 +191,6 @@ output(ostream &out) const {
|
|||||||
out << get_name();
|
out << get_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a special zero-valued TypeHandle that is used to indicate no type.
|
|
||||||
*/
|
|
||||||
constexpr TypeHandle TypeHandle::
|
|
||||||
none() {
|
|
||||||
return TypeHandle(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TypeHandle::none() evaluates to false, everything else evaluates to true.
|
* TypeHandle::none() evaluates to false, everything else evaluates to true.
|
||||||
*/
|
*/
|
||||||
@ -207,17 +199,6 @@ operator bool () const {
|
|||||||
return (_index != 0);
|
return (_index != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a TypeHandle from a type index without error checking, for use by
|
|
||||||
* internal functions.
|
|
||||||
*
|
|
||||||
* See TypeRegistry::find_type_by_id().
|
|
||||||
*/
|
|
||||||
constexpr TypeHandle TypeHandle::
|
|
||||||
from_index(int index) {
|
|
||||||
return TypeHandle(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private constructor for initializing a TypeHandle from an index, used by
|
* Private constructor for initializing a TypeHandle from an index, used by
|
||||||
* none() and by from_index().
|
* none() and by from_index().
|
||||||
|
@ -129,7 +129,7 @@ PUBLISHED:
|
|||||||
|
|
||||||
INLINE int get_index() const;
|
INLINE int get_index() const;
|
||||||
INLINE void output(ostream &out) const;
|
INLINE void output(ostream &out) const;
|
||||||
constexpr static TypeHandle none();
|
constexpr static TypeHandle none() { return TypeHandle(0); }
|
||||||
INLINE operator bool () const;
|
INLINE operator bool () const;
|
||||||
|
|
||||||
MAKE_PROPERTY(index, get_index);
|
MAKE_PROPERTY(index, get_index);
|
||||||
@ -142,7 +142,7 @@ public:
|
|||||||
void *reallocate_array(void *ptr, size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT);
|
void *reallocate_array(void *ptr, size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT);
|
||||||
void deallocate_array(void *ptr);
|
void deallocate_array(void *ptr);
|
||||||
|
|
||||||
constexpr static TypeHandle from_index(int index);
|
constexpr static TypeHandle from_index(int index) { return TypeHandle(index); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
constexpr TypeHandle(int index);
|
constexpr TypeHandle(int index);
|
||||||
|
@ -24,19 +24,6 @@ get_slot(TypeHandle type_handle) const {
|
|||||||
return _slots_by_type[(size_t)type_index];
|
return _slots_by_type[(size_t)type_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the maximum number that any slot number is allowed to grow.
|
|
||||||
* Actually, this number will be one higher than the highest possible slot
|
|
||||||
* number. This puts an upper bound on the number of RenderAttrib slots that
|
|
||||||
* may be allocated, and allows other code to define an array of slots.
|
|
||||||
*
|
|
||||||
* This number will not change during the lifetime of the application.
|
|
||||||
*/
|
|
||||||
constexpr int RenderAttribRegistry::
|
|
||||||
get_max_slots() {
|
|
||||||
return _max_slots;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of RenderAttrib slots that have been allocated. This is
|
* Returns the number of RenderAttrib slots that have been allocated. This is
|
||||||
* one more than the highest slot number in use.
|
* one more than the highest slot number in use.
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
INLINE int get_slot(TypeHandle type_handle) const;
|
INLINE int get_slot(TypeHandle type_handle) const;
|
||||||
static constexpr int get_max_slots();
|
static constexpr int get_max_slots() { return _max_slots; }
|
||||||
|
|
||||||
INLINE int get_num_slots() const;
|
INLINE int get_num_slots() const;
|
||||||
INLINE TypeHandle get_slot_type(int slot) const;
|
INLINE TypeHandle get_slot_type(int slot) const;
|
||||||
|
@ -78,44 +78,6 @@ range(int low_bit, int size) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if there is a maximum number of bits that may be stored in
|
|
||||||
* this structure, false otherwise. If this returns true, the number may be
|
|
||||||
* queried in get_max_num_bits().
|
|
||||||
*
|
|
||||||
* This method always returns false. The BitArray has no maximum number of
|
|
||||||
* bits. This method is defined so generic programming algorithms can use
|
|
||||||
* BitMask or BitArray interchangeably.
|
|
||||||
*/
|
|
||||||
constexpr bool BitArray::
|
|
||||||
has_max_num_bits() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If get_max_num_bits() returned true, this method may be called to return
|
|
||||||
* the maximum number of bits that may be stored in this structure. It is an
|
|
||||||
* error to call this if get_max_num_bits() return false.
|
|
||||||
*
|
|
||||||
* It is always an error to call this method. The BitArray has no maximum
|
|
||||||
* number of bits. This method is defined so generic programming algorithms
|
|
||||||
* can use BitMask or BitArray interchangeably.
|
|
||||||
*/
|
|
||||||
constexpr int BitArray::
|
|
||||||
get_max_num_bits() {
|
|
||||||
return INT_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of bits stored per word internally. This is of interest
|
|
||||||
* only in that it limits the maximum number of bits that may be queried or
|
|
||||||
* set at once by extract() and store().
|
|
||||||
*/
|
|
||||||
constexpr int BitArray::
|
|
||||||
get_num_bits_per_word() {
|
|
||||||
return num_bits_per_word;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current number of possibly different bits in this array. There
|
* Returns the current number of possibly different bits in this array. There
|
||||||
* are actually an infinite number of bits, but every bit higher than this bit
|
* are actually an infinite number of bits, but every bit higher than this bit
|
||||||
|
@ -54,10 +54,10 @@ PUBLISHED:
|
|||||||
INLINE static BitArray bit(int index);
|
INLINE static BitArray bit(int index);
|
||||||
INLINE static BitArray range(int low_bit, int size);
|
INLINE static BitArray range(int low_bit, int size);
|
||||||
|
|
||||||
constexpr static bool has_max_num_bits();
|
constexpr static bool has_max_num_bits() { return false; }
|
||||||
constexpr static int get_max_num_bits();
|
constexpr static int get_max_num_bits() { return INT_MAX; }
|
||||||
|
|
||||||
constexpr static int get_num_bits_per_word();
|
constexpr static int get_num_bits_per_word() { return num_bits_per_word; }
|
||||||
INLINE size_t get_num_bits() const;
|
INLINE size_t get_num_bits() const;
|
||||||
INLINE bool get_bit(int index) const;
|
INLINE bool get_bit(int index) const;
|
||||||
INLINE void set_bit(int index);
|
INLINE void set_bit(int index);
|
||||||
|
@ -101,41 +101,12 @@ range(int low_bit, int size) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if there is a maximum number of bits that may be stored in
|
|
||||||
* this structure, false otherwise. If this returns true, the number may be
|
|
||||||
* queried in get_max_num_bits().
|
|
||||||
*
|
|
||||||
* This method always returns true. This method is defined so generic
|
|
||||||
* programming algorithms can use BitMask or BitArray interchangeably.
|
|
||||||
*/
|
|
||||||
template<class WType, int nbits>
|
|
||||||
constexpr bool BitMask<WType, nbits>::
|
|
||||||
has_max_num_bits() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If get_max_num_bits() returned true, this method may be called to return
|
|
||||||
* the maximum number of bits that may be stored in this structure. It is an
|
|
||||||
* error to call this if get_max_num_bits() return false.
|
|
||||||
*
|
|
||||||
* It is never an error to call this method. This returns the same thing as
|
|
||||||
* get_num_bits(). This method is defined so generic programming algorithms
|
|
||||||
* can use BitMask or BitArray interchangeably.
|
|
||||||
*/
|
|
||||||
template<class WType, int nbits>
|
|
||||||
constexpr int BitMask<WType, nbits>::
|
|
||||||
get_max_num_bits() {
|
|
||||||
return num_bits;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of bits available to set in the bitmask.
|
* Returns the number of bits available to set in the bitmask.
|
||||||
*/
|
*/
|
||||||
template<class WType, int nbits>
|
template<class WType, int nbits>
|
||||||
constexpr int BitMask<WType, nbits>::
|
constexpr int BitMask<WType, nbits>::
|
||||||
get_num_bits() {
|
get_num_bits() const {
|
||||||
return num_bits;
|
return num_bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,10 +45,10 @@ PUBLISHED:
|
|||||||
INLINE static BitMask<WType, nbits> bit(int index);
|
INLINE static BitMask<WType, nbits> bit(int index);
|
||||||
INLINE static BitMask<WType, nbits> range(int low_bit, int size);
|
INLINE static BitMask<WType, nbits> range(int low_bit, int size);
|
||||||
|
|
||||||
constexpr static bool has_max_num_bits();
|
constexpr static bool has_max_num_bits() { return true; }
|
||||||
constexpr static int get_max_num_bits();
|
constexpr static int get_max_num_bits() { return num_bits; }
|
||||||
|
|
||||||
constexpr static int get_num_bits();
|
constexpr int get_num_bits() const;
|
||||||
INLINE bool get_bit(int index) const;
|
INLINE bool get_bit(int index) const;
|
||||||
INLINE void set_bit(int index);
|
INLINE void set_bit(int index);
|
||||||
INLINE void clear_bit(int index);
|
INLINE void clear_bit(int index);
|
||||||
|
@ -119,41 +119,12 @@ INLINE DoubleBitMask<BMType>::
|
|||||||
~DoubleBitMask() {
|
~DoubleBitMask() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if there is a maximum number of bits that may be stored in
|
|
||||||
* this structure, false otherwise. If this returns true, the number may be
|
|
||||||
* queried in get_max_num_bits().
|
|
||||||
*
|
|
||||||
* This method always returns true. This method is defined so generic
|
|
||||||
* programming algorithms can use DoubleBitMask or BitArray interchangeably.
|
|
||||||
*/
|
|
||||||
template<class BMType>
|
|
||||||
constexpr bool DoubleBitMask<BMType>::
|
|
||||||
has_max_num_bits() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If get_max_num_bits() returned true, this method may be called to return
|
|
||||||
* the maximum number of bits that may be stored in this structure. It is an
|
|
||||||
* error to call this if get_max_num_bits() return false.
|
|
||||||
*
|
|
||||||
* It is never an error to call this method. This returns the same thing as
|
|
||||||
* get_num_bits(). This method is defined so generic programming algorithms
|
|
||||||
* can use DoubleBitMask or BitArray interchangeably.
|
|
||||||
*/
|
|
||||||
template<class BMType>
|
|
||||||
constexpr int DoubleBitMask<BMType>::
|
|
||||||
get_max_num_bits() {
|
|
||||||
return num_bits;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of bits available to set in the doubleBitMask.
|
* Returns the number of bits available to set in the doubleBitMask.
|
||||||
*/
|
*/
|
||||||
template<class BMType>
|
template<class BMType>
|
||||||
constexpr int DoubleBitMask<BMType>::
|
constexpr int DoubleBitMask<BMType>::
|
||||||
get_num_bits() {
|
get_num_bits() const {
|
||||||
return num_bits;
|
return num_bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,10 +49,10 @@ PUBLISHED:
|
|||||||
|
|
||||||
INLINE ~DoubleBitMask();
|
INLINE ~DoubleBitMask();
|
||||||
|
|
||||||
constexpr static bool has_max_num_bits();
|
constexpr static bool has_max_num_bits() {return true;}
|
||||||
constexpr static int get_max_num_bits();
|
constexpr static int get_max_num_bits() {return num_bits;}
|
||||||
|
|
||||||
constexpr static int get_num_bits();
|
constexpr int get_num_bits() const;
|
||||||
INLINE bool get_bit(int index) const;
|
INLINE bool get_bit(int index) const;
|
||||||
INLINE void set_bit(int index);
|
INLINE void set_bit(int index);
|
||||||
INLINE void clear_bit(int index);
|
INLINE void clear_bit(int index);
|
||||||
|
@ -25,30 +25,6 @@ constexpr UpdateSeq::
|
|||||||
UpdateSeq() : _seq((unsigned int)SC_initial) {
|
UpdateSeq() : _seq((unsigned int)SC_initial) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an UpdateSeq in the 'initial' state.
|
|
||||||
*/
|
|
||||||
constexpr UpdateSeq UpdateSeq::
|
|
||||||
initial() {
|
|
||||||
return UpdateSeq((unsigned int)SC_initial);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an UpdateSeq in the 'old' state.
|
|
||||||
*/
|
|
||||||
constexpr UpdateSeq UpdateSeq::
|
|
||||||
old() {
|
|
||||||
return UpdateSeq((unsigned int)SC_old);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an UpdateSeq in the 'fresh' state.
|
|
||||||
*/
|
|
||||||
constexpr UpdateSeq UpdateSeq::
|
|
||||||
fresh() {
|
|
||||||
return UpdateSeq((unsigned int)SC_fresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -40,9 +40,9 @@ private:
|
|||||||
|
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
constexpr UpdateSeq();
|
constexpr UpdateSeq();
|
||||||
constexpr static UpdateSeq initial();
|
constexpr static UpdateSeq initial() { return UpdateSeq(SC_initial); }
|
||||||
constexpr static UpdateSeq old();
|
constexpr static UpdateSeq old() { return UpdateSeq(SC_old); }
|
||||||
constexpr static UpdateSeq fresh();
|
constexpr static UpdateSeq fresh() { return UpdateSeq(SC_fresh); }
|
||||||
|
|
||||||
INLINE UpdateSeq(const UpdateSeq ©);
|
INLINE UpdateSeq(const UpdateSeq ©);
|
||||||
constexpr UpdateSeq(const UpdateSeq &&from) noexcept;
|
constexpr UpdateSeq(const UpdateSeq &&from) noexcept;
|
||||||
@ -76,7 +76,7 @@ private:
|
|||||||
INLINE static bool priv_le(AtomicAdjust::Integer a, AtomicAdjust::Integer b);
|
INLINE static bool priv_le(AtomicAdjust::Integer a, AtomicAdjust::Integer b);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum SpecialCases {
|
enum SpecialCases : unsigned int {
|
||||||
SC_initial = 0,
|
SC_initial = 0,
|
||||||
SC_old = 1,
|
SC_old = 1,
|
||||||
SC_fresh = ~(unsigned int)0,
|
SC_fresh = ~(unsigned int)0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user