171
190
void move(SomeObject *, int direction, int distance);
175
195
One thing you might want to do is impose a constraint on the direction parameter to
176
196
make sure it's one of a few accepted values. To do that, SWIG provides an easy to
177
197
use macro %aggregate_check() that works like this:
181
202
%aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT);
185
207
This merely defines a utility function of the form
189
212
int check_direction(int x);
193
217
That checks the argument x to see if it is one of the values listed. This utility
194
218
function can be used in contracts. For example:
198
223
%aggregate_check(int, check_direction, UP, DOWN, RIGHT, LEFT);