Re: Calling a CFM library from Mach-o and passing a Callback...
Re: Calling a CFM library from Mach-o and passing a Callback...
- Subject: Re: Calling a CFM library from Mach-o and passing a Callback...
- From: Dave Thorup <email@hidden>
- Date: Thu, 20 Apr 2006 19:05:25 -0400
Thanks George and Frederick! I was actually able to stumble across
an old Carbon-dev thread that got me the information I needed (after
a lot of searching). I found it right before I got your emails:
http://lists.apple.com/archives/carbon-development/2003/Aug/
msg01698.html
http://lists.apple.com/archives/carbon-development/2003/Aug/
msg01697.html
Also, I found that Uli Kusterer has put together some sample code
that implements functions for creating CFM function pointers out of
Mach-o function pointers and vice versa:
http://www.zathras.de/angelweb/sourcecode.htm
Lastly, I've put together a quick tutorial on my site that puts it
all together. This is mostly for my benefit as I would hope that no
one else has to deal with this anymore: ;-)
http://cutterpillow.com/content/view/24/1/
Thanks again!
Dave
On Apr 20, 2006, at 3:41 PM, George Warner wrote:
on 4/20/06 9:34 AM, Dave Thorup at <email@hidden> wrote:
Alright, I'm in the unfortunate position of having to use a third-
party CFM
library with our Mach-o application. I have it working for the
most part
using CFBundle to load the library and
CFBundleGetFunctionPointerForName to
load the function pointers that I need. The last thing that I
need to do is
be able to pass a function pointer from my Mach-o application so
that it can
be used by the CFM library.
I can't seem to find any way to do this, at least I haven't been
able to find
it yet. The best I could do was locate the CFM_MachO_CFM sample
code. But
this does the opposite of what I need to do (CFM -> Mach-o ->
CFM), I need to
do Mach-o -> CFM -> Mach-o. Can anybody point me in the right
direction?
All you need to do is create fake TVectors for the macho routines
that you
need to pass as callback for CFM API's.
typedef struct TVector_struct {
void *codePtr;
void *tocPtr;
} TVector_rec,*TVector_ptr;
Set the codePtr to the macho routine; the tocPtr doesn't matter
(for macho).
then pass the address of this vector as the callback. Note: Don't
use a
stack based TVector that may "go away" when your routine returns if
the
callback may get called after that point (such as a asynchronous
callback).
For callbacks that only get called (back) while it's parent routine is
executing (before it returns) it's ok.
--
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden