mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
PointerToArray fixes, Windows build fixes, more move constructors
This commit is contained in:
parent
0e67fb7cf3
commit
db87bc7914
@ -64,6 +64,39 @@ Filename(const Filename ©) :
|
||||
{
|
||||
}
|
||||
|
||||
#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
|
||||
// Access: Published
|
||||
@ -216,6 +249,42 @@ operator = (const Filename ©) {
|
||||
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
|
||||
|
@ -68,6 +68,11 @@ PUBLISHED:
|
||||
Filename(const Filename &dirname, const Filename &basename);
|
||||
INLINE ~Filename();
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
INLINE Filename(string &&filename) NOEXCEPT;
|
||||
INLINE Filename(Filename &&from) NOEXCEPT;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
PyObject *__reduce__(PyObject *self) const;
|
||||
#endif
|
||||
@ -88,7 +93,7 @@ PUBLISHED:
|
||||
Type type = T_general);
|
||||
static Filename from_os_specific_w(const wstring &os_specific,
|
||||
Type type = T_general);
|
||||
static Filename expand_from(const string &user_string,
|
||||
static Filename expand_from(const string &user_string,
|
||||
Type type = T_general);
|
||||
static Filename temporary(const string &dirname, const string &prefix,
|
||||
const string &suffix = string(),
|
||||
@ -105,6 +110,11 @@ PUBLISHED:
|
||||
INLINE Filename &operator = (const char *filename);
|
||||
INLINE Filename &operator = (const Filename ©);
|
||||
|
||||
#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.
|
||||
INLINE operator const string & () const;
|
||||
INLINE const char *c_str() const;
|
||||
|
@ -210,6 +210,8 @@ def PrettyTime(t):
|
||||
return "%d sec" % (seconds)
|
||||
|
||||
def ProgressOutput(progress, msg, target = None):
|
||||
sys.stdout.flush()
|
||||
sys.stderr.flush()
|
||||
prefix = ""
|
||||
thisthread = threading.currentThread()
|
||||
if thisthread is MAINTHREAD:
|
||||
@ -235,6 +237,8 @@ def ProgressOutput(progress, msg, target = None):
|
||||
suffix = GetColor()
|
||||
|
||||
print(''.join((prefix, msg, suffix)))
|
||||
sys.stdout.flush()
|
||||
sys.stderr.flush()
|
||||
|
||||
def exit(msg = ""):
|
||||
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())
|
||||
sys.stdout.flush()
|
||||
|
||||
if sys.platform == "win32":
|
||||
if sys.platform in ("win32", "cygwin"):
|
||||
exe = cmd.split()[0]
|
||||
exe_path = LocateBinary(exe)
|
||||
if exe_path is None:
|
||||
|
@ -82,6 +82,33 @@ operator = (const Datagram ©) {
|
||||
_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
|
||||
// Access: Public
|
||||
|
@ -48,6 +48,11 @@ PUBLISHED:
|
||||
INLINE Datagram(const Datagram ©);
|
||||
INLINE void operator = (const Datagram ©);
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
INLINE Datagram(Datagram &&from) NOEXCEPT;
|
||||
INLINE void operator = (Datagram &&from) NOEXCEPT;
|
||||
#endif
|
||||
|
||||
virtual ~Datagram();
|
||||
|
||||
virtual void clear();
|
||||
|
@ -77,6 +77,21 @@ PointerToArray(const PointerToArray<Element> ©) :
|
||||
{
|
||||
}
|
||||
|
||||
#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
|
||||
// Access: Public
|
||||
@ -682,6 +697,21 @@ operator = (const PointerToArray<Element> ©) {
|
||||
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
|
||||
// Access: Public
|
||||
@ -736,6 +766,36 @@ ConstPointerToArray(const ConstPointerToArray<Element> ©) :
|
||||
{
|
||||
}
|
||||
|
||||
#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
|
||||
// Access: Public
|
||||
@ -1141,6 +1201,36 @@ operator = (const ConstPointerToArray<Element> ©) {
|
||||
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
|
||||
// Access: Public
|
||||
|
@ -151,6 +151,10 @@ public:
|
||||
INLINE PointerToArray(size_type n, const Element &value, TypeHandle type_handle = get_type_handle(Element));
|
||||
INLINE PointerToArray(const PointerToArray<Element> ©);
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
INLINE PointerToArray(PointerToArray<Element> &&from) NOEXCEPT;
|
||||
#endif
|
||||
|
||||
public:
|
||||
// Duplicating the interface of vector. The following member
|
||||
// functions are all const, because they do not reassign the
|
||||
@ -231,6 +235,12 @@ public:
|
||||
operator = (ReferenceCountedVector<Element> *ptr);
|
||||
INLINE PointerToArray<Element> &
|
||||
operator = (const PointerToArray<Element> ©);
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
INLINE PointerToArray<Element> &
|
||||
operator = (PointerToArray<Element> &&from) NOEXCEPT;
|
||||
#endif
|
||||
|
||||
INLINE void clear();
|
||||
|
||||
private:
|
||||
@ -305,6 +315,11 @@ PUBLISHED:
|
||||
INLINE ConstPointerToArray(const PointerToArray<Element> ©);
|
||||
INLINE ConstPointerToArray(const ConstPointerToArray<Element> ©);
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
INLINE ConstPointerToArray(PointerToArray<Element> &&from) NOEXCEPT;
|
||||
INLINE ConstPointerToArray(ConstPointerToArray<Element> &&from) NOEXCEPT;
|
||||
#endif
|
||||
|
||||
// Duplicating the interface of vector.
|
||||
|
||||
INLINE iterator begin() const;
|
||||
@ -355,6 +370,14 @@ PUBLISHED:
|
||||
operator = (const PointerToArray<Element> ©);
|
||||
INLINE ConstPointerToArray<Element> &
|
||||
operator = (const ConstPointerToArray<Element> ©);
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
INLINE ConstPointerToArray<Element> &
|
||||
operator = (PointerToArray<Element> &&from) NOEXCEPT;
|
||||
INLINE ConstPointerToArray<Element> &
|
||||
operator = (ConstPointerToArray<Element> &&from) NOEXCEPT;
|
||||
#endif
|
||||
|
||||
INLINE void clear();
|
||||
|
||||
private:
|
||||
|
@ -57,11 +57,11 @@ template<class Element>
|
||||
INLINE ReferenceCountedVector<Element>::
|
||||
~ReferenceCountedVector() {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ReferenceCountedVector::size
|
||||
// Access: Public
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE TYPENAME ReferenceCountedVector<Element>::size_type ReferenceCountedVector<Element>::
|
||||
@ -72,7 +72,7 @@ size() const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ReferenceCountedVector::insert
|
||||
// Access: Public
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE TYPENAME ReferenceCountedVector<Element>::iterator ReferenceCountedVector<Element>::
|
||||
@ -83,7 +83,7 @@ insert(iterator position, const Element &x) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ReferenceCountedVector::insert
|
||||
// Access: Public
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE void ReferenceCountedVector<Element>::
|
||||
@ -94,7 +94,7 @@ insert(iterator position, size_type n, const Element &x) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ReferenceCountedVector::erase
|
||||
// Access: Public
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE void ReferenceCountedVector<Element>::
|
||||
@ -105,7 +105,7 @@ erase(iterator position) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ReferenceCountedVector::erase
|
||||
// Access: Public
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE void ReferenceCountedVector<Element>::
|
||||
@ -116,7 +116,7 @@ erase(iterator first, iterator last) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ReferenceCountedVector::pop_back
|
||||
// Access: Public
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE void ReferenceCountedVector<Element>::
|
||||
@ -127,7 +127,7 @@ pop_back() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ReferenceCountedVector::clear
|
||||
// Access: Public
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE void ReferenceCountedVector<Element>::
|
||||
@ -138,7 +138,7 @@ clear() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayBase::Constructor
|
||||
// Access: Protected
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE PointerToArrayBase<Element>::
|
||||
@ -150,7 +150,7 @@ PointerToArrayBase(ReferenceCountedVector<Element> *ptr) :
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayBase::Copy Constructor
|
||||
// Access: Protected
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE PointerToArrayBase<Element>::
|
||||
@ -159,10 +159,24 @@ PointerToArrayBase(const PointerToArrayBase<Element> ©) :
|
||||
{
|
||||
}
|
||||
|
||||
#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
|
||||
// Access: Published
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE PointerToArrayBase<Element>::
|
||||
|
@ -82,6 +82,10 @@ protected:
|
||||
INLINE PointerToArrayBase(ReferenceCountedVector<Element> *ptr);
|
||||
INLINE PointerToArrayBase(const PointerToArrayBase<Element> ©);
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
INLINE PointerToArrayBase(PointerToArrayBase<Element> &&from) NOEXCEPT;
|
||||
#endif
|
||||
|
||||
PUBLISHED:
|
||||
INLINE ~PointerToArrayBase();
|
||||
};
|
||||
|
@ -22,26 +22,33 @@
|
||||
// Python buffer protocol.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
void Extension<PointerToArray<Element> >::
|
||||
INLINE void Extension<PointerToArray<Element> >::
|
||||
__init__(PyObject *self, PyObject *source) {
|
||||
#if PY_VERSION_HEX >= 0x02060000
|
||||
if (PyObject_CheckBuffer(source)) {
|
||||
// User passed a buffer object.
|
||||
Py_buffer view;
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
this->_this->resize(view.len / sizeof(Element));
|
||||
memcpy(this->_this->p(), view.buf, view.len);
|
||||
}
|
||||
|
||||
@ -52,21 +59,22 @@ __init__(PyObject *self, PyObject *source) {
|
||||
|
||||
if (!PySequence_Check(source)) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
// If we were passed a Python string, then instead of storing it
|
||||
// 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 (PyBytes_Check(source)) {
|
||||
int size = PyBytes_Size(source);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -85,10 +93,9 @@ __init__(PyObject *self, PyObject *source) {
|
||||
if (PyString_CheckExact(source)) {
|
||||
int size = PyString_Size(source);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -107,20 +114,29 @@ __init__(PyObject *self, PyObject *source) {
|
||||
|
||||
// Now construct the internal list by copying the elements
|
||||
// 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);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
PyObject *item = PySequence_GetItem(source, i);
|
||||
if (item == NULL) {
|
||||
return;
|
||||
}
|
||||
PyObject *result = PyObject_CallMethod(self, (char *)"push_back", (char *)"O", item);
|
||||
PyObject *result = PyObject_CallFunctionObjArgs(push_back, item, NULL);
|
||||
Py_DECREF(item);
|
||||
if (result == NULL) {
|
||||
// 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;
|
||||
}
|
||||
Py_DECREF(result);
|
||||
@ -161,7 +177,9 @@ __setitem__(size_t n, const Element &value) {
|
||||
template<class Element>
|
||||
INLINE void Extension<ConstPointerToArray<Element> >::
|
||||
__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) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@ -314,7 +332,7 @@ __releasebuffer__(PyObject *self, Py_buffer *view) const {
|
||||
|
||||
if (view->internal != NULL) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,26 @@ public:
|
||||
#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
|
||||
// as used in the Python 'struct' and 'array' modules.
|
||||
#define get_format_code(type) _get_format_code((const type *)0)
|
||||
|
28
panda/src/mathutil/pta_LMatrix3_ext.h
Executable file
28
panda/src/mathutil/pta_LMatrix3_ext.h
Executable file
@ -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
panda/src/mathutil/pta_LMatrix4_ext.h
Executable file
28
panda/src/mathutil/pta_LMatrix4_ext.h
Executable file
@ -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
panda/src/mathutil/pta_LVecBase2_ext.h
Executable file
30
panda/src/mathutil/pta_LVecBase2_ext.h
Executable file
@ -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
panda/src/mathutil/pta_LVecBase3_ext.h
Executable file
30
panda/src/mathutil/pta_LVecBase3_ext.h
Executable file
@ -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
panda/src/mathutil/pta_LVecBase4_ext.h
Executable file
30
panda/src/mathutil/pta_LVecBase4_ext.h
Executable file
@ -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
|
@ -39,6 +39,8 @@
|
||||
#include "pta_LVecBase2.h"
|
||||
#include "stl_compares.h"
|
||||
#include "shaderInput.h"
|
||||
#include "textureCollection.h"
|
||||
#include "textureStageCollection.h"
|
||||
|
||||
class NodePathCollection;
|
||||
class FindApproxPath;
|
||||
|
Loading…
x
Reference in New Issue
Block a user