mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 08:15:18 -04:00
dtoolutil: iostream should use Py_ssize_t instead of int
This commit is contained in:
parent
fa62344452
commit
99e6a1d9b8
@ -24,12 +24,12 @@ extern struct Dtool_PyTypedObject Dtool_std_istream;
|
||||
* If the given size is -1, all bytes are read from the stream.
|
||||
*/
|
||||
PyObject *Extension<istream>::
|
||||
read(int size) {
|
||||
read(Py_ssize_t size) {
|
||||
if (size < 0) {
|
||||
return readall();
|
||||
}
|
||||
|
||||
char *buffer;
|
||||
char *buffer = nullptr;
|
||||
std::streamsize read_bytes = 0;
|
||||
|
||||
if (size > 0) {
|
||||
@ -62,7 +62,7 @@ read(int size) {
|
||||
* will always be greater than 0 until EOF is reached.
|
||||
*/
|
||||
PyObject *Extension<istream>::
|
||||
read1(int size) {
|
||||
read1(Py_ssize_t size) {
|
||||
std::streambuf *buf = _this->rdbuf();
|
||||
nassertr(buf != nullptr, nullptr);
|
||||
|
||||
@ -171,7 +171,7 @@ readinto(PyObject *b) {
|
||||
* Returns empty string when the end of file is reached.
|
||||
*/
|
||||
PyObject *Extension<istream>::
|
||||
readline(int size) {
|
||||
readline(Py_ssize_t size) {
|
||||
std::streambuf *buf = _this->rdbuf();
|
||||
nassertr(buf != nullptr, nullptr);
|
||||
|
||||
@ -207,7 +207,7 @@ readline(int size) {
|
||||
* for readline().
|
||||
*/
|
||||
PyObject *Extension<istream>::
|
||||
readlines(int hint) {
|
||||
readlines(Py_ssize_t hint) {
|
||||
PyObject *lst = PyList_New(0);
|
||||
if (lst == nullptr) {
|
||||
return nullptr;
|
||||
@ -223,7 +223,7 @@ readlines(int hint) {
|
||||
py_line = readline(-1);
|
||||
}
|
||||
} else {
|
||||
size_t totchars = 0;
|
||||
Py_ssize_t totchars = 0;
|
||||
while (Py_SIZE(py_line) > 0) {
|
||||
totchars += Py_SIZE(py_line);
|
||||
PyList_Append(lst, py_line);
|
||||
|
@ -31,13 +31,13 @@
|
||||
template<>
|
||||
class Extension<istream> : public ExtensionBase<istream> {
|
||||
public:
|
||||
PyObject *read(int size=-1);
|
||||
PyObject *read1(int size=-1);
|
||||
PyObject *read(Py_ssize_t size=-1);
|
||||
PyObject *read1(Py_ssize_t size=-1);
|
||||
PyObject *readall();
|
||||
std::streamsize readinto(PyObject *b);
|
||||
|
||||
PyObject *readline(int size=-1);
|
||||
PyObject *readlines(int hint=-1);
|
||||
PyObject *readline(Py_ssize_t size=-1);
|
||||
PyObject *readlines(Py_ssize_t hint=-1);
|
||||
PyObject *__iter__(PyObject *self);
|
||||
};
|
||||
|
||||
|
@ -50,13 +50,13 @@ namespace std {
|
||||
__published:
|
||||
istream(const istream&) = delete;
|
||||
|
||||
__extension PyObject *read(int size=-1);
|
||||
__extension PyObject *read1(int size=-1);
|
||||
__extension PyObject *read(Py_ssize_t size=-1);
|
||||
__extension PyObject *read1(Py_ssize_t size=-1);
|
||||
__extension PyObject *readall();
|
||||
__extension std::streamsize readinto(PyObject *b);
|
||||
|
||||
__extension PyObject *readline(int size=-1);
|
||||
__extension PyObject *readlines(int hint=-1);
|
||||
__extension PyObject *readline(Py_ssize_t size=-1);
|
||||
__extension PyObject *readlines(Py_ssize_t hint=-1);
|
||||
__extension PyObject *__iter__(PyObject *self);
|
||||
|
||||
int get();
|
||||
|
Loading…
x
Reference in New Issue
Block a user