Import a GNU Smalltalk project into Pharo?

I have about 1800 lines of GNU Smalltalk code that I would like to take in Pharo. I started doing it in class, selector in selector, but it is very laborious and tedious.

Is there a way to mass import a project? I could easily customize the GST source file format with vi to be more Pharo-like in advance.

Another thing I looked at was copying the "start" .mcz file, getting the format of the source.st file, and then creating a new source.st with the cat and vi file. But then there is a snapshot.bin file, which seems to also have a source in it, which makes this the hard way. There seems to be an easier way. I have google'd for him with different phrases but nothing hit.

+5
source share
2 answers

Putting it in the Monticello format (.mcz) is unnecessary for migration. Just upload it to a file format ( http://wiki.squeak.org/squeak/1105 ), and once you upload it to Pharo via a file, you can create the Monticello package using the graphical interface if you want.

A quick way to see which file format includes (basically, just put "!" In the right places):

  • Download Pharo
  • Open browser
  • Right-click on the class and select "File Out" from the menu.
  • You should see a file named [Classname] .st in the directory in which you launched Pharo from
+7
source

Let's say you have two classes, LuckyClass1 a subclass of the Object subclass and LuckyClass2 LuckyClass1 . And let your name be LuckyName . And let them say that you want to put your code in Lucky-Package1 .

 Object subclass: #LuckyClass1 LuckyClass1 subclass: #LuckyClass2 

LuckyClass1 class with instance side method luckyInstanceSideMethod1 , class side method luckyClassSideMethod1 and instance side variable luckyInstanceSideVariable1 and class variable LuckyClassSideVariable1 .

Similarly, the LuckyClass2 class with the luckyInstanceSideMethod1 instance luckyInstanceSideMethod1 method, the luckyClassSideMethod1 class side method and the luckyClassSideMethod1 additional instance luckyInstanceSideVariable2 variable and the LuckyClassSideVariable2 class LuckyClassSideVariable2 .

Method references will look like this:

 LuckyClass1>>#luckyInstanceSideMethod1 LuckyClass1 class>>#luckyClassSideMethod1 LuckyClass2>>#luckyInstanceSideMethod1 LuckyClass2 class>>#luckyClassSideMethod1 

On Linux / Mac OS X, run

vi Lucky-Package1-unix.st

to insert a file called Lucky-Package1-unix.st something like

 Object subclass: #LuckyClass1 instanceVariableNames: 'luckyInstanceSideVariable1' classVariableNames: 'LuckyClassSideVariable1' poolDictionaries: '' category: 'Lucky-Package1'! !LuckyClass1 methodsFor: 'lucky instance side protocol 1' stamp: 'LuckyName 6/8/2016 17:05'! luckyInstanceSideMethod1 ^ luckyInstanceSideVariable1 := 'lucky instance side' ! ! !LuckyClass1 class methodsFor: 'lucky class side protocol 1' stamp: 'LuckyName 6/8/2016 17:06'! luckyClassSideMethod1 ^ LuckyClassSideVariable1 := 'lucky class side' ! ! LuckyClass1 subclass: #LuckyClass2 instanceVariableNames: 'luckyInstanceSideVariable2' classVariableNames: 'LuckyClassSideVariable2' poolDictionaries: '' category: 'Lucky-Package1'! !LuckyClass2 methodsFor: 'lucky instance side protocol 1' stamp: 'LuckyName 6/8/2016 17:15'! luckyInstanceSideMethod1 ^ super luckyInstanceSideMethod1, ' subclass' ! ! !LuckyClass2 class methodsFor: 'lucky class side protocol 1' stamp: 'LuckyName 6/8/2016 17:17'! luckyClassSideMethod1 ^ super luckyClassSideMethod1, ' subclass' ! ! 

In fact, you can cut and paste the previous block.

Then convert line feeds to carriage returns, otherwise Pharo will complain. It is important. If you are running Linux / Mac OS X, you can use the following

 cat Lucky-Package1-unix.st | tr \\n \\r > Lucky-Package1-pharo.st 

On Windows, I will still use bash, vi, cat, tr from git -scm https://git-scm.com/download/win

Then the file in Lucky-Package1-pharo.st . It should appear in the Lucky-Package1 package in the system browser.

+2
source

All Articles