Ok, that worked. Thanks.

Hmm, how come that I couldn't find any documentation about this? All I found was a little example code on a japaneese internet site where you couldn't read anything except the code snippet itself. :) This was, as you said, an old example with CBPerlObject but it gave me a hint how to begin at all with that.
Or maybe I am just incapable of searching in the internet. ;)
I figured CamelBones is pretty nice, not only for doing complete Perl- Cocoa applications for which a lot of examples exist.

Ok, another question.
I guess the Xcode codesence is not working for any Perl classes and methods, right? And can I somehow get rid of the warning message from gcc that the object xxx might not respond to method yyy if calling a method of a Perl class?

Manfred



Am 27.10.2005 um 13:02 schrieb Sherm Pendley:

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



Reply via email to