stsh (was: Scripting languages and IDEs)

Marcel Weiher marcel at metaobject.com
Fri Aug 25 09:42:23 UTC 2006


On Aug 24, 2006, at 21:39 , Damien Pollet wrote:

> On 8/24/06, Marcel Weiher <marcel at metaobject.com> wrote:
>> Interesting discussion, as I have been wrestling with this very issue
>> in my Objective-Smalltalk / stsh work for some time now.
>
> can we play with stsh ? besides systrace shell google only found a
> mail from you :)

As it happens, I created an internal 'release' package the other day  
just before I stumbled on this thread.  The package can be found at:

	http://www.metaobject.com/downloads/Misc/stsh.tgz

This is not even a pre-release, binary only, only runs on Mac OS X  
(Tiger) and also comes with not documentation whatsoever, not even a  
Readme!  That said, I have been using it myself and it has proven  
quite useful.

Contents of the tar are a couple of frameworks that need to be put in  
a frameworks place ( /Library/Frameworks/ or ~/Library/Frameworks/ )  
and the stsh executable itself, which is probably best place in /usr/ 
local/bin/ .

As Smalltalkers, you will probably miss the Smalltalk class  
libraries:  they aren't there.  It's Objective-C and Cocoa underneath.

So it's NSArrays, NSStrings, and NSDictionaries, as well as those  
protocols:

 > 'Hello World' class.
NSCFString


Of course, that isn't all bad.  You have Foundation, AppKit, QTKit  
(QuickTime), WebKit, CoreImage and friends to play with.

Here is an example script, it uses QuickTime to concatenate a bunch of  
movies:

--------------- qtcat --------------------
#!/usr/local/bin/stsh

#---  load a framework we weren't linked against

qtkit := NSBundle bundleWithPath:'/System/Library/Frameworks/ 
QTKit.framework'.
qtkit load.

#---  command line parameters are passed in "args"

movieArgs := args.

#---  Objective-Smalltalk will convert a string to an Objective-C  
selector (SEL)

movieArgs := movieArgs sortedArrayUsingSelector:'numericCompare:'.

#---  Higher Order Messaging works...(what did you expect?!)

movies:=QTMovie collect movieWithFile:movieArgs each error:nil.
firstMovie := movies objectAtIndex:0.
restMovies := movies subarrayWithRange:(1 to:movies count-1).

#---   we will append the rest of the movies to the first movie,
#---   so we have to make that one editable.

firstMovie setAttribute:1 forKey:'QTMovieEditableAttribute'.

#----   Movie editing in QTKit is based on selections, so we
#----   have to do a 'select all' by getting the total range
#----   and then

ranges := restMovies collect movieAttributes collect  
objectForKey:'QTMovieActive
SegmentAttribute'.
0 to: restMovies count - 1 do: [ :i | (restMovies objectAtIndex:i)  
setSelection:
(ranges objectAtIndex:i) ].

#----	   now do the append.

firstMovie do appendSelectionFromMovie:restMovies each.

#----  figure out a good name for the result

outName := (movieArgs objectAtIndex:0) stringByDeletingPathExtension.
outName := outName stringByAppendingString:'-full.mov'.
outputAttributes := NSMutableDictionary dictionary.

#----  flattening would be nicer, because then you don't have to keep  
the
#----  original files around, but sometimes doesn't work

#outputAttributes setObject:1 forKey:'QTMovieFlatten'.

#----  write the result

firstMovie writeToFile:outName withAttributes:outputAttributes.
#NSFileManager defaultManager do removeFileAtPath:movieArgs each  
handler:nil.

--------------- qtcat --------------------

Flames, comments, suggestions welcome.

And yes, there will be a real release, but I want to get the native  
code compilation a bit more complete than it is at the moment.

Marcel




More information about the Squeak-dev mailing list