On Oct 26, 2005, at 10:27 PM, Manfred Bergmann wrote:
Am 27.10.2005 um 11:50 schrieb Sherm Pendley:
CBPerl is a singleton, so it's better to use the class method to
access the shared instance:
CBPerl *perl = [CBPerl sharedPerl];
That doesn't work here. Get a nil pointer returned.
I forgot a recent addition, sorry. Should be:
#import <CamelBones/AppMain.h>
[CBPerl stubInit: CBGetPerlArchver()];
CBPerl *perl = [CBPerl sharedPerl];
id perlO = [[NSClassFromString(@"SomePerl") alloc] init];
Note that perlO is typed as "id". That's necessary because the
compiler doesn't know about the SomePerl class at compile time.
The call to NSClassFromString() is needed for the same reason.
That either returns a nil pointer. Where does the ObjC runtime
system look for the SomePerl.pm file.
As far as the ObjC runtime goes, if a class hasn't yet been
registered, it calls a CamelBones "class handler" function. That
function tries to do an ordinary "use ClassName" to try to load and
register the class. That "use" looks in the standard @INC.
When CamelBones starts up, it adds the Resources/ sub-directories of
all linked frameworks and bundles (including the .app bundle) to
@INC, and platform- and version- specific subdirectories under that.
For instance, on Tiger it would add:
Resources/
Resources/5.8.6/
Resources/5.8.6/darwin-thread-multi-2level/
This is repeated whenever a new bundle is loaded by way of NSBundle
methods - any Objective-C classes in the bundle are automatically
wrapped to be visible from Perl, and the bundle's Resources/ sub-
directory is added to @INC.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org