Browse Source

restore implicit coercion of Python objects into CPTA

David Rose 12 years ago
parent
commit
a27908a7e8
2 changed files with 25 additions and 0 deletions
  1. 17 0
      panda/src/express/pointerToArray.I
  2. 8 0
      panda/src/express/pointerToArray.h

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

@@ -831,6 +831,23 @@ ConstPointerToArray(const ConstPointerToArray<Element> &copy) :
 {
 }
 
+#ifdef HAVE_PYTHON
+////////////////////////////////////////////////////////////////////
+//     Function: ConstPointerToArray::Constructor
+//       Access: Public
+//  Description: This special constructor accepts a Python list of
+//               elements, or a Python string (or a bytes object,
+//               in Python 3).
+////////////////////////////////////////////////////////////////////
+template<class Element>
+INLINE ConstPointerToArray<Element>::
+ConstPointerToArray(PyObject *self, PyObject *sequence) :
+  PointerToArrayBase<Element>(PointerToArray<Element>(self, sequence)),
+  _type_handle(get_type_handle(Element))
+{
+}
+#endif  // HAVE_PYTHON
+
 ////////////////////////////////////////////////////////////////////
 //     Function: ConstPointerToArray::begin
 //       Access: Public

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

@@ -267,6 +267,10 @@ PUBLISHED:
   INLINE ConstPointerToArray(const PointerToArray<Element> &copy);
   INLINE ConstPointerToArray(const ConstPointerToArray<Element> &copy);
 
+#ifdef HAVE_PYTHON
+  INLINE ConstPointerToArray(PyObject *self, PyObject *sequence);
+#endif
+
   typedef TYPENAME pvector<Element>::size_type size_type;
   INLINE size_type size() const;
   INLINE const Element &get_element(size_type n) const;
@@ -298,6 +302,10 @@ PUBLISHED:
   INLINE ConstPointerToArray(const PointerToArray<Element> &copy);
   INLINE ConstPointerToArray(const ConstPointerToArray<Element> &copy);
 
+#ifdef HAVE_PYTHON
+  INLINE ConstPointerToArray(PyObject *self, PyObject *sequence);
+#endif
+
   // Duplicating the interface of vector.
 
   INLINE iterator begin() const;