Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PerlObjCBridge

PerlObjCBridge
Thread Tools
Fresh-Faced Recruit
Join Date: Jan 2002
Location: Oslo/Norway
Status: Offline
Reply With Quote
Jan 25, 2002, 12:09 PM
 
I was looking at the 10.2 stuff that was posted. In the file of the /Library content I noticed this:

/Library/Perl/darwin/auto/PerlObjCBridge
/Library/Perl/darwin/auto/PerlObjCBridge/.packlist
/Library/Perl/darwin/auto/PerlObjCBridge/autosplit.ix
/Library/Perl/darwin/auto/PerlObjCBridge/PerlObjCBridge.bs
/Library/Perl/darwin/auto/PerlObjCBridge/PerlObjCBridge.bundle
/Library/Perl/darwin/Bom.pm
/Library/Perl/darwin/Foundation.pm
/Library/Perl/darwin/PerlObjCBridge.pm

Does this mean we get a perl coco bridge at last?

[ 01-25-2002: Message edited by: Kjartan Holmen ]
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Jan 25, 2002, 01:21 PM
 
well, you already got one if you want.

it's quite simple: create your perl scripts, put them in your app's bundle and then use <font face = "courier"> [[NSBundle bundleForClass:[self class]] pathForResource:@"&lt;nameofyourperlscript& ;gt;" ofType:@""] </font> to locate them and use an nstask to get their output.

works well for me...

edit: had messed up the ubb tags.

[ 01-25-2002: Message edited by: seb2 ]
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Jan 25, 2002, 01:22 PM
 
please ignore.

[ 01-25-2002: Message edited by: seb2 ]
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jan 25, 2002, 02:16 PM
 
Originally posted by Kjartan Holmen:
<STRONG>I was looking at the 10.2 stuff that was posted. In the file of the /Library content I noticed this:

/Library/Perl/darwin/auto/PerlObjCBridge
/Library/Perl/darwin/auto/PerlObjCBridge/.packlist
/Library/Perl/darwin/auto/PerlObjCBridge/autosplit.ix
/Library/Perl/darwin/auto/PerlObjCBridge/PerlObjCBridge.bs
/Library/Perl/darwin/auto/PerlObjCBridge/PerlObjCBridge.bundle
/Library/Perl/darwin/Bom.pm
/Library/Perl/darwin/Foundation.pm
/Library/Perl/darwin/PerlObjCBridge.pm

Does this mean we get a perl coco bridge at last?

[ 01-25-2002: Message edited by: Kjartan Holmen ]</STRONG>
I wouldn't be too sure, I mean, it could just be some stuff left over from XBS (the OS X build system) that isn't meant for public consumption.
     
qyn
Dedicated MacNNer
Join Date: Dec 2000
Location: sj ca
Status: Offline
Reply With Quote
Jan 25, 2002, 03:02 PM
 
Did anyone look inside the PerlObjCBridge.bs or PerlObjCBridge.pm files? That'll tell us what can and can't be done.

I'm at work now so I can't look, but when I get home I'm going to give them a whirl!
     
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status: Offline
Reply With Quote
Jan 28, 2002, 03:47 AM
 
Originally posted by seb2:
<STRONG>it's quite simple: create your perl scripts, put them in your app's bundle and then use &lt;font face = "courier"&gt; [[NSBundle bundleForClass:[self class]] pathForResource:@"&lt;nameofyourperlscript& ;gt;" ofType:@""] &lt;/font&gt; to locate them and use an nstask to get their output.

works well for me... </STRONG>
Hold it... would that work for any language?

I always thought the Perl/Cocoa bridge was supposed to be just that - writing Cocoa applications using Perl. Which would be cool.
All words are lies. Including these ones.
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Jan 28, 2002, 07:47 AM
 
pretty much, i guess. i mean, in the end, a perl script is not very different from other command line tools in the respect that they can take arguments and can write output to standard output or to standard error.

this is how i did the case insensitive locate in locator, works quite well.

as long as &lt;insert name of language here&gt; behaves like that, it really shouldn't be a problem to get its output using nstask.

of course, things get more complicated when there's more going on than just passing some argument and then reading the output, that is, "real interaction" with the shell tool / script, but it's possible. in that case, working with temp files might be the easier (probably not most elegant) solution.

it's just a matter of trial and error, i found out about that by experimenting myself, but i was pleasantly surprised that it works so well.

if you have any questions, feel free to ask.
     
qyn
Dedicated MacNNer
Join Date: Dec 2000
Location: sj ca
Status: Offline
Reply With Quote
Jan 28, 2002, 03:50 PM
 
Originally posted by seb2:
[QB]
of course, things get more complicated when there's more going on than just passing some argument and then reading the output, that is, "real interaction" with the shell tool / script, but it's possible. in that case, working with temp files might be the easier (probably not most elegant) solution.
QB]
Actually, embedding the whole perl interpreter in your ObjC code is not that difficult. (Note: I've only personally done that in C++, never ObjC.) More difficult than nstask, to be sure, but you get full interaction. Pretty slick for certain tasks.

What the PerlObjCBridge seems to be about is invoking ObjC from Perl, which seems more interesting to me. I'd really like to give it a try. But I need to get 10.2 first...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:04 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2