Browse Source

PointerToArray fixes, Windows build fixes, more move constructors

rdb 10 years ago
parent
commit
db87bc7914

+ 69 - 0
dtool/src/dtoolutil/filename.I

@@ -64,6 +64,39 @@ Filename(const Filename &copy) :
 {
 {
 }
 }
 
 
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: Filename::Move Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE Filename::
+Filename(string &&filename) NOEXCEPT {
+  _flags = 0;
+  (*this) = move(filename);
+}
+#endif  // USE_MOVE_SEMANTICS
+
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: Filename::Move Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE Filename::
+Filename(Filename &&from) NOEXCEPT :
+  _filename(move(from._filename)),
+  _dirname_end(from._dirname_end),
+  _basename_start(from._basename_start),
+  _basename_end(from._basename_end),
+  _extension_start(from._extension_start),
+  _hash_start(from._hash_start),
+  _hash_end(from._hash_end),
+  _flags(from._flags)
+{
+}
+#endif  // USE_MOVE_SEMANTICS
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Filename::text_filename named constructor
 //     Function: Filename::text_filename named constructor
 //       Access: Published
 //       Access: Published
@@ -216,6 +249,42 @@ operator = (const Filename &copy) {
   return *this;
   return *this;
 }
 }
 
 
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: Filename::Move assignment operator
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE Filename &Filename::
+operator = (string &&filename) NOEXCEPT {
+  _filename = move(filename);
+
+  locate_basename();
+  locate_extension();
+  locate_hash();
+  return *this;
+}
+#endif  // USE_MOVE_SEMANTICS
+
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: Filename::Move assignment operator
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE Filename &Filename::
+operator = (Filename &&from) NOEXCEPT {
+  _filename = MOVE(from._filename);
+  _dirname_end = from._dirname_end;
+  _basename_start = from._basename_start;
+  _basename_end = from._basename_end;
+  _extension_start = from._extension_start;
+  _hash_start = from._hash_start;
+  _hash_end = from._hash_end;
+  _flags = from._flags;
+  return *this;
+}
+#endif  // USE_MOVE_SEMANTICS
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Filename::string typecast operator
 //     Function: Filename::string typecast operator

+ 11 - 1
dtool/src/dtoolutil/filename.h

@@ -68,6 +68,11 @@ PUBLISHED:
   Filename(const Filename &dirname, const Filename &basename);
   Filename(const Filename &dirname, const Filename &basename);
   INLINE ~Filename();
   INLINE ~Filename();
 
 
+#ifdef USE_MOVE_SEMANTICS
+  INLINE Filename(string &&filename) NOEXCEPT;
+  INLINE Filename(Filename &&from) NOEXCEPT;
+#endif
+
 #ifdef HAVE_PYTHON
 #ifdef HAVE_PYTHON
   PyObject *__reduce__(PyObject *self) const;
   PyObject *__reduce__(PyObject *self) const;
 #endif
 #endif
@@ -88,7 +93,7 @@ PUBLISHED:
                                    Type type = T_general);
                                    Type type = T_general);
   static Filename from_os_specific_w(const wstring &os_specific,
   static Filename from_os_specific_w(const wstring &os_specific,
                                      Type type = T_general);
                                      Type type = T_general);
-  static Filename expand_from(const string &user_string, 
+  static Filename expand_from(const string &user_string,
                               Type type = T_general);
                               Type type = T_general);
   static Filename temporary(const string &dirname, const string &prefix,
   static Filename temporary(const string &dirname, const string &prefix,
                             const string &suffix = string(),
                             const string &suffix = string(),
@@ -105,6 +110,11 @@ PUBLISHED:
   INLINE Filename &operator = (const char *filename);
   INLINE Filename &operator = (const char *filename);
   INLINE Filename &operator = (const Filename &copy);
   INLINE Filename &operator = (const Filename &copy);
 
 
+#ifdef USE_MOVE_SEMANTICS
+  INLINE Filename &operator = (string &&filename) NOEXCEPT;
+  INLINE Filename &operator = (Filename &&from) NOEXCEPT;
+#endif
+
   // And retrieval is by any of the classic string operations.
   // And retrieval is by any of the classic string operations.
   INLINE operator const string & () const;
   INLINE operator const string & () const;
   INLINE const char *c_str() const;
   INLINE const char *c_str() const;

+ 5 - 1
makepanda/makepandacore.py

@@ -210,6 +210,8 @@ def PrettyTime(t):
     return "%d sec" % (seconds)
     return "%d sec" % (seconds)
 
 
 def ProgressOutput(progress, msg, target = None):
 def ProgressOutput(progress, msg, target = None):
+    sys.stdout.flush()
+    sys.stderr.flush()
     prefix = ""
     prefix = ""
     thisthread = threading.currentThread()
     thisthread = threading.currentThread()
     if thisthread is MAINTHREAD:
     if thisthread is MAINTHREAD:
@@ -235,6 +237,8 @@ def ProgressOutput(progress, msg, target = None):
         suffix = GetColor()
         suffix = GetColor()
 
 
     print(''.join((prefix, msg, suffix)))
     print(''.join((prefix, msg, suffix)))
+    sys.stdout.flush()
+    sys.stderr.flush()
 
 
 def exit(msg = ""):
 def exit(msg = ""):
     sys.stdout.flush()
     sys.stdout.flush()
@@ -498,7 +502,7 @@ def oscmd(cmd, ignoreError = False):
         print(GetColor("blue") + cmd.split(" ", 1)[0] + " " + GetColor("magenta") + cmd.split(" ", 1)[1] + GetColor())
         print(GetColor("blue") + cmd.split(" ", 1)[0] + " " + GetColor("magenta") + cmd.split(" ", 1)[1] + GetColor())
     sys.stdout.flush()
     sys.stdout.flush()
 
 
-    if sys.platform == "win32":
+    if sys.platform in ("win32", "cygwin"):
         exe = cmd.split()[0]
         exe = cmd.split()[0]
         exe_path = LocateBinary(exe)
         exe_path = LocateBinary(exe)
         if exe_path is None:
         if exe_path is None:

+ 27 - 0
panda/src/express/datagram.I

@@ -82,6 +82,33 @@ operator = (const Datagram &copy) {
   _stdfloat_double = copy._stdfloat_double;
   _stdfloat_double = copy._stdfloat_double;
 }
 }
 
 
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: Datagram::Copy Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE Datagram::
+Datagram(Datagram &&from) NOEXCEPT :
+  _data(move(from._data)),
+  _stdfloat_double(from._stdfloat_double)
+{
+}
+#endif  // USE_MOVE_SEMANTICS
+
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: Datagram::Move Assignment Operator
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void Datagram::
+operator = (Datagram &&from) NOEXCEPT {
+  _data = move(from._data);
+  _stdfloat_double = from._stdfloat_double;
+}
+#endif  // USE_MOVE_SEMANTICS
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Datagram::add_bool
 //     Function: Datagram::add_bool
 //       Access: Public
 //       Access: Public

+ 5 - 0
panda/src/express/datagram.h

@@ -48,6 +48,11 @@ PUBLISHED:
   INLINE Datagram(const Datagram &copy);
   INLINE Datagram(const Datagram &copy);
   INLINE void operator = (const Datagram &copy);
   INLINE void operator = (const Datagram &copy);
 
 
+#ifdef USE_MOVE_SEMANTICS
+  INLINE Datagram(Datagram &&from) NOEXCEPT;
+  INLINE void operator = (Datagram &&from) NOEXCEPT;
+#endif
+
   virtual ~Datagram();
   virtual ~Datagram();
 
 
   virtual void clear();
   virtual void clear();

+ 90 - 0
panda/src/express/pointerToArray.I

@@ -77,6 +77,21 @@ PointerToArray(const PointerToArray<Element> &copy) :
 {
 {
 }
 }
 
 
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: PointerToArray::Move Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template<class Element>
+INLINE PointerToArray<Element>::
+PointerToArray(PointerToArray<Element> &&from) NOEXCEPT :
+  PointerToArrayBase<Element>(move(from)),
+  _type_handle(from._type_handle)
+{
+}
+#endif  // USE_MOVE_SEMANTICS
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PointerToArray::begin
 //     Function: PointerToArray::begin
 //       Access: Public
 //       Access: Public
@@ -682,6 +697,21 @@ operator = (const PointerToArray<Element> &copy) {
   return *this;
   return *this;
 }
 }
 
 
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: PointerToArray::Assignment operator
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template<class Element>
+INLINE PointerToArray<Element> &PointerToArray<Element>::
+operator = (PointerToArray<Element> &&from) NOEXCEPT {
+  _type_handle = from._type_handle;
+  ((PointerToArray<Element> *)this)->reassign(move(from));
+  return *this;
+}
+#endif  // USE_MOVE_SEMANTICS
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PointerToArray::clear
 //     Function: PointerToArray::clear
 //       Access: Public
 //       Access: Public
@@ -736,6 +766,36 @@ ConstPointerToArray(const ConstPointerToArray<Element> &copy) :
 {
 {
 }
 }
 
 
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: ConstPointerToArray::Move Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template<class Element>
+INLINE ConstPointerToArray<Element>::
+ConstPointerToArray(PointerToArray<Element> &&from) NOEXCEPT :
+  PointerToArrayBase<Element>(move(from)),
+  _type_handle(from._type_handle)
+{
+}
+#endif  // USE_MOVE_SEMANTICS
+
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: ConstPointerToArray::Move Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template<class Element>
+INLINE ConstPointerToArray<Element>::
+ConstPointerToArray(ConstPointerToArray<Element> &&from) NOEXCEPT :
+  PointerToArrayBase<Element>(move(from)),
+  _type_handle(from._type_handle)
+{
+}
+#endif  // USE_MOVE_SEMANTICS
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ConstPointerToArray::begin
 //     Function: ConstPointerToArray::begin
 //       Access: Public
 //       Access: Public
@@ -1141,6 +1201,36 @@ operator = (const ConstPointerToArray<Element> &copy) {
   return *this;
   return *this;
 }
 }
 
 
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: ConstPointerToArray::Assignment operator
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template<class Element>
+INLINE ConstPointerToArray<Element> &ConstPointerToArray<Element>::
+operator = (PointerToArray<Element> &&from) NOEXCEPT {
+  _type_handle = from._type_handle;
+  ((ConstPointerToArray<Element> *)this)->reassign(move(from));
+  return *this;
+}
+#endif  // USE_MOVE_SEMANTICS
+
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: ConstPointerToArray::Assignment operator
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+template<class Element>
+INLINE ConstPointerToArray<Element> &ConstPointerToArray<Element>::
+operator = (ConstPointerToArray<Element> &&from) NOEXCEPT {
+  _type_handle = from._type_handle;
+  ((ConstPointerToArray<Element> *)this)->reassign(move(from));
+  return *this;
+}
+#endif  // USE_MOVE_SEMANTICS
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ConstPointerToArray::clear
 //     Function: ConstPointerToArray::clear
 //       Access: Public
 //       Access: Public

+ 23 - 0
panda/src/express/pointerToArray.h

@@ -151,6 +151,10 @@ public:
   INLINE PointerToArray(size_type n, const Element &value, TypeHandle type_handle = get_type_handle(Element));
   INLINE PointerToArray(size_type n, const Element &value, TypeHandle type_handle = get_type_handle(Element));
   INLINE PointerToArray(const PointerToArray<Element> &copy);
   INLINE PointerToArray(const PointerToArray<Element> &copy);
 
 
+#ifdef USE_MOVE_SEMANTICS
+  INLINE PointerToArray(PointerToArray<Element> &&from) NOEXCEPT;
+#endif
+
 public:
 public:
   // Duplicating the interface of vector.  The following member
   // Duplicating the interface of vector.  The following member
   // functions are all const, because they do not reassign the
   // functions are all const, because they do not reassign the
@@ -231,6 +235,12 @@ public:
   operator = (ReferenceCountedVector<Element> *ptr);
   operator = (ReferenceCountedVector<Element> *ptr);
   INLINE PointerToArray<Element> &
   INLINE PointerToArray<Element> &
   operator = (const PointerToArray<Element> &copy);
   operator = (const PointerToArray<Element> &copy);
+
+#ifdef USE_MOVE_SEMANTICS
+  INLINE PointerToArray<Element> &
+  operator = (PointerToArray<Element> &&from) NOEXCEPT;
+#endif
+
   INLINE void clear();
   INLINE void clear();
 
 
 private:
 private:
@@ -305,6 +315,11 @@ PUBLISHED:
   INLINE ConstPointerToArray(const PointerToArray<Element> &copy);
   INLINE ConstPointerToArray(const PointerToArray<Element> &copy);
   INLINE ConstPointerToArray(const ConstPointerToArray<Element> &copy);
   INLINE ConstPointerToArray(const ConstPointerToArray<Element> &copy);
 
 
+#ifdef USE_MOVE_SEMANTICS
+  INLINE ConstPointerToArray(PointerToArray<Element> &&from) NOEXCEPT;
+  INLINE ConstPointerToArray(ConstPointerToArray<Element> &&from) NOEXCEPT;
+#endif
+
   // Duplicating the interface of vector.
   // Duplicating the interface of vector.
 
 
   INLINE iterator begin() const;
   INLINE iterator begin() const;
@@ -355,6 +370,14 @@ PUBLISHED:
   operator = (const PointerToArray<Element> &copy);
   operator = (const PointerToArray<Element> &copy);
   INLINE ConstPointerToArray<Element> &
   INLINE ConstPointerToArray<Element> &
   operator = (const ConstPointerToArray<Element> &copy);
   operator = (const ConstPointerToArray<Element> &copy);
+
+#ifdef USE_MOVE_SEMANTICS
+  INLINE ConstPointerToArray<Element> &
+  operator = (PointerToArray<Element> &&from) NOEXCEPT;
+  INLINE ConstPointerToArray<Element> &
+  operator = (ConstPointerToArray<Element> &&from) NOEXCEPT;
+#endif
+
   INLINE void clear();
   INLINE void clear();
 
 
 private:
 private:

+ 25 - 11
panda/src/express/pointerToArrayBase.I

@@ -57,11 +57,11 @@ template<class Element>
 INLINE ReferenceCountedVector<Element>::
 INLINE ReferenceCountedVector<Element>::
 ~ReferenceCountedVector() {
 ~ReferenceCountedVector() {
 }
 }
- 
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ReferenceCountedVector::size
 //     Function: ReferenceCountedVector::size
 //       Access: Public
 //       Access: Public
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE TYPENAME ReferenceCountedVector<Element>::size_type ReferenceCountedVector<Element>::
 INLINE TYPENAME ReferenceCountedVector<Element>::size_type ReferenceCountedVector<Element>::
@@ -72,7 +72,7 @@ size() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ReferenceCountedVector::insert
 //     Function: ReferenceCountedVector::insert
 //       Access: Public
 //       Access: Public
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE TYPENAME ReferenceCountedVector<Element>::iterator ReferenceCountedVector<Element>::
 INLINE TYPENAME ReferenceCountedVector<Element>::iterator ReferenceCountedVector<Element>::
@@ -83,7 +83,7 @@ insert(iterator position, const Element &x) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ReferenceCountedVector::insert
 //     Function: ReferenceCountedVector::insert
 //       Access: Public
 //       Access: Public
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE void ReferenceCountedVector<Element>::
 INLINE void ReferenceCountedVector<Element>::
@@ -94,7 +94,7 @@ insert(iterator position, size_type n, const Element &x) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ReferenceCountedVector::erase
 //     Function: ReferenceCountedVector::erase
 //       Access: Public
 //       Access: Public
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE void ReferenceCountedVector<Element>::
 INLINE void ReferenceCountedVector<Element>::
@@ -105,7 +105,7 @@ erase(iterator position) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ReferenceCountedVector::erase
 //     Function: ReferenceCountedVector::erase
 //       Access: Public
 //       Access: Public
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE void ReferenceCountedVector<Element>::
 INLINE void ReferenceCountedVector<Element>::
@@ -116,7 +116,7 @@ erase(iterator first, iterator last) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ReferenceCountedVector::pop_back
 //     Function: ReferenceCountedVector::pop_back
 //       Access: Public
 //       Access: Public
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE void ReferenceCountedVector<Element>::
 INLINE void ReferenceCountedVector<Element>::
@@ -127,7 +127,7 @@ pop_back() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ReferenceCountedVector::clear
 //     Function: ReferenceCountedVector::clear
 //       Access: Public
 //       Access: Public
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE void ReferenceCountedVector<Element>::
 INLINE void ReferenceCountedVector<Element>::
@@ -138,7 +138,7 @@ clear() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PointerToArrayBase::Constructor
 //     Function: PointerToArrayBase::Constructor
 //       Access: Protected
 //       Access: Protected
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE PointerToArrayBase<Element>::
 INLINE PointerToArrayBase<Element>::
@@ -150,7 +150,7 @@ PointerToArrayBase(ReferenceCountedVector<Element> *ptr) :
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PointerToArrayBase::Copy Constructor
 //     Function: PointerToArrayBase::Copy Constructor
 //       Access: Protected
 //       Access: Protected
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE PointerToArrayBase<Element>::
 INLINE PointerToArrayBase<Element>::
@@ -159,10 +159,24 @@ PointerToArrayBase(const PointerToArrayBase<Element> &copy) :
 {
 {
 }
 }
 
 
+#ifdef USE_MOVE_SEMANTICS
+////////////////////////////////////////////////////////////////////
+//     Function: PointerToArrayBase::Move Constructor
+//       Access: Protected
+//  Description:
+////////////////////////////////////////////////////////////////////
+template<class Element>
+INLINE PointerToArrayBase<Element>::
+PointerToArrayBase(PointerToArrayBase<Element> &&from) NOEXCEPT :
+  PointerToBase<ReferenceCountedVector<Element> >(move(from))
+{
+}
+#endif  // USE_MOVE_SEMANTICS
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PointerToArrayBase::Destructor
 //     Function: PointerToArrayBase::Destructor
 //       Access: Published
 //       Access: Published
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
 INLINE PointerToArrayBase<Element>::
 INLINE PointerToArrayBase<Element>::

+ 4 - 0
panda/src/express/pointerToArrayBase.h

@@ -82,6 +82,10 @@ protected:
   INLINE PointerToArrayBase(ReferenceCountedVector<Element> *ptr);
   INLINE PointerToArrayBase(ReferenceCountedVector<Element> *ptr);
   INLINE PointerToArrayBase(const PointerToArrayBase<Element> &copy);
   INLINE PointerToArrayBase(const PointerToArrayBase<Element> &copy);
 
 
+#ifdef USE_MOVE_SEMANTICS
+  INLINE PointerToArrayBase(PointerToArrayBase<Element> &&from) NOEXCEPT;
+#endif
+
 PUBLISHED:
 PUBLISHED:
   INLINE ~PointerToArrayBase();
   INLINE ~PointerToArrayBase();
 };
 };

+ 41 - 23
panda/src/express/pointerToArray_ext.I

@@ -22,26 +22,33 @@
 //               Python buffer protocol.
 //               Python buffer protocol.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 template<class Element>
 template<class Element>
-void Extension<PointerToArray<Element> >::
+INLINE void Extension<PointerToArray<Element> >::
 __init__(PyObject *self, PyObject *source) {
 __init__(PyObject *self, PyObject *source) {
 #if PY_VERSION_HEX >= 0x02060000
 #if PY_VERSION_HEX >= 0x02060000
   if (PyObject_CheckBuffer(source)) {
   if (PyObject_CheckBuffer(source)) {
     // User passed a buffer object.
     // User passed a buffer object.
     Py_buffer view;
     Py_buffer view;
     if (PyObject_GetBuffer(source, &view, PyBUF_CONTIG_RO) == -1) {
     if (PyObject_GetBuffer(source, &view, PyBUF_CONTIG_RO) == -1) {
-      PyErr_SetString(PyExc_TypeError, "PointerToArray constructor requires a contiguous buffer");
+      PyErr_SetString(PyExc_TypeError,
+                      "PointerToArray constructor requires a contiguous buffer");
       return;
       return;
     }
     }
 
 
     if (view.itemsize != 1 && view.itemsize != sizeof(Element)) {
     if (view.itemsize != 1 && view.itemsize != sizeof(Element)) {
-      PyErr_SetString(PyExc_TypeError, "buffer.itemsize does not match PointerToArray element size");
+      PyErr_SetString(PyExc_TypeError,
+                      "buffer.itemsize does not match PointerToArray element size");
       return;
       return;
     }
     }
 
 
-    int num_elements = view.len / sizeof(Element);
-    this->_this->insert(this->_this->begin(), num_elements, Element());
+    if (view.len % sizeof(Element) != 0) {
+      PyErr_Format(PyExc_ValueError,
+                   "byte buffer is not a multiple of %zu bytes",
+                   sizeof(Element));
+      return;
+    }
 
 
     if (view.len > 0) {
     if (view.len > 0) {
+      this->_this->resize(view.len / sizeof(Element));
       memcpy(this->_this->p(), view.buf, view.len);
       memcpy(this->_this->p(), view.buf, view.len);
     }
     }
 
 
@@ -52,21 +59,22 @@ __init__(PyObject *self, PyObject *source) {
 
 
   if (!PySequence_Check(source)) {
   if (!PySequence_Check(source)) {
     // If passed with a non-sequence, this isn't the right constructor.
     // If passed with a non-sequence, this isn't the right constructor.
-    PyErr_SetString(PyExc_TypeError, "PointerToArray constructor requires a sequence or buffer object");
+    PyErr_SetString(PyExc_TypeError,
+                    "PointerToArray constructor requires a sequence or buffer object");
     return;
     return;
   }
   }
 
 
   // If we were passed a Python string, then instead of storing it
   // If we were passed a Python string, then instead of storing it
   // character-at-a-time, just load the whole string as a data
   // character-at-a-time, just load the whole string as a data
-  // buffer.
+  // buffer.  Not sure if this case is still necessary - don't Python
+  // str/bytes objects export the buffer protocol, as above?
 #if PY_MAJOR_VERSION >= 3
 #if PY_MAJOR_VERSION >= 3
   if (PyBytes_Check(source)) {
   if (PyBytes_Check(source)) {
     int size = PyBytes_Size(source);
     int size = PyBytes_Size(source);
     if (size % sizeof(Element) != 0) {
     if (size % sizeof(Element) != 0) {
-      ostringstream stream;
-      stream << "Buffer not a multiple of " << sizeof(Element) << " bytes";
-      string str = stream.str();
-      PyErr_SetString(PyExc_ValueError, str.c_str());
+      PyErr_Format(PyExc_ValueError,
+                   "bytes object is not a multiple of %zu bytes",
+                   sizeof(Element));
       return;
       return;
     }
     }
 
 
@@ -85,10 +93,9 @@ __init__(PyObject *self, PyObject *source) {
   if (PyString_CheckExact(source)) {
   if (PyString_CheckExact(source)) {
     int size = PyString_Size(source);
     int size = PyString_Size(source);
     if (size % sizeof(Element) != 0) {
     if (size % sizeof(Element) != 0) {
-      ostringstream stream;
-      stream << "Buffer not a multiple of " << sizeof(Element) << " bytes";
-      string str = stream.str();
-      PyErr_SetString(PyExc_ValueError, str.c_str());
+      PyErr_Format(PyExc_ValueError,
+                   "str object is not a multiple of %zu bytes",
+                   sizeof(Element));
       return;
       return;
     }
     }
 
 
@@ -107,20 +114,29 @@ __init__(PyObject *self, PyObject *source) {
 
 
   // Now construct the internal list by copying the elements
   // Now construct the internal list by copying the elements
   // one-at-a-time from Python.
   // one-at-a-time from Python.
+  PyObject *push_back = PyObject_GetAttrString(self, "push_back");
+  if (push_back == NULL) {
+    PyErr_BadArgument();
+    return;
+  }
+
+  // We need to initialize the this pointer before we can call push_back.
+  ((Dtool_PyInstDef *)self)->_ptr_to_object = (void *)this->_this;
+
   int size = PySequence_Size(source);
   int size = PySequence_Size(source);
   for (int i = 0; i < size; ++i) {
   for (int i = 0; i < size; ++i) {
     PyObject *item = PySequence_GetItem(source, i);
     PyObject *item = PySequence_GetItem(source, i);
     if (item == NULL) {
     if (item == NULL) {
       return;
       return;
     }
     }
-    PyObject *result = PyObject_CallMethod(self, (char *)"push_back", (char *)"O", item);
+    PyObject *result = PyObject_CallFunctionObjArgs(push_back, item, NULL);
     Py_DECREF(item);
     Py_DECREF(item);
     if (result == NULL) {
     if (result == NULL) {
       // Unable to add item--probably it wasn't of the appropriate type.
       // Unable to add item--probably it wasn't of the appropriate type.
-      ostringstream stream;
-      stream << "Element " << i << " in sequence passed to PointerToArray constructor could not be added";
-      string str = stream.str();
-      PyErr_SetString(PyExc_TypeError, str.c_str());
+      PyErr_Print();
+      PyErr_Format(PyExc_TypeError,
+                   "Element %d in sequence passed to PointerToArray "
+                   "constructor could not be added", i);
       return;
       return;
     }
     }
     Py_DECREF(result);
     Py_DECREF(result);
@@ -161,7 +177,9 @@ __setitem__(size_t n, const Element &value) {
 template<class Element>
 template<class Element>
 INLINE void Extension<ConstPointerToArray<Element> >::
 INLINE void Extension<ConstPointerToArray<Element> >::
 __init__(PyObject *self, PyObject *source) {
 __init__(PyObject *self, PyObject *source) {
-  new (this->_this) ConstPointerToArray<Element>(get_type_handle(Element));
+  PointerToArray<Element> array;
+  invoke_extension(&array).__init__(self, source);
+  *(this->_this) = MOVE(array);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -240,7 +258,7 @@ __releasebuffer__(PyObject *self, Py_buffer *view) const {
 
 
   if (view->internal != NULL) {
   if (view->internal != NULL) {
     // Oh, right, let's not forget to unref this.
     // Oh, right, let's not forget to unref this.
-    ((const PointerToArray<Element> *) view->internal)->unref();
+    unref_delete((const PointerToArray<Element> *)view->internal);
     view->internal = NULL;
     view->internal = NULL;
   }
   }
 }
 }
@@ -314,7 +332,7 @@ __releasebuffer__(PyObject *self, Py_buffer *view) const {
 
 
   if (view->internal != NULL) {
   if (view->internal != NULL) {
     // Oh, right, let's not forget to unref this.
     // Oh, right, let's not forget to unref this.
-    ((const PointerToArray<Element> *) view->internal)->unref();
+    unref_delete((const PointerToArray<Element> *)view->internal);
     view->internal = NULL;
     view->internal = NULL;
   }
   }
 }
 }

+ 20 - 0
panda/src/express/pointerToArray_ext.h

@@ -66,6 +66,26 @@ public:
 #endif
 #endif
 };
 };
 
 
+#ifdef _MSC_VER
+// Ugh... MSVC needs this because they still don't have a decent linker.
+#include "PTA_uchar.h"
+#include "PTA_ushort.h"
+#include "PTA_float.h"
+#include "PTA_double.h"
+#include "PTA_int.h"
+
+template class EXPORT_THIS Extension<PTA_uchar>;
+template class EXPORT_THIS Extension<PTA_ushort>;
+template class EXPORT_THIS Extension<PTA_float>;
+template class EXPORT_THIS Extension<PTA_double>;
+template class EXPORT_THIS Extension<PTA_int>;
+template class EXPORT_THIS Extension<CPTA_uchar>;
+template class EXPORT_THIS Extension<CPTA_ushort>;
+template class EXPORT_THIS Extension<CPTA_float>;
+template class EXPORT_THIS Extension<CPTA_double>;
+template class EXPORT_THIS Extension<CPTA_int>;
+#endif
+
 // This macro is used to map a data type to a format code
 // This macro is used to map a data type to a format code
 // as used in the Python 'struct' and 'array' modules.
 // as used in the Python 'struct' and 'array' modules.
 #define get_format_code(type) _get_format_code((const type *)0)
 #define get_format_code(type) _get_format_code((const type *)0)

+ 28 - 0
panda/src/mathutil/pta_LMatrix3_ext.h

@@ -0,0 +1,28 @@
+// Filename: pta_LMatrix3_ext.h
+// Created by:  rdb (25Feb15)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef PTA_LMATRIX3_EXT_H
+#define PTA_LMATRIX3_EXT_H
+
+#include "pointerToArray_ext.h"
+#include "pta_LMatrix3.h"
+
+#if defined(_MSC_VER) && !defined(CPPPARSER)
+template class EXPORT_THIS Extension<PTA_LMatrix3f>;
+template class EXPORT_THIS Extension<PTA_LMatrix3d>;
+template class EXPORT_THIS Extension<CPTA_LMatrix3f>;
+template class EXPORT_THIS Extension<CPTA_LMatrix3d>;
+#endif
+
+#endif

+ 28 - 0
panda/src/mathutil/pta_LMatrix4_ext.h

@@ -0,0 +1,28 @@
+// Filename: pta_LMatrix4_ext.h
+// Created by:  rdb (25Feb15)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef PTA_LMATRIX4_EXT_H
+#define PTA_LMATRIX4_EXT_H
+
+#include "pointerToArray_ext.h"
+#include "pta_LMatrix4.h"
+
+#if defined(_MSC_VER) && !defined(CPPPARSER)
+template class EXPORT_THIS Extension<PTA_LMatrix4f>;
+template class EXPORT_THIS Extension<PTA_LMatrix4d>;
+template class EXPORT_THIS Extension<CPTA_LMatrix4f>;
+template class EXPORT_THIS Extension<CPTA_LMatrix4d>;
+#endif
+
+#endif

+ 30 - 0
panda/src/mathutil/pta_LVecBase2_ext.h

@@ -0,0 +1,30 @@
+// Filename: pta_LVecBase2_ext.h
+// Created by:  rdb (25Feb15)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef PTA_LVECBASE2_EXT_H
+#define PTA_LVECBASE2_EXT_H
+
+#include "pointerToArray_ext.h"
+#include "pta_LVecBase2.h"
+
+#if defined(_MSC_VER) && !defined(CPPPARSER)
+template class EXPORT_THIS Extension<PTA_LVecBase2f>;
+template class EXPORT_THIS Extension<PTA_LVecBase2d>;
+template class EXPORT_THIS Extension<PTA_LVecBase2i>;
+template class EXPORT_THIS Extension<CPTA_LVecBase2f>;
+template class EXPORT_THIS Extension<CPTA_LVecBase2d>;
+template class EXPORT_THIS Extension<CPTA_LVecBase2i>;
+#endif
+
+#endif

+ 30 - 0
panda/src/mathutil/pta_LVecBase3_ext.h

@@ -0,0 +1,30 @@
+// Filename: pta_LVecBase3_ext.h
+// Created by:  rdb (25Feb15)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef PTA_LVECBASE3_EXT_H
+#define PTA_LVECBASE3_EXT_H
+
+#include "pointerToArray_ext.h"
+#include "pta_LVecBase3.h"
+
+#if defined(_MSC_VER) && !defined(CPPPARSER)
+template class EXPORT_THIS Extension<PTA_LVecBase3f>;
+template class EXPORT_THIS Extension<PTA_LVecBase3d>;
+template class EXPORT_THIS Extension<PTA_LVecBase3i>;
+template class EXPORT_THIS Extension<CPTA_LVecBase3f>;
+template class EXPORT_THIS Extension<CPTA_LVecBase3d>;
+template class EXPORT_THIS Extension<CPTA_LVecBase3i>;
+#endif
+
+#endif

+ 30 - 0
panda/src/mathutil/pta_LVecBase4_ext.h

@@ -0,0 +1,30 @@
+// Filename: pta_LVecBase4_ext.h
+// Created by:  rdb (25Feb15)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef PTA_LVECBASE4_EXT_H
+#define PTA_LVECBASE4_EXT_H
+
+#include "pointerToArray_ext.h"
+#include "pta_LVecBase4.h"
+
+#if defined(_MSC_VER) && !defined(CPPPARSER)
+template class EXPORT_THIS Extension<PTA_LVecBase4f>;
+template class EXPORT_THIS Extension<PTA_LVecBase4d>;
+template class EXPORT_THIS Extension<PTA_LVecBase4i>;
+template class EXPORT_THIS Extension<CPTA_LVecBase4f>;
+template class EXPORT_THIS Extension<CPTA_LVecBase4d>;
+template class EXPORT_THIS Extension<CPTA_LVecBase4i>;
+#endif
+
+#endif

+ 2 - 0
panda/src/pgraph/nodePath.h

@@ -39,6 +39,8 @@
 #include "pta_LVecBase2.h"
 #include "pta_LVecBase2.h"
 #include "stl_compares.h"
 #include "stl_compares.h"
 #include "shaderInput.h"
 #include "shaderInput.h"
+#include "textureCollection.h"
+#include "textureStageCollection.h"
 
 
 class NodePathCollection;
 class NodePathCollection;
 class FindApproxPath;
 class FindApproxPath;