[C++-sig] [pybindgen] parameter defaults
Olaf Peter
ope-devel at gmx.de
Sat Aug 23 19:34:17 CEST 2008
> stdin_py.add_method('read', retval('PyObject*',
> caller_owns_return=False), [param('int', 'size=None')])
therefore the C code must like shown something like:
PyObject *
PyRedirectIn_read(PyRedirectIn *self, PyObject *args, PyObject *kwargs)
{
int size = std::numeric_limits<int>::max();
const char *keywords[] = {"size", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "|i", (char
**) keywords, &size)) {
return NULL;
}
QString retval = self->obj->read_fn(size);
PyObject *py_retval = Py_BuildValue((char *) "s", static_cast<const
char*>(retval.toUtf8()));
return py_retval;
}
More information about the Cplusplus-sig
mailing list