This is an exporter from pharo source code to visualworks file with extention ".st"
You will need pharo5 up and visualworks 7.4 up
In pharo playground execute the next piece of code
Gofer it
smalltalkhubUser: 'ObjectProfile' project: 'Pharo2VW';
package: 'Pharo2VW';
load.
In your playground execute the next piece of code
Pharo2VW exporter
environment: 'MySpaceInVW';
package: 'Pharo2VW';
export.
This will create file MySpaceInVW.st
in your pharo working directory. The file contains is an xml format that visualworks can open to load source code.
In the next example try to change the output directory with the selector: directory:
, or define the external namespaces that your software needs to run. Also you can define what methods of your package tags, you do not want to export.
Pharo2VW exporter
directory: FileSystem disk workingDirectory/'exports';
environment: 'MySpaceInVW';
externalNamespaces: {'Roassal2'};
methodsBlacklist: {Pharo2VWExamples >> #example02};
package: 'Pharo2VW';
export.
Visualworks do not have the same array notation for {}. Then you need to change your code to avoid these symbols. You can use the exporter to dectect the methods that containts this array definition with checkForArrays
. By other hand showMethodsWithArray: true
will open a browser in pharo for each method that use {}
Pharo2VW exporter
environment: 'MySpaceInVW';
externalNamespaces: {'Roassal2'};
methodsBlacklist: {Pharo2VWExamples >> #example03. Pharo2VWExamples >> #example02};
package: 'Pharo2VW';
showMethodsWithArray: true;
checkForArrays;
export.
After you get the file MySpaceInVW.st
you can load it into a visualworks image
- In this example, create a bundle called
MyBundle
, and add the packageMyPackage
in that bundle - For
MyPackage
, rightclick then select the optionFile into...
. - Select the file
MySpaceInVW.st
and load it. - If you get some error loading the file. Delete the loaded code, and fix the problem in pharo. (Common errors: your code have '{}', or your code have '..', etc )
- At this point your code is loaded in visualworks all classes in the same package. Probably now you need the classes have the same package organization. In that case try to use the next piece of code.
| main classes cat pkg |
main := Registry bundleNamed: 'MyBundle'.
classes := main allClasses.
packages := Dictionary new.
classes do: [ :cls |
cat := cls myClass category asString.
pkg := packages at: cat ifAbsentPut: [ | p |
p := Registry packageNamedOrCreate: cat.
main addItem: p.
p ].
XChangeSet current moveWholeClass: cls toPackage: pkg
- Run the tests, you need to have many tests to ensure that you code works well in Visualworks like in pharo
- In some cases you will need code that not exists in pharo. In that case you can create class extentions. In this example maybe we need to have a particular method of
Color
from pharo inColorValue
the color class in visualworks. So we can create an extention. - Create the package
MyPackage-extentions
then rightclick in the class area, and selectadd class extention
for classColorValue
. With extentions you can add or override existing methods in visualworks, please try to avoid overrides. - In case that you need a different class of visualworks like
DateAndTime
in pharo, but for visualworks that class isTimestamp
. Maybe you will need a classPlatform
in order to idenfify when your system is running in pharo or in visualworks, to use the correct classes. - In case that you need to update your code. You will need to delete all the code and packages(except extentions) and load the process again. For that case use this example script.
| b notremove |
notremove := OrderedCollection new.
notremove add: 'MyPackage-extentions'.
b := Registry bundleNamed: 'MyBundle'.
b leafItems do: [ :pkg |
(notremove includes: pkg name) ifFalse: [
pkg doUnloadFromImage.
].
- In visualworks check that your source code do not have refereces to undefined objects, you can check this in you bundle tab
Prerequisites
- At this points, you have correct extentions, your classes are in the correct package, your tests are green, and you do not have references to undefined objects. Now you can upload you code to the public repository. Finally last point is check the bundle load order. you can see that in
Bundle Structure
tab. Try you use the next example to set the load order of your packages.
b := Registry bundleNamed: 'MyBundle'.
list := b containedItems.
r := list select: [:d | d name = 'MyPackage-extentions'].
list remove: r first.
list add: r first.
b containedItems: list.
- Now publish your code and drink a glass of beer!!
Browse the Pharo2VWExamples
in your system browser to get more examples
Use test runner to execute the tests. Pharo2VWExporterTest
execute all the examples in Pharo2VWExamples
We use Smalltalkhub for versioning. For the versions available, see the Pharo2VW.
This project is licensed under the MIT License - see the LICENSE.md file for details
Feel free to add issues if you wish to have some requestion for enhancement, bug fixes, or bug description. You can get in touch with us on discord (instruction on http://pharo.org/community), channel #Roassal