[CalendarServer-changes] [1322] PyOpenDirectory/trunk/src/PythonWrapper.cpp

source_changes at macosforge.org source_changes at macosforge.org
Mon Mar 5 17:36:26 PST 2007


Revision: 1322
          http://trac.macosforge.org/projects/calendarserver/changeset/1322
Author:   cdaboo at apple.com
Date:     2007-03-05 17:36:26 -0800 (Mon, 05 Mar 2007)

Log Message:
-----------
Remove unneeded functions. Also eliminates a Python 2.4 vs 2.5 build issue.

Modified Paths:
--------------
    PyOpenDirectory/trunk/src/PythonWrapper.cpp

Modified: PyOpenDirectory/trunk/src/PythonWrapper.cpp
===================================================================
--- PyOpenDirectory/trunk/src/PythonWrapper.cpp	2007-03-06 01:31:33 UTC (rev 1321)
+++ PyOpenDirectory/trunk/src/PythonWrapper.cpp	2007-03-06 01:36:26 UTC (rev 1322)
@@ -32,10 +32,6 @@
 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
 #endif
 
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
-typedef int Py_ssize_t;
-#endif
-
 // Utility function - not exposed to Python
 static PyObject* CFStringToPyStr(CFStringRef str)
 {
@@ -44,25 +40,6 @@
 }
 
 // Utility function - not exposed to Python
-static PyObject* CFArrayToPyTuple(CFArrayRef list, bool sorted = false)
-{
-	CFIndex lsize = CFArrayGetCount(list);
-	if (sorted)
-		CFArraySortValues((CFMutableArrayRef)list, CFRangeMake(0, lsize), (CFComparatorFunction)CFStringCompare, NULL);
-	
-	PyObject* result = PyTuple_New(lsize);
-	for(CFIndex i = 0; i < lsize; i++)
-	{
-		CFStringRef str = (CFStringRef)CFArrayGetValueAtIndex(list, i);
-		PyObject* pystr = CFStringToPyStr(str);
-		
-		PyTuple_SetItem(result, i, pystr);
-	}
-	
-	return result;
-}
-
-// Utility function - not exposed to Python
 static PyObject* CFArrayToPyList(CFArrayRef list, bool sorted = false)
 {
 	CFIndex lsize = (list != NULL) ? CFArrayGetCount(list) : 0;
@@ -107,80 +84,6 @@
 }
 
 // Utility function - not exposed to Python
-static CFDictionaryRef PyDictToCFDictionary(PyObject* dict)
-{
-	CFMutableDictionaryRef result = CFDictionaryCreateMutable(kCFAllocatorDefault, PyDict_Size(dict), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-	PyObject* key;
-	PyObject* value;
-	Py_ssize_t pos = 0;
-	
-	while (PyDict_Next(dict, &pos, &key, &value))
-	{
-		if ((key == NULL) || !PyString_Check(key) ||
-			(value == NULL) || !PyString_Check(value))
-		{
-			CFRelease(result);
-			return NULL;
-		}
-		const char* ckey = PyString_AsString(key);
-		if (ckey == NULL)
-		{
-			CFRelease(result);
-			return NULL;
-		}
-		CFStringUtil cfkey(ckey);
-		const char* cvalue = PyString_AsString(value);
-		if (cvalue == NULL)
-		{
-			CFRelease(result);
-			return NULL;
-		}
-		CFStringUtil cfvalue(cvalue);
-		CFDictionaryAddValue(result, cfkey.get(), cfvalue.get());
-	}
-	
-	return result;
-}
-
-// Utility function - not exposed to Python
-static CFComparisonResult CompareRecordListValues(const void *val1, const void *val2, void *context)
-{
-	CFMutableArrayRef l1 = (CFMutableArrayRef)val1;
-	CFMutableArrayRef l2 = (CFMutableArrayRef)val2;
-	CFIndex c1 = CFArrayGetCount(l1);
-	CFIndex c2 = CFArrayGetCount(l2);
-	if ((c1 > 0) && (c2 > 0))
-	{
-		return CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(l1, 0), (CFStringRef)CFArrayGetValueAtIndex(l2, 0), NULL);
-	}
-	else if (c1 > 0)
-		return kCFCompareGreaterThan;
-	else if (c2 > 0)
-		return kCFCompareLessThan;
-	else
-		return kCFCompareEqualTo;
-}
-
-// Utility function - not exposed to Python
-static PyObject* CFArrayArrayToPyList(CFMutableArrayRef list, bool sorted = false)
-{
-	CFIndex lsize = (list != NULL) ? CFArrayGetCount(list) : 0;
-	if (sorted and (list != NULL))
-		CFArraySortValues(list, CFRangeMake(0, lsize), CompareRecordListValues, NULL);
-	
-	PyObject* result = PyList_New(lsize);
-	for(CFIndex i = 0; i < lsize; i++)
-	{
-		CFMutableArrayRef array = (CFMutableArrayRef)CFArrayGetValueAtIndex(list, i);
-		PyObject* pytuple = CFArrayToPyTuple(array);
-		
-		PyList_SetItem(result, i, pytuple);
-	}
-	
-	return result;
-}
-
-// Utility function - not exposed to Python
 static void CFDictionaryIterator(const void* key, const void* value, void* ref)
 {
 	CFStringRef strkey = (CFStringRef)key;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070305/5522f1cd/attachment.html


More information about the calendarserver-changes mailing list