Added PyMac_BuildOptStr255, which returns None on a null pointer.

This commit is contained in:
Jack Jansen 1999-12-17 17:15:50 +00:00
parent a07431f0ce
commit b734adef4b
2 changed files with 15 additions and 0 deletions

View File

@ -105,6 +105,7 @@ PyObject *PyMac_BuildNumVersion(NumVersion); /* Convert NumVersion to PyObject *
int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */
PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */
PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject, NULL to None */
int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */
PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */

View File

@ -826,6 +826,20 @@ PyMac_GetStr255(PyObject *v, Str255 pbuf)
PyObject *
PyMac_BuildStr255(Str255 s)
{
if ( s == NULL ) {
PyErr_SetString(PyExc_SystemError, "Str255 pointer is NULL");
return NULL;
}
return PyString_FromStringAndSize((char *)&s[1], (int)s[0]);
}
PyObject *
PyMac_BuildOptStr255(Str255 s)
{
if ( s == NULL ) {
Py_INCREF(Py_None);
return Py_None;
}
return PyString_FromStringAndSize((char *)&s[1], (int)s[0]);
}