OILS / demo / swig / example.cc View on Github | oilshell.org

30 lines, 14 significant
1/* Based on example.c from SWIG docs */
2
3#include <stdio.h>
4
5#include "example.h"
6
7namespace fanos {
8
9int 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
22int add(int x, int y) {
23 return x + y;
24}
25
26void send(int fd, Str* s) {
27 printf("hi\n");
28}
29
30}