Version 16 (modified by 13 years ago) ( diff ) | ,
---|
Macro Support for Squeak
Macros is a framework which provides compile-time macros for Squeak. It is primarily focused on macros that need to generate additional methods or check constraints. Basic integration with OmniBrowser and the Squeak Debugger is provided.
How to Install
Environment | |
4.1, 4.2 | |
Any | |
Any | |
Sources | |
ConfigurationOfMacros | |
Macros | |
CTM
| |
OmniBrowser optional | |
Misc | |
Macros@SqueakSource |
Use the Metacello configuration or just load the CTM
package. If you also want OmniBrowser support, load the XXX
package, too.
You can find the following categories in the packages:
CTM-Core
- core implemenation including the event listener
CTM-Operations
- supported operations, currently those for methods
CTM-Tests
- some basic tests, all should pass
CTM-Examples
- basic macros, see the class documentation of each for details
How to Use
Applying Macros
Creating New Macros
To create a macro you have to extend the CTMMacro
class. The first thing to do is to decide on which pragmas the macro should listen. You need to implement at least one of those two methods:
matchMethodPragma:
aPragma- This should return true if the macro wants to process a method annotated with aPragma or false otherwise. Additionally the method can be used to store additional information that are found in the pragma, e.g. pragma parameters.
matchClassPragma:
aPragma- Same as matchMethodPragma: but for classes and their pragmas.
Depending on the use-case and the decision you made above, implement one or more of the following methods which are called when an event in a relevant entity occurs:
methodAdded:
aMethodin:
aClassmethodCompiled:
aCompiledMethodin:
aClassfrom:
anOldCompiledMethodOrNilmethodModified:
aMethodin:
aClassfrom:
anOldMethodmethodRemoved:
aMethodin:
aClass- Those are called if a method event occurred.
classAdded:
aClassclassCompiled:
aClassfrom:
anOldClassOrNilclassModified:
aClassfrom:
anOldClassclassRemoved:
aClass- Those are called if a class event occurred.
To perform actions on the classes and methods related to the entity in the event, the methods should return a collection of CTMOperation
elements. At this time, only method operations are implemented. You can add methods to classes or remove them using the following operation constructors:
CTMMethodOperation class>>add:
aSelectorin:
aClassfor:
aClassOrMethodwith:
aSourceString- returns an operation to add a method to a class, the parameters should be self-explanatory
CTMMethodOperation class>>remove:
aSelectorin:
aClass- removes a method from a class in the same way
How to Extend
Internal documentation. Show models, explain the architecture. Do anything that may help a new developer to extend this project.
Acknowledgments
To date, the following people contributed to this project:
- Michael Grünewald
- Stefan Richter