Re: NSBundle question
Re: NSBundle question
- Subject: Re: NSBundle question
- From: "R. Eranki" <email@hidden>
- Date: Sat, 08 Dec 2001 16:55:37 -0500
Thank you! I shall try that out...
Now, when I'm trying to get _C++_ functions using CFBundle, GCC adds the
crap at the end (such as _foo_Fv) (I assume this is for polymorphism)...
I've been using
extern "C" {
// prototypes
}
To remedy this, but it seems kinda hackish. Is there a better way to do
this?
On 12/8/01 1:51 AM, "Bill Bumgarner" <email@hidden> wrote:
>
( *sigh* People-- *please* stop assuming that the API you prefer -- Carbon,
>
Cocoa, Java, whatever -- is the *only* way to do things or the *right*
>
way to do things. In particular, *please* stop assuming that because
>
someone is doing it some other way, they must be wrong or ignorant... OS X
>
is a whole lot bigger than OS 9, OpenStep, or JDK/Swing -- there are lots
>
of options and people are going to do things in ways you may not agree
>
with, but are perfectly correct. Sarcasm, arrogance, and responses like
>
'RTFM: open your eyes, it is damned obvious' don't help anyone. )
>
>
For Mach-O files-- I believe NSBundle only loads Mach-O's?-- one can use
>
the NSModule API to grab a pointer to C functions. See the man page for
>
NSModule; in particular the various NSLookup* functions. I believe
>
NSLookupAndBindSymbol() will do what you want once the NSBundle has been
>
loaded -- you can force loading of the NSBundle by invoking the -load
>
method, checking the return type to see if it loaded successfully.
>
>
Once you find the NSSymbol that you are looking for, NSAddressOfSymbol()
>
will turn it into an address and you can go from there.
>
>
If I remember correctly, gcc effectively prepends an underscore to all
>
symbols. So, if you need to call the function 'initialize_foo_module' in
>
the newly loaded bundle, it would look something like:
>
>
aSymbol = NSLookupAndBindSymbol("_ initialize_foo_module");
>
funcPtr = NSAddressOfSymbol(aSymbol);
>
>
returnValue = funcPtr(foo, bar, baz);
>
>
... or something like that ...
>
>
I may have missed a couple of '*'s in that and, certainly, a bit of error
>
checking would be prudent.
>
>
There may be API in the core foundation that covers some of this? I'm not
>
sure-- I do know that there is a plug in architecture over in the Carbon
>
world that may come into play if you are dyna-loading CFM binaries, but I
>
don't think it is applicable to mach-o.
>
>
b.bum
>
>
On Saturday, December 8, 2001, at 01:27 AM, email@hidden.
>
com wrote:
>
>
> What if I need to get a specific C function to call? I should use
>
> CFBundle's
>
> functions in this case? I've used NSBundle before invoking ObjC methods,
>
> but
>
> this time I want a set of C functions.
>
>
>
b.bum
>
I ride tandem with the random....
>
.... things don't happen the way I planned them.
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
ectonot post admin requests to the list. They will be ignored.