Plug-In strategy in Mach-O / Cocoa?
Plug-In strategy in Mach-O / Cocoa?
- Subject: Plug-In strategy in Mach-O / Cocoa?
- From: Pierre-Olivier Latour <email@hidden>
- Date: Sun, 03 Nov 2002 01:48:47 -0800
Hi,
I have an application which is basically a multi-platform C 3D engine with a
Cocoa interface built on top of it. The 3D engine functionalities are based
on plug-ins. So far, all plug-ins code are actually embedded in the
application executable code (these plug-ins form the default set of
plug-ins), but I want the possibility that external developers add their own
plug-ins.
Registering a plug-in with the 3D engine is just about calling this routine:
PSEError PSEPlugIn_RegisterFromProc(void* mainProc);
passing it the entry point of the plug-in code which should have this
prototype:
typedef PSEError (*PSEPlugInMainProc)(PSEPlugInCoreInfoPtr info);
I've read various documentations (CFPlugIns, Mach-O Runtime...) but I still
did not figure the easiest way to do my plug-in architecture with Mach-O /
ProjectBuilder, given the fact that my needs are extremely simple. Actually,
I'm seriously lost ;)
Basically here's what I would have done under OS 9 / CFM / CodeWarrior - I
would like to mirror this exactly but with Mach-O and Project Builder:
Dev kit for developers would have contained:
1) a stub CFM-library that contains only the necessary exported symbols from
the 3D engine (the fact that no code is present in the library prevent it to
be used in another program and also makes the dev kit extremely light).
2) the required set of C headers
To develop a plug-in, a developer would have simply created a shared-library
project that links to the stub library and imported the headers. The entry
point of the code fragment would have be the entry point of the plug-in code
(simple and clean).
On the application side, plug-ins would have been put in a PlugIns folder
inside the application's folder (plug-ins resources would have been put
inside the resource fork). Then at run time, I would have scanned this
folder, loaded each CFM shared library and extracted the shared library
entry point (as far as I remember, it's only one call in CFM for both
operations), and finally passed it to "PSEPlugIn_RegisterFromProc".
So, one file per plug-in with no need to export symbols from it, since I use
the CFM entry point as the plug-in entry point: easy and simple. Loading the
plug-ins is also extremely simple (2 lines of code - once you've located the
plug-in file).
What should I do in OS X? Use CFPlugIns which seem quite complicated? Use
basic bundles which multiplies the number of files and folders? Use simple
.dylib files - but I can't have any resources in that case?
On the other side, when I try to mirror my CFM strategy with Mach-O /
Project Builder, I encounter the following problems among other things:
1) how do you define the entry point of the library in PB?
2) how do you create a stub library in PB?
3) how do you get the entry point of the code contained in a CFBundle?
4) how do you specify which symbols should be exported when building a
library in PB? Trough #pragma export?
Thanks for any advice :)
_____________________________________________________________
Pierre-Olivier Latour email@hidden
Palo Alto, USA
http://www.pol-online.net
_______________________________________________
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.