Dolphin Store Porting Scripts
A porting script is a text file that contains transformation rules that can be used by Dolphin Store to load code from a VisualWorks Store code repository. There are several different types of transformation rules that can be used. This page contains the types of rules that are currently supported. The Glorp packages has a porting script for Glorp if you wish to view a real example.
You can use the code rewriter to make code changes before the methods are compiled:
'`@a numArgs' -> '`@a argumentCount'
Both the left and right hand sides of the code rewrite expression are Smalltalk strings. Inside the strings, you can use any rewrite expression that can be used by the Code Rewriter in the browser. The example above renames #numArgs messages to be #argumentCount messages.
If you use "-->" instead of "->" in the rewrite, then the search and replace expressions will be method expressions as if you had changed the "Match whole method?" option in the Code Rewriter.
To rename a class, you can use:
VWClassName -> DolphinClassName
This will rename the class when it is loaded and it will also rename all references to the class in the code.
Add instance variable
To add instance variables to a class definition when it is loaded, you can use:
+ClassName 'variable1 variable2'
This adds variable1 and variable2 to ClassName class.
To remove a class, you can use:
This removes the ClassName class so it will not be loaded.
To remove a method, you can use:
-ClassName>selector -ClassName class>classSelector
This removes the #selector method from the ClassName class and the #classSelector method from the ClassName metaclass.
Remove instance variable
To remove an instance variable from a class definition when it is loaded, you can use:
This removes variableName from the ClassName class.
Adding or redefining a method
To add a new method or change the source of an existing method, you can use:
'PackageName' ClassName>'category name'>instanceMethod ^3 zork!
This adds an #instanceMethod method to the ClassName class in the PackageName package that is categorized under the "category name" category. Similarly to the remove method, we can compile a metaclass method if we add " class" after the ClassName.
Remove or replace package
You can remove a package from loading in a bundle:
This omits the PackageName package when it is included in a bundle that is loaded.
You can also substitute a package when it is loaded:
-'PackageName' / 'C:\Directory\DolphinPackage.pac'
This loads the DolphinPackage.pac package instead of loading the code from Store. This is useful for GUI packages where it is easier to reimplement the code in Dolphin instead of trying to translate it.