[Python-checkins] python/dist/src/Modules _testcapimodule.c,1.23,1.24
theller@users.sourceforge.net
theller@users.sourceforge.net
Thu, 24 Apr 2003 09:14:29 -0700
- Previous message: [Python-checkins] python/dist/src/Lib/test string_tests.py,1.31,1.32 test_capi.py,1.5,1.6 test_codecs.py,1.7,1.8 test_csv.py,1.3,1.4 test_getargs2.py,1.2,1.3 test_gettext.py,1.12,1.13 test_macfs.py,1.6,1.7 test_pwd.py,1.15,1.16 test_scriptpackages.py,1.2,1.3 test_shlex.py,1.3,1.4 test_signal.py,1.13,1.14 test_stringprep.py,1.1,1.2 test_time.py,1.14,1.15 test_unicode_file.py,1.8,1.9
- Next message: [Python-checkins] python/dist/src/Lib/test test_getargs2.py,1.3,1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv26581
Modified Files:
_testcapimodule.c
Log Message:
New support functions for test_getargs2.
Theres now a separate function for each of the format codes
b, B, H, I, k, i, l, L, K.
Index: _testcapimodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_testcapimodule.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** _testcapimodule.c 22 Apr 2003 01:28:57 -0000 1.23
--- _testcapimodule.c 24 Apr 2003 16:14:27 -0000 1.24
***************
*** 295,386 ****
#endif /* ifdef HAVE_LONG_LONG */
! /* Call PyArg_ParseTuple, and return the result as unsigned long */
static PyObject *
! getargs_ul(PyObject *self, PyObject *args)
{
! PyObject *ob, *result = NULL, *argtuple;
! char *fmt;
! unsigned long value = 0;
! if (!PyArg_ParseTuple(args, "sO", &fmt, &ob))
return NULL;
! argtuple = PyTuple_New(1);
! Py_INCREF(ob);
! PyTuple_SET_ITEM(argtuple, 0, ob);
! if (PyArg_ParseTuple(argtuple, fmt, &value))
! result = PyLong_FromUnsignedLong(value);
! Py_DECREF(argtuple);
! return result;
}
- /* Call PyArg_ParseTuple, and return the result as signed long */
static PyObject *
! getargs_l(PyObject *self, PyObject *args)
{
! PyObject *ob, *result = NULL, *argtuple;
! char *fmt;
! if (!PyArg_ParseTuple(args, "sO", &fmt, &ob))
return NULL;
! argtuple = PyTuple_New(1);
! Py_INCREF(ob);
! PyTuple_SET_ITEM(argtuple, 0, ob);
! /* It's necessary to distinguish between ints and longs, since
! sizeof(int) != sizeof(long) on some (64 bit) platforms.
! value must be an int for: PyArg_ParseTuple(t, 'i', &value)
! value must be an long for: PyArg_ParseTuple(t, 'l', &value)
! */
! if (*fmt == 'i') {
! int value;
! if (PyArg_ParseTuple(argtuple, fmt, &value))
! result = PyLong_FromLong(value);
! } else if (*fmt == 'l') {
! long value;
! if (PyArg_ParseTuple(argtuple, fmt, &value))
! result = PyLong_FromLong(value);
! } else {
! PyErr_SetString(PyExc_TypeError, "format was not i or l");
! }
! Py_DECREF(argtuple);
! return result;
}
- #ifdef HAVE_LONG_LONG
- /* Call PyArg_ParseTuple, and return the result as signed long long */
static PyObject *
! getargs_ll(PyObject *self, PyObject *args)
{
! PyObject *ob, *result = NULL, *argtuple;
! char *fmt;
! PY_LONG_LONG value = 0;
! if (!PyArg_ParseTuple(args, "sO", &fmt, &ob))
return NULL;
! argtuple = PyTuple_New(1);
! Py_INCREF(ob);
! PyTuple_SET_ITEM(argtuple, 0, ob);
! if (PyArg_ParseTuple(argtuple, fmt, &value))
! result = PyLong_FromLongLong(value);
! Py_DECREF(argtuple);
! return result;
}
- /* Call PyArg_ParseTuple, and return the result as unsigned long long */
static PyObject *
! getargs_ull(PyObject *self, PyObject *args)
{
! PyObject *ob, *result = NULL, *argtuple;
! char *fmt;
! unsigned PY_LONG_LONG value = 0;
! if (!PyArg_ParseTuple(args, "sO", &fmt, &ob))
return NULL;
! argtuple = PyTuple_New(1);
! Py_INCREF(ob);
! PyTuple_SET_ITEM(argtuple, 0, ob);
! if (PyArg_ParseTuple(argtuple, fmt, &value))
! result = PyLong_FromUnsignedLongLong(value);
! Py_DECREF(argtuple);
! return result;
}
#endif
--- 295,381 ----
#endif /* ifdef HAVE_LONG_LONG */
! /* Functions to call PyArg_ParseTuple with integer format codes,
! and return the result.
! */
static PyObject *
! getargs_b(PyObject *self, PyObject *args)
{
! unsigned char value;
! if (!PyArg_ParseTuple(args, "b", &value))
! return NULL;
! return PyLong_FromUnsignedLong((unsigned long)value);
! }
! static PyObject *
! getargs_B(PyObject *self, PyObject *args)
! {
! unsigned char value;
! if (!PyArg_ParseTuple(args, "B", &value))
return NULL;
! return PyLong_FromUnsignedLong((unsigned long)value);
}
static PyObject *
! getargs_H(PyObject *self, PyObject *args)
{
! unsigned short value;
! if (!PyArg_ParseTuple(args, "H", &value))
! return NULL;
! return PyLong_FromUnsignedLong((unsigned long)value);
! }
! static PyObject *
! getargs_I(PyObject *self, PyObject *args)
! {
! unsigned int value;
! if (!PyArg_ParseTuple(args, "I", &value))
return NULL;
! return PyLong_FromUnsignedLong((unsigned long)value);
}
static PyObject *
! getargs_k(PyObject *self, PyObject *args)
{
! unsigned long value;
! if (!PyArg_ParseTuple(args, "k", &value))
! return NULL;
! return PyLong_FromUnsignedLong(value);
! }
! static PyObject *
! getargs_i(PyObject *self, PyObject *args)
! {
! int value;
! if (!PyArg_ParseTuple(args, "i", &value))
return NULL;
! return PyLong_FromLong((long)value);
}
static PyObject *
! getargs_l(PyObject *self, PyObject *args)
{
! long value;
! if (!PyArg_ParseTuple(args, "l", &value))
! return NULL;
! return PyLong_FromLong(value);
! }
! #ifdef HAVE_LONG_LONG
! static PyObject *
! getargs_L(PyObject *self, PyObject *args)
! {
! PY_LONG_LONG value;
! if (!PyArg_ParseTuple(args, "L", &value))
return NULL;
! return PyLong_FromLongLong(value);
! }
!
! static PyObject *
! getargs_K(PyObject *self, PyObject *args)
! {
! unsigned PY_LONG_LONG value;
! if (!PyArg_ParseTuple(args, "K", &value))
! return NULL;
! return PyLong_FromUnsignedLongLong(value);
}
#endif
***************
*** 601,609 ****
{"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS},
{"test_k_code", (PyCFunction)test_k_code, METH_NOARGS},
! {"getargs_ul", (PyCFunction)getargs_ul, METH_VARARGS},
{"getargs_l", (PyCFunction)getargs_l, METH_VARARGS},
#ifdef HAVE_LONG_LONG
! {"getargs_ll", (PyCFunction)getargs_ll, METH_VARARGS},
! {"getargs_ull", (PyCFunction)getargs_ull, METH_VARARGS},
{"test_longlong_api", (PyCFunction)test_longlong_api, METH_NOARGS},
{"test_L_code", (PyCFunction)test_L_code, METH_NOARGS},
--- 596,610 ----
{"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS},
{"test_k_code", (PyCFunction)test_k_code, METH_NOARGS},
!
! {"getargs_b", (PyCFunction)getargs_b, METH_VARARGS},
! {"getargs_B", (PyCFunction)getargs_B, METH_VARARGS},
! {"getargs_H", (PyCFunction)getargs_H, METH_VARARGS},
! {"getargs_I", (PyCFunction)getargs_I, METH_VARARGS},
! {"getargs_k", (PyCFunction)getargs_k, METH_VARARGS},
! {"getargs_i", (PyCFunction)getargs_i, METH_VARARGS},
{"getargs_l", (PyCFunction)getargs_l, METH_VARARGS},
#ifdef HAVE_LONG_LONG
! {"getargs_L", (PyCFunction)getargs_L, METH_VARARGS},
! {"getargs_K", (PyCFunction)getargs_K, METH_VARARGS},
{"test_longlong_api", (PyCFunction)test_longlong_api, METH_NOARGS},
{"test_L_code", (PyCFunction)test_L_code, METH_NOARGS},
- Previous message: [Python-checkins] python/dist/src/Lib/test string_tests.py,1.31,1.32 test_capi.py,1.5,1.6 test_codecs.py,1.7,1.8 test_csv.py,1.3,1.4 test_getargs2.py,1.2,1.3 test_gettext.py,1.12,1.13 test_macfs.py,1.6,1.7 test_pwd.py,1.15,1.16 test_scriptpackages.py,1.2,1.3 test_shlex.py,1.3,1.4 test_signal.py,1.13,1.14 test_stringprep.py,1.1,1.2 test_time.py,1.14,1.15 test_unicode_file.py,1.8,1.9
- Next message: [Python-checkins] python/dist/src/Lib/test test_getargs2.py,1.3,1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]