Python use Py_ssize_t instead of int for better portability

This commit is contained in:
William S Fulton 2015-12-04 23:32:46 +00:00
commit c5322a9ecb
9 changed files with 50 additions and 63 deletions

View file

@ -2473,15 +2473,15 @@ public:
Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args) {", NIL);
Wrapper_add_local(f, "argc", "int argc");
Wrapper_add_local(f, "argc", "Py_ssize_t argc");
Printf(tmp, "PyObject *argv[%d] = {0}", maxargs + 1);
Wrapper_add_local(f, "argv", tmp);
if (!fastunpack) {
Wrapper_add_local(f, "ii", "int ii");
Wrapper_add_local(f, "ii", "Py_ssize_t ii");
if (maxargs - (add_self ? 1 : 0) > 0)
Append(f->code, "if (!PyTuple_Check(args)) SWIG_fail;\n");
Append(f->code, "argc = args ? (int)PyObject_Length(args) : 0;\n");
Append(f->code, "argc = args ? PyObject_Length(args) : 0;\n");
if (add_self)
Append(f->code, "argv[0] = self;\n");
Printf(f->code, "for (ii = 0; (ii < %d) && (ii < argc); ii++) {\n", add_self ? maxargs - 1 : maxargs);