mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
Py_buffer is not available in Python versions before 2.6
This commit is contained in:
parent
7926a5fa7b
commit
87aa66f09c
@ -96,6 +96,7 @@ PointerToArray(PyObject *self, PyObject *source) :
|
|||||||
// self in the constructor--the caller can't initialize this for us.
|
// self in the constructor--the caller can't initialize this for us.
|
||||||
((Dtool_PyInstDef *)self)->_ptr_to_object = this;
|
((Dtool_PyInstDef *)self)->_ptr_to_object = this;
|
||||||
|
|
||||||
|
#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;
|
||||||
@ -119,6 +120,7 @@ PointerToArray(PyObject *self, PyObject *source) :
|
|||||||
PyBuffer_Release(&view);
|
PyBuffer_Release(&view);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
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.
|
||||||
@ -1330,6 +1332,7 @@ clear() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
|
#if PY_VERSION_HEX >= 0x02060000
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PointerToArray::__getbuffer__
|
// Function: PointerToArray::__getbuffer__
|
||||||
// Access: Published
|
// Access: Published
|
||||||
@ -1342,7 +1345,6 @@ INLINE int PointerToArray<Element>::
|
|||||||
__getbuffer__(PyObject *self, Py_buffer *view, int flags) {
|
__getbuffer__(PyObject *self, Py_buffer *view, int flags) {
|
||||||
|
|
||||||
const char *format = get_format_code(Element);
|
const char *format = get_format_code(Element);
|
||||||
cerr << "non-const __getbuffer__ with fmt " << format << "\n";
|
|
||||||
if (format == NULL) {
|
if (format == NULL) {
|
||||||
// Not supported.
|
// Not supported.
|
||||||
return -1;
|
return -1;
|
||||||
@ -1411,14 +1413,12 @@ INLINE int ConstPointerToArray<Element>::
|
|||||||
__getbuffer__(PyObject *self, Py_buffer *view, int flags) const {
|
__getbuffer__(PyObject *self, Py_buffer *view, int flags) const {
|
||||||
|
|
||||||
if ((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) {
|
if ((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) {
|
||||||
cerr << "writable buffer requested of const array\n";
|
|
||||||
PyErr_SetString(PyExc_BufferError,
|
PyErr_SetString(PyExc_BufferError,
|
||||||
"Object is not writable.");
|
"Object is not writable.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *format = get_format_code(Element);
|
const char *format = get_format_code(Element);
|
||||||
cerr << "const __getbuffer__ with fmt " << format << "\n";
|
|
||||||
if (format == NULL) {
|
if (format == NULL) {
|
||||||
// Not supported.
|
// Not supported.
|
||||||
return -1;
|
return -1;
|
||||||
@ -1474,6 +1474,7 @@ __releasebuffer__(PyObject *self, Py_buffer *view) const {
|
|||||||
view->internal = NULL;
|
view->internal = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // PY_VERSION_HEX
|
||||||
#endif // HAVE_PYTHON
|
#endif // HAVE_PYTHON
|
||||||
|
|
||||||
#endif // CPPPARSER
|
#endif // CPPPARSER
|
||||||
|
@ -131,9 +131,11 @@ PUBLISHED:
|
|||||||
INLINE int get_node_ref_count() const;
|
INLINE int get_node_ref_count() const;
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
|
#if PY_VERSION_HEX >= 0x02060000
|
||||||
int __getbuffer__(PyObject *self, Py_buffer *view, int flags);
|
int __getbuffer__(PyObject *self, Py_buffer *view, int flags);
|
||||||
void __releasebuffer__(PyObject *self, Py_buffer *view) const;
|
void __releasebuffer__(PyObject *self, Py_buffer *view) const;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#else // CPPPARSER
|
#else // CPPPARSER
|
||||||
// This is the actual, complete interface.
|
// This is the actual, complete interface.
|
||||||
|
@ -129,6 +129,7 @@ read_file(const Filename &file, bool do_uncompress,
|
|||||||
if (asset == (AAsset *)NULL) {
|
if (asset == (AAsset *)NULL) {
|
||||||
express_cat.info()
|
express_cat.info()
|
||||||
<< "Unable to read " << file << "\n";
|
<< "Unable to read " << file << "\n";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reserve enough space to hold the entire file.
|
// Reserve enough space to hold the entire file.
|
||||||
@ -251,7 +252,7 @@ get_system_info(const Filename &file, SubfileInfo &info) {
|
|||||||
// We don't actually need the file descriptor, so close it.
|
// We don't actually need the file descriptor, so close it.
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
info = SubfileInfo(_apk_path, start, length);
|
info = SubfileInfo(_apk_path, start, length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user