Merge branch 'release/1.10.x'

This commit is contained in:
rdb 2019-09-16 21:20:20 +02:00
commit 9d14117ad3
11 changed files with 126 additions and 64 deletions

View File

@ -23,8 +23,6 @@
// MemoryBase; this macro is provided to resolve problems with multiple // MemoryBase; this macro is provided to resolve problems with multiple
// inheritance or some such. // inheritance or some such.
#ifndef USE_MEMORY_NOWRAPPERS
#define ALLOC_MEMORY_BASE \ #define ALLOC_MEMORY_BASE \
inline void *operator new(size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT) { \ inline void *operator new(size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT) { \
return PANDA_MALLOC_SINGLE(size); \ return PANDA_MALLOC_SINGLE(size); \
@ -51,12 +49,6 @@
inline void operator delete[](void *, void *) { \ inline void operator delete[](void *, void *) { \
} }
#else // USE_MEMORY_NOWRAPPERS
#define ALLOC_MEMORY_BASE
#endif // USE_MEMORY_NOWRAPPERS
/** /**
* This class is intended to be the base class of all objects in Panda that * This class is intended to be the base class of all objects in Panda that
* might be allocated and deleted via the new and delete operators. It * might be allocated and deleted via the new and delete operators. It

View File

@ -25,37 +25,41 @@ register_type(TypeHandle &type_handle, const std::string &name) {
INLINE void INLINE void
register_type(TypeHandle &type_handle, const std::string &name, register_type(TypeHandle &type_handle, const std::string &name,
TypeHandle parent1) { TypeHandle parent1) {
if (TypeRegistry::ptr()->register_type(type_handle, name)) { TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->record_derivation(type_handle, parent1); if (registry->register_type(type_handle, name)) {
registry->record_derivation(type_handle, parent1);
} }
} }
INLINE void INLINE void
register_type(TypeHandle &type_handle, const std::string &name, register_type(TypeHandle &type_handle, const std::string &name,
TypeHandle parent1, TypeHandle parent2) { TypeHandle parent1, TypeHandle parent2) {
if (TypeRegistry::ptr()->register_type(type_handle, name)) { TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->record_derivation(type_handle, parent1); if (registry->register_type(type_handle, name)) {
TypeRegistry::ptr()->record_derivation(type_handle, parent2); registry->record_derivation(type_handle, parent1);
registry->record_derivation(type_handle, parent2);
} }
} }
INLINE void INLINE void
register_type(TypeHandle &type_handle, const std::string &name, register_type(TypeHandle &type_handle, const std::string &name,
TypeHandle parent1, TypeHandle parent2, TypeHandle parent1, TypeHandle parent2,
TypeHandle parent3) { TypeHandle parent3) {
if (TypeRegistry::ptr()->register_type(type_handle, name)) { TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->record_derivation(type_handle, parent1); if (registry->register_type(type_handle, name)) {
TypeRegistry::ptr()->record_derivation(type_handle, parent2); registry->record_derivation(type_handle, parent1);
TypeRegistry::ptr()->record_derivation(type_handle, parent3); registry->record_derivation(type_handle, parent2);
registry->record_derivation(type_handle, parent3);
} }
} }
INLINE void INLINE void
register_type(TypeHandle &type_handle, const std::string &name, register_type(TypeHandle &type_handle, const std::string &name,
TypeHandle parent1, TypeHandle parent2, TypeHandle parent1, TypeHandle parent2,
TypeHandle parent3, TypeHandle parent4) { TypeHandle parent3, TypeHandle parent4) {
if (TypeRegistry::ptr()->register_type(type_handle, name)) { TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->record_derivation(type_handle, parent1); if (registry->register_type(type_handle, name)) {
TypeRegistry::ptr()->record_derivation(type_handle, parent2); registry->record_derivation(type_handle, parent1);
TypeRegistry::ptr()->record_derivation(type_handle, parent3); registry->record_derivation(type_handle, parent2);
TypeRegistry::ptr()->record_derivation(type_handle, parent4); registry->record_derivation(type_handle, parent3);
registry->record_derivation(type_handle, parent4);
} }
} }
@ -71,40 +75,40 @@ register_dynamic_type(const std::string &name) {
} }
INLINE TypeHandle INLINE TypeHandle
register_dynamic_type(const std::string &name, TypeHandle parent1) { register_dynamic_type(const std::string &name, TypeHandle parent1) {
TypeHandle type_handle = TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->register_dynamic_type(name); TypeHandle type_handle = registry->register_dynamic_type(name);
TypeRegistry::ptr()->record_derivation(type_handle, parent1); registry->record_derivation(type_handle, parent1);
return type_handle; return type_handle;
} }
INLINE TypeHandle INLINE TypeHandle
register_dynamic_type(const std::string &name, register_dynamic_type(const std::string &name,
TypeHandle parent1, TypeHandle parent2) { TypeHandle parent1, TypeHandle parent2) {
TypeHandle type_handle = TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->register_dynamic_type(name); TypeHandle type_handle = registry->register_dynamic_type(name);
TypeRegistry::ptr()->record_derivation(type_handle, parent1); registry->record_derivation(type_handle, parent1);
TypeRegistry::ptr()->record_derivation(type_handle, parent2); registry->record_derivation(type_handle, parent2);
return type_handle; return type_handle;
} }
INLINE TypeHandle INLINE TypeHandle
register_dynamic_type(const std::string &name, register_dynamic_type(const std::string &name,
TypeHandle parent1, TypeHandle parent2, TypeHandle parent1, TypeHandle parent2,
TypeHandle parent3) { TypeHandle parent3) {
TypeHandle type_handle = TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->register_dynamic_type(name); TypeHandle type_handle = registry->register_dynamic_type(name);
TypeRegistry::ptr()->record_derivation(type_handle, parent1); registry->record_derivation(type_handle, parent1);
TypeRegistry::ptr()->record_derivation(type_handle, parent2); registry->record_derivation(type_handle, parent2);
TypeRegistry::ptr()->record_derivation(type_handle, parent3); registry->record_derivation(type_handle, parent3);
return type_handle; return type_handle;
} }
INLINE TypeHandle INLINE TypeHandle
register_dynamic_type(const std::string &name, register_dynamic_type(const std::string &name,
TypeHandle parent1, TypeHandle parent2, TypeHandle parent1, TypeHandle parent2,
TypeHandle parent3, TypeHandle parent4) { TypeHandle parent3, TypeHandle parent4) {
TypeHandle type_handle = TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->register_dynamic_type(name); TypeHandle type_handle = registry->register_dynamic_type(name);
TypeRegistry::ptr()->record_derivation(type_handle, parent1); registry->record_derivation(type_handle, parent1);
TypeRegistry::ptr()->record_derivation(type_handle, parent2); registry->record_derivation(type_handle, parent2);
TypeRegistry::ptr()->record_derivation(type_handle, parent3); registry->record_derivation(type_handle, parent3);
TypeRegistry::ptr()->record_derivation(type_handle, parent4); registry->record_derivation(type_handle, parent4);
return type_handle; return type_handle;
} }

View File

@ -64,14 +64,17 @@ is_on(NotifySeverity severity) const {
return (int)severity >= (int)get_severity(); return (int)severity >= (int)get_severity();
} }
#if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
/** /**
* A shorthand way to write is_on(NS_spam). * A shorthand way to write is_on(NS_spam).
*/ */
INLINE bool NotifyCategory:: INLINE bool NotifyCategory::
is_spam() const { is_spam() const {
#if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
// Instruct the compiler to optimize for the usual case. // Instruct the compiler to optimize for the usual case.
return UNLIKELY(is_on(NS_spam)); return UNLIKELY(is_on(NS_spam));
#else
return false;
#endif
} }
/** /**
@ -79,10 +82,13 @@ is_spam() const {
*/ */
INLINE bool NotifyCategory:: INLINE bool NotifyCategory::
is_debug() const { is_debug() const {
#if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
// Instruct the compiler to optimize for the usual case. // Instruct the compiler to optimize for the usual case.
return UNLIKELY(is_on(NS_debug)); return UNLIKELY(is_on(NS_debug));
} #else
return false;
#endif #endif
}
/** /**
* A shorthand way to write is_on(NS_info). * A shorthand way to write is_on(NS_info).

View File

@ -51,13 +51,8 @@ PUBLISHED:
// to present a consistent interface to our scripting language, so during // to present a consistent interface to our scripting language, so during
// the interrogate pass (that is, when CPPPARSER is defined), we still // the interrogate pass (that is, when CPPPARSER is defined), we still
// pretend they're nonstatic. // pretend they're nonstatic.
#if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
INLINE bool is_spam() const; INLINE bool is_spam() const;
INLINE bool is_debug() const; INLINE bool is_debug() const;
#else
constexpr static bool is_spam() { return false; }
constexpr static bool is_debug() { return false; }
#endif
INLINE bool is_info() const; INLINE bool is_info() const;
INLINE bool is_warning() const; INLINE bool is_warning() const;
INLINE bool is_error() const; INLINE bool is_error() const;

View File

@ -65,26 +65,30 @@ is_on(NotifySeverity severity) {
/** /**
* *
*/ */
#ifdef NOTIFY_DEBUG
template<class GetCategory> template<class GetCategory>
INLINE bool NotifyCategoryProxy<GetCategory>:: INLINE bool NotifyCategoryProxy<GetCategory>::
is_spam() { is_spam() {
#ifdef NOTIFY_DEBUG
// Instruct the compiler to optimize for the usual case. // Instruct the compiler to optimize for the usual case.
return UNLIKELY(get_unsafe_ptr()->is_spam()); return UNLIKELY(get_unsafe_ptr()->is_spam());
} #else
return false;
#endif #endif
}
/** /**
* *
*/ */
#ifdef NOTIFY_DEBUG
template<class GetCategory> template<class GetCategory>
INLINE bool NotifyCategoryProxy<GetCategory>:: INLINE bool NotifyCategoryProxy<GetCategory>::
is_debug() { is_debug() {
#ifdef NOTIFY_DEBUG
// Instruct the compiler to optimize for the usual case. // Instruct the compiler to optimize for the usual case.
return UNLIKELY(get_unsafe_ptr()->is_debug()); return UNLIKELY(get_unsafe_ptr()->is_debug());
} #else
return false;
#endif #endif
}
/** /**
* *

View File

@ -71,13 +71,8 @@ public:
INLINE bool is_on(NotifySeverity severity); INLINE bool is_on(NotifySeverity severity);
#if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
INLINE bool is_spam(); INLINE bool is_spam();
INLINE bool is_debug(); INLINE bool is_debug();
#else
constexpr static bool is_spam() { return false; }
constexpr static bool is_debug() { return false; }
#endif
INLINE bool is_info(); INLINE bool is_info();
INLINE bool is_warning(); INLINE bool is_warning();
INLINE bool is_error(); INLINE bool is_error();

View File

@ -2159,7 +2159,7 @@ def SdkLocatePython(prefer_thirdparty_python=False):
SDK["PYTHONEXEC"] = tp_python + "/bin/" + SDK["PYTHONVERSION"] SDK["PYTHONEXEC"] = tp_python + "/bin/" + SDK["PYTHONVERSION"]
SDK["PYTHON"] = tp_python + "/include/" + SDK["PYTHONVERSION"] SDK["PYTHON"] = tp_python + "/include/" + SDK["PYTHONVERSION"]
elif GetTarget() == 'darwin': elif GetTarget() == 'darwin' and not PkgHasCustomLocation("PYTHON"):
# On macOS, search for the Python framework directory matching the # On macOS, search for the Python framework directory matching the
# version number of our current Python version. # version number of our current Python version.
sysroot = SDK.get("MACOSX", "") sysroot = SDK.get("MACOSX", "")

View File

@ -21,7 +21,6 @@
#include <windows.h> // for IsBadWritePtr() #include <windows.h> // for IsBadWritePtr()
#endif #endif
#ifdef DO_DCAST
/** /**
* This function performs the actual check that the indicated TypedObject * This function performs the actual check that the indicated TypedObject
* pointer is of the intended type. * pointer is of the intended type.
@ -29,6 +28,7 @@
bool bool
_dcast_verify(TypeHandle want_handle, size_t want_size, _dcast_verify(TypeHandle want_handle, size_t want_size,
const TypedObject *ptr) { const TypedObject *ptr) {
#ifdef DO_DCAST
if (get_verify_dcast()) { if (get_verify_dcast()) {
if (ptr == nullptr) { if (ptr == nullptr) {
// This is allowed these days. It used to be an error, but what the // This is allowed these days. It used to be an error, but what the
@ -54,7 +54,7 @@ _dcast_verify(TypeHandle want_handle, size_t want_size,
return false; return false;
} }
} }
#endif // DO_DCAST
return true; return true;
} }
#endif // DO_DCAST

View File

@ -62,12 +62,12 @@ INLINE WantType *_dcast_ref(WantType *&, TypedObject *ptr);
template<class WantType> template<class WantType>
INLINE const WantType *_dcast_ref(WantType *&, const TypedObject *ptr); INLINE const WantType *_dcast_ref(WantType *&, const TypedObject *ptr);
#ifdef DO_DCAST // _dcast_verify performs the actual verification. This is an empty function
// _dcast_verify performs the actual verification. // when DO_DCAST is not set, but we still need to define it for ABI
// compatibility reasons.
EXPCL_PANDA_EXPRESS bool EXPCL_PANDA_EXPRESS bool
_dcast_verify(TypeHandle want_handle, size_t want_size, _dcast_verify(TypeHandle want_handle, size_t want_size,
const TypedObject *ptr); const TypedObject *ptr);
#endif // DO_DCAST
#define DCAST_INTO_V(to_pointer, from_pointer) \ #define DCAST_INTO_V(to_pointer, from_pointer) \
{ \ { \

View File

@ -12,6 +12,8 @@
*/ */
#include "pStatClient.h" #include "pStatClient.h"
#include "pStatCollector.h"
#include "pStatThread.h"
#ifdef DO_PSTATS #ifdef DO_PSTATS
// This file only defines anything interesting if DO_PSTATS is defined. // This file only defines anything interesting if DO_PSTATS is defined.
@ -19,8 +21,6 @@
#include "pStatClientImpl.h" #include "pStatClientImpl.h"
#include "pStatClientControlMessage.h" #include "pStatClientControlMessage.h"
#include "pStatServerControlMessage.h" #include "pStatServerControlMessage.h"
#include "pStatCollector.h"
#include "pStatThread.h"
#include "config_pstatclient.h" #include "config_pstatclient.h"
#include "pStatProperties.h" #include "pStatProperties.h"
#include "thread.h" #include "thread.h"
@ -1222,4 +1222,44 @@ InternalThread(const string &name, const string &sync_name) :
{ {
} }
#else // DO_PSTATS
PStatThread PStatClient::
get_main_thread() const {
return PStatThread((PStatClient *)this, 0);
}
PStatThread PStatClient::
get_current_thread() const {
return get_main_thread();
}
PStatCollector PStatClient::
make_collector_with_relname(int parent_index, std::string relname) {
return PStatCollector();
}
PStatClient *PStatClient::
get_global_pstats() {
static PStatClient global_pstats;
return &global_pstats;
}
void PStatClient::
start(int collector_index, int thread_index) {
}
void PStatClient::
start(int collector_index, int thread_index, double as_of) {
}
void PStatClient::
stop(int collector_index, int thread_index) {
}
void PStatClient::
stop(int collector_index, int thread_index, double as_of) {
}
#endif // DO_PSTATS #endif // DO_PSTATS

View File

@ -266,6 +266,12 @@ public:
~PStatClient() { } ~PStatClient() { }
PUBLISHED: PUBLISHED:
std::string get_collector_name(int index) const { return std::string(); }
std::string get_collector_fullname(int index) const { return std::string(); }
PStatThread get_main_thread() const;
PStatThread get_current_thread() const;
INLINE static bool connect(const std::string & = std::string(), int = -1) { return false; } INLINE static bool connect(const std::string & = std::string(), int = -1) { return false; }
INLINE static void disconnect() { } INLINE static void disconnect() { }
INLINE static bool is_connected() { return false; } INLINE static bool is_connected() { return false; }
@ -273,6 +279,26 @@ PUBLISHED:
INLINE static void main_tick() { } INLINE static void main_tick() { }
INLINE static void thread_tick(const std::string &) { } INLINE static void thread_tick(const std::string &) { }
static PStatClient *get_global_pstats();
private:
// These are used by inline PStatCollector methods, so they need to be
// stubbed out for ABI compatibility.
PStatCollector make_collector_with_relname(int parent_index, std::string relname);
bool is_active(int collector_index, int thread_index) const { return false; }
bool is_started(int collector_index, int thread_index) const { return false; }
void start(int collector_index, int thread_index);
void start(int collector_index, int thread_index, double as_of);
void stop(int collector_index, int thread_index);
void stop(int collector_index, int thread_index, double as_of);
void clear_level(int collector_index, int thread_index) { }
void set_level(int collector_index, int thread_index, double level) { }
void add_level(int collector_index, int thread_index, double increment) { }
double get_level(int collector_index, int thread_index) const { return 0.0; }
}; };
#endif // DO_PSTATS #endif // DO_PSTATS