summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2001-11-05 14:39:22 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2001-11-05 14:39:22 (GMT)
commit537a69fe66b10614b11b129d07da146f30801717 (patch)
tree7dc192e0c60c4aecb6b22eee77503f46eb3bbbf4
parent80c85d80c4c0ae7ebbd3fb650c23346c391edb7b (diff)
downloadcpython-537a69fe66b10614b11b129d07da146f30801717.zip
cpython-537a69fe66b10614b11b129d07da146f30801717.tar.gz
cpython-537a69fe66b10614b11b129d07da146f30801717.tar.bz2
Make the CoreFoundation object _New and _Convert routines available to other modules. Idea by Donovan Preston, implementaion by me.
-rw-r--r--Include/pymactoolbox.h24
-rw-r--r--Mac/Modules/cf/_CFmodule.c89
-rw-r--r--Mac/Modules/cf/cfsupport.py89
-rw-r--r--Python/mactoolboxglue.c22
4 files changed, 186 insertions, 38 deletions
diff --git a/Include/pymactoolbox.h b/Include/pymactoolbox.h
index 9c7a1dc..5313d91 100644
--- a/Include/pymactoolbox.h
+++ b/Include/pymactoolbox.h
@@ -15,6 +15,12 @@
#include <Lists.h>
#include <Movies.h>
#include <Errors.h>
+#include <CFBase.h>
+#include <CFArray.h>
+#include <CFData.h>
+#include <CFDictionary.h>
+#include <CFString.h>
+#include <CFURL.h>
#else
#include <Carbon/Carbon.h>
#include <QuickTime/QuickTime.h>
@@ -167,6 +173,24 @@ extern PyObject *WinObj_New(WindowPtr);
extern int WinObj_Convert(PyObject *, WindowPtr *);
extern PyObject *WinObj_WhichWindow(WindowPtr);
+/* CF exports */
+extern PyObject *CFTypeRefObj_New(CFTypeRef);
+extern int CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
+extern PyObject *CFStringRefObj_New(CFStringRef);
+extern int CFStringRefObj_Convert(PyObject *, CFStringRef *);
+extern PyObject *CFMutableStringRefObj_New(CFMutableStringRef);
+extern int CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *);
+extern PyObject *CFArrayRefObj_New(CFArrayRef);
+extern int CFArrayRefObj_Convert(PyObject *, CFArrayRef *);
+extern PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef);
+extern int CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *);
+extern PyObject *CFDictionaryRefObj_New(CFDictionaryRef);
+extern int CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *);
+extern PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef);
+extern int CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *);
+extern PyObject *CFURLRefObj_New(CFURLRef);
+extern int CFURLRefObj_Convert(PyObject *, CFURLRef *);
+extern int OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *);
#ifdef __cplusplus
}
diff --git a/Mac/Modules/cf/_CFmodule.c b/Mac/Modules/cf/_CFmodule.c
index 649e437..fc2bb52 100644
--- a/Mac/Modules/cf/_CFmodule.c
+++ b/Mac/Modules/cf/_CFmodule.c
@@ -31,23 +31,58 @@
#include <CoreServices/CoreServices.h>
#endif
-/* For now we declare them forward here. They'll go to mactoolbox later */
-staticforward PyObject *CFTypeRefObj_New(CFTypeRef);
-staticforward int CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
-staticforward PyObject *CFStringRefObj_New(CFStringRef);
-staticforward int CFStringRefObj_Convert(PyObject *, CFStringRef *);
-staticforward PyObject *CFURLRefObj_New(CFURLRef);
-staticforward int CFURLRefObj_Convert(PyObject *, CFURLRef *);
-
-staticforward int CFURLRefObj_Convert(PyObject *, CFURLRef *);
-
-// ADD declarations
-#ifdef NOTYET_USE_TOOLBOX_OBJECT_GLUE
-//extern PyObject *_CFTypeRefObj_New(CFTypeRef);
-//extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
-
-//#define CFTypeRefObj_New _CFTypeRefObj_New
-//#define CFTypeRefObj_Convert _CFTypeRefObj_Convert
+#ifdef USE_TOOLBOX_OBJECT_GLUE
+extern PyObject *_CFTypeRefObj_New(CFTypeRef);
+extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
+#define CFTypeRefObj_New _CFTypeRefObj_New
+#define CFTypeRefObj_Convert _CFTypeRefObj_Convert
+
+extern PyObject *_CFStringRefObj_New(CFStringRef);
+extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *);
+#define CFStringRefObj_New _CFStringRefObj_New
+#define CFStringRefObj_Convert _CFStringRefObj_Convert
+
+extern PyObject *_CFMutableStringRefObj_New(CFMutableStringRef);
+extern int _CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *);
+#define CFMutableStringRefObj_New _CFMutableStringRefObj_New
+#define CFMutableStringRefObj_Convert _CFMutableStringRefObj_Convert
+
+extern PyObject *_CFArrayRefObj_New(CFArrayRef);
+extern int _CFArrayRefObj_Convert(PyObject *, CFArrayRef *);
+#define CFArrayRefObj_New _CFArrayRefObj_New
+#define CFArrayRefObj_Convert _CFArrayRefObj_Convert
+
+extern PyObject *_CFMutableArrayRefObj_New(CFMutableArrayRef);
+extern int _CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *);
+#define CFMutableArrayRefObj_New _CFMutableArrayRefObj_New
+#define CFMutableArrayRefObj_Convert _CFMutableArrayRefObj_Convert
+
+extern PyObject *_CFDataRefObj_New(CFDataRef);
+extern int _CFDataRefObj_Convert(PyObject *, CFDataRef *);
+#define CFDataRefObj_New _CFDataRefObj_New
+#define CFDataRefObj_Convert _CFDataRefObj_Convert
+
+extern PyObject *_CFMutableDataRefObj_New(CFMutableDataRef);
+extern int _CFMutableDataRefObj_Convert(PyObject *, CFMutableDataRef *);
+#define CFMutableDataRefObj_New _CFMutableDataRefObj_New
+#define CFMutableDataRefObj_Convert _CFMutableDataRefObj_Convert
+
+extern PyObject *_CFDictionaryRefObj_New(CFDictionaryRef);
+extern int _CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *);
+#define CFDictionaryRefObj_New _CFDictionaryRefObj_New
+#define CFDictionaryRefObj_Convert _CFDictionaryRefObj_Convert
+
+extern PyObject *_CFMutableDictionaryRefObj_New(CFMutableDictionaryRef);
+extern int _CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *);
+#define CFMutableDictionaryRefObj_New _CFMutableDictionaryRefObj_New
+#define CFMutableDictionaryRefObj_Convert _CFMutableDictionaryRefObj_Convert
+
+extern PyObject *_CFURLRefObj_New(CFURLRef);
+extern int _CFURLRefObj_Convert(PyObject *, CFURLRef *);
+extern int _OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *);
+#define CFURLRefObj_New _CFURLRefObj_New
+#define CFURLRefObj_Convert _CFURLRefObj_Convert
+#define OptionalCFURLRefObj_Convert _OptionalCFURLRefObj_Convert
#endif
/*
@@ -3122,8 +3157,24 @@ void init_CF(void)
- // PyMac_INIT_TOOLBOX_OBJECT_NEW(Track, TrackObj_New);
- // PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Track, TrackObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef, CFTypeRefObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef, CFTypeRefObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(CFStringRef, CFStringRefObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFStringRef, CFStringRefObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableStringRef, CFMutableStringRefObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableStringRef, CFMutableStringRefObj_Convert);
+
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(CFArrayRef, CFArrayRefObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFArrayRef, CFArrayRefObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableArrayRef, CFMutableArrayRefObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableArrayRef, CFMutableArrayRefObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(CFDictionaryRef, CFDictionaryRefObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFDictionaryRef, CFDictionaryRefObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableDictionaryRef, CFMutableDictionaryRefObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableDictionaryRef, CFMutableDictionaryRefObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(CFURLRef, CFURLRefObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef, CFURLRefObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef, CFURLRefObj_Convert);
m = Py_InitModule("_CF", CF_methods);
diff --git a/Mac/Modules/cf/cfsupport.py b/Mac/Modules/cf/cfsupport.py
index af62b66..fb275c3 100644
--- a/Mac/Modules/cf/cfsupport.py
+++ b/Mac/Modules/cf/cfsupport.py
@@ -53,23 +53,58 @@ includestuff = includestuff + """
#include <CoreServices/CoreServices.h>
#endif
-/* For now we declare them forward here. They'll go to mactoolbox later */
-staticforward PyObject *CFTypeRefObj_New(CFTypeRef);
-staticforward int CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
-staticforward PyObject *CFStringRefObj_New(CFStringRef);
-staticforward int CFStringRefObj_Convert(PyObject *, CFStringRef *);
-staticforward PyObject *CFURLRefObj_New(CFURLRef);
-staticforward int CFURLRefObj_Convert(PyObject *, CFURLRef *);
-
-staticforward int CFURLRefObj_Convert(PyObject *, CFURLRef *);
-
-// ADD declarations
-#ifdef NOTYET_USE_TOOLBOX_OBJECT_GLUE
-//extern PyObject *_CFTypeRefObj_New(CFTypeRef);
-//extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
-
-//#define CFTypeRefObj_New _CFTypeRefObj_New
-//#define CFTypeRefObj_Convert _CFTypeRefObj_Convert
+#ifdef USE_TOOLBOX_OBJECT_GLUE
+extern PyObject *_CFTypeRefObj_New(CFTypeRef);
+extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
+#define CFTypeRefObj_New _CFTypeRefObj_New
+#define CFTypeRefObj_Convert _CFTypeRefObj_Convert
+
+extern PyObject *_CFStringRefObj_New(CFStringRef);
+extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *);
+#define CFStringRefObj_New _CFStringRefObj_New
+#define CFStringRefObj_Convert _CFStringRefObj_Convert
+
+extern PyObject *_CFMutableStringRefObj_New(CFMutableStringRef);
+extern int _CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *);
+#define CFMutableStringRefObj_New _CFMutableStringRefObj_New
+#define CFMutableStringRefObj_Convert _CFMutableStringRefObj_Convert
+
+extern PyObject *_CFArrayRefObj_New(CFArrayRef);
+extern int _CFArrayRefObj_Convert(PyObject *, CFArrayRef *);
+#define CFArrayRefObj_New _CFArrayRefObj_New
+#define CFArrayRefObj_Convert _CFArrayRefObj_Convert
+
+extern PyObject *_CFMutableArrayRefObj_New(CFMutableArrayRef);
+extern int _CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *);
+#define CFMutableArrayRefObj_New _CFMutableArrayRefObj_New
+#define CFMutableArrayRefObj_Convert _CFMutableArrayRefObj_Convert
+
+extern PyObject *_CFDataRefObj_New(CFDataRef);
+extern int _CFDataRefObj_Convert(PyObject *, CFDataRef *);
+#define CFDataRefObj_New _CFDataRefObj_New
+#define CFDataRefObj_Convert _CFDataRefObj_Convert
+
+extern PyObject *_CFMutableDataRefObj_New(CFMutableDataRef);
+extern int _CFMutableDataRefObj_Convert(PyObject *, CFMutableDataRef *);
+#define CFMutableDataRefObj_New _CFMutableDataRefObj_New
+#define CFMutableDataRefObj_Convert _CFMutableDataRefObj_Convert
+
+extern PyObject *_CFDictionaryRefObj_New(CFDictionaryRef);
+extern int _CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *);
+#define CFDictionaryRefObj_New _CFDictionaryRefObj_New
+#define CFDictionaryRefObj_Convert _CFDictionaryRefObj_Convert
+
+extern PyObject *_CFMutableDictionaryRefObj_New(CFMutableDictionaryRef);
+extern int _CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *);
+#define CFMutableDictionaryRefObj_New _CFMutableDictionaryRefObj_New
+#define CFMutableDictionaryRefObj_Convert _CFMutableDictionaryRefObj_Convert
+
+extern PyObject *_CFURLRefObj_New(CFURLRef);
+extern int _CFURLRefObj_Convert(PyObject *, CFURLRef *);
+extern int _OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *);
+#define CFURLRefObj_New _CFURLRefObj_New
+#define CFURLRefObj_Convert _CFURLRefObj_Convert
+#define OptionalCFURLRefObj_Convert _OptionalCFURLRefObj_Convert
#endif
/*
@@ -107,8 +142,24 @@ OptionalCFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself)
"""
initstuff = initstuff + """
-// PyMac_INIT_TOOLBOX_OBJECT_NEW(Track, TrackObj_New);
-// PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Track, TrackObj_Convert);
+PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef, CFTypeRefObj_New);
+PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef, CFTypeRefObj_Convert);
+PyMac_INIT_TOOLBOX_OBJECT_NEW(CFStringRef, CFStringRefObj_New);
+PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFStringRef, CFStringRefObj_Convert);
+PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableStringRef, CFMutableStringRefObj_New);
+PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableStringRef, CFMutableStringRefObj_Convert);
+
+PyMac_INIT_TOOLBOX_OBJECT_NEW(CFArrayRef, CFArrayRefObj_New);
+PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFArrayRef, CFArrayRefObj_Convert);
+PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableArrayRef, CFMutableArrayRefObj_New);
+PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableArrayRef, CFMutableArrayRefObj_Convert);
+PyMac_INIT_TOOLBOX_OBJECT_NEW(CFDictionaryRef, CFDictionaryRefObj_New);
+PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFDictionaryRef, CFDictionaryRefObj_Convert);
+PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableDictionaryRef, CFMutableDictionaryRefObj_New);
+PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableDictionaryRef, CFMutableDictionaryRefObj_Convert);
+PyMac_INIT_TOOLBOX_OBJECT_NEW(CFURLRef, CFURLRefObj_New);
+PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef, CFURLRefObj_Convert);
+PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef, CFURLRefObj_Convert);
"""
Boolean = Type("Boolean", "l")
diff --git a/Python/mactoolboxglue.c b/Python/mactoolboxglue.c
index ef59900..ea21b4e 100644
--- a/Python/mactoolboxglue.c
+++ b/Python/mactoolboxglue.c
@@ -459,4 +459,26 @@ GLUE_NEW(WindowPtr, WinObj_New, "Carbon.Win")
GLUE_CONVERT(WindowPtr, WinObj_Convert, "Carbon.Win")
GLUE_NEW(WindowPtr, WinObj_WhichWindow, "Carbon.Win")
+GLUE_CONVERT(CFTypeRef, CFTypeRefObj_Convert, "Carbon.CF")
+GLUE_NEW(CFTypeRef, CFTypeRefObj_New, "Carbon.CF")
+
+GLUE_CONVERT(CFStringRef, CFStringRefObj_Convert, "Carbon.CF")
+GLUE_NEW(CFStringRef, CFStringRefObj_New, "Carbon.CF")
+GLUE_CONVERT(CFMutableStringRef, CFMutableStringRefObj_Convert, "Carbon.CF")
+GLUE_NEW(CFMutableStringRef, CFMutableStringRefObj_New, "Carbon.CF")
+
+GLUE_CONVERT(CFArrayRef, CFArrayRefObj_Convert, "Carbon.CF")
+GLUE_NEW(CFArrayRef, CFArrayRefObj_New, "Carbon.CF")
+GLUE_CONVERT(CFMutableArrayRef, CFMutableArrayRefObj_Convert, "Carbon.CF")
+GLUE_NEW(CFMutableArrayRef, CFMutableArrayRefObj_New, "Carbon.CF")
+
+GLUE_CONVERT(CFDictionaryRef, CFDictionaryRefObj_Convert, "Carbon.CF")
+GLUE_NEW(CFDictionaryRef, CFDictionaryRefObj_New, "Carbon.CF")
+GLUE_CONVERT(CFMutableDictionaryRef, CFMutableDictionaryRefObj_Convert, "Carbon.CF")
+GLUE_NEW(CFMutableDictionaryRef, CFMutableDictionaryRefObj_New, "Carbon.CF")
+
+GLUE_CONVERT(CFURLRef, CFURLRefObj_Convert, "Carbon.CF")
+GLUE_CONVERT(CFURLRef, OptionalCFURLRefObj_Convert, "Carbon.CF")
+GLUE_NEW(CFURLRef, CFURLRefObj_New, "Carbon.CF")
+
#endif /* USE_TOOLBOX_OBJECT_GLUE */ \ No newline at end of file