|
Re: Using ctypes to access OS X frameworks: msg#00017python.ctypes
On Oct 15, 2004, at 1:20 PM, Thomas Heller wrote: I have been asked in private email if ctypes can be used to access OS X All of the function lookup code in OS X nomatter which API it's from boils down to dyld. libdl is implemented as a shim over top of dyld, so ctypes can already be used to load code from frameworks. All you have to do is point it at the code in the bundle, which is always Foo.framework/Versions/Current/Foo .. as opposed to libfoo.so on other platforms. Apart from that, I really do not know if this is a niche covered by PyObjC in SVN does wrap CFBundleGetFunctionPointer for name (objc.loadBundleFunctions, IIRC) and can do some, not all, of the things that ctypes does. It's primarily useful if you're calling into functions that are CoreFoundation based, or deal with very basic types (integers, floats, simple structures, etc.). Here is an example that uses PyObjC to do something ctypes-like. Note that it's a lot less ugly if the functions are shoved into globals.. but I wanted to make sure all of the functions exist at runtime because CPS is undocumented private SPI and may disappear in the future. http://svn.red-bean.com/pyobjc/trunk/pyobjc/Examples/wmEnable.py I've been meaning to experiment with ctypes more on OS X, but I have simply been too busy :( -bob ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Using ctypes to access OS X frameworks: 00017, Thomas Heller |
|---|---|
| Next by Date: | Catching NavigateError in test_browser.py: 00017, Brad Clements |
| Previous by Thread: | Using ctypes to access OS X frameworksi: 00017, Thomas Heller |
| Next by Thread: | Catching NavigateError in test_browser.py: 00017, Brad Clements |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |