1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
%module contract
%warnfilter(802,813,833) C; /* C#, Java multiple inheritance */
#ifdef SWIGCSHARP
%ignore B::bar; // otherwise get a warning: `C.bar' no suitable methods found to override
#endif
%contract test_preassert(int a, int b) {
require:
a > 0;
b > 0;
}
%contract test_postassert(int a) {
ensure:
test_postassert > 0;
}
%contract test_prepost(int a, int b) {
require:
a > 0;
ensure:
test_prepost > 0;
}
%inline %{
int test_preassert(int x, int y) {
if ((x > 0) && (y > 0)) return 1;
return 0;
}
int test_postassert(int x) {
return x;
}
int test_prepost(int x, int y) {
return x+y;
}
%}
/* Class tests */
%contract Foo::test_preassert(int x, int y) {
require:
x > 0;
y > 0;
}
%contract Foo::test_postassert(int a) {
ensure:
test_postassert > 0;
}
%contract Foo::test_prepost(int a, int b) {
require:
a > 0;
ensure:
test_prepost > 0;
}
%contract Foo::stest_prepost(int a, int b) {
require:
a > 0;
ensure:
stest_prepost > 0;
}
%contract Bar::test_prepost(int c, int d) {
require:
d > 0;
}
%inline %{
class Foo {
public:
virtual ~Foo() { }
virtual int test_preassert(int x, int y) {
if ((x > 0) && (y > 0)) return 1;
return 0;
}
virtual int test_postassert(int x) {
return x;
}
virtual int test_prepost(int x, int y) {
return x+y;
}
static int stest_prepost(int x, int y) {
return x+y;
}
};
class Bar : public Foo {
public:
virtual int test_prepost(int x, int y) {
return x+y;
}
};
%}
/* Multiple inheritance test */
%contract A::foo(int i, int j, int k, int l, int m) {
require:
i > 0;
j > 0;
ensure:
foo > 0;
}
%contract B::bar(int x, int y, int z, int w, int v) {
require:
w > 0;
v > 0;
ensure:
bar > 0;
}
%contract C::foo(int a, int b, int c, int d, int e) {
require:
c > 0;
d > 0;
ensure:
foo > 0;
}
%contract D::foo(int, int, int, int, int x) {
require:
x > 0;
}
%contract D::bar(int a, int b, int c, int, int) {
require:
a > 0;
b > 0;
c > 0;
}
%inline %{
class A {
public:
virtual ~A() {}
virtual int foo(int a, int b, int c, int d, int e) {
if ((a > 0) && (b > 0) && (c > 0) && (d > 0) && (e > 0)) {
return 1;
}
return 0;
}
};
class B {
public:
virtual ~B() {}
virtual int bar(int a, int b, int c, int d, int e) {
if ((a > 0) && (b > 0) && (c > 0) && (d > 0) && (e > 0)) {
return 1;
}
return 0;
}
};
class C : public A, public B {
public:
virtual int foo(int a, int b, int c, int d, int e) {
return A::foo(a,b,c,d,e);
}
virtual int bar(int a, int b, int c, int d, int e) {
return B::bar(a,b,c,d,e);
}
};
class D : public C {
public:
public:
virtual int foo(int a, int b, int c, int d, int e) {
return C::foo(a,b,c,d,e);
}
virtual int bar(int a, int b, int c, int d, int e) {
return C::bar(a,b,c,d,e);
}
};
%}
|