5 extern int gcd(int x, int y);
6 extern int gcdmain(int argc, char *argv[]);
7 extern int count(char *bytes, int len, char c);
8 extern void capitalize (char *str, int len);
9 extern void circle (double cx, double cy);
10 extern int squareCubed (int n, int *OUTPUT);
16 extern int gcd(int x, int y);
18 %typemap(in) (int argc, char *argv[]) {
21 if (!SCHEME_VECTORP($input)) {
22 scheme_wrong_type("$name","vector",$argnum,argc,argv);
24 $1 = SCHEME_VEC_SIZE($input);
25 elms = SCHEME_VEC_ELS($input);
27 scheme_wrong_type("$name","vector",$argnum,argc,argv);
29 $2 = (char **) malloc(($1+1)*sizeof(char *));
30 for (i = 0; i < $1; i++) {
31 if (!SCHEME_STRINGP(elms[i])) {
33 scheme_wrong_type("$name","vector",$argnum,argc,argv);
35 $2[i] = SCHEME_STR_VAL(elms[i]);
40 %typemap(freearg) (int argc, char *argv[]) {
43 extern int gcdmain(int argc, char *argv[]);
45 %typemap(in) (char *bytes, int len) {
46 if (!SCHEME_STRINGP($input)) {
47 scheme_wrong_type("$name","string",1,argc,argv);
49 $1 = SCHEME_STR_VAL($input);
50 $2 = SCHEME_STRLEN_VAL($input);
53 extern int count(char *bytes, int len, char c);
56 /* This example shows how to wrap a function that mutates a string */
58 %typemap(in) (char *str, int len) {
59 if (!SCHEME_STRINGP($input)) {
60 scheme_wrong_type("$name","string",1,argc,argv);
62 $2 = SCHEME_STRLEN_VAL($input);
63 $1 = (char *) malloc($2+1);
64 memmove($1,SCHEME_STR_VAL($input),$2);
67 /* Return the mutated string as a new object. */
69 %typemap(argout) (char *str, int len) {
71 s = scheme_make_sized_string($1,$2,1);
76 extern void capitalize(char *str, int len);
78 /* A multi-valued constraint. Force two arguments to lie
79 inside the unit circle */
81 %typemap(check) (double cx, double cy) {
82 double a = $1*$1 + $2*$2;
84 SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle");
89 extern void circle(double cx, double cy);