|
|
Subject: Re: Using ctypes to access OS X frameworks - msg#00017
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
frameworks. I googled around a bit and found these pages:
http://developer.apple.com/samplecode/CallMachOFramework/
CallMachOFramework.html
http://developer.apple.com/samplecode/CallMachOFramework/listing2.html
Remember that I know nearly nothing about macs, but by reading these
pages I got the impression that the key functions here are
LoadFrameworkBundle() and CFBundleGetFunctionPointerForName(), which
seem to play roles similar to dl_open()/dl_sym() or
LoadLibrary()/GetProcAddress().
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, or would ctypes have a place here?
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
Thread at a glance:
Previous Message by Date:
Using ctypes to access OS X frameworks
I have been asked in private email if ctypes can be used to access OS X
frameworks. I googled around a bit and found these pages:
http://developer.apple.com/samplecode/CallMachOFramework/CallMachOFramework.html
http://developer.apple.com/samplecode/CallMachOFramework/listing2.html
Remember that I know nearly nothing about macs, but by reading these
pages I got the impression that the key functions here are
LoadFrameworkBundle() and CFBundleGetFunctionPointerForName(), which
seem to play roles similar to dl_open()/dl_sym() or
LoadLibrary()/GetProcAddress().
Apart from that, I really do not know if this is a niche covered by
PyObjC, or would ctypes have a place here?
The background, for me at least, is that ctypes still lacks critical
mass on non-windows systems. In the meantime I have started learning to
run and debug code on some x86 platforms (some linuxes, openbsd), but
not on the mac.
Thomas
-------------------------------------------------------
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
Next Message by Date:
Catching NavigateError in test_browser.py
Sorry for the cross-post to ctypes. Venster list seems to be very idle.
I'm trying to catch NavigateError events in test_browser.
In testing, I added this to the browserWindow class
def NavigateError(self, this, pDisp, URL, targetFrameName, statusCode,
Cancel):
1. what is "this" ?
2. Cancel is Python type bool, but I'm looking for a POINTER(c_int) as
described in ie6_gen
DISPMETHOD(0x10f, None, "NavigateError", POINTER(IDispatch),
POINTER(VARIANT), POINTER(VARIANT), POINTER(VARIANT), POINTER(c_int)),
I need to set Cancel.value = 1
How is it that Cancel is being converted to a bool? I how can I set it's value
by reference?
Thanks for ideas
--
Brad Clements, bkc@xxxxxxxxxxxxx (315)268-1000
http://www.murkworks.com (315)268-9812 Fax
http://www.wecanstopspam.org/ AOL-IM: BKClements
-------------------------------------------------------
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
Previous Message by Thread:
Using ctypes to access OS X frameworks
I have been asked in private email if ctypes can be used to access OS X
frameworks. I googled around a bit and found these pages:
http://developer.apple.com/samplecode/CallMachOFramework/CallMachOFramework.html
http://developer.apple.com/samplecode/CallMachOFramework/listing2.html
Remember that I know nearly nothing about macs, but by reading these
pages I got the impression that the key functions here are
LoadFrameworkBundle() and CFBundleGetFunctionPointerForName(), which
seem to play roles similar to dl_open()/dl_sym() or
LoadLibrary()/GetProcAddress().
Apart from that, I really do not know if this is a niche covered by
PyObjC, or would ctypes have a place here?
The background, for me at least, is that ctypes still lacks critical
mass on non-windows systems. In the meantime I have started learning to
run and debug code on some x86 platforms (some linuxes, openbsd), but
not on the mac.
Thomas
-------------------------------------------------------
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
Next Message by Thread:
Catching NavigateError in test_browser.py
Sorry for the cross-post to ctypes. Venster list seems to be very idle.
I'm trying to catch NavigateError events in test_browser.
In testing, I added this to the browserWindow class
def NavigateError(self, this, pDisp, URL, targetFrameName, statusCode,
Cancel):
1. what is "this" ?
2. Cancel is Python type bool, but I'm looking for a POINTER(c_int) as
described in ie6_gen
DISPMETHOD(0x10f, None, "NavigateError", POINTER(IDispatch),
POINTER(VARIANT), POINTER(VARIANT), POINTER(VARIANT), POINTER(c_int)),
I need to set Cancel.value = 1
How is it that Cancel is being converted to a bool? I how can I set it's value
by reference?
Thanks for ideas
--
Brad Clements, bkc@xxxxxxxxxxxxx (315)268-1000
http://www.murkworks.com (315)268-9812 Fax
http://www.wecanstopspam.org/ AOL-IM: BKClements
-------------------------------------------------------
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
|
|