diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-08-03 15:39:27 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-08-03 15:39:27 (GMT) |
commit | a5bca579fd2c887783d87b45724381954db88cbf (patch) | |
tree | 76fc9e4238040e578a29f877a35bc999ac98f8e8 /Mac | |
parent | 3988358b4d70c01660b068deb72bd0818ad85333 (diff) | |
download | cpython-a5bca579fd2c887783d87b45724381954db88cbf.zip cpython-a5bca579fd2c887783d87b45724381954db88cbf.tar.gz cpython-a5bca579fd2c887783d87b45724381954db88cbf.tar.bz2 |
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/Include/pymactoolbox.h | 3 | ||||
-rw-r--r-- | Mac/Modules/macfsmodule.c | 17 | ||||
-rw-r--r-- | Mac/Python/macglue.c | 1 |
3 files changed, 20 insertions, 1 deletions
diff --git a/Mac/Include/pymactoolbox.h b/Mac/Include/pymactoolbox.h index c4a56da..64ac823 100644 --- a/Mac/Include/pymactoolbox.h +++ b/Mac/Include/pymactoolbox.h @@ -42,6 +42,9 @@ #define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) #endif /* USE_TOOLBOX_OBJECT_GLUE */ +/* macfs exports */ +extern int PyMac_GetFSSpec(PyObject *, FSSpec *); + /* AE exports */ extern PyObject *AEDesc_New(AppleEvent *); /* XXXX Why passed by address?? */ extern int AEDesc_Convert(PyObject *, AppleEvent *); diff --git a/Mac/Modules/macfsmodule.c b/Mac/Modules/macfsmodule.c index e6f11ae..d1b8bb0 100644 --- a/Mac/Modules/macfsmodule.c +++ b/Mac/Modules/macfsmodule.c @@ -24,6 +24,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "Python.h" #include "macglue.h" +#include "pymactoolbox.h" #ifdef WITHOUT_FRAMEWORKS #include <Memory.h> @@ -38,7 +39,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "getapplbycreator.h" - +#ifdef USE_TOOLBOX_OBJECT_GLUE +extern int _PyMac_GetFSSpec(PyObject *, FSSpec *); +#define PyMac_GetFSSpec _PyMac_GetFSSpec +#endif static PyObject *ErrorObject; /* ----------------------------------------------------- */ @@ -1201,8 +1205,17 @@ PyMac_GetFSRef(PyObject *v, FSRef *fsr) if ( _mfs_GetFSRefFromFSSpec(v, fsr) ) return 1; if ( PyString_Check(v) ) { +#if TARGET_API_MAC_OSX + OSStatus err; + if ( (err=FSPathMakeRef(PyString_AsString(v), fsr, NULL)) ) { + PyErr_Mac(ErrorObject, err); + return 0; + } + return 1; +#else PyErr_SetString(PyExc_NotImplementedError, "Cannot create an FSRef from a pathname on this platform"); return 0; +#endif } PyErr_SetString(PyExc_TypeError, "FSRef argument should be existing FSRef, FSSpec or (OSX only) pathname"); return 0; @@ -1270,6 +1283,8 @@ initmacfs() { PyObject *m, *d; + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, PyMac_GetFSSpec); + /* Create the module and add the functions */ m = Py_InitModule("macfs", mfs_methods); diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c index 5fdfe55..b81cd85 100644 --- a/Mac/Python/macglue.c +++ b/Mac/Python/macglue.c @@ -1194,6 +1194,7 @@ int routinename(PyObject *pyobj, object *cobj) { \ } \ return (*PyMacGluePtr_##routinename)(pyobj, cobj); \ } +GLUE_CONVERT(FSSpec, PyMac_GetFSSpec, "macfs") GLUE_NEW(AppleEvent *, AEDesc_New, "AE") /* XXXX Why by address? */ GLUE_CONVERT(AppleEvent, AEDesc_Convert, "AE") |