Commit c90acb95 authored by unknown's avatar unknown

Do conversion of CFStrings to/from unicode.

parent d1054ef3
...@@ -8,6 +8,14 @@ ...@@ -8,6 +8,14 @@
#include "macglue.h" #include "macglue.h"
#include "pymactoolbox.h" #include "pymactoolbox.h"
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
PyErr_SetString(PyExc_NotImplementedError, \
"Not available in this shared library/OS version"); \
return NULL; \
}} while(0)
#ifdef WITHOUT_FRAMEWORKS #ifdef WITHOUT_FRAMEWORKS
#include <CoreFoundation.h> #include <CoreFoundation.h>
#else #else
...@@ -81,7 +89,6 @@ PyObject *CFTypeRefObj_New(CFTypeRef itself) ...@@ -81,7 +89,6 @@ PyObject *CFTypeRefObj_New(CFTypeRef itself)
{ {
CFTypeRefObject *it; CFTypeRefObject *it;
if (itself == NULL) return PyMac_Error(resNotFound); if (itself == NULL) return PyMac_Error(resNotFound);
CFRetain(itself);
it = PyObject_NEW(CFTypeRefObject, &CFTypeRef_Type); it = PyObject_NEW(CFTypeRefObject, &CFTypeRef_Type);
if (it == NULL) return NULL; if (it == NULL) return NULL;
it->ob_itself = itself; it->ob_itself = itself;
...@@ -116,6 +123,7 @@ static PyObject *CFTypeRefObj_CFGetTypeID(CFTypeRefObject *_self, PyObject *_arg ...@@ -116,6 +123,7 @@ static PyObject *CFTypeRefObj_CFGetTypeID(CFTypeRefObject *_self, PyObject *_arg
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFTypeID _rv; CFTypeID _rv;
PyMac_PRECHECK(CFGetTypeID);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFGetTypeID(_self->ob_itself); _rv = CFGetTypeID(_self->ob_itself);
...@@ -128,6 +136,7 @@ static PyObject *CFTypeRefObj_CFRetain(CFTypeRefObject *_self, PyObject *_args) ...@@ -128,6 +136,7 @@ static PyObject *CFTypeRefObj_CFRetain(CFTypeRefObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFTypeRef _rv; CFTypeRef _rv;
PyMac_PRECHECK(CFRetain);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFRetain(_self->ob_itself); _rv = CFRetain(_self->ob_itself);
...@@ -139,6 +148,7 @@ static PyObject *CFTypeRefObj_CFRetain(CFTypeRefObject *_self, PyObject *_args) ...@@ -139,6 +148,7 @@ static PyObject *CFTypeRefObj_CFRetain(CFTypeRefObject *_self, PyObject *_args)
static PyObject *CFTypeRefObj_CFRelease(CFTypeRefObject *_self, PyObject *_args) static PyObject *CFTypeRefObj_CFRelease(CFTypeRefObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
PyMac_PRECHECK(CFRelease);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
CFRelease(_self->ob_itself); CFRelease(_self->ob_itself);
...@@ -151,6 +161,7 @@ static PyObject *CFTypeRefObj_CFGetRetainCount(CFTypeRefObject *_self, PyObject ...@@ -151,6 +161,7 @@ static PyObject *CFTypeRefObj_CFGetRetainCount(CFTypeRefObject *_self, PyObject
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFIndex _rv; CFIndex _rv;
PyMac_PRECHECK(CFGetRetainCount);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFGetRetainCount(_self->ob_itself); _rv = CFGetRetainCount(_self->ob_itself);
...@@ -164,6 +175,7 @@ static PyObject *CFTypeRefObj_CFEqual(CFTypeRefObject *_self, PyObject *_args) ...@@ -164,6 +175,7 @@ static PyObject *CFTypeRefObj_CFEqual(CFTypeRefObject *_self, PyObject *_args)
PyObject *_res = NULL; PyObject *_res = NULL;
Boolean _rv; Boolean _rv;
CFTypeRef cf2; CFTypeRef cf2;
PyMac_PRECHECK(CFEqual);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFTypeRefObj_Convert, &cf2)) CFTypeRefObj_Convert, &cf2))
return NULL; return NULL;
...@@ -178,6 +190,7 @@ static PyObject *CFTypeRefObj_CFHash(CFTypeRefObject *_self, PyObject *_args) ...@@ -178,6 +190,7 @@ static PyObject *CFTypeRefObj_CFHash(CFTypeRefObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFHashCode _rv; CFHashCode _rv;
PyMac_PRECHECK(CFHash);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFHash(_self->ob_itself); _rv = CFHash(_self->ob_itself);
...@@ -190,6 +203,7 @@ static PyObject *CFTypeRefObj_CFCopyDescription(CFTypeRefObject *_self, PyObject ...@@ -190,6 +203,7 @@ static PyObject *CFTypeRefObj_CFCopyDescription(CFTypeRefObject *_self, PyObject
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
PyMac_PRECHECK(CFCopyDescription);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFCopyDescription(_self->ob_itself); _rv = CFCopyDescription(_self->ob_itself);
...@@ -201,6 +215,7 @@ static PyObject *CFTypeRefObj_CFCopyDescription(CFTypeRefObject *_self, PyObject ...@@ -201,6 +215,7 @@ static PyObject *CFTypeRefObj_CFCopyDescription(CFTypeRefObject *_self, PyObject
static PyObject *CFTypeRefObj_CFShow(CFTypeRefObject *_self, PyObject *_args) static PyObject *CFTypeRefObj_CFShow(CFTypeRefObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
PyMac_PRECHECK(CFShow);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
CFShow(_self->ob_itself); CFShow(_self->ob_itself);
...@@ -297,7 +312,6 @@ PyObject *CFArrayRefObj_New(CFArrayRef itself) ...@@ -297,7 +312,6 @@ PyObject *CFArrayRefObj_New(CFArrayRef itself)
{ {
CFArrayRefObject *it; CFArrayRefObject *it;
if (itself == NULL) return PyMac_Error(resNotFound); if (itself == NULL) return PyMac_Error(resNotFound);
CFRetain(itself);
it = PyObject_NEW(CFArrayRefObject, &CFArrayRef_Type); it = PyObject_NEW(CFArrayRefObject, &CFArrayRef_Type);
if (it == NULL) return NULL; if (it == NULL) return NULL;
it->ob_itself = itself; it->ob_itself = itself;
...@@ -332,6 +346,7 @@ static PyObject *CFArrayRefObj_CFArrayGetCount(CFArrayRefObject *_self, PyObject ...@@ -332,6 +346,7 @@ static PyObject *CFArrayRefObj_CFArrayGetCount(CFArrayRefObject *_self, PyObject
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFIndex _rv; CFIndex _rv;
PyMac_PRECHECK(CFArrayGetCount);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFArrayGetCount(_self->ob_itself); _rv = CFArrayGetCount(_self->ob_itself);
...@@ -366,7 +381,7 @@ static int CFArrayRefObj_compare(CFArrayRefObject *self, CFArrayRefObject *other ...@@ -366,7 +381,7 @@ static int CFArrayRefObj_compare(CFArrayRefObject *self, CFArrayRefObject *other
static PyObject * CFArrayRefObj_repr(CFArrayRefObject *self) static PyObject * CFArrayRefObj_repr(CFArrayRefObject *self)
{ {
char buf[100]; char buf[100];
sprintf(buf, "<CFArrayRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself); sprintf(buf, "<CFArrayRef object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
return PyString_FromString(buf); return PyString_FromString(buf);
} }
...@@ -414,7 +429,6 @@ PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef itself) ...@@ -414,7 +429,6 @@ PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef itself)
{ {
CFMutableArrayRefObject *it; CFMutableArrayRefObject *it;
if (itself == NULL) return PyMac_Error(resNotFound); if (itself == NULL) return PyMac_Error(resNotFound);
CFRetain(itself);
it = PyObject_NEW(CFMutableArrayRefObject, &CFMutableArrayRef_Type); it = PyObject_NEW(CFMutableArrayRefObject, &CFMutableArrayRef_Type);
if (it == NULL) return NULL; if (it == NULL) return NULL;
it->ob_itself = itself; it->ob_itself = itself;
...@@ -449,6 +463,7 @@ static PyObject *CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRe ...@@ -449,6 +463,7 @@ static PyObject *CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRe
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFIndex idx; CFIndex idx;
PyMac_PRECHECK(CFArrayRemoveValueAtIndex);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&idx)) &idx))
return NULL; return NULL;
...@@ -462,6 +477,7 @@ static PyObject *CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRe ...@@ -462,6 +477,7 @@ static PyObject *CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRe
static PyObject *CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject *_self, PyObject *_args) static PyObject *CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
PyMac_PRECHECK(CFArrayRemoveAllValues);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
CFArrayRemoveAllValues(_self->ob_itself); CFArrayRemoveAllValues(_self->ob_itself);
...@@ -475,6 +491,7 @@ static PyObject *CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableAr ...@@ -475,6 +491,7 @@ static PyObject *CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableAr
PyObject *_res = NULL; PyObject *_res = NULL;
CFIndex idx1; CFIndex idx1;
CFIndex idx2; CFIndex idx2;
PyMac_PRECHECK(CFArrayExchangeValuesAtIndices);
if (!PyArg_ParseTuple(_args, "ll", if (!PyArg_ParseTuple(_args, "ll",
&idx1, &idx1,
&idx2)) &idx2))
...@@ -517,7 +534,7 @@ static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject *self, CFMutable ...@@ -517,7 +534,7 @@ static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject *self, CFMutable
static PyObject * CFMutableArrayRefObj_repr(CFMutableArrayRefObject *self) static PyObject * CFMutableArrayRefObj_repr(CFMutableArrayRefObject *self)
{ {
char buf[100]; char buf[100];
sprintf(buf, "<CFMutableArrayRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself); sprintf(buf, "<CFMutableArrayRef object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
return PyString_FromString(buf); return PyString_FromString(buf);
} }
...@@ -565,7 +582,6 @@ PyObject *CFDictionaryRefObj_New(CFDictionaryRef itself) ...@@ -565,7 +582,6 @@ PyObject *CFDictionaryRefObj_New(CFDictionaryRef itself)
{ {
CFDictionaryRefObject *it; CFDictionaryRefObject *it;
if (itself == NULL) return PyMac_Error(resNotFound); if (itself == NULL) return PyMac_Error(resNotFound);
CFRetain(itself);
it = PyObject_NEW(CFDictionaryRefObject, &CFDictionaryRef_Type); it = PyObject_NEW(CFDictionaryRefObject, &CFDictionaryRef_Type);
if (it == NULL) return NULL; if (it == NULL) return NULL;
it->ob_itself = itself; it->ob_itself = itself;
...@@ -600,6 +616,7 @@ static PyObject *CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject * ...@@ -600,6 +616,7 @@ static PyObject *CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject *
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFIndex _rv; CFIndex _rv;
PyMac_PRECHECK(CFDictionaryGetCount);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFDictionaryGetCount(_self->ob_itself); _rv = CFDictionaryGetCount(_self->ob_itself);
...@@ -634,7 +651,7 @@ static int CFDictionaryRefObj_compare(CFDictionaryRefObject *self, CFDictionaryR ...@@ -634,7 +651,7 @@ static int CFDictionaryRefObj_compare(CFDictionaryRefObject *self, CFDictionaryR
static PyObject * CFDictionaryRefObj_repr(CFDictionaryRefObject *self) static PyObject * CFDictionaryRefObj_repr(CFDictionaryRefObject *self)
{ {
char buf[100]; char buf[100];
sprintf(buf, "<CFDictionaryRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself); sprintf(buf, "<CFDictionaryRef object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
return PyString_FromString(buf); return PyString_FromString(buf);
} }
...@@ -682,7 +699,6 @@ PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself) ...@@ -682,7 +699,6 @@ PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself)
{ {
CFMutableDictionaryRefObject *it; CFMutableDictionaryRefObject *it;
if (itself == NULL) return PyMac_Error(resNotFound); if (itself == NULL) return PyMac_Error(resNotFound);
CFRetain(itself);
it = PyObject_NEW(CFMutableDictionaryRefObject, &CFMutableDictionaryRef_Type); it = PyObject_NEW(CFMutableDictionaryRefObject, &CFMutableDictionaryRef_Type);
if (it == NULL) return NULL; if (it == NULL) return NULL;
it->ob_itself = itself; it->ob_itself = itself;
...@@ -716,6 +732,7 @@ static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject *self ...@@ -716,6 +732,7 @@ static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject *self
static PyObject *CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject *_self, PyObject *_args) static PyObject *CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
PyMac_PRECHECK(CFDictionaryRemoveAllValues);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
CFDictionaryRemoveAllValues(_self->ob_itself); CFDictionaryRemoveAllValues(_self->ob_itself);
...@@ -750,7 +767,7 @@ static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject *self, ...@@ -750,7 +767,7 @@ static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject *self,
static PyObject * CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject *self) static PyObject * CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject *self)
{ {
char buf[100]; char buf[100];
sprintf(buf, "<CFMutableDictionaryRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself); sprintf(buf, "<CFMutableDictionaryRef object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
return PyString_FromString(buf); return PyString_FromString(buf);
} }
...@@ -798,7 +815,6 @@ PyObject *CFDataRefObj_New(CFDataRef itself) ...@@ -798,7 +815,6 @@ PyObject *CFDataRefObj_New(CFDataRef itself)
{ {
CFDataRefObject *it; CFDataRefObject *it;
if (itself == NULL) return PyMac_Error(resNotFound); if (itself == NULL) return PyMac_Error(resNotFound);
CFRetain(itself);
it = PyObject_NEW(CFDataRefObject, &CFDataRef_Type); it = PyObject_NEW(CFDataRefObject, &CFDataRef_Type);
if (it == NULL) return NULL; if (it == NULL) return NULL;
it->ob_itself = itself; it->ob_itself = itself;
...@@ -833,6 +849,7 @@ static PyObject *CFDataRefObj_CFDataGetLength(CFDataRefObject *_self, PyObject * ...@@ -833,6 +849,7 @@ static PyObject *CFDataRefObj_CFDataGetLength(CFDataRefObject *_self, PyObject *
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFIndex _rv; CFIndex _rv;
PyMac_PRECHECK(CFDataGetLength);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFDataGetLength(_self->ob_itself); _rv = CFDataGetLength(_self->ob_itself);
...@@ -867,7 +884,7 @@ static int CFDataRefObj_compare(CFDataRefObject *self, CFDataRefObject *other) ...@@ -867,7 +884,7 @@ static int CFDataRefObj_compare(CFDataRefObject *self, CFDataRefObject *other)
static PyObject * CFDataRefObj_repr(CFDataRefObject *self) static PyObject * CFDataRefObj_repr(CFDataRefObject *self)
{ {
char buf[100]; char buf[100];
sprintf(buf, "<CFDataRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself); sprintf(buf, "<CFDataRef object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
return PyString_FromString(buf); return PyString_FromString(buf);
} }
...@@ -915,7 +932,6 @@ PyObject *CFMutableDataRefObj_New(CFMutableDataRef itself) ...@@ -915,7 +932,6 @@ PyObject *CFMutableDataRefObj_New(CFMutableDataRef itself)
{ {
CFMutableDataRefObject *it; CFMutableDataRefObject *it;
if (itself == NULL) return PyMac_Error(resNotFound); if (itself == NULL) return PyMac_Error(resNotFound);
CFRetain(itself);
it = PyObject_NEW(CFMutableDataRefObject, &CFMutableDataRef_Type); it = PyObject_NEW(CFMutableDataRefObject, &CFMutableDataRef_Type);
if (it == NULL) return NULL; if (it == NULL) return NULL;
it->ob_itself = itself; it->ob_itself = itself;
...@@ -950,6 +966,7 @@ static PyObject *CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject *_se ...@@ -950,6 +966,7 @@ static PyObject *CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject *_se
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFIndex length; CFIndex length;
PyMac_PRECHECK(CFDataSetLength);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&length)) &length))
return NULL; return NULL;
...@@ -964,6 +981,7 @@ static PyObject *CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject ...@@ -964,6 +981,7 @@ static PyObject *CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFIndex extraLength; CFIndex extraLength;
PyMac_PRECHECK(CFDataIncreaseLength);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&extraLength)) &extraLength))
return NULL; return NULL;
...@@ -980,6 +998,7 @@ static PyObject *CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject *_ ...@@ -980,6 +998,7 @@ static PyObject *CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject *_
unsigned char *bytes__in__; unsigned char *bytes__in__;
long bytes__len__; long bytes__len__;
int bytes__in_len__; int bytes__in_len__;
PyMac_PRECHECK(CFDataAppendBytes);
if (!PyArg_ParseTuple(_args, "s#", if (!PyArg_ParseTuple(_args, "s#",
&bytes__in__, &bytes__in_len__)) &bytes__in__, &bytes__in_len__))
return NULL; return NULL;
...@@ -999,6 +1018,7 @@ static PyObject *CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject * ...@@ -999,6 +1018,7 @@ static PyObject *CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject *
unsigned char *newBytes__in__; unsigned char *newBytes__in__;
long newBytes__len__; long newBytes__len__;
int newBytes__in_len__; int newBytes__in_len__;
PyMac_PRECHECK(CFDataReplaceBytes);
if (!PyArg_ParseTuple(_args, "O&s#", if (!PyArg_ParseTuple(_args, "O&s#",
CFRange_Convert, &range, CFRange_Convert, &range,
&newBytes__in__, &newBytes__in_len__)) &newBytes__in__, &newBytes__in_len__))
...@@ -1017,6 +1037,7 @@ static PyObject *CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject *_ ...@@ -1017,6 +1037,7 @@ static PyObject *CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject *_
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFRange range; CFRange range;
PyMac_PRECHECK(CFDataDeleteBytes);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFRange_Convert, &range)) CFRange_Convert, &range))
return NULL; return NULL;
...@@ -1061,7 +1082,7 @@ static int CFMutableDataRefObj_compare(CFMutableDataRefObject *self, CFMutableDa ...@@ -1061,7 +1082,7 @@ static int CFMutableDataRefObj_compare(CFMutableDataRefObject *self, CFMutableDa
static PyObject * CFMutableDataRefObj_repr(CFMutableDataRefObject *self) static PyObject * CFMutableDataRefObj_repr(CFMutableDataRefObject *self)
{ {
char buf[100]; char buf[100];
sprintf(buf, "<CFMutableDataRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself); sprintf(buf, "<CFMutableDataRef object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
return PyString_FromString(buf); return PyString_FromString(buf);
} }
...@@ -1109,7 +1130,6 @@ PyObject *CFStringRefObj_New(CFStringRef itself) ...@@ -1109,7 +1130,6 @@ PyObject *CFStringRefObj_New(CFStringRef itself)
{ {
CFStringRefObject *it; CFStringRefObject *it;
if (itself == NULL) return PyMac_Error(resNotFound); if (itself == NULL) return PyMac_Error(resNotFound);
CFRetain(itself);
it = PyObject_NEW(CFStringRefObject, &CFStringRef_Type); it = PyObject_NEW(CFStringRefObject, &CFStringRef_Type);
if (it == NULL) return NULL; if (it == NULL) return NULL;
it->ob_itself = itself; it->ob_itself = itself;
...@@ -1120,7 +1140,20 @@ CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself) ...@@ -1120,7 +1140,20 @@ CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself)
{ {
if (v == Py_None) { *p_itself = NULL; return 1; } if (v == Py_None) { *p_itself = NULL; return 1; }
/* Check for other CF objects here */ if (PyString_Check(v)) {
char *cStr = PyString_AsString(v);
*p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, 0);
return 1;
}
if (PyUnicode_Check(v)) {
/* We use the CF types here, if Python was configured differently that will give an error */
CFIndex size = PyUnicode_GetSize(v);
UniChar *unichars = PyUnicode_AsUnicode(v);
if (!unichars) return 0;
*p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size);
return 1;
}
if (!CFStringRefObj_Check(v)) if (!CFStringRefObj_Check(v))
{ {
...@@ -1144,6 +1177,7 @@ static PyObject *CFStringRefObj_CFStringGetLength(CFStringRefObject *_self, PyOb ...@@ -1144,6 +1177,7 @@ static PyObject *CFStringRefObj_CFStringGetLength(CFStringRefObject *_self, PyOb
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFIndex _rv; CFIndex _rv;
PyMac_PRECHECK(CFStringGetLength);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFStringGetLength(_self->ob_itself); _rv = CFStringGetLength(_self->ob_itself);
...@@ -1152,27 +1186,6 @@ static PyObject *CFStringRefObj_CFStringGetLength(CFStringRefObject *_self, PyOb ...@@ -1152,27 +1186,6 @@ static PyObject *CFStringRefObj_CFStringGetLength(CFStringRefObject *_self, PyOb
return _res; return _res;
} }
static PyObject *CFStringRefObj_CFStringGetCString(CFStringRefObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
Boolean _rv;
char buffer;
CFIndex bufferSize;
CFStringEncoding encoding;
if (!PyArg_ParseTuple(_args, "ll",
&bufferSize,
&encoding))
return NULL;
_rv = CFStringGetCString(_self->ob_itself,
&buffer,
bufferSize,
encoding);
_res = Py_BuildValue("lc",
_rv,
buffer);
return _res;
}
static PyObject *CFStringRefObj_CFStringGetBytes(CFStringRefObject *_self, PyObject *_args) static PyObject *CFStringRefObj_CFStringGetBytes(CFStringRefObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
...@@ -1184,6 +1197,7 @@ static PyObject *CFStringRefObj_CFStringGetBytes(CFStringRefObject *_self, PyObj ...@@ -1184,6 +1197,7 @@ static PyObject *CFStringRefObj_CFStringGetBytes(CFStringRefObject *_self, PyObj
UInt8 buffer; UInt8 buffer;
CFIndex maxBufLen; CFIndex maxBufLen;
CFIndex usedBufLen; CFIndex usedBufLen;
PyMac_PRECHECK(CFStringGetBytes);
if (!PyArg_ParseTuple(_args, "O&lbll", if (!PyArg_ParseTuple(_args, "O&lbll",
CFRange_Convert, &range, CFRange_Convert, &range,
&encoding, &encoding,
...@@ -1210,6 +1224,7 @@ static PyObject *CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject *_ ...@@ -1210,6 +1224,7 @@ static PyObject *CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject *_
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringEncoding _rv; CFStringEncoding _rv;
PyMac_PRECHECK(CFStringGetSmallestEncoding);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFStringGetSmallestEncoding(_self->ob_itself); _rv = CFStringGetSmallestEncoding(_self->ob_itself);
...@@ -1222,6 +1237,7 @@ static PyObject *CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject *_s ...@@ -1222,6 +1237,7 @@ static PyObject *CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject *_s
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringEncoding _rv; CFStringEncoding _rv;
PyMac_PRECHECK(CFStringGetFastestEncoding);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFStringGetFastestEncoding(_self->ob_itself); _rv = CFStringGetFastestEncoding(_self->ob_itself);
...@@ -1237,6 +1253,7 @@ static PyObject *CFStringRefObj_CFStringCompareWithOptions(CFStringRefObject *_s ...@@ -1237,6 +1253,7 @@ static PyObject *CFStringRefObj_CFStringCompareWithOptions(CFStringRefObject *_s
CFStringRef string2; CFStringRef string2;
CFRange rangeToCompare; CFRange rangeToCompare;
CFOptionFlags compareOptions; CFOptionFlags compareOptions;
PyMac_PRECHECK(CFStringCompareWithOptions);
if (!PyArg_ParseTuple(_args, "O&O&l", if (!PyArg_ParseTuple(_args, "O&O&l",
CFStringRefObj_Convert, &string2, CFStringRefObj_Convert, &string2,
CFRange_Convert, &rangeToCompare, CFRange_Convert, &rangeToCompare,
...@@ -1257,6 +1274,7 @@ static PyObject *CFStringRefObj_CFStringCompare(CFStringRefObject *_self, PyObje ...@@ -1257,6 +1274,7 @@ static PyObject *CFStringRefObj_CFStringCompare(CFStringRefObject *_self, PyObje
CFComparisonResult _rv; CFComparisonResult _rv;
CFStringRef string2; CFStringRef string2;
CFOptionFlags compareOptions; CFOptionFlags compareOptions;
PyMac_PRECHECK(CFStringCompare);
if (!PyArg_ParseTuple(_args, "O&l", if (!PyArg_ParseTuple(_args, "O&l",
CFStringRefObj_Convert, &string2, CFStringRefObj_Convert, &string2,
&compareOptions)) &compareOptions))
...@@ -1277,6 +1295,7 @@ static PyObject *CFStringRefObj_CFStringFindWithOptions(CFStringRefObject *_self ...@@ -1277,6 +1295,7 @@ static PyObject *CFStringRefObj_CFStringFindWithOptions(CFStringRefObject *_self
CFRange rangeToSearch; CFRange rangeToSearch;
CFOptionFlags searchOptions; CFOptionFlags searchOptions;
CFRange result; CFRange result;
PyMac_PRECHECK(CFStringFindWithOptions);
if (!PyArg_ParseTuple(_args, "O&O&l", if (!PyArg_ParseTuple(_args, "O&O&l",
CFStringRefObj_Convert, &stringToFind, CFStringRefObj_Convert, &stringToFind,
CFRange_Convert, &rangeToSearch, CFRange_Convert, &rangeToSearch,
...@@ -1299,6 +1318,7 @@ static PyObject *CFStringRefObj_CFStringFind(CFStringRefObject *_self, PyObject ...@@ -1299,6 +1318,7 @@ static PyObject *CFStringRefObj_CFStringFind(CFStringRefObject *_self, PyObject
CFRange _rv; CFRange _rv;
CFStringRef stringToFind; CFStringRef stringToFind;
CFOptionFlags compareOptions; CFOptionFlags compareOptions;
PyMac_PRECHECK(CFStringFind);
if (!PyArg_ParseTuple(_args, "O&l", if (!PyArg_ParseTuple(_args, "O&l",
CFStringRefObj_Convert, &stringToFind, CFStringRefObj_Convert, &stringToFind,
&compareOptions)) &compareOptions))
...@@ -1316,6 +1336,7 @@ static PyObject *CFStringRefObj_CFStringHasPrefix(CFStringRefObject *_self, PyOb ...@@ -1316,6 +1336,7 @@ static PyObject *CFStringRefObj_CFStringHasPrefix(CFStringRefObject *_self, PyOb
PyObject *_res = NULL; PyObject *_res = NULL;
Boolean _rv; Boolean _rv;
CFStringRef prefix; CFStringRef prefix;
PyMac_PRECHECK(CFStringHasPrefix);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFStringRefObj_Convert, &prefix)) CFStringRefObj_Convert, &prefix))
return NULL; return NULL;
...@@ -1331,6 +1352,7 @@ static PyObject *CFStringRefObj_CFStringHasSuffix(CFStringRefObject *_self, PyOb ...@@ -1331,6 +1352,7 @@ static PyObject *CFStringRefObj_CFStringHasSuffix(CFStringRefObject *_self, PyOb
PyObject *_res = NULL; PyObject *_res = NULL;
Boolean _rv; Boolean _rv;
CFStringRef suffix; CFStringRef suffix;
PyMac_PRECHECK(CFStringHasSuffix);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFStringRefObj_Convert, &suffix)) CFStringRefObj_Convert, &suffix))
return NULL; return NULL;
...@@ -1348,6 +1370,7 @@ static PyObject *CFStringRefObj_CFStringGetLineBounds(CFStringRefObject *_self, ...@@ -1348,6 +1370,7 @@ static PyObject *CFStringRefObj_CFStringGetLineBounds(CFStringRefObject *_self,
CFIndex lineBeginIndex; CFIndex lineBeginIndex;
CFIndex lineEndIndex; CFIndex lineEndIndex;
CFIndex contentsEndIndex; CFIndex contentsEndIndex;
PyMac_PRECHECK(CFStringGetLineBounds);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFRange_Convert, &range)) CFRange_Convert, &range))
return NULL; return NULL;
...@@ -1367,6 +1390,7 @@ static PyObject *CFStringRefObj_CFStringGetIntValue(CFStringRefObject *_self, Py ...@@ -1367,6 +1390,7 @@ static PyObject *CFStringRefObj_CFStringGetIntValue(CFStringRefObject *_self, Py
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
SInt32 _rv; SInt32 _rv;
PyMac_PRECHECK(CFStringGetIntValue);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFStringGetIntValue(_self->ob_itself); _rv = CFStringGetIntValue(_self->ob_itself);
...@@ -1379,6 +1403,7 @@ static PyObject *CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject *_self, ...@@ -1379,6 +1403,7 @@ static PyObject *CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject *_self,
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
double _rv; double _rv;
PyMac_PRECHECK(CFStringGetDoubleValue);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFStringGetDoubleValue(_self->ob_itself); _rv = CFStringGetDoubleValue(_self->ob_itself);
...@@ -1391,6 +1416,7 @@ static PyObject *CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStrin ...@@ -1391,6 +1416,7 @@ static PyObject *CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStrin
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringEncoding _rv; CFStringEncoding _rv;
PyMac_PRECHECK(CFStringConvertIANACharSetNameToEncoding);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFStringConvertIANACharSetNameToEncoding(_self->ob_itself); _rv = CFStringConvertIANACharSetNameToEncoding(_self->ob_itself);
...@@ -1402,6 +1428,7 @@ static PyObject *CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStrin ...@@ -1402,6 +1428,7 @@ static PyObject *CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStrin
static PyObject *CFStringRefObj_CFShowStr(CFStringRefObject *_self, PyObject *_args) static PyObject *CFStringRefObj_CFShowStr(CFStringRefObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
PyMac_PRECHECK(CFShowStr);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
CFShowStr(_self->ob_itself); CFShowStr(_self->ob_itself);
...@@ -1410,11 +1437,46 @@ static PyObject *CFStringRefObj_CFShowStr(CFStringRefObject *_self, PyObject *_a ...@@ -1410,11 +1437,46 @@ static PyObject *CFStringRefObj_CFShowStr(CFStringRefObject *_self, PyObject *_a
return _res; return _res;
} }
static PyObject *CFStringRefObj_CFStringGetString(CFStringRefObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
int size = CFStringGetLength(_self->ob_itself)+1;
char *data = malloc(size);
if( data == NULL ) return PyErr_NoMemory();
if ( CFStringGetCString(_self->ob_itself, data, size, 0) ) {
_res = (PyObject *)PyString_FromString(data);
} else {
PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string");
_res = NULL;
}
free(data);
return _res;
}
static PyObject *CFStringRefObj_CFStringGetUnicode(CFStringRefObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
int size = CFStringGetLength(_self->ob_itself)+1;
Py_UNICODE *data = malloc(size*sizeof(Py_UNICODE));
CFRange range;
range.location = 0;
range.length = size;
if( data == NULL ) return PyErr_NoMemory();
CFStringGetCharacters(_self->ob_itself, range, data);
_res = (PyObject *)PyUnicode_FromUnicode(data, size);
free(data);
return _res;
}
static PyMethodDef CFStringRefObj_methods[] = { static PyMethodDef CFStringRefObj_methods[] = {
{"CFStringGetLength", (PyCFunction)CFStringRefObj_CFStringGetLength, 1, {"CFStringGetLength", (PyCFunction)CFStringRefObj_CFStringGetLength, 1,
"() -> (CFIndex _rv)"}, "() -> (CFIndex _rv)"},
{"CFStringGetCString", (PyCFunction)CFStringRefObj_CFStringGetCString, 1,
"(CFIndex bufferSize, CFStringEncoding encoding) -> (Boolean _rv, char buffer)"},
{"CFStringGetBytes", (PyCFunction)CFStringRefObj_CFStringGetBytes, 1, {"CFStringGetBytes", (PyCFunction)CFStringRefObj_CFStringGetBytes, 1,
"(CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, CFIndex maxBufLen) -> (CFIndex _rv, UInt8 buffer, CFIndex usedBufLen)"}, "(CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, CFIndex maxBufLen) -> (CFIndex _rv, UInt8 buffer, CFIndex usedBufLen)"},
{"CFStringGetSmallestEncoding", (PyCFunction)CFStringRefObj_CFStringGetSmallestEncoding, 1, {"CFStringGetSmallestEncoding", (PyCFunction)CFStringRefObj_CFStringGetSmallestEncoding, 1,
...@@ -1443,6 +1505,10 @@ static PyMethodDef CFStringRefObj_methods[] = { ...@@ -1443,6 +1505,10 @@ static PyMethodDef CFStringRefObj_methods[] = {
"() -> (CFStringEncoding _rv)"}, "() -> (CFStringEncoding _rv)"},
{"CFShowStr", (PyCFunction)CFStringRefObj_CFShowStr, 1, {"CFShowStr", (PyCFunction)CFStringRefObj_CFShowStr, 1,
"() -> None"}, "() -> None"},
{"CFStringGetString", (PyCFunction)CFStringRefObj_CFStringGetString, 1,
"() -> (string _rv)"},
{"CFStringGetUnicode", (PyCFunction)CFStringRefObj_CFStringGetUnicode, 1,
"() -> (unicode _rv)"},
{NULL, NULL, 0} {NULL, NULL, 0}
}; };
...@@ -1466,7 +1532,7 @@ static int CFStringRefObj_compare(CFStringRefObject *self, CFStringRefObject *ot ...@@ -1466,7 +1532,7 @@ static int CFStringRefObj_compare(CFStringRefObject *self, CFStringRefObject *ot
static PyObject * CFStringRefObj_repr(CFStringRefObject *self) static PyObject * CFStringRefObj_repr(CFStringRefObject *self)
{ {
char buf[100]; char buf[100];
sprintf(buf, "<CFStringRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself); sprintf(buf, "<CFStringRef object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
return PyString_FromString(buf); return PyString_FromString(buf);
} }
...@@ -1514,7 +1580,6 @@ PyObject *CFMutableStringRefObj_New(CFMutableStringRef itself) ...@@ -1514,7 +1580,6 @@ PyObject *CFMutableStringRefObj_New(CFMutableStringRef itself)
{ {
CFMutableStringRefObject *it; CFMutableStringRefObject *it;
if (itself == NULL) return PyMac_Error(resNotFound); if (itself == NULL) return PyMac_Error(resNotFound);
CFRetain(itself);
it = PyObject_NEW(CFMutableStringRefObject, &CFMutableStringRef_Type); it = PyObject_NEW(CFMutableStringRefObject, &CFMutableStringRef_Type);
if (it == NULL) return NULL; if (it == NULL) return NULL;
it->ob_itself = itself; it->ob_itself = itself;
...@@ -1549,6 +1614,7 @@ static PyObject *CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject * ...@@ -1549,6 +1614,7 @@ static PyObject *CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject *
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef appendedString; CFStringRef appendedString;
PyMac_PRECHECK(CFStringAppend);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFStringRefObj_Convert, &appendedString)) CFStringRefObj_Convert, &appendedString))
return NULL; return NULL;
...@@ -1564,6 +1630,7 @@ static PyObject *CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStrin ...@@ -1564,6 +1630,7 @@ static PyObject *CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStrin
PyObject *_res = NULL; PyObject *_res = NULL;
StringPtr pStr; StringPtr pStr;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringAppendPascalString);
if (!PyArg_ParseTuple(_args, "O&l", if (!PyArg_ParseTuple(_args, "O&l",
PyMac_GetStr255, &pStr, PyMac_GetStr255, &pStr,
&encoding)) &encoding))
...@@ -1581,6 +1648,7 @@ static PyObject *CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefO ...@@ -1581,6 +1648,7 @@ static PyObject *CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefO
PyObject *_res = NULL; PyObject *_res = NULL;
char* cStr; char* cStr;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringAppendCString);
if (!PyArg_ParseTuple(_args, "sl", if (!PyArg_ParseTuple(_args, "sl",
&cStr, &cStr,
&encoding)) &encoding))
...@@ -1598,6 +1666,7 @@ static PyObject *CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject * ...@@ -1598,6 +1666,7 @@ static PyObject *CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject *
PyObject *_res = NULL; PyObject *_res = NULL;
CFIndex idx; CFIndex idx;
CFStringRef insertedStr; CFStringRef insertedStr;
PyMac_PRECHECK(CFStringInsert);
if (!PyArg_ParseTuple(_args, "lO&", if (!PyArg_ParseTuple(_args, "lO&",
&idx, &idx,
CFStringRefObj_Convert, &insertedStr)) CFStringRefObj_Convert, &insertedStr))
...@@ -1614,6 +1683,7 @@ static PyObject *CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject * ...@@ -1614,6 +1683,7 @@ static PyObject *CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject *
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFRange range; CFRange range;
PyMac_PRECHECK(CFStringDelete);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFRange_Convert, &range)) CFRange_Convert, &range))
return NULL; return NULL;
...@@ -1629,6 +1699,7 @@ static PyObject *CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject ...@@ -1629,6 +1699,7 @@ static PyObject *CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject
PyObject *_res = NULL; PyObject *_res = NULL;
CFRange range; CFRange range;
CFStringRef replacement; CFStringRef replacement;
PyMac_PRECHECK(CFStringReplace);
if (!PyArg_ParseTuple(_args, "O&O&", if (!PyArg_ParseTuple(_args, "O&O&",
CFRange_Convert, &range, CFRange_Convert, &range,
CFStringRefObj_Convert, &replacement)) CFStringRefObj_Convert, &replacement))
...@@ -1645,6 +1716,7 @@ static PyObject *CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObje ...@@ -1645,6 +1716,7 @@ static PyObject *CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObje
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef replacement; CFStringRef replacement;
PyMac_PRECHECK(CFStringReplaceAll);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFStringRefObj_Convert, &replacement)) CFStringRefObj_Convert, &replacement))
return NULL; return NULL;
...@@ -1661,6 +1733,7 @@ static PyObject *CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject *_se ...@@ -1661,6 +1733,7 @@ static PyObject *CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject *_se
CFStringRef padString; CFStringRef padString;
CFIndex length; CFIndex length;
CFIndex indexIntoPad; CFIndex indexIntoPad;
PyMac_PRECHECK(CFStringPad);
if (!PyArg_ParseTuple(_args, "O&ll", if (!PyArg_ParseTuple(_args, "O&ll",
CFStringRefObj_Convert, &padString, CFStringRefObj_Convert, &padString,
&length, &length,
...@@ -1679,6 +1752,7 @@ static PyObject *CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject *_s ...@@ -1679,6 +1752,7 @@ static PyObject *CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject *_s
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef trimString; CFStringRef trimString;
PyMac_PRECHECK(CFStringTrim);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFStringRefObj_Convert, &trimString)) CFStringRefObj_Convert, &trimString))
return NULL; return NULL;
...@@ -1692,6 +1766,7 @@ static PyObject *CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject *_s ...@@ -1692,6 +1766,7 @@ static PyObject *CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject *_s
static PyObject *CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject *_self, PyObject *_args) static PyObject *CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
PyMac_PRECHECK(CFStringTrimWhitespace);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
CFStringTrimWhitespace(_self->ob_itself); CFStringTrimWhitespace(_self->ob_itself);
...@@ -1744,7 +1819,7 @@ static int CFMutableStringRefObj_compare(CFMutableStringRefObject *self, CFMutab ...@@ -1744,7 +1819,7 @@ static int CFMutableStringRefObj_compare(CFMutableStringRefObject *self, CFMutab
static PyObject * CFMutableStringRefObj_repr(CFMutableStringRefObject *self) static PyObject * CFMutableStringRefObj_repr(CFMutableStringRefObject *self)
{ {
char buf[100]; char buf[100];
sprintf(buf, "<CFMutableStringRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself); sprintf(buf, "<CFMutableStringRef object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
return PyString_FromString(buf); return PyString_FromString(buf);
} }
...@@ -1792,7 +1867,6 @@ PyObject *CFURLRefObj_New(CFURLRef itself) ...@@ -1792,7 +1867,6 @@ PyObject *CFURLRefObj_New(CFURLRef itself)
{ {
CFURLRefObject *it; CFURLRefObject *it;
if (itself == NULL) return PyMac_Error(resNotFound); if (itself == NULL) return PyMac_Error(resNotFound);
CFRetain(itself);
it = PyObject_NEW(CFURLRefObject, &CFURLRef_Type); it = PyObject_NEW(CFURLRefObject, &CFURLRef_Type);
if (it == NULL) return NULL; if (it == NULL) return NULL;
it->ob_itself = itself; it->ob_itself = itself;
...@@ -1827,6 +1901,7 @@ static PyObject *CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject *_self, PyObjec ...@@ -1827,6 +1901,7 @@ static PyObject *CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject *_self, PyObjec
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFURLRef _rv; CFURLRef _rv;
PyMac_PRECHECK(CFURLCopyAbsoluteURL);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLCopyAbsoluteURL(_self->ob_itself); _rv = CFURLCopyAbsoluteURL(_self->ob_itself);
...@@ -1839,6 +1914,7 @@ static PyObject *CFURLRefObj_CFURLGetString(CFURLRefObject *_self, PyObject *_ar ...@@ -1839,6 +1914,7 @@ static PyObject *CFURLRefObj_CFURLGetString(CFURLRefObject *_self, PyObject *_ar
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
PyMac_PRECHECK(CFURLGetString);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLGetString(_self->ob_itself); _rv = CFURLGetString(_self->ob_itself);
...@@ -1851,6 +1927,7 @@ static PyObject *CFURLRefObj_CFURLGetBaseURL(CFURLRefObject *_self, PyObject *_a ...@@ -1851,6 +1927,7 @@ static PyObject *CFURLRefObj_CFURLGetBaseURL(CFURLRefObject *_self, PyObject *_a
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFURLRef _rv; CFURLRef _rv;
PyMac_PRECHECK(CFURLGetBaseURL);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLGetBaseURL(_self->ob_itself); _rv = CFURLGetBaseURL(_self->ob_itself);
...@@ -1863,6 +1940,7 @@ static PyObject *CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject *_self, PyObjec ...@@ -1863,6 +1940,7 @@ static PyObject *CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject *_self, PyObjec
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
Boolean _rv; Boolean _rv;
PyMac_PRECHECK(CFURLCanBeDecomposed);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLCanBeDecomposed(_self->ob_itself); _rv = CFURLCanBeDecomposed(_self->ob_itself);
...@@ -1875,6 +1953,7 @@ static PyObject *CFURLRefObj_CFURLCopyScheme(CFURLRefObject *_self, PyObject *_a ...@@ -1875,6 +1953,7 @@ static PyObject *CFURLRefObj_CFURLCopyScheme(CFURLRefObject *_self, PyObject *_a
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
PyMac_PRECHECK(CFURLCopyScheme);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLCopyScheme(_self->ob_itself); _rv = CFURLCopyScheme(_self->ob_itself);
...@@ -1887,6 +1966,7 @@ static PyObject *CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject *_self, PyObjec ...@@ -1887,6 +1966,7 @@ static PyObject *CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject *_self, PyObjec
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
PyMac_PRECHECK(CFURLCopyNetLocation);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLCopyNetLocation(_self->ob_itself); _rv = CFURLCopyNetLocation(_self->ob_itself);
...@@ -1899,6 +1979,7 @@ static PyObject *CFURLRefObj_CFURLCopyPath(CFURLRefObject *_self, PyObject *_arg ...@@ -1899,6 +1979,7 @@ static PyObject *CFURLRefObj_CFURLCopyPath(CFURLRefObject *_self, PyObject *_arg
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
PyMac_PRECHECK(CFURLCopyPath);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLCopyPath(_self->ob_itself); _rv = CFURLCopyPath(_self->ob_itself);
...@@ -1911,6 +1992,7 @@ static PyObject *CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject *_self, PyObje ...@@ -1911,6 +1992,7 @@ static PyObject *CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject *_self, PyObje
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
Boolean _rv; Boolean _rv;
PyMac_PRECHECK(CFURLHasDirectoryPath);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLHasDirectoryPath(_self->ob_itself); _rv = CFURLHasDirectoryPath(_self->ob_itself);
...@@ -1923,6 +2005,7 @@ static PyObject *CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject *_self, P ...@@ -1923,6 +2005,7 @@ static PyObject *CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject *_self, P
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
PyMac_PRECHECK(CFURLCopyResourceSpecifier);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLCopyResourceSpecifier(_self->ob_itself); _rv = CFURLCopyResourceSpecifier(_self->ob_itself);
...@@ -1935,6 +2018,7 @@ static PyObject *CFURLRefObj_CFURLCopyHostName(CFURLRefObject *_self, PyObject * ...@@ -1935,6 +2018,7 @@ static PyObject *CFURLRefObj_CFURLCopyHostName(CFURLRefObject *_self, PyObject *
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
PyMac_PRECHECK(CFURLCopyHostName);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLCopyHostName(_self->ob_itself); _rv = CFURLCopyHostName(_self->ob_itself);
...@@ -1947,6 +2031,7 @@ static PyObject *CFURLRefObj_CFURLGetPortNumber(CFURLRefObject *_self, PyObject ...@@ -1947,6 +2031,7 @@ static PyObject *CFURLRefObj_CFURLGetPortNumber(CFURLRefObject *_self, PyObject
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
SInt32 _rv; SInt32 _rv;
PyMac_PRECHECK(CFURLGetPortNumber);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLGetPortNumber(_self->ob_itself); _rv = CFURLGetPortNumber(_self->ob_itself);
...@@ -1959,6 +2044,7 @@ static PyObject *CFURLRefObj_CFURLCopyUserName(CFURLRefObject *_self, PyObject * ...@@ -1959,6 +2044,7 @@ static PyObject *CFURLRefObj_CFURLCopyUserName(CFURLRefObject *_self, PyObject *
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
PyMac_PRECHECK(CFURLCopyUserName);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLCopyUserName(_self->ob_itself); _rv = CFURLCopyUserName(_self->ob_itself);
...@@ -1971,6 +2057,7 @@ static PyObject *CFURLRefObj_CFURLCopyPassword(CFURLRefObject *_self, PyObject * ...@@ -1971,6 +2057,7 @@ static PyObject *CFURLRefObj_CFURLCopyPassword(CFURLRefObject *_self, PyObject *
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
PyMac_PRECHECK(CFURLCopyPassword);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLCopyPassword(_self->ob_itself); _rv = CFURLCopyPassword(_self->ob_itself);
...@@ -1984,6 +2071,7 @@ static PyObject *CFURLRefObj_CFURLCopyParameterString(CFURLRefObject *_self, PyO ...@@ -1984,6 +2071,7 @@ static PyObject *CFURLRefObj_CFURLCopyParameterString(CFURLRefObject *_self, PyO
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
CFStringRef charactersToLeaveEscaped; CFStringRef charactersToLeaveEscaped;
PyMac_PRECHECK(CFURLCopyParameterString);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFStringRefObj_Convert, &charactersToLeaveEscaped)) CFStringRefObj_Convert, &charactersToLeaveEscaped))
return NULL; return NULL;
...@@ -1999,6 +2087,7 @@ static PyObject *CFURLRefObj_CFURLCopyQueryString(CFURLRefObject *_self, PyObjec ...@@ -1999,6 +2087,7 @@ static PyObject *CFURLRefObj_CFURLCopyQueryString(CFURLRefObject *_self, PyObjec
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
CFStringRef charactersToLeaveEscaped; CFStringRef charactersToLeaveEscaped;
PyMac_PRECHECK(CFURLCopyQueryString);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFStringRefObj_Convert, &charactersToLeaveEscaped)) CFStringRefObj_Convert, &charactersToLeaveEscaped))
return NULL; return NULL;
...@@ -2014,6 +2103,7 @@ static PyObject *CFURLRefObj_CFURLCopyFragment(CFURLRefObject *_self, PyObject * ...@@ -2014,6 +2103,7 @@ static PyObject *CFURLRefObj_CFURLCopyFragment(CFURLRefObject *_self, PyObject *
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
CFStringRef charactersToLeaveEscaped; CFStringRef charactersToLeaveEscaped;
PyMac_PRECHECK(CFURLCopyFragment);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFStringRefObj_Convert, &charactersToLeaveEscaped)) CFStringRefObj_Convert, &charactersToLeaveEscaped))
return NULL; return NULL;
...@@ -2080,7 +2170,7 @@ static int CFURLRefObj_compare(CFURLRefObject *self, CFURLRefObject *other) ...@@ -2080,7 +2170,7 @@ static int CFURLRefObj_compare(CFURLRefObject *self, CFURLRefObject *other)
static PyObject * CFURLRefObj_repr(CFURLRefObject *self) static PyObject * CFURLRefObj_repr(CFURLRefObject *self)
{ {
char buf[100]; char buf[100];
sprintf(buf, "<CFURL object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself); sprintf(buf, "<CFURL object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
return PyString_FromString(buf); return PyString_FromString(buf);
} }
...@@ -2116,6 +2206,7 @@ static PyObject *CF_CFAllocatorGetTypeID(PyObject *_self, PyObject *_args) ...@@ -2116,6 +2206,7 @@ static PyObject *CF_CFAllocatorGetTypeID(PyObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFTypeID _rv; CFTypeID _rv;
PyMac_PRECHECK(CFAllocatorGetTypeID);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFAllocatorGetTypeID(); _rv = CFAllocatorGetTypeID();
...@@ -2130,6 +2221,7 @@ static PyObject *CF_CFAllocatorGetPreferredSizeForSize(PyObject *_self, PyObject ...@@ -2130,6 +2221,7 @@ static PyObject *CF_CFAllocatorGetPreferredSizeForSize(PyObject *_self, PyObject
CFIndex _rv; CFIndex _rv;
CFIndex size; CFIndex size;
CFOptionFlags hint; CFOptionFlags hint;
PyMac_PRECHECK(CFAllocatorGetPreferredSizeForSize);
if (!PyArg_ParseTuple(_args, "ll", if (!PyArg_ParseTuple(_args, "ll",
&size, &size,
&hint)) &hint))
...@@ -2147,6 +2239,7 @@ static PyObject *CF_CFCopyTypeIDDescription(PyObject *_self, PyObject *_args) ...@@ -2147,6 +2239,7 @@ static PyObject *CF_CFCopyTypeIDDescription(PyObject *_self, PyObject *_args)
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
CFTypeID theType; CFTypeID theType;
PyMac_PRECHECK(CFCopyTypeIDDescription);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&theType)) &theType))
return NULL; return NULL;
...@@ -2160,6 +2253,7 @@ static PyObject *CF_CFArrayGetTypeID(PyObject *_self, PyObject *_args) ...@@ -2160,6 +2253,7 @@ static PyObject *CF_CFArrayGetTypeID(PyObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFTypeID _rv; CFTypeID _rv;
PyMac_PRECHECK(CFArrayGetTypeID);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFArrayGetTypeID(); _rv = CFArrayGetTypeID();
...@@ -2173,6 +2267,7 @@ static PyObject *CF_CFArrayCreateCopy(PyObject *_self, PyObject *_args) ...@@ -2173,6 +2267,7 @@ static PyObject *CF_CFArrayCreateCopy(PyObject *_self, PyObject *_args)
PyObject *_res = NULL; PyObject *_res = NULL;
CFArrayRef _rv; CFArrayRef _rv;
CFArrayRef srcArray; CFArrayRef srcArray;
PyMac_PRECHECK(CFArrayCreateCopy);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFArrayRefObj_Convert, &srcArray)) CFArrayRefObj_Convert, &srcArray))
return NULL; return NULL;
...@@ -2188,6 +2283,7 @@ static PyObject *CF_CFArrayCreateMutable(PyObject *_self, PyObject *_args) ...@@ -2188,6 +2283,7 @@ static PyObject *CF_CFArrayCreateMutable(PyObject *_self, PyObject *_args)
PyObject *_res = NULL; PyObject *_res = NULL;
CFMutableArrayRef _rv; CFMutableArrayRef _rv;
CFIndex capacity; CFIndex capacity;
PyMac_PRECHECK(CFArrayCreateMutable);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&capacity)) &capacity))
return NULL; return NULL;
...@@ -2205,6 +2301,7 @@ static PyObject *CF_CFArrayCreateMutableCopy(PyObject *_self, PyObject *_args) ...@@ -2205,6 +2301,7 @@ static PyObject *CF_CFArrayCreateMutableCopy(PyObject *_self, PyObject *_args)
CFMutableArrayRef _rv; CFMutableArrayRef _rv;
CFIndex capacity; CFIndex capacity;
CFArrayRef srcArray; CFArrayRef srcArray;
PyMac_PRECHECK(CFArrayCreateMutableCopy);
if (!PyArg_ParseTuple(_args, "lO&", if (!PyArg_ParseTuple(_args, "lO&",
&capacity, &capacity,
CFArrayRefObj_Convert, &srcArray)) CFArrayRefObj_Convert, &srcArray))
...@@ -2221,6 +2318,7 @@ static PyObject *CF_CFDataGetTypeID(PyObject *_self, PyObject *_args) ...@@ -2221,6 +2318,7 @@ static PyObject *CF_CFDataGetTypeID(PyObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFTypeID _rv; CFTypeID _rv;
PyMac_PRECHECK(CFDataGetTypeID);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFDataGetTypeID(); _rv = CFDataGetTypeID();
...@@ -2236,6 +2334,7 @@ static PyObject *CF_CFDataCreate(PyObject *_self, PyObject *_args) ...@@ -2236,6 +2334,7 @@ static PyObject *CF_CFDataCreate(PyObject *_self, PyObject *_args)
unsigned char *bytes__in__; unsigned char *bytes__in__;
long bytes__len__; long bytes__len__;
int bytes__in_len__; int bytes__in_len__;
PyMac_PRECHECK(CFDataCreate);
if (!PyArg_ParseTuple(_args, "s#", if (!PyArg_ParseTuple(_args, "s#",
&bytes__in__, &bytes__in_len__)) &bytes__in__, &bytes__in_len__))
return NULL; return NULL;
...@@ -2255,6 +2354,7 @@ static PyObject *CF_CFDataCreateWithBytesNoCopy(PyObject *_self, PyObject *_args ...@@ -2255,6 +2354,7 @@ static PyObject *CF_CFDataCreateWithBytesNoCopy(PyObject *_self, PyObject *_args
unsigned char *bytes__in__; unsigned char *bytes__in__;
long bytes__len__; long bytes__len__;
int bytes__in_len__; int bytes__in_len__;
PyMac_PRECHECK(CFDataCreateWithBytesNoCopy);
if (!PyArg_ParseTuple(_args, "s#", if (!PyArg_ParseTuple(_args, "s#",
&bytes__in__, &bytes__in_len__)) &bytes__in__, &bytes__in_len__))
return NULL; return NULL;
...@@ -2273,6 +2373,7 @@ static PyObject *CF_CFDataCreateCopy(PyObject *_self, PyObject *_args) ...@@ -2273,6 +2373,7 @@ static PyObject *CF_CFDataCreateCopy(PyObject *_self, PyObject *_args)
PyObject *_res = NULL; PyObject *_res = NULL;
CFDataRef _rv; CFDataRef _rv;
CFDataRef data; CFDataRef data;
PyMac_PRECHECK(CFDataCreateCopy);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFDataRefObj_Convert, &data)) CFDataRefObj_Convert, &data))
return NULL; return NULL;
...@@ -2288,6 +2389,7 @@ static PyObject *CF_CFDataCreateMutable(PyObject *_self, PyObject *_args) ...@@ -2288,6 +2389,7 @@ static PyObject *CF_CFDataCreateMutable(PyObject *_self, PyObject *_args)
PyObject *_res = NULL; PyObject *_res = NULL;
CFMutableDataRef _rv; CFMutableDataRef _rv;
CFIndex capacity; CFIndex capacity;
PyMac_PRECHECK(CFDataCreateMutable);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&capacity)) &capacity))
return NULL; return NULL;
...@@ -2304,6 +2406,7 @@ static PyObject *CF_CFDataCreateMutableCopy(PyObject *_self, PyObject *_args) ...@@ -2304,6 +2406,7 @@ static PyObject *CF_CFDataCreateMutableCopy(PyObject *_self, PyObject *_args)
CFMutableDataRef _rv; CFMutableDataRef _rv;
CFIndex capacity; CFIndex capacity;
CFDataRef data; CFDataRef data;
PyMac_PRECHECK(CFDataCreateMutableCopy);
if (!PyArg_ParseTuple(_args, "lO&", if (!PyArg_ParseTuple(_args, "lO&",
&capacity, &capacity,
CFDataRefObj_Convert, &data)) CFDataRefObj_Convert, &data))
...@@ -2320,6 +2423,7 @@ static PyObject *CF_CFDictionaryGetTypeID(PyObject *_self, PyObject *_args) ...@@ -2320,6 +2423,7 @@ static PyObject *CF_CFDictionaryGetTypeID(PyObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFTypeID _rv; CFTypeID _rv;
PyMac_PRECHECK(CFDictionaryGetTypeID);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFDictionaryGetTypeID(); _rv = CFDictionaryGetTypeID();
...@@ -2333,6 +2437,7 @@ static PyObject *CF_CFDictionaryCreateCopy(PyObject *_self, PyObject *_args) ...@@ -2333,6 +2437,7 @@ static PyObject *CF_CFDictionaryCreateCopy(PyObject *_self, PyObject *_args)
PyObject *_res = NULL; PyObject *_res = NULL;
CFDictionaryRef _rv; CFDictionaryRef _rv;
CFDictionaryRef dict; CFDictionaryRef dict;
PyMac_PRECHECK(CFDictionaryCreateCopy);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFDictionaryRefObj_Convert, &dict)) CFDictionaryRefObj_Convert, &dict))
return NULL; return NULL;
...@@ -2348,6 +2453,7 @@ static PyObject *CF_CFDictionaryCreateMutable(PyObject *_self, PyObject *_args) ...@@ -2348,6 +2453,7 @@ static PyObject *CF_CFDictionaryCreateMutable(PyObject *_self, PyObject *_args)
PyObject *_res = NULL; PyObject *_res = NULL;
CFMutableDictionaryRef _rv; CFMutableDictionaryRef _rv;
CFIndex capacity; CFIndex capacity;
PyMac_PRECHECK(CFDictionaryCreateMutable);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&capacity)) &capacity))
return NULL; return NULL;
...@@ -2366,6 +2472,7 @@ static PyObject *CF_CFDictionaryCreateMutableCopy(PyObject *_self, PyObject *_ar ...@@ -2366,6 +2472,7 @@ static PyObject *CF_CFDictionaryCreateMutableCopy(PyObject *_self, PyObject *_ar
CFMutableDictionaryRef _rv; CFMutableDictionaryRef _rv;
CFIndex capacity; CFIndex capacity;
CFDictionaryRef dict; CFDictionaryRef dict;
PyMac_PRECHECK(CFDictionaryCreateMutableCopy);
if (!PyArg_ParseTuple(_args, "lO&", if (!PyArg_ParseTuple(_args, "lO&",
&capacity, &capacity,
CFDictionaryRefObj_Convert, &dict)) CFDictionaryRefObj_Convert, &dict))
...@@ -2382,6 +2489,7 @@ static PyObject *CF_CFStringGetTypeID(PyObject *_self, PyObject *_args) ...@@ -2382,6 +2489,7 @@ static PyObject *CF_CFStringGetTypeID(PyObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFTypeID _rv; CFTypeID _rv;
PyMac_PRECHECK(CFStringGetTypeID);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFStringGetTypeID(); _rv = CFStringGetTypeID();
...@@ -2396,6 +2504,7 @@ static PyObject *CF_CFStringCreateWithPascalString(PyObject *_self, PyObject *_a ...@@ -2396,6 +2504,7 @@ static PyObject *CF_CFStringCreateWithPascalString(PyObject *_self, PyObject *_a
CFStringRef _rv; CFStringRef _rv;
StringPtr pStr; StringPtr pStr;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringCreateWithPascalString);
if (!PyArg_ParseTuple(_args, "O&l", if (!PyArg_ParseTuple(_args, "O&l",
PyMac_GetStr255, &pStr, PyMac_GetStr255, &pStr,
&encoding)) &encoding))
...@@ -2414,6 +2523,7 @@ static PyObject *CF_CFStringCreateWithCString(PyObject *_self, PyObject *_args) ...@@ -2414,6 +2523,7 @@ static PyObject *CF_CFStringCreateWithCString(PyObject *_self, PyObject *_args)
CFStringRef _rv; CFStringRef _rv;
char* cStr; char* cStr;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringCreateWithCString);
if (!PyArg_ParseTuple(_args, "sl", if (!PyArg_ParseTuple(_args, "sl",
&cStr, &cStr,
&encoding)) &encoding))
...@@ -2432,6 +2542,7 @@ static PyObject *CF_CFStringCreateWithPascalStringNoCopy(PyObject *_self, PyObje ...@@ -2432,6 +2542,7 @@ static PyObject *CF_CFStringCreateWithPascalStringNoCopy(PyObject *_self, PyObje
CFStringRef _rv; CFStringRef _rv;
StringPtr pStr; StringPtr pStr;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringCreateWithPascalStringNoCopy);
if (!PyArg_ParseTuple(_args, "O&l", if (!PyArg_ParseTuple(_args, "O&l",
PyMac_GetStr255, &pStr, PyMac_GetStr255, &pStr,
&encoding)) &encoding))
...@@ -2451,6 +2562,7 @@ static PyObject *CF_CFStringCreateWithCStringNoCopy(PyObject *_self, PyObject *_ ...@@ -2451,6 +2562,7 @@ static PyObject *CF_CFStringCreateWithCStringNoCopy(PyObject *_self, PyObject *_
CFStringRef _rv; CFStringRef _rv;
char* cStr; char* cStr;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringCreateWithCStringNoCopy);
if (!PyArg_ParseTuple(_args, "sl", if (!PyArg_ParseTuple(_args, "sl",
&cStr, &cStr,
&encoding)) &encoding))
...@@ -2470,6 +2582,7 @@ static PyObject *CF_CFStringCreateWithSubstring(PyObject *_self, PyObject *_args ...@@ -2470,6 +2582,7 @@ static PyObject *CF_CFStringCreateWithSubstring(PyObject *_self, PyObject *_args
CFStringRef _rv; CFStringRef _rv;
CFStringRef str; CFStringRef str;
CFRange range; CFRange range;
PyMac_PRECHECK(CFStringCreateWithSubstring);
if (!PyArg_ParseTuple(_args, "O&O&", if (!PyArg_ParseTuple(_args, "O&O&",
CFStringRefObj_Convert, &str, CFStringRefObj_Convert, &str,
CFRange_Convert, &range)) CFRange_Convert, &range))
...@@ -2487,6 +2600,7 @@ static PyObject *CF_CFStringCreateCopy(PyObject *_self, PyObject *_args) ...@@ -2487,6 +2600,7 @@ static PyObject *CF_CFStringCreateCopy(PyObject *_self, PyObject *_args)
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
CFStringRef theString; CFStringRef theString;
PyMac_PRECHECK(CFStringCreateCopy);
if (!PyArg_ParseTuple(_args, "O&", if (!PyArg_ParseTuple(_args, "O&",
CFStringRefObj_Convert, &theString)) CFStringRefObj_Convert, &theString))
return NULL; return NULL;
...@@ -2502,6 +2616,7 @@ static PyObject *CF_CFStringCreateMutable(PyObject *_self, PyObject *_args) ...@@ -2502,6 +2616,7 @@ static PyObject *CF_CFStringCreateMutable(PyObject *_self, PyObject *_args)
PyObject *_res = NULL; PyObject *_res = NULL;
CFMutableStringRef _rv; CFMutableStringRef _rv;
CFIndex maxLength; CFIndex maxLength;
PyMac_PRECHECK(CFStringCreateMutable);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&maxLength)) &maxLength))
return NULL; return NULL;
...@@ -2518,6 +2633,7 @@ static PyObject *CF_CFStringCreateMutableCopy(PyObject *_self, PyObject *_args) ...@@ -2518,6 +2633,7 @@ static PyObject *CF_CFStringCreateMutableCopy(PyObject *_self, PyObject *_args)
CFMutableStringRef _rv; CFMutableStringRef _rv;
CFIndex maxLength; CFIndex maxLength;
CFStringRef theString; CFStringRef theString;
PyMac_PRECHECK(CFStringCreateMutableCopy);
if (!PyArg_ParseTuple(_args, "lO&", if (!PyArg_ParseTuple(_args, "lO&",
&maxLength, &maxLength,
CFStringRefObj_Convert, &theString)) CFStringRefObj_Convert, &theString))
...@@ -2539,6 +2655,7 @@ static PyObject *CF_CFStringCreateWithBytes(PyObject *_self, PyObject *_args) ...@@ -2539,6 +2655,7 @@ static PyObject *CF_CFStringCreateWithBytes(PyObject *_self, PyObject *_args)
int bytes__in_len__; int bytes__in_len__;
CFStringEncoding encoding; CFStringEncoding encoding;
Boolean isExternalRepresentation; Boolean isExternalRepresentation;
PyMac_PRECHECK(CFStringCreateWithBytes);
if (!PyArg_ParseTuple(_args, "s#ll", if (!PyArg_ParseTuple(_args, "s#ll",
&bytes__in__, &bytes__in_len__, &bytes__in__, &bytes__in_len__,
&encoding, &encoding,
...@@ -2561,6 +2678,7 @@ static PyObject *CF_CFStringCreateFromExternalRepresentation(PyObject *_self, Py ...@@ -2561,6 +2678,7 @@ static PyObject *CF_CFStringCreateFromExternalRepresentation(PyObject *_self, Py
CFStringRef _rv; CFStringRef _rv;
CFDataRef data; CFDataRef data;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringCreateFromExternalRepresentation);
if (!PyArg_ParseTuple(_args, "O&l", if (!PyArg_ParseTuple(_args, "O&l",
CFDataRefObj_Convert, &data, CFDataRefObj_Convert, &data,
&encoding)) &encoding))
...@@ -2580,6 +2698,7 @@ static PyObject *CF_CFStringCreateExternalRepresentation(PyObject *_self, PyObje ...@@ -2580,6 +2698,7 @@ static PyObject *CF_CFStringCreateExternalRepresentation(PyObject *_self, PyObje
CFStringRef theString; CFStringRef theString;
CFStringEncoding encoding; CFStringEncoding encoding;
UInt8 lossByte; UInt8 lossByte;
PyMac_PRECHECK(CFStringCreateExternalRepresentation);
if (!PyArg_ParseTuple(_args, "O&lb", if (!PyArg_ParseTuple(_args, "O&lb",
CFStringRefObj_Convert, &theString, CFStringRefObj_Convert, &theString,
&encoding, &encoding,
...@@ -2598,6 +2717,7 @@ static PyObject *CF_CFStringGetSystemEncoding(PyObject *_self, PyObject *_args) ...@@ -2598,6 +2717,7 @@ static PyObject *CF_CFStringGetSystemEncoding(PyObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringEncoding _rv; CFStringEncoding _rv;
PyMac_PRECHECK(CFStringGetSystemEncoding);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFStringGetSystemEncoding(); _rv = CFStringGetSystemEncoding();
...@@ -2612,6 +2732,7 @@ static PyObject *CF_CFStringGetMaximumSizeForEncoding(PyObject *_self, PyObject ...@@ -2612,6 +2732,7 @@ static PyObject *CF_CFStringGetMaximumSizeForEncoding(PyObject *_self, PyObject
CFIndex _rv; CFIndex _rv;
CFIndex length; CFIndex length;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringGetMaximumSizeForEncoding);
if (!PyArg_ParseTuple(_args, "ll", if (!PyArg_ParseTuple(_args, "ll",
&length, &length,
&encoding)) &encoding))
...@@ -2631,6 +2752,7 @@ static PyObject *CF_CFStringCreateArrayWithFindResults(PyObject *_self, PyObject ...@@ -2631,6 +2752,7 @@ static PyObject *CF_CFStringCreateArrayWithFindResults(PyObject *_self, PyObject
CFStringRef stringToFind; CFStringRef stringToFind;
CFRange rangeToSearch; CFRange rangeToSearch;
CFOptionFlags compareOptions; CFOptionFlags compareOptions;
PyMac_PRECHECK(CFStringCreateArrayWithFindResults);
if (!PyArg_ParseTuple(_args, "O&O&O&l", if (!PyArg_ParseTuple(_args, "O&O&O&l",
CFStringRefObj_Convert, &theString, CFStringRefObj_Convert, &theString,
CFStringRefObj_Convert, &stringToFind, CFStringRefObj_Convert, &stringToFind,
...@@ -2653,6 +2775,7 @@ static PyObject *CF_CFStringCreateByCombiningStrings(PyObject *_self, PyObject * ...@@ -2653,6 +2775,7 @@ static PyObject *CF_CFStringCreateByCombiningStrings(PyObject *_self, PyObject *
CFStringRef _rv; CFStringRef _rv;
CFArrayRef theArray; CFArrayRef theArray;
CFStringRef separatorString; CFStringRef separatorString;
PyMac_PRECHECK(CFStringCreateByCombiningStrings);
if (!PyArg_ParseTuple(_args, "O&O&", if (!PyArg_ParseTuple(_args, "O&O&",
CFArrayRefObj_Convert, &theArray, CFArrayRefObj_Convert, &theArray,
CFStringRefObj_Convert, &separatorString)) CFStringRefObj_Convert, &separatorString))
...@@ -2671,6 +2794,7 @@ static PyObject *CF_CFStringCreateArrayBySeparatingStrings(PyObject *_self, PyOb ...@@ -2671,6 +2794,7 @@ static PyObject *CF_CFStringCreateArrayBySeparatingStrings(PyObject *_self, PyOb
CFArrayRef _rv; CFArrayRef _rv;
CFStringRef theString; CFStringRef theString;
CFStringRef separatorString; CFStringRef separatorString;
PyMac_PRECHECK(CFStringCreateArrayBySeparatingStrings);
if (!PyArg_ParseTuple(_args, "O&O&", if (!PyArg_ParseTuple(_args, "O&O&",
CFStringRefObj_Convert, &theString, CFStringRefObj_Convert, &theString,
CFStringRefObj_Convert, &separatorString)) CFStringRefObj_Convert, &separatorString))
...@@ -2688,6 +2812,7 @@ static PyObject *CF_CFStringIsEncodingAvailable(PyObject *_self, PyObject *_args ...@@ -2688,6 +2812,7 @@ static PyObject *CF_CFStringIsEncodingAvailable(PyObject *_self, PyObject *_args
PyObject *_res = NULL; PyObject *_res = NULL;
Boolean _rv; Boolean _rv;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringIsEncodingAvailable);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&encoding)) &encoding))
return NULL; return NULL;
...@@ -2702,6 +2827,7 @@ static PyObject *CF_CFStringGetNameOfEncoding(PyObject *_self, PyObject *_args) ...@@ -2702,6 +2827,7 @@ static PyObject *CF_CFStringGetNameOfEncoding(PyObject *_self, PyObject *_args)
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringGetNameOfEncoding);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&encoding)) &encoding))
return NULL; return NULL;
...@@ -2716,6 +2842,7 @@ static PyObject *CF_CFStringConvertEncodingToNSStringEncoding(PyObject *_self, P ...@@ -2716,6 +2842,7 @@ static PyObject *CF_CFStringConvertEncodingToNSStringEncoding(PyObject *_self, P
PyObject *_res = NULL; PyObject *_res = NULL;
UInt32 _rv; UInt32 _rv;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringConvertEncodingToNSStringEncoding);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&encoding)) &encoding))
return NULL; return NULL;
...@@ -2730,6 +2857,7 @@ static PyObject *CF_CFStringConvertNSStringEncodingToEncoding(PyObject *_self, P ...@@ -2730,6 +2857,7 @@ static PyObject *CF_CFStringConvertNSStringEncodingToEncoding(PyObject *_self, P
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringEncoding _rv; CFStringEncoding _rv;
UInt32 encoding; UInt32 encoding;
PyMac_PRECHECK(CFStringConvertNSStringEncodingToEncoding);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&encoding)) &encoding))
return NULL; return NULL;
...@@ -2744,6 +2872,7 @@ static PyObject *CF_CFStringConvertEncodingToWindowsCodepage(PyObject *_self, Py ...@@ -2744,6 +2872,7 @@ static PyObject *CF_CFStringConvertEncodingToWindowsCodepage(PyObject *_self, Py
PyObject *_res = NULL; PyObject *_res = NULL;
UInt32 _rv; UInt32 _rv;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringConvertEncodingToWindowsCodepage);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&encoding)) &encoding))
return NULL; return NULL;
...@@ -2758,6 +2887,7 @@ static PyObject *CF_CFStringConvertWindowsCodepageToEncoding(PyObject *_self, Py ...@@ -2758,6 +2887,7 @@ static PyObject *CF_CFStringConvertWindowsCodepageToEncoding(PyObject *_self, Py
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringEncoding _rv; CFStringEncoding _rv;
UInt32 codepage; UInt32 codepage;
PyMac_PRECHECK(CFStringConvertWindowsCodepageToEncoding);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&codepage)) &codepage))
return NULL; return NULL;
...@@ -2772,6 +2902,7 @@ static PyObject *CF_CFStringConvertEncodingToIANACharSetName(PyObject *_self, Py ...@@ -2772,6 +2902,7 @@ static PyObject *CF_CFStringConvertEncodingToIANACharSetName(PyObject *_self, Py
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
CFStringEncoding encoding; CFStringEncoding encoding;
PyMac_PRECHECK(CFStringConvertEncodingToIANACharSetName);
if (!PyArg_ParseTuple(_args, "l", if (!PyArg_ParseTuple(_args, "l",
&encoding)) &encoding))
return NULL; return NULL;
...@@ -2786,6 +2917,7 @@ static PyObject *CF___CFStringMakeConstantString(PyObject *_self, PyObject *_arg ...@@ -2786,6 +2917,7 @@ static PyObject *CF___CFStringMakeConstantString(PyObject *_self, PyObject *_arg
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
char* cStr; char* cStr;
PyMac_PRECHECK(__CFStringMakeConstantString);
if (!PyArg_ParseTuple(_args, "s", if (!PyArg_ParseTuple(_args, "s",
&cStr)) &cStr))
return NULL; return NULL;
...@@ -2799,6 +2931,7 @@ static PyObject *CF_CFURLGetTypeID(PyObject *_self, PyObject *_args) ...@@ -2799,6 +2931,7 @@ static PyObject *CF_CFURLGetTypeID(PyObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFTypeID _rv; CFTypeID _rv;
PyMac_PRECHECK(CFURLGetTypeID);
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = CFURLGetTypeID(); _rv = CFURLGetTypeID();
...@@ -2816,6 +2949,7 @@ static PyObject *CF_CFURLCreateWithBytes(PyObject *_self, PyObject *_args) ...@@ -2816,6 +2949,7 @@ static PyObject *CF_CFURLCreateWithBytes(PyObject *_self, PyObject *_args)
int URLBytes__in_len__; int URLBytes__in_len__;
CFStringEncoding encoding; CFStringEncoding encoding;
CFURLRef baseURL; CFURLRef baseURL;
PyMac_PRECHECK(CFURLCreateWithBytes);
if (!PyArg_ParseTuple(_args, "s#lO&", if (!PyArg_ParseTuple(_args, "s#lO&",
&URLBytes__in__, &URLBytes__in_len__, &URLBytes__in__, &URLBytes__in_len__,
&encoding, &encoding,
...@@ -2839,6 +2973,7 @@ static PyObject *CF_CFURLCreateData(PyObject *_self, PyObject *_args) ...@@ -2839,6 +2973,7 @@ static PyObject *CF_CFURLCreateData(PyObject *_self, PyObject *_args)
CFURLRef url; CFURLRef url;
CFStringEncoding encoding; CFStringEncoding encoding;
Boolean escapeWhitespace; Boolean escapeWhitespace;
PyMac_PRECHECK(CFURLCreateData);
if (!PyArg_ParseTuple(_args, "O&ll", if (!PyArg_ParseTuple(_args, "O&ll",
CFURLRefObj_Convert, &url, CFURLRefObj_Convert, &url,
&encoding, &encoding,
...@@ -2859,6 +2994,7 @@ static PyObject *CF_CFURLCreateWithString(PyObject *_self, PyObject *_args) ...@@ -2859,6 +2994,7 @@ static PyObject *CF_CFURLCreateWithString(PyObject *_self, PyObject *_args)
CFURLRef _rv; CFURLRef _rv;
CFStringRef URLString; CFStringRef URLString;
CFURLRef baseURL; CFURLRef baseURL;
PyMac_PRECHECK(CFURLCreateWithString);
if (!PyArg_ParseTuple(_args, "O&O&", if (!PyArg_ParseTuple(_args, "O&O&",
CFStringRefObj_Convert, &URLString, CFStringRefObj_Convert, &URLString,
OptionalCFURLRefObj_Convert, &baseURL)) OptionalCFURLRefObj_Convert, &baseURL))
...@@ -2871,12 +3007,57 @@ static PyObject *CF_CFURLCreateWithString(PyObject *_self, PyObject *_args) ...@@ -2871,12 +3007,57 @@ static PyObject *CF_CFURLCreateWithString(PyObject *_self, PyObject *_args)
return _res; return _res;
} }
static PyObject *CF_CFURLCreateWithFileSystemPath(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
CFURLRef _rv;
CFStringRef filePath;
CFURLPathStyle pathStyle;
Boolean isDirectory;
PyMac_PRECHECK(CFURLCreateWithFileSystemPath);
if (!PyArg_ParseTuple(_args, "O&ll",
CFStringRefObj_Convert, &filePath,
&pathStyle,
&isDirectory))
return NULL;
_rv = CFURLCreateWithFileSystemPath((CFAllocatorRef)NULL,
filePath,
pathStyle,
isDirectory);
_res = Py_BuildValue("O&",
CFURLRefObj_New, _rv);
return _res;
}
static PyObject *CF_CFURLCreateStringWithFileSystemPath(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
CFStringRef _rv;
CFURLRef anURL;
CFURLPathStyle pathStyle;
Boolean resolveAgainstBase;
PyMac_PRECHECK(CFURLCreateStringWithFileSystemPath);
if (!PyArg_ParseTuple(_args, "O&ll",
CFURLRefObj_Convert, &anURL,
&pathStyle,
&resolveAgainstBase))
return NULL;
_rv = CFURLCreateStringWithFileSystemPath((CFAllocatorRef)NULL,
anURL,
pathStyle,
resolveAgainstBase);
_res = Py_BuildValue("O&",
CFStringRefObj_New, _rv);
return _res;
}
static PyObject *CF_CFURLCreateStringByReplacingPercentEscapes(PyObject *_self, PyObject *_args) static PyObject *CF_CFURLCreateStringByReplacingPercentEscapes(PyObject *_self, PyObject *_args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
CFStringRef _rv; CFStringRef _rv;
CFStringRef originalString; CFStringRef originalString;
CFStringRef charactersToLeaveEscaped; CFStringRef charactersToLeaveEscaped;
PyMac_PRECHECK(CFURLCreateStringByReplacingPercentEscapes);
if (!PyArg_ParseTuple(_args, "O&O&", if (!PyArg_ParseTuple(_args, "O&O&",
CFStringRefObj_Convert, &originalString, CFStringRefObj_Convert, &originalString,
CFStringRefObj_Convert, &charactersToLeaveEscaped)) CFStringRefObj_Convert, &charactersToLeaveEscaped))
...@@ -2982,6 +3163,10 @@ static PyMethodDef CF_methods[] = { ...@@ -2982,6 +3163,10 @@ static PyMethodDef CF_methods[] = {
"(CFURLRef url, CFStringEncoding encoding, Boolean escapeWhitespace) -> (CFDataRef _rv)"}, "(CFURLRef url, CFStringEncoding encoding, Boolean escapeWhitespace) -> (CFDataRef _rv)"},
{"CFURLCreateWithString", (PyCFunction)CF_CFURLCreateWithString, 1, {"CFURLCreateWithString", (PyCFunction)CF_CFURLCreateWithString, 1,
"(CFStringRef URLString, CFURLRef baseURL) -> (CFURLRef _rv)"}, "(CFStringRef URLString, CFURLRef baseURL) -> (CFURLRef _rv)"},
{"CFURLCreateWithFileSystemPath", (PyCFunction)CF_CFURLCreateWithFileSystemPath, 1,
"(CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory) -> (CFURLRef _rv)"},
{"CFURLCreateStringWithFileSystemPath", (PyCFunction)CF_CFURLCreateStringWithFileSystemPath, 1,
"(CFURLRef anURL, CFURLPathStyle pathStyle, Boolean resolveAgainstBase) -> (CFStringRef _rv)"},
{"CFURLCreateStringByReplacingPercentEscapes", (PyCFunction)CF_CFURLCreateStringByReplacingPercentEscapes, 1, {"CFURLCreateStringByReplacingPercentEscapes", (PyCFunction)CF_CFURLCreateStringByReplacingPercentEscapes, 1,
"(CFStringRef originalString, CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"}, "(CFStringRef originalString, CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
{NULL, NULL, 0} {NULL, NULL, 0}
......
...@@ -250,6 +250,15 @@ class CFStringRefObjectDefinition(MyGlobalObjectDefinition): ...@@ -250,6 +250,15 @@ class CFStringRefObjectDefinition(MyGlobalObjectDefinition):
*p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, 0); *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, 0);
return 1; return 1;
} }
if (PyUnicode_Check(v)) {
/* We use the CF types here, if Python was configured differently that will give an error */
CFIndex size = PyUnicode_GetSize(v);
UniChar *unichars = PyUnicode_AsUnicode(v);
if (!unichars) return 0;
*p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size);
return 1;
}
""") """)
def outputRepr(self): def outputRepr(self):
...@@ -377,6 +386,24 @@ f = ManualGenerator("CFStringGetString", getasstring_body); ...@@ -377,6 +386,24 @@ f = ManualGenerator("CFStringGetString", getasstring_body);
f.docstring = lambda: "() -> (string _rv)" f.docstring = lambda: "() -> (string _rv)"
CFStringRef_object.add(f) CFStringRef_object.add(f)
getasunicode_body = """
int size = CFStringGetLength(_self->ob_itself)+1;
Py_UNICODE *data = malloc(size*sizeof(Py_UNICODE));
CFRange range;
range.location = 0;
range.length = size;
if( data == NULL ) return PyErr_NoMemory();
CFStringGetCharacters(_self->ob_itself, range, data);
_res = (PyObject *)PyUnicode_FromUnicode(data, size);
free(data);
return _res;
"""
f = ManualGenerator("CFStringGetUnicode", getasunicode_body);
f.docstring = lambda: "() -> (unicode _rv)"
CFStringRef_object.add(f)
# ADD add forloop here # ADD add forloop here
# generate output (open the output file as late as possible) # generate output (open the output file as late as possible)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment