diff options
Diffstat (limited to 'Mac/Contrib/osam/OSAm.c')
-rw-r--r-- | Mac/Contrib/osam/OSAm.c | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/Mac/Contrib/osam/OSAm.c b/Mac/Contrib/osam/OSAm.c index a9c3445..aa9a5da 100644 --- a/Mac/Contrib/osam/OSAm.c +++ b/Mac/Contrib/osam/OSAm.c @@ -49,25 +49,30 @@ OSAm_RunCompiledScript (self, args) char *line; DescType typeCode; long dataSize = 0; + OSErr err; - HLock (temp.dataHandle); - - dataSize = GetHandleSize (temp.dataHandle); + dataSize = AEGetDescDataSize (&temp); if (dataSize > 0) { - PyObject *result = PyString_FromStringAndSize ((*temp.dataHandle), + PyObject *result = PyString_FromStringAndSize (NULL, dataSize); - - AEDisposeDesc (&temp); + if (!result) { printf ("OSAm.error Out of memory.\n"); Py_INCREF (Py_None); + AEDisposeDesc (&temp); return Py_None; } + if ( (err=AEGetDescData(&temp, PyString_AS_STRING(result), dataSize)) < 0 ) + { + AEDisposeDesc(&temp); + return PyMac_Error(err); + } + AEDisposeDesc(&temp); return result; } } @@ -110,28 +115,32 @@ OSAm_CompileAndSave (self, args) char *line; DescType typeCode; long dataSize = 0; + OSErr err; - HLock (temp.dataHandle); - - dataSize = GetHandleSize (temp.dataHandle); + dataSize = AEGetDescDataSize (&temp); if (dataSize > 0) { - PyObject *result = PyString_FromStringAndSize ((*temp.dataHandle), + PyObject *result = PyString_FromStringAndSize (NULL, dataSize); - - AEDisposeDesc (&temp); + if (!result) { printf ("OSAm.error Out of memory.\n"); Py_INCREF (Py_None); + AEDisposeDesc (&temp); return Py_None; } + if ( (err=AEGetDescData(&temp, PyString_AS_STRING(result), dataSize)) < 0 ) + { + AEDisposeDesc(&temp); + return PyMac_Error(err); + } + AEDisposeDesc(&temp); return result; } - } if (myErr != noErr) @@ -170,25 +179,30 @@ OSAm_CompileAndExecute (self, args) char *line; DescType typeCode; long dataSize = 0; + OSErr err; - HLock (temp.dataHandle); - - dataSize = GetHandleSize (temp.dataHandle); + dataSize = AEGetDescDataSize (&temp); if (dataSize > 0) { - PyObject *result = PyString_FromStringAndSize ((*temp.dataHandle), + PyObject *result = PyString_FromStringAndSize (NULL, dataSize); - - AEDisposeDesc (&temp); + if (!result) { printf ("OSAm.error Out of memory.\n"); Py_INCREF (Py_None); + AEDisposeDesc (&temp); return Py_None; } + if ( (err=AEGetDescData(&temp, PyString_AS_STRING(result), dataSize)) < 0 ) + { + AEDisposeDesc(&temp); + return PyMac_Error(err); + } + AEDisposeDesc(&temp); return result; } } @@ -216,7 +230,7 @@ static struct PyMethodDef OSAm_methods[] = (PyCFunction) OSAm_CompileAndExecute, METH_VARARGS, OSAm_DoCommand__doc__}, - +#if 0 {"CompileAndSave", (PyCFunction) OSAm_CompileAndSave, METH_VARARGS, @@ -226,6 +240,7 @@ static struct PyMethodDef OSAm_methods[] = (PyCFunction) OSAm_RunCompiledScript, METH_VARARGS, OSAm_DoCommand__doc__}, +#endif {NULL, (PyCFunction) NULL, 0, NULL} }; |