Consistent formatting of example code in the docs
This commit is contained in:
parent
129ef8ea8f
commit
268b942865
25 changed files with 1705 additions and 1714 deletions
|
|
@ -51,9 +51,9 @@ is a simple example:
|
|||
<pre>
|
||||
%contract sqrt(double x) {
|
||||
require:
|
||||
x >= 0;
|
||||
x >= 0;
|
||||
ensure:
|
||||
sqrt >= 0;
|
||||
sqrt >= 0;
|
||||
}
|
||||
|
||||
...
|
||||
|
|
@ -106,20 +106,20 @@ The <tt>%contract</tt> directive can also be applied to class methods and constr
|
|||
<pre>
|
||||
%contract Foo::bar(int x, int y) {
|
||||
require:
|
||||
x > 0;
|
||||
x > 0;
|
||||
ensure:
|
||||
bar > 0;
|
||||
bar > 0;
|
||||
}
|
||||
|
||||
%contract Foo::Foo(int a) {
|
||||
require:
|
||||
a > 0;
|
||||
a > 0;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
Foo(int);
|
||||
int bar(int, int);
|
||||
Foo(int);
|
||||
int bar(int, int);
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -133,7 +133,7 @@ Thus, any contract that you specified for a base class will also be attached to
|
|||
<pre>
|
||||
class Spam : public Foo {
|
||||
public:
|
||||
int bar(int,int); // Gets contract defined for Foo::bar(int,int)
|
||||
int bar(int,int); // Gets contract defined for Foo::bar(int,int)
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -146,22 +146,22 @@ In addition to this, separate contracts can be applied to both the base class an
|
|||
<pre>
|
||||
%contract Foo::bar(int x, int) {
|
||||
require:
|
||||
x > 0;
|
||||
x > 0;
|
||||
}
|
||||
|
||||
%contract Spam::bar(int, int y) {
|
||||
require:
|
||||
y > 0;
|
||||
y > 0;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
int bar(int,int); // Gets Foo::bar contract.
|
||||
int bar(int,int); // Gets Foo::bar contract.
|
||||
};
|
||||
|
||||
class Spam : public Foo {
|
||||
public:
|
||||
int bar(int,int); // Gets Foo::bar and Spam::bar contract
|
||||
int bar(int,int); // Gets Foo::bar and Spam::bar contract
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -225,7 +225,7 @@ function can be used in contracts. For example:
|
|||
|
||||
%contract move(SomeObject *, int direction, in) {
|
||||
require:
|
||||
check_direction(direction);
|
||||
check_direction(direction);
|
||||
}
|
||||
|
||||
#define UP 1
|
||||
|
|
@ -246,7 +246,7 @@ Alternatively, it can be used in typemaps and other directives. For example:
|
|||
%aggregate_check(int, check_direction, UP, DOWN, RIGHT, LEFT);
|
||||
|
||||
%typemap(check) int direction {
|
||||
if (!check_direction($1)) SWIG_exception(SWIG_ValueError, "Bad direction");
|
||||
if (!check_direction($1)) SWIG_exception(SWIG_ValueError, "Bad direction");
|
||||
}
|
||||
|
||||
#define UP 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue