33.9. Parameter Block Implementation

The parameters function in the binding for scripts loaded by abuild's Groovy backend is actually a closure returned by ParameterHelper.createClosure. This function takes a closure as an argument. In order to make things that look like assignments inside that closure modify abuild parameters, the parameters call changes the delegate of the closure to an instance of ParameterHelper helper class constructed with a reference to the abuild object, an instance of BuildState. Within ParameterHelper, the get, set, and leftshift methods are overridden to result in fields being translated into ParameterHelper objects which, when assigned to or appended to, relay the action through appropriate calls in BuildState, which implements the Parameterized interface. The code is relatively small. For additional details, please find ParameterHelper.groovy and Parameterized.groovy in abuild's source code and look at the parameter-helper test suite.