Sake = Rake for Smalltalk?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Sake = Rake for Smalltalk?

francisco.j.garau
Stef,

For your Mac, you could ask Marcel Weiher a copy of his Smalltalk Shell
Script (stsh). He has demoed it at the last UK Smalltalk meeting and it
looks really cool. It is scripting language (like csh) but with Smalltalk
sintax. Also, very fast...

Here a couple of examples:

===
#!/usr/local/bin/stsh
# -- how the stsh framework runs an interactive command

vi:=MPWCommandFilter filterWithCommandNamed:'vi' args:NSArray array
target:stdout.
vi setIsTarget:0.
vi startRunning.

===

#!/usr/local/bin/stsh
#-- initialize a PDF document object with the file passed on the command
line

pdf:=MPWPDFFile alloc initWithPdfData:(NSData dataWithContentsOfFile:(args
objectAtIndex:1)).
pdf parseXrefTables.

#-- log a description of the pdf to the console (standard out )
stdout println:pdf.

#--  get the first page object from the pdf file, log it
page := (pdf pages objectAtIndex:0).
stdout println:page.

#--  get the 'content stream' of that page, resolving pdf indirect object
reference
content := (page objectForKey:'Contents') referencedValue.

#--  get the (decoded) data from the content stream (the content stream is
usually compressed)
data := content data.

#-- replace the content stream's encoded data with the uncompressed data
we just got
content setEncodedData:data.

#-- remove the filter that indicates this data is compressed
content setObject:nil forKey:'Filter'.

#-- replace the stream length with the uncompressed length
content dict setObject:(MPWPSInteger integer:data length)
forStringKey:'Length'.

#--  log the resulting dictionary / pdf object
stdout println:content.

#-- write the resulting PDF object
writer := MPWPDFWriter streamWithTarget:MPWPDFByteStream stream.
writer outputPDFFile:pdf.
writer close.
writer target target writeToFile:'out.pdf' atomically:1.


---
Francisco Garau
0207 777 1362 - x71362


This communication is for informational purposes only. It is not intended
as an offer or solicitation for the purchase or sale of any financial
instrument or as an official confirmation of any transaction. All market prices,
data and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries
and affiliates.

Reply | Threaded
Open this post in threaded view
|

Re: Sake = Rake for Smalltalk?

Diego Fernández
Thanks for the info... a search for: "Smalltalk Shell Script" in
google take me to this link:
http://www.smalltalk.org/articles/article_20040103a.html

On 4/27/06, [hidden email]
<[hidden email]> wrote:

> Stef,
>
> For your Mac, you could ask Marcel Weiher a copy of his Smalltalk Shell
> Script (stsh). He has demoed it at the last UK Smalltalk meeting and it
> looks really cool. It is scripting language (like csh) but with Smalltalk
> sintax. Also, very fast...
>
> Here a couple of examples:
>
> ===
> #!/usr/local/bin/stsh
> # -- how the stsh framework runs an interactive command
>
> vi:=MPWCommandFilter filterWithCommandNamed:'vi' args:NSArray array
> target:stdout.
> vi setIsTarget:0.
> vi startRunning.
>
> ===
>
> #!/usr/local/bin/stsh
> #-- initialize a PDF document object with the file passed on the command
> line
>
> pdf:=MPWPDFFile alloc initWithPdfData:(NSData dataWithContentsOfFile:(args
> objectAtIndex:1)).
> pdf parseXrefTables.
>
> #-- log a description of the pdf to the console (standard out )
> stdout println:pdf.
>
> #--  get the first page object from the pdf file, log it
> page := (pdf pages objectAtIndex:0).
> stdout println:page.
>
> #--  get the 'content stream' of that page, resolving pdf indirect object
> reference
> content := (page objectForKey:'Contents') referencedValue.
>
> #--  get the (decoded) data from the content stream (the content stream is
> usually compressed)
> data := content data.
>
> #-- replace the content stream's encoded data with the uncompressed data
> we just got
> content setEncodedData:data.
>
> #-- remove the filter that indicates this data is compressed
> content setObject:nil forKey:'Filter'.
>
> #-- replace the stream length with the uncompressed length
> content dict setObject:(MPWPSInteger integer:data length)
> forStringKey:'Length'.
>
> #--  log the resulting dictionary / pdf object
> stdout println:content.
>
> #-- write the resulting PDF object
> writer := MPWPDFWriter streamWithTarget:MPWPDFByteStream stream.
> writer outputPDFFile:pdf.
> writer close.
> writer target target writeToFile:'out.pdf' atomically:1.
>
>
> ---
> Francisco Garau
> 0207 777 1362 - x71362
>
>
> This communication is for informational purposes only. It is not intended
> as an offer or solicitation for the purchase or sale of any financial
> instrument or as an official confirmation of any transaction. All market prices,
> data and other information are not warranted as to completeness or accuracy and
> are subject to change without notice. Any comments or statements made herein
> do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries
> and affiliates.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Sake = Rake for Smalltalk?

Giovanni Corriga
In reply to this post by francisco.j.garau
Il giorno gio, 27/04/2006 alle 18.44 +0100,
[hidden email] ha scritto:
> Stef,
>
> For your Mac, you could ask Marcel Weiher a copy of his Smalltalk Shell
> Script (stsh). He has demoed it at the last UK Smalltalk meeting and it
> looks really cool. It is scripting language (like csh) but with Smalltalk
> sintax. Also, very fast...

There's also Susie (Scripting Using a Smalltalk Interpreter Engine) on
http://sourceforge.net/projects/susie/

        Giovanni


Reply | Threaded
Open this post in threaded view
|

Re: Sake = Rake for Smalltalk?

Marcel Weiher
In reply to this post by Diego Fernández
Hi folks,


On 27 Apr 2006, at 21:14, Diego Fernandez wrote:

> Thanks for the info... a search for: "Smalltalk Shell Script" in
> google take me to this link:
> http://www.smalltalk.org/articles/article_20040103a.html

Interesting, hadn't seen that yet.

Something like "make for/in Smalltalk" is something that's also been  
in the back of my mind for some time.  After all, make is really just  
a dependency maintenance package, which is really nothing but a one-
way constraint solver.

And a constraint solver is in many ways not that much different from  
other programming.  For example, one might imagine writing:

a ::= c +d.
a ::= c compileWith: d.

instead of:

a := c+d.
a := c compileWith: d.

and have the former mean "maintain the LHS as the RHS changes",  
whereas the latter just means "assign it now".

So, in an architectural view of things, we just add the "::="  
connector to our repertoire of architectural connectors and are  
(mostly) done.

In fact, I've already built a (very primitive) constraint solver, but  
it isn't integrated in this way yet.

Cheers,

Marcel