Re: How to make a plugin?
Re: How to make a plugin?
- Subject: Re: How to make a plugin?
- From: Georg Tuparev <email@hidden>
- Date: Thu, 26 Jul 2001 11:37:53 +0200
Hey Rainer,
Here some comments and questions. BTW, did you received private replays
you your questions? will be interested to know them...
On Friday, July 20, 2001, at 03:01 AM, Rainer Brockerhoff wrote:
>
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
>
// iterate over all ".plugin" bundles in the "Plugins" folder
>
NSEnumerator *enumerator = [[NSBundle
>
pathsForResourcesOfType:@"plugin"
>
inDirectory:[[NSBundle mainBundle] builtInPlugInsPath]]
>
objectEnumerator];
>
Is the @"plugin" in pathsForResourcesOfType a magic ID? I could not see
documentation on this. What are the other magic IDs?
>
>
OK, this all works very well. But there are still some unsolved issues.
>
>
1) If I decide not to use a certain plugin anymore, I can deallocate
>
the instantiated object... but I found no way to close the bundle and
>
everything inside it as a whole. (I may even want to erase it entirely.)
>
Any hints?
>
I was doing this on NeXTstep. You can unload a class, but is a tricky
stuff. There should be no holes in the class stack. Did not tried it on
OSX though...
>
2) Should a plugin writer use a class name which has already been used
>
by the application (or by another plugin),
>
[plugb principalClass]
>
returns nil. OK, the new plugin won't get installed, but a long and
>
detailed error message is written to the console log, stating that the
>
class already exists.
>
I found no 100% reliable way of obtaining the bundle's principal class
>
name without calling principalClass and getting the error message. Yes,
>
I could call
>
[[plugb infoDictionary] objectForKey:@"NSPrincipalClass"]
>
but if the plugin's author didn't define it for some reason, the first
>
class in the executable is used - and I don't know how to get at that.
>
Again, you can query the runtime system. Check the objc.h & co. files
for different functions...
>
3) Even should I find out the principal class' name, how do I call the
>
ObjC runtime to check if this classname is already in use without
>
hitting a runtime error?
see the comment above. I hope there are better ways now for OSX, but I'm
sure is doable.
regards
Georg Tuparev
Tuparev Technologies
Klipper 13
1186 VR Amstelveen
The Netherlands
Mobile: +31-6-55798196