| 1 | /* Based on example.c from SWIG docs */ |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | |
| 5 | #include "example.h" |
| 6 | |
| 7 | namespace fanos { |
| 8 | |
| 9 | int fact(int n) { |
| 10 | if (n < 0){ /* This should probably return an error, but this is simpler */ |
| 11 | return 0; |
| 12 | } |
| 13 | if (n == 0) { |
| 14 | return 1; |
| 15 | } |
| 16 | else { |
| 17 | /* testing for overflow would be a good idea here */ |
| 18 | return n * fact(n-1); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | int add(int x, int y) { |
| 23 | return x + y; |
| 24 | } |
| 25 | |
| 26 | void send(int fd, Str* s) { |
| 27 | printf("hi\n"); |
| 28 | } |
| 29 | |
| 30 | } |