]> granicus.if.org Git - python/commitdiff
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
authorJack Jansen <jack.jansen@cwi.nl>
Fri, 3 Aug 2001 15:39:27 +0000 (15:39 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Fri, 3 Aug 2001 15:39:27 +0000 (15:39 +0000)
Mac/Include/pymactoolbox.h
Mac/Modules/macfsmodule.c
Mac/Python/macglue.c

index c4a56daa629e9eef03f7fce21b1435cc0cb9dfaa..64ac823fe34fa671366bba47475f8d6155af0f9e 100644 (file)
@@ -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 *);
index e6f11aeec4e35becd11da5a69a6a6ff0728c1ad2..d1b8bb0bfc831d1ecdb07a459069405e35d3228c 100644 (file)
@@ -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);
 
index 5fdfe559efa49c2e72222b8bd25a8a028632a110..b81cd85e1459765fe8a8562839eae9944161cfb0 100644 (file)
@@ -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")