[Pythonmac-SIG] ctypes and OS X CF types?
Daniel Miller
daniel at keystonewood.com
Mon Oct 22 18:30:25 CEST 2007
Please ignore my previous email. I hope it didn't come across as
condescending. Really, I was only trying to help. Unfortunately, I
had not read your question thoroughly enough.
Bill Janssen wrote:
> I'm trying to call the Spotlight system from Python, and I thought I'd
> try using the ctypes support in Python 2.5 to use the MDQuery
> framework. However, it seems that I'll have to unearth and write
> ctypes definitions for a number of Core Foundation C++ types, in order
> to do that. Has anyone already done this? Created ctypes definitions
> for the standard CF types, and made them available somewhere?
Are you asking about struct definitions and such? For example:
from ctypes import Structure, c_float, c_double
class PMRect(Structure):
_fields_ = [
("top", c_double),
("left", c_double),
("bottom", c_double),
("right", c_double),
]
class CGPoint(Structure):
_fields_ = [("x", c_float), ("y", c_float)]
class CGSize(Structure):
_fields_ = [("width", c_float), ("height", c_float)]
class CGRect(Structure):
_fields_ = [("origin", CGPoint), ("size", CGSize)]
Those are the only ones I've used, and luckily they're pretty simple.
I do not know of a library of definitions for standard CF types. Sorry.
~ Daniel
More information about the Pythonmac-SIG
mailing list