/*
 *  Python extension for reading a Mac OS X plist file.
 *  Copyright (C) 2004  Andreas Junghans <aj@lucid-cake.net>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef util_h
#define util_h 1

#include <Carbon/Carbon.h>
#include <Python.h>

typedef PyObject* (*ArrayElementToPyObjectConverter)(void* param, const void* arrayElement);

// Macro for easy release of things (even if null).
#define CFRELEASE(ref) \
    if (ref != NULL) \
    { \
        CFRelease(ref); \
        ref = NULL; \
    }


// determines the length of a 0-terminated unicode string
int unilen(UniChar* unicodeString);


// various conversion functions
PyObject*				PyListFromCFArray(CFArrayRef arrayValue);
PyObject*               PyDictFromCFDict(CFDictionaryRef dictValue);
//CFMutableArrayRef		CFArrayFromPyList(PyObject* pyList);
//CFMutableDictionaryRef	CFDictFromPyDict(PyObject* pyDict);
PyObject*				PyUnicodeFromCFString(CFStringRef string);
CFStringRef				CFStringFromPyString(PyObject* pyString);
CFNumberRef				CFNumberFromPyNumber(PyObject* pyNumber);
PyObject*				PyStringFromCFData(CFDataRef dataValue);
CFMutableDataRef		CFDataFromPyString(PyObject* pyString);
PyObject*				convertToPyObject(CFTypeRef cfObject);
//CFTypeRef				convertToCFType(ABPropertyType type, PyObject* propertyValue);
//ABPropertyType			getPropertyType(CFTypeRef typeRef);
//ABPropertyType			getPythonPropertyType(PyObject* pyObject);
//PyObject*				PyListFromPropertyArray(CFArrayRef arrayValue);

#endif
