Re: Bundle loading
Re: Bundle loading
- Subject: Re: Bundle loading
- From: Chris Ridd <email@hidden>
- Date: Thu, 22 Aug 2002 13:51:12 +0100
On 22/8/02 1:22 pm, Pierre-Olivier Latour <email@hidden> wrote:
>
> Does loading a bundle in cause any code to get executed in the bundle
>
> automatically, or any other kind of automatic initialization?
>
>
>
> Basically if I write a bundle, how do I make sure that some kind of
>
> initialization that I may require happens?
>
>
>
> The docs are pretty unclear on this, as they seem to be mostly written from
>
> the point of view of the code loading the bundle in.
>
>
I suppose you intend to put Obj-c classes inside this bundle. Then, you can
>
use the +initialize method of the class. Is it called only once, not when
>
the code is loaded, but before any method of the class gets called.
I'm expecting the bundle to contain classes and also some C functions. The
caller is a C app which is calling my C functions. Thanks for reminding me
about +initialize though :-)
>
As far as I know, Mach-o libraries do not define an initialization routine
>
and a termination routine, contrary to CFM libraries.
Hm, the man page for ld(1) suggests you're wrong (I hadn't read this
earlier.) Near the end:
-init sym
The argument sym is taken to be the symbol name of
the dynamic shared library initialization routine.
If any module is used from the dynamic library the
library initialization routine is called before any
symbol is used from the library including C++
static initializers (and #pragma CALL_ON_MOD-
ULE_BIND routines).
-run_init_lazily
Mark the dyanmic library to have its library ini-
tialization routine and module initialization rou-
tines run lazily via catching memory faults to its
writeable segments. The library's initialization
routine must not have any side effects that cause
semantic differences as to when its initialization
routine is run.
There doesn't seem to be an 'unload' routine at all, but maybe I can use
something like atexit() to get a chance to clean things up before the plug
gets pulled.
Cheers,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.