Format string describing arguments. A leading '-' in the format string disposes of the arguments on a successful parse. A '|' in the format string signifies, that the following arguments are optional. The following format specifiers are recognized:Table 5-2. Format specifiers for sipParseArgs()
fmt Operand type expected C argument(s) s String or None char ** S Slot name, return the name char ** G Signal name, return the name char ** I Class instance int (*convfunc)(PyObject *), PyObject ** O Python object of any type PyObject ** T Python object of given type PyTypeObject *, PyObject ** R Sub-class of QObject PyObject ** F Python callable object PyObject ** a Byte array or None char **, int * c Character char * i Integer int * h Short integer short * l Long integer long * f Float float * d Double float double * v Void pointer void **
Example 5-1. Interface for QRegExp::match
// Attempts to match in str, starting from position index. // Returns the position of the match, or -1 if there was no match. // if len is not a null pointer, the length of the match is stored in *len. int match(const char* str, int index=0, int*=0) const; %MemberCode // The Python interface returns the position and length as a tuple. const char *str; int index = 0; if (sipParseArgs(&sipArgsParsed, sipArgs, "s|i", &str, &index)) { int pos, len; QRegExp *ptr; if ((ptr = (QRegExp*) sipGetCppPtr(sipThis, sipClass_QRegExp)) == NULL) return NULL; pos = ptr -> QRegExp::match(str, index, &len); return Py_BuildValue("(ii)", pos, len); } %End
If the C/C++ pointer is recognised and it is an instance of a sub-class of the expected class then the previously wrapped instance is returned. Otherwise a new Python instance is created with the expected class. The instance comes with a reference.
Report a Python runtime error with this message: Cannot pass None as a classname argument in this call
Report a Python type error with this mesage: Invalid result type from classname.method();