Forráskód Böngészése

Bunch of minor compile fixes and changes

rdb 11 éve
szülő
commit
861234c349

+ 2 - 0
dtool/src/dtoolbase/deletedChain.h

@@ -96,6 +96,7 @@ public:
     return (void *)StaticDeletedChain< Type >::allocate(size, get_type_handle(Type)); \
   }                                                          \
   inline void *operator new(size_t size, void *ptr) {        \
+    (void) size;                                             \
     return ptr;                                              \
   }                                                          \
   inline void operator delete(void *ptr) {                   \
@@ -115,6 +116,7 @@ public:
     return (void *)_deleted_chain.allocate(size, get_type_handle(Type)); \
   }                                                          \
   inline void *operator new(size_t size, void *ptr) {        \
+    (void) size;                                             \
     return ptr;                                              \
   }                                                          \
   inline void operator delete(void *ptr) {                   \

+ 7 - 1
dtool/src/dtoolbase/dtoolbase.h

@@ -184,6 +184,9 @@
 
 #ifdef CPPPARSER
 #include <stdtypedefs.h>
+
+// Also pick up the forward declaration of PyObject.
+#include <Python.h>
 #endif
 
 #ifdef USE_TAU
@@ -322,14 +325,17 @@
 #define ALIGN_4BYTE
 #define ALIGN_8BYTE
 #define ALIGN_16BYTE
-#elif defined(WIN32_VC)
+#define ALIGN_64BYTE
+#elif defined(_MSC_VER)
 #define ALIGN_4BYTE __declspec(align(4))
 #define ALIGN_8BYTE __declspec(align(8))
 #define ALIGN_16BYTE __declspec(align(16))
+#define ALIGN_64BYTE __declspec(align(64))
 #elif defined(__GNUC__)
 #define ALIGN_4BYTE __attribute__ ((aligned (4)))
 #define ALIGN_8BYTE __attribute__ ((aligned (8)))
 #define ALIGN_16BYTE __attribute__ ((aligned (16)))
+#define ALIGN_64BYTE __attribute__ ((aligned (64)))
 #else
 #define ALIGN_4BYTE
 #define ALIGN_8BYTE

+ 7 - 5
dtool/src/dtoolbase/memoryBase.h

@@ -28,24 +28,26 @@
 
 #define ALLOC_MEMORY_BASE                                    \
   inline void *operator new(size_t size) {                   \
-    return PANDA_MALLOC_SINGLE(size);                     \
+    return PANDA_MALLOC_SINGLE(size);                        \
   }                                                          \
   inline void *operator new(size_t size, void *ptr) {        \
+    (void) size;                                             \
     return ptr;                                              \
   }                                                          \
   inline void operator delete(void *ptr) {                   \
-    PANDA_FREE_SINGLE(ptr);                          \
+    PANDA_FREE_SINGLE(ptr);                                  \
   }                                                          \
-  inline void operator delete(void *ptr, void *) {           \
+  inline void operator delete(void *, void *) {              \
   }                                                          \
   inline void *operator new[](size_t size) {                 \
-    return PANDA_MALLOC_ARRAY(size);                     \
+    return PANDA_MALLOC_ARRAY(size);                         \
   }                                                          \
   inline void *operator new[](size_t size, void *ptr) {      \
+    (void) size;                                             \
     return ptr;                                              \
   }                                                          \
   inline void operator delete[](void *ptr) {                 \
-    PANDA_FREE_ARRAY(ptr);                          \
+    PANDA_FREE_ARRAY(ptr);                                   \
   }                                                          \
   inline void operator delete[](void *, void *) {            \
   }

+ 4 - 0
dtool/src/dtoolbase/memoryHook.cxx

@@ -52,6 +52,10 @@
 #ifdef _DEBUG
   #define DEBUG 1
 #endif
+#ifdef assert
+  // dlmalloc defines its own assert, which clashes.
+  #undef assert
+#endif
 #include "dlmalloc.h"
 #include "dlmalloc_src.cxx"
 

+ 8 - 8
dtool/src/dtoolbase/typedObject.h

@@ -32,7 +32,7 @@
 //               return the specific type of the derived class.
 //               Inheriting from this automatically provides support
 //               for is_of_type() and is_exact_type().
-//               
+//
 //               All classes that inherit directly or indirectly from
 //               TypedObject should redefine get_type() and
 //               force_init_type(), as shown below.  Some classes that
@@ -44,7 +44,7 @@
 //               do not inherit from TypedObject need not define the
 //               virtual functions get_type() and force_init_type()
 //               (or any other virtual functions).
-//               
+//
 //               There is a specific layout for defining the
 //               overrides from this class.  Keeping the definitions
 //               formatted just like these examples will allow
@@ -53,10 +53,10 @@
 //               rearranging the braces or the order of the functions
 //               unless you're ready to change them in every file all
 //               at once.
-//               
+//
 //               What follows are some examples that can be used in
 //               new classes that you create.
-//               
+//
 //               @par In the class definition (.h file):
 //               @code
 //               public:
@@ -76,16 +76,16 @@
 //                   return get_class_type();
 //                 }
 //                 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-//               
+//
 //               private:
 //                 static TypeHandle _type_handle;
 //               @endcode
-//               
+//
 //               @par In the class .cxx file:
 //               @code
 //               TypeHandle <<<ThisClassStringName>>>::_type_handle;
 //               @endcode
-//               
+//
 //               @par In the class config_<<<PackageName>>>.cxx file:
 //               @code
 //               ConfigureFn(config_<<<PackageName>>>) {
@@ -124,7 +124,7 @@ public:
   // This pair of methods exists mainly for the convenience of
   // unambiguous upcasting.  Interrogate generates code to call this
   // method instead of making an explicit cast to (TypedObject *);
-  // this allows classes who multiply inherit from TypedObejct to
+  // this allows classes who multiply inherit from TypedObject to
   // override these methods and disambiguate the cast.  It doesn't
   // have to be a virtual method, since this is just a static upcast.
   INLINE TypedObject *as_typed_object();

+ 2 - 0
dtool/src/dtoolutil/preprocess_argv.cxx

@@ -35,6 +35,8 @@ void
 preprocess_argv(int &argc, char **&argv) {
 #ifndef _WIN32
   // Not Windows: do nothing.
+  (void) argc;
+  (void) argv;
 #else  // _WIN32
   // Temporarily commenting out to fix build.  Revisit shortly.
   static Win32ArgParser parser;

+ 13 - 0
dtool/src/prc/pnotify.h

@@ -127,6 +127,10 @@ private:
 // checking user input parameters, where optimal performance is not
 // paramount.
 
+// nassert_static() is a compile-time assertion.  It should only be
+// used with constant expressions and compilation will fail if the
+// assertion is not true.
+
 #ifdef NDEBUG
 
 #define nassertr(condition, return_value)
@@ -190,6 +194,15 @@ private:
 
 #endif  // NDEBUG
 
+#if __cplusplus >= 201103 || (defined(__has_extension) && __has_extension(cxx_static_assert))
+#define __nassert_static(condition, line, file) static_assert((condition), #condition " at line " #line " of " file)
+#define _nassert_static(condition, line, file) __nassert_static(condition, line, file)
+#define nassert_static(condition) _nassert_static(condition, __LINE__, __FILE__)
+#else
+#define __nassert_static(condition, suffix) typedef char nassert_static_ ## suffix [(condition) ? 1 : -1];
+#define _nassert_static(condition, suffix) __nassert_static(condition, suffix)
+#define nassert_static(condition) _nassert_static(condition, __COUNTER__)
+#endif
 
 #include "pnotify.I"
 

+ 8 - 4
dtool/src/prc/streamWrapper.I

@@ -127,8 +127,10 @@ get() {
 INLINE OStreamWrapper::
 OStreamWrapper(ostream *stream, bool owns_pointer, bool stringstream_hack) :
   _ostream(stream),
-  _owns_pointer(owns_pointer),
-  _stringstream_hack(stringstream_hack)
+  _owns_pointer(owns_pointer)
+#ifdef WIN32_VC
+, _stringstream_hack(stringstream_hack)
+#endif
 {
 }
 
@@ -140,8 +142,10 @@ OStreamWrapper(ostream *stream, bool owns_pointer, bool stringstream_hack) :
 INLINE OStreamWrapper::
 OStreamWrapper(ostream &stream) :
   _ostream(&stream),
-  _owns_pointer(false),
-  _stringstream_hack(false)
+  _owns_pointer(false)
+#ifdef WIN32_VC
+, _stringstream_hack(false)
+#endif
 {
 }
 

+ 2 - 0
dtool/src/prc/streamWrapper.h

@@ -105,7 +105,9 @@ private:
   // this flag is set true, we know we have a possibly-empty
   // stringstream, so we allow seekp(0) to fail silently, knowing that
   // there's no harm in this case.
+#ifdef WIN32_VC
   bool _stringstream_hack;
+#endif
 };
 
 ////////////////////////////////////////////////////////////////////

+ 10 - 0
dtool/src/pystub/pystub.cxx

@@ -28,6 +28,7 @@ extern "C" {
   EXPCL_PYSTUB int PyCFunction_New(...);
   EXPCL_PYSTUB int PyCFunction_NewEx(...);
   EXPCL_PYSTUB int PyCallable_Check(...);
+  EXPCL_PYSTUB int PyDict_DelItem(...);
   EXPCL_PYSTUB int PyDict_DelItemString(...);
   EXPCL_PYSTUB int PyDict_GetItem(...);
   EXPCL_PYSTUB int PyDict_GetItemString(...);
@@ -63,6 +64,7 @@ extern "C" {
   EXPCL_PYSTUB int PyInt_AsLong(...);
   EXPCL_PYSTUB int PyInt_AsSsize_t(...);
   EXPCL_PYSTUB int PyInt_FromLong(...);
+  EXPCL_PYSTUB int PyInt_FromSize_t(...);
   EXPCL_PYSTUB int PyInt_Type(...);
   EXPCL_PYSTUB int PyList_Append(...);
   EXPCL_PYSTUB int PyList_AsTuple(...);
@@ -81,6 +83,7 @@ extern "C" {
   EXPCL_PYSTUB int PyLong_FromUnsignedLongLong(...);
   EXPCL_PYSTUB int PyLong_Type(...);
   EXPCL_PYSTUB int PyMapping_GetItemString(...);
+  EXPCL_PYSTUB int PyMem_Free(...);
   EXPCL_PYSTUB int PyMemoryView_FromObject(...);
   EXPCL_PYSTUB int PyModule_AddIntConstant(...);
   EXPCL_PYSTUB int PyModule_AddObject(...);
@@ -191,6 +194,8 @@ extern "C" {
   EXPCL_PYSTUB extern void *PyExc_ValueError;
   EXPCL_PYSTUB extern void *_Py_NoneStruct;
   EXPCL_PYSTUB extern void *_Py_NotImplementedStruct;
+  EXPCL_PYSTUB extern void *_Py_TrueStruct;
+  EXPCL_PYSTUB extern void *_Py_ZeroStruct;
 };
 
 
@@ -207,6 +212,7 @@ int PyBytes_Size(...) { return 0; }
 int PyCFunction_New(...) { return 0; };
 int PyCFunction_NewEx(...) { return 0; };
 int PyCallable_Check(...) { return 0; }
+int PyDict_DelItem(...) { return 0; }
 int PyDict_DelItemString(...) { return 0; }
 int PyDict_GetItem(...) { return 0; }
 int PyDict_GetItemString(...) { return 0; }
@@ -242,6 +248,7 @@ int PyImport_GetModuleDict(...) { return 0; }
 int PyInt_AsLong(...) { return 0; }
 int PyInt_AsSsize_t(...) { return 0; }
 int PyInt_FromLong(...) { return 0; }
+int PyInt_FromSize_t(...) { return 0; }
 int PyInt_Type(...) { return 0; }
 int PyList_Append(...) { return 0; }
 int PyList_AsTuple(...) { return 0; }
@@ -260,6 +267,7 @@ int PyLong_FromUnsignedLong(...) { return 0; }
 int PyLong_FromUnsignedLongLong(...) { return 0; }
 int PyLong_Type(...) { return 0; }
 int PyMapping_GetItemString(...) { return 0; }
+int PyMem_Free(...) { return 0; }
 int PyMemoryView_FromObject(...) { return 0; }
 int PyModule_AddIntConstant(...) { return 0; };
 int PyModule_AddObject(...) { return 0; };
@@ -375,6 +383,8 @@ void *PyExc_TypeError = (void *)NULL;
 void *PyExc_ValueError = (void *)NULL;
 void *_Py_NoneStruct = (void *)NULL;
 void *_Py_NotImplementedStruct = (void *)NULL;
+void *_Py_TrueStruct = (void *)NULL;
+void *_Py_ZeroStruct = (void *)NULL;
 
 
 void