diff --git a/SWIG/Lib/swig.swg b/SWIG/Lib/swig.swg index 7d498a092..07b3a18f7 100644 --- a/SWIG/Lib/swig.swg +++ b/SWIG/Lib/swig.swg @@ -154,38 +154,40 @@ /* aggregation support */ /* - This macro performs constant aggregation. Basically the idea of - constant aggregation is that you can group a collection of constants - together. For example, suppose you have some code like this: + This macro performs constant aggregation. Basically the idea of + constant aggregation is that you can group a collection of constants + together. For example, suppose you have some code like this: #define UP 1 #define DOWN 2 #define LEFT 3 #define RIGHT 4 - Now, suppose you had a function like this: + Now, suppose you had a function like this: int move(int direction) - In this case, you might want to restrict the direction argument to one of the supplied - constant names. To do this, you could write some typemap code by hand. Alternatively, - you can use the %aggregate_check macro defined here to create a simple check function - for you. Here is an example: + In this case, you might want to restrict the direction argument to + one of the supplied constant names. To do this, you could write some + typemap code by hand. Alternatively, you can use the + %aggregate_check macro defined here to create a simple check + function for you. Here is an example: - %aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT); + %aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT); - Now, using a typemap + Now, using a typemap - %typemap(check) int direction { - if (!check_direction($1)) SWIG_exception(SWIG_ValueError,"Bad direction."); - } + %typemap(check) int direction { + if (!check_direction($1)) SWIG_exception(SWIG_ValueError,"Bad direction."); + } - or a contract (better) + or a contract (better) + + %contract move(int x) { + require: + check_direction(x); + } - %contract move(int x) { - require: - check_direction(x); - } */ %define %aggregate_check(TYPE, NAME, FIRST, ...) @@ -238,7 +240,7 @@ static int NAME(TYPE x) { %define %isdestructor match="destructor" %enddef %define %isnamespace match="namespace" %enddef %define %istemplate match="template" %enddef -%define %isconstant match="constant" %enddef +%define %isconstant match="constant" %enddef /* %constant definition */ %define %isunion match$kind="union" %enddef %define %isfunction match$kind="function" %enddef